/* sections/cards/cards.css — the cards browser (Cards Browser - Deep Design.html,
   settlement 2-Cards). Mobile-first: a single column with the rail as a chip row on
   phones, a 196px rail + grid row at --bp-lg. Tokens only (ds/tokens.css); no
   ad-hoc colors or breakpoints. The result set is the shared virtual grid (its vg-*
   chrome is owned by primitives.css); these rules style the chrome, the syntax
   helper, the filter chips, and the tile / row / table cells. */

/* ── shared atoms ── */
.cb-art {
  /* The per-card art rides as a CSS layer (--art-img, set inline per tile) STACKED
     OVER the brand hue-gradient -- never as an inline `background-image`, which would
     replace the whole layer list. So a blocked / slow / 404 art image just reveals the
     gradient beneath instead of collapsing to a flat box. Unset --art-img falls back to
     `none`, leaving the gradient exactly as before. */
  background-image:
    var(--art-img, none),
    linear-gradient(160deg, oklch(0.40 0.055 var(--art-h, 250)), oklch(0.28 0.045 calc(var(--art-h, 250) + 40))),
    repeating-linear-gradient(135deg, transparent 0 7px, rgba(255, 255, 255, 0.03) 7px 14px);
  background-color: var(--bg-elev-2);
  background-size: cover;
  background-position: center;
}
.cb-mono { font-family: var(--font-mono); font-size: 10px; color: var(--text-4); }
.cb-dim { color: var(--text-4); }
.cb-bar-spacer { flex: 1; }

/* ── library shell ── */
.cb-library { display: flex; flex-direction: column; min-height: 100%; }
.cb-rail {
  flex-shrink: 0; padding: 10px 10px 4px; border-bottom: 1px solid var(--border-soft);
  display: flex; gap: 4px; overflow-x: auto; align-items: center;
}
.cb-rail .cb-railhead { display: none; }
.cb-libmain { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.cb-railitem {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
  padding: 6px 10px; border-radius: var(--r-sm); text-decoration: none;
  color: var(--text-3); font-size: 12.5px; white-space: nowrap;
}
.cb-railitem:hover { background: var(--bg-elev-1); color: var(--text); }
.cb-railitem.on { background: var(--accent-soft); color: var(--text); }
.cb-railitem-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.cb-railitem-count { font-family: var(--font-mono); font-size: 10px; color: var(--text-4); }
.cb-railitem.on .cb-railitem-count { color: var(--accent); }
.cb-railitem-recent .cb-railitem-label { color: var(--text-4); }
.cb-railhead {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-4); padding: 10px 10px 4px;
}

/* ── header facts eyebrow ── */
.cb-header { flex-shrink: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; padding: 13px 16px 2px; }
.cb-header-title { font-family: var(--font-display); font-style: italic; font-size: 24px; color: var(--text); }
.cb-header-sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); }
/* default-state orientation line (all view, no query); flex-basis 100% drops it onto
   its own row under the title so an empty search reads as a starting point, not a dump. */
.cb-header-hint { flex-basis: 100%; font-size: 12.5px; color: var(--text-3); margin-top: 1px; }

/* ── control bar ── */
.cb-controlbar {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 16px; border-bottom: 1px solid var(--border-soft);
}
.cb-search {
  position: relative; display: flex; align-items: center; gap: 6px; flex: 1; min-width: 160px;
  padding: 6px 10px; border: 1px solid var(--border-soft); border-radius: var(--r-sm); background: var(--bg-elev-1);
}
.cb-search-icon { font-size: 12px; color: var(--text-4); }
.cb-search-input { border: 0; background: transparent; color: var(--text); font: inherit; outline: none; width: 100%; }
.cb-search-input::placeholder { color: var(--text-4); }
.cb-controls { display: flex; align-items: center; gap: 8px; }

/* ── manual filter facet bar (Color / Type / Mana value / Rarity + More
   filters) -- the popover chrome itself (.tcg-arrange-pop) is shared with the
   Arrange popover (shared/arrange-popover.css); these rules are the
   facet-specific content: pips, checklists, and the two-input range. ── */
