/* homesentinel · "lights out at home"
   Warm ink, one lamp-coloured accent that follows the state of the server. */

:root {
  --bg: #0c0b09;
  --bg-raise: #14120f;
  --ink: #efe8dc;
  --ink-2: #bcb3a4;
  --ink-3: #8f8778;
  --line: rgba(239, 232, 220, 0.11);
  --line-strong: rgba(239, 232, 220, 0.22);

  --ok: #93d89a;
  --warn: #ffb547;
  --bad: #ff8466;
  --moved: #9cc3ff;
  --tone: var(--warn);

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Geist", ui-sans-serif, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --gutter: clamp(16px, 4.5vw, 56px);
  --max: 1180px;
  --radius: 14px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-mask: cubic-bezier(0.77, 0, 0.18, 1);

  color-scheme: dark;
}

body[data-tone="ok"] { --tone: var(--ok); }
body[data-tone="warn"], body[data-tone="wait"] { --tone: var(--warn); }
body[data-tone="bad"] { --tone: var(--bad); }
body[data-tone="moved"] { --tone: var(--moved); }

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

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.6 var(--sans);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }
p { margin: 0; }
h1, h2 { margin: 0; font-weight: 400; }
button { font: inherit; }

:focus-visible {
  outline: 2px solid var(--tone);
  outline-offset: 3px;
  border-radius: 6px;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 50;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}
.skip:focus { top: 12px; }

/* Atmosphere: a lamp glow in the state colour, and film grain. */
.glow {
  position: fixed;
  inset: -20vh -10vw auto auto;
  width: 90vw;
  height: 90vh;
  pointer-events: none;
  background: radial-gradient(closest-side, color-mix(in oklab, var(--tone) 16%, transparent), transparent 72%);
  opacity: 0.85;
  transition: background 1.2s ease;
  z-index: 0;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Top bar ─────────────────────────────────────────── */
.bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: var(--max);
  margin: 0 auto;
  padding: 22px var(--gutter);
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--ink-2);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  text-decoration: none;
  color: var(--ink);
}
.brand-sub { color: var(--ink-3); margin-left: -6px; }
.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--line-strong);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--tone);
  box-shadow: 0 0 8px var(--tone);
}

.clock { white-space: nowrap; font-variant-numeric: tabular-nums; flex: none; }
.clock-label { color: var(--ink-3); }
.brand { min-width: 0; }
.brand > span:not(.brand-mark) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 480px) {
  .clock-label, .brand-sub { display: none; }
}

/* ── Layout ─────────────────────────────────────────── */
main {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter) clamp(56px, 10vw, 120px);
}

/* ── Hero ───────────────────────────────────────────── */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(32px, 5vw, 64px);
  padding: clamp(40px, 9vw, 112px) 0 clamp(48px, 8vw, 96px);
}

@media (min-width: 940px) {
  .hero { grid-template-columns: minmax(0, 1fr) 300px; align-items: end; }
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  color: var(--tone);
  margin-bottom: 22px;
  transition: color 0.6s ease;
}

.led {
  position: relative;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--tone);
  box-shadow: 0 0 0 4px color-mix(in oklab, var(--tone) 18%, transparent), 0 0 18px var(--tone);
  transition: background 0.6s ease, box-shadow 0.6s ease;
}
body:not([data-tone="ok"]) .led { animation: blink 2.4s steps(1, end) infinite; }

@keyframes blink {
  0%, 62% { opacity: 1; }
  63%, 70% { opacity: 0.25; }
  71%, 100% { opacity: 1; }
}

.headline {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 1.2rem + 5.6vw, 6.4rem);
  line-height: 0.96;
  letter-spacing: -0.022em;
  text-wrap: balance;
  max-width: 15ch;
}
.headline em {
  font-style: italic;
  color: var(--tone);
  transition: color 0.6s ease;
}
.headline.swap { animation: mask-up 0.9s var(--ease-mask) both; }

@keyframes mask-up {
  from { clip-path: inset(0 0 100% 0); transform: translateY(0.18em); }
  to { clip-path: inset(0 0 -0.2em 0); transform: none; }
}

.lede {
  margin-top: 26px;
  max-width: 56ch;
  font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
  line-height: 1.55;
  color: var(--ink-2);
  text-wrap: pretty;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}
