/*
 * Application styles.
 *
 * No colours here: every value comes from `theme.css`, which is generated from
 * `src/theme/tokens.ts`. A hex in this file would be a colour outside the design system, and one that
 * would not change when the theme does — which is exactly how the dev harness drifted.
 *
 * Layout only, plus the two things a design system cannot express: how the shell's regions divide the
 * viewport, and how the observation canvas fills the space the header leaves.
 */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--nouma-background);
  color: var(--nouma-text);
  font-family: var(--nouma-font-body);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

/* ---------------------------------------------------------------- shell */

.shell-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--nouma-border);
  background: var(--nouma-surface);
}

.shell-brand {
  color: var(--nouma-accent);
  font-family: var(--nouma-font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-decoration: none;
}

.shell-nav {
  display: flex;
  gap: 18px;
  margin-right: auto;
}

.shell-nav a {
  color: var(--nouma-text-muted);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
}

.shell-nav a:hover {
  color: var(--nouma-text);
}

/* The active link is marked by the router, never by the click handler. */
.shell-nav a[aria-current="page"] {
  color: var(--nouma-accent);
  border-bottom-color: var(--nouma-accent);
}

.shell-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.shell-status {
  font-family: var(--nouma-font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nouma-text-muted);
}

.shell-status[data-tone="ok"] {
  color: var(--nouma-accent-alt);
}

.shell-status[data-tone="warn"] {
  color: var(--nouma-burn);
}

.shell-status[data-tone="alarm"] {
  color: var(--nouma-alarm);
}

.shell-theme {
  padding: 6px 12px;
  border: 1px solid var(--nouma-border);
  border-radius: 4px;
  background: transparent;
  color: var(--nouma-text-muted);
  font-family: var(--nouma-font-mono);
  font-size: 11px;
  cursor: pointer;
}

.shell-theme:hover {
  color: var(--nouma-text);
  border-color: var(--nouma-accent-alt);
}

.shell-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ------------------------------------------------------------- home page */

.home-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 56px 24px 72px;
}

.home-header h1 {
  margin: 0;
  font-family: var(--nouma-font-display);
  font-size: 44px;
  letter-spacing: 0.2em;
  color: var(--nouma-accent);
}

.home-tagline {
  margin: 12px 0 0;
  color: var(--nouma-text-muted);
  font-size: 15px;
  line-height: 1.7;
}

/* Sections share a rhythm and a hairline, so the page reads as three movements rather than as an
   undifferentiated scroll. */
.home-window,
.home-migration,
.home-narrative {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--nouma-border);
}

.home-window h2,
.home-migration h2 {
  margin: 0 0 16px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--nouma-gene);
}

.home-figures {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin: 0 0 28px;
}

.home-figures dt {
  margin: 0;
  color: var(--nouma-text-muted);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.home-figures dd {
  margin: 5px 0 0;
  color: var(--nouma-text);
  font-family: var(--nouma-font-mono);
  font-size: 20px;
}

.home-entry {
  display: inline-block;
  padding: 10px 20px;
  border: 1px solid var(--nouma-accent);
  border-radius: 4px;
  color: var(--nouma-accent);
  font-size: 14px;
  text-decoration: none;
}

.home-entry:hover {
  background: var(--nouma-surface-raised);
}

.home-migration-body {
  margin: 0;
  color: var(--nouma-text);
  font-family: var(--nouma-font-mono);
  font-size: 14px;
}

.home-narrative p {
  margin: 0 0 18px;
  color: var(--nouma-text-muted);
  font-size: 14px;
  line-height: 1.9;
}

/* The one paragraph that is a disclosure rather than narrative. */
.home-note {
  padding-top: 14px;
  border-top: 1px dashed var(--nouma-border);
  color: var(--nouma-burn);
  font-size: 12px;
  line-height: 1.8;
}

/* ------------------------------------------------------ observation hall */

.swarm-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* The canvas fills what is left. `min-height: 0` above is what lets a flex child shrink below its
   content size, without which the stage would grow the page instead of scrolling nothing. */
.swarm-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: var(--nouma-background);
}

.swarm-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* The band reports one value, so it is one colour. A gradient would imply a range. */
.temperature-band {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--band, var(--nouma-accent-alt));
  transition: background 600ms linear;
}

.swarm-readout {
  position: absolute;
  top: 16px;
  left: 20px;
  display: flex;
  gap: 28px;
  margin: 0;
  pointer-events: none;
}

.swarm-readout dt {
  margin: 0;
  color: var(--nouma-text-muted);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.swarm-readout dd {
  margin: 4px 0 0;
  color: var(--nouma-text);
  font-family: var(--nouma-font-mono);
  font-size: 15px;
}

.swarm-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-top: 1px solid var(--nouma-border);
  background: var(--nouma-surface);
}

.swarm-module,
.swarm-intensity {
  font-family: var(--nouma-font-mono);
  font-size: 12px;
  color: var(--nouma-text);
  background: var(--nouma-surface-raised);
  border: 1px solid var(--nouma-border);
  border-radius: 4px;
  padding: 7px 10px;
}

