/* Valheim status page.
 *
 * Dark by default: this is looked at in the evening, next to a game that is
 * itself dark. One accent colour, warm, so the "everything is fine" state is
 * calm and only real problems are loud.
 */

:root {
  --bg: #14171c;
  --bg-card: #1b1f26;
  --bg-sunken: #12151a;
  --border: #2a3038;
  --text: #e3e6ea;
  --text-muted: #8b95a3;
  --accent: #c8a06a;
  --ok: #6faa63;
  --warn: #d4a03c;
  --error: #cf6156;
  --radius: 8px;
}

* { box-sizing: border-box; }

/* The hidden attribute only sets display:none through the browser's own
 * stylesheet, which any author rule outranks. Both .login and .update-box set
 * display:flex, so without this they stay visible while marked hidden -- the
 * login box would sit on top of the dashboard after signing in. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 1.15rem; margin: 0; font-weight: 600; }
h2 { font-size: 0.8rem; margin: 0 0 0.9rem; font-weight: 600;
     text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
h3 { font-size: 0.75rem; margin: 1.4rem 0 0.6rem; font-weight: 600;
     text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }

.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.error { color: var(--error); }

.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;
}

/* -- login ---------------------------------------------------------- */

.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-box {
  width: 100%;
  max-width: 22rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}

.login-box h1 { margin-bottom: 0.4rem; }
.login-box p { margin: 0 0 1.4rem; font-size: 0.9rem; }

input[type="password"] {
  width: 100%;
  padding: 0.7rem 0.8rem;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 1rem;
}

input[type="password"]:focus,
input[type="text"]:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.login-box button {
  width: 100%;
  margin-top: 0.8rem;
  padding: 0.7rem;
  background: var(--accent);
  color: #1a1408;
  border: 0;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}

.login-box button:hover { filter: brightness(1.08); }
.login-box button:disabled { opacity: 0.6; cursor: default; }
.login-box .error { margin: 1rem 0 0; font-size: 0.9rem; }

/* -- chrome --------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-wrap: wrap;
}

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 0.7rem; }

.dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-muted); flex: none;
}
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(111, 170, 99, 0.16); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(212, 160, 60, 0.16); }
.dot.error { background: var(--error); box-shadow: 0 0 0 3px rgba(207, 97, 86, 0.16); }

.badge {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; padding: 0.2rem 0.5rem;
  border: 1px solid var(--accent); color: var(--accent); border-radius: 4px;
}

.link {
  background: none; border: 0; color: var(--text-muted);
  cursor: pointer; font-size: 0.85rem; padding: 0.2rem;
}
.link:hover { color: var(--text); }

/* -- warnings ------------------------------------------------------- */

.warnings:not(:empty) { padding: 1rem 1.25rem 0; display: grid; gap: 0.6rem; }

.warning {
  padding: 0.7rem 0.9rem;
  border-radius: 6px;
  border-left: 3px solid var(--warn);
  background: rgba(212, 160, 60, 0.09);
  font-size: 0.9rem;
}
.warning.error { border-left-color: var(--error);
                 background: rgba(207, 97, 86, 0.09); color: var(--text); }

/* -- update banner -------------------------------------------------- */

.update-box {
  margin: 1rem 1.25rem 0;
  padding: 0.9rem 1.1rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  background: rgba(200, 160, 106, 0.1);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}
.update-text { display: flex; flex-direction: column; gap: 0.15rem; }