.actions:empty { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 0.9375rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.25s var(--ease-out), background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--tone); color: var(--bg); }
.btn-primary:hover { background: color-mix(in oklab, var(--tone) 86%, white); }
.btn-ghost { border-color: var(--line-strong); color: var(--ink); background: transparent; }
.btn-ghost:hover { border-color: var(--ink-2); background: rgba(239, 232, 220, 0.04); }
.btn[disabled] { opacity: 0.5; cursor: progress; }
.btn .arrow { transition: transform 0.25s var(--ease-out); }
.btn:hover .arrow { transform: translateX(3px); }

.return-note {
  margin-top: 18px;
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--ink-2);
}
.return-note button {
  margin-left: 8px;
  padding: 4px 2px;
  min-height: 32px;
  background: none;
  border: 0;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* Technical readout, like the back of a router. */
.readout {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.8125rem;
  border-top: 1px solid var(--line-strong);
}
.readout div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.readout dt { color: var(--ink-3); }
.readout dd { margin: 0; text-align: right; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ── Sections ───────────────────────────────────────── */
.panel {
  position: relative;
  padding: clamp(28px, 4vw, 44px) 0 clamp(36px, 5vw, 56px);
  border-top: 1px solid var(--line-strong);
}

.panel-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: clamp(22px, 3vw, 34px);
}
.kicker {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-3);
  min-width: 2ch;
}
.panel h2 {
  font-family: var(--serif);
  font-size: clamp(1.75rem, 1.3rem + 1.6vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 900px) {
  .split { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: clamp(32px, 5vw, 72px); }
}

/* Clip-path reveal (recipe 08): the window opens, the content barely moves. */
html.js .reveal {
  clip-path: inset(10% 3% 22% 3% round 18px);
  transition: clip-path 1.1s var(--ease-mask);
}
html.js .reveal > * {
  opacity: 0.001;
  transform: translateY(14px);
  transition: opacity 0.8s ease 0.15s, transform 1.2s var(--ease-out) 0.1s;
}
html.js .reveal.is-in { clip-path: inset(0 0 0 0 round 0px); }
html.js .reveal.is-in > * { opacity: 1; transform: none; }

/* ── Signal chain ───────────────────────────────────── */
.chain {
  --dot: 16px;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(var(--count, 6), minmax(0, 1fr));
  counter-reset: hop;
}

.hop {
  position: relative;
  padding-top: calc(var(--dot) + 22px);
  padding-right: 12px;
}

/* the line leading INTO this hop from the previous one.
   Grid tracks are equal, so the previous dot sits exactly one track (100%) to the left. */
.hop + .hop::before {
  content: "";
  position: absolute;
  top: calc(var(--dot) / 2 - 1px);
  left: calc(-100% + var(--dot) + 6px);
  width: calc(100% - var(--dot) - 12px);
  height: 2px;
  border-radius: 2px;
  background: var(--line);
}
.hop[data-link="live"]::before {
  background: repeating-linear-gradient(90deg, var(--ok) 0 10px, transparent 10px 18px);
  background-size: 36px 2px;
  opacity: 0.85;
  animation: flow 1.2s linear infinite;
}
.hop[data-link="broken"]::before {
  background: linear-gradient(90deg, var(--bad) 0 38%, transparent 38% 62%, var(--bad) 62%);
  opacity: 0.8;
}
.hop[data-link="wait"]::before {
  background: repeating-linear-gradient(90deg, var(--warn) 0 4px, transparent 4px 12px);
  background-size: 24px 2px;
  opacity: 0.6;
  animation: flow 2.4s linear infinite;
}
.hop[data-link="broken"]::after {
  content: "\d7";
  position: absolute;
  top: calc(var(--dot) / 2);
  left: calc(-50% + var(--dot) / 2);
  transform: translate(-50%, -55%);
  font: 500 1.125rem/1 var(--mono);
  color: var(--bad);
}

@keyframes flow { to { background-position: 36px 0; } }

.hop-dot {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: var(--bg);
  transition: background 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
}
.hop[data-state="ok"] .hop-dot { background: var(--ok); border-color: var(--ok); box-shadow: 0 0 14px color-mix(in oklab, var(--ok) 55%, transparent); }
.hop[data-state="fail"] .hop-dot { border-color: var(--bad); box-shadow: 0 0 0 5px color-mix(in oklab, var(--bad) 16%, transparent); }
.hop[data-state="fail"] .hop-dot::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--bad);
  animation: blink 1.8s steps(1, end) infinite;
}
.hop[data-state="wait"] .hop-dot { border-color: var(--warn); animation: breathe 1.6s ease-in-out infinite; }
.hop[data-state="moved"] .hop-dot { background: var(--moved); border-color: var(--moved); }
.hop[data-state="unknown"] .hop-dot { border-color: var(--line); background: transparent; }

