/* The Deck Vault — static gallery. Neutral greys; gold and red are the
   only hues, used for links and the red suits. */
:root {
  --bg: #121212;
  --bg-2: #191919;
  --panel: #1f1f1f;
  --panel-2: #282828;
  --line: #343434;
  --text: #ebebeb;
  --muted: #9c9c9c;
  --accent: #b9b9b9;
  --sel: #a0a0a0; /* hover / selection borders */
  --gold: #d9b45a;
  --red: #ff6b6b;
  --radius: 14px;
  /* A playing card's corner is ~3.2 mm on a 63.5 mm card, i.e. ~5% of its
     width, so the radius has to scale with however large the card is drawn --
     a fixed pixel value is under-rounded on a desktop grid and over-rounded on
     a phone. Percentages resolve per axis, so on a 5:7 box the vertical figure
     is 5% x 5/7 to keep the corner circular. Tuck boxes are square-cornered
     and opt out with .is-tuck. */
  --card-radius: 5% / 3.57%;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  --maxw: 1160px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 50% -10%, #242424 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}
/* Ambient page texture: a zoomed-in patch of the deck's card back. */
.deck-bg {
  position: fixed; inset: -40px; z-index: -1; pointer-events: none;
  background-repeat: no-repeat; background-position: center;
  background-size: 400%; /* zoomed-in patch of the card back (~25% of it) */
  filter: blur(12px) saturate(1.25);
  opacity: 0.14;
}
/* The index has no deck of its own, so its backdrop is scaled much further --
   far enough that the pattern reads as texture rather than as a card. */
.deck-bg--index {
  background-size: 1100%;
  filter: blur(26px) saturate(1.15);
  opacity: 0.18;
}

a { color: inherit; text-decoration: none; }
h1, h2 { margin: 0; font-weight: 700; letter-spacing: -0.02em; }
img { display: block; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- Index toolbar (search, filter, count, sort) ---------- */
/* Sized to the text it holds, not to the row: the count and sort keep their
   places and the leftover space stays empty. */
.search { position: relative; flex: 0 1 600px; min-width: 170px; text-align: left; }
#q {
  width: 100%;
  padding: 9px 16px;
  font-size: 1rem;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#q::placeholder { color: var(--muted); }
#q:focus { border-color: var(--sel); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12); }

/* Typeahead dropdown */
.ac {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px);
  z-index: 30; margin: 0; padding: 6px; list-style: none;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow);
  max-height: min(60vh, 420px); overflow-y: auto;
}
.ac-group {
  padding: 8px 10px 4px; font-size: 0.7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted);
}
.ac-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: 9px; cursor: pointer;
}
.ac-item.active { background: var(--panel-2); }
.ac-thumb {
  flex: 0 0 auto; width: 30px; height: 42px; border-radius: 4px;
  overflow: hidden; background: var(--bg-2); border: 1px solid var(--line);
}
.ac-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ac-text { min-width: 0; display: flex; flex-direction: column; }
.ac-name { font-weight: 600; }
.ac-sub { font-size: 0.78rem; color: var(--muted); }
.ac-tag { color: var(--text); }
.ac-tagname { font-weight: 600; }
.ac-hash { color: var(--accent); font-weight: 800; }
.ac-count {
  margin-left: auto; font-size: 0.74rem; color: var(--muted);
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 1px 8px; border-radius: 999px;
}
.ac mark { background: rgba(217, 180, 90, 0.28); color: inherit; border-radius: 3px; }
.ac-empty { padding: 12px 12px; color: var(--muted); }

.active-filter {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 0.9rem;
}
.active-filter .chip {
  color: var(--text); background: var(--panel-2);
  border: 1px solid var(--line); padding: 3px 11px; border-radius: 999px; font-weight: 600;
}
#filter-clear {
  border: 0; background: transparent; color: var(--gold);
  font: inherit; font-size: 0.85rem; cursor: pointer; padding: 2px 4px;
}
#filter-clear:hover { text-decoration: underline; }

/* ---------- Sort toolbar ---------- */
.toolbar {
  display: flex; align-items: center; gap: 14px;
  flex-wrap: wrap; padding: 26px 0 0;
}
/* Count sits after the filter and pushes the sort to the far end. */
.count { color: var(--muted); font-size: 0.9rem; margin: 0 auto 0 0; white-space: nowrap; }
.sort-field {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 0.85rem;
}
#sort {
  font: inherit; color: var(--text); background-color: var(--panel);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 32px 8px 14px; cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2390a89c' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}
