/* squadreader.com — shared site surface.
 *
 * The site's own language: light by default with a dark mode, SF Pro, generous
 * whitespace, soft shadows instead of hard borders, pill controls, one accent
 * used sparingly. Everything here is deliberately quiet — the loud thing on a
 * page should be the match, not the chrome.
 *
 * Token NAMES are shared with the app's stylesheet so /stats re-skins from the
 * same vocabulary; setup.html and admin.html alias their older names onto these.
 */

:root {
  --bg:        #fbfbfd;
  --surface-1: #ffffff;   /* cards */
  --surface-2: #f5f5f7;   /* inputs, hover, bands */
  --surface-3: #ececf1;   /* active / selected */
  --ink:       #1d1d1f;
  --ink-mute:  #6e6e73;
  --ink-faint: #86868b;
  --border:        #e3e3e8;
  --border-strong: #d2d2d7;

  --accent:      #0071e3;
  --accent-2:    #0077ed;
  --accent-weak: rgba(0,113,227,.07);
  --accent-ring: rgba(0,113,227,.35);
  --on-accent:   #ffffff;

  /* MIRRORED from the map renderer — changing these desyncs it. */
  --team1: #c65861;
  --team2: #5f97cf;
  --neutral: #9ca3af;

  --good: #1a8a3a;
  --warn: #9a6a00;
  --bad:  #d13b3b;

  --radius:      20px;
  --radius-sm:   12px;
  --radius-pill: 980px;
  --shadow:    0 4px 24px rgba(0,0,0,.06), 0 24px 60px rgba(0,0,0,.07);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);

  --sans: -apple-system, "SF Pro Display", "SF Pro Text", system-ui, "Segoe UI",
          Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --max: 1024px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #000000;
    --surface-1: #1a1a1c;
    --surface-2: #0f0f11;
    --surface-3: #262628;
    --ink:       #f5f5f7;
    --ink-mute:  #a1a1a6;
    --ink-faint: #6e6e73;
    --border:        #262628;
    --border-strong: #333336;
    --accent:      #2997ff;
    --accent-2:    #4aa8ff;
    --accent-weak: rgba(41,151,255,.14);
    --accent-ring: rgba(41,151,255,.40);
    --good: #30d158;
    --warn: #ffd426;
    --bad:  #ff6b6b;
    --team1: #e0868d;
    --team2: #78acdd;
    --shadow:    0 4px 24px rgba(0,0,0,.4), 0 30px 70px rgba(0,0,0,.55);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg:#000; --surface-1:#1a1a1c; --surface-2:#0f0f11; --surface-3:#262628;
  --ink:#f5f5f7; --ink-mute:#a1a1a6; --ink-faint:#6e6e73;
  --border:#262628; --border-strong:#333336;
  --accent:#2997ff; --accent-2:#4aa8ff; --accent-weak:rgba(41,151,255,.14);
  --accent-ring:rgba(41,151,255,.40);
  --good:#30d158; --warn:#ffd426; --bad:#ff6b6b;
  --team1:#e0868d; --team2:#78acdd;
  --shadow:0 4px 24px rgba(0,0,0,.4),0 30px 70px rgba(0,0,0,.55);
  --shadow-sm:0 1px 3px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  letter-spacing: -.011em;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); }
img { max-width: 100%; display: block; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.028em; text-wrap: balance; }
::selection { background: var(--accent-weak); }

/* Digits that line up in a column — tickets, counts, durations. SF's own
   tabular figures rather than a monospace face: a second typeface just for
   numbers would be louder than the numbers deserve. */
.num { font-variant-numeric: tabular-nums; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 28px; }
.grow { flex: 1; }

