/*
 * Status page — same design system as the Taktovka app: paper ground, navy ink, warm borders,
 * Public Sans everywhere and JetBrains Mono on numbers only. Tokens are copied from the app's
 * main.css; when the app's palette moves, move these with it.
 */

@font-face {
  font-family: 'Public Sans Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/public-sans-latin.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Public Sans Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/public-sans-latin-ext.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Public Sans has no Cyrillic; Ukrainian and Russian switch the whole page to Inter. */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/inter-latin.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/inter-latin-ext.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/inter-cyrillic.woff2') format('woff2-variations');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/inter-cyrillic-ext.woff2') format('woff2-variations');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url('fonts/jetbrains-mono-latin-500.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --color-navy-50: #f3f5f9;
  --color-navy-100: #e5e9f2;
  --color-navy-200: #c9d0e2;
  --color-navy-300: #a0abc9;
  --color-navy-400: #7080aa;
  --color-navy-500: #4e5f8e;
  --color-navy-600: #3b4a74;
  --color-navy-700: #2c3a5e;
  --color-navy-800: #1b2646;
  --color-navy-900: #131b33;
  --color-navy-950: #0b1022;

  --color-paper-50: #f9f6f1;
  --color-paper-100: #f3efe7;
  --color-paper-200: #e7e0d4;
  --color-paper-300: #d6ccbc;
  --color-paper-500: #7e7467;

  --font-sans: 'Public Sans Variable', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'DejaVu Sans Mono', monospace;

  --bg: var(--color-paper-50);
  --surface: #fff;
  --surface-muted: var(--color-paper-100);
  --text: var(--color-navy-800);
  --text-strong: var(--color-navy-950);
  --text-muted: var(--color-navy-500);
  --border: var(--color-paper-200);
  --border-strong: var(--color-paper-300);

  /* Orange is the brand moment (logo dot, "now"), never a meaning. State colours stay semantic. */
  --accent: #fd753e;
  --ok: #15803d;
  --ok-soft: color-mix(in oklab, #15803d 14%, var(--surface));
  --warn: #b45309;
  --warn-soft: color-mix(in oklab, #b45309 14%, var(--surface));
  --bad: #991b1b;
  --bad-soft: color-mix(in oklab, #991b1b 12%, var(--surface));
  --idle: color-mix(in oklab, var(--color-paper-300) 45%, var(--surface));

  --radius-card: 16px;
  --radius-control: 12px;
  --shadow-card: 0 8px 24px -12px color-mix(in oklab, var(--color-navy-950) 25%, transparent);
}

/* Cyrillic pages take Inter for the whole interface, so a Latin name in a Russian line is one face. */
:root:lang(uk),
:root:lang(ru) {
  --font-sans: 'Inter Variable', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* Night theme, opt-in only: the paper face is the default for every visitor. */
:root[data-theme='dark'] {
  --bg: var(--color-navy-950);
  --surface: var(--color-navy-900);
  --surface-muted: var(--color-navy-800);
  --text: var(--color-navy-50);
  --text-strong: #fff;
  --text-muted: var(--color-navy-300);
  --border: color-mix(in oklab, var(--color-navy-300) 30%, transparent);
  --border-strong: color-mix(in oklab, var(--color-navy-300) 45%, transparent);

  --ok: #4ade80;
  --ok-soft: color-mix(in oklab, #4ade80 16%, var(--surface));
  --warn: #fbbf24;
  --warn-soft: color-mix(in oklab, #fbbf24 16%, var(--surface));
  --bad: #f87171;
  --bad-soft: color-mix(in oklab, #f87171 16%, var(--surface));
  --idle: color-mix(in oklab, var(--color-navy-300) 14%, transparent);
  --shadow-card: none;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.num {
  font-family: var(--font-mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.wrap {
  width: min(100% - 32px, 880px);
  margin-inline: auto;
}

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

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 0 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand svg {
  display: block;
  width: auto;
  height: 26px;
}

.brand__ink { fill: var(--text-strong); }
.brand__dot { fill: var(--accent); }

.brand__word {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-strong);
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.seg {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-muted);
  border-radius: 9999px;
}

.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 9999px;
  cursor: pointer;
}

.seg button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text-strong);
  box-shadow: var(--shadow-card);
}

/* At night the navy steps sit too close for tone alone to read as "raised": the chosen chip takes a
   lighter fill and a visible edge instead, the way the app's segmented controls do. */
:root[data-theme='dark'] .seg button[aria-pressed='true'] {
  background: color-mix(in oklab, var(--color-navy-300) 16%, var(--surface-muted));
  border: 1px solid var(--border);
  padding: 4px 10px;
}

:root[data-theme='dark'] .themes button[aria-pressed='true'] { padding: 4px 8px; }

.themes button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
}

.themes svg {
  display: block;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 430px) {
  .head { gap: 10px; }
  .controls { gap: 6px; }
  .seg button { padding: 5px 8px; font-size: 12.5px; }
  .themes button { padding: 5px 7px; }
}

/* ---------- hero ---------- */

.hero {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 36px 0 30px;
}

.beacon {
  flex: none;
  width: 14px;
  height: 14px;
  margin-top: 12px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 5px var(--ok-soft);
}

/* Before the data arrives — and for a crawler that never runs our JS — the dot claims nothing. */
.hero[data-state='loading'] .beacon { background: var(--idle); box-shadow: 0 0 0 5px color-mix(in oklab, var(--idle) 40%, transparent); }
.hero[data-state='degraded'] .beacon { background: var(--warn); box-shadow: 0 0 0 5px var(--warn-soft); }
.hero[data-state='down'] .beacon { background: var(--bad); box-shadow: 0 0 0 5px var(--bad-soft); }

.hero[data-state='down'] .beacon { animation: pulse 2s ease-in-out infinite; }

@keyframes pulse {
  50% { box-shadow: 0 0 0 9px color-mix(in oklab, var(--bad) 8%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .hero[data-state='down'] .beacon { animation: none; }
}

.hero h1 {
  margin: 0;
  font-size: clamp(28px, 5.4vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 700;
  color: var(--text-strong);
}

.hero p {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 15px;
}

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

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

.services { display: grid; gap: 12px; }

.svc { padding: 16px 20px 14px; }

.svc__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 12px;
  flex-wrap: wrap;
}

.svc__title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.svc__state {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.svc__name {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text-strong);
}

.svc__sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.svc__ping {
  font-size: 13px;
  color: var(--text-muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--ok-soft);
  color: var(--ok);
}

.chip::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chip[data-state='down'] { background: var(--bad-soft); color: var(--bad); }
.chip[data-state='pending'],
.chip[data-state='maintenance'] { background: var(--warn-soft); color: var(--warn); }
.chip[data-state='paused'] { background: var(--surface-muted); color: var(--text-muted); }

/* ---------- 90-day bars ---------- */

.bars {
  display: flex;
  gap: 2px;
  height: 28px;
  margin: 14px 0 8px;
}

.bar {
  flex: 1 1 0;
  min-width: 0;
  border-radius: 2px;
  background: var(--ok);
  cursor: default;
}

.bar[data-state='none'] { background: var(--idle); }
.bar[data-state='partial'] { background: var(--warn); }
.bar[data-state='down'] { background: var(--bad); }

/* A phone cannot show 90 legible bars; it shows the most recent 30, a tablet 60. */
@media (max-width: 900px) { .bar:nth-child(-n + 30) { display: none; } }
@media (max-width: 560px) {
  .bar:nth-child(-n + 60) { display: none; }
  .scale { font-size: 12px; }
  .svc__state { margin-left: 0; }
}

.scale {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.scale__rule {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- latency chart ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 30px 0 12px;
}

.section-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--text);
}

.section-head p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.chart { padding: 18px 20px 14px; }

.chart svg {
  display: block;
  width: 100%;
  height: 150px;
  overflow: visible;
}

.chart__band { fill: color-mix(in oklab, var(--text) 7%, transparent); }
.chart__line { fill: none; stroke: var(--text-strong); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.chart__grid { stroke: var(--border); stroke-width: 1; }
.chart__label { fill: var(--text-muted); font-family: var(--font-mono); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart__plot { position: relative; }

/* The orange "now" marker: the one place on the chart where the brand accent is allowed. */
.chart__dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 22%, transparent);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* Without the plot the card is just the three numbers, so the rule that separated them from it goes. */
.chart--bare { padding: 14px 20px; }

.chart--bare .chart__foot {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.chart__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.chart__foot b {
  font-weight: inherit;
  color: var(--text-strong);
}

/* ---------- history ---------- */

.history { padding: 4px 20px; }

.history__row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  font-size: 14.5px;
}

.history__row:first-child { border-top: 0; }

.history__date {
  flex: none;
  width: 104px;
  color: var(--text-muted);
  font-size: 13px;
}

.history__what { color: var(--text); }

.history__len { margin-left: auto; color: var(--bad); font-size: 13px; }

.empty {
  padding: 20px;
  color: var(--text-muted);
  font-size: 14.5px;
}

/* ---------- footer ---------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  margin: 40px 0 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.foot a { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border-strong); }
.foot a:hover { color: var(--text-strong); border-color: currentColor; }

/* ---------- tooltip ---------- */

.tip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%);
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--color-navy-900);
  color: #fff;
  font-size: 12.5px;
  line-height: 1.35;
  white-space: nowrap;
  box-shadow: 0 16px 40px -16px color-mix(in oklab, var(--color-navy-950) 45%, transparent);
}

.tip[data-open='true'] { opacity: 1; }
.tip .num { color: #fff; }
.tip__muted { color: var(--color-navy-300); }

:root[data-theme='dark'] .tip { background: var(--color-navy-800); border: 1px solid var(--border); }

/* Nothing on this page shifts while it loads: the skeleton holds the same height as the data. */
.loading .bars .bar { background: var(--idle); }
