/* ==========================================================================
   Responsive — intentional layouts for tablet and mobile.
   Desktop-first; each breakpoint re-composes rather than shrinks.
   ========================================================================== */

/* ----- <= 1024px : small laptop / large tablet ---------------------------- */
@media (max-width: 1024px) {
  :root { --content-max: 900px; }

  /* the UX/research composition stops orbiting — hold the layout, keep it calm */
  .mid-cta__orbit,
  .mid-cta__ph img { animation: none !important; }
  .mid-cta__statement { font-size: clamp(1.5rem, 1rem + 2.2vw, 2rem); line-height: 1.75; max-width: min(560px, 82%); }
  .mid-cta__ph--1, .mid-cta__ph--2, .mid-cta__ph--3, .mid-cta__ph--4 { width: clamp(118px, 15vw, 178px); }
  .mid-cta__orbit--1 { left: 1%; }  .mid-cta__orbit--2 { right: 0%; }
  .mid-cta__orbit--3 { left: 2%; }  .mid-cta__orbit--4 { right: 1%; }

  .hero__body { grid-template-columns: 1fr; }
  .hero__body-text { max-width: 52ch; }
  .hero__media { max-width: 620px; justify-self: start; }
  .hero__title br { display: none; }

  .philosophy__grid { grid-template-columns: 1fr; }
  .philosophy__aside { grid-column: 1; grid-row: 1; }
  .philosophy__statement {
    grid-column: 1; grid-row: 2;
    justify-self: start;
    max-width: none;
    text-align: left;
    margin-top: var(--sp-5);
    font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2rem);
  }
  .philosophy__cluster {
    grid-column: 1; grid-row: 3;
    position: relative;
    margin-top: var(--sp-7);
    aspect-ratio: auto;
    display: flex;
    flex-direction: column;
    gap: var(--sp-5);
  }
  .philosophy__img {
    position: static;
    width: min(100%, 480px);
    aspect-ratio: 468 / 255;
  }
  .philosophy__img--2 { align-self: flex-end; }
  .philosophy__link { display: none; }

  .svc-item__panel-inner,
  .svc-item__panel-inner:has(.svc-item__body--wide) {
    grid-template-columns: 1fr;
    /* keep body copy flush under the title (trigger still uses the 60px + --svc-gap layout here) */
    padding-left: calc(60px + var(--svc-gap));
    gap: var(--sp-5);
  }
  .svc-item__mock { width: 100%; max-width: 320px; }

  .about__body { grid-template-columns: 1fr; }
  .about__portrait { max-width: 430px; }

  .bento { grid-template-columns: 1fr 1fr; }
  .bento .step { grid-column: span 1 !important; }

  .faq__grid { grid-template-columns: 1fr; gap: var(--sp-7); }
  .faq__aside .meta-table { margin-top: var(--sp-6); }

  .contact__grid { grid-template-columns: 1fr; }
  .contact-card { max-width: 520px; }

  .site-footer__main { grid-template-columns: 1fr 1fr; }
  .footer-wordmark { grid-column: 1 / -1; justify-self: start; text-align: left; margin-top: var(--sp-6); }

  /* .section-head only wraps once the title + lede can't fit side by side,
     which (thanks to the title's large fluid type) can happen well above
     760px — left-align here too, at the same breakpoint every other
     two-column layout on the page collapses at, so the lede never sits
     right-aligned against a wrapped line the way flex-wrap alone would
     leave it. */
  .section-head { flex-direction: column; align-items: flex-start; gap: var(--sp-4); }
  .section-head__lede { text-align: left; max-width: 52ch; }
}