/* ---- nav ---------------------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.nav-in {
  max-width: var(--max); margin: 0 auto; padding: 0 28px;
  height: 54px; display: flex; align-items: center; gap: 26px;
}
.brand { display: inline-flex; align-items: center; }
.brand .logo { height: 30px; width: auto; }
.nav-links { display: flex; align-items: center; gap: 24px; }
.nav-links a { color: var(--ink-mute); font-size: .86rem; transition: color .2s; }
.nav-links a:hover, .nav-links a.act { color: var(--ink); }
@media (max-width: 760px) {
  .nav-in { gap: 16px; padding: 0 18px; }
  .nav-links { gap: 16px; overflow-x: auto; scrollbar-width: none; }
  .nav-links::-webkit-scrollbar { display: none; }
  .wrap { padding: 0 18px; }
}

/* ---- controls ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-pill);
  background: transparent; color: var(--accent);
  border: 1px solid var(--border-strong); cursor: pointer;
  font: inherit; font-size: .92rem; font-weight: 500; letter-spacing: -.01em;
  line-height: 1; white-space: nowrap;
  transition: background .2s, border-color .2s, color .2s, transform .2s;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-ring); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.btn.primary:hover { background: var(--accent-2); color: var(--on-accent); transform: scale(1.015); }
.btn.ghost { border-color: transparent; color: var(--ink-mute); }
.btn.ghost:hover { color: var(--ink); background: var(--surface-2); }
.btn.sm { padding: 6px 14px; font-size: .82rem; }
.btn[disabled] { opacity: .4; pointer-events: none; }

.card {
  background: var(--surface-1);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--ink-mute);
  font-size: .74rem; font-weight: 500; white-space: nowrap;
}
.chip.good { color: var(--good); }

.arrow-link { color: var(--accent); font-size: .92rem; font-weight: 500; white-space: nowrap; }
.arrow-link:hover { color: var(--accent-2); }

/* ---- page header -------------------------------------------------------- */
.head { padding: 64px 0 26px; }
.head .kicker { color: var(--accent); font-size: 1.02rem; font-weight: 600; }
.head h1 {
  margin: 8px 0 0; font-size: clamp(2.1rem, 4.6vw, 3.1rem);
  line-height: 1.06; letter-spacing: -.03em;
}
.head .lead {
  margin: 16px 0 0; max-width: 54ch;
  color: var(--ink-mute); font-size: clamp(1.05rem, 1.8vw, 1.22rem);
}

/* ---- replay card -------------------------------------------------------- */
.rgrid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}
.rcard {
  background: var(--surface-1); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden;
  display: flex; flex-direction: column;
  transition: box-shadow .25s ease;
}
.rcard:hover { box-shadow: var(--shadow); }
.rcard.archived .rart { opacity: .5; }

.rart {
  position: relative; aspect-ratio: 16/9;
  background: var(--surface-2); background-size: cover; background-position: center;
  transition: opacity .25s;
}
.rart .rimg {
  position: absolute; inset: 0; z-index: 0;
  width: 100%; height: 100%; object-fit: cover;
}
/* Just enough darkening to carry the layer name. */
.rart::after {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, rgba(0,0,0,0) 45%, rgba(0,0,0,.58) 100%);
}
.rart .rlayer {
  position: absolute; left: 16px; right: 16px; bottom: 12px; z-index: 2;
  color: #fff; font-size: 1.06rem; font-weight: 600; letter-spacing: -.02em;
}
/* A quiet pill, and only when it says something the card does not already say. */
.rart .rstate {
  position: absolute; left: 14px; top: 12px; z-index: 2;
  padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: .72rem; font-weight: 600;
  background: rgba(255,255,255,.92); color: #1d1d1f;
}
.rart .rstate.watch { display: none; }   /* the Watch link below already says it */
.rart .rstate.livenow { background: var(--bad); color: #fff; }
.rart .rmode {
  position: absolute; right: 14px; top: 12px; z-index: 2;
  padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: .72rem; font-weight: 500;
  background: rgba(0,0,0,.42); color: #fff;
}

.rbody {
  padding: 16px 18px 18px; flex: 1;
  display: flex; flex-direction: column; gap: 10px;
}

.rscore { display: flex; align-items: baseline; gap: 10px; font-size: .95rem; }
.rside { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.rside .fac {
  color: var(--ink-mute); font-size: .82rem; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rside .tk { font-size: 1.06rem; font-weight: 600; }
.rside.t1 .tk { color: var(--team1); }
.rside.t2 .tk { color: var(--team2); }
.rscore .vs { color: var(--ink-faint); font-size: .78rem; }

.rmeta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  color: var(--ink-faint); font-size: .84rem;
}
.rmeta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .6; }

/* The action is a text link, not a filled button: no card is more important
   than the next, and twenty filled buttons is a wall of colour. */
/* margin-top:auto pushes this to the bottom of the card, so every Watch link
   in a row lines up regardless of how far the meta above it wrapped. */
.ract { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 4px; }
.ract .btn {
  padding: 0; border: 0; background: none; color: var(--accent);
  font-size: .92rem; font-weight: 500;
}
.ract .btn:hover { background: none; color: var(--accent-2); transform: none; }
.rnote { color: var(--ink-faint); font-size: .84rem; cursor: help; }

/* ---- filter bar --------------------------------------------------------- */
.filters {
  position: sticky; top: 54px; z-index: 40;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 14px 0;
}
.frow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fsearch {
  flex: 1 1 220px; min-width: 180px;
  display: flex; align-items: center; gap: 9px;
  padding: 8px 15px; border-radius: var(--radius-pill);
  background: var(--surface-2);
}
.fsearch:focus-within { box-shadow: 0 0 0 4px var(--accent-ring); }
.fsearch input {
  flex: 1; background: none; border: 0; outline: none;
  color: var(--ink); font: inherit; font-size: .94rem; min-width: 0;
}
.fsearch svg { flex: none; opacity: .45; }
select.fsel {
  padding: 8px 34px 8px 15px; border-radius: var(--radius-pill);
  background-color: var(--surface-2); color: var(--ink);
  border: 0; font: inherit; font-size: .94rem;
  cursor: pointer; max-width: 210px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236e6e73' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
select.fsel:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-ring); }

