/* Public status block. Uses ONLY the site tokens (--paper --card --ink --ink-2 --line --nose --moss --mustard --tang --plum,
   --f-display / --f-body / --f-mono) so it follows light/dark automatically.
   State is never colour alone: every state has its own glyph, label, fill pattern and bar height.
   ok = moss, degraded = mustard, down = plum with diagonal hatch (not brand --nose, which is the accent),
   no data = dashed outline with no fill. */
.status { position: relative; overflow-x: clip; padding-block: clamp(56px, 8vw, 104px); color: var(--ink); }
.status *, .status *::before, .status *::after { box-sizing: border-box; }
.st-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

.status-head { display: grid; gap: 14px; margin-bottom: clamp(24px, 4vw, 44px); max-width: 46rem; }
.status-head h2 { font-size: var(--step-4); }
.status-intro { font-size: var(--step-1); color: var(--ink-2); max-width: 46ch; }

/* ---------- the big live sticker ---------- */
.status-board { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: clamp(20px, 3.4vw, 40px); align-items: stretch; }
.status-sticker {
  position: relative; isolation: isolate; overflow: hidden; min-width: 0;
  display: grid; grid-template-rows: auto 1fr auto; gap: 14px;
  min-height: 17rem; padding: clamp(20px, 3vw, 32px);
  border: 5px solid var(--sticker-edge); border-radius: 26px; box-shadow: var(--shadow);
  background: var(--card); color: var(--ink);
  transform: rotate(-.7deg);
}
.status-sticker[data-state="operational"] { background: var(--moss); color: var(--on-cool); }
.status-sticker[data-state="degraded"] { background: var(--mustard); color: var(--on-warm); }
.status-sticker[data-state="outage"] {
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, .17) 0 12px, transparent 12px 24px), var(--plum);
  color: var(--on-cool);
}
.status-sticker[data-state="stale"] {
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, .17) 0 12px, transparent 12px 24px), var(--plum);
  color: var(--on-cool);
}
.status-sticker[data-state="stale"]::after,
.status-sticker[data-state="unknown"]::after,
.status-sticker[data-state="nosnapshot"]::after,
.status-sticker[data-state="loading"]::after {
  content: ""; position: absolute; inset: 10px; border: 2px dashed currentColor; border-radius: 18px; opacity: .45; pointer-events: none;
}
.status-sticker[data-state="unknown"], .status-sticker[data-state="nosnapshot"], .status-sticker[data-state="loading"] { background: var(--card); color: var(--ink); }