#sort:focus { outline: none; border-color: var(--sel); }

/* ---------- Deck grid (index) ---------- */
.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 22px;
  padding: 34px 0 10px;
}
.deck-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.deck-card:hover {
  transform: translateY(-4px);
  border-color: var(--sel);
  box-shadow: var(--shadow);
}
.cover-wrap { position: relative; aspect-ratio: 5 / 7; background: var(--bg-2); }
/* A tuck box has square corners; the tile's own top corners are what round it. */
.deck-card:has(.cover-wrap.is-tuck) { border-top-left-radius: 0; border-top-right-radius: 0; }
.cover { width: 100%; height: 100%; object-fit: cover; }
.pip {
  position: absolute; right: 6%; bottom: 4%; width: 24%;
  aspect-ratio: 5 / 7; object-fit: cover;
  border-radius: var(--card-radius);
  border: 1px solid rgba(0, 0, 0, 0.5);
  /* Two shadows: a tight contact edge so it reads as lying on the tuck, and a
     wide soft one for the lift. */
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.55),
    0 10px 26px rgba(0, 0, 0, 0.75);
  transition: width 0.22s ease, right 0.22s ease, bottom 0.22s ease,
              border-radius 0.22s ease, box-shadow 0.22s ease;
}

/* Hovering the back grows it over the tuck. The pip shares the cover's 5:7
   shape, so a full width lands it exactly on top. Only where hovering is a
   real thing -- on a touch screen it would stick open after a tap. */
@media (hover: hover) {
  .pip:hover {
    width: 100%; right: 0; bottom: 0;
    border-radius: 0;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.7);
  }
}
.cover--empty {
  display: grid; place-items: center;
  color: var(--muted); font-size: 0.85rem; letter-spacing: 0.04em;
}
.deck-card__body { padding: 13px 15px 16px; }
.deck-card__body h2 { font-size: 1.12rem; }
.sub { color: var(--muted); font-size: 0.86rem; margin: 3px 0 0; }
.added { color: var(--muted); font-size: 0.78rem; margin: 6px 0 0; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tag:hover, .tag:focus-visible { border-color: var(--sel); background: var(--panel); }
.tag {
  font-size: 0.72rem; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 3px 9px; border-radius: 999px;
  cursor: pointer; text-decoration: none;
  transition: border-color 0.12s, background 0.12s;
}
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- Deck page header ---------- */
.deck-head {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent);
  padding-bottom: 28px;
}
.back { display: inline-block; color: var(--muted); padding: 20px 0 14px; font-size: 0.9rem; }
.back:hover { color: var(--text); }
.deck-head__grid { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: start; }
.hero-img {
  padding: 0; border: 1px solid var(--line); background: var(--bg-2);
  border-radius: var(--card-radius); overflow: hidden; cursor: zoom-in;
  aspect-ratio: 5 / 7; box-shadow: var(--shadow);
}
.hero-img img { width: 100%; height: 100%; object-fit: cover; }
.deck-meta h1 { font-size: clamp(1.7rem, 4vw, 2.6rem); margin-bottom: 12px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px 22px; margin: 18px 0; }
.fact dt { color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; }
.fact dd { margin: 2px 0 0; font-size: 1.02rem; font-weight: 600; }
.desc { color: #d4d4d4; max-width: 60ch; }
.links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.links a {
  font-size: 0.86rem; color: var(--gold);
  border: 1px solid var(--line); background: var(--panel);
  padding: 7px 13px; border-radius: 999px;
}
.links a:hover { border-color: var(--gold); }

/* ---------- Card grid (suits as columns, ranks as rows) ---------- */
.grid-section { padding-top: 30px; }
.suit--red { color: var(--red); }
.suit--black { color: var(--text); }
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(8px, 1.4vw, 18px);
  width: 100%;
}
.suit-h { text-align: center; font-size: 1.6rem; line-height: 1; padding-bottom: 4px; }
.cell {
  padding: 0; margin: 0; border: 1px solid var(--line);
  background: var(--bg-2); border-radius: var(--card-radius); overflow: hidden;
  aspect-ratio: 5 / 7; cursor: zoom-in;
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.cell img { width: 100%; height: 100%; object-fit: cover; }
.cell:hover { transform: scale(1.07); border-color: var(--sel); box-shadow: var(--shadow); z-index: 2; }
.cell--empty {
  display: grid; place-items: center; cursor: default; border-style: dashed;
  background: repeating-linear-gradient(45deg, #171717, #171717 6px, #1d1d1d 6px, #1d1d1d 12px);
}
.cell--empty i { font-style: normal; font-size: 1.05rem; opacity: 0.45; }

/* Tuck boxes are square-cornered; only the cards are rounded. */
.pack-tile.is-tuck img,
.cf-slide.is-tuck img,
.hero-img.is-tuck,
.cover-wrap.is-tuck,
.rel-cover.is-tuck { border-radius: 0; }

/* ---------- Packaging ---------- */
.pack { padding: 44px 0 10px; }
.pack h2, .related h2 { font-size: 1.15rem; margin-bottom: 16px; }
.pack-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(8px, 1.4vw, 18px);
}
.pack-tile {
  padding: 0; border: 0; background: transparent;
  cursor: zoom-in; text-align: left;
  transition: transform 0.12s;
}
.pack-tile:hover { transform: translateY(-3px); }
.pack-tile img {
  width: 100%; aspect-ratio: 5 / 7; object-fit: cover;
  border: 1px solid var(--line); border-radius: var(--card-radius); background: var(--bg-2);
  transition: border-color 0.12s;
}
.pack-tile:hover img { border-color: var(--sel); }
.pack-tile span { display: block; padding: 8px 2px 0; font-size: 0.82rem; color: var(--muted); }

/* ---------- Related decks ---------- */
.related { padding: 34px 0 10px; margin-top: 24px; border-top: 1px solid var(--line); }
.rel-row { display: flex; flex-wrap: wrap; gap: 16px; }
.rel-card { width: 118px; }
.rel-cover {
  display: block; aspect-ratio: 5 / 7; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--card-radius); background: var(--bg-2);
  transition: border-color 0.14s, transform 0.14s;
}
.rel-cover img { width: 100%; height: 100%; object-fit: cover; }
.rel-card:hover .rel-cover { border-color: var(--sel); transform: translateY(-3px); }
.rel-name { display: block; margin-top: 8px; font-size: 0.86rem; font-weight: 600; }

