/* /ops, /status and /changelog. Uses the tokens from /style.css.
   Status colours avoid green on purpose: cyan = OK, amber = degraded, red = down. */

:root {
  --ok: #0e7490;
  --ok-soft: #e0f2fe;
  --ok-text: #075985;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --warn-text: #92400e;
  --down: #dc2626;
  --down-soft: #fee2e2;
  --down-text: #991b1b;
  --none: #c9ccd8;
  --elite-soft: #eceeff;
  --elite-text: #3730a3;
  --chart-bg: #eef0f5;
}
:root[data-scheme="dark"] {
  --ok: #22b8cf;
  --ok-soft: #0c2a36;
  --ok-text: #7dd3e8;
  --warn: #f59e0b;
  --warn-soft: #3a2c0d;
  --warn-text: #ffcf5c;
  --down: #f87171;
  --down-soft: #3d1614;
  --down-text: #ff8e85;
  --none: #343a4a;
  --elite-soft: #1d1f3d;
  --elite-text: #a5a8ff;
  --chart-bg: #181b24;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-scheme]) {
    --ok: #22b8cf; --ok-soft: #0c2a36; --ok-text: #7dd3e8; --warn: #f59e0b; --warn-soft: #3a2c0d; --warn-text: #ffcf5c;
    --down: #f87171; --down-soft: #3d1614; --down-text: #ff8e85; --none: #343a4a; --elite-soft: #1d1f3d; --elite-text: #a5a8ff; --chart-bg: #181b24;
  }
}

.wrap-wide { max-width: 76rem; }
.ops-page .page-head { margin-bottom: 1.25rem; }
.ops-page .page-head h1 { margin: 0; font-size: clamp(2rem, 5vw, 2.8rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.ops-page .eyebrow { margin: 0 0 0.5rem; }

.subnav { margin-bottom: 2.5rem; }
.subnav ul { display: inline-flex; gap: 4px; margin: 0; padding: 5px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); list-style: none; }
.subnav a { display: inline-flex; align-items: center; min-height: 2.5rem; padding: 0 1rem; border-radius: 10px; color: var(--muted); font-weight: 700; text-decoration: none; }
.subnav a:hover { color: var(--ink); background: color-mix(in srgb, var(--line) 50%, transparent); }
.subnav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); }

.ops-section { margin-bottom: clamp(2.5rem, 6vw, 3.75rem); }
.section-lede { max-width: 46rem; margin: -0.4rem 0 1.25rem; color: var(--muted); }
.fine-print { margin: 0.9rem 0 0; color: var(--muted); font-size: 0.9rem; }
.slot-empty { margin: 0; padding: 1.25rem 1.35rem; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }
.ops-page code { font: 0.88em var(--mono); }

