/* ===========================================================================
   theme.css — Weekend Warriors design system
   "Ballpark at night" : CRM dashboard chassis, baseball scoreboard chrome.

   The palette commits to dark. This is a scoreboard and it is mostly read on a
   phone in a stadium at night — a light mode would be the wrong object.

   Data-series hues are the validated categorical slots 1 and 2 (blue/orange).
   Amber is deliberately NOT a series colour: it lives only inside the
   scoreboard strip, which has its own green plane, so the two never compete.
   =========================================================================== */

:root {
  color-scheme: dark;

  /* -- surfaces -- */
  --plane:        #0a0d12;
  --surface-1:    #131a23;
  --surface-2:    #1b242f;
  --surface-3:    #24303d;
  --surface-sunk: #0d131a;

  /* -- Gwinnett Stripers --
     Pulled off the crest. Used for team identity and the scoreboard plane —
     deliberately never for a data series, so club colour and data colour can
     never be mistaken for each other. */
  --stripers-navy:  #12244a;
  --stripers-green: #6dbe45;
  --stripers-red:   #c8102e;

  /* -- Weekend Warriors (the fantasy team crest) --
     Olive drab, lifted off the badge. Chrome only, never a data series. */
  --team-olive:      #a9b84c;
  --team-olive-dim:  rgba(169, 184, 76, .16);

  /* -- scoreboard plane (its own world: navy board, amber bulbs) -- */
  --board-bg:     #081733;
  --board-bg-2:   #12244a;
  --board-amber:  #ffb020;
  --board-amber-dim: #6b4a12;
  --board-grid:   rgba(255, 176, 32, 0.16);

  /* -- ink -- */
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;

  /* -- lines -- */
  --border:   rgba(255, 255, 255, 0.10);
  --border-2: rgba(255, 255, 255, 0.16);
  --grid:     rgba(255, 255, 255, 0.07);
  --baseline: rgba(255, 255, 255, 0.22);

  /* -- data series (validated categorical slots, dark steps) -- */
  --series-dog:      #d95926;   /* slot 2 — orange */
  --series-dog-soft: rgba(217, 89, 38, 0.18);
  --series-beer:      #3987e5;  /* slot 1 — blue   */
  --series-beer-soft: rgba(57, 135, 229, 0.18);

  /* -- sequential ramp (blue, light -> dark) for magnitude-only charts -- */
  --seq-100: #cde2fb;
  --seq-250: #86b6ef;
  --seq-350: #5598e7;
  --seq-400: #3987e5;
  --seq-500: #256abf;
  --seq-600: #184f95;

  /* -- status (reserved; never used as a series) -- */
  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;

  /* -- geometry -- */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  --font: system-ui, -apple-system, "Segoe UI", sans-serif;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.28);
  --shadow-2: 0 2px 6px rgba(0,0,0,.5), 0 16px 40px rgba(0,0,0,.36);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 700px at 50% -12%, #16202c 0%, transparent 62%),
    var(--plane);
  background-attachment: fixed;
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
p { margin: 0; }

a { color: var(--seq-350); }

::selection { background: rgba(57,135,229,.35); }

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

.ww-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px 72px;
}

/* ---------------------------------------------------------------- masthead */

.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(180deg, rgba(10,13,18,.97) 0%, rgba(10,13,18,.88) 100%);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.masthead-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* On a phone the brand and the actions each take a full row rather than
   wrapping into a ragged third line. */
@media (max-width: 520px) {
  .masthead-inner { gap: 8px; padding-bottom: 10px; }
  .brand { flex: 1 1 100%; }
  .masthead-spacer { display: none; }
  .masthead-actions { flex: 1 1 100%; justify-content: flex-start; }
}

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

/* ------------------------------------------------------------------ crest -- */
/* The logo lives in an <img>. If assets/logo.png is missing the image hides
   itself and the wrapper draws a baseball glyph instead, so a missing file
   degrades to something reasonable rather than a broken-image icon. */

.crest {
  flex: none;
  display: grid;
  place-items: center;
  line-height: 0;
}

.crest img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .55));
}

.crest.logo-missing::after {
  content: "⚾";
  font-size: .62em;
  line-height: 1;
}

.crest-sm { width: 42px; height: 42px; font-size: 42px; }
.crest-md { width: 84px; height: 84px; font-size: 84px; }
.crest-lg { width: 100%; max-width: 200px; aspect-ratio: 1; font-size: 150px; }

.brand-mark {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 19px;
  background:
    repeating-conic-gradient(from 45deg, #f4f2ec 0deg 90deg, #e6e2d8 90deg 180deg);
  box-shadow: inset 0 0 0 2px var(--critical), var(--shadow-1);
}

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

.brand-title {
  font-size: 15px;
  font-weight: 750;
  letter-spacing: .04em;
  line-height: 1.15;
  white-space: nowrap;
}

.brand-sub {
  font-size: 10.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.masthead-spacer { flex: 1 1 auto; }

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

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

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.028), transparent);
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.card-note {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
}

.card-body { padding: 16px; }

/* ------------------------------------------------------------- stat tiles -- */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
}

.tile {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 15px 13px;
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--tile-accent, var(--border-2));
}

