/* =====================================================================
   RELIK A-Z — pop-art redesign
   =====================================================================
   Direction: Warhol's flat, saturated color-blocking meets Moebius's
   luminous gradients. A pastel paper ground throughout, thick ink
   outlines and hard "sticker" drop shadows for structure, and a glossy
   saturated accent color (from each card's own data) doing the actual
   color work — including a soft glow that radiates from the art itself.
   This replaced an earlier warm-dark "museum case" look; the card
   layout and JS underneath are unchanged, only the paint job.
   ===================================================================== */

:root {
  /* --- the pastel paper world (the page, and every card's body) --- */
  --paper: #fff5e8;
  --paper-dot: #f0dcb8;
  --card-bg: #fffdf9;
  --ink: #1e1811;
  --ink-soft: #55483a;
  --hairline: #e4d3ae;

  /* --- glossy accent palette. app.js picks one of these per card from
     its `accentColor` text (see accentColorFromText in app.js) and sets
     it as --accent on that card's tile/flip-card — everything below
     reads var(--accent), so one color choice repaints the whole card. --- */
  --gloss-gold: #ffc93c;

  /* --- semantic colors (right/wrong), kept separate from the accent
     palette on purpose — these always mean the same thing regardless
     of a card's own domain color. --- */
  --correct: #159a5b;
  --correct-glow: #2fe38a;
  --miss: #c9451f;
  --miss-glow: #ff6a4d;

  /* --- fonts (see index.html for how these are loaded) --- */
  --font-display: "Fraunces", serif;   /* big titles, banners */
  --font-body: "Newsreader", serif;    /* reading text */
  --font-mono: "JetBrains Mono", monospace; /* stats, serials, scores */
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  margin: 0;
  padding: 1.5rem;
  /* a soft screen-print dot texture behind everything — small nod to
     Warhol's repeated halftone screens */
  background:
    radial-gradient(circle, var(--paper-dot) 1.6px, transparent 1.6px) 0 0 / 24px 24px,
    var(--paper);
}

header {
  text-align: center;
  margin-bottom: 1.5rem;
}

header h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.4rem;
  margin: 0;
  letter-spacing: 0.06em;
  color: var(--ink);
}

#deck-subtitle {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

/* ---------------------------------------------------------------------
   The mascot badge (header) and its "burst" reaction.
   The header badge just sits there quietly, identifying the brand. The
   burst is the loud, temporary moment after you answer — see app.js's
   reactMascot(). It's fixed above the quiz modal (z-index higher than
   .modal-overlay's) since you answer WHILE the modal is open.
   --------------------------------------------------------------------- */

.brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.mascot-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--card-bg);
  border: 3px solid var(--ink);
}

.mascot-burst {
  position: fixed;
  top: 1.25rem;
  left: 50%;
  z-index: 200;
  transform: translate(-50%, -12px);
  display: flex;
  align-items: center;
  gap: 0.9rem;
  max-width: 380px;
  background: var(--card-bg);
  border: 4px solid var(--ink);
  border-radius: 20px;
  padding: 0.7rem 1.2rem 0.7rem 0.7rem;
  box-shadow: 5px 5px 0 var(--ink);
  opacity: 0;
  pointer-events: none; /* never blocks a click on whatever's underneath */
  transition: opacity 0.25s, transform 0.25s;
}

.mascot-burst.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* A soft colored glow plus a little confetti scatter on a correct
   answer; a quieter glow (no confetti) on a miss. */
.mascot-burst.correct {
  box-shadow: 5px 5px 0 var(--ink), 0 0 34px -8px var(--correct-glow);
}
.mascot-burst.correct::after {
  content: "";
  position: absolute;
  inset: -12px;
  pointer-events: none;
  background:
    radial-gradient(circle, var(--gloss-gold) 3px, transparent 3.5px) 6% 12% / 100% 100% no-repeat,
    radial-gradient(circle, var(--correct-glow) 3px, transparent 3.5px) 92% 20% / 100% 100% no-repeat,
    radial-gradient(circle, var(--gloss-gold) 3px, transparent 3.5px) 88% 84% / 100% 100% no-repeat;
}
.mascot-burst.incorrect {
  box-shadow: 5px 5px 0 var(--ink), 0 0 28px -8px var(--miss-glow);
}

.mascot-burst-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  flex-shrink: 0;
}

.mascot-burst.correct .mascot-burst-icon {
  animation: burst-hop 1.1s ease-in-out infinite;
}
.mascot-burst.incorrect .mascot-burst-icon {
  animation: burst-sag 1.6s ease-in-out infinite;
  filter: saturate(0.85);
}

@keyframes burst-hop {
  0%, 100% { transform: rotate(0) translateY(0); }
  30% { transform: rotate(-8deg) translateY(-6px); }
  55% { transform: rotate(6deg) translateY(0); }
}
@keyframes burst-sag {
  0%, 100% { transform: rotate(0) translateY(0); }
  50% { transform: rotate(-4deg) translateY(2px); }
}