.action.primary {
  background: var(--accent); color: #1a1408; border-color: var(--accent);
  font-weight: 600;
}
.action.primary:hover:not(:disabled) { filter: brightness(1.08); color: #1a1408; }

#update-result { margin: 0.8rem 1.25rem 0; }

/* -- layout --------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  gap: 1rem;
  padding: 1.25rem;
  align-items: start;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem 1.3rem;
}

.wide { grid-column: 1 / -1; }

@media (min-width: 60rem) {
  #card-players, #card-stats { grid-column: span 2; }
}

.headline { font-size: 2.2rem; font-weight: 300; line-height: 1.1; }
.headline-unit { font-size: 1rem; color: var(--text-muted); margin-left: 0.3rem; }

/* -- facts ---------------------------------------------------------- */

.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 0.45rem 1rem; }
.facts dt { color: var(--text-muted); font-size: 0.85rem; }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.facts-inline { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 0.4rem; }
.facts-inline div { display: flex; flex-direction: column; }
.facts-inline .value { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.facts-inline .label { font-size: 0.78rem; color: var(--text-muted); }

/* -- rows ----------------------------------------------------------- */

.rows { display: grid; gap: 1px; background: var(--border); border-radius: 6px; overflow: hidden; }
.rows:empty { display: none; }

.row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 0.8rem; padding: 0.55rem 0.75rem; background: var(--bg-card);
}
.row .name { font-weight: 500; }
.row .sub { color: var(--text-muted); font-size: 0.82rem; }
.row .value { color: var(--text-muted); font-size: 0.88rem;
              font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .rank { color: var(--text-muted); font-size: 0.85rem; width: 1.4rem; flex: none; }

.players { display: grid; gap: 0.5rem; margin: 0.8rem 0 0; }
.players:empty::after {
  content: "Gerade ist niemand online.";
  color: var(--text-muted); font-size: 0.9rem;
}

.player {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.6rem 0.75rem; background: var(--bg-sunken);
  border-radius: 6px; border-left: 2px solid var(--ok);
}
.player.loading { border-left-color: var(--warn); }
.player .who { flex: 1; min-width: 0; }
.player .character { color: var(--text-muted); font-size: 0.85rem; }

/* -- activity chart ------------------------------------------------- */

/* Categorical slots from the validated dark palette. Assigned by a player's
 * first appearance, never by rank: a colour has to follow the person, or
 * everyone's colour shifts whenever the leaderboard reorders. */
.chart {
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #6c757d;
  position: relative;
}

.legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; margin-bottom: 0.8rem; }
.legend-item { display: flex; align-items: center; gap: 0.4rem;
               font-size: 0.82rem; color: var(--text-secondary, var(--text-muted)); }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }

.chart-body { display: flex; gap: 0.6rem; }

/* Y axis: just the ceiling and the midpoint. More lines would out-shout the
 * data they are supposed to support. */
.chart-scale {
  display: flex; flex-direction: column; justify-content: space-between;
  height: 7rem; font-size: 0.72rem; color: var(--text-muted);
  text-align: right; flex: none; min-width: 2.2rem;
}

.chart-plot {
  flex: 1; display: flex; gap: 2px; align-items: stretch; min-width: 0;
  /* Centred so a short history sits under the axis instead of being stretched
     across the whole card. */
  justify-content: center;
}

/* flex:1 with a ceiling: thirty columns stay thin, seven columns stop at a
   sensible bar width instead of turning into slabs. */
.chart-col {
  flex: 1 1 0; min-width: 0; max-width: 3.25rem;
  display: flex; flex-direction: column; cursor: default;
}
.chart-col.weekend .chart-stack { background: rgba(255, 255, 255, 0.035); }
.chart-col:hover .chart-stack { background: rgba(255, 255, 255, 0.07); }

/* Bars grow from the baseline; the column holds its height so empty days keep
 * their slot in the calendar instead of collapsing. */
.chart-stack {
  height: 7rem; display: flex; flex-direction: column-reverse;
  justify-content: flex-start; border-radius: 2px; overflow: hidden;
}

.chart-seg { width: 100%; min-height: 2px; }
/* 2px of surface between stacked segments, so two adjacent hues never touch. */
.chart-seg + .chart-seg { margin-bottom: 2px; }
.chart-seg:last-child { border-radius: 2px 2px 0 0; }

.chart-day {
  font-size: 0.65rem; color: var(--text-muted); text-align: center;
  padding-top: 0.3rem; white-space: nowrap; overflow: hidden;
}

/* -- heatmap -------------------------------------------------------- */