.cb-facetbar { flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 8px; }
.cb-facet { position: relative; display: inline-flex; }
.cb-facet-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-left: 2px; }
.cb-facet-head { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-4); padding: 6px 8px 4px; }
.cb-facet-head:first-child { padding-top: 2px; }
.cb-facet-pips { display: flex; gap: 6px; padding: 2px 8px 6px; }
/* Official Scryfall symbol artwork (shared/mana-pips.js's manaSymHtml), wrapped
   in a button for the toggle affordance -- a ring + soft fill marks the
   selected state, since the pip artwork itself has no "selected" look. */
.cb-facet-pip {
  display: inline-flex; padding: 3px; border-radius: 50%; border: 2px solid transparent;
  background: transparent; cursor: pointer; line-height: 0;
}
.cb-facet-pip:hover { background: var(--bg-hover); }
.cb-facet-pip.on { border-color: var(--accent); background: var(--accent-soft); }
.cb-facet-pip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cb-facet-check {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  font-size: 12.5px; color: var(--text-2); cursor: pointer;
}
.cb-facet-check:hover { color: var(--text); }
.cb-facet-check input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.cb-facet-range { display: flex; align-items: center; gap: 8px; padding: 2px 8px 8px; }
.cb-facet-range-sep { color: var(--text-4); }
.cb-facet-num, .cb-facet-text, .cb-facet-select {
  background: var(--bg-elev-1); border: 1px solid var(--border-soft); border-radius: var(--r-sm);
  color: var(--text); font: inherit; font-size: 12.5px; padding: 5px 8px;
}
.cb-facet-num { width: 64px; }
.cb-facet-text, .cb-facet-select { width: 100%; margin: 0 8px 8px; box-sizing: border-box; }
.cb-facet-num:focus, .cb-facet-text:focus, .cb-facet-select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.cb-facet-more .cb-facet-pop { min-width: 220px; }

/* ── syntax helper popover ── */
.cb-helper {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: var(--z-palette, 900);
  width: min(380px, calc(92vw / var(--ui-scale, 1))); padding: 8px; background: var(--bg-elev-2);
  border: 1px solid var(--border-soft); border-radius: var(--r-md); box-shadow: var(--shadow-2, 0 8px 28px rgba(0,0,0,0.4));
  /* the grouped cheat-sheet is taller than the viewport on a phone -> scroll it,
     and divide dvh by the global UI scale (mobile-first rule). */
  max-height: calc(70dvh / var(--ui-scale, 1)); overflow-y: auto; overscroll-behavior: contain;
}
.cb-helper.open { display: block; }
.cb-helper-head:not(:first-child) { margin-top: 6px; }
.cb-helper-head, .cb-helper-foot {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-4);
  padding: 4px 6px;
}
.cb-helper-foot { text-transform: none; letter-spacing: 0; font-family: var(--font-sans); font-size: 11px; color: var(--text-3); line-height: 1.5; border-top: 1px solid var(--border-soft); margin-top: 4px; }
.cb-helper-foot .cb-mono { font-size: 10.5px; color: var(--text-2); }
.cb-helper-row {
  display: grid; grid-template-columns: minmax(56px, auto) 1fr auto; align-items: center; gap: 8px; width: 100%;
  padding: 6px; border: 0; background: transparent; border-radius: var(--r-sm); cursor: pointer; text-align: left;
}
.cb-helper-row:hover { background: var(--bg-hover); }
.cb-helper-op { color: var(--accent); font-size: 11px; white-space: nowrap; }
.cb-helper-desc { color: var(--text-2); font-size: 12px; }
.cb-helper-ex { color: var(--text-4); font-size: 10px; }

/* ── filter chips ── */
.cb-chips { display: none; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 16px 0; }
.cb-chips.on { display: flex; }
.cb-chip {
  display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 11px;
  color: var(--text); background: var(--bg-elev-1); border: 1px solid var(--border-soft);
  border-radius: var(--r-pill); padding: 3px 8px; cursor: pointer;
}
.cb-chip:hover { border-color: var(--border-strong); }
/* manual-filter facet chips (one per active facet, not per raw token): accent
   treatment distinguishes them from the advanced-text token chips below. */
