/* ==========================================================================
   Responsive rules. Mobile-first values live in style.css / components.css;
   this file only adapts layouts as the screen narrows.
   ========================================================================== */

@media (max-width: 1100px) {
  /* A blurred header would trap the fixed mobile menu inside its own box. */
  .nav { display: none; }
  .menu-btn {
    display: inline-grid;
    place-items: center;
    width: 48px; height: 48px;
    border: 1.5px solid var(--line-strong);
    border-radius: 50%;
    background: transparent;
  }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .footer__grid { grid-template-columns: 1fr 1fr 1fr; }
  .footer__brand { grid-column: 1 / -1; max-width: none; }
}

@media (max-width: 960px) {
  .offers { grid-template-columns: 1fr; }
  .guide { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .aside-layout { grid-template-columns: 1fr; }
  .aside-layout__intro { position: static; }
  .feature, .split, .visit, .pdp, .fieldnotes { grid-template-columns: 1fr; }
  .split--reverse > :first-child { order: 0; }
  .feature__media { aspect-ratio: 4 / 3.4; }
  .pdp__media { position: relative; inset-block-start: 0; max-height: 70vh; aspect-ratio: 4 / 3.6; }
  .people { grid-template-columns: 1fr; }
  .voices { grid-template-columns: 1fr; }
  .mosaic { columns: 2; }
  .photo--tall { aspect-ratio: 4 / 3.4; }
  .hero::before {
    background:
      linear-gradient(0deg, rgb(40 24 18 / .94) 0%, rgb(40 24 18 / .55) 55%, rgb(40 24 18 / .25) 100%);
  }
  .hero__media img { object-position: 70% 50%; }
}

/* --------------------------------------------------------------------------
   Phone app shell (up to 760px): bottom tab bar, bottom-sheet order drawer
   -------------------------------------------------------------------------- */
@media (max-width: 760px) {
  :root { --tabbar-h: 62px; --safe-b: env(safe-area-inset-bottom, 0px); }
  html { -webkit-tap-highlight-color: transparent; }
  a, button, summary, label, select { touch-action: manipulation; }
  body { padding-block-end: calc(var(--tabbar-h) + var(--safe-b)); }

  /* The header keeps the logo and the menu button; ordering moves to the tab bar. */
  .site-header__actions .cart-btn { display: none; }
  .mobile-nav { inset-block-end: calc(var(--tabbar-h) + var(--safe-b)); padding-block-end: 2rem; }
  .mobile-nav__links a { font-size: 1.6rem; }

  .tabbar {
    position: fixed;
    inset-inline: 0;
    inset-block-end: 0;
    z-index: 70;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: end;
    height: calc(var(--tabbar-h) + var(--safe-b));
    padding-block-end: var(--safe-b);
    background: color-mix(in srgb, var(--cream) 96%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-start-start-radius: 22px;
    border-start-end-radius: 22px;
    box-shadow: 0 -1px 0 var(--line), 0 -8px 28px rgb(40 24 18 / .10);
  }
  .tabbar__item {
    position: relative;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: .2rem;
    min-height: var(--tabbar-h);
    color: var(--muted-ink);
    font-size: .72rem;
    font-weight: 650;
    text-decoration: none;
    transition: color .2s;
  }
  .tabbar__item .icon { width: 25px; height: 25px; transition: transform .2s; }
  .tabbar__item[aria-current='page'] { color: var(--coffee); }
  .tabbar__item[aria-current='page'] .icon { transform: translateY(-1px); stroke-width: 2; }
  .tabbar__item[aria-current='page']::before {
    content: '';
    position: absolute;
    inset-block-start: 0;
    width: 26px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: var(--amber);
  }
  .tabbar__item:active { color: var(--espresso); }

  /* The raised Order button in the middle. */
  .tabbar .tabbar__cart {
    justify-self: center;
    align-self: start;
    width: 62px;
    height: 62px;
    margin-block-start: -24px;
    border: 4px solid var(--cream);
    background: var(--amber);
    color: var(--espresso);
    box-shadow: 0 8px 20px rgb(40 24 18 / .28);
  }
  .tabbar .tabbar__cart:hover { background: var(--amber-hover); border-color: var(--cream); }
  .tabbar .tabbar__cart:active { background: var(--amber-press); }
  .tabbar .tabbar__cart .icon { width: 27px; height: 27px; }
  .tabbar .cart-btn__count { inset-block-start: -4px; inset-inline-end: -6px; border: 2px solid var(--cream); }

  .toasts { inset-block-end: calc(var(--tabbar-h) + var(--safe-b) + .75rem); }
  .testclock { inset-block-end: calc(var(--tabbar-h) + var(--safe-b)); }

  /* The order slides up as a bottom sheet. */
  .drawer {
    inset-block: auto 0;
    inset-inline: 0;
    width: 100%;
    height: 92vh;
    height: 92dvh;
    transform: translateY(104%);
  }
  .drawer.is-open { transform: none; }
  .ticket {
    margin-inline-start: 0;
    -webkit-mask: none;
    mask: none;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -10px 40px rgb(0 0 0 / .28);
  }
  .ticket__head { position: relative; padding: 1.7rem 1.25rem 1rem; }
  .ticket__head::before {
    content: '';
    position: absolute;
    inset-block-start: .6rem;
    inset-inline: 0;
    margin-inline: auto;
    width: 44px;
    height: 5px;
    border-radius: 3px;
    background: var(--line-strong);
  }
  .ticket__title { font-size: 1.7rem; }
  .ticket__body { padding: .5rem 1.25rem 1.5rem; }
  .ticket__foot { padding-inline: 1.25rem; }
}

@media (max-width: 640px) {
  :root { --header-h: 64px; }

  /* Inputs at 16px stop iOS from zooming the page when a field is focused. */
  input, select, textarea, .input, .mini-select { font-size: 16px; }
  .announce { font-size: .8rem; }
  .announce__inner { padding-block: .45rem; gap: .1rem .6rem; }

  /* Product page: the add button stays in reach above the tab bar. */
  .pdp .buy {
    position: sticky;
    inset-block-end: calc(var(--tabbar-h) + var(--safe-b) + .6rem);
    z-index: 20;
    padding: .6rem;
    margin-inline: -.6rem;
    border-radius: var(--r-md);
    background: color-mix(in srgb, var(--cream) 94%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 -1px 0 var(--line), var(--shadow-soft);
  }
  .pdp .buy .btn { flex: 1 1 0; padding-inline: 1rem; }
  .pdp .buy .btn--ghost-dark { flex: 0 0 auto; }

  .brand__logo { width: 34px; }
  .brand__name { font-size: 1.2rem; }
  .brand__sub { font-size: .7rem; }
  .site-header__inner { gap: .75rem; }
  .announce { font-size: .82rem; }

  .hero { min-height: clamp(600px, 92svh, 760px); }
  .board { grid-template-columns: 1fr; gap: 1rem; }
  .board__item { grid-template-columns: 7.5rem 1fr; align-items: baseline; column-gap: 1rem; }
  .board__item .board__detail { grid-column: 2; }

  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.75rem .9rem; }
  .tile__name { font-size: 1.1rem; }
  .tile__foot .price { font-size: 1rem; }
  .add-btn { width: 44px; height: 44px; }
  .tile__meta { font-size: .82rem; }


  .offer { --stub: 124px; }
  .offer__stub { padding: 1rem .75rem 1rem 1rem; }
  .offer__headline { font-size: 1.7rem; }
  .offer__main { padding: 1rem; }


  .segment { gap: .4rem; }
  .buy .btn { flex-basis: 100%; }
  .timeline__item { grid-template-columns: 4rem 1fr; gap: 1rem; }
  .timeline__year { font-size: 1.5rem; }
  .footer__grid { grid-template-columns: 1fr 1fr; gap: 2rem 1.25rem; }
  .footer__col:last-child { grid-column: 1 / -1; }
  .footer__brand .btn { display: none; }
  .mosaic { columns: 2; column-gap: .6rem; }
  .mosaic__item { margin-block-end: .6rem; }
  .shot__cap { padding: 1.6rem .65rem .6rem; }
  .shot__cap strong { font-size: .95rem; }
  .shot__cap span { font-size: .72rem; }
  .shot--empty { padding: 1rem .6rem; }
  .shot--empty strong { font-size: 1rem; }
  .lightbox { width: 100vw; max-height: 100vh; border-radius: 0; }
}

@media (max-width: 520px) {
  .hours__row { flex-wrap: wrap; row-gap: .15rem; }
  .hours__row .leader { display: none; }
  .hours__row > :last-child { margin-inline-start: auto; white-space: nowrap; }
}

@media (max-width: 400px) {
  .btn { padding-inline: 1.2rem; }
  .tile__badge { font-size: .72rem; padding: .22rem .55rem; }
}

/* --------------------------------------------------------------------------
   About, Roastery and Offers: narrower layouts
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .pcards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .offer--photo { grid-template-columns: var(--stub) minmax(0, 1fr) minmax(0, 13rem); }
}

@media (max-width: 860px) {
  .about-hero__grid, .offers-hero, .cta-photo { grid-template-columns: minmax(0, 1fr); }
  .about-hero__copy .h-xl { max-width: none; }
  .collage { max-width: 28rem; margin-inline: auto; }
  .cta-photo__img { aspect-ratio: 16 / 10; }

  .factband { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fact { border-inline-start: 0; border-block-start: 1px solid rgb(255 247 235 / .16); padding: 1.25rem .75rem 1.25rem 0; }
  .fact:nth-child(-n + 2) { border-block-start: 0; }
  .fact:last-child:nth-child(odd) { grid-column: 1 / -1; }


  .roast-hero__grid { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .roast-hero__media { order: -1; min-height: 0; height: clamp(15rem, 48vw, 22rem); }
  .roast-hero__media img { object-position: 50% 40%; }
  .roast-hero__media::after { background: linear-gradient(0deg, var(--espresso), transparent 45%); }
  .roast-hero__copy { padding-inline: var(--gutter); padding-block: 1.5rem clamp(40px, 8vw, 72px); }
  .roast-hero__copy .h-xl { max-width: 16ch; }
  .sourcing-photo { aspect-ratio: 4 / 3; }

  .offer--photo { grid-template-columns: var(--stub) minmax(0, 1fr); }
  .offer--photo .offer__photo { grid-column: 1 / -1; min-height: 0; height: 11rem; margin: 0 .6rem .6rem; }
  .now__item { grid-template-columns: 8rem minmax(0, 1fr); }
}

@media (max-width: 640px) {
  /* Offer tickets stack: price band on top, perforated edge under it. */
  .offer, .offer--photo { grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .offer::before, .offer::after { display: none; }
  .offer__stub {
    position: relative;
    grid-auto-flow: column;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    padding: 1rem 1.25rem;
    border-inline-end: 0;
    border-block-end: 2px dashed var(--line-strong);
  }
  .offer__stub::before, .offer__stub::after {
    content: '';
    position: absolute;
    inset-block-end: -13px;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: var(--notch);
  }
  .offer__stub::before { inset-inline-start: -13px; }
  .offer__stub::after { inset-inline-end: -13px; }
  .offer__headline { font-size: 1.75rem; }
  .offer__main { padding: 1.1rem 1.25rem 1.25rem; }
  .offer--photo .offer__photo { grid-column: auto; order: -1; height: 9.5rem; margin: .6rem .6rem 0; }
  .offer--photo .offer__stub { border-radius: 0; }
  .offer__code-row { width: 100%; }
  .offer__code-row .btn { flex: 1 1 auto; justify-content: center; }

  .about-hero { padding-block: 28px 56px; }
  .collage { max-width: 22rem; }
  .stamp { width: 84px; }
  .values { gap: 1.35rem; }

  .pcards { grid-template-columns: minmax(0, 1fr); gap: .8rem; }
  .pcard { grid-template-columns: 5.5rem minmax(0, 1fr); column-gap: 1rem; row-gap: .2rem; align-items: start; padding: 1rem; }
  .pcard__art { grid-row: 1 / span 3; height: 5.5rem; margin: 0; }
  .pcard__art svg { width: 4.6rem; }
  .pcard__no, .pcard__title, .pcard__text { padding-inline: 0; }
  .pcard__title { font-size: 1.3rem; }

  .quoteband { padding-block: 64px; }
  .tagrow li { font-size: .82rem; padding: .35rem .8rem; }
}

@media (max-width: 520px) {
  .people--cards .person { padding: 1.25rem; }

  .bignums { grid-template-columns: minmax(0, 1fr); gap: .6rem; }
  .bignum { grid-template-columns: 9rem minmax(0, 1fr); column-gap: .9rem; row-gap: 0; align-items: center; padding: 1rem 1.1rem; }
  .bignum__value { grid-row: 1 / span 2; font-size: 1.9rem; }
  .bignum__label { margin: 0; }

  .now { padding: 1.25rem 1.1rem; }
  .now__item { grid-template-columns: minmax(0, 1fr); gap: .5rem; }
  .week__row { grid-template-columns: minmax(0, 1fr); padding: .85rem 1rem; }
  .week__days { justify-content: space-between; }
  .week__day { width: 2.2rem; }
  .timeline--rail .timeline__item { grid-template-columns: 3.6rem minmax(0, 1fr); gap: .75rem; }
  .btn-row .btn { flex: 1 1 auto; }
}

/* --------------------------------------------------------------------------
   Home redesign: narrower layouts
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .menu-home { grid-template-columns: minmax(0, 1fr); }
  .feature { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: none; }
  .feature__media { aspect-ratio: auto; min-height: 100%; }
  .feature__media img { position: absolute; inset: 0; }
  .tiles--rail { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .roast-home, .visit-faq { grid-template-columns: minmax(0, 1fr); }
  .promo__grid { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  .promo__copy { justify-items: center; text-align: center; }
  .promo__points { text-align: start; }
  .promo__stage { width: min(100%, 19rem); }
  .roast-home__photo { aspect-ratio: 16 / 11; }
  .roast-home__photo img { object-position: 50% 62%; }
  .board { grid-template-columns: minmax(0, 1fr); gap: .5rem; padding: .35rem; border-radius: var(--r-md); background: rgb(40 24 18 / .58); border: 1px solid rgb(255 247 235 / .18); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
  .board__item { padding: .75rem .9rem; border: 0; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; grid-template-columns: 6.6rem minmax(0, 1fr); column-gap: .75rem; align-items: baseline; }
  .board__item + .board__item { border-block-start: 1px solid rgb(255 247 235 / .16); border-radius: 0; }
  .board__item .board__detail { grid-column: 2; }
}

@media (max-width: 640px) {
  :root { --section-y: 52px; }
  .hero__eyebrow { letter-spacing: .1em; font-size: .72rem; }
  .hero__inner { gap: 1.5rem; }
  .hero__copy { gap: 1.1rem; }
  .section-head { margin-block-end: 1.5rem; }

  /* Menu groups and featured drinks scroll sideways like app rails. */
  .cats { margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); scroll-padding-inline: var(--gutter); }
  .cat { flex: 0 0 auto; min-width: 0; padding: .65rem .95rem .65rem .7rem; column-gap: .65rem; grid-template-columns: 36px auto; }
  .cat__icon { width: 36px; height: 36px; }
  .cat__name { font-size: 1.05rem; }
  .cat__meta { font-size: .78rem; white-space: nowrap; }

  .feature { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .feature__media { aspect-ratio: 16 / 11; min-height: 0; }
  .feature__media img { position: static; }
  .feature__body { padding: 1.25rem 1.25rem 1.5rem; }
  .feature__name { font-size: 2rem; }
  .feature__price strong { font-size: 1.9rem; }

  .tiles--rail {
    display: flex;
    gap: .9rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    margin-inline: calc(-1 * var(--gutter));
    padding-inline: var(--gutter);
    scroll-padding-inline: var(--gutter);
    padding-block-end: .25rem;
  }
  .tiles--rail::-webkit-scrollbar { display: none; }
  .tiles--rail .tile { flex: 0 0 min(62vw, 15rem); scroll-snap-align: start; }

  .values--grid { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .values--grid .value { grid-template-columns: 3.1rem minmax(0, 1fr); gap: 1rem; }
  .visitcard { padding: 1.35rem 1.25rem 1.5rem; }
  .ctaband__inner { gap: 1.25rem; }
  .ctaband .btn-row { width: 100%; }
  .ctaband .btn-row .btn { flex: 1 1 auto; justify-content: center; }
  .ctaband__steps { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .subnav__inner { scroll-padding-inline: var(--gutter); }
  .map-card { aspect-ratio: 16 / 10; }
}

/* Section nav pills (Visit page) stay compact on narrow phones. */
@media (max-width: 520px) {
  .subnav__inner { gap: .4rem; }
  .subnav a { padding-inline: .9rem; }
}
@media (max-width: 380px) {
  .subnav a { padding-inline: .72rem; }
}

/* The bottom tab bar already has the Order button, so the menu panel does not repeat it on phones. */
@media (max-width: 760px) {
  .mobile-nav > .btn { display: none; }
}

/* Round 3: home page coffee moments and step photos on smaller screens. */
@media (max-width: 640px) {
  .mosaic--home { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 9.5rem; }
  .mosaic--home .mosaic__item:first-child { grid-column: 1 / -1; grid-row: span 2; }
  .pcard__art--photo { margin: 0; aspect-ratio: auto; border-radius: var(--r-sm); }
}

@media (max-width: 860px) {
  .mosaic--grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: clamp(9rem, 34vw, 14rem); }
}
@media (max-width: 640px) {
  .mosaic--grid { grid-auto-rows: 9.5rem; }
}

@media (max-width: 960px) {
  .story-strip__block { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
}
@media (max-width: 760px) {
  .values--row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .timeline--row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem 1rem; }
  .timeline--row::before, .timeline--row .timeline__item::before { display: none; }
  .timeline--row .timeline__item { padding-top: 0; }
}

@media (max-width: 860px) {
  .quoteband--facts .fact { padding: 1.1rem .5rem; }
  .quoteband--facts .factband { margin-block-start: .25rem; }
}

@media (min-width: 641px) and (max-width: 960px) {
  .people--cards .person { flex-basis: calc((100% - 1rem) / 2); }
}

@media (max-width: 640px) {
  .people--cards .person { flex-basis: min(82vw, 19rem); }
}

@media (min-width: 961px) {
  /* Three whole cards fill the container; no half card peeks out beside the page margin. */
  .people--cards { padding-block: .75rem; }
  .rail__viewport:has(.people--cards) { margin-inline: 0; padding-inline: 0; scroll-padding-inline: 0; margin-block: -.75rem; }
}

/* Menu toolbar and cards ------------------------------------------------------------------------- */
@media (max-width: 1179px) {
  /* Not enough room for one row: search and sort on top, the filters centred below. */
  .toolbar__inner { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'search sort' 'chips chips'; }
}
@media (max-width: 1099px) {
  .tiles--menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  /* Phones: one slim panel. Search and sort share a row, the filters become small pills that scroll sideways. */
  .toolbar { padding-block: .5rem; }
  .toolbar__inner { gap: .5rem; padding: .55rem .6rem; border-radius: 1.5rem; }
  .sort label { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .sort .mini-select { width: 7.4rem; padding-inline-start: .8rem; }
  .search .input { padding-inline-start: 2.6rem; }
  .search .icon { inset-inline-start: .85rem; }
  .chips { flex-wrap: nowrap; justify-content: flex-start; gap: .4rem; overflow-x: auto; margin-inline: -.6rem; padding-inline: .6rem; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; display: inline-flex; align-items: center; gap: .45rem; min-width: 0; min-height: 44px; padding: .25rem .95rem .25rem .3rem; border: 1.5px solid var(--line-strong); border-radius: var(--r-pill); font-size: .9rem; }
  .chip__badge { width: 1.95rem; height: 1.95rem; clip-path: none; border-radius: 50%; }
  .chip__badge img { width: 1.25rem; height: 1.25rem; }
  .chip__badge .icon { width: 1.1rem; height: 1.1rem; }
  .chip:hover .chip__badge { transform: none; }
  .chip[aria-pressed='true'] { background: var(--espresso); border-color: var(--espresso); }
  .chip[aria-pressed='true'] .chip__label { color: var(--cream); }
}
@media (max-width: 700px) {
  .tiles--menu { grid-template-columns: minmax(0, 1fr); gap: .9rem; }
  .tiles--menu .tile--card { grid-template-columns: 8.25rem minmax(0, 1fr); gap: .4rem 1rem; padding: 1rem; }
  .tile--card .tile__name { font-size: 1.28rem; }
  .tile--card .tile__foot .price { font-size: 1.5rem; }
  .tiles--menu .skel { grid-template-columns: 8.25rem minmax(0, 1fr); }
}

/* Hero board: three items side by side on phones and tablets */
@media (max-width: 860px) {
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; padding: .25rem; }
  .board__item { grid-template-columns: minmax(0, 1fr); gap: .15rem; padding: .7rem .5rem; align-items: start; }
  .board__item + .board__item { border-block-start: 0; border-inline-start: 1px solid rgb(255 247 235 / .16); }
  .board__item .board__detail { grid-column: auto; }
  .board__label { font-size: .72rem; }
  .board__value { font-size: .82rem; letter-spacing: -.01em; overflow-wrap: normal; }
  .board__detail { font-size: .75rem; line-height: 1.35; }
}
