/* ============================================================================
   Press Esc — mobile.css
   Mobile-only refinements. Desktop layout remains owned by main.css.
   ========================================================================== */

/* The shop filter trigger exists in the document but is intentionally absent
   from desktop layouts. */
.mobile-filter-toggle { display: none; }

@media (max-width: 760px) {
  :root {
    --header-h: 56px;
    --mobile-gutter: 20px;
  }

  html {
    scroll-padding-top: calc(var(--header-h) + 16px);
    -webkit-tap-highlight-color: rgba(240, 77, 102, .14);
  }

  body {
    overflow-x: hidden;
    font-size: .96rem;
  }

  button,
  input,
  select,
  textarea { font-size: 1rem; }

  .wrap {
    padding-left: max(var(--mobile-gutter), env(safe-area-inset-left));
    padding-right: max(var(--mobile-gutter), env(safe-area-inset-right));
  }

  .sec { padding: 42px 0; }
  .sec-tight { padding: 30px 0; }
  .page-head { padding: 32px 0 8px; }
  .page-head h1 { font-size: clamp(2rem, 9vw, 2.75rem); }
  .page-head > p,
  .page-head .wrap > p { font-size: 1rem; line-height: 1.55; }
  .shop-external-row { margin-top: 16px; }
  .shop-external-link {
    width: 100%;
    min-height: 46px;
    justify-content: center;
    padding: 12px 16px;
  }
  .sec-head { gap: 10px; margin-bottom: 22px; }
  .sec-head h2 { font-size: clamp(1.75rem, 8vw, 2.35rem); }
  .eyebrow { font-size: .66rem; letter-spacing: .13em; }
  .prose h2 { font-size: 1.5rem; }
  .prose h3 { font-size: 1.08rem; }

  /* Header: retain menu, search, wishlist and cart without horizontal overflow. */
  .studio-notice {
    padding: 6px 10px;
    font-size: .69rem;
    line-height: 1.35;
  }
  .announce { padding: 7px 10px; font-size: .76rem; }
  header.site { backdrop-filter: saturate(1.1) blur(9px); }
  .nav-inner {
    min-height: var(--header-h);
    gap: 1px;
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }
  .menu-btn { flex: 0 0 40px; }
  .icon-btn { width: 40px; height: 40px; }
  .nav-tools { gap: 0; }
  .nav-tools .icon-btn { width: 38px; height: 38px; }
  .nav-tools a[aria-label="Account"] { display: none; }
  .nav-tools svg { width: 20px; height: 20px; }
  .brand-logo { gap: 7px; }
  .brand-logo .brand-key {
    width: 31px;
    height: 31px;
    flex-basis: 31px;
  }
  .brand-logo .brand-wordmark { font-size: 1rem; }
  .count-dot { top: 1px; right: 1px; }

  /* Homepage hero: message first, art second, with a tighter first screen. */
  .hero { padding: 28px var(--mobile-gutter) 36px; }
  .hero-grid { gap: 24px; }
  .hero-copy { order: 0; }
  .hero-copy h1 {
    font-size: clamp(2.25rem, 11vw, 3.05rem);
    line-height: 1.02;
    margin-bottom: .38em;
  }
  .lead { font-size: .98rem; line-height: 1.55; }
  .hero-cta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
    margin: 20px 0 14px;
  }
  .hero-cta .btn {
    width: 100%;
    min-height: 46px;
    justify-content: center;
  }
  .hero-hint { font-size: .73rem; line-height: 1.45; }
  .hero-art-stage {
    order: 1;
    min-height: 305px;
    width: min(100%, 430px);
    margin: 0 auto;
  }
  .hero-art-card span { display: none; }
  .hero-art-one { width: 63%; height: 72%; }
  .hero-art-two { width: 48%; height: 50%; }
  .hero-art-three { width: 41%; height: 41%; }
  .hero-art-key {
    left: 36%;
    top: 40%;
    width: 76px !important;
    height: 66px !important;
    font-size: 1rem !important;
    border-radius: 12px !important;
  }
  .hero-art-stage .hero-key-caption { display: none; }

  /* Scannable strips instead of tall wrapped stacks. */
  .fact-strip .wrap {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 26px;
    padding-top: 14px;
    padding-bottom: 14px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .fact-strip .wrap::-webkit-scrollbar { display: none; }
  .fact { min-width: 132px; scroll-snap-align: start; }
  .fact b { font-size: .98rem; }
  .fact span { font-size: .78rem; }

  .ci-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 14px 4px;
  }
  .ci-row:hover { padding-left: 8px; }
  .ci-row .n { font-size: 1.18rem; }
  .ci-row .cnt { font-size: .62rem; }
  .ci-row .go { opacity: 1; font-size: .7rem; }

  /* Product cards stay two-up, but remove redundant mobile chrome. */
  .grid-products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 11px;
  }
  .pcard { min-width: 0; }
  .plate { aspect-ratio: 4 / 5; }
  .image-badge {
    left: 6px;
    top: 6px;
    max-width: calc(100% - 50px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 5px 7px;
    font-size: .52rem;
  }
  .save-btn {
    top: 5px;
    right: 5px;
    width: 40px;
    height: 40px;
  }
  .meta { padding: 9px 1px 5px; }
  .meta .kind { font-size: .58rem; letter-spacing: .07em; }
  .meta h3 {
    min-height: 2.3em;
    margin: .22em 0 .25em;
    font-size: .98rem;
    line-height: 1.15;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  .price { font-size: .82rem; }
  .why {
    font-size: .68rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }
  .card-actions { padding-top: 5px; }
  .card-actions .mini:first-child { display: none; }
  .card-actions .mini.primary {
    width: 100%;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 5px;
    text-align: center;
    font-size: .6rem;
    line-height: 1.2;
  }

  /* Let the cards use the screen width; place carousel arrows below. */
  .featured-carousel {
    grid-template-columns: 1fr auto auto !important;
    gap: 8px !important;
  }
  .featured-carousel-window {
    grid-column: 1 / -1;
    grid-row: 1;
    padding-bottom: 4px;
  }
  .featured-carousel > .featured-carousel-arrow:first-child {
    grid-column: 2;
    grid-row: 2;
  }
  .featured-carousel > .featured-carousel-arrow:last-child {
    grid-column: 3;
    grid-row: 2;
  }
  .featured-carousel-arrow { width: 42px !important; height: 42px !important; }
  .featured-carousel-meta {
    grid-column: 1;
    grid-row: 2;
    align-self: center;
    margin: 0 !important;
    text-align: left;
  }

  .archive-band,
  .ed-band { padding: 25px 20px; }
  .archive-band { gap: 20px; }
  .archive-band h2 { font-size: clamp(2.25rem, 12vw, 3.6rem); }
  .archive-band::after { top: -26px; font-size: 9rem; }
  .archive-band p,
  .ed-band p { font-size: .96rem; }

  /* General stacked layouts, including pages with desktop inline grid styles. */
  .mobile-stack {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 26px !important;
  }
  body[data-page="index"] .mobile-home-tools {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
  }
  body[data-page="index"] .mobile-home-tools > div { padding: 22px !important; }
  body[data-page="journal"] .journal-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 14px !important;
  }
  body[data-page="journal"] .journal-grid .q-result-card { padding: 21px; }

  /* Shop controls: one filter button, horizontally swipable filter cards. */
  body[data-page="shop"] #collections { display: block; }
  .mobile-filter-toggle {
    width: 100%;
    min-height: 46px;
    display: inline-flex;
    justify-content: center;
    margin-bottom: 14px;
  }
  .mobile-filter-toggle[aria-expanded="true"] { background: var(--ink); color: var(--text-inverse); }
  #mobileFilterCount:empty { display: none; }
  #mobileFilterCount {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    display: inline-grid;
    place-items: center;
    border-radius: var(--r-pill);
    background: var(--berry);
    color: #fff;
    font-family: var(--font-spec);
    font-size: .68rem;
  }
  .facet-groups { display: none !important; }
  .facet-groups.mobile-open {
    display: flex !important;
    position: static;
    gap: 11px;
    width: calc(100% + (var(--mobile-gutter) * 2));
    margin: 0 calc(var(--mobile-gutter) * -1) 20px;
    padding: 0 var(--mobile-gutter) 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }
  .facet-groups.mobile-open::-webkit-scrollbar { display: none; }
  .facet-groups fieldset {
    flex: 0 0 min(78vw, 286px);
    max-height: 340px;
    overflow-y: auto;
    scroll-snap-align: start;
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-panel);
    padding: 14px;
    background: color-mix(in srgb, var(--bg-elevated) 94%, transparent);
  }
  .facet-groups legend { padding: 0 4px; }
  .facet-opt { min-height: 42px; padding: 8px 2px; }
  .facet-opt input { width: 18px; height: 18px; flex: none; }
  .results-meta { gap: 9px; margin-bottom: 15px; }
  .results-meta > div:last-child {
    width: 100%;
    display: flex !important;
    flex-wrap: wrap;
    gap: 7px !important;
    justify-content: space-between;
  }
  #resultCount { font-size: .76rem; }
  .live-sync-note { font-size: .62rem; }
  #sortSel {
    flex: 1 0 100%;
    width: 100%;
    min-height: 44px;
  }
  .filter-bar {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 3px;
    scrollbar-width: none;
  }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-bar .chip { flex: none; }
  .shop-render-error { padding: 22px; }

  /* Forms and calculators: prevent iOS zoom and keep controls thumb-friendly. */
  .calc { padding: 16px; }
  .calc-grid { gap: 10px; }
  .field input,
  .field select,
  .field textarea,
  textarea {
    width: 100%;
    min-height: 44px;
    font-size: 1rem !important;
  }
  .field label { font-size: .66rem; }
  .calc-out .row { gap: 12px; font-size: .88rem; }
  .calc-out .row span:first-child { min-width: 0; }
  .calc-out .row b { text-align: right; }
  body[data-page="trade"] .calc-grid,
  body[data-page="support"] .calc-grid { grid-template-columns: 1fr; }
  body[data-page="trade"] form .btn,
  body[data-page="support"] form .btn { width: 100%; justify-content: center; }

  /* Support page section links become a compact swipe row. */
  body[data-page="support"] .mobile-stack > nav.calc {
    position: static !important;
    display: flex;
    align-items: center;
    gap: 5px;
    overflow-x: auto;
    padding: 8px;
    scrollbar-width: none;
  }
  body[data-page="support"] .mobile-stack > nav.calc::-webkit-scrollbar { display: none; }
  body[data-page="support"] .mobile-stack > nav.calc h3 { display: none; }
  body[data-page="support"] .mobile-stack > nav.calc p { flex: none; margin: 0; }
  body[data-page="support"] .mobile-stack > nav.calc a {
    display: block;
    padding: 10px 12px;
    border-radius: var(--r-pill);
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    text-decoration: none;
    white-space: nowrap;
    font-size: .82rem;
  }

  /* Quiz. */
  .quiz-shell { width: 100%; }
  .opts { grid-template-columns: 1fr; gap: 9px; margin: 18px 0; }
  .opt { min-height: 68px; padding: 14px 14px 14px 18px; }
  .o-label { font-size: 1.05rem; }
  .o-desc { font-size: .8rem; }
  .q-nav { gap: 12px; }
  .q-nav .spec { text-align: right; font-size: .65rem; }
  .q-result-card { padding: 20px; }
  .quiz-shell .grid-products[style] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  /* Product page. */
  body[data-page="product"] { padding-bottom: 78px; }
  .pdp { gap: 24px; padding: 22px 0; }
  .pdp-info h1 { font-size: clamp(2rem, 9vw, 2.7rem); }
  .pdp-info .byline { font-size: .96rem; }
  .pdp-thumbs {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 2px 2px 6px;
    scrollbar-width: none;
  }
  .pdp-thumbs::-webkit-scrollbar { display: none; }
  .pdp-thumbs button { width: 58px; height: 70px; flex: 0 0 58px; }
  .price-row .p { font-size: 1.45rem; }
  .spec-table { font-size: .85rem; }
  .spec-table th { width: 38%; font-size: .67rem; }
  .spec-table th,
  .spec-table td { padding: 9px 3px; }
  .opt-row { gap: 7px; }
  .opt-pill { min-height: 42px; padding: 8px 12px; font-size: .84rem; }
  .buy-panel { padding: 15px; }
  details summary { min-height: 46px; display: flex; align-items: center; }
  .sticky-buy {
    padding: 10px max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    gap: 8px;
  }
  .sticky-buy .sb-info { min-width: 0; }
  .sticky-buy .sb-info b {
    max-width: 52vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .92rem;
  }
  .sticky-buy .sb-info span { font-size: .68rem; }
  .sticky-buy .btn { flex: none; min-height: 42px; padding: 10px 15px; font-size: .82rem; }

  /* Tables stay usable without shrinking text into dust. */
  .mat-table-wrap {
    width: calc(100% + (var(--mobile-gutter) * 2));
    margin-left: calc(var(--mobile-gutter) * -1);
    margin-right: calc(var(--mobile-gutter) * -1);
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }
  .mat-table { min-width: 650px; font-size: .82rem; }
  .mat-table th,
  .mat-table td { padding: 11px 12px; }
  .mat-table th:first-child,
  .mat-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--bg-elevated);
    box-shadow: 1px 0 0 var(--border-subtle);
  }
  .mat-table thead th:first-child { z-index: 3; background: var(--bg-recessed); }

  /* Search, menu and cart become true phone-sized surfaces. */
  .search-panel { max-height: 100dvh; }
  .search-head {
    gap: 8px;
    padding: max(12px, env(safe-area-inset-top)) 12px 12px;
  }
  .search-head input { min-width: 0; font-size: 1rem; }
  .search-head .keycap { padding: 5px 7px; font-size: .62rem; }
  .search-body { padding: 0 10px 14px; }
  .search-opt { gap: 10px; padding: 10px 8px; }
  .so-glyph { width: 38px; height: 46px; }
  .so-title { font-size: .9rem; }
  .so-side { max-width: 34%; }
  .so-why { display: none; }

  .drawer {
    width: 100%;
    max-width: none;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .drawer-head { padding: max(12px, env(safe-area-inset-top)) 14px 12px; }
  .drawer-items { padding: 8px 14px; }
  .drawer-foot { padding: 14px; }
  .cart-line { gap: 10px; }
  .cl-plate { width: 50px; height: 62px; }
  .cl-top b { font-size: .9rem; }
  .cl-cfg { font-size: .72rem; }
  .cl-qty button { width: 36px; height: 36px; }

  .mobile-menu {
    width: min(360px, 92vw);
    max-width: 100%;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mm-head { padding: max(14px, env(safe-area-inset-top)) 14px 12px; }
  .mm-links {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
  }
  .mm-links a {
    min-height: 46px;
    display: flex;
    align-items: center;
    padding: 10px 12px;
    font-size: 1rem;
  }

  #pe-toasts {
    left: 12px;
    right: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    transform: none;
  }
  .pe-toast { width: min(100%, 380px); text-align: center; }

  /* Footer: brand full-width, link groups two-up. */
  footer.site { margin-top: 48px; padding: 40px 0 22px; }
  .foot-top {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 26px 20px;
    padding-bottom: 28px;
  }
  .foot-brand { grid-column: 1 / -1; }
  .news-form { width: 100%; max-width: none; }
  .news-form input { min-width: 0; font-size: 1rem; }
  .foot-col a { min-height: 38px; display: flex; align-items: center; padding: 5px 0; }
  .foot-bottom { align-items: flex-start; flex-direction: column; padding-top: 18px; }

  /* Standalone error page. */
  body:not([data-page]) .status-panel[style*="text-align:center"] { padding: 24px !important; }

  /* Mobile background artwork should frame the first screen, not stretch to
     the full height of long catalog pages. */
  body[data-page="index"],
  body[data-page="journal"],
  body[data-page="trade"],
  body[data-page="materials"],
  body[data-page="quiz"] {
    background-size: auto 100svh;
    background-position: center top;
    background-attachment: scroll;
  }
  body[data-page="shop"] {
    background-size: auto 100svh, auto 100svh;
    background-attachment: scroll, scroll;
  }
}

@media (max-width: 390px) {
  :root { --mobile-gutter: 18px; }
  .wrap { padding-left: max(var(--mobile-gutter), env(safe-area-inset-left)); padding-right: max(var(--mobile-gutter), env(safe-area-inset-right)); }
  .nav-inner { padding-left: 5px; padding-right: 5px; }
  .brand-logo .brand-wordmark { font-size: .94rem; }
  .nav-tools .icon-btn { width: 36px; height: 36px; }
  .hero { padding-left: var(--mobile-gutter); padding-right: var(--mobile-gutter); }
  .grid-products { gap: 16px 9px; }
  .meta h3 { font-size: .92rem; }
  .card-actions .mini.primary { font-size: .56rem; }
  .archive-band,
  .ed-band { padding: 22px 17px; }
}

@media (max-width: 350px) {
  .brand-logo .brand-wordmark { display: none; }
  .brand-logo { margin-left: 2px; }
  .calc-grid { grid-template-columns: 1fr; }
  .foot-top { grid-template-columns: 1fr; }
  .foot-brand { grid-column: 1; }
}
