:root {
  --background: #060a13;
  --surface: #0b1120;
  --surface-2: #101a30;
  --surface-3: #16223d;
  --foreground: #e8edf7;
  --muted: #8da0bf;
  --accent: #3b82f6;
  --accent-soft: #7fb1ff;
  --ok: #34d399;
  --part: #fbbf24;
  --down: #f87171;
  --none: #17223a;
  --state: var(--muted);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --dur-press: 140ms;
  --dur-hover: 200ms;

  --gutter: clamp(16px, 4vw, 32px);
  --frame: 1040px;
  --radius: 14px;
  color-scheme: dark;
}

body[data-state="operational"] { --state: var(--ok); }
body[data-state="degraded"] { --state: var(--part); }
body[data-state="outage"] { --state: var(--down); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: 400 1rem/1.55 Geist, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: color-mix(in oklab, currentColor 40%, transparent); text-underline-offset: 3px; }
h1, h2, h3, p, dl, dd { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 3px; border-radius: 6px; }
::selection { background: color-mix(in oklab, var(--accent) 45%, transparent); }

.bar, main, .discord-band, .foot { width: min(100% - 2 * var(--gutter), var(--frame)); margin-inline: auto; }

/* Top bar */
.bar { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1.0625rem; text-decoration: none; letter-spacing: -0.01em; }
.brand-sub { color: var(--muted); font-weight: 500; }
.bar nav { display: flex; align-items: center; gap: 8px; }
.bar nav a, .lang {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px;
  border-radius: 999px; text-decoration: none; font-size: 0.9375rem; font-weight: 500;
  background: var(--surface); border: 0; cursor: pointer;
  transition: background-color var(--dur-hover) ease, transform var(--dur-press) var(--ease-out);
}
@media (hover: hover) and (pointer: fine) {
  .bar nav a:hover, .lang:hover { background: var(--surface-2); }
}
.press:active { transform: scale(0.97); }

/* Hero: the whole field takes the colour of the current state */
.hero {
  position: relative;
  margin-top: 92px;
  display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 24px 40px;
  padding: clamp(22px, 3.2vw, 36px) clamp(20px, 3.5vw, 40px);
  border-radius: calc(var(--radius) + 6px);
  background: color-mix(in oklab, var(--state) 11%, var(--surface));
  transition: background-color 600ms ease;
}
.hero h1 {
  display: flex; align-items: center; gap: 0.32em;
  font-size: clamp(1.75rem, 3.4vw, 2.75rem); line-height: 1.05; letter-spacing: -0.04em; font-weight: 650;
  text-wrap: balance;
}
.dot { position: relative; flex: none; width: 0.42em; height: 0.42em; border-radius: 50%; background: var(--state); transition: background-color 600ms ease; }
body:not([data-state="loading"]) .dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--state);
  animation: pulse 2.4s var(--ease-out) infinite;
}
@keyframes pulse { from { transform: scale(1); opacity: 0.55; } to { transform: scale(2.6); opacity: 0; } }
.lede { margin-top: 12px; max-width: 52ch; font-size: 1rem; color: var(--foreground); }
#ago { color: var(--muted); }
.hero-figure { text-align: right; }
.hero-figure dt { color: var(--muted); font-size: 0.9375rem; }
.hero-figure dd { font-size: clamp(1.75rem, 3vw, 2.5rem); font-weight: 600; letter-spacing: -0.04em; line-height: 1.05; }

