/* Hockey Event Detection: shared look for every page.
   Rink palette: ice background, white boards, navy ink, blue line for
   anything you can act on, goal-light red reserved for goals (and deletes). */

:root {
  --ice: #eef3f6;
  --board: #ffffff;
  --ink: #0f1d2a;
  --ink-2: #4a5b69;
  --ink-3: #7d8c98;
  --rule: #d3dde4;
  --rule-soft: #e4ebf0;
  --blueline: #1c4e9e;
  --blueline-hover: #163f82;
  --crease: #e3eff9;
  --goal: #d22630;
  --goal-soft: #fbe7e8;
  --penalty: #b8570f;
  --penalty-soft: #fbeedf;
  --done: #2f7a4e;
  --done-soft: #e3f2e9;

  --font-display: "Big Shoulders Display", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "Atkinson Hyperlegible Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "Martian Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --radius: 6px;
  --shadow: 0 1px 0 rgba(15, 29, 42, 0.04), 0 1px 3px rgba(15, 29, 42, 0.06);
  --page: 1200px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ice);
  color: var(--ink);
  font: 15px/1.5 var(--font-body);
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
}
a { color: var(--blueline); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img, video { max-width: 100%; display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--blueline); outline-offset: 2px; border-radius: 3px; }
code, .mono { font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: -0.01em; }
h1, h2, h3 { margin: 0; font-weight: 700; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  background: var(--board);
  border-bottom: 3px solid var(--blueline);
  position: sticky; top: 0; z-index: 20;
}
.app-header .inner {
  max-width: var(--page); margin: 0 auto; padding: 0 20px;
  display: flex; align-items: stretch; gap: 28px; min-height: 60px;
}
.app-header .wordmark, .app-header .header-tools { align-self: center; }
.wordmark { display: flex; align-items: baseline; gap: 8px; color: var(--ink); white-space: nowrap; }
.wordmark:hover { text-decoration: none; }
.wordmark b {
  font-family: var(--font-display); font-weight: 800; font-size: 1.55rem;
  letter-spacing: 0.02em; text-transform: uppercase; line-height: 1;
}
.wordmark span { font-size: 0.82rem; color: var(--ink-2); }
.nav { display: flex; gap: 2px; }
.nav a {
  position: relative; display: flex; align-items: center;
  color: var(--ink-2); font-weight: 500; font-size: 0.9rem; padding: 0 10px; white-space: nowrap;
}
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--ink); }
/* Sits on the header's 3px blue line, exactly covering it under the active tab. */
.nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 6px; right: 6px; bottom: -3px; height: 3px; background: var(--goal);
}
.header-tools { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.api-state { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--ink-2); }
.api-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.api-state.ok i { background: var(--done); }
.api-state.bad i { background: var(--goal); }

