/* Lex's World Cup 2026 — noir broadcast overlay
   Desaturated near-black palette, single accent: #ff5b00 (the X mark). */

:root {
  color-scheme: dark;

  --accent: #ff5b00;
  --accent-soft: rgba(0, 0, 0, 0.185);
  --accent-line: rgb(255, 89, 0);

  --ink: #f0f0f0; /* primary text, just off-white */
  --ink-dim: #9d9d9d; /* secondary */
  --ink-faint: #686868; /* tertiary / labels */

  --panel: rgba(12, 12, 12, 0.12);
  --panel-strong: rgba(18, 18, 18, 0.16);
  --panel-raise: rgba(26, 26, 26, 0.12);
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);

  --gap: 16px;
  --radius: 3px;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.55);

  --font-display: "Oswald", "Arial Narrow", system-ui, sans-serif;
  --font-body:
    "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  /* bg.webp shown as-is; it is already a dark noir texture */
  background: #050505 url("/assets/bg.webp") center / cover no-repeat fixed;
}

body.transparent,
body.transparent .grain,
body.transparent .vignette {
  background: transparent;
}
body.transparent {
  backdrop-filter: none;
}

/* Film grain + vignette layers for the noir texture */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(
    130% 100% at 50% 40%,
    transparent 70%,
    rgba(0, 0, 0, 0.22) 100%
  );
}

.stage {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  padding: 22px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--gap);
}

/* ---------- Top bar ---------- */

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 16px 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), transparent 60%);
}

/* Subtle film grain over the top bar and panels */
.topbar::before,
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.12;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.brand-mark {
  height: 52px;
  width: auto;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 18px rgba(255, 91, 0, 0.35));
}

.brand-text {
  min-width: 0;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-year {
  color: var(--accent);
}

.subtitle {
  margin-top: 4px;
  color: var(--ink-dim);
  font-size: 14px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink-dim);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(255, 91, 0, 0.85);
  flex: 0 0 auto;
  animation: pulse 2.4s ease-in-out infinite;
}

.dot.stale {
  background: var(--ink-faint);
  box-shadow: none;
  animation: none;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

/* ---------- Layout ---------- */

.layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(540px, 1.06fr) minmax(500px, 0.94fr);
  grid-template-rows: minmax(0, 1fr) minmax(270px, 0.64fr);
  gap: var(--gap);
}

.panel {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.panel.leaderboard {
  grid-row: 1 / span 2;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
  position: relative;
  padding-left: 14px;
}

.panel-header h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 16px;
  background: var(--accent);
}

.meta {
  color: var(--ink-faint);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.search {
  flex: 0 1 240px;
  margin-left: auto;
  min-width: 0;
  padding: 7px 12px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 2px;
  outline: none;
  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.search::placeholder {
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 11px;
}

.search:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
}

/* Leaderboard scrolls through the full field with a pinned header */
.leaderboard .table-wrap {
  overflow-y: auto;
  padding-top: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 91, 0, 0.4) transparent;
}

.leaderboard .table-wrap::-webkit-scrollbar {
  width: 7px;
}

.leaderboard .table-wrap::-webkit-scrollbar-thumb {
  background: rgba(255, 91, 0, 0.4);
  border-radius: 4px;
}

.leaderboard thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(8, 8, 8, 0.96);
  backdrop-filter: blur(8px);
}

/* ---------- Tables ---------- */

.table-wrap {
  min-height: 0;
  overflow: hidden;
  padding: 4px 12px 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 10px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

th {
  color: var(--ink-faint);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: left;
  font-weight: 600;
}

td {
  font-size: 19px;
  line-height: 1.15;
}

tbody tr:last-child td {
  border-bottom: none;
}

.rank {
  width: 64px;
  color: var(--ink-dim);
  font-family: var(--font-display);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.num {
  width: 78px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
}

.name {
  font-weight: 600;
  color: var(--ink);
}
.points {
  color: var(--accent);
  font-weight: 800;
}
.small {
  color: var(--ink-faint);
  font-size: 13px;
}

/* Podium emphasis */
.leaderboard tbody tr.r1 td {
  background: var(--accent-soft);
}
.leaderboard tbody tr.r1 .rank,
.leaderboard tbody tr.r1 .name {
  color: #fff;
}
.leaderboard tbody tr.r1 .rank::before {
  content: "★ ";
  color: var(--accent);
}
.leaderboard tbody tr.r2 .rank,
.leaderboard tbody tr.r3 .rank {
  color: var(--accent);
}

/* ---------- Match cards ---------- */

.matches {
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  gap: 9px;
  align-content: start;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 91, 0, 0.4) transparent;
}

.matches::-webkit-scrollbar {
  width: 7px;
}
.matches::-webkit-scrollbar-thumb {
  background: rgba(255, 91, 0, 0.4);
  border-radius: 4px;
}

.match {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 11px 14px;
  background: var(--panel-raise);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent-line);
  border-radius: 2px;
}