/* Sections */
main > section + section { margin-top: clamp(44px, 5vw, 64px); }
h2 { font-size: clamp(1.25rem, 1.8vw, 1.5rem); font-weight: 650; letter-spacing: -0.025em; line-height: 1.1; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px 24px; margin-bottom: 18px; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: var(--muted); font-size: 0.875rem; }
.key { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.key + span { margin-right: 10px; }
.key.ok, .b-ok { background: var(--ok); }
.key.part, .b-part { background: var(--part); }
.key.down, .b-down { background: var(--down); }
.key.none, .b-none { background: var(--none); }
.note { color: var(--muted); }

/* Service groups */
.group + .group { margin-top: 24px; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 10px; }
.group-head h3 { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; }
.group-head span { color: var(--muted); font-size: 0.9375rem; }
.rows { display: grid; gap: 3px; border-radius: var(--radius); overflow: hidden; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr) 228px; align-items: center; gap: 12px 28px;
  padding: 14px 20px; background: var(--surface);
}
.svc-name { font-weight: 600; font-size: 0.9375rem; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.svc-desc { color: var(--muted); font-size: 0.875rem; margin-top: 2px; }
.svc-state { text-align: right; }
.svc-state strong { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.9375rem; }
.svc-state strong::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.s-operational { color: var(--ok); }
.s-degraded { color: var(--part); }
.s-outage { color: var(--down); }
.svc-state small { display: block; white-space: nowrap; color: var(--muted); font-size: 0.875rem; margin-top: 2px; }

.bars { display: flex; gap: 2px; height: 26px; }
.bars i {
  flex: 1 1 0; min-width: 0; border-radius: 2px; transform-origin: 50% 100%;
  transition: opacity var(--dur-hover) ease;
}
.bars:hover i { opacity: 0.55; }
.bars i:hover, .bars i.is-active { opacity: 1; }
.bars-scale { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); font-size: 0.75rem; }
.bars-scale b { color: var(--foreground); font-weight: 500; }

/* Incidents */
.incidents-active h2 { margin-bottom: 14px; }
.incident {
  padding: clamp(16px, 2.2vw, 22px) clamp(16px, 2.5vw, 24px); border-radius: var(--radius);
  background: color-mix(in oklab, var(--impact, var(--part)) 12%, var(--surface));
}
.incident + .incident { margin-top: 12px; }
.incident[data-impact="outage"] { --impact: var(--down); }
.incident[data-impact="maintenance"] { --impact: var(--accent); }
.incident h3 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -0.015em; }
.incident-meta { color: var(--muted); font-size: 0.9375rem; margin-top: 4px; }
.incident-meta strong { color: var(--impact, var(--part)); font-weight: 600; }
.updates { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 14px; }
.updates li { display: grid; grid-template-columns: 9.5rem 1fr; gap: 4px 20px; }
.updates time { color: var(--muted); font-size: 0.9375rem; }

.history h2 { margin-bottom: 12px; }
.past { display: grid; grid-template-columns: 9.5rem 1fr; gap: 6px 24px; padding: 12px 0; }
.past + .past { margin-top: 3px; }
.past time { color: var(--muted); }
.past h3 { font-size: 1.0625rem; font-weight: 600; }
.past p { color: var(--muted); margin-top: 2px; }

/* Footer: the name returns */
.foot { margin-top: clamp(64px, 8vw, 104px); padding-bottom: 32px; }
.foot-name {
  font-size: 1em; font-weight: 700; letter-spacing: -0.06em; line-height: 0.8;
  color: var(--surface-2); user-select: none;
}
.foot-meta { margin-top: 18px; color: var(--muted); font-size: 0.9375rem; }

/* Tooltip floats, so it is the one thing with a shadow */
.tip {
  position: fixed; z-index: 10; left: 0; top: 0; pointer-events: none;
  padding: 10px 12px; border-radius: 10px; background: var(--surface-3); color: var(--foreground);
  font-size: 0.875rem; line-height: 1.4; white-space: nowrap;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.45);
  transform-origin: 50% 100%;
  transition: opacity 125ms ease-out, transform 125ms var(--ease-out);
}
.tip[data-hidden] { opacity: 0; transform: translate(var(--x), var(--y)) scale(0.97); }
.tip:not([data-hidden]) { opacity: 1; transform: translate(var(--x), var(--y)); }
.tip[data-instant] { transition-duration: 0ms; }
.tip b { font-weight: 600; }
.tip span { color: var(--muted); }