.cb-chip.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-ring); }
.cb-chip.active .cb-chip-x { color: var(--accent); }
/* structural tokens (parens, and/or): shown for context, not removable. */
.cb-chip-struct { background: transparent; border-color: transparent; color: var(--text-4); cursor: default; padding: 3px 4px; }
.cb-chip-x { color: var(--text-4); font-size: 12px; }
.cb-chip:hover .cb-chip-x { color: var(--text); }
.cb-chip-warn { color: var(--warning, var(--text-3)); }
.cb-chip-clear { background: transparent; border: 0; color: var(--text-4); font-size: 11px; cursor: pointer; padding: 3px 4px; }
.cb-chip-clear:hover { color: var(--accent); text-decoration: underline; }

/* ── table column header (shown only in table view) ── */
.cb-tablehead { display: none; flex-shrink: 0; padding: 0 16px; border-bottom: 1px solid var(--border-soft); }
.cb-tablehead.on { display: block; }

/* ── main ── */
.cb-main { flex: 1; min-height: 0; overflow-y: auto; position: relative; }
.cb-main.tcg-vgrid { padding: 0; }

/* ── pager (universe view; sits below the scrolling grid so it's always visible) ── */
.cb-pager {
  flex-shrink: 0; display: flex; justify-content: center; align-items: center; gap: 2px;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border-soft);
  overflow-x: auto;
}
.cb-pager:empty { display: none; }
.cb-pg {
  min-width: 34px; padding: 6px 8px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text-3); font-family: var(--font-mono); font-size: 12px;
  cursor: pointer; flex-shrink: 0;
}
.cb-pg:hover:not(:disabled) { background: var(--bg-elev-1); color: var(--text); }
.cb-pg.on { background: var(--accent-soft); color: var(--accent); }
.cb-pg:disabled { color: var(--text-4); cursor: default; opacity: 0.5; }
.cb-pg-gap { color: var(--text-4); font-family: var(--font-mono); font-size: 12px; padding: 0 2px; flex-shrink: 0; }

/* degrade path + skeleton reuse .cb-tiles */
.cb-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(122px, 100%), 1fr)); gap: 16px 12px; padding: 14px 16px 24px; }
@media (min-width: 768px) { /* --bp-md: match the live grid's desktop floor (browser.js CELL.grid.w) */
  .cb-tiles { grid-template-columns: repeat(auto-fill, minmax(min(158px, 100%), 1fr)); }
}

/* ── grid tile ── */
/* position: relative is the anchor for the favorite star, which is a sibling of
   the cover (a button can't nest inside the cover <a>). */
