/* ==========================================================================
   TECHIE ZEST — RESPONSIVE
   Deliberate breakpoints: 1280 / 1024 / 768 / 390 / 375. Mobile is designed,
   not merely shrunk. Load LAST so these overrides win.
   ========================================================================== */

/* ---- Header + logo sizing per breakpoint ----------------------------
   Logo is the header's visual anchor; nav/CTA sizes are left untouched.
   Desktop (>1024): logo 96px / header 108px (set in tokens.css).          */
@media (max-width: 1024px) {          /* tablet: 1024 & 768 */
  :root { --header-h: 96px; --logo-h: 80px; }
}
@media (max-width: 480px) {           /* mobile: 390 & 375 */
  :root { --header-h: 86px; --logo-h: 66px; }
}

/* ---- <= 1024px ------------------------------------------------------- */
@media (max-width: 1024px) {
  /* Reset start lines FIRST, then set spans, so the two never conflict. */
  .start-2, .start-3, .start-6, .start-7, .start-8, .start-9 { grid-column-start: auto; }
  .col-3 { grid-column: auto / span 6; }
  .col-4 { grid-column: auto / span 6; }
  .col-5, .col-7 { grid-column: auto / span 12; }
  .col-6 { grid-column: auto / span 12; }
  .col-8, .col-9, .col-10 { grid-column: auto / span 12; }

  .svc-grid { grid-template-columns: repeat(2, 1fr); }   /* tablet: 2 columns */

  .work-featured { grid-template-columns: 1fr; }
  /* About: text first, photograph second; give the overlapping proof strip room. */
  .about { grid-template-columns: 1fr; gap: var(--space-2xl); }
  .about__media { order: 2; }
  .about__figure { max-width: 560px; margin-inline: auto; }
  .about__photo { aspect-ratio: 16 / 11; }
  /* Keep the proof strip centered under the (max-width-capped) image on stacked layouts. */
  .about__proof { max-width: 560px; margin-inline: auto; }
  .insights__grid { grid-template-columns: 1fr; }

  .section-head--between { flex-direction: column; align-items: flex-start; }
}

/* ---- <= 900px -------------------------------------------------------- */
@media (max-width: 900px) {
  .hero__grid { grid-template-columns: 1fr; }
  /* Visual stacks BELOW the headline + CTAs; kept large enough to read. */
  .hero__visual { max-width: 460px; margin: var(--space-lg) auto 0; }
  .hero h1, .hero__lead { max-width: none; }

  .principles { grid-template-columns: 1fr 1fr; }
  .positioning .grid { gap: var(--space-lg); }
}

/* ---- Process: tighten the 40/60 split on smaller desktops/tablets ---- */
@media (max-width: 1180px) and (min-width: 901px) {
  .process-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }  /* ~35/65 */
  /* Let the staircase indent a touch less so nodes keep their width */
  .pnode:nth-child(3) { grid-column: 3 / span 8; }
  .pnode:nth-child(4) { grid-column: 3 / span 8; }
  .pnode:nth-child(5) { grid-column: 5 / span 8; }
}

/* ---- Process → vertical connected SYSTEM (spine) at <= 900px --------
   The SVG staircase is replaced by a single vertical spine with an
   emerald progression that grows on scroll; nodes stack full-width. */
@media (max-width: 900px) {
  .process-grid { grid-template-columns: 1fr; gap: var(--space-xl); }
  .process-intro { position: static; }
  .process-intro__rule { margin: var(--space-lg) 0 var(--space-md); }

  .psys__wire { display: none; }                 /* JS also skips drawing */
  .psys { padding-left: var(--space-lg); }
  .psys__nodes {
    display: block;
    position: relative;
    padding-left: var(--space-lg);
  }
  /* Base spine + emerald fill drawn with the list's own pseudo-elements */
  .psys__nodes::before,
  .psys__nodes::after {
    content: "";
    position: absolute;
    left: 5px; top: 10px; bottom: 10px;
    width: 2px;
    border-radius: 2px;
  }
  .psys__nodes::before { background: var(--line-strong); }
  .psys__nodes::after {
    background: linear-gradient(180deg, var(--navy), var(--emerald));
    bottom: auto; height: 0;
    transition: height 1100ms var(--ease);
  }
  .psys[data-inview="true"] .psys__nodes::after { height: calc(100% - 20px); }

  .pnode { margin-bottom: var(--space-lg); }
  .pnode:last-child { margin-bottom: 0; }
  /* Node marker sits on the spine */
  .pnode::before {
    left: calc(-1 * var(--space-lg) - 1px);
    top: 50%; bottom: auto;
    width: 12px; height: 12px;
    background: var(--white);
    border: 2px solid var(--line-strong);
    border-radius: 3px;
    transform: translateY(-50%) scale(1);
    transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
  }
  .pnode.is-lit::before,
  .pnode:hover::before,
  .pnode:focus-within::before { transform: translateY(-50%) scale(1); border-color: var(--emerald); background: var(--emerald); }
  .pnode__desc { max-width: 52ch; }
}

@media (max-width: 420px) {
  .tz-chip { font-size: 0.66rem; padding: 0.42em 0.6em; }
  .tz-chip--a4 { right: 0; }
}

/* ---- AI automation diagram: stack, then go vertical on phones -------- */
@media (max-width: 960px) {
  .ail__grid { grid-template-columns: 1fr; gap: var(--space-xl); }
  .ail__stage { max-width: 640px; }
}
@media (max-width: 640px) {
  .ail__viz { display: none; }
  .ail__vert { display: block; margin-top: var(--space-md); }
}

/* ---- <= 768px -------------------------------------------------------- */
@media (max-width: 768px) {
  .proof { grid-template-columns: 1fr; gap: var(--space-lg); }
  .proof__item { display: flex; align-items: baseline; gap: var(--space-md); }
  .proof__num { font-size: var(--step-4); }

  .work-secondary { grid-template-columns: 1fr; }
}

/* ---- <= 480px -------------------------------------------------------- */
@media (max-width: 480px) {
  .principles { grid-template-columns: 1fr; }
  .svc-grid { grid-template-columns: 1fr; }              /* mobile: 1 column  */
  .svc-cta { flex-direction: column; }
  .svc-cta .btn { width: 100%; }
  .about__proof-item { padding: var(--space-xs) var(--space-2xs); }
  .about__proof-n { font-size: var(--step-1); }
  .work-cs li { grid-template-columns: 1fr; gap: var(--space-2xs); }
}

/* ---- very narrow safety (375/390) ------------------------------------ */
@media (max-width: 400px) {
  :root { --gutter: 1.15rem; }
  .mobile-nav__link { font-size: var(--step-1); }
}
