/*
  terminal.css — the shared look for everything served out of wwwroot.

  The palette, the chrome and the line vocabulary are lifted from the iOS/macOS app rather than
  invented for the web, so the site and the app read as one product:

    * colours are the app's asset-catalog values (Assets.xcassets/Terminal*.colorset, AccentGreen),
      light and dark variants included;
    * `.box` is `TerminalBox` — surface fill, 1px accent-at-35% border, radius 4, the title label
      sitting ON the top border;
    * the line prefixes mean what they mean in the app: `>` a command, `#` a note, `»` the app
      talking back, `!` an error. A reader must never have to wonder which is which.

  Accent is a single custom property for the same reason it is a single value in the app: changing
  it recolours everything. Warn and error are deliberately NOT derived from it — they are semantic,
  and amber and red are both selectable accents there.
*/

:root {
  --bg: #f5f7f0;
  --surface: #e8ede3;
  --fg: #16181c;
  --muted: #66756e;
  --accent: #1a9e66;
  --warn: #cc6b05;
  --error: #bf1f14;

  --rule: color-mix(in srgb, var(--accent) 30%, transparent);
  --edge: color-mix(in srgb, var(--muted) 26%, transparent);

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --step-0: 0.9375rem;
  --step-1: 1.0625rem;
  --step-2: 1.375rem;
  --step-3: 1.875rem;
  --step-4: 2.75rem;

  --gap: 1.15rem;
  --shell: 68rem;
  --prose: 68ch;

  /* Reflectivity bands, keyed to RadarTransferFunction's canonical floors (5 / 20 / 35 / 50 / 60
     dBZ) so a storm drawn here reads on the same scale as the app's legend and its 3D shells.
     Fixed in both themes, on a plot surface that stays dark in both — which is exactly what the app
     does with Theme.radarPlot, and for the same reason: the faintest band is a pale grey that
     disappears completely against a light background. */
  --plot: #0b1113;
  --d1: #7e8c92;
  --d2: #2fbf5f;
  --d3: #e3cf3c;
  --d4: #e5622c;
  --d5: #c0459e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0d0f;
    --surface: #141a1c;
    --fg: #e8eae9;
    --muted: #738c85;
    --accent: #5cf2ad;
    --warn: #ff941a;
    --error: #ff4d38;
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  /* Scrollbars and form controls follow the page, not the OS default. */
  color-scheme: light dark;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Anchored sections shouldn't land flush against the viewport edge. */
[id] { scroll-margin-top: 1.5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: var(--step-0)/1.65 var(--mono);
  font-variant-ligatures: none;
  overflow-wrap: break-word;
}

/* ---- shell + rhythm -------------------------------------------------- */

.shell {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 1.15rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.stack-lg { gap: 2.75rem; }

.prose { max-width: var(--prose); }

/* ---- links + focus --------------------------------------------------- */

a {
  color: var(--accent);
  text-decoration-color: var(--rule);
  text-underline-offset: 0.22em;
}

a:hover { text-decoration-color: currentColor; }

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

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--accent);
}

/* ---- top bar --------------------------------------------------------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem 1.25rem;
  padding: 1.5rem 0 0.5rem;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
  margin-left: auto;
  font-size: 0.8125rem;
}

.topbar nav a { color: var(--muted); }
.topbar nav a:hover { color: var(--accent); }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
}

/* The app icon's own artwork, traced from Assets.xcassets/AppIcon.appiconset/icon-1024.png and
   inlined as a <symbol>. It fills with `currentColor`, so it takes the accent in both themes for
   free and needs no light/dark variant — and because it is inline rather than an <img>, the page
   still issues no requests but its own stylesheet.

   Sized in `em` so it scales with whatever text it sits beside: the wordmark in the top bar and the
   --step-4 mark in the hero use the same rule. The aspect ratio comes from the viewBox (766x391). */
.logo {
  width: 1.96em;
  height: 1em;
  flex: none;
  fill: currentColor;
}

.logo-lg { width: 2.35em; height: 1.2em; }