.cb-tile { display: flex; flex-direction: column; min-width: 0; position: relative; }
.cb-tile-cover { display: block; position: relative; border-radius: var(--r-md); overflow: hidden; text-decoration: none; }
.cb-tile-art { display: block; aspect-ratio: 5 / 7; border: 1px solid var(--border-soft); border-radius: var(--r-md); }
.cb-tile-name {
  font-size: 12.5px; color: var(--text); text-decoration: none; margin-top: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cb-tile-name:hover { color: var(--accent); }
.cb-tile-foot { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.cb-tile-meta { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9.5px; color: var(--text-3); }

/* owned badge: inline pill by default, absolute over the tile art */
.cb-owned {
  display: inline-flex; align-items: center; font-family: var(--font-mono); font-size: 9px; color: var(--text);
  background: var(--accent-soft); border: 1px solid var(--accent-ring); border-radius: var(--r-pill); padding: 1px 6px;
  white-space: nowrap;
}
/* on the narrowest tiles the absolute pill can run into the art edge; cap it so the
   label ellipsizes instead of wrapping to a second line. Over full-card art the
   translucent accent wash vanishes against light card frames, so the overlay
   variant gets a near-opaque surface backdrop. */
.cb-tile-cover .cb-owned {
  position: absolute; top: 6px; left: 6px; max-width: calc(100% - 12px); overflow: hidden; text-overflow: ellipsis;
  background: color-mix(in oklab, var(--bg-elev-1) 88%, var(--accent));
}
.cb-indeck {
  position: absolute; bottom: 6px; right: 6px; display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: 9px; color: var(--text-2);
  background: color-mix(in oklab, var(--bg) 88%, transparent); border: 1px solid var(--border-soft);
  border-radius: var(--r-pill); padding: 1px 6px;
}

/* ── list row ── */
.cb-row { display: flex; align-items: center; gap: 10px; text-decoration: none; padding: 0 16px; height: 100%; border-bottom: 1px solid var(--border-soft); }
.cb-row-art { width: 30px; aspect-ratio: 5 / 7; border-radius: 4px; border: 1px solid var(--border-soft); flex-shrink: 0; }
.cb-row-name { font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 32ch; }
.cb-row:hover .cb-row-name { color: var(--accent); }
.cb-row-type { font-size: 10px; color: var(--text-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-row-price { font-size: 10px; color: var(--text-3); white-space: nowrap; }

/* ── table row ── */
.cb-trow {
  display: grid; align-items: center; gap: 10px; text-decoration: none; padding: 0 16px; height: 100%;
  grid-template-columns: 28px minmax(0, 2.4fr) 64px minmax(0, 1.8fr) 48px 64px 64px 72px;
  border-bottom: 1px solid var(--border-soft);
}
.cb-trow-head {
  height: 34px; align-items: center; border-bottom: 1px solid var(--border-soft);
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-4);
}
.cb-tcell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-tcell-r { text-align: right; }
.cb-trow-art { width: 24px; aspect-ratio: 5 / 7; border-radius: 3px; border: 1px solid var(--border-soft); }
.cb-trow-name { font-size: 12.5px; color: var(--text); }
.cb-trow:hover .cb-trow-name { color: var(--accent); }
.cb-trow-type { font-size: 10.5px; }

/* ── stacks view (Archidekt-style fanned columns; ported from the deck
   editor's .dk-stack* -- see stacks-render.js) ──
   --cb-tile-w is set by repaintMain() from the Arrange zoom slider (same
   144-320px mapping as grid view's column width, shared/arrange-popover.js's
   tileWidthForZoom). packStacks() (JS bin-packing, not CSS multi-column --
   see that module for why) distributes .cb-stackcol blocks into .cb-stackcolumn
   wrappers after render; the columns lay out in a simple flex row. */
.cb-stacks { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px 32px; overflow-x: auto; }
.cb-stackcolumn { display: flex; flex-direction: column; gap: 10px; flex-shrink: 0; }
.cb-stackcol { width: var(--cb-tile-w, 200px); flex-shrink: 0; }
.cb-stackcol-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 0 2px 6px; }
.cb-stackcol-name { font-size: 12.5px; color: var(--text); }
.cb-stackcol-count { font-family: var(--font-mono); font-size: 10px; color: var(--text-4); }
/* the fanned pile: each card overlaps the one before it so only the printed
   title peeks; hovering pushes everything below it down to reveal the whole
   card. Bottom padding reserves room for the last card to fully reveal. */
.cb-stack { display: flex; flex-direction: column; padding-bottom: calc(var(--cb-tile-w, 200px) * 1.25); }
.cb-stackcard {
  display: block; position: relative; text-decoration: none; margin-top: -117.6%;
  border-radius: var(--r-md); border: 1px solid var(--border-soft); overflow: hidden;
  transition: transform 160ms ease;
}
.cb-stackcard:first-child { margin-top: 0; }
.cb-stackcard:hover, .cb-stackcard:focus-within { z-index: 1; }
/* hovering a card pushes every LATER sibling down to reveal it; earlier cards
   (already further back in the pile) don't need to move. */
.cb-stack .cb-stackcard:hover ~ .cb-stackcard { transform: translateY(84%); }
.cb-stackcard-art { display: block; aspect-ratio: 5 / 7; position: relative; }
.cb-stackcard-img { display: block; width: 100%; height: 100%; object-fit: cover; position: relative; z-index: 1; }
/* fallback (no art yet): the name + mana cost, shown behind the image so it
   only appears when a card genuinely has no rendered art. */
.cb-stackcard-fallback { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; padding: 8px; }
.cb-stackcard-fallname { font-size: 11px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── keyboard-nav focus ring ──
   Arrow keys move focus between cards (shared/virtual-grid.js keyboardNav). The
   virtual grid clips its cells (.vg-cell { overflow: hidden }), which would crop a
   normal OUTSET ring, so draw the focus ring INSET on the focused cell's card link.
   Scoped to .tcg-vgrid: the degrade-path grid (.cb-tiles, no clipping) keeps the
   standard outset .tcg-ref ring. */
.tcg-vgrid .cb-tile-cover:focus-visible,
.tcg-vgrid .cb-row:focus-visible,
.tcg-vgrid .cb-trow:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: var(--r-md);
}

/* ── skeleton + empty ── */
.cb-skel-tile { display: flex; flex-direction: column; gap: 6px; }
.cb-skel-cover { aspect-ratio: 5 / 7; border-radius: var(--r-md); background: var(--bg-elev-1); animation: cb-pulse 1.2s ease-in-out infinite; }
.cb-skel-bar { height: 8px; border-radius: 4px; background: var(--bg-elev-1); }
@keyframes cb-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .cb-skel-cover { animation: none; } }

.cb-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 44px 18px; max-width: 50ch; }
.cb-empty-title { font-family: var(--font-display); font-style: italic; font-size: 21px; color: var(--text); }
.cb-empty-sub { font-size: 13px; color: var(--text-3); line-height: 1.55; }