/* Entrance, once, on first render */
.enter { animation: rise 560ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
.enter .bars i { animation: grow 460ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms + 120ms + var(--b) * 3ms); }
@keyframes grow { from { opacity: 0; transform: scaleY(0.35); } }

@media (prefers-reduced-motion: reduce) {
  .enter, .enter .bars i { animation-name: fade; }
  @keyframes fade { from { opacity: 0; } }
  .dot::after { animation: none !important; display: none; }
  .px-layer, .px-bob, .px-fly, .px-flutter, .px-hop, .mascot-body, .art-leaf, .leaf-sway { animation: none !important; }
  .sky { display: none; }
  .press:active { transform: none; }
  .tip { transition: opacity 125ms ease-out; }
}

/* Pixel layer (shared look with torchlite.host's seasonal sprites) */
.px-sprite { position: relative; display: block; width: calc(var(--w) * var(--px, 4px)); height: calc(var(--h) * var(--px, 4px)); overflow: hidden; }
.px-sprite > svg { position: absolute; top: 0; left: 0; display: block; height: 100%; }
.px-layer { animation: var(--anim); }
.px-stage[data-paused] *, .px-stage[data-paused] *::before { animation-play-state: paused !important; }

.discord { background: #5865f2 !important; color: #fff; gap: 8px; }
@media (hover: hover) and (pointer: fine) { .bar nav a.discord:hover { background: #4752c4 !important; } }
.clyde { --px: 1.25px; flex: none; }

/* The flame stands on the hero's top edge and says how things are. */
.mascot {
  --px: 4px;
  position: absolute; right: clamp(20px, 22%, 280px); bottom: 100%; margin-bottom: -2px;
  padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.mascot-body { display: block; transform-origin: 50% 100%; }
.mascot .px-say {
  position: absolute; bottom: 58%; right: calc(100% + 12px);
  padding: 5px 11px; background: #f8fafc; color: #0b1020;
  font-size: 0.8125rem; font-weight: 600; line-height: 18px; white-space: nowrap;
  box-shadow: 0 3px 0 #94a3b8;
}
.mascot .px-say::after { content: ""; position: absolute; left: 100%; bottom: 4px; width: 7px; height: 9px; background: inherit; clip-path: polygon(0 0, 100% 100%, 0 100%); }
.px-pop { animation: px-pop 320ms var(--ease-out); }
@keyframes px-pop { from { opacity: 0.4; transform: translateY(4px) scale(0.94); } }
@keyframes px-hop {
  0% { transform: none; } 16% { transform: scale(1.12, 0.86); }
  46% { transform: translateY(calc(var(--px) * -9)) scale(0.94, 1.08); }
  76% { transform: scale(1.08, 0.92); } 100% { transform: none; }
}
.px-hop { animation: px-hop 620ms var(--ease-out); }
body[data-state="outage"] .mascot-body { animation: px-shake 2.8s ease-in-out infinite; }
@keyframes px-shake { 0%, 84%, 100% { transform: none; } 88% { transform: translateX(-2px); } 92% { transform: translateX(2px); } 96% { transform: translateX(-1px); } }

/* Bats cross above the hero in Halloween season. */
.sky { position: absolute; left: 0; right: 0; bottom: 100%; height: 108px; overflow: hidden; pointer-events: none; container-type: size; }
.sky .px-sprite { --px: 3px; }
@keyframes px-fly { 0% { transform: translateX(-60px); } 45%, 100% { transform: translateX(calc(100cqw + 60px)); } }
.px-fly { position: absolute; left: 0; animation: px-fly var(--dur) linear var(--delay) infinite backwards; }
@keyframes px-flutter { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(var(--lift)); } }
.px-flutter { display: block; animation: px-flutter 1.3s ease-in-out infinite; }
@keyframes px-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(calc(var(--px) * -2)); } }
.px-bob { animation: px-bob 2.6s ease-in-out infinite; }

/* Each group carries a lantern: lit, flickering amber, or gone dark. */
.group-head h3 { display: flex; align-items: center; gap: 12px; }
.lamp { --px: 2px; flex: none; }

/* Discord band: a whole field of blurple */
.discord-band {
  margin-top: clamp(44px, 5vw, 64px);
  display: grid; grid-template-columns: 1.3fr 1fr; align-items: center; gap: 24px;
  padding: clamp(22px, 3.2vw, 36px) clamp(20px, 3.5vw, 40px); border-radius: calc(var(--radius) + 6px);
  background: #5865f2; color: #fff; overflow: hidden;
}
.discord-band h2 { font-size: clamp(1.375rem, 2.4vw, 1.875rem); letter-spacing: -0.035em; }
.discord-band p { margin-top: 8px; max-width: 44ch; font-size: 0.9375rem; }
.btn-discord {
  margin-top: 18px; display: inline-flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 18px;
  background: #0b1020; color: #fff; border-radius: 999px; font-weight: 600; text-decoration: none;
  transition: background-color var(--dur-hover) ease, transform var(--dur-press) var(--ease-out);
}
.btn-discord .clyde { --px: 1.5px; }
@media (hover: hover) and (pointer: fine) { .btn-discord:hover { background: #1e1f5c; } }
.band-art { display: flex; align-items: flex-end; justify-content: center; gap: 20px; min-height: 0; }
.art-critter { --px: inherit; }
.art-flame { --px: 4px; }
/* The leaf hovers over the critter's head, swaying like it's about to land. */
.art-critter-wrap { position: relative; display: block; padding-top: calc(var(--px, 5px) * 12); --px: 5px; }
.art-leaf { position: absolute; top: 0; left: 38%; --px: inherit; animation: leaf-float 3.2s ease-in-out infinite; }
.leaf-sway { display: block; transform-origin: 50% 100%; animation: leaf-sway 1.6s ease-in-out infinite alternate; }
@keyframes leaf-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(calc(var(--px) * 2)); } }
@keyframes leaf-sway { from { transform: rotate(-14deg); } to { transform: rotate(10deg); } }

/* Footer props sit on the wordmark during the season. */
.foot-stage { position: relative; width: fit-content; font-size: clamp(3rem, 10vw, 7.5rem); }
.prop { position: absolute; bottom: calc(100% - 0.1em); display: none; --px: 3px; }
.prop-1 { left: 2%; } .prop-2 { left: 42%; } .prop-3 { left: calc(100% + 0.06em); bottom: 0.02em; --px: 3px; }
body[data-season] .prop { display: block; }
body[data-season="autumn"] .prop-2 { display: none; }

/* Tablet and phone: each row becomes its own small composition */
@media (max-width: 860px) {
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row .uptime { grid-column: 1 / -1; grid-row: 2; }
  .row > div:first-child { min-width: 9rem; }
  .svc-state { max-width: 42vw; }
  .svc-state small { white-space: normal; }
}
@media (max-width: 600px) {
  .bar { height: 64px; }
  .brand-sub { display: none; }
  .hero { grid-template-columns: 1fr; align-items: start; }
  .hero-figure { text-align: left; }
  .lede { font-size: 1rem; }
  .row { padding: 14px; gap: 10px 14px; }
  .bars { height: 24px; gap: 1px; }
  .updates li, .past { grid-template-columns: 1fr; }
  .hide-sm { display: none !important; }
  .hero { margin-top: 76px; }
  .mascot { --px: 3.25px; right: 20px; }
  .discord-band { grid-template-columns: 1fr; }
  .band-art { min-height: 0; justify-content: flex-start; }
  .art-critter-wrap { --px: 3.5px; } .art-flame { --px: 3.25px; }
  .prop { --px: 2.5px; } .prop-3 { --px: 2px; }
}
