/* ==========================================================================
   Server statistics v2 (/stats/v2) — built on Skynet UI (https://skynetui.com)

   This page is a frame around views/partials/dashboard-v2/tabs/stats.ejs, so
   almost all of its styling already exists: components from skynet-ui.css,
   palettes from themes-v2.css, the dv2-* classes from dashboard-v2.css, and
   the markup public/js/tabs/stats.js injects from dashboard-v2-compat.css.
   What is below is only what this page adds around that panel.

   Every colour is a Skynet UI token, so the page follows whichever of the
   twelve palettes the reader picked.
   ========================================================================== */

body.stv2 { background: var(--sk-bg); color: var(--sk-text); }

.stv2 .hidden { display: none !important; }
.stv2 [hidden] { display: none !important; }

/* dashboard-v2.css declares `.tab-content { display: none }` — correct on the
   dashboard, which shows one tab at a time, and wrong here, where the tab is
   the whole page. This is a class selector, not [hidden], so it is what the
   framework rule loses to; adding `.active` in the markup instead would mean
   forking the shared partial for one word. */
.stv2-main #stats-tab { display: block; }

/* A grid or flex ITEM defaults to `min-width: auto` — its MIN-CONTENT width,
   not zero — so a long server name sizes the whole track and the card clips it
   off a phone. `npm run audit:mobile` is what catches that; this prevents it.
   The shared panel carries the same rule for its own rows in dashboard-v2.css. */
.stv2-head > *,
.stv2-picker-row > *,
.stv2-field > *,
.stv2-gate-acts > * {
  min-width: 0;
}

.stv2-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

/* ---------- page header --------------------------------------------------- */

.stv2-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stv2-head-text { flex: 1 1 22rem; }

.stv2-head h1 {
  margin: 0 0 0.4rem;
  font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--sk-text);
}

.stv2-head p {
  margin: 0;
  max-width: 62ch;
  color: var(--sk-text-2);
  line-height: 1.6;
}

/* The way back to the classic page. Skynet UI sizes buttons for a mouse, so a
   coarse pointer gets the 44px target back. */
.stv2-classic { flex: 0 0 auto; }
@media (pointer: coarse) {
  .stv2-classic { min-height: 44px; }
}

/* ---------- the three states that are not the panel ----------------------- */

.stv2-gate { max-width: 44rem; }

.stv2-gate .sk-card-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1.75rem;
}

.stv2-gate h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--sk-text);
}

.stv2-gate p {
  margin: 0;
  max-width: 58ch;
  color: var(--sk-text-2);
  line-height: 1.6;
}

.stv2-gate-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  /* A soft tint of the accent, not the accent itself: the glyph inherits
     --sk-primary-text, which is the readable half of the pair in both modes
     (--sk-primary is a FILL token and measures ~2.8:1 as text on a card). */
  background: color-mix(in srgb, var(--sk-primary) 16%, transparent);
  color: var(--sk-primary-text);
  font-size: 1.1rem;
}
.stv2-gate-icon.is-warning {
  background: color-mix(in srgb, var(--sk-warning) 18%, transparent);
  color: var(--sk-warning-text);
}

.stv2-gate-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.35rem;
}
@media (pointer: coarse) {
  .stv2-gate-acts .sk-btn { min-height: 44px; }
}

/* ---------- the server picker --------------------------------------------- */

.stv2-picker { margin-bottom: 1.25rem; }

.stv2-picker-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1.25rem;
}

.stv2-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 20rem;
}

/* 16px on a coarse pointer: below that, iOS zooms the whole page on focus. */
.stv2-field .sk-select { width: 100%; }
@media (pointer: coarse) {
  .stv2-field .sk-select { min-height: 44px; font-size: 16px; }
}

.stv2-picker-note {
  margin: 0 0 0.35rem;
  flex: 1 1 16rem;
  color: var(--sk-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.stv2-noscript {
  margin: 0.9rem 0 0;
  padding: 0.75rem 0.9rem;
  border: 1px dashed var(--sk-border-2);
  border-radius: 12px;
  color: var(--sk-text-2);
  line-height: 1.6;
}
.stv2-noscript a { color: var(--sk-primary-text); }

@media (max-width: 480px) {
  .stv2-main { padding-left: 0.75rem; padding-right: 0.75rem; }
  .stv2-gate .sk-card-body { padding: 1.25rem; }
  .stv2-gate-acts .sk-btn { width: 100%; }
}