/* ── --bp-lg: the rail becomes a 196px sidebar ── */
@media (min-width: 1024px) {
  .cb-library { flex-direction: row; }
  .cb-rail {
    width: 196px; flex-direction: column; align-items: stretch; gap: 0; overflow-x: hidden; overflow-y: auto;
    padding: 10px 10px 0; border-bottom: 0; border-right: 1px solid var(--border-soft);
  }
  .cb-rail .cb-railhead { display: block; }
  .cb-railitem { flex-shrink: 1; }
}

/* ── card stub page (/cards/<oracleId>) ── */
.cb-stub { padding: 14px 16px 32px; max-width: 1100px; }
.cb-stub-back { display: inline-block; color: var(--text-3); text-decoration: none; font-size: 12px; margin-bottom: 12px; }
.cb-stub-back:hover { color: var(--accent); }
.cb-stub-fold { display: flex; flex-direction: column; gap: 18px; }
.cb-stub-left { display: flex; flex-direction: column; gap: 10px; }
.cb-stub-art { width: 100%; max-width: 280px; aspect-ratio: 5 / 7; border: 1px solid var(--border-soft); border-radius: var(--r-lg); }
.cb-stub-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; max-width: 280px; }
.cb-stub-pick { display: flex; flex-direction: column; align-items: center; gap: 3px; flex-shrink: 0; padding: 2px; background: transparent; border: 1px solid transparent; border-radius: var(--r-sm); cursor: pointer; }
.cb-stub-pick.on { border-color: var(--accent-ring); background: var(--accent-soft); }
.cb-stub-pickart { width: 34px; aspect-ratio: 5 / 7; border-radius: 3px; border: 1px solid var(--border-soft); }
.cb-stub-pickset { font-size: 8.5px; color: var(--text-4); }
.cb-stub-pick.on .cb-stub-pickset { color: var(--accent); }
.cb-stub-pickhint { font-size: 9px; color: var(--text-4); max-width: 280px; }
.cb-stub-price { display: flex; align-items: baseline; gap: 8px; }
.cb-stub-priceusd { font-family: var(--font-mono); font-size: 16px; color: var(--text); }
.cb-stub-foil { color: var(--text-4); }
.cb-stub-own { align-self: flex-start; }
.cb-stub-scryfall { align-self: flex-start; }

