/* Hand-written stylesheet for the PlayGuard SPA. Self-hosted only: no
 * external fonts, no CDN imports (CSP style-src 'self'). Sized for phones
 * (~380px) first; a single media query switches the card list to a grid on
 * desktop. */

* {
  box-sizing: border-box;
}

:root {
  --hud-bg: #0a0f0e;
  --hud-panel: #0f1715;
  --hud-panel-2: #121c19;
  --hud-line: #1e2c28;
  --hud-ink: #e9f5ee;
  --hud-dim: #8fa89b;
  --hud-faint: #5c7268;
  --hud-accent: #3dff9e;
  --hud-accent-soft: rgba(61, 255, 158, 0.14);
  --hud-accent-glow: rgba(61, 255, 158, 0.3);
  --hud-warn: #ffc24b;
  --hud-warn-soft: rgba(255, 194, 75, 0.14);
  --hud-warn-glow: rgba(255, 194, 75, 0.3);
  --hud-hot: #ff4d61;
  --hud-hot-soft: rgba(255, 77, 97, 0.14);
  --hud-hot-glow: rgba(255, 77, 97, 0.32);
  --hud-cool: #4bd8ff;
  --hud-cool-soft: rgba(75, 216, 255, 0.13);
  --hud-cool-glow: rgba(75, 216, 255, 0.3);
  --hud-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --hud-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* The page itself is dark (body.hud-theme); the stage only spaces the
 * cards. */
.hud-stage {
  padding: 16px 0 40px;
  color: var(--hud-ink);
}

.hud-message {
  margin: 0;
  color: var(--hud-dim);
  text-align: center;
}

.hud-device-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.hud-card {
  position: relative;
  width: 100%;
  max-width: 430px;
  margin: 0;
  overflow: hidden;
  padding: 18px 18px 20px;
  border: 1px solid var(--hud-line);
  border-radius: 6px;
  background-color: var(--hud-panel);
  box-shadow: none;
}

.hud-card::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 0;
  border-radius: inherit;
  background: repeating-linear-gradient(0deg, rgba(233, 245, 238, 0.018) 0 1px, transparent 1px 3px);
  pointer-events: none;
}

.hud-swarm {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.hud-card > :not(.hud-swarm) {
  position: relative;
  z-index: 1;
}

.hud-top {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--hud-faint);
  font-family: var(--hud-mono);
  font-size: 11px;
  letter-spacing: 2px;
}

.hud-mark {
  color: var(--hud-dim);
  font-weight: 700;
}

.hud-player {
  overflow: hidden;
  padding: 3px 7px;
  border: 1px solid var(--hud-line);
  border-radius: 3px;
  color: var(--hud-dim);
  letter-spacing: 1.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-live {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  color: var(--hud-dim);
  letter-spacing: 1.5px;
}

.hud-live-dot {
  position: relative;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--hud-accent);
}

.hud-live-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px solid var(--hud-accent);
  border-radius: 50%;
  opacity: 0;
  animation: hud-ping 2.4s ease-out infinite;
}

@keyframes hud-ping {
  0% { transform: scale(0.5); opacity: 0.9; }
  70% { transform: scale(1.4); opacity: 0; }
  100% { opacity: 0; }
}

.hud-banner {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

.hud-banner-chip {
  padding: 7px 16px 7px 20px;
  border: 1px solid;
  border-radius: 4px;
  font-family: var(--hud-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 4px;
}

.hud-banner.hud-tone-ok .hud-banner-chip {
  border-color: var(--hud-accent);
  background: var(--hud-accent-soft);
  box-shadow: 0 0 22px var(--hud-accent-glow);
  color: var(--hud-accent);
}

.hud-banner.hud-tone-warn .hud-banner-chip {
  border-color: var(--hud-warn);
  background: var(--hud-warn-soft);
  box-shadow: 0 0 22px var(--hud-warn-glow);
  color: var(--hud-warn);
}

.hud-banner.hud-tone-hot .hud-banner-chip {
  border-color: var(--hud-hot);
  background: var(--hud-hot-soft);
  box-shadow: 0 0 22px var(--hud-hot-glow);
  color: var(--hud-hot);
}

.hud-banner.hud-tone-cool .hud-banner-chip {
  border-color: var(--hud-cool);
  background: var(--hud-cool-soft);
  box-shadow: 0 0 22px var(--hud-cool-glow);
  color: var(--hud-cool);
}

.hud-hero {
  margin-top: 20px;
  text-align: center;
}

.hud-hero-label {
  color: var(--hud-dim);
  font-family: var(--hud-mono);
  font-size: 11px;
  letter-spacing: 3px;
}

.hud-hero-clock {
  margin-top: 6px;
  color: var(--hud-ink);
  font-family: var(--hud-mono);
  font-size: clamp(56px, 19vw, 84px);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1.05;
  text-shadow: 0 0 26px var(--hud-accent-glow);
}

.hud-hero-warn .hud-hero-clock {
  color: var(--hud-warn);
  text-shadow: 0 0 26px var(--hud-warn-glow);
}

.hud-hero-hot .hud-hero-clock {
  color: var(--hud-hot);
  text-shadow: 0 0 30px var(--hud-hot-glow);
  animation: hud-pulse 1s ease-in-out infinite;
}

.hud-hero-cool .hud-hero-clock {
  color: var(--hud-cool);
  text-shadow: 0 0 26px var(--hud-cool-glow);
}

.hud-hero-dead .hud-hero-clock {
  color: var(--hud-hot);
  opacity: 0.75;
  text-shadow: none;
}

@keyframes hud-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

.hud-hero-sub {
  min-height: 18px;
  margin-top: 10px;
  color: var(--hud-dim);
  font-family: var(--hud-mono);
  font-size: 12px;
  letter-spacing: 2px;
}

.hud-meters {
  display: grid;
  gap: 16px;
  margin-top: 26px;
}

.hud-meter-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--hud-dim);
  font-family: var(--hud-mono);
  font-size: 11px;
  letter-spacing: 1.5px;
}