/* One hue, dark to light. On a dark surface "nothing happened" has to recede
 * towards the background, so the ramp runs the opposite way from a light
 * theme's. Never a rainbow: this encodes magnitude, not identity. */
.heatmap {
  --heat-0: #171c24;
  --heat-1: #104281;
  --heat-2: #1c5cab;
  --heat-3: #2a78d6;
  --heat-4: #5598e7;
  --heat-5: #86b6ef;

  display: grid;
  /* minmax(0, 1fr) rather than 1fr: a grid track's implicit minimum is its
     content size, which stops the cells shrinking on a narrow screen and
     pushes the grid past its container. */
  grid-template-columns: 2rem repeat(24, minmax(0, 1fr));
  gap: 2px;
  align-items: center;
  /* Below this the cells become unreadable specks; the wrapper scrolls
     instead, which is honest about there being more to see. */
  min-width: 21rem;
}

.heat-scroll { overflow-x: auto; padding-bottom: 0.2rem; }

.heat-hour, .heat-day {
  font-size: 0.65rem; color: var(--text-muted); text-align: center;
  white-space: nowrap;
}
.heat-day { text-align: right; padding-right: 0.35rem; }

.heat-cell {
  aspect-ratio: 1; border-radius: 2px; background: var(--heat-0);
  min-height: 9px; cursor: default;
}
.heat-cell:hover { outline: 1px solid var(--text-muted); outline-offset: -1px; }

.heat-legend {
  display: flex; align-items: center; gap: 0.35rem;
  margin-top: 0.7rem; font-size: 0.72rem; color: var(--text-muted);
}
.heat-legend .swatch { width: 12px; height: 12px; border-radius: 2px; }

.chart-note {
  padding: 1.2rem 0.5rem; color: var(--text-muted); font-size: 0.88rem;
  text-align: center; border: 1px dashed var(--border); border-radius: 6px;
}

.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: 6px; padding: 0.5rem 0.7rem; font-size: 0.8rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4); min-width: 9rem;
}
.chart-tip[hidden] { display: none !important; }
.chart-tip .tip-day { font-weight: 600; margin-bottom: 0.3rem; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 0.4rem;
                      justify-content: space-between; }
.chart-tip .tip-name { display: flex; align-items: center; gap: 0.35rem; }
.chart-tip .tip-total { margin-top: 0.3rem; padding-top: 0.3rem;
                        border-top: 1px solid var(--border); color: var(--text-muted); }

/* -- bars ----------------------------------------------------------- */

.meter { margin-top: 0.8rem; }
.meter-label { display: flex; justify-content: space-between;
               font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.meter-track { height: 5px; background: var(--bg-sunken); border-radius: 3px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.meter-fill.warn { background: var(--warn); }
.meter-fill.error { background: var(--error); }

/* -- admin ---------------------------------------------------------- */

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.action {
  padding: 0.55rem 0.9rem; background: var(--bg-sunken);
  border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); font-size: 0.9rem; cursor: pointer;
}
.action:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.action:disabled { opacity: 0.5; cursor: default; }

.result {
  margin: 0.9rem 0 0; padding: 0.6rem 0.8rem; border-radius: 6px;
  font-size: 0.9rem; background: rgba(111, 170, 99, 0.1);
  border-left: 3px solid var(--ok);
}
.result.bad { background: rgba(207, 97, 86, 0.1); border-left-color: var(--error); }

.list-block { margin-top: 1rem; }
.list-block h4 { margin: 0 0 0.5rem; font-size: 0.9rem; font-weight: 600; }

.list-add { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }
.list-add input {
  flex: 1; min-width: 9rem; padding: 0.45rem 0.6rem;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 0.88rem;
}

.remove {
  background: none; border: 0; color: var(--text-muted);
  cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 0.3rem;
}
.remove:hover { color: var(--error); }

/* -- footer --------------------------------------------------------- */

.footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem;
  padding: 1rem 1.25rem 2rem;
}

@media (prefers-reduced-motion: no-preference) {
  .dot, .meter-fill { transition: background-color 0.3s ease, width 0.3s ease; }
}
