/* ==========================================================================
   Responsive.
   Load LAST — several rules here are deliberate overrides of a base rule, and
   in the cascade a later plain rule beats an earlier media query.
   Mobile is re-composed, not shrunk: the work grid becomes a single editorial
   column, the process table becomes stacked blocks, the menu becomes one list.
   ========================================================================== */

/* Nothing may depend on hover to be readable. On touch, the person bio and
   the project reveal are simply always shown. */
@media (hover: none) {
  .pcard__reveal { transform: none; position: static; background: none; color: var(--accent-text); padding: 0.75rem 0 0; }
  .person__media img { filter: none; }
}

/* --- ≤1280px ------------------------------------------------------------- */
@media (max-width: 1280px) {
  .work-grid > *:nth-child(6n + 1) { grid-column: 1 / span 8; }
  .work-grid > *:nth-child(6n + 2) { grid-column: 9 / span 4; }
  .work-grid > *:nth-child(6n + 3) { grid-column: 1 / span 5; }
  .work-grid > *:nth-child(6n + 4) { grid-column: 6 / span 7; }
  .work-grid > *:nth-child(6n + 5) { grid-column: 1 / span 7; }
  .work-grid > *:nth-child(6n + 6) { grid-column: 8 / span 5; }
  .masonry { column-count: 2; }
}

/* --- ≤1080px: the desktop nav gives way to the full-screen menu ---------- */
@media (max-width: 1080px) {
  .nav { display: none; }
  .header__cta { display: none; }
  .burger { display: block; }

  .menu__body { grid-template-columns: minmax(0, 1fr); align-content: start; gap: 2rem; }
  .menu__secondary { grid-template-columns: repeat(2, minmax(0, 1fr)); display: grid; }

  .split--text-image,
  .split--image-text,
  .split--wide-narrow,
  .split--narrow-wide,
  .split--even { grid-template-columns: minmax(0, 1fr); }
  .split--image-text > .split__media { order: -1; }

  .phero__grid { grid-template-columns: minmax(0, 1fr); }

  .frow { grid-template-columns: minmax(0, 1fr); }
  .frow:nth-child(even) > .frow__media { order: 0; }

  .selector__panel { grid-template-columns: minmax(0, 1fr); }
  .mb { grid-template-columns: minmax(0, 1fr); }
  .mb__board { position: static; }
  .quiz__result { grid-template-columns: minmax(0, 1fr); }
  .contact-grid { grid-template-columns: minmax(0, 1fr); }

  .chapter-block,
  .chapter-block:nth-child(even) { grid-template-columns: minmax(0, 1fr); }
  .chapter-block:nth-child(even) .chapter-block__text { order: 0; }

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

/* --- ≤860px -------------------------------------------------------------- */
@media (max-width: 860px) {
  :root { --header-h: 64px; }

  .work-grid { grid-template-columns: minmax(0, 1fr); }
  .work-grid > * { grid-column: 1 / -1 !important; }
  /* Reintroduce rhythm on a single column by insetting every other card. */
  .work-grid > *:nth-child(even) { padding-inline: clamp(1rem, 8vw, 4rem) 0; }

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

  .pstep {
    grid-template-columns: 3.25rem minmax(0, 1fr);
    row-gap: 0.5rem;
  }
  .pstep__body { grid-column: 2; }
  .pstep__weeks { grid-column: 2; }
  .pstep__panel { grid-column: 2; }

  .tline { grid-template-columns: 4.5rem minmax(0, 1fr); row-gap: 0.4rem; }
  .tline__body { grid-column: 2; }

  .hero__foot { grid-template-columns: minmax(0, 1fr); }
  .hero__title { max-width: 100%; }

  .contact-list a, .contact-list .row { grid-template-columns: minmax(0, 1fr); row-gap: 0.25rem; }

  .article-body .figure--wide { width: auto; margin-inline: 0; }

  .lightbox__nav { width: 46px; height: 46px; }
  .lightbox__nav--prev { left: 0.5rem; }
  .lightbox__nav--next { right: 0.5rem; }
}

/* --- ≤640px -------------------------------------------------------------- */
@media (max-width: 640px) {
  .masonry { column-count: 1; }

  /* Footer nav categories (Studio / Services / Explore) go two per row on
     mobile instead of stacking one per row; the brand block still spans the
     full width above them. */
  .footer__main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer__brand { grid-column: 1 / -1; }
  .footer__bottom .footer__legal { margin-left: 0; }

  .menu__secondary { grid-template-columns: minmax(0, 1fr); }
  .menu__foot { flex-direction: column; align-items: flex-start; }
  .menu__foot .btn { margin-left: 0; width: 100%; justify-content: center; }

  .btn-row .btn { flex: 1 1 100%; justify-content: center; }

  .quotes__controls { flex-wrap: wrap; }

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

  /* Horizontal rails are a better mobile pattern than a tall stack of cards
     for the style and kitchen selectors. */
  .selector__tabs,
  .filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    /* Let the row bleed to the viewport edge and pad it back, so the last
       chip is not visually clipped by the shell's padding. */
    margin-inline: calc(var(--pad-x) * -1);
    padding-inline: var(--pad-x);
    scroll-padding-inline: var(--pad-x);
    padding-bottom: 0.5rem;
  }
  .selector__tabs::-webkit-scrollbar,
  .filters::-webkit-scrollbar { display: none; }
  .filter, .selector__tabs .btn { flex: none; }

  .ba__grip { width: 46px; height: 46px; }
  .ba__tag { top: 0.6rem; font-size: 0.625rem; }
  .ba__tag--before { left: 0.6rem; }
  .ba__tag--after { right: 0.6rem; }
}

/* --- ≤380px: the smallest supported width -------------------------------- */
@media (max-width: 380px) {
  :root { --pad-x: 1.15rem; }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .pdata { grid-template-columns: minmax(0, 1fr); }
  .mb__options { grid-template-columns: minmax(0, 1fr); }
}

/* --- Very wide ----------------------------------------------------------- */
@media (min-width: 1800px) {
  :root { --fs-body: 1.0938rem; }
  .masonry { column-count: 3; }
}

/* --- Print --------------------------------------------------------------- */
@media print {
  .header, .menu, .to-top, .progress, .lightbox { display: none !important; }
  body { background: #fff; color: #000; }
  .hero { min-height: auto; color: #000; background: #fff; }
  .hero__scrim, .hero__media { display: none; }
  .hero__title, .hero__lead { color: #000; }
  a[href^='http']::after { content: ' (' attr(href) ')'; font-size: 0.8em; }
}