/* ── Page frame ─────────────────────────────────────────────────────────── */
.page { max-width: var(--page); margin: 0 auto; padding: 28px 20px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-title {
  font-family: var(--font-display); font-weight: 800; font-size: 2.6rem; line-height: 0.95;
  text-transform: uppercase; letter-spacing: 0.01em;
}
.page-sub { color: var(--ink-2); margin: 6px 0 0; }
.crumbs { font-size: 0.85rem; color: var(--ink-2); margin-bottom: 10px; }
.crumbs a { color: var(--ink-2); }
.section { margin-top: 32px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section-title { font-size: 1rem; font-weight: 700; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.small { font-size: 0.82rem; }

.panel { background: var(--board); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-pad { padding: 18px 20px; }

/* ── Controls ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 0.88rem/1 var(--font-body); padding: 9px 14px; border-radius: var(--radius);
  border: 1px solid var(--rule); background: var(--board); color: var(--ink); cursor: pointer;
  white-space: nowrap; transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { border-color: var(--ink-3); text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--blueline); border-color: var(--blueline); color: #fff; }
.btn-primary:hover { background: var(--blueline-hover); border-color: var(--blueline-hover); }
.btn-danger { color: var(--goal); border-color: #efb9bc; }
.btn-danger:hover { background: var(--goal-soft); border-color: var(--goal); }
.btn-warn { color: var(--penalty); border-color: #ecc9a6; }
.btn-warn:hover { background: var(--penalty-soft); border-color: var(--penalty); }
.btn-sm { padding: 6px 10px; font-size: 0.8rem; }
.btn-lg { padding: 13px 20px; font-size: 0.98rem; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--blueline); cursor: pointer; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 0.8rem; font-weight: 600; color: var(--ink-2); }
.input, select.input {
  font: 0.92rem/1.3 var(--font-body); color: var(--ink); background: var(--board);
  border: 1px solid var(--rule); border-radius: var(--radius); padding: 9px 11px; min-width: 0;
}
.input::placeholder { color: var(--ink-3); }
.input:focus, .input:focus-visible { outline: none; border-color: var(--blueline); box-shadow: 0 0 0 3px rgba(28, 78, 158, 0.14); }
select.input {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%234a5b69' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
select.input:hover, .input[type="date"]:hover { border-color: var(--ink-3); }
.input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.55; cursor: pointer; }
.input-lg { font-size: 1.02rem; padding: 13px 14px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 0.86rem; color: var(--ink-2); cursor: pointer; user-select: none; }
.check input { accent-color: var(--blueline); width: 15px; height: 15px; }

kbd {
  font-family: var(--font-mono); font-size: 0.68rem; line-height: 1; padding: 3px 5px;
  border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px; background: var(--board); color: var(--ink-2);
}
.btn-primary kbd { background: transparent; color: #d7e3f5; border-color: rgba(255, 255, 255, 0.35); }

/* ── Status pills ───────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; background: var(--rule-soft); color: var(--ink-2); white-space: nowrap;
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-queued { background: var(--rule-soft); color: var(--ink-2); }
.pill-downloading, .pill-processing { background: var(--crease); color: var(--blueline); }
.pill-downloading i, .pill-processing i { animation: blink 1.2s ease-in-out infinite; }
.pill-completed { background: var(--done-soft); color: var(--done); }
.pill-failed { background: var(--penalty-soft); color: var(--penalty); }
.pill-canceled { background: var(--rule-soft); color: var(--ink-3); }
.tag {
  display: inline-block; font-size: 0.74rem; font-weight: 600; padding: 2px 7px; border-radius: 4px;
  background: var(--rule-soft); color: var(--ink-2); white-space: nowrap;
}
.tag-ok { background: var(--done-soft); color: var(--done); }
.tag-blue { background: var(--crease); color: var(--blueline); }
.tag-warn { background: var(--penalty-soft); color: var(--penalty); }
.tag-goal { background: var(--goal); color: #fff; letter-spacing: 0.04em; text-transform: uppercase; }
@keyframes blink { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.meter { height: 4px; border-radius: 2px; background: var(--rule-soft); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--blueline); border-radius: 2px; transition: width 0.5s ease; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th {
  text-align: left; font-size: 0.74rem; font-weight: 700; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.06em; padding: 11px 14px; border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #f7fafc; }
.table .num { text-align: right; }
.table .empty { text-align: center; color: var(--ink-2); padding: 36px 14px; }
.cell-url { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }

/* ── Goal track: the broadcast timeline with a red mark per goal ─────────── */
.track { position: relative; height: 38px; background: var(--ice); border: 1px solid var(--rule); border-radius: 4px; overflow: hidden; }
.track .done { position: absolute; inset: 0 auto 0 0; background: var(--crease); transition: width 0.5s ease; }
.track .tick {
  position: absolute; top: 5px; bottom: 5px; width: 4px; margin-left: -2px; border: 0; padding: 0;
  background: var(--goal); border-radius: 2px; cursor: pointer;
}
.track .tick:hover, .track .tick:focus-visible { top: 2px; bottom: 2px; width: 6px; margin-left: -3px; outline: none; box-shadow: 0 0 0 2px var(--board), 0 0 0 4px var(--goal); }
.track .tick.no { background: var(--ink-3); }
.track-sm { height: 16px; }
.track-sm .tick { top: 2px; bottom: 2px; width: 3px; margin-left: -1.5px; cursor: default; }
.track-axis { position: relative; height: 16px; margin-top: 5px; font-family: var(--font-mono); font-size: 0.66rem; color: var(--ink-3); }
.track-axis span { position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap; }
.track-axis span:first-child { transform: none; }

/* ── Goal cards ─────────────────────────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.goal-card { background: var(--board); border: 1px solid var(--rule); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); scroll-margin-top: 90px; }
.goal-card.flash { animation: flash 1.4s ease; }
@keyframes flash { 0%, 40% { border-color: var(--goal); box-shadow: 0 0 0 3px var(--goal-soft); } }
.goal-card .media { aspect-ratio: 16 / 9; background: #0f1d2a; display: grid; place-items: center; color: #9fb0bd; font-size: 0.82rem; }
.goal-card .media video, .goal-card .media img { width: 100%; height: 100%; object-fit: cover; }
.goal-card .body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.goal-time { display: flex; align-items: center; gap: 10px; }
.goal-time strong { font-family: var(--font-display); font-weight: 800; font-size: 1.9rem; line-height: 1; letter-spacing: 0.01em; }
.goal-card .conf { margin-left: auto; font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-2); }
.goal-card .quote { font-size: 0.86rem; color: var(--ink-2); border-left: 3px solid var(--rule); padding-left: 10px; margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.review { display: flex; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--rule-soft); }
.review .btn[aria-pressed="true"].yes { background: var(--done-soft); border-color: var(--done); color: var(--done); }
.review .btn[aria-pressed="true"].no { background: var(--goal-soft); border-color: var(--goal); color: var(--goal); }
details.raw summary { cursor: pointer; font-size: 0.8rem; color: var(--ink-3); }
details.raw pre { font-family: var(--font-mono); font-size: 0.68rem; background: var(--ice); border-radius: 4px; padding: 8px; max-height: 160px; overflow: auto; margin: 6px 0 0; }

/* ── Dialogs + toast ────────────────────────────────────────────────────── */
dialog { border: 1px solid var(--rule); border-radius: 8px; padding: 0; width: min(420px, calc(100vw - 32px)); color: var(--ink); box-shadow: 0 12px 40px rgba(15, 29, 42, 0.18); }
dialog::backdrop { background: rgba(15, 29, 42, 0.35); }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
dialog h2 { font-size: 1.1rem; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; background: var(--ink); color: #fff;
  padding: 10px 14px; border-radius: var(--radius); font-size: 0.86rem; box-shadow: 0 8px 24px rgba(15, 29, 42, 0.25);
}
.toast.bad { background: var(--penalty); }
.notice { border: 1px solid #ecc9a6; background: var(--penalty-soft); color: #7a3a0a; border-radius: var(--radius); padding: 10px 14px; font-size: 0.88rem; }
.notice.info { border-color: #bcd3ee; background: var(--crease); color: #173f7e; }

@media (max-width: 860px) {
  .app-header .inner { flex-wrap: wrap; gap: 0 16px; padding: 10px 16px 0; min-height: 0; }
  .wordmark span, .api-state span { display: none; }
  .nav { order: 3; width: 100%; overflow-x: auto; margin: 0 -10px; }
  .nav a { padding: 12px 10px 13px; }
  .nav a[aria-current="page"]::after { bottom: 0; } /* the scrolling nav clips anything below it */
  .page { padding: 20px 16px 48px; }
}
@media (max-width: 720px) {
  .page-title { font-size: 2.1rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
