/* ==========================================================================
   Halloween Cup — display.php

   Fixed-stage layout: #stage is a literal 1672x941 box — the exact
   reference size of the approved mockup, so every decorative asset
   (cropped directly from that mockup; see assets/images/decor/ and the
   original placements.json) sits at its precise original coordinate
   instead of an eyeballed one. display.js measures the viewport and
   applies one transform: scale(...) to #stage so the whole composition —
   decorative art layers AND the live schedule/sidebar UI — scales
   together as a single rigid unit, instead of every element reflowing
   independently at CSS breakpoints.

   Layer order inside #stage:
   1) .decor-layer   — real illustrated PNG assets cropped from the mockup
   2) everything else — the real, data-driven UI (header, schedule, sidebar)
   ========================================================================== */

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden; /* the TV display is not meant to scroll */
  background: var(--color-ink);
}

body {
  font-family: var(--font-body);
}

.stage-wrapper {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% -10%, #ff8300 0%, transparent 55%), radial-gradient(ellipse at 15% 110%, #000 0%, transparent 45%), radial-gradient(ellipse at 85% 105%, #1c1e26 0%, transparent 45%), #521001
}

.stage {
  position: relative;
  width: 1920px;
  height: 1081px;
  flex: none;
  transform-origin: center center;
  color: var(--color-paper);
}

/* paper grain, generated (no external texture image) */
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0.12;
  mix-blend-mode: overlay;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- Frame overlay (single complete asset, sits ABOVE the real UI) ------- */

/*
 * Main frame — title, real club crest, reaper, trees and graveyard baked
 * into one asset with a transparent centre. Sits IN FRONT of the table
 * (higher z-index than .display-body) so any small edge overlap is simply
 * painted over instead of requiring pixel-perfect non-overlap.
 */
.frame-overlay {
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: 1081px;
  z-index: 3;
  pointer-events: none;
}

/*
 * Secondary corner accents (graveyard corner, moon/castle corner) — same
 * canvas, drawn BEHIND the table/sidebar as background depth.
 */
.frame-overlay-back {
  position: absolute;
  left: 0;
  top: 0;
  width: 1920px;
  height: 1081px;
  z-index: 1;
  pointer-events: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.display-subheader {
  position: absolute;
  left: 108px;
  top: 214px;
  width: 1692px;
  height: 28px;
  z-index: 2;
  text-align: center;
}

.display-subheader h2,
#tournament-subtitle {
  display: none; /* tournament name + time hidden per feedback — hint below stays */
}

.display-subheader p {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--color-paper-dim);
}

#tournament-hint {
  min-height: 1em;
  font-weight: 700;
  color: var(--color-burnt-orange);
}

/* ---- Schedule table --------------------------------------------------- */

.display-body {
  position: absolute;
  left: 169px;
  top: 211px; /* sized to the v3 frame's transparent centre hole */
  width: 1580px;
  height: 688px;
  z-index: 2;
  display: flex;
  gap: 18px;
}