@keyframes breathe {
  50% { box-shadow: 0 0 0 6px color-mix(in oklab, var(--warn) 22%, transparent); }
}

.hop-name { font-weight: 500; font-size: 0.9375rem; line-height: 1.3; }
.hop-where { display: block; margin-top: 3px; font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); overflow-wrap: anywhere; }
.hop-state { display: block; margin-top: 10px; font-family: var(--mono); font-size: 0.75rem; color: var(--ink-2); }
.hop[data-state="ok"] .hop-state { color: var(--ok); }
.hop[data-state="fail"] .hop-state { color: var(--bad); }
.hop[data-state="wait"] .hop-state { color: var(--warn); }
.hop[data-state="moved"] .hop-state { color: var(--moved); }

.chain-caption {
  margin-top: 30px;
  max-width: 68ch;
  color: var(--ink-2);
  text-wrap: pretty;
}

/* Vertical chain on narrow screens: rows share one height (1fr), so the
   previous dot is exactly one row (100%) above. */
@media (max-width: 760px) {
  .chain { grid-template-columns: minmax(0, 1fr); grid-auto-rows: 1fr; }
  .hop { padding: 0 0 24px calc(var(--dot) + 18px); }
  .hop + .hop::before {
    top: calc(-100% + var(--dot) + 6px);
    left: calc(var(--dot) / 2 - 1px);
    width: 2px;
    height: calc(100% - var(--dot) - 12px);
  }
  .hop[data-link="live"]::before { background: repeating-linear-gradient(180deg, var(--ok) 0 6px, transparent 6px 10px); background-size: 2px 20px; animation-name: flow-y; }
  .hop[data-link="wait"]::before { background: repeating-linear-gradient(180deg, var(--warn) 0 3px, transparent 3px 8px); background-size: 2px 16px; animation-name: flow-y; }
  .hop[data-link="broken"]::before { background: linear-gradient(180deg, var(--bad) 0 30%, transparent 30% 70%, var(--bad) 70%); }
  .hop[data-link="broken"]::after {
    top: calc(-50% + var(--dot) / 2);
    left: calc(var(--dot) / 2);
    transform: translate(-50%, -50%);
  }
  .hop-where { display: inline; margin-left: 8px; }
  .hop-state { margin-top: 4px; }
}

@keyframes flow-y { to { background-position: 0 20px; } }