.swarm-poke {
  padding: 8px 18px;
  border: 1px solid var(--nouma-burn);
  border-radius: 4px;
  background: transparent;
  color: var(--nouma-burn);
  font-family: var(--nouma-font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.swarm-poke:hover:not(:disabled) {
  background: var(--nouma-surface-raised);
}

.swarm-poke:disabled {
  opacity: 0.5;
  cursor: progress;
}

.swarm-poke-result {
  font-family: var(--nouma-font-mono);
  font-size: 11px;
  color: var(--nouma-text-muted);
}

/* --------------------------------------------------- chronicle / inspector */

.page-subtitle {
  margin: 6px 0 22px;
  color: var(--nouma-text-muted);
  font-size: 13px;
  line-height: 1.7;
  word-break: break-word;
}

/* Shown while a lazily-loaded screen is fetched. It replaces the previous screen, so it has to be
   something other than a blank page — a blank page looks like a broken link. */
.page-loading {
  padding: 64px 24px;
  color: var(--nouma-text-muted);
  font-family: var(--nouma-font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
}

/* ------------------------------------------------------------------ docs page */

.docs-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.docs-page h2 {
  margin: 0;
  font-family: var(--nouma-font-display);
  font-size: 22px;
  letter-spacing: 0.08em;
  color: var(--nouma-accent);
}

.docs-section {
  margin-top: 34px;
}

.docs-section h3 {
  margin: 0 0 6px;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--nouma-gene);
}

.docs-intro {
  margin: 0 0 14px;
  color: var(--nouma-text-muted);
  font-size: 12px;
  line-height: 1.8;
}

.docs-list {
  margin: 0;
  padding-left: 18px;
  color: var(--nouma-text-muted);
  font-size: 12px;
  line-height: 2;
}

.docs-list code {
  font-family: var(--nouma-font-mono);
  font-size: 11px;
  color: var(--nouma-text);
}

.docs-list a {
  color: var(--nouma-accent);
  text-decoration: none;
  border-bottom: 1px solid var(--nouma-border);
}

.docs-list a:hover {
  border-bottom-color: var(--nouma-accent);
}

.docs-where {
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid var(--nouma-border);
  color: var(--nouma-text-muted);
  font-family: var(--nouma-font-mono);
  font-size: 11px;
}

/* ----------------------------------------------- contract panels (M5/M6/M7/M10) */

.contract-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.contract-page h2 {
  margin: 0;
  font-family: var(--nouma-font-display);
  font-size: 22px;
  letter-spacing: 0.08em;
  color: var(--nouma-accent);
}

.contract-explain {
  margin-bottom: 22px;
  color: var(--nouma-text-muted);
  font-size: 12px;
}

.contract-explain summary {
  cursor: pointer;
  letter-spacing: 0.06em;
}

.contract-explain ul {
  margin: 10px 0 0;
  padding-left: 18px;
  line-height: 1.9;
}

/* -------------------------------------------------------------- canary page */

.canary-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.canary-page h2 {
  margin: 0;
  font-family: var(--nouma-font-display);
  font-size: 22px;
  letter-spacing: 0.08em;
  color: var(--nouma-accent);
}

/*
 * A caveat about data the protocol does not measure.
 *
 * Styled to read as prose rather than as a figure: it sits beside the metric cards, and anything that
 * looks like one would be read as a value — which is the mistake this component exists to prevent.
 */
.notice {
  padding: 14px 16px;
  border: 1px solid var(--nouma-border);
  border-left: 3px solid var(--nouma-burn);
  border-radius: 4px;
  background: var(--nouma-surface);
}

.notice[data-tone="alarm"] {
  border-left-color: var(--nouma-alarm);
}

.notice-title {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--nouma-burn);
}

.notice[data-tone="alarm"] .notice-title {
  color: var(--nouma-alarm);
}

.notice-lines {
  margin: 0;
  padding-left: 18px;
  color: var(--nouma-text-muted);
  font-size: 12px;
  line-height: 1.8;
}

.chronicle-page,
.inspector-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.chronicle-page h2,
.inspector-page h2 {
  margin: 0;
  font-family: var(--nouma-font-display);
  font-size: 22px;
  letter-spacing: 0.08em;
  color: var(--nouma-accent);
}

.inspector-picker {
  margin-bottom: 20px;
}

.inspector-picker select {
  font-family: var(--nouma-font-mono);
  font-size: 12px;
  color: var(--nouma-text);
  background: var(--nouma-surface-raised);
  border: 1px solid var(--nouma-border);
  border-radius: 4px;
  padding: 7px 10px;
}

/* ------------------------------------------------------------- reduced motion */

/* Respect a reduced-motion preference: the particles are the point, but a pulsing glow is not worth
   making someone ill over. */
@media (prefers-reduced-motion: reduce) {
  .temperature-band {
    transition: none;
  }
}
