:root {
  --brand-blue: #273BA3;
  --brand-red: #C22F1B;
  --brand-yellow: #F2EA51;
  --brand-dark: #1B2450;
  --brand-cream: #faf8f3;
  --ink: #2b2a28;
  --muted: #6b6659;
  --border: #e7e3d8;
  --success: #2f7d4f;
  --warn: #b8842c;
  --danger: #b8342c;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--brand-cream); color: var(--ink); line-height: 1.5; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header { background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.site-header .bar { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; max-width: 1180px; margin: 0 auto; gap: 20px; position: relative; }
.brand { font-size: 22px; font-weight: 800; color: var(--brand-blue); letter-spacing: -0.5px; display: flex; align-items: center; flex-shrink: 0; }
.brand-logo { height: 42px; max-width: 200px; object-fit: contain; }
.brand span { color: var(--brand-red); }

/* Nav + search + RFQ button are grouped so they collapse together into one
   dropdown on small screens (see the media query below) — cart and the
   hamburger button stay outside this group, always visible, since those are
   the two things a mobile shopper needs reachable without opening a menu. */
.nav-collapse { display: flex; align-items: center; gap: 24px; }
.main-nav { display: flex; gap: 24px; font-weight: 600; font-size: 14.5px; }
.main-nav a:hover { color: var(--brand-red); }
.header-search { display: flex; }
.header-search input { border: 1px solid var(--border); border-radius: 6px 0 0 6px; padding: 9px 12px; font-size: 14px; width: 220px; }
.header-search button { border: none; background: var(--brand-red); color: #fff; padding: 0 14px; border-radius: 0 6px 6px 0; cursor: pointer; }
.cta-quote { background: var(--brand-dark); color: #fff !important; padding: 9px 16px; border-radius: 6px; font-weight: 700; white-space: nowrap; }
.header-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.cart-link { position: relative; font-weight: 600; font-size: 14.5px; padding: 9px 4px; color: var(--ink); white-space: nowrap; }
.cart-badge { display: inline-block; background: var(--brand-red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 20px; padding: 1px 7px; margin-left: 3px; }

/* Hamburger — hidden on desktop, shown only under the mobile breakpoint below. */
.nav-toggle { display: none; flex-direction: column; justify-content: center; gap: 5px; width: 34px; height: 34px; padding: 6px; background: none; border: none; cursor: pointer; }
.nav-toggle span { display: block; width: 100%; height: 2px; background: var(--ink); border-radius: 2px; transition: transform 0.15s, opacity 0.15s; }
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.cart-table-wrap { width: 100%; overflow-x: auto; }
.cart-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.cart-table th { text-align: left; font-size: 12.5px; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--border); }
.cart-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 14.5px; }
.cart-inquiry-form { max-width: 480px; margin-top: 36px; padding-top: 30px; border-top: 1px solid var(--border); }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Hero */
.hero { background: linear-gradient(135deg, #fff 0%, var(--brand-cream) 100%); padding: 56px 0; border-bottom: 1px solid var(--border); }
.hero .container { display: flex; align-items: center; gap: 40px; flex-wrap: wrap; }
.hero-copy { flex: 1; min-width: 280px; }
.hero-copy h1 { font-size: 34px; line-height: 1.2; margin: 0 0 16px; }
.hero-copy p { color: var(--muted); font-size: 16px; margin-bottom: 22px; max-width: 480px; }
.btn { display: inline-block; padding: 12px 24px; background: var(--brand-red); color: #fff; border-radius: 8px; font-weight: 700; border: none; cursor: pointer; font-size: 15px; }
.btn.secondary { background: transparent; border: 2px solid var(--brand-dark); color: var(--brand-dark); }
.hero-image { flex: 1; min-width: 280px; }
.hero-image img { border-radius: 14px; }

/* Page banner (About Us / Contact) */
.page-banner { width: 100%; max-height: 280px; overflow: hidden; border-bottom: 1px solid var(--border); }
.page-banner img { width: 100%; height: 280px; object-fit: cover; display: block; }

/* Section titles */
.section { padding: 48px 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 22px; }
.section-title h2 { font-size: 24px; margin: 0; }
.section-title a { color: var(--brand-red); font-weight: 600; font-size: 14px; }

/* Category grid */
.cat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.cat-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px 14px; text-align: center; font-weight: 700; font-size: 14px; transition: 0.15s; }
.cat-card:hover { border-color: var(--brand-red); color: var(--brand-red); transform: translateY(-2px); }
.cat-card img { width: 96px; height: 96px; object-fit: cover; margin: 0 auto 10px; border-radius: 8px; }

/* Product grid */
.product-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.product-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; transition: 0.15s; }
.product-card:hover { box-shadow: 0 6px 18px rgba(0,0,0,0.08); transform: translateY(-2px); }
.product-card .thumb { aspect-ratio: 1; background: #f6f4ee; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-card .info { padding: 12px 14px 16px; }
.product-card .name { font-weight: 700; font-size: 14.5px; margin-bottom: 4px; min-height: 38px; }
.product-card .price { color: var(--brand-red); font-weight: 800; font-size: 15px; margin-bottom: 6px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 20px; text-transform: uppercase; letter-spacing: 0.3px; }
.badge-instock { background: #e5f4ea; color: var(--success); }
.badge-lowstock { background: #fbf0dc; color: var(--warn); }
.badge-outofstock { background: #fbe6e4; color: var(--danger); }
.badge-preorder { background: #e6eefc; color: #3163b8; }

/* Filters bar */
.filters-bar { display: flex; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.category-filter { position: relative; }
.filter-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { border: 1px solid var(--border); padding: 7px 14px; border-radius: 20px; font-size: 13.5px; font-weight: 600; background: #fff; }
.pill.active { background: var(--brand-dark); color: #fff; border-color: var(--brand-dark); }

/* The dropdown toggle button only appears under the mobile breakpoint below
   — on desktop the pills row above renders inline exactly as it always
   has, and this button stays hidden. */
.category-filter-toggle { display: none; width: 100%; align-items: center; justify-content: space-between; gap: 10px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 11px 14px; font-size: 14.5px; font-weight: 700; color: var(--ink); cursor: pointer; }
.category-filter-toggle .chevron { flex-shrink: 0; transition: transform 0.15s; color: var(--muted); }
.category-filter-toggle.open .chevron { transform: rotate(180deg); }

/* Product detail */
.pd-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; padding: 40px 0; }
.pd-gallery-main { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; aspect-ratio: 1; background: #fff; margin-bottom: 12px; }
.pd-gallery-main img { width: 100%; height: 100%; object-fit: contain; }
.pd-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.pd-thumbs img { width: 66px; height: 66px; object-fit: cover; border-radius: 8px; border: 2px solid var(--border); cursor: pointer; }
.pd-thumbs img.active { border-color: var(--brand-red); }
.pd-info h1 { font-size: 26px; margin: 0 0 10px; }
.pd-price { font-size: 26px; font-weight: 800; color: var(--brand-red); margin: 14px 0; }
.pd-meta { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.variant-group { margin: 18px 0; }
.variant-group label { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); display: block; margin-bottom: 8px; }
.variant-options { display: flex; gap: 8px; flex-wrap: wrap; }
.variant-option { border: 1.5px solid var(--border); padding: 8px 16px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; background: #fff; }
.variant-option.selected { border-color: var(--brand-red); background: #fdeceb; color: var(--brand-red); }
.pd-specs { margin-top: 28px; border-top: 1px solid var(--border); padding-top: 20px; }
.pd-specs table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pd-specs td { padding: 6px 0; border-bottom: 1px solid var(--border); }
.pd-specs td:first-child { color: var(--muted); width: 40%; }
.pd-description ul { padding-left: 20px; }

/* Contact */
.contact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; padding: 40px 0; }
.contact-info div { margin-bottom: 20px; }
.contact-info h4 { margin: 0 0 6px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; }
.form-field { margin-bottom: 14px; }
.form-field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.form-field input, .form-field textarea, .form-field select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px; font-family: inherit; }
.map-embed iframe { width: 100%; height: 260px; border: 0; border-radius: 10px; }
.alert-success { background: #e5f4ea; color: var(--success); padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 600; }

/* Footer */
.site-footer { background: var(--brand-dark); color: #cfcdc7; padding: 40px 0 24px; margin-top: 60px; }
.site-footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 30px; }
.site-footer h5 { color: #fff; margin: 0 0 10px; }
.site-footer .copyright { text-align: center; margin-top: 30px; font-size: 13px; color: #8b8880; }

/* "Switch to Desktop/Mobile Site" toggle — see middleware/siteView.js. */
.site-view-switch { display: flex; align-items: center; gap: 8px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }
.site-view-switch-label { font-size: 12.5px; color: #8b8880; }
.site-view-pill { font-size: 12.5px; font-weight: 600; padding: 5px 14px; border-radius: 20px; border: 1px solid #454d7a; color: #cfcdc7 !important; }
.site-view-pill.active { background: #fff; color: var(--brand-dark) !important; border-color: #fff; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 100; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 28px; width: 420px; max-width: 90vw; }
.modal h3 { margin-top: 0; }
.modal-close { float: right; cursor: pointer; font-size: 20px; color: var(--muted); }

@media (max-width: 900px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .pd-wrap, .contact-grid { grid-template-columns: 1fr; }

  /* Collapse nav + search + Upload RFQ into a dropdown under the header,
     opened by the hamburger button (see the inline script in header.ejs).
     Cart stays visible in the bar the whole time. */
  .nav-toggle { display: flex; }
  .nav-collapse {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    background: #fff;
    padding: 18px 20px 22px;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 20px rgba(0,0,0,0.08);
  }
  .nav-collapse.open { display: flex; }
  .main-nav { flex-direction: column; gap: 16px; font-size: 16px; }
  .header-search input { width: auto; flex: 1; }
  .cta-quote { text-align: center; }
}

@media (max-width: 640px) {
  .hero { padding: 36px 0; }
  .hero-copy h1 { font-size: 26px; }
  .hero-copy p { font-size: 15px; }

  .filters-bar { flex-direction: column; align-items: stretch; }
  .filters-bar form { width: 100%; }
  .filters-bar form input { flex: 1; width: auto; }

  /* Category bubbles get jarring once they wrap across several lines on a
     phone, so below this width they're tucked behind a single toggle
     button and open as a floating dropdown panel instead. */
  .category-filter-toggle { display: flex; }
  .filter-pills {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 40;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 4px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    max-height: 60vh;
    overflow-y: auto;
    box-shadow: 0 12px 24px rgba(0,0,0,0.12);
  }
  .filter-pills.open { display: flex; }
  .filter-pills .pill { border-radius: 8px; padding: 10px 12px; text-align: left; border-color: transparent; }
  .filter-pills .pill:not(.active):hover { background: var(--brand-cream); }

  .cart-inquiry-form { max-width: none; }

  /* Qty input + Add to Inquiry button need to wrap rather than overflow
     on a narrow phone. */
  .pd-actions { flex-wrap: wrap; }
}

@media (max-width: 420px) {
  .product-grid { grid-template-columns: 1fr; }
}