.hud-meter-value {
  color: var(--hud-ink);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.hud-bar {
  position: relative;
  height: 18px;
  overflow: hidden;
  border: 1px solid var(--hud-line);
  border-radius: 3px;
  background: var(--hud-panel-2);
}

.hud-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--hud-accent);
  box-shadow: 0 0 14px var(--hud-accent-glow);
  transition: width 0.4s ease;
}

.hud-bar.hud-tone-warn .hud-bar-fill {
  background: var(--hud-warn);
  box-shadow: 0 0 14px var(--hud-warn-glow);
}

.hud-bar.hud-tone-hot .hud-bar-fill {
  background: var(--hud-hot);
  box-shadow: 0 0 14px var(--hud-hot-glow);
}

.hud-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 14px, var(--hud-bg) 14px 16px);
  pointer-events: none;
}

.hud-meter-secondary .hud-meter-row {
  color: var(--hud-faint);
}

.hud-meter-secondary .hud-meter-value {
  color: var(--hud-dim);
}

.hud-meter-secondary .hud-bar {
  height: 12px;
}

.hud-meter-secondary .hud-bar-fill {
  opacity: 0.32;
  box-shadow: none;
}

.hud-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.hud-stat {
  padding: 6px 10px;
  border: 1px solid var(--hud-line);
  border-radius: 3px;
  background: var(--hud-panel-2);
  color: var(--hud-dim);
  font-family: var(--hud-mono);
  font-size: 11px;
  letter-spacing: 1.5px;
}

.hud-stat b {
  color: var(--hud-ink);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.hud-strip {
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--hud-line);
}

.hud-strip-cap {
  margin-bottom: 10px;
  color: var(--hud-faint);
  font-family: var(--hud-mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-align: center;
}

.hud-strip-cols {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 8px;
  height: 46px;
}

.hud-strip-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
}

.hud-strip-value {
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  background: #2a4a3c;
}

.hud-strip-col.hud-today .hud-strip-value {
  background: var(--hud-accent);
  box-shadow: 0 0 10px var(--hud-accent-glow);
}

.hud-strip-col.hud-future .hud-strip-value {
  opacity: 0.35;
}

.hud-strip-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin-top: 6px;
  color: var(--hud-faint);
  font-family: var(--hud-mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-align: center;
}

.hud-strip-days .hud-today {
  color: var(--hud-accent);
  font-weight: 700;
}

.hud-strip-error {
  margin: 8px 0 0;
  color: var(--hud-warn);
  font-family: var(--hud-mono);
  font-size: 10px;
  text-align: center;
}

.hud-hint {
  margin: 18px 0 0;
  color: var(--hud-dim);
  font-family: var(--hud-sans);
  font-size: 13px;
  text-align: center;
}

@media (min-width: 720px) {
  .hud-card {
    max-width: 640px;
    padding: 28px 36px 30px;
  }

  .hud-hero-clock {
    font-size: 96px;
  }

  .hud-bar {
    height: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hud-hero-hot .hud-hero-clock,
  .hud-live-dot::after {
    animation: none;
  }

  .hud-bar-fill {
    transition: none;
  }
}

body {
  font: 16px/1.5 -apple-system, system-ui, "Segoe UI", sans-serif;
  margin: 0 auto;
  max-width: 1100px;
  padding: 12px;
  background: #f4f4f6;
  color: #1a1a24;
}

/* -- login ------------------------------------------------------------- */

main.center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}

form.login {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 380px;
}

/* -- app shell ----------------------------------------------------------- */

