/* badvpn.dev
 *
 * Two hues carry meaning rather than decoration: phosphor amber is a packet
 * that arrived, rose is one that did not. They are used for nothing else, so
 * the live traces read as instrumentation instead of ornament.
 *
 * No web fonts: a strict CSP blocks external hosts, and embedding a face would
 * cost more than the type treatment gains. Character comes from setting the
 * system mono hard -- tight tracking, wide size range -- against plain sans
 * prose.
 */

:root {
  /* Warm near-black. Blue-black is the reflex for a dark technical page; this
     is closer to a powered-down CRT, which suits the 2003 modem register. */
  --ink: #0c0a07;
  --panel: #15110b;
  --panel-lift: #1c170f;
  --line: #2c2417;
  --line-bright: #453a25;

  --phosphor: #ffc24b; /* signal */
  --drop: #ff5c6e;     /* loss */

  --text: #ece3d0;
  --muted: #92866c;
  --dim: #6b6150;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --gutter: clamp(1.25rem, 5vw, 4rem);
  --measure: 62ch;
}

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

body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* A faint scanline wash, fixed so it does not travel with scroll. Subtle
   enough to read as screen texture rather than an effect. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 194, 75, 0.028) 0 1px,
    transparent 1px 3px
  );
}

main, .masthead, .colophon { position: relative; z-index: 1; }

a { color: var(--phosphor); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--text); }

code { font-family: var(--mono); font-size: 0.9em; color: var(--phosphor); }

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

/* ---- masthead ---- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1.5rem;
  padding: 1.5rem var(--gutter);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-family: var(--mono);
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.wordmark .tld { color: var(--dim); font-weight: 400; }
.wordmark:hover { color: var(--phosphor); }

.tagline {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}

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

.hero { padding: clamp(3rem, 9vw, 6.5rem) var(--gutter) clamp(2rem, 5vw, 3.5rem); }

.eyebrow {
  margin: 0 0 1.75rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--phosphor);
}

h1 {
  margin: 0 0 1.5rem;
  max-width: 18ch;
  font-family: var(--mono);
  font-size: clamp(2.1rem, 1.1rem + 4.4vw, 4.5rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.045em;
}

.lede {
  margin: 0;
  max-width: var(--measure);
  color: var(--muted);
  font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
}

/* ---- the trace: the signature element ----
   Ticks arrive at the mode's real interval, and drop at its real probability.
   It is a readout, not an animation. */

.trace-figure { margin: clamp(2.5rem, 6vw, 4rem) 0 0; }

