/* ============================================================================
 * VYNUMO — BLOODCRIMES THEME
 * ============================================================================
 * Optional theme (data-theme="bloodcrimes"). The default Vynumo themes and
 * their identity are untouched: this file only applies when the theme is
 * explicitly selected, which the BloodCrimes adapter does automatically in
 * BloodCrimes mode.
 *
 * Design source of truth: BloodCrimes tokens
 *   (assets/css/bloodcrimes/tokens.css — neo-noir crime RPG).
 *   bg #0B0C10 · surface #141418 · crimson #B51220 · gold #C99A38
 *
 * RULES OBSERVED HERE
 *   1. The 4x4 board stays the most readable thing on screen. Decoration is
 *      always edge-anchored, low-alpha, and never sits over a value.
 *   2. Low-value tiles stay plain. Only 128+ gains real ornament, so early
 *      play reads as a clean board instead of confetti.
 *   3. Motion is short (<= 220ms) and fully disabled under
 *      prefers-reduced-motion.
 * ========================================================================== */

[data-theme="bloodcrimes"] {
  /* ── Page / chrome ─────────────────────────────────────────────── */
  --page-text: #F2F2F2;
  --link-color: #E0BD73;
  --bg-radial: rgba(181, 18, 32, 0.14);
  --bg-start: #0B0C10;
  --bg-end: #09090B;
  --surface-bg: rgba(20, 20, 24, 0.92);
  --surface-border: #292930;
  --surface-shadow: rgba(0, 0, 0, 0.55);
  --accent: #C99A38;
  --accent-soft: rgba(201, 154, 56, 0.12);
  --title-color: #F4F4F5;
  --subtitle-color: #C9C9CE;
  --muted-color: #A3A3A3;
  --button-gradient-start: #B51220;
  --button-gradient-end: #7E0C16;
  --button-text: #FFF6F2;
  --button-shadow: rgba(181, 18, 32, 0.34);
  --ghost-button-bg: rgba(255, 255, 255, 0.045);
  --panel-bg: rgba(24, 24, 27, 0.96);
  --panel-border: #292930;
  --panel-label: #9A9AA2;
  --intro-color: #B4B4BC;

  /* ── Board ─────────────────────────────────────────────────────── */
  --board-bg: #101014;
  --grid-cell-bg: rgba(255, 255, 255, 0.035);
  --overlay-bg: rgba(9, 9, 11, 0.96);
  --table-row-bg: rgba(255, 255, 255, 0.022);
  --input-bg: rgba(255, 255, 255, 0.05);
  --tile-shadow: rgba(0, 0, 0, 0.5);

  /* ── Tile progression: criminal wealth / status ─────────────────
   *  2    small cash          — plain slate, barely there
   *  4    cash                — a little warmer
   *  8    stack of money      — banding begins
   *  16   larger stack        — deeper banding
   *  32   bundle              — wrapped band, first real warmth
   *  64   bag                 — rounded silhouette
   *  128  briefcase           — hard case frame + latch
   *  256  larger loot         — metal rim + rivets
   *  512  gold / high loot    — gold sheen + glow
   *  1024 vault / premium     — steel plate + dial
   *  2048 criminal empire     — crimson + gold, radiant
   * ------------------------------------------------------------- */
  --tile-2-bg: #1E1E24;
  --tile-2-fg: #D6D6DC;

  --tile-4-bg: #262229;
  --tile-4-fg: #E6E2EA;

  --tile-8-bg: #33302C;
  --tile-8-fg: #F0EBE2;

  --tile-16-bg: #453B2C;
  --tile-16-fg: #F6F0E3;

  --tile-32-bg: #5A4726;
  --tile-32-fg: #FBF4E4;

  --tile-64-bg: #6E5423;
  --tile-64-fg: #FFF8E8;

  --tile-128-bg: #8A6524;
  --tile-128-fg: #FFFBF0;

  --tile-256-bg: #A67B29;
  --tile-256-fg: #FFFDF6;

  --tile-512-bg: #C99A38;
  --tile-512-fg: #1A1408;

  --tile-1024-bg: #B51220;
  --tile-1024-fg: #FFF3F0;

  --tile-2048-bg: #E11D2A;
  --tile-2048-fg: #FFF8F0;

  --tile-super-bg: #1B1B20;
  --tile-super-fg: #E0BD73;

  /* Theme-local helpers (not used by other themes). */
  --bc-tile-crimson: #B51220;
  --bc-tile-crimson-hot: #E11D2A;
  --bc-tile-gold: #C99A38;
  --bc-tile-gold-light: #E0BD73;
  --bc-tile-edge: rgba(255, 255, 255, 0.1);
  --bc-tile-edge-gold: rgba(224, 189, 115, 0.5);
}