.time {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.teams {
  min-width: 0;
  font-size: 18px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  padding: 4px 10px;
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  border-radius: 2px;
}

/* ---------- Group tables ---------- */

.groups {
  min-height: 0;
  overflow: hidden;
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
}

.group {
  background: var(--panel-raise);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 10px 12px;
  min-width: 0;
}

.group-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.group table td {
  font-size: 14px;
  padding: 6px 5px;
  color: var(--ink);
}
.group table th {
  font-size: 10px;
  padding: 4px 5px;
}

/* ---------- Ticker ---------- */

.ticker {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  overflow: hidden;
  color: var(--ink-dim);
  font-size: 15px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.ticker-rail {
  display: flex;
  width: max-content;
  min-width: 100%;
  animation: ticker-scroll 46s linear infinite;
  will-change: transform;
}

.ticker-set {
  display: flex;
  gap: 28px;
  flex: 0 0 auto;
  padding-right: 28px;
}

.ticker-set span::before {
  content: "▸";
  color: var(--accent);
  margin-right: 8px;
}

.ticker strong {
  color: var(--ink);
  font-weight: 700;
}

@keyframes ticker-scroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

/* ---------- View variants ---------- */

.view-leaderboard .layout,
.view-schedule .layout,
.view-tables .layout {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.view-leaderboard .panel:not(.leaderboard),
.view-schedule .panel:not(.schedule),
.view-tables .panel:not(.standings) {
  display: none;
}

.view-leaderboard .panel.leaderboard,
.view-schedule .panel.schedule,
.view-tables .panel.standings {
  grid-row: auto;
}

.view-tables .groups {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.view-schedule .matches {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.view-schedule .match {
  grid-template-columns: 140px 1fr auto;
}

.empty {
  padding: 18px;
  color: var(--ink-dim);
  font-size: 16px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
  .stage {
    padding: 12px;
    gap: 12px;
  }
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(400px, 1fr) 300px 300px;
  }
  .panel.leaderboard {
    grid-row: auto;
  }
  .brand-mark {
    height: 40px;
  }
  h1 {
    font-size: 26px;
  }
  .subtitle {
    display: none;
  }
  td {
    font-size: 16px;
  }
  .match {
    grid-template-columns: 104px 1fr;
  }
  .match .pill {
    display: none;
  }
  .groups {
    grid-template-columns: 1fr;
  }
  .ticker {
    display: none;
  }
}

/* Mobile display mode: use the page as the scroll container instead of a fixed overlay. */
@media (max-width: 760px), (pointer: coarse) and (max-width: 1024px) {
  html,
  body {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body {
    min-height: 100dvh;
    background-attachment: scroll;
    -webkit-overflow-scrolling: touch;
  }

  .stage {
    width: 100%;
    min-height: 100dvh;
    height: auto;
    padding:
      max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 12px;
    padding: 12px;
    overflow: visible;
  }

  .brand {
    gap: 12px;
  }

  .brand-mark {
    height: 36px;
  }

  h1 {
    font-size: 22px;
    line-height: 1.08;
    white-space: normal;
  }

  .status {
    justify-self: start;
    font-size: 12px;
    white-space: normal;
  }

  .layout,
  .view-leaderboard .layout,
  .view-schedule .layout,
  .view-tables .layout {
    min-height: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .panel,
  .view-leaderboard .panel.leaderboard,
  .view-schedule .panel.schedule,
  .view-tables .panel.standings {
    min-height: auto;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .panel-header {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
  }

  .panel-header h2 {
    flex: 1 1 auto;
    font-size: 16px;
  }

  .meta {
    padding-top: 2px;
    font-size: 11px;
  }

  .search {
    flex: 1 0 100%;
    width: 100%;
    min-height: 44px;
    margin-left: 0;
    font-size: 16px;
  }

  .table-wrap,
  .leaderboard .table-wrap {
    min-height: auto;
    max-height: min(58dvh, 520px);
    overflow: auto;
    padding: 0 8px 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .leaderboard table {
    min-width: 0;
  }

  .leaderboard th:nth-child(3),
  .leaderboard th:nth-child(4),
  .leaderboard th:nth-child(5),
  .leaderboard td:nth-child(3),
  .leaderboard td:nth-child(4),
  .leaderboard td:nth-child(5) {
    display: none;
  }

  .leaderboard table.is-empty {
    min-width: 0;
  }

  .leaderboard table.is-empty td {
    white-space: normal;
  }

  th,
  td {
    padding: 8px 6px;
  }

  td {
    font-size: 15px;
  }

  .rank {
    width: 52px;
  }

  .num {
    width: 62px;
  }

  .matches,
  .view-schedule .matches {
    min-height: auto;
    max-height: min(48dvh, 420px);
    overflow-y: auto;
    padding: 10px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .match,
  .view-schedule .match {
    grid-template-columns: 1fr;
    gap: 6px;
    align-items: start;
    padding: 12px;
  }

  .teams {
    font-size: 16px;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  .pill,
  .match .pill {
    display: inline-flex;
    width: fit-content;
    margin-top: 2px;
  }

  .groups,
  .view-tables .groups {
    min-height: auto;
    max-height: min(62dvh, 560px);
    overflow-y: auto;
    grid-template-columns: 1fr;
    padding: 10px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .group {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .group table {
    min-width: 0;
    table-layout: auto;
  }

  .group table td {
    white-space: normal;
  }

  .empty {
    padding: 14px;
    font-size: 14px;
  }
}