/* ── ETA / Why ──────────────────────────────────────── */
.eta-big {
  font-family: var(--serif);
  font-size: clamp(2.1rem, 1.5rem + 2.6vw, 3.4rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-wrap: balance;
}
.eta-big em { font-style: italic; color: var(--tone); }
.eta-body { margin-top: 18px; color: var(--ink-2); max-width: 46ch; text-wrap: pretty; }
.eta-note {
  margin-top: 22px;
  padding: 14px 16px;
  border-left: 2px solid var(--tone);
  background: rgba(239, 232, 220, 0.035);
  border-radius: 0 10px 10px 0;
  color: var(--ink);
  white-space: pre-line;
}

.why-panel p { color: var(--ink-2); max-width: 54ch; text-wrap: pretty; }
.why-panel p + p { margin-top: 14px; }
.why-aside { font-family: var(--mono); font-size: 0.8125rem; color: var(--ink-3) !important; padding-top: 6px; }

/* ── Announcements ──────────────────────────────────── */
.notice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.notice {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 6px 22px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.notice:last-child { border-bottom: 0; }
.notice-date { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); padding-top: 4px; }
.notice-title { font-weight: 600; font-size: 1.0625rem; }
.notice[data-level="warn"] .notice-title::before { content: "● "; color: var(--warn); }
.notice-body { color: var(--ink-2); white-space: pre-line; margin-top: 4px; grid-column: 2; }
.notice-link { grid-column: 2; margin-top: 6px; font-family: var(--mono); font-size: 0.8125rem; color: var(--tone); text-underline-offset: 3px; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .notice { grid-template-columns: minmax(0, 1fr); }
  .notice-body, .notice-link { grid-column: 1; }
}

/* ── Site board ─────────────────────────────────────── */
.board-head { justify-content: space-between; align-items: flex-end; flex-wrap: wrap; }
.board-head > div:first-child { display: flex; align-items: baseline; gap: 18px; }
.board-tools { display: flex; align-items: center; gap: 16px; }
.board-meta { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }

.sites { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }

.site {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px 24px;
  padding: 18px 8px;
  border-bottom: 1px solid var(--line);
  transition: background 0.3s ease;
}
.site:hover { background: rgba(239, 232, 220, 0.025); }
.site.is-current { background: color-mix(in oklab, var(--tone) 7%, transparent); }

.site-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.75rem;
  text-transform: lowercase;
}
.site-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
  flex: none;
}
.site[data-status="up"] .site-status { color: var(--ok); }
.site[data-status="up"] .site-status::before { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.site[data-status="down"] .site-status { color: var(--bad); }
.site[data-status="down"] .site-status::before { background: var(--bad); }
.site[data-status="moved"] .site-status { color: var(--moved); }
.site[data-status="moved"] .site-status::before { background: var(--moved); }
.site[data-status="unknown"] .site-status { color: var(--warn); }
.site[data-status="unknown"] .site-status::before { background: transparent; border: 1.5px dashed var(--warn); }

.site-name { font-weight: 500; font-size: 1.0625rem; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.site-here { font-family: var(--mono); font-size: 0.6875rem; color: var(--tone); border: 1px solid currentColor; border-radius: 999px; padding: 1px 8px; }
.site-desc { color: var(--ink-3); font-size: 0.875rem; margin-top: 2px; }
.site-host { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-2); margin-top: 4px; overflow-wrap: anywhere; }

.site-side { display: flex; align-items: center; gap: 18px; justify-self: end; }
.site-metric { font-family: var(--mono); font-size: 0.75rem; color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.site-link {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  text-decoration: none;
  color: var(--ink);
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s var(--ease-out);
}
.site-link:hover { border-color: var(--ink-2); transform: rotate(-45deg); }
.site-link svg { width: 16px; height: 16px; }

@media (max-width: 680px) {
  .site { grid-template-columns: minmax(0, 1fr) auto; padding: 16px 4px; }
  .site-status { grid-column: 1 / -1; }
  .site-metric { display: none; }
}

/* ── Hyperspace footer (recipe 07): the ending of this page is the site coming back. */
.warp {
  position: relative;
  isolation: isolate;
  min-height: clamp(380px, 62vh, 600px);
  display: grid;
  place-items: center;
  padding: 80px var(--gutter) 28px;
  overflow: hidden;
  /* Fade from the page (and its glow) into deep space instead of a hard edge. */
  background: linear-gradient(to bottom, transparent, #050505 220px);
}
.tunnel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 220px);
  mask-image: linear-gradient(to bottom, transparent, #000 220px);
}
.warp-copy { position: relative; z-index: 2; text-align: center; max-width: 34ch; }
/* A dark halo keeps the copy readable over streaking stars. */
.warp-copy::before {
  content: "";
  position: absolute;
  inset: -40% -30%;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(5, 5, 5, 0.85), transparent);
}
.warp-title {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 1.4rem + 2.4vw, 3.2rem);
  line-height: 1.04;
  letter-spacing: -0.012em;
  text-wrap: balance;
}
.warp-sub { margin-top: 14px; color: var(--ink-2); text-wrap: pretty; }
.fine {
  position: relative;
  z-index: 2;
  align-self: end;
  margin-top: 40px;
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--ink-3);
  text-align: center;
}

.flash {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--ink);
  pointer-events: none;
  animation: flash 0.7s ease forwards;
}
@keyframes flash { from { opacity: 0; } 35% { opacity: 1; } to { opacity: 1; } }

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  z-index: 70;
  padding: 16px 18px;
  background: var(--bg-raise);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition-duration: 0.01ms !important; }
  html.js .reveal, html.js .reveal.is-in { clip-path: none; }
  html.js .reveal > * { opacity: 1; transform: none; }
}
