/* ==========================================================================
   Mobile adaptation layer
   --------------------------------------------------------------------------
   Appended after the desktop design system on purpose: the desktop rules above
   stay untouched, and everything here only takes effect on small viewports.

   Problems this solves (measured on the live site at 375/390px):
     1. the header nav (5 links + currency + cart) forced the document to
        740px wide — a horizontal scroll on every single page
     2. .spec / .cart-table tables overflowed their container
     3. most tap targets were shorter than the 44px touch guideline
     4. section padding and type were sized for a 1240px desktop
   ========================================================================== */

/* ---------- Mobile drawer toggle (hidden on desktop) ---------- */

.burger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-right: -10px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--ink);
  flex: none;
  /* above the drawer (z-index 100) so it stays tappable when open */
  position: relative;
  z-index: 120;
}
.burger span {
  display: block;
  position: relative;
  width: 21px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: background .2s ease;
}
.burger span::before,
.burger span::after {
  content: "";
  position: absolute;
  left: 0;
  width: 21px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: transform .22s ease, top .22s ease;
}
.burger span::before { top: -7px; }
.burger span::after { top: 7px; }

/* open state → the three bars become an X */
body.nav-open .burger span { background: transparent; }
body.nav-open .burger span::before { top: 0; transform: rotate(45deg); }
body.nav-open .burger span::after { top: 0; transform: rotate(-45deg); }

/* ---------- Scrim behind the drawer ---------- */

.nav-scrim {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: rgba(20, 24, 42, .48);
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s ease;
  z-index: 90;
}
body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }

/* <header> is sticky with z-index 60, so it forms its own stacking
   context — a z-index on the burger alone cannot lift it above the
   scrim (z-index 90), which is a child of <body>. While the drawer is
   open the header has to sit on top, otherwise the X button cannot be
   tapped and the drawer cannot be closed. */
body.nav-open header {
  z-index: 130;
}
body.nav-open header .burger {
  color: var(--ink);
}

/* ---------- The drawer ---------- */

@media (max-width: 900px) {
  .nav-scrim { display: block; }

  /* header row keeps brand + burger on one line.
     The blur is dropped on purpose: backdrop-filter creates a containing
     block for fixed descendants, which would anchor the drawer to the
     header instead of the viewport. It also costs GPU time on a phone. */
  header {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--cream);
  }
  .head {
    height: 60px;
    gap: 12px;
    justify-content: space-between;
  }
  .head .brand { margin-right: auto; }

  .burger { display: inline-flex; }

  /* the desktop nav becomes the drawer.
     height is set explicitly (not via top+bottom) because the nav is a flex
     child of .head, and a fixed element still inherits the parent's layout
     constraints — sizing it by both top and bottom left it 108px tall. */
  nav.primary {
    position: fixed;
    top: 0;
    right: 0;
    /* -1px pulls the drawer over the sticky header, whose top offset would
       otherwise push the drawer down by the header height */
    margin-top: -1px;
    height: 100vh;
    height: 100dvh;
    z-index: 100;
    width: min(320px, 86vw);
    margin: 0;
    padding: 76px 22px 32px;
    background: var(--cream);
    border-left: 1px solid var(--line);
    box-shadow: -12px 0 40px rgba(20, 24, 42, .18);
    flex-direction: column;
    gap: 0;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform .26s cubic-bezier(.4, 0, .2, 1);
    visibility: hidden;
  }
  body.nav-open nav.primary {
    transform: translateX(0);
    visibility: visible;
  }

  nav.primary a {
    display: block;
    font-size: 16px;
    font-weight: 600;
    padding: 15px 2px;
    min-height: 50px;
    border-bottom: 1px solid var(--line-soft);
    color: var(--ink);
  }
  nav.primary a:hover { text-decoration: none; color: var(--accent); border-bottom-color: var(--accent); }
  nav.primary a:last-child { border-bottom: none; }

  /* drawer footer: language + currency + cart all reachable on mobile */
  nav.primary::after {
    content: "";
    display: block;
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid var(--line-soft);
  }

  /* currency select, language switch and cart button all move into the
     drawer on mobile — nothing is left behind in the header bar, so the
     burger is the only thing the header row contains */
  .head-actions { display: none; }
}