.status-ecg { position: absolute; z-index: -1; top: clamp(16px, 2.4vw, 26px); right: clamp(16px, 2.4vw, 26px); width: min(52%, 22rem); height: 3.4rem; opacity: .6; pointer-events: none; }
.status-ecg use { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.status-ecg .ecg-live { stroke-width: 3.4; stroke-dasharray: 52 348; animation: st-scan 2.8s linear infinite; }
.status-sticker[data-state="degraded"] .ecg-live { animation-duration: 4.2s; }
.status-sticker[data-state="outage"] .ecg-live, .status-sticker[data-state="stale"] .ecg-live,
.status-sticker[data-state="unknown"] .ecg-live, .status-sticker[data-state="nosnapshot"] .ecg-live, .status-sticker[data-state="loading"] .ecg-live { display: none; }
.status-sticker[data-state="unknown"] .ecg-base, .status-sticker[data-state="nosnapshot"] .ecg-base, .status-sticker[data-state="loading"] .ecg-base { stroke-dasharray: 2 9; }
@keyframes st-scan { from { stroke-dashoffset: 400; } to { stroke-dashoffset: 0; } }

.status-mark { display: flex; align-items: center; gap: 14px; }
.status-nose {
  flex: none; width: 1.55rem; height: 1.55rem; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ff8a80 0 14%, var(--nose) 42%, color-mix(in srgb, var(--nose) 70%, #000) 100%);
  box-shadow: 0 0 0 4px var(--sticker-edge);
  animation: st-beat 1.7s ease-in-out infinite;
}
.status-sticker[data-state="degraded"] .status-nose { animation: st-beat-uneven 3.1s ease-in-out infinite; }
.status-sticker[data-state="outage"] .status-nose, .status-sticker[data-state="stale"] .status-nose {
  animation: none; filter: grayscale(1) brightness(.75); background: #6d6470; box-shadow: 0 0 0 4px var(--sticker-edge);
}
.status-sticker[data-state="unknown"] .status-nose, .status-sticker[data-state="nosnapshot"] .status-nose, .status-sticker[data-state="loading"] .status-nose {
  animation: none; background: transparent; box-shadow: none; border: 3px dashed var(--ink-2);
}
@keyframes st-beat { 0%, 100% { transform: scale(1); } 10% { transform: scale(1.3); } 22% { transform: scale(.94); } 34% { transform: scale(1.18); } 52% { transform: scale(1); } }
@keyframes st-beat-uneven { 0%, 100% { transform: scale(1); } 12% { transform: scale(1.22); } 26% { transform: scale(.96); } 68% { transform: scale(1); } 80% { transform: scale(1.1); } }

.status-glyph {
  flex: none; width: 2.9rem; height: 2.9rem; padding: .5rem; border-radius: 50%;
  background: color-mix(in srgb, currentColor 16%, transparent);
  fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round;
}
.status-headline { display: grid; align-content: center; gap: 12px; min-width: 0; }
.status-state { font-size: clamp(2rem, 5.2vw, 3.6rem); line-height: .98; overflow-wrap: anywhere; text-wrap: balance; }
.status-reason { font-size: var(--step-0); font-weight: 500; max-width: 38ch; }
.status-asof { margin: 0; font-size: .75rem; opacity: .85; overflow-wrap: anywhere; }

/* ---------- KPIs ---------- */
.status-kpis { display: grid; gap: 14px; margin: 0; grid-auto-rows: 1fr; }
.status-kpi {
  display: grid; align-content: center; gap: 4px; min-width: 0; padding: 14px 18px;
  background: var(--card); border: 2px solid var(--ink); border-radius: 16px; box-shadow: 4px 4px 0 var(--ink);
}
.status-kpi dt { font: 600 .75rem/1.3 var(--f-mono); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); }
.status-kpi dd { margin: 0; font: 400 clamp(1.45rem, 2.8vw, 2.1rem)/1.08 var(--f-display); overflow-wrap: anywhere; }
.status-kpi small { display: block; margin-top: 4px; font: 400 .75rem/1.3 var(--f-mono); color: var(--ink-2); letter-spacing: 0; }

/* ---------- legend, swatches, patterns ---------- */
.st-legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: clamp(22px, 3vw, 34px) 0 0; padding: 0; list-style: none; font: 600 .8125rem/1.2 var(--f-mono); }
.st-legend li { display: inline-flex; align-items: center; gap: 8px; }
.st-swatch { display: inline-block; width: 1.15rem; height: 1.15rem; border-radius: 4px; border: 2px solid var(--ink); }
[data-s="ok"] { background: var(--moss); }
[data-s="degraded"] { background: var(--mustard); }
[data-s="down"] { background: repeating-linear-gradient(135deg, rgba(255, 255, 255, .6) 0 2px, transparent 2px 5px), var(--plum); }
[data-s="nodata"] { background: transparent; border-style: dashed; border-color: var(--ink-2); }
.st-cell { display: block; flex: 1 1 0; min-width: 0; border: 1px solid transparent; border-radius: 3px; }
.st-cell[data-s="nodata"] { border: 1px dashed var(--ink-2); }

/* ---------- figures ---------- */
.status-fig {
  position: relative; margin: clamp(22px, 3vw, 34px) 0 0; padding: clamp(16px, 2.4vw, 28px);
  background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius); box-shadow: 4px 4px 0 var(--ink);
}
.st-fig-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; }
.st-fig-title { font-size: clamp(1.25rem, 2.4vw, 1.7rem); }
.st-caption { margin: 8px 0 18px; max-width: 70ch; font-size: .875rem; color: var(--ink-2); }
.st-keys { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0; padding: 0; list-style: none; font: 600 .75rem/1.2 var(--f-mono); }
.st-keys li { display: inline-flex; align-items: center; gap: 8px; }
.st-key { display: inline-block; width: 1.6rem; height: 0; border-top: 3px solid var(--ink); }
.st-key-p95 { border-top: 3px dashed var(--tang); }

.st-plot { position: relative; border-radius: 10px; touch-action: pan-y; -webkit-tap-highlight-color: transparent; }
.st-plot:focus-visible { outline: 3px solid var(--focus); outline-offset: 6px; }
.st-strip { display: flex; align-items: flex-end; gap: 2px; height: 4.2rem; }
.st-strip .st-cell[data-s="ok"], .st-strip .st-cell[data-s="down"] { height: 100%; }
.st-strip .st-cell[data-s="degraded"] { height: 70%; }
.st-strip .st-cell[data-s="nodata"] { height: 24%; }
.st-cell.is-active { outline: 2px solid var(--ink); outline-offset: 2px; }
.st-axis { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; font: 400 .6875rem/1.2 var(--f-mono); color: var(--ink-2); }