/* ============================================================================
 * TILE BASE
 * ========================================================================== */

[data-theme="bloodcrimes"] .game-container .tile .tile-inner {
  position: relative;
  border-radius: 6px;
  box-shadow:
    0 5px 16px var(--tile-shadow),
    inset 0 0 0 1px var(--bc-tile-edge);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  transition: box-shadow 160ms ease;
}

/* Decoration layer lives on the wrapper so it can never cover the value. */
[data-theme="bloodcrimes"] .game-container .tile::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0.9;
  z-index: 1;
}

[data-theme="bloodcrimes"] .game-container .tile .tile-inner {
  z-index: 2;
}

/* ============================================================================
 * LOW VALUES (2–64) — plain, quiet, instantly readable
 * ========================================================================== */

/* 2 — a single note. Nothing but a soft top light. */
[data-theme="bloodcrimes"] .game-container .tile.tile-2::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 62%);
}

/* 4 — cash: a faint bill rule near the bottom edge. */
[data-theme="bloodcrimes"] .game-container .tile.tile-4::before {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 62%),
    linear-gradient(90deg, transparent 16%, rgba(255, 255, 255, 0.09) 16%, rgba(255, 255, 255, 0.09) 84%, transparent 84%) center/100% 1px no-repeat;
  background-position: center, center calc(100% - 14px);
}

/* 8 — a stack: two banding lines. */
[data-theme="bloodcrimes"] .game-container .tile.tile-8::before {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 60%),
    repeating-linear-gradient(180deg,
      rgba(0, 0, 0, 0) 0,
      rgba(0, 0, 0, 0) 6px,
      rgba(255, 255, 255, 0.07) 6px,
      rgba(255, 255, 255, 0.07) 7px);
  background-position: center, bottom;
  background-size: 100% 100%, 100% 34%;
  background-repeat: no-repeat, no-repeat;
}

/* 16 — a taller stack. */
[data-theme="bloodcrimes"] .game-container .tile.tile-16::before {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 58%),
    repeating-linear-gradient(180deg,
      rgba(0, 0, 0, 0) 0,
      rgba(0, 0, 0, 0) 5px,
      rgba(255, 255, 255, 0.085) 5px,
      rgba(255, 255, 255, 0.085) 6px);
  background-position: center, bottom;
  background-size: 100% 100%, 100% 46%;
  background-repeat: no-repeat, no-repeat;
}

/* 32 — a bundle: wrapped band across the middle-bottom. */
[data-theme="bloodcrimes"] .game-container .tile.tile-32::before {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 56%),
    linear-gradient(180deg, transparent 46%, rgba(0, 0, 0, 0.28) 46%, rgba(0, 0, 0, 0.28) 62%, transparent 62%);
}

/* 64 — a duffel bag: rounded base silhouette + strap. */
[data-theme="bloodcrimes"] .game-container .tile.tile-64::before {
  background:
    radial-gradient(120% 62% at 50% 118%, rgba(0, 0, 0, 0.42) 0%, rgba(0, 0, 0, 0) 68%),
    linear-gradient(180deg, transparent 58%, rgba(255, 255, 255, 0.1) 58%, rgba(255, 255, 255, 0.1) 60%, transparent 60%),
    linear-gradient(90deg, transparent 44%, rgba(255, 255, 255, 0.08) 44%, rgba(255, 255, 255, 0.08) 56%, transparent 56%);
}

/* ============================================================================
 * MID VALUES (128–256) — first real ornament: hardware and metal
 * ========================================================================== */

/* 128 — a briefcase: hard frame with a latch pip on top. */
[data-theme="bloodcrimes"] .game-container .tile.tile-128::before {
  background:
    radial-gradient(circle at 50% 16%, rgba(26, 20, 8, 0.5) 0 2px, transparent 2px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 40%),
    linear-gradient(180deg, transparent 62%, rgba(0, 0, 0, 0.22) 62%, rgba(0, 0, 0, 0.22) 66%, transparent 66%);
}

[data-theme="bloodcrimes"] .game-container .tile.tile-128 .tile-inner {
  box-shadow:
    0 5px 16px var(--tile-shadow),
    inset 0 0 0 1px var(--bc-tile-edge-gold);
}

/* 256 — larger loot: riveted metal rim. */
[data-theme="bloodcrimes"] .game-container .tile.tile-256::before {
  background:
    radial-gradient(circle at 13% 13%, rgba(255, 255, 255, 0.4) 0 1.5px, transparent 1.5px),
    radial-gradient(circle at 87% 13%, rgba(255, 255, 255, 0.4) 0 1.5px, transparent 1.5px),
    radial-gradient(circle at 13% 87%, rgba(255, 255, 255, 0.28) 0 1.5px, transparent 1.5px),
    radial-gradient(circle at 87% 87%, rgba(255, 255, 255, 0.28) 0 1.5px, transparent 1.5px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.13), transparent 44%);
}

