/* Cost Warehouse - Clean, professional auto parts storefront */

:root {
  --primary: #1a5632;
  --primary-dark: #143d24;
  --primary-light: #e8f5ec;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --bg: #ffffff;
  --bg-alt: #f9fafb;
  --border: #e5e7eb;
  --accent: #c2410c;
  --success: #059669;
  --radius: 6px;
  --radius-lg: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.07), 0 4px 6px rgba(0,0,0,0.05);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --max-w: 1200px;
  --header-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 0.75rem; line-height: 1.25; font-weight: 600; }
h1 { font-size: clamp(1.75rem, 3vw, 2.25rem); }
h2 { font-size: clamp(1.4rem, 2.5vw, 1.75rem); }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

ul, ol { margin: 0 0 1rem; padding-left: 1.5rem; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--primary); color: #fff; padding: 0.5rem 1rem;
  border-radius: var(--radius);
}
.skip:focus { top: 0.5rem; }

.wrap { max-width: var(--max-w); margin: 0 auto; padding: 0 1.25rem; }

/* Top Bar */
.top-bar {
  background: var(--primary-dark);
  color: #fff;
  font-size: 0.85rem;
}
.top-bar-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 1.25rem;
}
.top-bar a { color: #fff; }
.top-bar a:hover { text-decoration: underline; }

@media (max-width: 640px) {
  .top-bar-inner { flex-direction: column; gap: 0.25rem; text-align: center; }
}

/* Header */
.site-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-inner {
  display: flex;
  align-items: center;
  height: var(--header-h);
  gap: 1.5rem;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.logo:hover { text-decoration: none; }
.main-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-left: 1.5rem;
}
.main-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
}
.main-nav a:hover,
.main-nav a[aria-current="page"] { color: var(--text); text-decoration: none; }

.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.cart-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius);
}
.cart-btn:hover { background: var(--bg-alt); text-decoration: none; }
.cart-btn svg { width: 20px; height: 20px; }
.cart-count {
  background: var(--primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  min-width: 1.25rem;
  text-align: center;
}
.mobile-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}
.mobile-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}
.mobile-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.mobile-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.mobile-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 768px) {
  .main-nav { display: none; }
  .mobile-toggle { display: flex; }
}

/* Mobile Menu */
.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: calc(var(--header-h) + 1rem) 1.5rem 2rem;
  gap: 0.25rem;
}
.mobile-menu[hidden] { display: none; }
.mobile-menu a {
  display: block;
  padding: 0.75rem 0;
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}
.mobile-menu a:hover { color: var(--primary); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn { background: var(--primary); color: #fff; }
.btn:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-lg { padding: 0.8rem 2rem; font-size: 1rem; }

/* Hero */
.hero {
  background: var(--bg-alt);
  padding: 3rem 0;
}
.hero-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  align-items: center;
}
.hero-content h1 { font-size: clamp(2rem, 4vw, 2.75rem); margin-bottom: 1rem; }
.hero-sub { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 1.5rem; max-width: 40ch; }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.hero-trust { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.trust-badge {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.hero-image img {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

@media (max-width: 768px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-image { order: -1; }
  .hero { padding: 2rem 0; }
}

/* Categories */
.categories { padding: 3rem 0; }
.categories h2 { margin-bottom: 1.5rem; }
.cat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
}
.cat-card {
  text-decoration: none;
  color: var(--text);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: box-shadow 0.2s;
}
.cat-card:hover { box-shadow: var(--shadow-md); text-decoration: none; }
.cat-card img { width: 100%; height: 140px; object-fit: cover; }
.cat-card-body { padding: 0.75rem; }
.cat-card-body h3 { font-size: 0.95rem; margin-bottom: 0.25rem; }
.cat-card-body p { font-size: 0.8rem; color: var(--text-muted); margin: 0; }

@media (max-width: 900px) { .cat-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .cat-grid { grid-template-columns: repeat(2, 1fr); } }

/* Featured / Product Grid */
.featured { padding: 3rem 0; background: var(--bg-alt); }
.featured h2 { margin-bottom: 1.5rem; }
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}
.product-card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: box-shadow 0.2s;
}
.product-card:hover { box-shadow: var(--shadow-md); }
.product-card a { text-decoration: none; color: inherit; }
.product-card img { width: 100%; aspect-ratio: 1/1; object-fit: cover; }
.product-card-body { padding: 0.85rem; }
.product-sku {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: "SF Mono", "Consolas", monospace;
  margin: 0 0 0.25rem;
}
.product-card-body h3 {
  font-size: 0.95rem;
  margin: 0 0 0.25rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card-body h3 a:hover { color: var(--primary); }
.product-spec { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 0.35rem; }
.product-price { font-weight: 700; font-size: 1.05rem; color: var(--text); margin: 0; }

.center-btn { text-align: center; margin-top: 2rem; }

@media (max-width: 1024px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .product-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .product-grid { grid-template-columns: 1fr; } }

/* Trust Section */
.trust-section { padding: 3rem 0; }
.trust-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
}
.trust-item { text-align: center; }
.trust-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.trust-item h3 { font-size: 1rem; margin-bottom: 0.35rem; }
.trust-item p { font-size: 0.9rem; color: var(--text-muted); margin: 0; }

@media (max-width: 768px) { .trust-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .trust-grid { grid-template-columns: 1fr; } }

/* Page */
.page { padding: 2rem 0 3rem; }
.page-sub { color: var(--text-muted); margin-bottom: 1rem; }

/* Breadcrumb */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }

/* Search */
.search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.search-form input {
  flex: 1;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
}
.search-form input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 2px var(--primary-light); }

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  background: var(--bg);
  transition: all 0.15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.chip[aria-current="page"] {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Product Detail */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2.5rem;
  margin-bottom: 3rem;
}
.product-gallery img { border-radius: var(--radius-lg); }
.product-info h1 { font-size: 1.6rem; margin-bottom: 0.5rem; }
.product-sku { font-size: 0.8rem; color: var(--text-muted); font-family: monospace; margin: 0 0 0.5rem; }
.product-spec-large { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 0.75rem; }
.product-rating { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.stars { color: #f59e0b; font-size: 1rem; letter-spacing: 1px; }
.rating-text { font-size: 0.85rem; color: var(--text-muted); }
.product-price-large { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.75rem; }
.product-desc { color: var(--text-muted); margin-bottom: 1.25rem; }
.qty-row { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.qty-row label { font-weight: 600; font-size: 0.9rem; }
.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.qty button {
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  background: var(--bg-alt);
  cursor: pointer;
  font-size: 1.1rem;
}
.qty button:hover { background: var(--border); }
.qty input {
  width: 3rem;
  height: 2.5rem;
  border: none;
  text-align: center;
  background: var(--bg);
  font-size: 0.95rem;
}
.product-meta { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.product-meta p { font-size: 0.9rem; margin-bottom: 0.35rem; }

@media (max-width: 768px) {
  .product-detail { grid-template-columns: 1fr; gap: 1.5rem; }
}

/* Reviews */
.reviews-section { margin-bottom: 3rem; }
.reviews-section h3 { margin-bottom: 1rem; }
.reviews-list { display: grid; gap: 1rem; }
.review {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-alt);
}
.review-header { display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; margin-bottom: 0.35rem; }
.review-name { font-weight: 600; font-size: 0.9rem; }
.review-loc { font-size: 0.8rem; color: var(--text-muted); }
.review-date { font-size: 0.8rem; color: var(--text-muted); margin-left: auto; }
.review-stars { margin-bottom: 0.35rem; }
.review-text { font-size: 0.9rem; color: var(--text); margin: 0; }

/* Related */
.related-section { margin-top: 2rem; }
.related-section h2 { margin-bottom: 1rem; }

/* Cart */
.cart-list { display: grid; gap: 0.75rem; margin-top: 1.25rem; }
.cart-item {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  align-items: center;
}
.cart-item img { width: 80px; height: 80px; object-fit: cover; border-radius: var(--radius); }
.cart-item-info h3 { font-size: 0.95rem; margin-bottom: 0.25rem; }
.cart-item-info h3 a { color: var(--text); }
.cart-item-info h3 a:hover { color: var(--primary); }
.cart-item-price { font-weight: 600; }
.cart-item-remove {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
}
.cart-summary { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.summary-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.5rem; }
.summary-row strong { font-size: 1.25rem; }
.summary-note { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem; }
.cart-summary .btn { margin-bottom: 0.5rem; }
.cart-summary .btn-outline { display: block; text-align: center; }
.undo { margin-top: 0.75rem; }

/* Checkout */
.checkout-wrap { max-width: 960px; }
.checkout-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 2rem;
  margin-top: 1.5rem;
}
.checkout-form h2 { font-size: 1.15rem; margin-top: 1.5rem; margin-bottom: 0.75rem; }
.checkout-form h2:first-child { margin-top: 0; }
.checkout-sidebar {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  height: fit-content;
  position: sticky;
  top: calc(var(--header-h) + 1rem);
}
.checkout-sidebar h2 { font-size: 1.05rem; margin-bottom: 0.75rem; }
.checkout-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  padding: 0.35rem 0;
}
.checkout-trust { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.checkout-trust p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.35rem; }

@media (max-width: 768px) {
  .checkout-grid { grid-template-columns: 1fr; }
  .checkout-sidebar { position: static; }
}

/* Forms */
label { display: block; font-weight: 500; font-size: 0.9rem; margin-bottom: 0.25rem; }
input, select, textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px var(--primary-light);
}
input::placeholder, textarea::placeholder { color: #9ca3af; }
textarea { min-height: 100px; resize: vertical; }
.err { min-height: 1.2em; margin: -0.5rem 0 0.5rem; color: var(--accent); font-size: 0.8rem; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 640px) { .row-2 { grid-template-columns: 1fr; } }

/* Prose */
.prose-page { max-width: 720px; margin: 0 auto; }
.prose-page .lead { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.prose-page h2 { margin-top: 2rem; }
.prose-page ul, .prose-page ol { color: var(--text-muted); }
.prose-page table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
.prose-page th, .prose-page td { padding: 0.6rem 0.75rem; border: 1px solid var(--border); text-align: left; font-size: 0.9rem; }
.prose-page th { background: var(--bg-alt); font-weight: 600; }

/* Contact */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 2rem;
  margin-top: 1.5rem;
}
.contact-info h2 { margin-bottom: 0.75rem; }
.contact-info h3 { margin-top: 1.25rem; margin-bottom: 0.5rem; }
.contact-info p { font-size: 0.95rem; }
.contact-form-wrap h2 { margin-bottom: 0.75rem; }
.stack { display: grid; gap: 0.25rem; }

@media (max-width: 768px) {
  .contact-grid { grid-template-columns: 1fr; }
}

/* Empty */
.empty { color: var(--text-muted); padding: 2rem 0; }

/* Footer */
.site-footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 2.5rem 0 1.5rem;
  margin-top: 3rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}
.footer-brand strong { font-size: 1.1rem; display: block; margin-bottom: 0.5rem; }
.footer-brand p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.footer-links { list-style: none; padding: 0; margin: 0; }
.footer-links li { margin-bottom: 0.35rem; }
.footer-links a { color: var(--text-muted); font-size: 0.9rem; }
.footer-links a:hover { color: var(--text); }
.site-footer h4 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 0.75rem; }
.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 1rem;
}
.payment-icons { display: flex; gap: 0.5rem; align-items: center; }

@media (max-width: 768px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-bottom { flex-direction: column; text-align: center; }
}
@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
}

/* Order page */
#order-root { max-width: 600px; }
