/* ═══════════════════════════════════════════════════════════════════════════
   Holbæk Padel Klub Liga — style.css

   ⚠ Farverne står tre steder, fordi temaerne er adskilt: lyst tema først,
   derefter to mørke blokke — @media (prefers-color-scheme: dark) for systemets
   indstilling og :root[data-theme="dark"] for knappen på selve siden. Begge
   mørke blokke skal have samme værdi, ellers skifter farven, når man trykker
   på tema-knappen.

   En farve skal kunne læses på begge baggrunde. Lyst tema har næsten hvid
   baggrund, så meget lyse farver forsvinder i prikken på 10px og i
   statusbjælken på 8px. Sigt efter mindst 4,5:1 kontrast i lyst tema.
   ═══════════════════════════════════════════════════════════════════════════ */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-plane, #f9f9f7);
}

.viz-root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page-plane:     #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);
  --accent-herrer:  #2a78d6;
  --accent-damer:   #c9407a;
  --series-played:  #c2691f;
  --series-planned: #2f7d6b;
  --status-good:    #1e8a5f;
  --status-warn:    #a8710d;
  --status-critical:#c23b3b;
  --track-alpha:    0.13;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page-plane:     #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);
    --accent-herrer:  #3987e5;
    --accent-damer:   #ffc0cb;
    --series-played:  #e2954f;
    --series-planned: #5fb3a0;
    --status-good:    #34c98a;
    --status-warn:    #e0a83c;
    --status-critical:#ef6461;
    --track-alpha:    0.20;
  }
}

:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page-plane:     #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255,255,255,0.10);
  --accent-herrer:  #3987e5;
  --accent-damer:   #ffc0cb;
  --series-played:  #e2954f;
  --series-planned: #5fb3a0;
  --status-good:    #34c98a;
  --status-warn:    #e0a83c;
  --status-critical:#ef6461;
  --track-alpha:    0.20;
}

.viz-root {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
  padding: 28px 16px calc(40px + env(safe-area-inset-bottom));
  padding-top: calc(28px + env(safe-area-inset-top));
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 880px; margin: 0 auto; }

/* ─── Hoved ─────────────────────────────────────────────────────────────── */
header.page-head { margin-bottom: 24px; }

.head-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 4px;
}

header.page-head h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
  flex: 1;
}

.head-knapper {
  display: flex;
  gap: 6px;
  flex: none;
}

.ikon-knap {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.ikon-knap:hover { color: var(--text-primary); }
.ikon-knap:active { transform: scale(0.94); }
.ikon-knap.henter { animation: spin 0.9s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .ikon-knap.henter { animation: none; opacity: 0.5; }
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  color: var(--text-muted);
  font-size: 13px;
}
.meta-row .dot-sep::before { content: "·"; margin-right: 12px; color: var(--gridline); }

/* ─── Fejlbanner ────────────────────────────────────────────────────────── */
.fejl-banner {
  display: none;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 15px;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid;
}
.fejl-banner.show { display: flex; }
.fejl-banner .icon { flex: none; font-size: 14px; line-height: 1.45; }
.fejl-banner.warn {
  color: var(--status-warn);
  background: color-mix(in srgb, var(--status-warn) 12%, var(--surface-1));
  border-color: color-mix(in srgb, var(--status-warn) 38%, transparent);
}
.fejl-banner.critical {
  color: var(--status-critical);
  background: color-mix(in srgb, var(--status-critical) 12%, var(--surface-1));
  border-color: color-mix(in srgb, var(--status-critical) 38%, transparent);
}
.fejl-banner .banner-head { font-weight: 600; margin-bottom: 2px; }
.fejl-banner .banner-body { color: var(--text-secondary); }

/* ─── Nøgletal ──────────────────────────────────────────────────────────── */
.hero-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.hero-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}
.hero-tile .label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.hero-tile .value {
  font-size: 34px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.hero-tile .value .af {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 500;
}
.hero-tile .sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ─── Kort ──────────────────────────────────────────────────────────────── */
.league-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px 18px;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 16px;
}
.swatch {
  width: 10px; height: 10px; border-radius: 50%;
  flex: none;
}
.card-head h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.card-head .round-tag {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: right;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px 16px;
  margin-bottom: 18px;
}
.stat-tile .label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 3px;
}
.stat-tile .value {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.meter-block { margin-top: 4px; }
.meter-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.meter-label-row .pct { color: var(--text-primary); font-weight: 600; }
.meter-track {
  height: 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--meter-color) 13%, var(--surface-1));
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  border-radius: 4px 0 0 4px;
  background: var(--meter-color);
  transition: width 0.5s ease;
}
@media (prefers-reduced-motion: reduce) {
  .meter-fill { transition: none; }
}