/* ---- headings -------------------------------------------------------- */

h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  line-height: 1.2;
  text-wrap: balance;
}

h1 { font-size: var(--step-3); letter-spacing: -0.01em; }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }

p { margin: 0; }

.lede {
  font-size: var(--step-1);
  line-height: 1.6;
}

.muted { color: var(--muted); }
.accent { color: var(--accent); }

/* Caption under a figure or a demo block — the line that says what you are looking at, or that an
   illustration is an illustration. */
.fine {
  font-size: 0.8125rem;
  color: var(--muted);
}

/* A column inside .grid. `.stack` is the page-level rhythm and too loose for content that belongs
   together; this is the tighter one, for a label sitting directly above its list. */
.col {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ---- hero ------------------------------------------------------------ */

.hero {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  padding: 2.5rem 0 1rem;
}

.mark {
  display: flex;
  align-items: center;
  gap: 0.28em;
  font-size: var(--step-4);
  line-height: 1;
  color: var(--accent);
  letter-spacing: 0.06em;
}

.cursor { animation: blink 1.1s steps(1) infinite; }

@keyframes blink { 50% { opacity: 0; } }

.tagline {
  font-size: var(--step-1);
  color: var(--muted);
  max-width: var(--prose);
}

/* ---- status line (the launch CTA) ------------------------------------ */

.status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.9rem;
  padding: 0.85rem 1rem;
  border: 1px dashed var(--rule);
  border-radius: 4px;
  font-size: 0.9375rem;
}

.status .dot {
  color: var(--warn);
}

/* ---- box (TerminalBox) ----------------------------------------------- */

.box {
  position: relative;
  padding: 1.55rem 1.15rem 1.2rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
}

.box > .title {
  position: absolute;
  top: 0;
  left: 0.85rem;
  transform: translateY(-50%);
  padding: 0 0.45rem;
  background: var(--surface);
  color: var(--accent);
  font-size: 0.8125rem;
  letter-spacing: 0.05em;
  text-transform: lowercase;
}

.box.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.box.warn > .title { color: var(--warn); }

.box-body {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

/* ---- feature grid ---------------------------------------------------- */

.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}

@media (min-width: 56rem) {
  .grid { grid-template-columns: 1fr 1fr; }
}

/* ---- terminal lines -------------------------------------------------- */

.term {
  padding: 1rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
  font-size: 0.875rem;
  line-height: 1.55;
  overflow-x: auto;
}

/* Sized to the tallest demo frame so cycling never shifts the page under a reader.

   Deliberately NOT `white-space: pre`: each `.line` is a block that preserves its own spacing, so
   setting it here too renders the source newline BETWEEN two spans on top of the block break, and
   every frame comes out double-spaced. Indentation inside a line is the line's job. */
.term-body {
  min-height: 11.5rem;
}

/* A terminal line keeps its own spacing, so columns line up in a block that is NOT the full
   `.term-body` (which sets `white-space: pre` for the whole frame). Without this, runs of spaces
   collapse and every aligned column in a short block drifts. `.term` carries the `overflow-x`, so
   an over-wide line scrolls its own container rather than the page. */
.line {
  display: block;
  white-space: pre;
}
/* The four markers named at the top of this file. Colour alone does not carry the distinction —
   `.ans` and `.cmd` are both accent, and a colourblind or high-contrast reader gets no signal at
   all — so each kind states itself in a glyph, exactly as it does in the app. `.out` is deliberately
   unprefixed: it is the data the command returned, and a marker in front of every row of a table
   would be noise on the one line kind that already has a shape. */
.line.cmd { color: var(--fg); }
.line.cmd::before { content: "> "; color: var(--accent); }
.line.note { color: var(--muted); }
.line.note::before { content: "# "; }
.line.ans { color: var(--accent); }
.line.ans::before { content: "» "; }
.line.err { color: var(--error); }
.line.err::before { content: "! "; }
.line.out { color: var(--fg); }

.bar { color: var(--accent); }
.bar .off { color: var(--edge); }

/* ---- dBZ minimap ----------------------------------------------------- */