.st-chart { position: relative; height: clamp(150px, 22vw, 220px); }
.st-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.st-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.st-area { fill: color-mix(in srgb, var(--ink) 9%, transparent); stroke: none; }
.st-band { fill: color-mix(in srgb, var(--tang) 24%, transparent); stroke: none; }
.st-p50, .st-p95 { fill: none; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.st-p50 { stroke: var(--ink); stroke-width: 2.5; }
.st-p95 { stroke: var(--tang); stroke-width: 2; stroke-dasharray: 7 5; }
.st-yl {
  position: absolute; left: 0; transform: translateY(-105%); padding: 0 4px; border-radius: 4px;
  font: 600 .6875rem/1.3 var(--f-mono); color: var(--ink-2); background: color-mix(in srgb, var(--card) 82%, transparent);
  pointer-events: none;
}
.st-yl-top { transform: translateY(3px); }
.st-dot {
  position: absolute; width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
  background: var(--ink); box-shadow: 0 0 0 2px var(--card); pointer-events: none;
}
.st-dot-hi { width: 6px; height: 6px; margin: -3px 0 0 -3px; background: var(--tang); }
.st-dot.is-active { width: 12px; height: 12px; margin: -6px 0 0 -6px; }
.st-dot-hi.is-active { width: 10px; height: 10px; margin: -5px 0 0 -5px; }
.st-cursor { position: absolute; top: 0; width: 2px; margin-left: -1px; background: color-mix(in srgb, var(--ink) 55%, transparent); pointer-events: none; }
.st-bandrow { display: flex; gap: 1px; height: 14px; margin-top: 10px; }
.st-bandrow .st-cell { height: 100%; border-radius: 2px; }
.st-bandrow .st-cell.is-active { outline-offset: 1px; }
.st-xaxis { position: relative; height: 2.6rem; margin-top: 6px; font: 400 .6875rem/1.25 var(--f-mono); color: var(--ink-2); }
.st-xl { position: absolute; top: 0; display: grid; justify-items: center; transform: translateX(-50%); white-space: nowrap; }
.st-xl b { font-weight: 600; color: var(--ink); }
.st-xl i { font-style: normal; }
.st-xl-first { left: 0 !important; transform: none; justify-items: start; }
.st-xl-last { left: 100% !important; transform: translateX(-100%); justify-items: end; }

.st-tip {
  position: absolute; z-index: 4; left: 0; top: 0; max-width: min(20rem, 86vw); padding: 8px 11px; border-radius: 10px;
  background: var(--ink); color: var(--paper); font: 500 .75rem/1.4 var(--f-mono); pointer-events: none;
  box-shadow: 0 8px 20px -8px rgba(0, 0, 0, .55); transform: translate(-50%, calc(-100% - 12px));
}
.st-tip[hidden] { display: none; }

/* ---------- text equivalents ---------- */
.st-data { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.st-data summary { cursor: pointer; font: 600 .8125rem/1.3 var(--f-mono); color: var(--ink-2); }
.st-table-wrap { max-height: 20rem; overflow: auto; margin-top: 10px; border: 1px solid var(--line); border-radius: 10px; }
.st-data table { width: 100%; border-collapse: collapse; font: 400 .75rem/1.35 var(--f-mono); }
.st-data th, .st-data td { padding: 6px 10px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); }
.st-data thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }

.status-def { margin-top: clamp(24px, 3vw, 34px); max-width: 72ch; font-size: .9375rem; color: var(--ink-2); }
.status-static { margin-top: 16px; font: 400 .75rem/1.4 var(--f-mono); color: var(--ink-2); }
.status-dimmed { margin: 22px 0 -6px; padding-left: 12px; border-left: 3px solid var(--plum); font-size: .875rem; font-weight: 600; }
.status[data-state="stale"] .status-fig, .status[data-state="stale"] .status-kpis,
.status[data-state="loading"] .status-fig, .status[data-state="loading"] .status-kpis { opacity: .55; filter: grayscale(.7); }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .status-board { grid-template-columns: minmax(0, 1fr); }
  .status-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: auto; }
  .status-sticker { margin-inline: 4px; }
}
@media (max-width: 640px) {
  .status-kpis { grid-template-columns: minmax(0, 1fr); }
  .st-strip { gap: 1px; height: 3.6rem; }
  .st-dot { width: 5px; height: 5px; margin: -2.5px 0 0 -2.5px; box-shadow: 0 0 0 1px var(--card); }
  .st-dot-hi { width: 4px; height: 4px; margin: -2px 0 0 -2px; }
  .st-xl-opt { display: none; }
  .status-sticker { min-height: 15rem; }
}

@media (prefers-reduced-motion: reduce) {
  .status *, .status *::before, .status *::after { animation: none !important; transition: none !important; }
  .status-ecg .ecg-live { display: none; }
}
