/* Vibe Wars online: house style (docs/UX_PLAN.md section 4).
   Solid dark surfaces, art in front, one accent per screen, two fonts. */

@font-face { font-family: 'Russo One'; src: url('../show/fonts/russo-one.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Chakra Petch'; font-weight: 500; src: url('../show/fonts/chakra-petch-500.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Chakra Petch'; font-weight: 700; src: url('../show/fonts/chakra-petch-700.woff2') format('woff2'); font-display: swap; }

:root {
  --bg: #07060f;
  --panel: #0f0d1c;
  --line: rgba(255, 255, 255, .09);
  --text: #f5f3ff;
  --muted: #a9a4c9;
  --accent: #22d3ee;          /* this screen's one accent */
  --accent-ink: #04121a;
  --gold: #facc15;
  --display: 'Russo One', 'Segoe UI Black', Impact, sans-serif;
  --body: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
  --out: cubic-bezier(.23, 1, .32, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --gutter: 16px;
  --tap: 56px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
/* The body stays transparent so the arena background layer (z-index -1)
   isn't painted over by it. */
html, body { margin: 0; color: var(--text); font-family: var(--body); font-weight: 500; }
body { min-height: 100dvh; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
img { display: block; }

/* ------------------------------------------------------------ background
   The current arena's own art, tiny and soft, behind everything. It changes
   with the arena. Not a decorative gradient: the colour comes from the game. */

.page-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; background: var(--bg); }
.bg-layer {
  position: absolute; inset: -8%;
  background-size: cover; background-position: center;
  opacity: 0;
  transition: opacity 1.4s var(--out);
  animation: drift 40s ease-in-out infinite alternate;
}
.bg-layer.on { opacity: .62; }
/* Keep text contrast: the page stays dark under the copy. */
.page-bg::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(7, 6, 15, .25), rgba(7, 6, 15, .55) 45%, rgba(7, 6, 15, .9) 66%, rgba(7, 6, 15, .96));
}
@media (min-width: 960px) {
  .page-bg::after { background: linear-gradient(to right, rgba(7, 6, 15, .94), rgba(7, 6, 15, .8) 36%, rgba(7, 6, 15, .3) 70%, rgba(7, 6, 15, .2)); }
}
@keyframes drift { from { transform: scale(1.04) translate(-1%, -1%); } to { transform: scale(1.12) translate(1.5%, 1%); } }

/* ------------------------------------------------------------ layout */

.landing {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: max(env(safe-area-inset-top), 12px) var(--gutter) max(env(safe-area-inset-bottom), 16px);
  max-width: 560px;
  margin: 0 auto;
}

.topbar { display: flex; align-items: center; justify-content: space-between; height: 48px; }
.logo { height: 34px; width: auto; }

.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--line); background: rgba(15, 13, 28, .7);
  color: var(--muted); cursor: pointer;
  transition: transform .12s var(--out), color .2s, border-color .2s, background-color .2s;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.icon-btn:active { transform: scale(.94); }
@media (hover: hover) { .icon-btn:hover { color: var(--text); border-color: rgba(255, 255, 255, .2); } }
.sound-toggle .icon-on, .sound-toggle[aria-pressed="true"] .icon-off { display: none; }
.sound-toggle[aria-pressed="true"] .icon-on { display: block; }
.sound-toggle[aria-pressed="true"] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* Phone: the live scores sit above the arena, filling the space under the
   logo and keeping the arena close to the headline. */
.arena { position: relative; display: flex; flex-direction: column-reverse; justify-content: center; gap: 6px; min-height: 0; }
.arena-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
}
/* Leave room for the logo, scores, headline and both buttons on screen. */
.landing .arena-frame {
  max-height: calc(100dvh - 400px);
  max-width: calc(100dvh - 400px);
  margin: 0 auto;
}
#board { position: absolute; inset: 0; width: 100%; height: 100%; }
/* The arena's straight edges dissolve into the page; the corners (where the
   bases are) stay fully visible. */
.arena-frame {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 5%, #000 95%, transparent),
                      linear-gradient(to bottom, transparent, #000 5%, #000 95%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 5%, #000 95%, transparent),
              linear-gradient(to bottom, transparent, #000 5%, #000 95%, transparent);
  mask-composite: intersect;
}

.scoreboard { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.live-chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.live-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; box-shadow: 0 0 0 0 rgba(239, 68, 68, .6); animation: live 1.8s var(--out) infinite; }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .55); } 70%, 100% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); } }

.scores { position: relative; display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; flex: 1; justify-content: flex-end; min-width: 0; }
.score {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  padding: 3px 8px 3px 3px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  transition: transform .45s var(--out), border-color .3s;
}
.score img { width: 24px; height: 24px; border-radius: 50%; background: #1b1830; box-shadow: 0 0 0 2px var(--c); object-fit: cover; }
.score b { font-family: var(--display); font-weight: 400; font-size: 14px; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.score.lead { border-color: color-mix(in srgb, var(--gold) 60%, transparent); }
.score .crown { position: absolute; top: -9px; left: 9px; width: 16px; height: 16px; opacity: 0; transform: translateY(4px) scale(.6); transition: opacity .3s, transform .4s var(--spring); }
.score.lead .crown { opacity: 1; transform: none; }
.score.bump b { animation: bump .45s var(--spring); }
.score.won { border-color: var(--gold); animation: won 1.4s var(--out) 2; }
.score.won::after {
  content: 'wins'; position: absolute; left: 50%; bottom: -17px; transform: translateX(-50%);
  font-family: var(--display); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--gold);
}
@keyframes won { 0% { box-shadow: 0 0 0 0 rgba(250, 204, 21, .55); } 70%, 100% { box-shadow: 0 0 0 10px rgba(250, 204, 21, 0); } }
.live-chip.final .dot { background: var(--gold); animation: none; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.35); color: var(--gold); } 100% { transform: scale(1); } }

