/* ============================================================================
   AVINYAI — RESPONSIVE + MOTION PREFERENCES
   Breakpoints: 1440 · 1280 · 1024 · 768 · 390
   ========================================================================= */

/* ---- ≤1440: keep the shell breathing ---------------------------------- */
@media (max-width: 1440px) {
  :root { --band: 128px; }
}

/* ---- ≤1280 ------------------------------------------------------------ */
@media (max-width: 1280px) {
  :root { --gutter: 32px; --band: 116px; }

  .hero { padding: 176px 0 100px; }
  .story { gap: 56px; padding: 84px 0; }
  .contact__grid { gap: 60px; }
  .nav__links a { padding: 8px 10px; font-size: 0.8438rem; }
  .nav__inner { gap: 24px; }
}

/* ---- ≤1080: nav collapses, stack becomes 3+2 -------------------------- */
@media (max-width: 1080px) {
  .nav__links, .nav__right .nav__text-link { display: none; }
  .nav__right { margin-left: auto; }
  .nav__inner { gap: 16px; }
  .burger { display: grid; }

  .stack__rail { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tech__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .trust__row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; }
  .trust__item { padding: 16px 20px 16px 0; }
}

/* ---- ≤1024: single-column editorial ----------------------------------- */
@media (max-width: 1024px) {
  :root { --band: 100px; }

  h1 { font-size: clamp(2.25rem, 5.4vw, 3rem); }   /* 40–48 tablet */

  .head--split,
  .story,
  .zt__grid,
  .contact__grid,
  .perimeter__body { grid-template-columns: minmax(0, 1fr); }

  .head--split { gap: 26px; align-items: start; }
  .hero { padding: 152px 0 88px; }
  .hero h1 { max-width: 640px; }
  .hero__visual { margin-top: 64px; }

  .story { gap: 42px; padding: 72px 0; }
  .story--flip .story__copy { order: 0; }
  .story--flip .story__visual { order: 0; }
  .story__copy p { max-width: 58ch; }

  .console__body { grid-template-columns: minmax(0, 1fr); }
  .console__req { border-right: 0; border-bottom: 1px solid var(--line); }

  .zt__grid { gap: 48px; }
  .contact__info { position: static; }
  .contact__form { padding: 30px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .res__row { grid-template-columns: 128px minmax(0, 1fr) auto; gap: 26px; }
  .res__thumb { height: 82px; }

  .cta { padding: 128px 0; }
}

/* ---- ≤768: mobile ----------------------------------------------------- */
@media (max-width: 768px) {
  :root { --gutter: 22px; --band: 84px; }

  h1 { font-size: clamp(2.25rem, 9vw, 2.625rem); }     /* 36–42 mobile */
  h2 { font-size: clamp(1.625rem, 6.4vw, 2rem); }

  .hero { padding: 122px 0 72px; }
  /* Cover-cropping on a narrow screen puts a lit wall behind the copy, so the
     backdrop drops back to texture and the text keeps its contrast. */
  .hero__backdrop { min-height: 620px; }
  .hero__backdrop img { object-position: 30% 50%; }
  .hero__backdrop::after {
    background-image:
      linear-gradient(to right, rgba(126, 158, 205, 0.05) 1px, transparent 1px),
      linear-gradient(to bottom, rgba(126, 158, 205, 0.05) 1px, transparent 1px),
      linear-gradient(to bottom, rgba(5, 9, 20, 0.90) 0, rgba(5, 9, 20, 0.72) 120px, rgba(5, 9, 20, 0.72) 74%, var(--bg) 100%);
    background-size: 88px 88px, 88px 88px, cover;
  }
  .hero h1 { margin-top: 20px; max-width: none; }
  .hero .lede { margin-top: 22px; }
  .hero__cta { gap: 10px; margin-top: 32px; }
  .hero__cta .btn { flex: 1 1 100%; justify-content: center; }
  .hero__meta { margin-top: 36px; gap: 8px 16px; }
  .hero__visual { margin-top: 48px; }
  .ticker { position: static; margin-top: 16px; left: auto; right: auto; bottom: auto; }

  .stack__rail { grid-template-columns: minmax(0, 1fr); }
  .stack__layer { border-left: 0; padding: 22px 18px 24px; }
  .stack__detail { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 22px 18px; }
  .stack__detail .btn { width: 100%; justify-content: center; }

  .tech__grid, .trust__row { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .console__req, .pipe, .console__foot { padding: 22px 20px; }
  .rec__row { grid-template-columns: minmax(0, 1fr); gap: 5px; padding: 12px 0; }
  .pipe__stage { grid-template-columns: 24px minmax(0, 1fr); gap: 12px; }
  .pipe__note { grid-column: 2; text-align: left; }
  .console__verdict { margin-left: 0; }

  .res__row { grid-template-columns: minmax(0, 1fr) auto; gap: 18px; }
  .res__row:hover { padding-left: 0; }
  .res__thumb { display: none; }

  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { padding: 20px 18px; }

  .cta { padding: 96px 0; text-align: left; }
  .cta h2, .cta .lede { margin-left: 0; }
  .cta__row { justify-content: stretch; }
  .cta__row .btn { flex: 1 1 100%; justify-content: center; }

  .form__row { grid-template-columns: minmax(0, 1fr); }
  .contact__form { padding: 24px 20px; }
  .contact__form .btn { width: 100%; justify-content: center; }

  .foot { padding: 62px 0 28px; }
  .foot__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px 24px; }
  .foot__brand { grid-column: 1 / -1; }
  .foot__bottom { margin-top: 48px; flex-direction: column; align-items: flex-start; gap: 18px; }

  /* Wide architecture diagrams become legible vertical flows. */
  .diagram--wide { display: none; }

  .vflow { display: grid; gap: 0; }
  .vflow__row { display: flex; flex-wrap: wrap; gap: 6px; }
  .vflow__chip {
    flex: 1 1 calc(50% - 6px);
    padding: 12px 10px;
    border: 1px solid var(--line-2);
    border-radius: var(--radius);
    background: #101B30;
    font-size: 0.8125rem;
    text-align: center;
  }
  .vflow__chip--ai { background: #150F2B; border-color: rgba(139, 92, 246, 0.4); color: #C4AFFC; }

  .vflow__link {
    justify-self: center;
    width: 1px; height: 28px;
    background: rgba(126, 158, 205, 0.5);
    position: relative;
  }
  .vflow__link::after {
    content: "";
    position: absolute;
    bottom: 0; left: -3px;
    width: 7px; height: 7px;
    border-right: 1px solid rgba(126, 158, 205, 0.5);
    border-bottom: 1px solid rgba(126, 158, 205, 0.5);
    transform: rotate(45deg);
  }

  .vflow__core {
    padding: 18px 16px;
    border: 1px solid rgba(91, 140, 255, 0.55);
    border-radius: var(--radius);
    background: #0E1A31;
    text-align: center;
  }
  .vflow__core b {
    display: block;
    font-family: var(--display);
    font-size: 0.9375rem;
    font-weight: 550;
    letter-spacing: -0.015em;
    color: #A9C3FF;
  }
  .vflow__core small {
    display: block;
    margin-top: 7px;
    font-family: var(--mono);
    font-size: 0.5625rem;
    letter-spacing: 0.12em;
    line-height: 1.7;
    color: var(--ink-3);
  }

  .vflow__out { display: flex; gap: 6px; }
  .vflow__out span {
    flex: 1;
    padding: 10px 4px;
    border: 1px solid;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: 0.5625rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-align: center;
  }
  .vflow__out .is-allow { color: var(--green); border-color: rgba(52, 211, 153, 0.45); }
  .vflow__out .is-challenge { color: var(--amber); border-color: rgba(240, 178, 58, 0.45); }
  .vflow__out .is-deny { color: var(--red); border-color: rgba(240, 89, 107, 0.45); }

  /* Narrow diagrams stay as diagrams and pan horizontally. */
  .diagram--pan {
    aspect-ratio: auto !important;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }
  .diagram--pan > svg { min-width: var(--pan, 520px); }
  .diagram--pan::-webkit-scrollbar { height: 3px; }
  .diagram--pan::-webkit-scrollbar-thumb { background: var(--line-3); border-radius: 3px; }

  .hero__visual::after,
  .story__visual::after,
  .zt__visual::after {
    content: "Swipe diagram →";
    display: block;
    margin-top: 10px;
    font-family: var(--mono);
    font-size: 0.5625rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-3);
    text-align: right;
  }
}

/* ---- ≤560: the nav CTA lives in the menu sheet instead --------------- */
@media (max-width: 560px) {
  .nav__right .btn { display: none; }
}

/* ---- ≤390: smallest supported ---------------------------------------- */
@media (max-width: 400px) {
  :root { --gutter: 18px; }
  .trust__row { grid-template-columns: minmax(0, 1fr); }
  .metrics { grid-template-columns: minmax(0, 1fr); }
  .brand__word { height: 15px; }
}

/* ---- Motion preferences ---------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  [data-reveal], [data-reveal-group] > * { opacity: 1 !important; transform: none !important; }
  .d-pulse { stroke-dashoffset: 0; opacity: 0.5; }
  .d-halo { opacity: 0.4; }
}

/* ---- Print ----------------------------------------------------------- */
@media print {
  .nav, .sheet, .ambient, .ticker { display: none !important; }
  body { background: #fff; color: #000; }
}