/* ─── Foldbare tabeller ─────────────────────────────────────────────────── */
details.pool-detail {
  margin-top: 16px;
  border-top: 1px solid var(--gridline);
  padding-top: 10px;
}
details.pool-detail summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-secondary);
  user-select: none;
}
details.pool-detail summary:hover { color: var(--text-primary); }

.tabel-scroll { overflow-x: auto; }

table.pool-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12.5px;
}
table.pool-table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0 8px 6px 0;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}
table.pool-table td {
  padding: 6px 8px 6px 0;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  white-space: nowrap;
}
table.pool-table td:first-child,
table.pool-table th:first-child { color: var(--text-secondary); font-variant-numeric: normal; }
table.pool-table tr:last-child td { border-bottom: none; }

/* ─── Udvikling & tempo ─────────────────────────────────────────────────── */
.trend-card { margin-bottom: 16px; }
.trend-note {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--status-warn);
  background: color-mix(in srgb, var(--status-warn) 10%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--status-warn) 30%, transparent);
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 14px;
}
.trend-badge-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.trend-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}
.trend-badge.good { color: var(--status-good); background: color-mix(in srgb, var(--status-good) 15%, var(--surface-1)); }
.trend-badge.bad  { color: var(--status-critical); background: color-mix(in srgb, var(--status-critical) 15%, var(--surface-1)); }
.trend-badge.neutral { color: var(--text-secondary); background: color-mix(in srgb, var(--baseline) 25%, var(--surface-1)); }
.trend-badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.trend-detail {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.trend-detail strong { color: var(--text-primary); font-weight: 600; }

.chart-wrap { position: relative; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .grid-line { stroke: var(--gridline); stroke-width: 1; }
.chart-svg .axis-label { fill: var(--text-muted); font-size: 9.5px; font-family: inherit; }
.chart-svg .series-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart-svg .series-dot { stroke: var(--surface-1); stroke-width: 1.5; }
.chart-svg .target-line { fill: none; stroke: var(--text-muted); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart-svg .deadline-line { stroke: var(--baseline); stroke-width: 1; stroke-dasharray: 2 3; }
.chart-svg .crosshair { stroke: var(--text-muted); stroke-width: 1; pointer-events: none; opacity: 0; }
.chart-hit { fill: transparent; cursor: crosshair; }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-primary);
  box-shadow: 0 4px 14px rgba(0,0,0,0.12);
  opacity: 0;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  z-index: 5;
}
.chart-tooltip .t-date { color: var(--text-muted); font-size: 10.5px; margin-bottom: 3px; }
.chart-tooltip .t-row { display: flex; align-items: center; gap: 5px; }
.chart-tooltip .t-swatch { width: 7px; height: 7px; border-radius: 50%; flex: none; }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-secondary);
}
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chart-legend i.line { border-radius: 2px; height: 2px; width: 14px; }
.chart-legend i.target { border-radius: 0; height: 0; width: 14px; border-top: 1.5px dashed var(--text-muted); }

/* ─── Bund ──────────────────────────────────────────────────────────────── */
footer.page-foot {
  margin-top: 28px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}
footer.page-foot a { color: var(--text-secondary); }

/* ─── Telefon ───────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .viz-root { padding-left: 13px; padding-right: 13px; }
  header.page-head h1 { font-size: 19px; }
  .card { padding: 17px 16px 15px; }
  .hero-tile { padding: 15px 16px; }
  .hero-tile .value { font-size: 30px; }
  .league-grid { grid-template-columns: 1fr; }
}