.burst-line1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.1rem;
  margin: 0 0 0.15rem;
}
.mascot-burst.correct .burst-line1 { color: var(--correct); }
.mascot-burst.incorrect .burst-line1 { color: var(--miss); }

.burst-line2 {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin: 0;
}

/* ---------------------------------------------------------------------
   Score badge
   --------------------------------------------------------------------- */

.score-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  background: linear-gradient(135deg, #fff1cf, var(--gloss-gold));
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 0.3rem 0.7rem;
  box-shadow: 3px 3px 0 var(--ink);
}

.score-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: var(--ink);
  text-transform: uppercase;
}

.score-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
}

.score-badge.pulse {
  animation: score-pulse 0.5s ease;
}

@keyframes score-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* ---------------------------------------------------------------------
   Deck switcher + A-Z jump bar
   --------------------------------------------------------------------- */

.deck-switcher {
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.deck-button {
  font-family: var(--font-body);
  background: var(--card-bg);
  border: 2px solid var(--ink);
  border-radius: 999px;
  color: var(--ink);
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.deck-button:hover {
  background: #fff1cf;
}

.deck-button.active {
  background: linear-gradient(135deg, #fff1cf, var(--gloss-gold));
  font-weight: bold;
  box-shadow: 2px 2px 0 var(--ink);
}

.letter-nav {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  background: var(--paper);
  padding: 0.75rem 0;
  margin-bottom: 1.5rem;
  z-index: 10;
  border-bottom: 2px solid var(--hairline);
}

.letter-nav-button {
  font-family: var(--font-mono);
  background: var(--card-bg);
  border: 2px solid var(--ink);
  border-radius: 6px;
  color: var(--ink-soft);
  width: 2rem;
  height: 2rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.letter-nav-button:hover {
  background: #fff1cf;
  color: var(--ink);
}

.letter-section {
  max-width: 1100px;
  margin: 0 auto 2rem;
  scroll-margin-top: 4rem; /* keeps the sticky letter-nav from covering the heading when we jump here */
}

.letter-section h2 {
  font-family: var(--font-display);
  border-bottom: 2px solid var(--hairline);
  padding-bottom: 0.4rem;
  color: var(--ink);
}

.letter-section .card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.1rem;
}

/* =====================================================================
   Grid tiles — a mini version of the same "lead with the art" card,
   so browsing feels like the real thing, not a plain list.
   ===================================================================== */

.card-tile {
  --accent: var(--gloss-gold); /* app.js overrides this per card, from accentColor */
  position: relative;
  cursor: pointer;
  background: var(--card-bg);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 0.6rem;
  text-align: center;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 0.15s, box-shadow 0.15s;
}

.card-tile:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 var(--ink);
}

/* The tile's own little art stage — same idea as the big modal's art
   window: an image if one has loaded, otherwise a glowing gradient
   with the card's letter watermarked in the middle. */
.tile-art {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 2px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 0.5rem;
  background:
    radial-gradient(circle, #ffffff55 2px, transparent 2.2px) 0 0 / 12px 12px,
    radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--accent) 35%, white), var(--accent) 75%);
  box-shadow: 0 0 18px -5px var(--accent);
}

.tile-art::after {
  content: attr(data-letter);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 2.4rem;
  color: color-mix(in srgb, var(--accent) 30%, white 40%);
  -webkit-text-stroke: 2px var(--ink);
}

.tile-art-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.tile-art.has-image .tile-art-image { display: block; }
.tile-art.has-image::after { display: none; }

.card-tile .word {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0.15rem 0;
  color: var(--ink);
}

.card-tile .rarity {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
}

.card-tile .serial {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--ink-soft);
  margin-top: 0.3rem;
  opacity: 0.75;
}

/* Rarer cards glow harder — same idea used on the big card in the
   modal (see .card-face.rarity-* below). */
.card-tile.rarity-ultra-rare .tile-art { box-shadow: 0 0 22px -3px var(--accent); }
.card-tile.rarity-legendary .tile-art {
  box-shadow: 0 0 30px -2px var(--accent);
  animation: legendary-glow 2.4s ease-in-out infinite;
}

@keyframes legendary-glow {
  0%, 100% { box-shadow: 0 0 18px -4px var(--accent); }
  50% { box-shadow: 0 0 32px 0px var(--accent); }
}

/* Stage 7 — the per-word audio play button, pinned to the tile's
   corner. Stays hidden (see the `hidden` attribute app.js sets) until
   app.js confirms an audio/ file actually exists for this card. */
.play-button {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--card-bg);
  color: var(--ink);
  border: 2px solid var(--ink);
  cursor: pointer;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 2px 2px 0 var(--ink);
}

.play-button:hover {
  background: #fff1cf;
}

.play-button[hidden] {
  display: none;
}

