/* ==========================================================================
   RESPONSIVE — tablet reflow, mobile single column, purpose-built layouts
   ========================================================================== */

/* ---- 1280 and below: tighter gutters ---------------------------------- */
@media (max-width: 1280px) {
  :root { --gutter: 22px; }
  .nav { gap: 18px; }
  .nav__link { padding: 9px 10px; font-size: .9125rem; }
  .foot-top { grid-template-columns: minmax(200px, 1fr) repeat(5, minmax(0,1fr)); gap: 34px 20px; }
}

/* ---- 1120: hero stacks earlier than nav collapses --------------------- */
@media (max-width: 1120px) {
  .hero__in { grid-template-columns: minmax(0,1fr); gap: 44px; }
  .hero__copy { max-width: 680px; }
  /* inset the mockup so floating callouts sit in the margin, not on top of data */
  .hero__stage { max-width: 940px; padding: 26px 46px 26px 62px; margin-inline: -14px; }
  /* Bleed is gone at this width, so the nav's counter-margin must go too. */
  .hs__nav, .hs__note { margin-right: 0; }
  .app--tilt { transform: none; }
  .float--wo  { left: 0;  top: 8%; }
  .float--pro { left: 0;  bottom: 16%; }
  .float--inv { right: 0; top: 37%; }
  .float--po  { right: 0; bottom: -2%; }
  .ai-grid { grid-template-columns: minmax(0,1fr); gap: 40px; }
  .trial__in { grid-template-columns: minmax(0,1fr); gap: 36px; }
  .demo { grid-template-columns: minmax(0,1fr); gap: 36px; }
  .faq { grid-template-columns: minmax(0,1fr); }
  .faq__aside { position: static; }
  .plans { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .fit__grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .creds { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* ---- 1024: collapse nav to drawer ------------------------------------- */
@media (max-width: 1024px) {
  /* Trust section: the ownership statements and the capability list stack. */
  .trust-grid { grid-template-columns: minmax(0,1fr); }

  /* Migration: two cards stack; each path then has the full width and stops
     needing to scroll. */
  .mig { grid-template-columns: minmax(0,1fr); }
  /* Go-live rail: once it wraps to 2-up the right border on the last cell of a
     row would float, so switch to a bottom border on every cell instead. */
  .golive { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
  .gostep { border-right: 0; border-bottom: 1px solid var(--line); }
  .gostep:last-child { border-bottom: 0; }

  /* WhatsApp: the phone goes below the steps and centres, rather than being
     squeezed into a column narrower than a phone. */
  .waz { grid-template-columns: minmax(0,1fr); gap: 40px; }

  .nav__links { display: none; }
  .nav__actions .nav__login,
  .nav__actions .btn--ghost { display: none; }
  .burger { display: grid; }
  .nav { justify-content: space-between; }
  .nav__actions { margin-left: auto; }

  .mod-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
  .res-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .mfg { grid-template-columns: minmax(0,1fr); gap: 28px; }
  .steps { display: flex; overflow-x: auto; border-left: 0; border-bottom: 1px solid var(--line); padding-bottom: 2px; gap: 4px; scrollbar-width: none; }
  .steps::-webkit-scrollbar { display: none; }
  .step { flex: none; width: auto; min-width: 168px; padding: 12px 14px; border-radius: var(--r-sm) var(--r-sm) 0 0; flex-direction: column; gap: 4px; }
  .step::before { left: 0; right: 0; top: auto; bottom: -1px; width: auto; height: 2px; transform: scaleX(0); transform-origin: left; }
  .step.is-on::before { transform: scaleX(1); }
  .step__ico { display: none; }
  .step__d { display: none; }
  .orbit { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .orbit__core { grid-column: 1 / -1; grid-row: auto; order: -1; }
  .mini-stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .prob-grid { grid-template-columns: minmax(0,1fr); }
}

/* ---- 860: tablet portrait -------------------------------------------- */
@media (max-width: 860px) {
  /* Control tower: the queue table beside the work order has nowhere to go
     below this width, so the two cards stack. KPIs stay auto-fit. */
  .tow-cols { grid-template-columns: minmax(0,1fr); }

  body { font-size: 16px; }
  .app__body { grid-template-columns: minmax(0,1fr); }
  .app__side {
    flex-direction: row; align-items: center; gap: 6px;
    border-right: 0; border-bottom: 1px solid var(--line);
    overflow-x: auto; padding: 9px 10px; scrollbar-width: none;
  }
  .app__side::-webkit-scrollbar { display: none; }
  .app__side .side-label, .app__side-foot { display: none; }
  .side-row { flex: none; padding: 6px 11px; font-size: 11.5px; border-radius: 999px; background: #fff; border: 1px solid var(--line); }
  .side-row.is-active { box-shadow: none; border-color: rgba(14,159,110,.3); }
  .side-row .badge { display: none; }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .app__cols, .app__cols--even, .app__cols--3 { grid-template-columns: minmax(0,1fr); }
  .demo .fgrid { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .map__head, .mrow { grid-template-columns: minmax(0,1fr); gap: 6px; }
  .mwire { display: none; }
  .mcell--fin { justify-content: flex-start; text-align: left; margin-left: 24px; position: relative; }
  .mcell--fin::before {
    content: ""; position: absolute; left: -18px; top: 50%; width: 14px; height: 1px;
    background: rgba(143,192,255,.5);
  }
  .mcell--fin .mcell__ico { order: 0; }
  .map__head span:last-child { text-align: left; margin-left: 24px; }
  .cmp__scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cmp__scroll table { min-width: 620px; }
  .cmp__scroll th, .cmp__scroll td { padding: 13px 13px; }
  .cmp__hint { display: flex; }
}

/* ---- 720: mobile ------------------------------------------------------ */
@media (max-width: 720px) {
  :root { --gutter: 18px; --nav-h: 62px; }
  h1 { font-size: clamp(2.1rem, 8.6vw, 2.7rem); }
  h2 { font-size: clamp(1.75rem, 6.6vw, 2.15rem); }
  .section { padding-block: 62px; }
  .section--tight { padding-block: 48px; }

  .announce__in { min-height: 34px; font-size: .75rem; gap: 8px; }
  .announce__sep, .announce .hide-sm { display: none; }

  .hero { padding-top: 34px; padding-bottom: 48px; }
  .hero .cta-row { gap: 10px; }
  .hero .cta-row .btn { flex: 1 1 100%; }
  .hero__trust { margin-top: 26px; padding-top: 20px; }
  .trust-list { gap: 9px 18px; }
  .trust-list li { font-size: .875rem; }
  .float { padding: 7px 10px; border-radius: 10px; }
  .float b { font-size: 11px; }
  .float span { font-size: 8.5px; }
  .float__ico { width: 24px; height: 24px; }
  .float--wo  { top: -2.5%; left: -2%; transform: scale(.92); }
  .float--inv { top: 26%; right: -2%; transform: scale(.92); }
  .float--pro { display: none; }
  .float--po  { bottom: -3%; right: 0; transform: scale(.92); }

  .mod-grid { grid-template-columns: minmax(0,1fr); gap: 14px; margin-top: 34px; }
  .mod { padding: 20px; border-radius: var(--r); }
  .res-grid { grid-template-columns: minmax(0,1fr); }
  .plans { grid-template-columns: minmax(0,1fr); }
  .fit__grid { grid-template-columns: minmax(0,1fr); }
  .orbit { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .orbit__core { padding: 22px 18px; }
  .mini-stats { grid-template-columns: minmax(0,1fr); }
  .demo .fgrid { grid-template-columns: minmax(0,1fr); gap: 14px; }
  .form-card { border-radius: var(--r-lg); }
  .trial { border-radius: var(--r-xl); padding: 32px 22px; }
  .price-foot, .cmp__foot { flex-direction: column; align-items: flex-start; gap: 14px; }
  .price-foot .cta-row, .cmp__foot .cta-row { width: 100%; }
  .price-foot .btn, .cmp__foot .btn { flex: 1; }

  /* Calculator: users and plan stack, and the total gets its own line so the
     figure never collides with the "/ month" qualifier. */
  .calc__head, .calc__body, .calc__out, .calc__foot { padding-inline: 18px; }
  .calc__body { grid-template-columns: 1fr; gap: 20px; }
  .segs { width: 100%; }
  .seg { flex: 1 1 auto; }

  .faq__q { font-size: 1rem; gap: 14px; padding: 17px 2px; }
  .faq__a p { padding-right: 30px; }

  .prob-list li { flex-wrap: wrap; gap: 9px 12px; padding: 14px 15px; }
  .prob-list .sys { min-width: 0; }
  .prob-list .x { margin-left: 0; }

  .foot-top { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 30px 18px; padding-bottom: 40px; }
  .foot-brand { grid-column: 1 / -1; }
  .foot-bottom { flex-direction: column; align-items: flex-start; gap: 14px; }
  /* larger tap targets for touch */
  .foot-col li + li { margin-top: 2px; }
  .foot-col a { display: inline-flex; align-items: center; min-height: 38px; }
  .foot-meta a { min-height: 38px; display: inline-flex; align-items: center; }
  .foot-demo { min-height: 40px; }
  .drawer__foot a { min-height: 40px; display: inline-flex; align-items: center; }
  .mod .tlink { min-height: 40px; align-items: center; }
  /* Every inline text link becomes a real touch target on phones. */
  .tlink, .res__meta .tlink { min-height: 40px; align-items: center; }
  .form-note a, .foot-meta a, .consent a { display: inline-block; padding-block: 6px; }

  .mobile-cta { display: flex; }
  body { padding-bottom: 0; }
  .site-foot { padding-bottom: 76px; }

  .app { border-radius: var(--r-lg); font-size: 12.5px; }
  .app__main { padding: 13px; }
  .kpi__val { font-size: 17px; }
  .app__bar { padding: 9px 12px; }
  .app__url { font-size: 9.5px; }

  .lane { padding: 18px; }
  .demo__side ul { gap: 14px; }
  .steps3 { gap: 10px; }
  .step3 { padding: 15px 16px; gap: 13px; }
}

/* ---- 720 and below: crop the product UI, don't run it to full length ----
   The mockup's container queries correctly collapse it to one column on a
   phone, and at native size every label stays legible — the problem is length:
   ten stacked panels ran the hero to ~2100px, so the page opened on an endless
   dashboard instead of a product glimpse. Real apps are viewports, so the shell
   is cropped to a confident glimpse (toolbar, KPIs, first panel) and faded at
   the cut. Full-fidelity views stay reachable in the tour below. */
@media (max-width: 720px) {
  .hero__stage { padding: 0; margin-inline: 0; }
  .hs__view { position: relative; border-radius: var(--r-lg); overflow: hidden; }
  .hs__slide { height: 430px; overflow: hidden; }
  /* Fade the crop instead of guillotining it — implies more product below. */
  .hs__view::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 88px;
    background: linear-gradient(180deg, rgba(255,255,255,0), #fff 84%);
    pointer-events: none; z-index: 3;
  }
  /* Callouts would now sit on top of the crop rather than beside the data. */
  .float { display: none !important; }
}

/* ---- 420: small phones ----------------------------------------------- */
@media (max-width: 420px) {
  /* 420: five metrics in one column read as a list, which is what a phone
     wants. Work-order numbers stay 3-up — they are compared, not read. */
  .tow-kpis { grid-template-columns: minmax(0,1fr); }
  .tower__body { padding: 13px; gap: 11px; }
  .tow-kpi__v { font-size: 1.5rem; }
  .wo-st > li { flex-wrap: wrap; }
  .wo-st .st-note { margin-left: 0; width: 100%; text-align: left; }

  .kpis { grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 7px; }
  .kpi { padding: 9px 10px; }
  .brand img { height: 28px; }
  .btn { padding: 11px 16px; font-size: .9125rem; }
  .btn--lg { padding: 14px 20px; font-size: .9375rem; }
  .creds { grid-template-columns: minmax(0,1fr); }
  .float--inv { display: none; }
  .tbl { font-size: 10.5px; }
  .tbl th { font-size: 8.5px; }
}

/* ---- Container queries for app mockups ------------------------------- */
@container (max-width: 560px) {
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .app__cols, .app__cols--even, .app__cols--3 { grid-template-columns: minmax(0,1fr); }

  /* A narrow shell can't hold a record title AND its action cluster on one
     row. Real apps drop the secondary actions first and keep the title whole —
     truncating to "Plant…" while an Export button sits beside it looks broken.
     The primary action and status pill stay; the rest are recoverable. */
  .app__head { flex-wrap: wrap; }
  .app__head > div:first-child { flex: 1 1 100%; }
  .app__title, .app__head h4, .app__head p { white-space: normal; overflow: visible; }
  .app__head-actions { flex: 0 0 auto; }
  .app__head-actions .mini-btn:not(.mini-btn--solid) { display: none; }

  /* Let the tab strip scroll rather than shear a label in half. */
  .app__tabs { overflow-x: auto; scrollbar-width: none; }
  .app__tabs::-webkit-scrollbar { display: none; }
}

/* ---- Print ----------------------------------------------------------- */
@media print {
  .site-head, .announce, .mobile-cta, .drawer, .float { display: none !important; }
  .section { padding-block: 24px; }
  .reveal { opacity: 1 !important; transform: none !important; }
}