.cb-stub-right { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cb-stub-namerow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cb-stub-name { font-family: var(--font-display); font-style: italic; font-size: 28px; line-height: 1.1; color: var(--text); margin: 0; }
.cb-stub-typerow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cb-stub-type { font-size: 13px; color: var(--text-2); }
.cb-stub-edh { color: var(--text-4); }
.cb-stub-oracle { font-size: 13.5px; line-height: 1.6; color: var(--text); padding: 10px 0; margin-top: 6px; border-top: 1px solid var(--border-soft); white-space: pre-wrap; }
.cb-stub-pt { font-size: 12px; color: var(--text-3); }
.cb-stub-savings { color: var(--text-3); padding: 4px 0; }

.cb-stub-section { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.cb-stub-sechead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.cb-stub-legal { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px; }
.cb-stub-legrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; }
.cb-stub-legfmt { font-size: 12px; color: var(--text-2); text-transform: capitalize; }
.cb-stub-legbadge { font-family: var(--font-mono); font-size: 9px; padding: 1px 6px; border-radius: var(--r-pill); }
.cb-stub-legbadge.ok { color: var(--text-2); border: 1px solid var(--border-soft); }
.cb-stub-legbadge.no { color: var(--text-4); border: 1px solid var(--border-soft); }
.cb-stub-legbadge.ban { color: var(--danger, var(--text)); background: color-mix(in oklab, var(--danger, red) 16%, transparent); border: 1px solid color-mix(in oklab, var(--danger, red) 40%, transparent); }

.cb-stub-ownrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; }
.cb-stub-ownn { font-family: var(--font-mono); font-size: 12px; color: var(--text); }
.cb-stub-cusrow { display: flex; align-items: center; gap: 8px; text-decoration: none; padding: 5px 0; color: var(--text-2); border-top: 1px solid var(--border-soft); }
.cb-stub-cusrow:hover .cb-stub-cuslabel { color: var(--accent); }
.cb-stub-cuslabel { flex: 1; font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-stub-cusarrow { color: var(--text-4); }

.cb-stub-data { margin-top: 20px; }
.cb-stub-ptable { display: flex; flex-direction: column; }
.cb-stub-prow { display: grid; grid-template-columns: 30px minmax(0, 1.6fr) 44px 56px 56px 1fr; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--border-soft); font-size: 12px; }
.cb-stub-prowart { width: 26px; aspect-ratio: 5 / 7; border-radius: 3px; border: 1px solid var(--border-soft); }
.cb-stub-prowset { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-stub-prowdim { color: var(--text-4); }
.cb-stub-prowprice { color: var(--text-2); text-align: right; }
.cb-stub-prowbar { height: 6px; background: var(--bg-elev-1); border-radius: 3px; overflow: hidden; }
.cb-stub-prowbarfill { display: block; height: 100%; background: var(--accent); opacity: 0.7; }
.cb-stub-pmore { width: 100%; margin-top: 8px; padding: 8px; border: 1px solid var(--border-soft); border-radius: var(--r-sm); background: var(--bg-elev-1); color: var(--text-2); font-family: var(--font-mono); font-size: 11px; cursor: pointer; transition: border-color var(--transition-fast), color var(--transition-fast); }
.cb-stub-pmore:hover { border-color: var(--accent-ring); color: var(--text); }
.cb-stub-pnote { margin-top: 8px; }

.cb-stub-ruling { padding: 8px 0; border-top: 1px solid var(--border-soft); }
.cb-stub-rulingmeta { font-size: 9.5px; color: var(--text-4); margin-bottom: 2px; }
.cb-stub-rulingtext { font-size: 12.5px; line-height: 1.55; color: var(--text-2); }

/* context-follows-you-in: the deck chip (Phase 6 part 4) */
.cb-stub-toprow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cb-stub-deckchip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border: 1px solid var(--accent-ring); background: var(--accent-soft); border-radius: var(--r-pill); font-size: 12px; }
.cb-stub-deckname { color: var(--text); font-weight: 500; }
.cb-stub-deckclear { color: var(--text-4); text-decoration: none; }
.cb-stub-deckclear:hover { color: var(--accent); }