/* =====================================================================
   The flip-card quiz modal.
   ---------------------------------------------------------------
   How the flip works: .flip-card-inner holds two faces (front and
   back) positioned exactly on top of each other. "backface-visibility:
   hidden" means each face disappears once it's rotated away from you,
   so you only ever see one at a time. Adding the "flipped" class to
   #flip-card rotates .flip-card-inner 180 degrees around the Y axis,
   which spins the front out of view and the back into view.
   ===================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--ink) 65%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-overlay.hidden {
  display: none;
}

.close-modal {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  font-size: 2rem;
  line-height: 1;
  background: none;
  border: none;
  color: var(--paper);
  cursor: pointer;
}

.flip-card {
  --accent: var(--gloss-gold); /* app.js overrides this per card, from accentColor */
  width: min(92vw, 440px);
  height: min(90vh, 640px);
  perspective: 1800px; /* how "deep" the 3D flip looks */
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

/* --- the card frame itself: thick ink outline, hard "sticker" shadow,
   pastel paper body --- */
.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: var(--card-bg);
  border: 5px solid var(--ink);
  border-radius: 28px;
  padding: 0.6rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
  box-shadow: 8px 8px 0 var(--ink);
}

.card-face-back {
  transform: rotateY(180deg); /* pre-rotated so it faces the right way once flipped */
}

/* Rarer cards get a stronger glow around the whole frame — layered on
   top of the flat "sticker" shadow, not replacing it. */
.card-face.rarity-ultra-rare {
  box-shadow: 8px 8px 0 var(--ink), 0 0 30px -6px var(--accent);
}
.card-face.rarity-legendary {
  box-shadow: 8px 8px 0 var(--ink), 0 0 44px -4px var(--accent);
  animation: legendary-glow-card 2.4s ease-in-out infinite;
}

@keyframes legendary-glow-card {
  0%, 100% { box-shadow: 8px 8px 0 var(--ink), 0 0 26px -6px var(--accent); }
  50% { box-shadow: 8px 8px 0 var(--ink), 0 0 48px -2px var(--accent); }
}

/* Small serial-number badge, top-left corner, printed in mono like a
   real trading card's catalog number — see .chip below, it's one of
   four small badges pinned to the corners of the art window. */

/* Title banner — a glossy gradient built from the card's own --accent,
   so it repaints correctly no matter which domain color a card uses. */
.pop-banner {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1rem;
  line-height: 1.2;
  text-align: center;
  color: var(--ink);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 35%, white 65%), var(--accent) 70%);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 0.55rem 0.7rem;
}

/* --- the art window: now the whole point of the card. Stage 5's <img>
   still points at images/<cardId>-front.png / -back.png and falls back
   to this glowing gradient-and-letter placeholder if that file 404s —
   see attachArt() in app.js. --- */
.art-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 4px solid var(--ink);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 0 44px -6px var(--accent), inset 0 0 40px -12px #ffffff90;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 22%, #ffffffaa, transparent 45%),
    radial-gradient(circle, #ffffff40 2px, transparent 2.3px) 0 0 / 18px 18px,
    radial-gradient(circle at 50% 55%, color-mix(in srgb, var(--accent) 35%, white), var(--accent) 75%);
}

/* The placeholder letter watermark. It's normal-flow content centered
   by the flexbox above; the <img> and the four chips are all
   position:absolute (see below), so they float on top of it without
   disturbing that centering. */
.art-stage::after {
  content: attr(data-letter);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 5.5rem;
  color: color-mix(in srgb, var(--accent) 40%, white 30%);
  -webkit-text-stroke: 4px var(--ink);
  text-shadow: 0 0 30px #fff8;
}

.art-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.art-stage.has-image .art-image { display: block; }
.art-stage.has-image::after { display: none; }

/* The four small corner badges pinned over the art. */
.chip {
  position: absolute;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.02em;
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  box-shadow: 2px 2px 0 var(--ink);
  max-width: 46%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip.serial { top: 8px; left: 8px; }
.chip.rarity { top: 8px; right: 8px; }
.chip.rail-left { bottom: 8px; left: 8px; }
.chip.rail-right { bottom: 8px; right: 8px; }

/* The trivia box at the bottom — plain card-bg, thick ink border, just
   like the rest of the frame. */
.trivia-box {
  background: var(--card-bg);
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 0.7rem 0.8rem;
  overflow-y: auto;
  flex: 0 1 auto;
  max-height: 45%;
}

.card-question {
  font-family: var(--font-body);
  margin: 0 0 0.6rem;
}

.card-choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.choice-button {
  font-family: var(--font-body);
  background: #fff2df;
  border: 2px solid var(--ink);
  border-radius: 8px;
  color: var(--ink);
  padding: 0.5rem 0.75rem;
  text-align: left;
  cursor: pointer;
  font-size: 0.95rem;
}

.choice-button:hover {
  background: #fff;
  border-color: var(--accent);
}

.card-result {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.card-result.correct { color: var(--correct); }
.card-result.incorrect { color: var(--miss); }

.card-definition {
  font-family: var(--font-body);
  margin: 0 0 0.5rem;
}

.card-flavor {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--ink-soft);
  margin: 0 0 0.6rem;
}

.try-another {
  font-family: var(--font-body);
  font-weight: 600;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 35%, white 65%), var(--accent) 70%);
  color: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 0.95rem;
  width: 100%;
  box-shadow: 3px 3px 0 var(--ink);
}

.try-another:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}