.display-schedule {
  flex: none;
  width: 1250px;
  height: 688px;
  background: linear-gradient(180deg, #1b1f1f 0%, #121616 100%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.display-schedule table {
  width: 100%;
  height: 100%;
  border-collapse: separate;
  border-spacing: 3px;
  table-layout: fixed;
}

.display-schedule thead th {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 5px 4px;
  color: #fff;
  border-radius: 5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.display-schedule th.schedule-time-head {
  background: var(--color-ink-soft);
  width: 68px;
  color: var(--color-paper);
}

.display-schedule tbody td {
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(236, 224, 200, 0.045);
  color: #ffaa50;
  vertical-align: middle;
  line-height: 1.15;
  text-align: center;
}

.schedule-time {
  font-weight: 700;
  font-size: 20px;
  white-space: nowrap;
  text-align: left;
  background: transparent !important;
}

.schedule-cell {
  font-size: 11px;
}

.cell-team {
  display: block;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.1;
  color: var(--color-paper);
}

.cell-vs {
  display: block;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #fe8403;
  opacity: 0.7;
  margin: 0;
}

.cell-score {
  display: block;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  color: var(--color-gold);
  margin: 0;
}

.cell-empty {
  color: var(--color-paper-dim);
  opacity: 0.5;
}

.schedule-cell.is-live {
  background: rgba(166, 54, 44, 0.16);
  box-shadow: inset 0 0 0 2px var(--color-blood);
  animation: live-pulse 2.4s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { box-shadow: inset 0 0 0 2px var(--color-blood); }
  50%      { box-shadow: inset 0 0 0 2px var(--color-burnt-orange); }
}

@media (prefers-reduced-motion: reduce) {
  .schedule-cell.is-live { animation: none; }
}

/* ---- Sidebar ------------------------------------------------------------ */

.display-sidebar {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.display-live {
  background: linear-gradient(180deg, #1b1f1f 0%, #121616 100%);
  padding: 6px 9px 7px;
  overflow-y: auto;
  flex: 1;
}

.display-sidebar h3 {
  margin: 12px 0 18px;
  font-family: atone;
  font-size: 35px;
  letter-spacing: 2px;
  color: #fd7404;
  padding-bottom: 3px;
}

.display-empty-hint {
  color: var(--color-paper-dim);
  font-size: 24px;
  font-style: italic;
  margin: 3px 0;
}

/*
 * Sized for the worst case: up to 4 cards (one per pitch) in ~250px of
 * available height each, so a full round showing live or coming up never
 * overflows/scrolls.
 */
.live-card,
.next-round-item {
  display: block;
  background: rgba(236, 224, 200, 0.045);
  border-radius: 7px;
  padding: 4px 8px 4px;
  margin-bottom: 4px;
  text-align: center;
}

.live-card:last-child,
.next-round-item:last-child {
  margin-bottom: 0;
}

.live-card-head,
.next-round-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin-bottom: 2px;
}

.live-badge {
  background: var(--color-blood);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 1px 5px;
  border-radius: 3px;
  animation: live-badge-pulse 1.8s ease-in-out infinite;
}

@keyframes live-badge-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.65; }
}

@media (prefers-reduced-motion: reduce) {
  .live-badge { animation: none; }
}

.next-round-time {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-burnt-orange);
  font-size: 15px;
}

.live-pitch,
.next-round-pitch {
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 1px 5px;
  border-radius: 3px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}

.live-teams,
.next-round-teams {
  font-size: 11px;
}

.live-countdown {
  margin-top: 80px;
  text-align: center;
  font-family: 'Manticore', var(--font-display);
  font-weight: 700;
  font-size: 82px;
  color: var(--color-burnt-orange);
  font-variant-numeric: tabular-nums;
}

/* ---- Fullscreen control ----------------------------------------------
   Deliberately outside #stage (see display.php) so it stays a real,
   comfortably-clickable fixed size regardless of the stage's scale. */

#fullscreen-btn {
  position: fixed;
  right: 14px;
  bottom: 10px;
  z-index: 5;
  background: rgba(22, 19, 15, 0.7);
  color: var(--color-paper-dim);
  border: 1px solid rgba(236, 224, 200, 0.25);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 11px;
  letter-spacing: 2px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s ease;
}

#fullscreen-btn:hover,
#fullscreen-btn:focus-visible {
  opacity: 1;
}

/* ---- League table (replaces the live / next games box while switched on) ---- */
.display-table {
  background: linear-gradient(180deg, #1b1f1f 0%, #121616 100%);
  padding: 6px 9px 7px;
  overflow: hidden;
  flex: 1;
}

.standings {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 3px;
  table-layout: fixed;
  font-family: var(--font-body);
  color: var(--color-paper);
}

.standings th {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--color-paper-dim);
  text-align: center;
  padding: 0 2px 3px;
}

.standings th.st-team,
.standings td.st-team {
  text-align: left;
}

.standings th:nth-child(1) { width: 26px; }
.standings th:nth-child(3) { width: 30px; }
.standings th:nth-child(4) { width: 40px; }
.standings th:nth-child(5) { width: 38px; }

.standings td {
  height: var(--st-row-h, 40px);
  padding: 0 2px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  background: rgba(236, 224, 200, 0.045);
  line-height: 1.1;
}

.standings td:first-child { border-radius: 6px 0 0 6px; }
.standings td:last-child { border-radius: 0 6px 6px 0; }

.standings td.st-rank {
  color: var(--color-gold);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
}

.standings td.st-team {
  font-size: 14px;
  padding-left: 6px;
  overflow-wrap: anywhere;
}

.standings td.st-pts {
  color: #ffaa50;
  font-weight: 700;
  font-size: 18px;
}

.standings tr.st-first td {
  background: rgba(217, 154, 43, 0.16);
  box-shadow: inset 0 0 0 1px rgba(217, 154, 43, 0.45);
}

/* ---- Cancelled match ("fällt aus") ---- */
.schedule-cell.is-cancelled .cell-team {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  opacity: 0.5;
}

.schedule-cell.is-cancelled {
  background: rgba(166, 54, 44, 0.07);
}

.cell-cancel {
  display: block;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: #ff6b57;
  margin: 1px 0;
}