[data-theme="bloodcrimes"] .game-container .tile.tile-256 .tile-inner {
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(26, 20, 8, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

/* ============================================================================
 * HIGH VALUES (512+) — genuinely impressive, still readable
 * ========================================================================== */

/* 512 — gold: a diagonal sheen and a warm glow. */
[data-theme="bloodcrimes"] .game-container .tile.tile-512::before {
  background:
    linear-gradient(118deg, rgba(255, 255, 255, 0) 34%, rgba(255, 255, 255, 0.34) 47%, rgba(255, 255, 255, 0) 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 46%);
}

[data-theme="bloodcrimes"] .game-container .tile.tile-512 .tile-inner {
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.48),
    0 0 22px rgba(201, 154, 56, 0.36),
    inset 0 0 0 1px rgba(255, 255, 255, 0.3);
}

/* 1024 — the vault: steel plate, inner ring, dial. */
[data-theme="bloodcrimes"] .game-container .tile.tile-1024::before {
  background:
    radial-gradient(circle at 50% 50%, transparent 0 22%, rgba(255, 255, 255, 0.14) 22%, rgba(255, 255, 255, 0.14) 24%, transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 42%),
    repeating-linear-gradient(90deg,
      rgba(0, 0, 0, 0) 0 10px,
      rgba(0, 0, 0, 0.12) 10px 11px);
  opacity: 0.75;
}

[data-theme="bloodcrimes"] .game-container .tile.tile-1024 .tile-inner {
  box-shadow:
    0 7px 22px rgba(0, 0, 0, 0.55),
    0 0 26px rgba(181, 18, 32, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

/* 2048 — criminal empire: crown of gold over crimson, radiant halo. */
[data-theme="bloodcrimes"] .game-container .tile.tile-2048::before {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 214, 130, 0.22) 0%, transparent 62%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 44%),
    linear-gradient(118deg, transparent 36%, rgba(255, 232, 176, 0.32) 48%, transparent 62%);
  opacity: 1;
}

[data-theme="bloodcrimes"] .game-container .tile.tile-2048 .tile-inner {
  box-shadow:
    0 8px 26px rgba(0, 0, 0, 0.55),
    0 0 34px rgba(225, 29, 42, 0.5),
    inset 0 0 0 1px rgba(224, 189, 115, 0.65);
}

/* 4096+ — beyond empire: dark vault with gold inlay. */
[data-theme="bloodcrimes"] .game-container .tile.tile-super::before {
  background:
    radial-gradient(circle at 50% 50%, rgba(224, 189, 115, 0.2) 0%, transparent 66%),
    linear-gradient(180deg, rgba(224, 189, 115, 0.16), transparent 44%);
}

[data-theme="bloodcrimes"] .game-container .tile.tile-super .tile-inner {
  box-shadow:
    0 8px 26px rgba(0, 0, 0, 0.6),
    0 0 30px rgba(224, 189, 115, 0.4),
    inset 0 0 0 1px rgba(224, 189, 115, 0.55);
}

/* ============================================================================
 * NUMBER SIZING
 * The value is the most important pixel on the board. 4- and 5-digit tiles
 * step down so they never touch (or cross) the tile edge.
 * ========================================================================== */

[data-theme="bloodcrimes"] .game-container .tile.tile-128 .tile-inner,
[data-theme="bloodcrimes"] .game-container .tile.tile-256 .tile-inner,
[data-theme="bloodcrimes"] .game-container .tile.tile-512 .tile-inner {
  font-size: calc(var(--board-cell) * 0.44);
}

[data-theme="bloodcrimes"] .game-container .tile.tile-1024 .tile-inner,
[data-theme="bloodcrimes"] .game-container .tile.tile-2048 .tile-inner {
  font-size: calc(var(--board-cell) * 0.36);
  letter-spacing: -0.03em;
}

[data-theme="bloodcrimes"] .game-container .tile.tile-super .tile-inner {
  font-size: calc(var(--board-cell) * 0.28);
  letter-spacing: -0.03em;
}

/* ============================================================================
 * MERGE FEEDBACK — short, restrained, never slows play
 * ========================================================================== */

@keyframes bc-merge-pop {
  0%   { transform: scale(1); }
  42%  { transform: scale(1.07); }
  100% { transform: scale(1); }
}

@keyframes bc-merge-flash {
  0%   { box-shadow: 0 0 0 0 rgba(224, 189, 115, 0.55); }
  100% { box-shadow: 0 0 0 14px rgba(224, 189, 115, 0); }
}

[data-theme="bloodcrimes"] .game-container .tile.tile-merged .tile-inner {
  animation: bc-merge-pop 170ms ease-out;
}

[data-theme="bloodcrimes"] .game-container .tile.tile-merged.tile-128 .tile-inner,
[data-theme="bloodcrimes"] .game-container .tile.tile-merged.tile-256 .tile-inner,
[data-theme="bloodcrimes"] .game-container .tile.tile-merged.tile-512 .tile-inner,
[data-theme="bloodcrimes"] .game-container .tile.tile-merged.tile-1024 .tile-inner,
[data-theme="bloodcrimes"] .game-container .tile.tile-merged.tile-2048 .tile-inner,
[data-theme="bloodcrimes"] .game-container .tile.tile-merged.tile-super .tile-inner {
  animation: bc-merge-pop 190ms ease-out, bc-merge-flash 320ms ease-out;
}

/* ============================================================================
 * AMBIENT — smoke / dust. Extremely subtle; never behind the numbers.
 * ========================================================================== */

[data-theme="bloodcrimes"] body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(60% 40% at 18% 8%, rgba(181, 18, 32, 0.1), transparent 70%),
    radial-gradient(50% 36% at 84% 92%, rgba(201, 154, 56, 0.07), transparent 72%),
    radial-gradient(120% 70% at 50% 120%, rgba(0, 0, 0, 0.5), transparent 70%);
}