/* ---------- Cover Flow lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(8, 8, 8, 0.96);
  display: flex; flex-direction: column;
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.cf-stage {
  position: relative; flex: 1; min-height: 0;
  perspective: 1500px; perspective-origin: 50% 44%;
  overflow: hidden; touch-action: none;
}
.cf-track { position: absolute; inset: 0; transform-style: preserve-3d; }
.cf-slide {
  position: absolute; left: 50%; top: 45%;
  width: min(56vw, 300px); margin: 0;
  transform-style: preserve-3d; will-change: transform;
  transition: transform 0.45s cubic-bezier(0.22, 0.61, 0.24, 1);
  cursor: pointer;
}
.cf-slide img {
  width: 100%; height: auto; display: block; border-radius: var(--card-radius);
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.65);
  -webkit-box-reflect: below 8px linear-gradient(transparent 58%, rgba(255, 255, 255, 0.22));
}
.cf-cap {
  text-align: center; margin: 0;
  padding: 6px 0 calc(22px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 4px;
}
.cf-label { color: var(--text); font-size: 1.05rem; font-weight: 600; letter-spacing: 0.02em; }
.cf-hint { color: var(--muted); font-size: 0.76rem; }
.lb-close {
  position: fixed; top: 12px; right: 16px; font-size: 1.7rem; line-height: 1;
  background: transparent; border: 0; color: var(--text);
  cursor: pointer; opacity: 0.72; transition: opacity 0.12s; z-index: 52;
}
.lb-close:hover { opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .deck-head__grid { grid-template-columns: 120px 1fr; gap: 16px; }
  .deck-meta h1 { margin-bottom: 8px; }
  .facts { grid-template-columns: repeat(2, 1fr); gap: 10px 16px; margin: 14px 0; }
}
@media (max-width: 460px) {
  .card-grid { gap: 8px; }
  .deck-grid { gap: 16px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .cf-slide { width: 68vw; }
}