.fcount { color: var(--ink-faint); font-size: .88rem; }
.fcount b { color: var(--ink-mute); font-weight: 600; }

/* ---- states ------------------------------------------------------------- */
.empty { padding: 72px 24px; text-align: center; color: var(--ink-mute); }
.empty h3 { margin: 0 0 8px; color: var(--ink); font-size: 1.2rem; }
.empty p { margin: 0; }
.skel { color: var(--ink-faint); }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 40px 0 64px; }
.pager .pinfo { color: var(--ink-faint); font-size: .88rem; }

/* ---- footer ------------------------------------------------------------- */
footer { border-top: 1px solid var(--border); margin-top: 40px; }
.foot {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 28px 0 40px; color: var(--ink-faint); font-size: .85rem;
}
.foot a { color: var(--ink-mute); }
.foot a:hover { color: var(--ink); }


/* ---- list view (the /replays browser) -----------------------------------
   Cards are for showing a handful off; a browser is for scanning many. Rows
   put the layer name, the result and the action on one line each, so twenty
   matches read as a list instead of twenty separate objects. */
.rlist { display: flex; flex-direction: column; }
.rrow {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 8px;
  border-bottom: 1px solid var(--border);
  transition: background .18s;
}
.rlist .rrow:first-child { border-top: 1px solid var(--border); }
.rrow:hover { background: var(--surface-2); }
.rrow.archived { opacity: .62; }
.rrow.archived:hover { opacity: 1; }

.rrow .th {
  flex: none; width: 92px; height: 52px; border-radius: 8px;
  background: var(--surface-2); background-size: cover; background-position: center;
  position: relative; overflow: hidden;
}
.rrow .th img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.rrow .main { flex: 1 1 260px; min-width: 0; }
.rrow .rl-name {
  font-size: 1.02rem; font-weight: 600; letter-spacing: -.02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rrow .rl-sub {
  margin-top: 3px; color: var(--ink-faint); font-size: .84rem;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.rrow .rl-sub .dot { width: 3px; height: 3px; border-radius: 50%;
                     background: currentColor; opacity: .6; }

.rrow .score { flex: none; display: flex; align-items: baseline; gap: 7px; font-size: .95rem; }
.rrow .score .tk { font-weight: 600; }
.rrow .score .t1 { color: var(--team1); }
.rrow .score .t2 { color: var(--team2); }
.rrow .score .fac { color: var(--ink-mute); font-size: .8rem; }
.rrow .score .vs { color: var(--ink-faint); font-size: .76rem; }

.rrow .act { flex: none; margin-left: auto; display: flex; align-items: center; gap: 12px; }
.rrow .act a { font-size: .92rem; font-weight: 500; white-space: nowrap; }
.rrow .act .rnote { font-size: .84rem; }

@media (max-width: 780px) {
  .rrow { flex-wrap: wrap; gap: 12px; }
  .rrow .main { flex: 1 1 100%; order: 2; }
  .rrow .score { order: 3; }
  .rrow .act { order: 4; }
}