/* ---------- DORA ---------- */

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.metric { display: grid; align-content: start; gap: 0.55rem; padding: 1.25rem 1.3rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.metric h3 { margin: 0; color: var(--muted); font: 700 0.85rem/1.3 var(--mono); }
.metric-value { margin: 0.2rem 0 0; font-size: clamp(1.8rem, 3.5vw, 2.35rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metric-unit { color: var(--muted); font-size: 0.5em; font-weight: 700; letter-spacing: 0; }
.metric-note { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.level-badge { justify-self: start; padding: 0.15rem 0.6rem; border-radius: 999px; font: 800 0.75rem/1.6 var(--mono); }
.level-elite { background: var(--elite-soft); color: var(--elite-text); }
.level-high { background: var(--ok-soft); color: var(--ok-text); }
.level-medium { background: var(--warn-soft); color: var(--warn-text); }
.level-low { background: var(--down-soft); color: var(--down-text); }
.level-none { background: var(--chart-bg); color: var(--muted); }

/* ---------- Deployments ---------- */

.chart { margin: 0 0 1.25rem; padding: 1.1rem 1.2rem 0.8rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.deploy-chart { display: block; width: 100%; height: 120px; }
.bar-bg { fill: var(--chart-bg); }
.bar-ok { fill: var(--accent); }
.bar-fail { fill: var(--down); }
.chart figcaption { display: flex; justify-content: space-between; gap: 1rem; margin-top: 0.6rem; color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.legend { display: inline-flex; align-items: center; gap: 0.4rem; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; }
.dot-ok { background: var(--accent); }
.dot-fail { margin-left: 0.5rem; background: var(--down); }

.runs { min-width: 36rem; }
.runs td { vertical-align: middle; }
.runs a { font-weight: 700; }
.cell-message { max-width: 28rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font: 800 0.75rem/1.6 var(--mono); }
.result-success { background: var(--ok-soft); color: var(--ok-text); }
.result-failure { background: var(--down-soft); color: var(--down-text); }

/* ---------- Replay ---------- */

.replay { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.replay-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.replay-head p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.replay-button { min-height: 2.6rem; padding: 0 1rem; font-size: 0.95rem; cursor: pointer; }
.replay-jobs { display: grid; gap: 1.25rem; padding: 1.1rem 1.25rem 1.25rem; }
.replay-job h3 { display: flex; align-items: baseline; gap: 0.6rem; margin: 0 0 0.6rem; font: 800 0.95rem var(--mono); }
.job-time { color: var(--muted); font-weight: 600; }
.replay-steps { display: grid; gap: 0.35rem; margin: 0; padding: 0; list-style: none; }
.replay-step { display: grid; grid-template-columns: 1.2rem minmax(10rem, 18rem) 1fr 4rem; align-items: center; gap: 0.75rem; font-size: 0.92rem; }
.step-state { width: 0.9rem; height: 0.9rem; border-radius: 50%; background: var(--ok); }
.replay-step[data-conclusion="failure"] .step-state { background: var(--down); }
.replay-step[data-conclusion="skipped"] .step-state { background: var(--none); }
.step-name { overflow: hidden; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.step-bar { width: 100%; height: 10px; }
.step-track { fill: var(--chart-bg); }
.step-fill { fill: var(--accent); }
.step-time { color: var(--muted); font: 600 0.82rem var(--mono); text-align: right; }
.replay.is-playing .replay-step { opacity: 0.35; transition: opacity .2s ease; }
.replay.is-playing .replay-step .step-state { background: var(--none); }
.replay.is-playing .replay-step.is-running { opacity: 1; }
.replay.is-playing .replay-step.is-running .step-state { background: var(--accent); animation: pulse 0.8s ease-in-out infinite; }
.replay.is-playing .replay-step.is-done { opacity: 1; }
.replay.is-playing .replay-step.is-done .step-state { background: var(--ok); }
.replay.is-playing .replay-step.is-failed .step-state { background: var(--down); }
.replay-log { max-height: 16rem; margin: 0; padding: 1rem 1.25rem; overflow-y: auto; border-top: 1px solid var(--term-line); background: var(--term-bg); color: var(--term-text); font: 500 0.86rem/1.65 var(--mono); white-space: pre-wrap; }
@keyframes pulse { 50% { transform: scale(0.7); opacity: 0.6; } }

/* ---------- Architecture ---------- */

.arch { position: relative; padding: 1.25rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.arch-edges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.arch-edges line { stroke: var(--line-strong); stroke-width: 2; marker-end: url(#arch-arrow); transition: stroke .2s ease, opacity .2s ease; }
.arch-edges marker path { fill: var(--line-strong); }
.arch-edges line.is-active { stroke: var(--accent); stroke-width: 2.5; }
.arch.has-selection .arch-edges line:not(.is-active) { opacity: 0.35; }
.arch-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-areas:
    "push repo actions pages"
    "dependabot uptime . browser"
    ". . steam worker";
  gap: 2.75rem 2.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.arch-node { position: relative; display: grid; align-content: start; }
.arch-node[data-node="push"] { grid-area: push; }
.arch-node[data-node="repo"] { grid-area: repo; }
.arch-node[data-node="actions"] { grid-area: actions; }
.arch-node[data-node="pages"] { grid-area: pages; }
.arch-node[data-node="dependabot"] { grid-area: dependabot; }
.arch-node[data-node="uptime"] { grid-area: uptime; }
.arch-node[data-node="browser"] { grid-area: browser; }
.arch-node[data-node="steam"] { grid-area: steam; }
.arch-node[data-node="worker"] { grid-area: worker; }
.arch-button {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.15rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.arch-button:hover { border-color: var(--accent); transform: translateY(-1px); }
.arch-button[aria-expanded="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.arch-node.is-linked .arch-button { border-color: var(--accent); }
.arch-kind { color: var(--muted); font: 700 0.72rem/1.4 var(--mono); text-transform: uppercase; letter-spacing: 0.06em; }
.arch-title { font-size: 1rem; font-weight: 800; }
.arch-detail { position: absolute; top: calc(100% + 0.5rem); right: 0; left: 0; z-index: 3; min-width: 15rem; padding: 0.85rem 1rem; border: 1px solid var(--accent); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); font-size: 0.9rem; }
.arch-detail p { margin: 0; }
.arch-detail p + p { margin-top: 0.5rem; }
.arch-links a { font-weight: 700; }

/* ---------- Status ---------- */

.status-banner { display: flex; align-items: center; gap: 1rem; padding: 1.25rem 1.4rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.status-dot { flex: none; width: 1rem; height: 1rem; border-radius: 50%; background: var(--none); }
.tone-ok .status-dot { background: var(--ok); box-shadow: 0 0 0 6px color-mix(in srgb, var(--ok) 20%, transparent); }
.tone-warn .status-dot { background: var(--warn); }
.tone-down .status-dot { background: var(--down); }
.status-banner.tone-ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.status-banner.tone-down { border-color: color-mix(in srgb, var(--down) 50%, var(--line)); }
.status-headline { margin: 0; font-size: 1.25rem; font-weight: 800; }
.status-meta { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.92rem; }

.components { display: grid; gap: 1rem; }
.component { padding: 1.2rem 1.3rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.component-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.component h3 { margin: 0; font-size: 1.05rem; font-weight: 800; }
.component-desc { margin: 0.15rem 0 0; color: var(--muted); font-size: 0.9rem; }
.pill { flex: none; padding: 0.2rem 0.7rem; border-radius: 999px; font: 800 0.78rem/1.6 var(--mono); }
.pill.tone-ok { background: var(--ok-soft); color: var(--ok-text); }
.pill.tone-down { background: var(--down-soft); color: var(--down-text); }
.pill.tone-none { background: var(--chart-bg); color: var(--muted); }
.uptime-bars { display: block; width: 100%; height: 28px; }
.day-ok { fill: var(--ok); }
.day-warn { fill: var(--warn); }
.day-down { fill: var(--down); }
.day-none { fill: var(--none); }
.uptime-axis { display: flex; justify-content: space-between; margin-top: 0.3rem; color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.uptime-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin: 1rem 0 0; }
.uptime-stats dt { color: var(--muted); font: 600 0.78rem var(--mono); }
.uptime-stats dd { margin: 0.1rem 0 0; font-size: 1.05rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.sparkline { display: block; width: 100%; height: 36px; margin-top: 0.8rem; }
.sparkline polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }

.incidents { display: grid; gap: 0.75rem; margin: 0; padding: 0; list-style: none; }
.incident { padding: 1rem 1.2rem; border: 1px solid var(--line); border-left: 4px solid var(--none); border-radius: 10px; background: var(--surface); }
.incident-resolved { border-left-color: var(--ok); }
.incident-ongoing { border-left-color: var(--down); }
.incident-note { border-left-color: var(--accent); }
.incident h3 { margin: 0 0 0.3rem; font-size: 1rem; font-weight: 800; }
.incident p { margin: 0; color: var(--muted); font-size: 0.92rem; }

/* ---------- Changelog ---------- */

.changelog { display: grid; gap: 1.75rem; margin: 0; padding: 0; list-style: none; }
.changelog-day h2 { margin: 0 0 0.6rem; color: var(--muted); font: 700 0.9rem var(--mono); }
.changelog-day ul { display: grid; gap: 0.5rem; margin: 0; padding: 0; list-style: none; }
.change { display: grid; grid-template-columns: 6.5rem 1fr auto; align-items: baseline; gap: 0.9rem; padding: 0.75rem 1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.change-type { justify-self: start; padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--chart-bg); color: var(--muted); font: 800 0.72rem/1.6 var(--mono); }
.type-feature { background: var(--elite-soft); color: var(--elite-text); }
.type-fix { background: var(--warn-soft); color: var(--warn-text); }
.type-ci { background: var(--ok-soft); color: var(--ok-text); }
.type-library { background: var(--accent-soft); color: var(--accent-text); }
.change-text { font-weight: 600; overflow-wrap: anywhere; }
.change-sha { font-size: 0.85rem; text-decoration: none; }
.change-sha:hover { text-decoration: underline; }

/* ---------- Responsive ---------- */

@media (max-width: 60rem) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .arch-grid { grid-template-columns: 1fr 1fr; grid-template-areas: "push repo" "dependabot actions" "uptime pages" "steam browser" ". worker"; gap: 2rem 1.5rem; }
}
@media (max-width: 40rem) {
  .metric-grid { grid-template-columns: 1fr; }
  .uptime-stats { grid-template-columns: 1fr 1fr; }
  .replay-step { grid-template-columns: 1.2rem 1fr 3.5rem; }
  .step-bar { grid-column: 2 / -1; }
  .arch { padding: 1rem; }
  .arch-edges { display: none; }
  .arch-grid { grid-template-columns: 1fr; grid-template-areas: none; gap: 0.6rem; }
  .arch-node { grid-area: auto !important; }
  .arch-detail { position: relative; top: auto; min-width: 0; margin-top: 0.5rem; }
  .change { grid-template-columns: 1fr auto; }
  .change-type { grid-column: 1 / -1; }
  .subnav ul { display: flex; }
  .subnav li { flex: 1; }
  .subnav a { justify-content: center; padding: 0 0.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .replay.is-playing .replay-step.is-running .step-state { animation: none; }
}