/* synergy explorer (Phase 6 part 4): groups are grounded server-side; this is presentation only. */
.cb-syn-head { flex-wrap: wrap; }
.cb-syn-sub { order: 3; flex-basis: 100%; }
.cb-syn-filters { display: flex; gap: 6px; }
.cb-syn-filter { font-family: var(--font-mono); font-size: 10px; color: var(--text-3); background: transparent; border: 1px solid var(--border-soft); border-radius: var(--r-pill); padding: 2px 9px; cursor: pointer; }
.cb-syn-filter.on { color: var(--text); background: var(--accent-soft); border-color: var(--accent-ring); }
.cb-syn-groups { display: flex; flex-direction: column; gap: 16px; margin-top: 4px; }
.cb-syn-grouphead { display: flex; flex-direction: column; gap: 1px; margin-bottom: 8px; }
.cb-syn-title { font-size: 13.5px; font-weight: 500; color: var(--text); }
.cb-syn-why { font-size: 11.5px; color: var(--text-4); }
.cb-syn-tiles { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
.cb-syn-tilewrap { position: relative; flex: 0 0 112px; width: 112px; scroll-snap-align: start; }
.cb-syn-tile { display: block; width: 100%; text-decoration: none; }
.cb-syn-add { position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; padding: 0; border-radius: 10px; border: 1px solid var(--accent-ring); background: var(--accent); color: var(--on-accent, #fff); font-size: 14px; line-height: 1; display: grid; place-items: center; cursor: pointer; }
.cb-syn-add:disabled { background: var(--bg-elev-1); color: var(--text-4); border-color: var(--border-soft); cursor: default; }
.cb-syn-add.added { background: var(--accent-soft); color: var(--text); }
.cb-syn-tileart { position: relative; display: block; aspect-ratio: 5 / 7; border-radius: var(--r-md); border: 1px solid var(--border-soft); }
.cb-syn-tile:hover .cb-syn-tileart { border-color: var(--accent-ring); }
.cb-syn-owned { position: absolute; top: 5px; left: 5px; font-size: 8.5px; color: var(--text); background: var(--accent-soft); border: 1px solid var(--accent-ring); border-radius: var(--r-pill); padding: 0 5px; }
.cb-syn-tilename { display: block; font-size: 12px; font-style: italic; color: var(--text); margin: 6px 0 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-syn-tile:hover .cb-syn-tilename { color: var(--accent); }
.cb-syn-tileev { display: block; font-size: 9px; color: var(--text-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cb-syn-empty { padding: 6px 0; }

/* --bp-md: the stub above-fold goes two-column. The left column (art + printing
   picker + price) sticks to the top of the scroll area so the image stays in view
   while the long right column (oracle, legality, printings, rulings, synergy)
   scrolls past. align-self:flex-start keeps the column its natural height (a
   stretched flex item can't stick); the scroll container is the shell's .main. */
@media (min-width: 768px) {
  .cb-stub-fold { flex-direction: row; gap: 28px; align-items: flex-start; }
  .cb-stub-left { flex-shrink: 0; width: 280px; position: sticky; top: 16px; align-self: flex-start; }
  .cb-stub-right { flex: 1; }
}

/* ── per-card favorite star (cards-discovery-landing Phase 3) ──
   The tile star is positioned over the cover; the cover stays a plain <a> (a
   <button> can't nest in it), so .cb-tile is the positioning context. It reveals
   on hover/focus on pointer devices and is always visible on touch. The header
   variant (.cb-fav-lg, on the stub + drawer name rows) sits inline. The 44px
   touch target comes from a transparent ::before so the visual chip stays small.
   shared/favorites.js owns the click; this is presentation only. */
.cb-fav {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--border-soft); border-radius: var(--r-pill);
  background: color-mix(in oklab, var(--bg) 72%, transparent);
  color: var(--text-2); cursor: pointer;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  transition: opacity 160ms ease, color 160ms ease, border-color 160ms ease, transform 140ms ease;
}
.cb-fav::before { content: ""; position: absolute; inset: -7px; } /* 30 + 14 = 44px hit area */
.cb-fav:hover { color: var(--text); border-color: var(--accent-ring); }
.cb-fav:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cb-fav:active { transform: scale(.92); }
.cb-fav-icon { display: block; }
/* pressed = favorited: fill the star with the accent */
.cb-fav[aria-pressed="true"] {
  color: var(--accent); border-color: var(--accent-ring); background: var(--accent-soft);
}
.cb-fav[aria-pressed="true"] .cb-fav-icon { fill: currentColor; }

/* reveal on hover/focus on pointer devices; always visible on touch (coarse) */
@media (hover: hover) and (pointer: fine) {
  .cb-tile .cb-fav { opacity: 0; }
  .cb-tile:hover .cb-fav,
  .cb-tile:focus-within .cb-fav,
  .cb-tile .cb-fav:focus-visible,
  .cb-tile .cb-fav[aria-pressed="true"] { opacity: 1; }
}

/* header variant: inline in the stub + drawer name rows (not absolute), pushed to
   the end of the row so it right-aligns past the name + mana pips */
.cb-fav-lg { position: static; width: 34px; height: 34px; flex: 0 0 auto; }
.cb-fav-lg::before { inset: -5px; } /* 34 + 10 = 44px */
.cb-stub-namerow .cb-fav-lg, .cl-cd-namerow .cb-fav-lg { margin-left: auto; }

/* the pop on starring; disabled under reduced-motion */
@keyframes cb-fav-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.32); }
  100% { transform: scale(1); }
}
.cb-fav-pop { animation: cb-fav-pop 220ms ease; }
@media (prefers-reduced-motion: reduce) {
  .cb-fav { transition: none; }
  .cb-fav:active { transform: none; }
  .cb-fav-pop { animation: none; }
}

/* ── per-card flip control (double-faced cards; follow-up #27) ──
   A sibling of the cover (like the star), positioned over the art's top-right just
   left of the star (the star is right:6px, this is right:42px). Reveals on
   hover/focus on pointer, always visible on touch. The 44px touch target comes from
   a transparent ::before. shared/card-flip.js owns the click + cover-image swap;
   this is presentation only. */
.cb-flip {
  position: absolute; top: 6px; right: 42px; z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--border-soft); border-radius: var(--r-pill);
  background: color-mix(in oklab, var(--bg) 72%, transparent);
  color: var(--text-2); cursor: pointer;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  transition: opacity 160ms ease, color 160ms ease, border-color 160ms ease, transform 140ms ease;
}
.cb-flip::before { content: ""; position: absolute; inset: -7px; } /* 30 + 14 = 44px hit area */
.cb-flip:hover { color: var(--text); border-color: var(--accent-ring); }
.cb-flip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cb-flip:active { transform: scale(.92); }
.cb-flip-icon { display: block; }
/* showing the back face: tint the control with the accent so the state reads */
.cb-flip.is-flipped { color: var(--accent); border-color: var(--accent-ring); background: var(--accent-soft); }

/* reveal on hover/focus on pointer devices; always visible on touch (coarse) */
@media (hover: hover) and (pointer: fine) {
  .cb-tile .cb-flip { opacity: 0; }
  .cb-tile:hover .cb-flip,
  .cb-tile:focus-within .cb-flip,
  .cb-tile .cb-flip:focus-visible,
  .cb-tile .cb-flip.is-flipped { opacity: 1; }
}

/* the cover-image cross-fade on flip; disabled under reduced-motion */
@keyframes cb-art-fade { from { opacity: 0.35; } to { opacity: 1; } }
.cb-art-fade { animation: cb-art-fade 220ms ease; }
@media (prefers-reduced-motion: reduce) {
  .cb-flip { transition: none; }
  .cb-flip:active { transform: none; }
  .cb-art-fade { animation: none; }
}

/* ── shared "see all" grid page (/cards/favorites + /cards/recent) ──
   One tile-grid page chrome (back link + display title + mono count + the .cb-tiles
   grid), reused by the favorites see-all (Phase 3) and the recently-viewed fuller
   view (follow-up #43). */
.cb-gridpage-head { padding: 18px 16px 4px; display: flex; flex-direction: column; gap: 4px; }
.cb-gridpage-head .cb-stub-back { align-self: flex-start; }
/* the see-all pages keep a back-to-discovery link AND a back-to-browser link side by
   side, so returning from a search lands back in the browsing context, not a detour. */
.cb-gridpage-nav { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; }
.cb-gridpage-title { font-family: var(--font-display); font-style: italic; font-size: 26px; line-height: 1.1; color: var(--text); margin: 6px 0 0; }
.cb-gridpage-sub { font-size: 11px; color: var(--text-3); }
.cb-gridpage-grid { min-height: 220px; }
/* --bp-md */
@media (min-width: 768px) {
  .cb-gridpage-head { padding: 24px 24px 6px; }
  .cb-gridpage-title { font-size: 30px; }
}