.pitch { padding-top: 14px; }
.headline {
  margin: 0;
  font-family: var(--display); font-weight: 400;
  font-size: clamp(32px, 9vw, 44px); line-height: 1.02;
  letter-spacing: -.01em;
}
.headline span { display: block; white-space: nowrap; }
.headline span + span { color: var(--accent); }
.lede { margin: 12px 0 0; color: var(--muted); font-size: 16px; line-height: 1.45; max-width: 34ch; }

.actions { display: grid; gap: 8px; margin-top: 20px; }
.btn {
  display: flex; align-items: center; justify-content: center;
  min-height: var(--tap);
  border-radius: 14px;
  font-family: var(--display); font-size: 18px; letter-spacing: .01em;
  text-decoration: none;
  user-select: none;
  transition: transform .12s var(--out), background-color .2s, box-shadow .2s, color .2s;
}
.btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.btn:active { transform: scale(.97); }
.btn-primary {
  color: var(--accent-ink);
  background: var(--accent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .35) inset, 0 10px 28px -12px rgba(34, 211, 238, .7);
}
.btn-quiet { color: var(--text); background: transparent; border: 1px solid var(--line); font-size: 16px; min-height: 48px; }
@media (hover: hover) {
  .btn-primary:hover { background: #4fe0f3; }
  .btn-quiet:hover { background: var(--panel); border-color: rgba(255, 255, 255, .18); }
}

/* Short phones: tighten the copy block so both buttons fit. */
@media (max-width: 699px) and (max-height: 720px) {
  .headline { font-size: 30px; }
  .lede { font-size: 15px; margin-top: 8px; }
  .actions { margin-top: 14px; }
  .pitch { padding-top: 8px; }
}

@media (min-width: 700px) and (max-width: 959px) {
  .landing { max-width: 640px; }
  .lede { font-size: 18px; }
}

/* ------------------------------------------------------------ desktop */

@media (min-width: 960px) {
  .landing {
    max-width: 1280px;
    grid-template-columns: minmax(360px, 5fr) 7fr;
    grid-template-rows: auto 1fr;
    column-gap: 48px;
    padding: 28px 48px 32px;
  }
  .topbar { grid-column: 1 / -1; height: 56px; }
  .logo { height: 44px; }
  .pitch { grid-column: 1; grid-row: 2; align-self: center; padding: 0 0 6vh; }
  .arena { grid-column: 2; grid-row: 2; flex-direction: column; }
  .landing .arena-frame { max-height: calc(100dvh - 170px); width: auto; height: calc(100dvh - 170px); max-width: 100%; }
  .headline { font-size: clamp(42px, 3.9vw, 60px); }
  .lede { font-size: 18px; margin-top: 18px; }
  .actions { grid-template-columns: auto auto; justify-content: start; margin-top: 32px; gap: 12px; }
  .btn-primary { padding: 0 34px; }
  .btn-quiet { padding: 0 24px; min-height: var(--tap); }
  .scoreboard { justify-content: center; }
  .scores { flex: none; gap: 6px; }
  .score { padding-right: 10px; }
  .score img { width: 28px; height: 28px; }
  .live-label::after { content: ' match'; }
}

/* ------------------------------------------------------------ entrance
   One orchestrated reveal, under a second; nothing else animates on load. */

.landing[data-state] .logo,
.landing[data-state] .headline span,
.landing[data-state] .lede,
.landing[data-state] .actions,
.landing[data-state] .scoreboard { opacity: 0; transform: translateY(10px); }
.landing[data-state] .arena-frame { opacity: 0; transform: scale(.97); }

.landing[data-state="ready"] .logo,
.landing[data-state="ready"] .headline span,
.landing[data-state="ready"] .lede,
.landing[data-state="ready"] .actions,
.landing[data-state="ready"] .scoreboard,
.landing[data-state="ready"] .arena-frame {
  opacity: 1; transform: none;
  transition: opacity .5s var(--out), transform .6s var(--out);
}
.landing[data-state="ready"] .arena-frame { transition-duration: .8s; }
.landing[data-state="ready"] .logo { transition-delay: .05s; }
.landing[data-state="ready"] .headline span:nth-child(1) { transition-delay: .15s; }
.landing[data-state="ready"] .headline span:nth-child(2) { transition-delay: .24s; }
.landing[data-state="ready"] .lede { transition-delay: .33s; }
.landing[data-state="ready"] .actions { transition-delay: .42s; }
.landing[data-state="ready"] .scoreboard { transition-delay: .6s; }

/* Between matches the arena dips out and back in. */
.arena-frame.swap { opacity: 0 !important; transition: opacity .35s var(--out) !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .landing[data-state] * { opacity: 1 !important; transform: none !important; }
}