/* The drawer needs its own copy of the language switcher and cart.
   They are rendered by JS into .nav-extra so the markup stays in one place.
   The default (hidden) rule must come first, otherwise it would override
   the display:block set inside the media query below. */
.nav-extra { display: none; }

@media (max-width: 900px) {
  .nav-extra { display: block; }
  .nav-extra .lang-switch { margin-bottom: 14px; }
  .nav-extra .lang-switch a { padding: 11px 14px; font-size: 13px; }
  .nav-extra .cart-btn {
    display: inline-flex;
    width: 100%;
    justify-content: center;
    padding: 13px 16px;
    font-size: 14px;
    background: var(--indigo);
    border-color: var(--indigo);
    color: #fff;
  }
  .nav-extra .cart-btn:hover { background: var(--indigo-deep); border-color: var(--indigo-deep); }
}

/* ---------- Tables scroll instead of pushing the page wide ---------- */

.table-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  margin: 0 0 26px;
  /* keep the rounded corners of the card look tidy */
  border-radius: var(--radius);
}
.table-scroll > table {
  min-width: 460px;
  margin-bottom: 0;
}
.table-scroll::-webkit-scrollbar { height: 6px; }
.table-scroll::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 3px;
}
.table-scroll::-webkit-scrollbar-track { background: transparent; }

/* Spec tables carry long values (file names, addresses). Scrolling sideways
   for them is worse than reading them stacked, so on a phone every row
   becomes a labelled block. */
@media (max-width: 760px) {
  .table-scroll:has(> .spec) { overflow-x: visible; }
  .table-scroll > .spec {
    min-width: 0;
    width: 100%;
    display: block;
  }
  .table-scroll > .spec thead { display: none; }
  .table-scroll > .spec tbody,
  .table-scroll > .spec tr,
  .table-scroll > .spec td { display: block; width: 100%; }
  .table-scroll > .spec tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .table-scroll > .spec tr:last-child { border-bottom: none; }
  .table-scroll > .spec td {
    border: none;
    padding: 3px 0;
    display: flex;
    gap: 14px;
    align-items: baseline;
    line-height: 1.55;
  }
  .table-scroll > .spec td::before {
    content: attr(data-label);
    flex: none;
    width: 34%;
    max-width: 130px;
    font-size: 11px;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #8b8578;
    font-weight: 700;
  }
  .table-scroll > .spec td > * { min-width: 0; overflow-wrap: anywhere; }
  .table-scroll > .spec code { overflow-wrap: anywhere; }
}

/* Key/value spec tables (no <thead>): each row is already a label + value
   pair, so on a phone the <th> becomes the label sitting above the value. */
@media (max-width: 760px) {
  .table-scroll > .spec:has(> tbody > tr > th) {
    min-width: 0;
    width: 100%;
    display: block;
  }
  .table-scroll > .spec:has(> tbody > tr > th) tbody,
  .table-scroll > .spec:has(> tbody > tr > th) tr { display: block; width: 100%; }
  .table-scroll > .spec:has(> tbody > tr > th) td {
    display: block;
    width: 100%;
    border: none;
    padding: 0 0 4px 0;
  }
  .table-scroll > .spec:has(> tbody > tr > th) td::before { display: none; }
  .table-scroll > .spec:has(> tbody > tr > th) th {
    display: block;
    width: 100%;
    padding: 0 0 4px 0;
    border: none;
    font-size: 11px;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #8b8578;
    font-weight: 700;
  }
  .table-scroll > .spec:has(> tbody > tr > th) tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .table-scroll > .spec:has(> tbody > tr > th) tr:last-child { border-bottom: none; }
}

/* The cart table is a different beast: on a phone each row becomes a card
   rather than a sideways-scrolling strip, because a cart is scanned by
   reading, not by comparing columns. */