/* ----- <= 860px : nav collapses --------------------------------------------- */
@media (max-width: 860px) {
  /* at rest (over the hero/photo, not yet scrolled) the nav sits flush at
     the page's own gutter, same as desktop — no plate, no pill, just the
     logo/toggle sitting on the background. Only once scrolled does it
     become the smaller floating pill; both states already transition
     smoothly via .site-header__inner's own transition list. */
  .site-header:not(.is-scrolled) .site-header__inner {
    max-width: none;
    padding-inline: var(--gutter);
  }
  .site-header.is-scrolled .site-header__inner {
    margin-inline: var(--sp-4);
    max-width: none;
    padding: 0.7rem 0.6rem 0.7rem 1.1rem;
  }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    color: inherit;
    border-radius: var(--r-xs);
    z-index: calc(var(--z-overlay) + 1);
  }
  .nav-toggle__box { position: relative; width: 22px; height: 14px; }
  .nav-toggle__box span {
    position: absolute; left: 0; right: 0; height: 2px;
    background: currentColor; border-radius: 2px;
    transition: transform var(--dur-2) var(--ease-out), opacity var(--dur-2) var(--ease-out);
  }
  .nav-toggle__box span:nth-child(1) { top: 0; }
  .nav-toggle__box span:nth-child(2) { top: 6px; }
  .nav-toggle__box span:nth-child(3) { top: 12px; }
  .nav-toggle[aria-expanded="true"] .nav-toggle__box span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] .nav-toggle__box span:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] .nav-toggle__box span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  .nav-list {
    position: fixed;
    /* longhand fallback first — some older mobile browsers don't support the
       `inset` shorthand, which would otherwise leave the panel unpositioned
       and collapsed, letting page content show through it */
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    inset: 0 0 0 auto;
    width: min(78vw, 340px);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-5);
    padding: 5rem var(--sp-7) var(--sp-7);
    /* translucent, not solid — the blur behind it (from any background,
       light, dark, photo, video or gradient) is what gives the same glassy
       read as the desktop nav pill; the tint stays dark/opaque enough to
       keep the white labels legible over anything behind it. */
    background: rgba(14, 26, 39, 0.86);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform var(--dur-3) var(--ease-out), visibility 0s linear var(--dur-3);
    z-index: var(--z-overlay);
  }
  /* the open panel sits above the header (see initNav()'s relocation of
     .nav-list to <body>), which covers the hamburger/× toggle it grew out
     of — this dedicated close control lives inside the panel itself so
     it's always visible and reachable while the menu is open. */
  .nav-list__close-item {
    display: block;
    position: absolute;
    top: var(--sp-4);
    right: var(--sp-4);
  }
  .nav-list__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    background: none;
    color: #fff;
    cursor: pointer;
    opacity: 0.85;
    transition: opacity var(--dur-2) var(--ease-out);
  }
  .nav-list__close:hover, .nav-list__close:focus-visible { opacity: 1; }
  .nav-list.is-open {
    transform: translateX(0);
    visibility: visible;
    box-shadow: -20px 0 60px -20px rgba(0, 0, 0, 0.6);
    transition: transform var(--dur-3) var(--ease-out);
  }
  /* the slide-in panel is always dark — force light foreground regardless of
     which section the pill is currently over */
  .nav-list { color: #fff; }
  .nav-list .nav-link { color: #fff; }
  .nav-list .nav-link::after { background: var(--c-mint); }
  body.nav-open .nav-toggle { color: #fff; }
  .nav-link { font-size: 1.375rem; }
  .nav-preview { display: none; }

  body.nav-open { overflow: hidden; }
  body.nav-open::after {
    content: "";
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-overlay) - 1);
  }
}

/* ----- <= 760px : tablet portrait / large phone --------------------------- */
@media (max-width: 760px) {
  :root { --content-max: 640px; }

  /* below this width the container is too narrow to hold the sentence on
     one line at a legible size — let it wrap again, balanced so it never
     leaves a short orphaned line. */
  .hero__support { white-space: normal; text-wrap: balance; }

  .stats { grid-template-columns: 1fr 1fr; gap: var(--sp-6) var(--sp-5); }

  .work__collage { grid-template-columns: 1fr; }
  .work-item,
  .work-item--1, .work-item--2, .work-item--3, .work-item--4 {
    grid-column: 1;
    margin-top: 0;
  }
  .work-card { --tilt: 0deg; transform: none; max-width: 460px; margin-inline: auto; }

  .svc-item__trigger {
    grid-template-columns: 1fr auto;
    grid-template-areas: "num icon" "name icon";
    gap: 0.35rem var(--sp-4);
    align-items: center;
  }
  .svc-item__num { grid-area: num; }
  .svc-item__name { grid-area: name; }
  .svc-item__icon { grid-area: icon; align-self: center; }
  .svc-item__panel-inner,
  .svc-item__panel-inner:has(.svc-item__body--wide) { padding-left: 0; }

  .mid-cta__scatter { display: none; }
  .mid-cta { margin-top: clamp(3rem, 2rem + 6vw, 6rem); padding-bottom: 2rem; }

  /* left-aligned here (not centred) — the gallery sits under the
     left-aligned copy above it, and centring would drift it out of that
     reading column. Re-centred only on true phone widths, below. */
  .about__gallery li,
  .about__gallery li:nth-child(2),
  .about__gallery li:nth-child(3) { flex-basis: 100%; max-width: 460px; margin-top: 0; }

  .bento { grid-template-columns: 1fr; }

  .contact-info__features { grid-template-columns: 1fr; gap: var(--sp-5); }

  .site-footer__main { grid-template-columns: 1fr; }
  .site-footer__bar { flex-direction: column; align-items: flex-start; gap: var(--sp-3); }

  .frame--tilt-a, .frame--tilt-b { transform: rotate(-1deg); }
  .frame--tilt-b { transform: rotate(1deg); }
}

/* ----- <= 520px : phone -------------------------------------------------- */
@media (max-width: 520px) {
  .hero { padding-top: 6.5rem; }
  .stats { grid-template-columns: 1fr; }
  .about__copy p { font-size: 1.125rem; }
  .about__gallery li,
  .about__gallery li:nth-child(2),
  .about__gallery li:nth-child(3) { margin-inline: auto; }
  .contact-card { padding: var(--sp-5); }
  .step { padding: var(--sp-6); }
  /* the base rule's scale compensates for the rotation so the band still
     reaches both edges — this override was dropping that scale entirely,
     leaving visible gaps (and clipped text) at the left/right edges on
     phones. Matches the base rule's 1.15 (verified empirically — smaller
     values still gapped). */
  .marquee { transform: rotate(-3deg) scale(1.15); margin-block: 3rem; }
  .philosophy__img--2 { width: 100%; }
  .frame--tilt-a, .frame--tilt-b { transform: none; }
}

/* ----- fine-pointer hover niceties only ------------------------------------ */
@media (hover: hover) and (pointer: fine) {
  .stat { transition: transform var(--dur-3) var(--ease-out); }
}