main.app {
  display: block;
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

header.top h1 {
  font-size: 1.3rem;
  margin: 0;
}

.top-actions {
  display: flex;
  gap: 8px;
}

nav.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 2px solid #ddd;
}

nav.tabs button {
  flex: 1;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  color: #556;
  padding: 10px 8px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -2px;
}

nav.tabs button.active {
  color: #2c6e49;
  border-bottom-color: #2c6e49;
}

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

.card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin: 0 0 12px;
  width: 100%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.card h1 {
  font-size: 1.4rem;
  margin: 0 0 16px;
}

.card h2 {
  font-size: 1.1rem;
  margin: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

section.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

section.grid .card {
  margin: 0;
}

/* Desktop: cards side by side, wider gutters. */
@media (min-width: 900px) {
  body {
    padding: 24px;
  }

  section.grid {
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  }
}

/* -- controls ------------------------------------------------------------------ */

input,
button,
select {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid #ccd;
  border-radius: 6px;
  background: #fff;
}

button {
  background: #2c6e49;
  color: #fff;
  border: 0;
  cursor: pointer;
}

button:disabled {
  background: #9bb8a8;
  cursor: default;
}

button.ghost {
  background: none;
  color: #2c6e49;
  border: 1px solid #ccd;
  padding: 6px 10px;
}

button.ghost:disabled {
  background: none;
  color: #99a;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 12px;
}

label.picker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #556;
  font-size: 0.9rem;
}

/* Wide enough to keep the week label readable; wraps onto its own row on
 * phones instead of getting crushed next to the device picker. */
.week-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 240px;
  min-width: 0;
}

.week-picker select {
  flex: 1;
  min-width: 0;
}

button.arrow {
  padding: 6px 12px;
  font-weight: 700;
}

/* -- text states ------------------------------------------------------------------ */

.error {
  color: #c0392b;
  margin: 0 0 8px;
}

.muted {
  color: #667;
}

.small {
  font-size: 0.85rem;
  margin: 8px 0 0;
}

.big {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 4px 0;
}

.big.yes {
  color: #2c6e49;
}

.big.no {
  color: #778;
}

.status-body p {
  margin: 4px 0;
}

/* -- badges, alerts, overrides ---------------------------------------------------- */

.badge {
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge.playing {
  background: #dcf3e4;
  color: #1d5c3a;
}

.badge.idle {
  background: #e8e8ee;
  color: #555;
}

.badge.offline {
  background: #fdecea;
  color: #b03a2e;
}

/* Build skew (spec WP3): amber like the override notices -- worth a look,
   not an emergency. */
.badge.skew {
  background: #fef5e7;
  color: #7e4a10;
}

.alert {
  background: #fdecea;
  border-left: 4px solid #c0392b;
  color: #7c261d;
  border-radius: 6px;
  padding: 10px 12px;
  margin: 8px 0;
}

.override {
  background: #fef5e7;
  border-left: 4px solid #e67e22;
  color: #7e4a10;
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px 0;
  font-weight: 600;
}

/* -- progress bars -------------------------------------------------------------------- */

.meter {
  margin: 10px 0;
}

.meter-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.progress {
  background: #e8e8ee;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.progress-fill {
  background: #2c6e49;
  height: 100%;
  border-radius: 999px;
}

.progress-fill.full {
  background: #c0392b;
}

/* -- week chart ---------------------------------------------------------------------------- */

svg.chart {
  display: block;
  width: 100%;
  max-width: 640px;
  height: auto;
  margin: 4px auto;
}

svg.chart .axis {
  stroke: #ccd;
  stroke-width: 1;
}

svg.chart .bar {
  fill: #2c6e49;
}

svg.chart g.today .bar {
  fill: #e67e22;
}

svg.chart text {
  font-family: inherit;
  font-size: 12px;
  fill: #556;
}

svg.chart .value {
  font-size: 11px;
}

svg.chart g.today .day {
  font-weight: 700;
  fill: #1a1a24;
}

svg.chart g.future .day {
  fill: #aab;
}

.week-total {
  margin: 4px 0 0;
  font-weight: 600;
}

/* -- admin controls ------------------------------------------------------------------------ */

section.stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

section.stack .card {
  margin: 0;
}

.note {
  background: #eaf1fb;
  border-left: 4px solid #3a6ea5;
  color: #1f3a5c;
  border-radius: 6px;
  padding: 8px 12px;
  margin: 8px 0 12px;
  font-size: 0.9rem;
}

form.control-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 8px 0 4px;
}

form.control-form label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #556;
  font-size: 0.9rem;
}

form.control-form input[type="number"] {
  width: 110px;
}

.success {
  color: #1d5c3a;
  margin: 4px 0;
}

