/*
 * The terminal every page is drawn on: an amber phosphor screen, after
 * webartisan.info's "80s retro style homepage", toned down for reading.
 * Glow only on the logo and headings, body text in plain warm white, faint
 * static scanlines. This file is the screen, the header and the workflow and
 * sign-in pages; app.css styles the tracker's own parts on top of it. No
 * framework, and no inline styles because of the CSP.
 */

:root {
  --crt-bg: #15120e;
  --crt-glare: #241f18;
  --crt-text: #ece3d0;   /* body text, about 14:1 on the background */
  --crt-dim: #b5a68a;    /* secondary text, about 7.5:1 */
  --crt-accent: #ffb547; /* amber: logo, headings, links, prompts */
  --crt-alert: #ff8a7a;  /* errors and hard deadlines */
  --crt-ok: #a9d98c;     /* fulfilled, more than ten days left */
  --crt-case: #9fd0e0;   /* FOIC case stages */
  --crt-rule: #5a4e3c;
  --crt-line: rgb(0 0 0 / .14);
  --crt-glow: 0 0 6px rgb(255 181 71 / .45);
  color-scheme: dark;
}

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

html { background: var(--crt-bg); }

body {
  margin: 0;
  min-height: 100vh;
  padding: 6vh 16px 4rem;
  color: var(--crt-text);
  background: radial-gradient(ellipse at top, var(--crt-glare) 0%, var(--crt-bg) 65%) fixed;
  font: 17px/1.7 ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

/* Faint scanlines. Static: a flicker makes text tiring to read. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background: repeating-linear-gradient(transparent 0 2px, var(--crt-line) 2px 4px);
}

@keyframes crt-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes crt-on {
  from { opacity: 0; }
  to { opacity: 1; }
}

a { color: var(--crt-accent); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--crt-accent); outline-offset: 2px; }

strong { color: var(--crt-accent); font-weight: 700; }

/* Statute links (core/statutes.py): never break "§ 1-206(a)" at the hyphen. */
a.statute { white-space: nowrap; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 1rem; top: 1rem; z-index: 20; padding: .25rem .5rem; background: var(--crt-bg); }

.terminal { max-width: 62rem; margin: 0 auto; }
/* Reading pages (workflow, sign-in): the header stays full width, the text column narrows. */
.terminal.slim > main { max-width: 44rem; }
.terminal p { max-width: 68ch; }

/* --- header: logo, boot lines, menu bar --- */
.site-header { margin: 0 0 2.25rem; }
.logo-link { display: block; width: max-content; max-width: 100%; text-decoration: none; }
.logo-link:hover .logo { filter: drop-shadow(0 0 5px rgb(255 181 71 / .7)); }
.site-header .boot { margin-bottom: 1.25rem; }
.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: .4rem 3ch;
  padding: .5rem 0;
  border-block: 1px dashed var(--crt-rule);
}
.topnav { display: flex; flex-wrap: wrap; gap: .2rem 2.5ch; margin: 0; padding: 0; list-style: none; }
.topnav li::before { content: "> "; color: var(--crt-dim); }
.topbar a { text-decoration: none; }
.topbar a:hover { text-decoration: underline; }
.topbar a[aria-current="page"] { padding: 0 .5ch; background: var(--crt-accent); color: var(--crt-bg); }
.topbar .account { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem 2.5ch; }

.prompt-line { margin: 2.5rem 0 0; }
.site-footer { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--crt-rule); }
.site-footer p { margin: 0 0 .5rem; }

/* The logo is an SVG of the ANSI Shadow text art (static/img/logo.svg): as text
   it fell apart on Android, whose fonts lack or misalign the box-drawing glyphs. */
.logo {
  display: block;
  width: min(21rem, 62vw);
  height: auto;
  margin: 0 0 1.25rem;
  filter: drop-shadow(var(--crt-glow));
}

.boot { margin: 0 0 2rem; font-size: .9em; line-height: 1.6; }
.boot p { margin: 0; animation: crt-on .15s steps(1, end) both; }
.boot p:nth-child(2) { animation-delay: .15s; }
.boot p:nth-child(3) { animation-delay: .3s; }
.boot p:nth-child(4) { animation-delay: .45s; }
.dim { color: var(--crt-dim); }

h2, h3 {
  color: var(--crt-accent);
  text-shadow: var(--crt-glow);
  letter-spacing: .04em;
  line-height: 1.4;
}
h2 { font-size: 1.15em; margin: 0 0 1.25rem; }
.prompt::before { content: "> "; }

/* --- forms --- */
.login { margin: 0 0 2.5rem; }

