/* ============================================================
   Whiskey Buddy — the app catalogue (T120, 2026-08-03).

   Loaded on /v2/catalog for every viewport, but every rule is inside
   @media (max-width:860px) — the SAME fence the former Buddy script and the rest of
   the app use. Above it this file contributes nothing and the desktop grid
   (wb-components.css .cat-*) is untouched. Do not add a second breakpoint:
   tests/test_v2_app_landing_viewport_fences.py pins 860/861 consistency.

   Reuses catalog.css's :root tokens (--card/--ink/--muted/--line/--accent/
   --green/--red/--round/--sans) — no new palette.

   LAYOUT PRINCIPLE: one column, and every optional element COLLAPSES when the
   data is missing rather than reserving space. Rows are allowed to be
   different heights; that is the point of leaving the grid. The only fixed
   dimensions are the image well (so a missing photo can't shift the text
   column) and the name's 2-line clamp (so a 90-character canonical name can't
   push the price off the card).
   ============================================================ */

@media (max-width:860px){

  #catMobile{display:block}
  .catm{padding:0 .85rem}

  /* ---------- head + search ---------- */
  .catm-head{padding:.9rem 0 .5rem}
  .catm-title{font-family:var(--sans);font-size:1.35rem;font-weight:750;
    letter-spacing:-.015em;line-height:1.15;color:var(--ink);margin:0}
  .catm-title em{font-style:normal;color:var(--accent)}

  /* Sticky under the site header. --wb-header-h is published by the former Buddy script's
     ResizeObserver, so this tracks a header that changes height. The sticky
     positioning lives on the ROW (T347), not just the search box, so the
     Buddy opener pins along with it. */
  .catm-search-row{position:sticky;top:calc(var(--wb-header-h,0px) - 1px);z-index:30;
    display:flex;align-items:center;gap:.5rem;margin:0 0 .55rem}
  .catm-searchbar{flex:1;min-width:0;display:flex;align-items:center;gap:.5rem;
    background:var(--card);border:1px solid var(--line);border-radius:12px;
    padding:.1rem .6rem;box-shadow:0 1px 0 rgba(var(--sk-q-shadow-rgb),.05)}
  .catm-searchbar:focus-within{border-color:var(--focus);
    box-shadow:0 0 0 3px rgba(201,135,54,.18)}
  .catm-search-ico{display:grid;place-items:center;color:var(--muted);flex:none}
  input.catm-search{flex:1;min-width:0;font:inherit;font-size:1rem;
    color:var(--ink);background:transparent;border:0;outline:none;
    padding:.62rem 0;-webkit-appearance:none;appearance:none}
  input.catm-search::-webkit-search-cancel-button{display:none}
  .catm-clear{flex:none;border:0;background:transparent;color:var(--muted);
    font-size:1.35rem;line-height:1;padding:.1rem .25rem;cursor:pointer}
  /* T347 — the at-rest Buddy opener living in the pinned search row (Option
     C, sprint-state/ui-acceptance/t1832-catalogue-buddy-opener-2026-08-19/
     option_c_header_row_icon.png). The SVG already paints its own gradient
     circle, so the button itself carries no background/border — just sizing
     and a tap target big enough for a phone. */
  .catm-buddy-open{flex:none;width:36px;height:36px;padding:0;border:0;
    background:none;border-radius:50%;display:inline-flex;align-items:center;
    justify-content:center;cursor:pointer}
  .catm-buddy-open:active{filter:brightness(.96)}

  /* ---------- controls row ---------- */
  .catm-controls{display:flex;align-items:center;justify-content:space-between;
    gap:.6rem;margin-bottom:.5rem}
  .catm-filters-btn{display:inline-flex;align-items:center;gap:.38rem;
    font-family:var(--round);font-weight:600;font-size:.86rem;color:var(--ink);
    background:var(--card);border:1px solid var(--line);border-radius:999px;
    padding:.42rem .82rem;cursor:pointer}
  .catm-filters-btn:active{background:var(--soft)}
  .catm-filters-n{display:inline-grid;place-items:center;min-width:1.15rem;
    height:1.15rem;padding:0 .3rem;border-radius:999px;background:var(--accent);
    color:#fff;font-size:.7rem;font-weight:700;font-variant-numeric:tabular-nums}
  /* An author `display` beats the UA stylesheet's [hidden]{display:none}, so
     without this the count badge renders as an empty brass dot when NO filters
     are active — which reads as "something is on" when nothing is. Caught on
     the real app, 2026-08-03. */
  .catm-filters-n[hidden]{display:none}
  .catm-count{font-family:var(--round);font-size:.8rem;color:var(--muted);
    font-variant-numeric:tabular-nums;text-align:right}

  /* ---------- active filter chips ---------- */
  .catm-chips{display:flex;flex-wrap:wrap;gap:.35rem}
  .catm-chips:not(:empty){margin-bottom:.6rem}
  .catm-chip{display:inline-flex;align-items:center;gap:.35rem;
    font-family:var(--round);font-weight:600;font-size:.78rem;
    color:var(--accent);background:var(--accent-bg);
    border:1px solid var(--accent-line);border-radius:999px;
    padding:.24rem .5rem .24rem .62rem;cursor:pointer;max-width:100%}
  .catm-chip > span:first-child{overflow:hidden;text-overflow:ellipsis;
    white-space:nowrap}
  .catm-chip-x{font-size:1rem;line-height:1;opacity:.7;flex:none}
  /* T640: the plain-text "Reset all" chip-row entry (not a pill — the mock,
     phone-after-list-light.png, sets it apart from the removable chips). */
  .catm-chip-reset{display:inline-flex;align-items:center;
    font-family:var(--round);font-weight:600;font-size:.78rem;
    color:var(--muted);text-decoration:underline;text-underline-offset:2px;
    cursor:pointer;padding:.24rem 0}

  /* T640: "Dan Murphy's · 312" above the cards while a shop is ticked — 13px
     small-caps label, secondary ink, same voice as the desktop panel's own
     .cf-label (catalog-finder.css), scoped here since this heading only ever
     exists in the mobile DOM. */
  .catm-shop-head{font-family:var(--round);font-size:.8rem;font-weight:650;
    letter-spacing:.04em;text-transform:uppercase;color:var(--muted);
    margin:0 0 .5rem}
  .catm-shop-head[hidden]{display:none}

  /* ---------- the list ---------- */
  .catm-list{display:flex;flex-direction:column;gap:.55rem;padding-bottom:1.5rem}

  .catm-card{position:relative;display:grid;grid-template-columns:5.4rem 1fr;
    gap:.75rem;align-items:start;
    background:var(--card);border:1px solid var(--line);border-radius:12px;
    padding:.6rem;box-shadow:0 1px 0 rgba(var(--sk-q-shadow-rgb),.04)}

  /* Stretched hit area → the canonical bottle page. The retailer link and the
     Good-fit button re-escape it with their own z-index, so tapping those does
     NOT open the bottle page. */
  .catm-hit{position:absolute;inset:0;z-index:1;border-radius:inherit;
    display:block;outline-offset:2px}
  .catm-hit:focus-visible{outline:2px solid var(--focus)}
  .catm-sr{position:absolute;width:1px;height:1px;overflow:hidden;
    clip:rect(0 0 0 0);white-space:nowrap}

  /* Image well — FIXED box. A missing/broken photo swaps to the placeholder
     and dims; the row's geometry never moves. */
  .catm-shot{height:7rem;display:flex;align-items:center;justify-content:center;
    background:var(--bg-tint);border-radius:8px;overflow:hidden;padding:.35rem}
  .catm-shot img{max-height:100%;max-width:100%;object-fit:contain;display:block}
  .catm-shot.is-placeholder img{opacity:.38}

  .catm-body{min-width:0;display:flex;flex-direction:column}

  .catm-brand{font-family:var(--sans);font-size:.6rem;font-weight:700;
    letter-spacing:.07em;text-transform:uppercase;color:var(--muted);
    white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-bottom:.12rem}

  /* Clamped to 2 lines, and deliberately NO min-height. The grid needed one to
     keep names aligned across a row; a single-column list has nothing to align
     to, so reserving a second line just opens a gap under every one-line name —
     the "large empty space" this redesign exists to remove. Seen on the real
     app (1792 Small Batch, 2026-08-03) before it was taken out. */
  .catm-name{font-family:var(--sans);font-size:.94rem;font-weight:700;
    line-height:1.24;letter-spacing:-.005em;color:var(--ink);margin:0;
    display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;
    overflow:hidden}

  .catm-sub{font-family:var(--sans);font-size:.76rem;font-weight:600;
    color:var(--muted);margin-top:.1rem}

  .catm-priceline{display:flex;align-items:baseline;flex-wrap:wrap;
    gap:.15rem .5rem;margin-top:.3rem}
  .catm-from{font-family:var(--sans);font-size:.7rem;font-weight:600;
    color:var(--muted)}
  .catm-price{display:inline-flex;align-items:baseline;
    font-family:var(--sans);font-size:1.12rem;font-weight:800;color:var(--ink);
    font-variant-numeric:tabular-nums;letter-spacing:-.02em;line-height:1.1}
  .catm-dollar{font-size:.76rem;font-weight:700;margin-right:1px}
  .catm-cur{font-size:.58rem;font-weight:700;color:var(--muted);
    letter-spacing:.04em;margin-left:.22rem}
  .catm-ret{position:relative;z-index:2;font-family:var(--sans);
    font-size:.74rem;font-weight:650;color:var(--accent-2);text-decoration:none;
    white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
  .catm-noprice{font-family:var(--sans);font-size:.8rem;font-style:italic;
    color:var(--muted)}

  /* ---------- the one signal ---------- */
  /* Absent ⇒ the element is not rendered at all, so the row is simply shorter.
     No placeholder, no dash, no reserved height. */
  .catm-sig{align-self:flex-start;margin-top:.4rem;
    font-family:var(--round);font-weight:650;font-size:.72rem;
    padding:.16rem .5rem;border-radius:6px;border:1px solid transparent;
    max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .catm-sig-at_low,
  .catm-sig-falling{background:var(--green-bg);color:var(--green);
    border-color:var(--green-line)}
  .catm-sig-new{background:var(--accent-bg);color:var(--accent);
    border-color:var(--accent-line)}
  .catm-sig-batches{background:var(--amber-bg);color:var(--amber-txt);
    border-color:var(--amber-line)}

  /* ---------- Good fit for me? ---------- */
  /* The former sparkle, labelled. Same .card-buddy contract the former Buddy script
     delegates on; only the presentation is local. z-index:2 escapes the
     stretched .catm-hit so the tap reaches the button, not the bottle page. */
  .catm-fit{position:relative;z-index:2;align-self:flex-start;margin-top:.45rem;
    display:inline-flex;align-items:center;gap:.3rem;
    font-family:var(--round);font-weight:650;font-size:.78rem;
    color:var(--accent);background:transparent;
    border:1px solid var(--accent-line);border-radius:999px;
    padding:.28rem .68rem;cursor:pointer;-webkit-tap-highlight-color:transparent}
  .catm-fit:active{background:var(--accent-bg)}
  .catm-fit .star{font-size:.95rem;line-height:1;flex:none}
  /* Undo the desktop visually-hidden label — here the words ARE the control.
     (The wb-components.css rule is scoped to .cat-frame, so this is a local
     positive statement, not an override fight.) */
  .catm-fit .buddy-label{position:static;width:auto;height:auto;
    overflow:visible;clip:auto;white-space:nowrap}

  /* Safety fallback only — the catalogue lists priced bottles (#1595). If a row
     ever arrives without a price it mutes rather than breaking. No out-of-stock
     treatment: that would be the "Currently unavailable" surface the
     eligibility rules exclude. */
  .catm-card-unpriced{opacity:.74}

  /* ---------- empty + more ---------- */
  .catm-empty{padding:2.6rem 1rem;text-align:center;color:var(--muted)}
  .catm-empty-big{font-family:var(--round);font-weight:600;font-size:1.1rem;
    color:var(--ink-soft);margin-bottom:.3rem}
  .catm-empty p{margin:0 0 1rem;font-size:.9rem}
  .catm-empty-reset,
  .catm-more{font-family:var(--round);font-weight:600;font-size:.9rem;
    background:var(--ink);color:#fdf4e4;border:none;border-radius:10px;
    padding:.62rem 1.3rem;cursor:pointer;width:100%}
  .catm-empty-reset{width:auto}

  /* ---------- filters sheet ---------- */
  /* z 1240/1250: above the site header (1200) so the sheet is usable, below
     Buddy's ceiling (1300) so an opened Buddy still covers it. */
  .catm-sheet-scrim{position:fixed;inset:0;z-index:1240;
    background:rgba(35,25,17,.42);backdrop-filter:blur(2px)}
  .catm-sheet{position:fixed;left:0;right:0;bottom:0;z-index:1250;
    max-height:82vh;display:flex;flex-direction:column;
    background:var(--card);border-top-left-radius:18px;
    border-top-right-radius:18px;box-shadow:0 -10px 40px rgba(35,25,17,.28);
    padding-bottom:env(safe-area-inset-bottom,0)}
  .catm-sheet[hidden],.catm-sheet-scrim[hidden]{display:none}
  html.catm-sheet-open,html.catm-sheet-open body{overflow:hidden}

  /* While the sheet is open, suppress the site-wide bottom-anchored toasts.
     Found on the REAL app, not in a fixture (2026-08-03): wb-new-bottle-nudge.js
     appends #wbNewBottleNudge to <body> at z-index:1310 — above this sheet AND
     above Buddy — bottom-centred, i.e. directly over Reset/Show results, where
     it silently ate every tap on them. Raising the sheet above 1310 would have
     put it over Buddy too; the correct behaviour is that an unrelated toast does
     not sit on top of an open modal. Same reasoning for the smart-offer toast,
     the other always-on body-appended banner (base.html loads both site-wide). */
  html.catm-sheet-open #wbNewBottleNudge,
  html.catm-sheet-open #wbSmartOffer{display:none !important}

  .catm-sheet-grab{width:2.4rem;height:.25rem;border-radius:999px;
    background:var(--line);margin:.55rem auto .2rem}
  .catm-sheet-head{display:flex;align-items:center;justify-content:space-between;
    padding:.35rem 1.1rem .1rem}
  .catm-sheet-head h2{font-family:var(--sans);font-size:1.05rem;font-weight:750;
    color:var(--ink);margin:0}
  .catm-sheet-x{border:0;background:transparent;color:var(--muted);
    font-size:1.6rem;line-height:1;padding:0 .2rem;cursor:pointer}
  .catm-sheet-body{overflow-y:auto;padding:.7rem 1.1rem 1rem;
    display:flex;flex-direction:column;gap:.85rem}
  /* T640: the shared panel module (catalog-finder.js) always builds a live
     "<n> bottles" count as its first child (.cf-panel-count) — the desktop
     sidebar shows it beside the grid instead (#cfGridHead), and here the
     SAME number already lives on the sheet's own "Show <n> bottles" footer
     button, so a second copy at the top of the sheet would just repeat it
     (see phone-a-sheet-light.png: nothing above "PRICE"). Hidden, not
     removed — catalog-finder.js owns that element and rebuilds it wholesale
     on every render. */
  #catmFinderPanel .cf-panel-count{display:none}
  /* Same reasoning, same ownership note as .cf-panel-count above: the sheet
     footer (.catm-reset, see .catm-sheet-foot below) is already the sheet's
     "Reset all" — the panel's own .cf-reset-all (catalog-finder.js's
     buildResetAll) would be a second control with the same label (see
     phone-a-sheet-light.png: one "Reset all", in the footer). Desktop keeps
     the panel's own Reset all (no #catmFinderPanel ancestor there). */
  #catmFinderPanel .cf-reset-all{display:none}
  .catm-field{display:flex;flex-direction:column;gap:.28rem}
  .catm-field > span{font-family:var(--round);font-size:.76rem;font-weight:600;
    color:var(--muted);letter-spacing:.02em}
  .catm-field select{font:inherit;font-size:.94rem;color:var(--ink);
    background-color:var(--bg-tint);border:1px solid var(--line);
    border-radius:11px;padding:.62rem .7rem;width:100%;cursor:pointer;
    appearance:none;-webkit-appearance:none;
    background-image:var(--sk-lg-chevron);
    background-repeat:no-repeat;background-position:right .8rem center;
    padding-right:2.1rem}
  .catm-sheet-foot{display:flex;gap:.6rem;padding:.7rem 1.1rem 1rem;
    border-top:1px solid var(--line-soft)}
  .catm-reset{flex:none;font-family:var(--round);font-weight:600;font-size:.9rem;
    color:var(--ink-soft);background:transparent;border:1px solid var(--line);
    border-radius:11px;padding:.66rem 1.1rem;cursor:pointer}
  .catm-apply{flex:1;font-family:var(--round);font-weight:650;font-size:.95rem;
    color:#fff;background:var(--accent);border:1px solid var(--accent);
    border-radius:11px;padding:.66rem 1.1rem;cursor:pointer}

  :where(.catm) :focus-visible,
  :where(.catm-sheet) :focus-visible{outline:2px solid var(--focus);
    outline-offset:2px;border-radius:6px}
}

@media (max-width:860px) and (prefers-reduced-motion:reduce){
  .catm-sheet{transition:none}
}

/* Above the fence this screen does not exist. */
@media (min-width:861px){
  #catMobile{display:none}
}

/* Phone list thumbnail, same treatment as the bottle cards (Robert, 6 Nov 2026,
   T2953): a bench or family photo fills a 3:4 box with no side bands; any other
   picture stays whole on its plate. Website only, the app keeps its own. */
html:not(.wb-app):not(#_) body .catm-shot:has(>:is(img[src*="/img/bottle-bartop"],img[src*="/img/bottle-card/"],img[src*="/img/family-hero/"])){
  height:auto !important;aspect-ratio:3/4;align-self:start;padding:0 !important;background:var(--sk-ink) !important;
}
html:not(.wb-app):not(#_) body .catm-shot>:is(img[src*="/img/bottle-bartop"],img[src*="/img/bottle-card/"],img[src*="/img/family-hero/"]){
  width:100% !important;height:100% !important;max-width:none !important;max-height:none !important;
  object-fit:cover !important;object-position:center !important;
}

/* T3221: store-scoped shop with no outbound link: plain text, not a link. */
.catm-ret--note{color:var(--muted,#7a6f63);font-weight:500}
