/* ==========================================================================
   VEXONA — Responsive layout
   Components are mobile-first; this file layers on tablet/desktop layouts and
   holds the intentional mobile-only patterns (stacked tables, filter sheet).
   Breakpoints:  ≥640 (large phone)  ≥768 (tablet)  ≥1024 (laptop)  ≥1280
   ========================================================================== */

/* ---- < 640: phone ------------------------------------------------------- */
@media (max-width: 639.98px) {
  .hero__cta .btn,
  .cta-band .btn {
    width: 100%;
  }

  /* Data tables become labelled cards instead of scrolling sideways */
  .table--stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .table--stack,
  .table--stack tbody,
  .table--stack tr,
  .table--stack td {
    display: block;
    width: 100%;
  }
  .table--stack tr {
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border);
  }
  .table--stack tr:last-child {
    border-bottom: 0;
  }
  .table--stack td {
    display: flex;
    justify-content: space-between;
    gap: var(--space-4);
    padding: 0.35rem var(--space-4);
    border: 0;
    text-align: right;
  }
  .table--stack td::before {
    content: attr(data-label);
    flex: none;
    color: var(--text-subtle);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
  }
  .table--stack .num {
    text-align: right;
  }

  /* Filters become a bottom sheet */
  .filters {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-modal);
    max-height: 86dvh;
    overflow-y: auto;
    padding: 0 var(--gutter); /* no bottom padding: the sticky "Show results" bar owns the bottom edge (else a strip of the list shows beneath it) */
    border: 1px solid var(--border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    transform: translateY(105%);
    visibility: hidden;
    transition: transform var(--dur-slow) var(--ease), visibility 0s linear var(--dur-slow);
  }
  .filters.is-open {
    transform: none;
    visibility: visible;
    transition: transform var(--dur-slow) var(--ease), visibility 0s;
  }
  .filters__head {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-4);
  }
  .filters__backdrop {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-modal) - 1);
    background: var(--overlay);
  }
  .filters__backdrop.is-open {
    display: block;
  }
  .filters__apply {
    position: sticky;
    bottom: 0;
    padding-block: var(--space-4) calc(var(--space-4) + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--border);
  }
  .filters > [data-reset-filters] {
    margin-bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  }

  .toast-region {
    justify-items: stretch;
  }
  .toast {
    max-width: none;
  }
  body:has(.mobile-cta) .toast-region {
    bottom: 84px;
  }

  /* Two-column comparison tables scroll but keep first column visible */
  .table--compare th[scope="row"] {
    position: sticky;
    left: 0;
    z-index: 1;
  }

  /* Checkout stepper: on phones only the current step shows its label (others keep an
     accessible name via visually-hidden text), so the bar fits without scrolling. */
  .stepper__item {
    justify-content: center;
    padding-inline: var(--space-1);
  }
  .stepper__item.is-current {
    flex: 3 1 0;
  }
  .stepper__item:not(.is-current) > span:not(.stepper__num) {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .kv {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .kv dd {
    margin-bottom: var(--space-3);
  }
  .step {
    grid-template-columns: 40px 1fr;
  }
}

/* ---- ≥ 640: large phone / small tablet ---------------------------------- */
@media (min-width: 640px) {
  .grid--2,
  .grid--3,
  .grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .form-row--2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .stat {
    border-bottom: 0;
  }
  .stat:nth-child(2n) {
    border-right: 1px solid var(--border);
  }
  .stat:last-child {
    border-right: 0;
  }
  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .toast-region {
    left: auto;
  }
  .facts {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .wa-float__label,
  .ai-launcher__label {
    display: inline;
  }
}

/* ---- ≥ 768: tablet ------------------------------------------------------ */
@media (min-width: 768px) {
  :root {
    --header-h: 72px;
  }
  .cta-band {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }
  .steps {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: var(--space-4);
  }
  .step {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
  }
  .step:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 20px;
    left: 52px;
    right: calc(var(--space-4) * -1 + 4px);
    border-top: 1px dashed var(--border-strong);
  }
  .form-row--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .mobile-cta {
    display: none;
  }
  body.has-mobile-cta {
    padding-bottom: 0;
  }
  body.has-mobile-cta .wa-float {
    bottom: var(--space-4);
  }
  body.has-mobile-cta .ai-launcher {
    bottom: calc(var(--space-4) + var(--ai-stack, 0px));
  }
}

/* ---- ≥ 1024: laptop ----------------------------------------------------- */
@media (min-width: 1024px) {
  .hero__grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  }
  .grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .grid--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .footer-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.1fr) repeat(2, minmax(0, 0.8fr)) minmax(0, 1.5fr);
  }
  .catalog {
    grid-template-columns: 250px minmax(0, 1fr);
    align-items: start;
  }
  .catalog .filters {
    position: sticky;
    top: calc(var(--header-h) + var(--space-5));
    max-height: calc(100dvh - var(--header-h) - var(--space-8));
    overflow-y: auto;
    padding: var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
  }
  .catalog__filter-btn {
    display: none;
  }
  .filters__apply {
    display: none; /* on a laptop the results update as you tick, so "Show N results" is only for the phone sheet */
  }
  .detail-layout {
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
  }
  .detail-layout--picker {
    grid-template-columns: 300px minmax(0, 1fr);
    align-items: stretch; /* the picker column must span the panel's height for position:sticky to work */
  }
  .detail-aside {
    position: sticky;
    top: calc(var(--header-h) + var(--space-5));
  }
  .checkout-layout {
    grid-template-columns: minmax(0, 1fr) 380px;
  }
  .summary-sticky {
    position: sticky;
    top: calc(var(--header-h) + var(--space-5));
  }
  .offering-picker {
    position: sticky;
    top: calc(var(--header-h) + var(--space-5));
    display: grid;
    overflow: visible;
    padding-bottom: 0;
  }
  .offering-btn {
    width: 100%;
    min-width: 0;
  }
}

/* ---- ≥ 1200: the full 8-link navigation fits beside the brand and header actions.
   Between 768 and 1199 (tablets, small laptops) the hamburger menu is used instead — measured:
   inline nav + actions need ~1120px, so switching at 1024 pushed the header off-screen. */
@media (min-width: 1200px) {
  .nav {
    display: flex;
  }
  .menu-toggle,
  .mobile-nav {
    display: none !important;
  }
}

/* ---- ≥ 1280 ------------------------------------------------------------- */
@media (min-width: 1280px) {
  .nav {
    margin-left: var(--space-8);
  }
  .nav__link {
    padding-inline: 0.85rem;
  }
}

/* ---- Print --------------------------------------------------------------- */
@media print {
  .site-header,
  .site-footer,
  .wa-float,
  .ai-launcher,
  .ai-panel,
  .mobile-cta,
  .toast-region,
  .skip-link {
    display: none !important;
  }
  body {
    background: #fff;
    color: #000;
  }
}