.tile-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.tile-value {
  margin-top: 6px;
  font-size: 34px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.tile-value .of {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0;
}

.tile-foot {
  margin-top: 7px;
  font-size: 11.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 17px;
}

/* --------------------------------------------------------------- badges -- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-good     { color: #7ee87e; background: rgba(12,163,12,.16);  border-color: rgba(12,163,12,.42); }
.badge-warning  { color: #ffd479; background: rgba(250,178,25,.15); border-color: rgba(250,178,25,.40); }
.badge-serious  { color: #ffb08c; background: rgba(236,131,90,.15); border-color: rgba(236,131,90,.40); }
.badge-critical { color: #ff8f8f; background: rgba(208,59,59,.16);  border-color: rgba(208,59,59,.44); }
.badge-neutral  { color: var(--text-secondary); background: rgba(255,255,255,.06); border-color: var(--border-2); }

.badge-live {
  color: #ff8f8f;
  background: rgba(208,59,59,.15);
  border-color: rgba(208,59,59,.45);
}
.badge-live .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--critical);
  animation: pulse 1.7s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

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

/* -------------------------------------------------------------- buttons -- */

.btn {
  appearance: none;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text-primary);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: var(--r-md);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background .13s ease, border-color .13s ease, transform .06s ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover  { background: var(--surface-3); border-color: rgba(255,255,255,.26); }
.btn:active { transform: translateY(1px); }

.btn:focus-visible {
  outline: 2px solid var(--seq-350);
  outline-offset: 2px;
}

.btn-ghost { background: transparent; }
.btn-sm    { font-size: 12px; padding: 6px 10px; }

/* Touch devices get a comfortable target even on the "small" buttons —
   44px is the floor a thumb can hit reliably. Narrow viewports are included
   because a phone is a phone whether or not it reports a coarse pointer. */
@media (pointer: coarse), (max-width: 520px) {
  .btn-sm { min-height: 44px; padding: 6px 14px; font-size: 13px; }
}

.btn-primary {
  background: var(--seq-500);
  border-color: var(--seq-400);
}
.btn-primary:hover { background: var(--seq-400); }

.btn-danger {
  background: rgba(208,59,59,.14);
  border-color: rgba(208,59,59,.45);
  color: #ff9d9d;
}
.btn-danger:hover { background: rgba(208,59,59,.24); }

.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:active { transform: none; }

/* --------------------------------------------------------------- inputs -- */

.field { display: block; margin-bottom: 14px; }

.field-label {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.input, .select, .textarea {
  width: 100%;
  font: inherit;
  font-size: 16px;              /* 16px stops iOS Safari zooming on focus */
  color: var(--text-primary);
  background: var(--surface-sunk);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 11px 12px;
}

.textarea { resize: vertical; min-height: 74px; }

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--seq-400);
  box-shadow: 0 0 0 3px rgba(57,135,229,.22);
}

.select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
                    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

/* --------------------------------------------------------------- meters -- */
/* Nine boxes, like the inning columns on a linescore. */

.meter {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
}

.meter-cell {
  height: 26px;
  border-radius: 4px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.meter-cell.filled {
  background: var(--meter-color, var(--seq-400));
  border-color: var(--meter-color, var(--seq-400));
  color: #fff;
}

.meter-cell.partial {
  background: linear-gradient(90deg, var(--meter-color, var(--seq-400)) var(--fill, 50%), var(--surface-sunk) var(--fill, 50%));
  border-color: var(--meter-color, var(--seq-400));
  color: var(--text-secondary);
}

/* ----------------------------------------------------------------- misc -- */

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 28px 0 13px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.muted { color: var(--text-muted); }
.mono  { font-variant-numeric: tabular-nums; }

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

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 130%);
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  color: var(--text-primary);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-2);
  z-index: 100;
  transition: transform .26s cubic-bezier(.2,.9,.3,1);
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.show { transform: translate(-50%, 0); }
.toast.err  { border-color: rgba(208,59,59,.5); background: #3a1b1b; }

/* ============================================== milestone celebration ==== */

.celebrate {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgba(6, 9, 14, .9);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
  padding: 24px;
}

.celebrate.show { opacity: 1; pointer-events: auto; }

.celebrate-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.celebrate-inner {
  position: relative;
  text-align: center;
  max-width: 460px;
  animation: pop .45s cubic-bezier(.2, 1.2, .4, 1);
}

@keyframes pop {
  from { transform: scale(.82); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

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

/* The crest is a JPG on white, so it gets framed like a real plaque instead
   of floating as a bright rectangle on a dark screen. */
.celebrate-plaque {
  width: min(260px, 62vw);
  margin: 0 auto 20px;
  padding: 16px;
  border-radius: var(--r-xl);
  background: #f4f3ec;
  box-shadow:
    0 0 0 3px rgba(169, 184, 76, .55),
    0 18px 50px rgba(0, 0, 0, .6);
}

.celebrate-plaque.no-logo::after {
  content: "🏆";
  font-size: 92px;
  line-height: 1;
  display: block;
}

.celebrate-logo {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
}

.celebrate-title {
  font-size: clamp(24px, 6.5vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.08;
  color: #fff;
  text-shadow: 0 2px 20px rgba(0, 0, 0, .7);
}

.celebrate-sub {
  margin-top: 10px;
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.celebrate-close {
  margin-top: 22px;
  min-height: 46px;
  padding: 10px 26px;
}

/* ------------------------------------------------------------- tooltips -- */

.viz-tip {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-primary);
  box-shadow: var(--shadow-2);
  opacity: 0;
  transition: opacity .1s ease;
  white-space: nowrap;
}

.viz-tip.show { opacity: 1; }

.viz-tip .tip-title {
  font-weight: 700;
  margin-bottom: 3px;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.viz-tip .tip-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-variant-numeric: tabular-nums;
}

.viz-tip .swatch {
  width: 9px; height: 9px; border-radius: 2px; flex: none;
}

/* --------------------------------------------------------------- legend -- */

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.legend-swatch {
  width: 10px; height: 10px; border-radius: 2px; flex: none;
}

.legend-swatch.line {
  height: 3px; width: 15px; border-radius: 2px;
}

.legend-swatch.dashed {
  height: 0; width: 15px; border-radius: 0;
  border-top: 2px dashed var(--text-muted);
}