.field { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1.5ch; margin-bottom: 1rem; }
.field label { flex: 0 0 9ch; margin: 0; color: var(--crt-dim); }
.field input {
  flex: 1 1 16rem;
  min-width: 0;
  padding: .45rem .75ch;
  border: 1px solid var(--crt-rule);
  border-radius: 3px;
  background: rgb(0 0 0 / .35);
  color: var(--crt-text);
  caret-color: var(--crt-accent);
  font: inherit;
}
.field input:focus { outline: none; border-color: var(--crt-accent); box-shadow: 0 0 0 1px var(--crt-accent), var(--crt-glow); }
/* Keep browser autofill from painting the field white or yellow. */
.field input:-webkit-autofill {
  -webkit-text-fill-color: var(--crt-text);
  box-shadow: 0 0 0 100px #0e0c09 inset;
  transition: background-color 9999s;
}

.check { display: inline-flex; align-items: center; gap: 1ch; cursor: pointer; margin: .25rem 0 1.5rem; }
.check input { appearance: none; margin: 0; font: inherit; color: var(--crt-accent); cursor: pointer; }
.check input::before { content: "[ ]"; }
.check input:checked::before { content: "[x]"; }

.submit {
  padding: .5rem 3ch;
  border: 1px solid var(--crt-accent);
  border-radius: 3px;
  background: var(--crt-accent);
  color: var(--crt-bg);
  font: inherit;
  font-weight: 700;
  letter-spacing: .06em;
  box-shadow: var(--crt-glow);
  cursor: pointer;
}
.submit:hover { background: #ffc66e; }

.errors { color: var(--crt-alert); margin: 0 0 1rem; padding: 0; list-style: none; }
.errors li::before { content: "Error: "; font-weight: 700; }
.field .errors { flex-basis: 100%; margin: 0 0 0 10.5ch; }

.menu { list-style: none; margin: 0 0 2rem; padding: 0; }
.menu li { margin-bottom: .4rem; }
.menu li::before { content: "> "; color: var(--crt-dim); }

.fineprint { color: var(--crt-dim); font-size: .85em; line-height: 1.6; }

/* --- workflow: numbered steps joined by a line --- */
.alert { color: var(--crt-alert); }
.flow { list-style: none; margin: 0 0 3rem; padding: 0; }
.flow > li { position: relative; padding: 0 0 2rem 5ch; }
.flow > li::before {
  content: "";
  position: absolute;
  left: 1.5ch; top: 2.1rem; bottom: .5rem;
  border-left: 1px dashed var(--crt-rule);
}
.flow > li:last-child::before { display: none; }
.flow h3 { font-size: 1em; margin: 0 0 .5rem -5ch; }
.flow .step { display: inline-block; width: 5ch; }
.flow p { margin: 0 0 .75rem; }
.flow .meta {
  color: var(--crt-dim);
  font-size: .85em;
  line-height: 1.6;
  padding-left: 1.5ch;
  border-left: 2px solid var(--crt-rule);
}
.flow .meta b { color: var(--crt-text); font-weight: 600; }

.more { margin: 0 0 1rem; padding: .5rem 1.5ch; border: 1px dashed var(--crt-rule); border-radius: 3px; }
.more summary { color: var(--crt-accent); cursor: pointer; }
.more summary::marker { content: "[+] "; }
.more[open] summary::marker { content: "[-] "; }
.more[open] summary { margin-bottom: .75rem; }
.more ul { margin: 0 0 .75rem; padding-left: 2ch; list-style: "- "; }
.more li { margin-bottom: .2rem; }
.more cite { font-style: italic; }

.branches { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .5rem; }
.branches li {
  display: grid;
  grid-template-columns: 14ch 1fr;
  gap: 1.5ch;
  padding: .6rem 1.5ch;
  border: 1px solid var(--crt-rule);
  border-radius: 3px;
  background: rgb(0 0 0 / .2);
}
.tag { color: var(--crt-accent); font-weight: 700; font-size: .9em; letter-spacing: .04em; }
.tag.alert { color: var(--crt-alert); }

.calc {
  margin: 0 0 2.5rem;
  padding: 1.5rem 2.5ch;
  border: 1px solid var(--crt-rule);
  border-radius: 4px;
  background: rgb(0 0 0 / .25);
}
.calc .field label { flex-basis: auto; }
.calc .field input { flex: 0 1 14rem; }
.readout { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 2ch; margin: 1.75rem 0 1rem; }
.readout dt { color: var(--crt-dim); }
.readout dd { margin: 0; font-weight: 600; }

.cursor { display: inline-block; color: var(--crt-accent); animation: crt-blink 1.06s step-end infinite; }

@media (max-width: 520px) {
  body { font-size: 16px; }
  .field label { flex-basis: 100%; }
  .field .errors { margin-left: 0; }
  .flow > li { padding-left: 3ch; }
  .flow > li::before { left: .5ch; }
  .flow h3 { margin-left: -3ch; }
  .flow .step { width: 4ch; }
  .branches li { grid-template-columns: 1fr; gap: .15rem; }
  .readout { grid-template-columns: 1fr; gap: 0; }
  .readout dd { margin-bottom: .75rem; }
}

/* No blink or boot sequence for people who ask for less motion. */
@media (prefers-reduced-motion: reduce) {
  .cursor, .boot p { animation: none; }
}