textarea.config {
  width: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  border: 1px solid #ccd;
  border-radius: 6px;
  padding: 10px 12px;
  resize: vertical;
  margin: 8px 0;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dirty {
  color: #7e4a10;
  font-size: 0.85rem;
  font-weight: 600;
}

.badge.pending {
  background: #fef5e7;
  color: #7e4a10;
}

.badge.applied {
  background: #dcf3e4;
  color: #1d5c3a;
}

.badge.rejected {
  background: #fdecea;
  color: #b03a2e;
}

table.history-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}

table.history-table th,
table.history-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid #e4e4ea;
  white-space: nowrap;
}

table.history-table th {
  color: #667;
  font-weight: 600;
}

table.history-table td.detail {
  white-space: normal;
  min-width: 140px;
  color: #556;
}

/* -- statistics --------------------------------------------------------------------------------- */

dl.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin: 12px 0;
}

dl.stats div {
  background: #f4f4f6;
  border-radius: 6px;
  padding: 8px 10px;
}

dl.stats dt {
  font-size: 0.8rem;
  color: #667;
}

dl.stats dd {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

dl.stats div.bad {
  background: #fdecea;
}

dl.stats div.bad dd {
  color: #b03a2e;
}

.table-wrap {
  overflow-x: auto;
}

table.stats-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
  white-space: nowrap;
}

table.stats-table th,
table.stats-table td {
  text-align: right;
  padding: 6px 8px;
  border-bottom: 1px solid #e4e4ea;
}

table.stats-table th:first-child,
table.stats-table td:first-child {
  text-align: left;
}

table.stats-table th {
  color: #667;
  font-weight: 600;
}

tr.bad td {
  background: #fdecea;
  color: #7c261d;
}

/* -- footer (admin shell only, spec WP3) ------------------------------------------ */

footer.foot {
  margin-top: 24px;
  padding: 8px 0;
  text-align: center;
  color: #99a;
  font-size: 0.8rem;
}

/* -- kid dark theme ---------------------------------------------------------------
 * Applied to <body> while a kid session is active (app.rs toggles the
 * class), so the WHOLE page - shell, tabs, History - shares the HUD look.
 * Login and admin keep the plain light style. */

body.hud-theme {
  background: var(--hud-bg);
  color: var(--hud-ink);
  -webkit-font-smoothing: antialiased;
}

body.hud-theme header.top h1 {
  color: var(--hud-ink);
}

/* Login as a HUD panel: the ambient cloud lives behind the form fields,
 * clipped by the card like on the status view. */
body.hud-theme form.login {
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  padding: 26px 22px;
}

body.hud-theme form.login > :not(.hud-swarm) {
  position: relative;
  z-index: 1;
}

body.hud-theme form.login h1 {
  margin: 0 0 10px;
  color: var(--hud-ink);
  font-family: var(--hud-mono);
  font-size: 1.05rem;
  letter-spacing: 4px;
  text-align: center;
  text-transform: uppercase;
}

body.hud-theme nav.tabs {
  border-bottom-color: var(--hud-line);
}

body.hud-theme nav.tabs button {
  background: none;
  color: var(--hud-dim);
}

body.hud-theme nav.tabs button.active {
  border-bottom-color: var(--hud-accent);
  color: var(--hud-accent);
}

body.hud-theme .card {
  border: 1px solid var(--hud-line);
  background: var(--hud-panel);
  box-shadow: none;
}

body.hud-theme .muted {
  color: var(--hud-dim);
}

body.hud-theme .error {
  color: var(--hud-hot);
}

body.hud-theme input,
body.hud-theme select {
  border: 1px solid var(--hud-line);
  background: var(--hud-panel-2);
  color: var(--hud-ink);
}

body.hud-theme button {
  background: var(--hud-accent);
  color: var(--hud-bg);
}

body.hud-theme button:disabled {
  background: #23392f;
  color: var(--hud-faint);
}

body.hud-theme button.ghost {
  border: 1px solid var(--hud-line);
  background: none;
  color: var(--hud-accent);
}

body.hud-theme button.ghost:disabled {
  color: var(--hud-faint);
}

body.hud-theme label.picker {
  color: var(--hud-dim);
}

body.hud-theme .week-total {
  color: var(--hud-ink);
}

/* History week chart in HUD colors: quiet green bars, accent on today --
 * the same visual language as the status strip. */
body.hud-theme svg.chart .axis {
  stroke: var(--hud-line);
}

body.hud-theme svg.chart .bar {
  fill: #2a4a3c;
}

body.hud-theme svg.chart g.today .bar {
  fill: var(--hud-accent);
}

body.hud-theme svg.chart text {
  fill: var(--hud-dim);
}

body.hud-theme svg.chart g.today .day {
  fill: var(--hud-ink);
}

body.hud-theme svg.chart g.future .day {
  fill: var(--hud-faint);
}