@media (max-width: 760px) {
  .table-scroll:has(> .cart-table) { overflow-x: visible; }
  .table-scroll > .cart-table {
    min-width: 0;
    width: 100%;
    display: block;
  }
  .table-scroll > .cart-table thead { display: none; }
  .table-scroll > .cart-table tbody,
  .table-scroll > .cart-table tr,
  .table-scroll > .cart-table td { display: block; width: 100%; }
  .table-scroll > .cart-table tr {
    padding: 14px 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .table-scroll > .cart-table tr:last-child { border-bottom: none; }
  .table-scroll > .cart-table td {
    padding: 0;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
  }
  .table-scroll > .cart-table td::before {
    content: attr(data-label);
    font-size: 11px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #8b8578;
    font-weight: 700;
    flex: none;
  }
  /* the product cell stacks the thumbnail and the name */
  .table-scroll > .cart-table td:first-child { display: block; }
  .table-scroll > .cart-table td:first-child::before { display: none; }
  .table-scroll > .cart-table .cart-item { margin-bottom: 8px; }
}

/* ---------- Typography & rhythm on small screens ---------- */

@media (max-width: 760px) {
  body { font-size: 15px; }

  .wrap { padding: 0 18px; }

  /* announcement bar: keep it readable instead of one long clipped line */
  .announce {
    font-size: 11.5px;
    line-height: 1.5;
    padding: 8px 18px;
    text-align: left;
  }

  h1 { font-size: clamp(1.75rem, 8.5vw, 2.4rem); }
  h2 { font-size: clamp(1.35rem, 6.6vw, 1.7rem); }
  h3 { font-size: 1.12rem; }

  section { padding: 46px 0; }
  .legal { padding: 36px 0 48px; }
  .legal h2 { font-size: 22px; }
  .legal h3 { margin-top: 26px; }
  .legal .meta { padding-bottom: 16px; margin-bottom: 22px; }

  .sec-head { margin-bottom: 30px; }
  .sec-head p { font-size: 15px; }

  .hero { padding: 52px 0 58px; }
  .hero .eyebrow { font-size: 10.5px; letter-spacing: .18em; margin-bottom: 12px; }
  .hero p.lede { font-size: 15.5px; line-height: 1.7; }
  .hero .cta { gap: 10px; margin-top: 24px; }
  .hero .btn { flex: 1 1 auto; min-width: 140px; justify-content: center; padding: 13px 18px; }

  /* stats row becomes a 2-column grid instead of a wide flex row */
  .hero-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 16px;
    margin-top: 34px;
    padding-top: 22px;
  }
  .hero-stats .st b { font-size: 19px; }

  .btn { padding: 11px 16px; min-height: 44px; }
  .btn.block { width: 100%; }
  .btn.sm { min-height: 40px; }

  .filterbar { padding: 14px 0 20px; margin-bottom: 24px; gap: 8px; }
  .filterbar .chip { padding: 9px 14px; min-height: 40px; display: inline-flex; align-items: center; }
  .filterbar .count { margin-left: 0; width: 100%; }

  .feature { padding: 20px 18px; }
  .grid { gap: 18px; }

  .card .body { padding: 14px 15px 16px; }
  .card h3 { font-size: 15.5px; }
  .card .price { font-size: 18px; }

  .checklist li { padding: 10px 0 10px 28px; font-size: 14px; }

  .pdp { gap: 26px; }
  .pdp .price { font-size: 25px; }
  .pdp .price-row { margin: 16px 0; }
  .pdp .desc { font-size: 14.5px; }

  .qty button { width: 44px; height: 44px; }
  .qty input { width: 52px; height: 44px; font-size: 16px; }

  .spec { font-size: 13.5px; }
  .spec th { width: 40%; }
  .spec th, .spec td { padding: 10px 8px 10px 0; }

  .accordion summary { padding: 16px 0; font-size: 14.5px; min-height: 48px; }
  .faq-item summary { padding: 16px 0; font-size: 14.5px; min-height: 48px; gap: 14px; }
  .faq-item .a { padding: 0 24px 18px 0; font-size: 14px; }

  .toc { padding: 16px 18px; margin-bottom: 26px; }
  .toc ol { font-size: 13px; }

  .trust { padding: 24px 0; }
  .trust-grid { grid-template-columns: 1fr; gap: 20px; }
  .trust .t-item b { font-size: 13.5px; }

  /* the cart page used an inline grid-template-columns, which no media
     query can override — it is now a class so it can collapse here */
  .cart-layout { grid-template-columns: 1fr !important; gap: 24px !important; }

  /* the drawer language switch was only 35px tall — make it a proper
     tap target */
  .nav-extra .lang-switch a {
    padding: 13px 18px;
    min-height: 46px;
    font-size: 13.5px;
    display: inline-flex;
    align-items: center;
  }
  .nav-extra .select {
    width: 100%;
    min-height: 46px;
    font-size: 14px;
    padding: 12px 12px;
    margin-bottom: 12px;
  }
  .nav-extra .cart-btn { min-height: 48px; }

  .summary { padding: 20px 18px; }
  .sum-row { font-size: 13.5px; }
  .sum-row.total { font-size: 16px; }

  .cart-item { gap: 12px; }
  .cart-item .nm { font-size: 14px; }
  .cart-table .thumb { width: 62px; height: 62px; }

  .searchbox input { max-width: none; font-size: 16px; }  /* 16px stops iOS zoom-on-focus */
  .select { font-size: 13px; min-height: 40px; }

  .thumb-btn { width: 62px; height: 52px; }

  .notice-box { padding: 12px 14px; font-size: 13px; }
  .notice-box a { display: inline-block; padding: 4px 0; }
  .pill { font-size: 11.5px; }

  hr.sep { margin: 28px 0; }
  .breadcrumb { padding: 12px 0; font-size: 12px; }
}