/* The `storms` command's ASCII reflectivity grid. A monospace advance is ~0.6em wide, so the rows
   are packed to ~0.62em to make each `█` read as a square cell rather than a tall rectangle. The
   glyphs overlap slightly at that spacing and paint in document order, which is what welds them
   into a solid raster; the margins keep that overspill clear of the lines above and below. */
.map {
  font-size: 0.7rem;
  line-height: 0.62;
  letter-spacing: 0;
  margin: 0.5rem 0;
  padding: 0.7rem 0.8rem;
  background: var(--plot);
  border-radius: 3px;
  /* The plot hugs its raster instead of stretching to the box. A dark panel running the full width
     with the storm in one corner reads as a layout mistake; sized to content it reads as an
     instrument. `max-width` keeps it inside the box on a narrow screen, where the font-size query
     below has already shrunk the cell to fit. */
  width: max-content;
  max-width: 100%;
}

/* 46 columns at the base size is ~310px, which overruns the content box on a small phone. Shrinking
   the cell is the only lever that keeps the grid whole — wrapping or scrolling a raster splits the
   storm in half. */
@media (max-width: 30rem) {
  .map { font-size: 0.58rem; }
}

.map .you { color: #f2f5f4; }

.map .d1 { color: var(--d1); }
.map .d2 { color: var(--d2); }
.map .d3 { color: var(--d3); }
.map .d4 { color: var(--d4); }
.map .d5 { color: var(--d5); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* A real swatch rather than a `██` glyph: block characters in CSS `content` get announced
   literally by some screen readers, which is noise over a label that already says the word. */
.legend i {
  width: 1.5em;
  height: 0.6em;
  border-radius: 1px;
  background: var(--sw, var(--muted));
}

/* ---- lists ----------------------------------------------------------- */

.checks {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.checks li::before {
  content: "[x] ";
  color: var(--accent);
}

.checks.no li::before {
  content: "[ ] ";
  color: var(--muted);
}

.dashes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.dashes li::before {
  content: "· ";
  color: var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--edge);
  border-radius: 3px;
  font-size: 0.75rem;
  color: var(--muted);
}

/* ---- footer ---------------------------------------------------------- */

footer {
  margin-top: 3.5rem;
  padding: 1.4rem 0 3.5rem;
  border-top: 1px solid var(--edge);
  color: var(--muted);
  font-size: 0.8125rem;
}

footer a { color: var(--muted); }
footer a:hover { color: var(--accent); }

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin-bottom: 0.6rem;
}

/* ---- long-form documents (privacy, terms) ---------------------------- */

.doc {
  max-width: 52rem;
  margin: 0 auto;
  padding: 2.5rem 0 0;
}

.doc h1 { margin-bottom: 0.35rem; }

.doc h2 {
  margin: 2.6rem 0 0.6rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--edge);
  font-size: var(--step-1);
  color: var(--accent);
}

.doc h3 {
  margin: 1.6rem 0 0.4rem;
  font-size: var(--step-0);
}

.doc p { margin: 0 0 0.9rem; }

.doc .meta {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 2rem;
}

.doc ul { padding-left: 1.25rem; margin: 0 0 0.9rem; }
.doc li { margin: 0.35rem 0; }

.doc strong { color: var(--fg); font-weight: 600; }

.doc table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.8rem 0;
  font-size: 0.875rem;
}

.doc th,
.doc td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--edge);
  vertical-align: top;
}

.doc th {
  color: var(--accent);
  font-weight: 600;
}

/* The life-safety callout in the Terms. Warn-tinted, never accent-tinted — amber is a selectable
   accent in the app, so state colour and brand colour stay separate here too. */
.doc .callout {
  margin: 1.4rem 0;
  padding: 1rem 1.15rem;
  background: color-mix(in srgb, var(--warn) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: 4px;
}

.doc .callout h3 {
  margin-top: 0;
  color: var(--warn);
}

/* Horizontal scroll belongs to the wide element, never the page body. */
.scroll-x { overflow-x: auto; }

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

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