[data-theme="bloodcrimes"] .container,
[data-theme="bloodcrimes"] .game-container,
[data-theme="bloodcrimes"] .heading {
  position: relative;
  z-index: 1;
}

/* ============================================================================
 * BLOODCRIMES CHROME (only rendered by the BloodCrimes adapter)
 * ========================================================================== */

.bc-arcade-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--surface-border, #292930);
  border-left: 3px solid var(--bc-tile-crimson, #B51220);
  border-radius: 4px;
  background: rgba(20, 20, 24, 0.9);
  font-family: 'Barlow Condensed', 'Inter', sans-serif;
}

.bc-arcade-strip__id {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.bc-arcade-strip__avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 3px;
  border: 1px solid rgba(224, 189, 115, 0.35);
  background: #1A1A1A;
}

.bc-arcade-strip__name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #F2F2F2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bc-arcade-strip__meta {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #A3A3A3;
}

.bc-arcade-strip__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.bc-arcade-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.045);
  font-size: 0.78rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: #C9C9CE;
  white-space: nowrap;
}

.bc-arcade-chip b {
  color: #E0BD73;
  font-weight: 700;
}

.bc-arcade-chip.is-warn b { color: #E11D2A; }
.bc-arcade-chip.is-good b { color: #4ADE80; }

.bc-arcade-strip__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid rgba(224, 189, 115, 0.4);
  border-radius: 3px;
  color: #E0BD73;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
}

.bc-arcade-strip__link:hover { background: rgba(224, 189, 115, 0.1); color: #E0BD73; }

/* Reward panel shown after a settled BloodCrimes run. */
.bc-arcade-rewards {
  margin: 10px 0 0;
  padding: 10px 14px;
  border: 1px solid rgba(224, 189, 115, 0.28);
  border-left: 3px solid #C99A38;
  border-radius: 4px;
  background: rgba(24, 24, 27, 0.94);
  font-family: 'Barlow Condensed', 'Inter', sans-serif;
}

.bc-arcade-rewards__title {
  margin: 0 0 6px;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #E0BD73;
}

.bc-arcade-rewards__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.bc-arcade-rewards__list li {
  padding: 4px 9px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
  color: #F2F2F2;
}

.bc-arcade-rewards__note {
  margin: 8px 0 0;
  font-size: 0.74rem;
  color: #A3A3A3;
}

/* ============================================================================
 * ACCESSIBILITY / MOTION
 * ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  [data-theme="bloodcrimes"] .game-container .tile.tile-merged .tile-inner,
  [data-theme="bloodcrimes"] .game-container .tile.tile-merged.tile-128 .tile-inner,
  [data-theme="bloodcrimes"] .game-container .tile.tile-merged.tile-256 .tile-inner,
  [data-theme="bloodcrimes"] .game-container .tile.tile-merged.tile-512 .tile-inner,
  [data-theme="bloodcrimes"] .game-container .tile.tile-merged.tile-1024 .tile-inner,
  [data-theme="bloodcrimes"] .game-container .tile.tile-merged.tile-2048 .tile-inner,
  [data-theme="bloodcrimes"] .game-container .tile.tile-merged.tile-super .tile-inner {
    animation: none;
  }
}

/* Body class toggled by the motion preference module. */
html.is-reduced-motion [data-theme="bloodcrimes"] .game-container .tile .tile-inner,
html.is-reduced-motion [data-theme="bloodcrimes"] .game-container .tile.tile-merged .tile-inner {
  animation: none !important;
  transition: none !important;
}