/* ---------- Cart layout ----------
   The cart used to carry grid-template-columns as an inline style, which
   cannot be overridden by a media query. It is a class now so the two
   columns can stack on a phone. */
.cart-layout {
  grid-template-columns: 1.6fr .9fr;
  align-items: start;
  gap: 34px;
}

/* ---------- Footer links get a comfortable tap height ---------- */

@media (max-width: 760px) {
  footer { padding: 40px 0 26px; }
  .foot-grid { gap: 24px; }
  footer li { margin: 0; }
  footer li a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 14px;
  }
  /* the contact email sat at 15px tall — too small to hit reliably */
  footer a[href^="mailto:"] {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 14px;
    overflow-wrap: anywhere;
  }
  footer h4 { margin-bottom: 8px; }
  .foot-legal { margin-top: 30px; padding-top: 20px; font-size: 11.5px; line-height: 1.8; }
  .foot-bottom { font-size: 11.5px; gap: 10px; }
  .lang-row { margin-top: 14px; padding-top: 14px; }
  footer .lang-switch a {
    padding: 13px 18px;
    min-height: 46px;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
  }
  /* the brand link in the footer is a link too */
  footer .brand a { display: inline-flex; align-items: center; min-height: 44px; }
}

/* ---------- Product grid on phones: keep two columns, tighter ---------- */

@media (max-width: 520px) {
  .g2, .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .card .body { padding: 11px 12px 13px; }
  /* the product title is the main tap target on a card — give the link
     enough height to hit without affecting the type size */
  .card h3 a {
    display: inline-block;
    min-height: 22px;
    padding: 2px 0;
  }
  .card .foot .btn { min-height: 40px; }
  .card .line { font-size: 9.5px; }
  .card h3 { font-size: 14px; }
  .card p { font-size: 12px; margin-bottom: 10px; }
  .card .price { font-size: 16px; }
  .card .price .old { font-size: 11.5px; margin-left: 5px; }
  .badge { top: 8px; left: 8px; font-size: 9.5px; padding: 3px 7px; }
  .photo-band { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .photo-band .pb-lg { grid-row: auto; aspect-ratio: 4/3; }

  /* two buttons side by side do not fit a 170px card — stack them and
     let each take the full width */
  .card .foot {
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
    margin-top: 10px;
  }
  .card .foot .btn {
    width: 100%;
    justify-content: center;
    min-height: 40px;
    padding: 9px 10px;
    font-size: 12px;
  }
}

/* Very narrow phones (iPhone SE and older) */
@media (max-width: 380px) {
  .wrap { padding: 0 15px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .hero-stats { grid-template-columns: 1fr; }
  .card p { display: none; }
}

/* ---------- Respect users who ask for less motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  nav.primary, .nav-scrim, .burger span, .burger span::before, .burger span::after {
    transition: none !important;
  }
}