.trace {
  display: flex;
  align-items: flex-end;
  /* Fills from the right like a strip chart, so the newest packet is always at
     the same edge and a slow link reads as "still arriving" rather than as an
     empty box with a few bars in the corner. */
  justify-content: flex-end;
  gap: 3px;
  height: 58px;
  padding: 0 2px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.mode-trace {
  height: 40px;
  margin: 1.25rem 0 1.5rem;
}

.tick {
  flex: 0 0 5px;
  border-radius: 1px;
  transform-origin: bottom;
  animation: tick-in 220ms ease-out both;
}

.tick-ok {
  background: var(--phosphor);
  box-shadow: 0 0 8px rgba(255, 194, 75, 0.45);
}

/* A drop is a gap with a mark at the baseline: absence you can see. */
.tick-drop {
  background: var(--drop);
  box-shadow: 0 0 10px rgba(255, 92, 110, 0.5);
}

/* Seeded history appears at once; only live arrivals animate. */
.is-seeding .tick { animation: none; }

@keyframes tick-in {
  from { transform: scaleY(0.15); opacity: 0; }
  to   { transform: scaleY(1); opacity: 1; }
}

.trace-caption {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  margin-top: 0.75rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  color: var(--dim);
}

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

.pip { width: 5px; height: 12px; border-radius: 1px; display: inline-block; }
.pip-ok { background: var(--phosphor); }
.pip-drop { background: var(--drop); }

.trace-label { margin-left: auto; color: var(--muted); }

/* ---- sections ---- */

.modes, .disclosure, .howto { padding: clamp(3rem, 7vw, 5rem) var(--gutter); }
.disclosure, .howto { border-top: 1px solid var(--line); }

.section-heading {
  margin: 0 0 0.5rem;
  font-family: var(--mono);
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.section-note, .disclosure-lede {
  margin: 0 0 2.25rem;
  max-width: var(--measure);
  color: var(--muted);
}

.disclosure-lede { color: var(--text); }

.loading { font-family: var(--mono); font-size: 0.8125rem; color: var(--dim); }

/* ---- mode cards ---- */

.mode-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
}

.mode {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
}

.mode-title {
  margin: 0 0 0.35rem;
  font-family: var(--mono);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.mode-blurb { margin: 0; color: var(--muted); font-size: 0.9375rem; }

.specs {
  display: flex;
  flex-wrap: wrap;
  gap: 0 2rem;
  margin: 0 0 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.spec dt {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
}

.spec dd {
  margin: 0.15rem 0 0;
  font-family: var(--mono);
  font-size: 1.0625rem;
  color: var(--phosphor);
}

.mode-endpoint { margin: 0 0 1.5rem; font-size: 0.8125rem; color: var(--muted); }

.endpoint-label {
  font-family: var(--mono);
  font-size: 0.625rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  margin-right: 0.5rem;
}

.endpoint-value { color: var(--text); word-break: break-all; }

/* ---- controls ---- */

.get, .copy {
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: 2px;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.get {
  margin-top: auto;
  width: 100%;
  padding: 0.85rem 1rem;
  color: var(--ink);
  background: var(--phosphor);
  border: 1px solid var(--phosphor);
}

.get:hover:not(:disabled) { background: #ffd177; border-color: #ffd177; }
.get:disabled { opacity: 0.5; cursor: wait; }

.copy {
  padding: 0.5rem 0.9rem;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line-bright);
}

.copy:hover { border-color: var(--phosphor); color: var(--phosphor); }

.mode-status {
  margin: 0.75rem 0 0;
  min-height: 1.2em;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.mode-status.is-error { color: var(--drop); }

/* ---- issued config ---- */

.result {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.qr {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
  margin: 0 auto 1.25rem;
  padding: 10px;
  background: #fff;
  border-radius: 3px;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.download {
  flex: 1 1 auto;
  padding: 0.6rem 1rem;
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  color: var(--phosphor);
  border: 1px solid var(--phosphor);
  border-radius: 2px;
}

.download:hover { background: var(--phosphor); color: var(--ink); }

.assigned {
  margin: 1rem 0 0;
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--dim);
}

.raw { margin-top: 1rem; }

.raw summary {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
}

.raw summary:hover { color: var(--phosphor); }

.raw-conf {
  margin: 0.75rem 0 0;
  padding: 0.9rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--muted);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 2px;
}

/* ---- the ledger ---- */

.ledger { margin: 0; max-width: 68ch; }

.ledger-row {
  display: grid;
  gap: 0.25rem 2rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--line);
}

.ledger-row:last-child { border-bottom: 1px solid var(--line); }

.ledger dt {
  font-family: var(--mono);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--phosphor);
}

.ledger dd { margin: 0; color: var(--muted); font-size: 0.9375rem; }

.disclosure-foot, .howto-note {
  max-width: var(--measure);
  margin: 2rem 0 0;
  font-size: 0.9375rem;
  color: var(--dim);
}

/* ---- steps ---- */

.steps {
  max-width: var(--measure);
  margin: 0;
  padding-left: 1.4rem;
}

.steps li { margin-bottom: 0.6rem; color: var(--muted); }
.steps b { color: var(--text); font-weight: 600; }

/* ---- colophon ---- */

.colophon {
  padding: 2.5rem var(--gutter) 3.5rem;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--dim);
}

.colophon p { margin: 0 0 0.4rem; }

@media (min-width: 44rem) {
  .ledger-row { grid-template-columns: 16rem 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .tick { animation: none; }
  * { transition-duration: 0.01ms !important; }
}
