/* ============================================================
   DISPATCH — wire-service theme
   Carries the vikramsundaram.com language: JetBrains Mono only,
   near-black ground, white at graded opacity, terminal accents.
   ============================================================ */

:root {
  --ground:        #ffffff;
  --ground-raised: #f5f5f3;
  --paper:         #04050a;

  --t-100: rgba(4,5,10,0.93);
  --t-80:  rgba(4,5,10,0.74);
  --t-60:  rgba(4,5,10,0.58);
  --t-40:  rgba(4,5,10,0.45);
  --t-20:  rgba(4,5,10,0.24);

  --rule:      rgba(4,5,10,0.18);
  --rule-soft: rgba(4,5,10,0.10);

  /* The terminal accents are neon, built to glow on near-black. On white they
     vanish, so each is taken down to the same hue at printable density. */
  --green: #07704a;
  --coral: #c4392a;
  --cyan:  #0a6791;
  --accent: var(--green);

  /* Three faces, three jobs:
     --body    reading — long-form article copy, decks, excerpts
     --display headlines and the masthead — the 80s computer-industry voice
     --mono    the wire furniture — datelines, slugs, bylines, labels        */
  --body:    Verdana, Geneva, "DejaVu Sans", sans-serif;
  --display: "Michroma", "Eurostile", "Chakra Petch", sans-serif;
  --wordmark: var(--display);
  /* Michroma now carries the furniture too. It is already very wide, so every
     tracking value below is roughly half what the monospace wanted. */
  --mono:    var(--display);
  /* real monospace survives only where it means something: code */
  --code:    "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --measure: 34rem;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
  --masthead-h: 74px;
}

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

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--t-100);
  font-family: var(--body);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

::selection { background: var(--green); color: var(--ground); }

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding-inline: var(--gutter);
}

.skip {
  position: absolute; left: -9999px;
}
.skip:focus {
  left: var(--gutter); top: 0.5rem; z-index: 100;
  background: var(--green); color: var(--ground);
  padding: 0.5rem 0.9rem;
}

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

.masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--ground) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--rule);
}

.masthead-inner {
  height: var(--masthead-h);
  display: flex;
  align-items: center;
  gap: clamp(0.75rem, 2vw, 1.5rem);
}

/* the revolving chrome ident */
.ident {
  flex: none;
  width: 58px;
  height: 58px;
  position: relative;
  display: block;
  margin-inline-start: -4px;
}
.ident canvas,
.ident img {
  width: 100%;
  height: 100%;
  display: block;
}
.ident img { opacity: 0.9; }
.ident canvas + img { display: none; }

.wordmark {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.1;
  margin-inline-end: auto;
  min-width: 0;
}
.wordmark-name {
  font-family: var(--wordmark);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.071em;
  text-transform: uppercase;
  white-space: nowrap;
}
.wordmark-kicker {
  font-family: var(--body);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--t-40);
  white-space: nowrap;
}

.mast-nav {
  font-family: var(--mono);
  display: flex;
  align-items: center;
  gap: clamp(0.7rem, 1.8vw, 1.4rem);
  font-size: 10px;
  letter-spacing: 0.059em;
  text-transform: uppercase;
}
.mast-nav a { color: var(--t-60); transition: color 0.15s ease; }
.mast-nav a:hover,
.mast-nav .nav-current a { color: var(--t-100); }

.mast-sub {
  font-family: var(--mono);
  flex: none;
  font-size: 10px;
  letter-spacing: 0.059em;
  text-transform: uppercase;
  color: var(--ground);
  background: var(--accent);
  padding: 0.45em 0.9em;
  transition: filter 0.15s ease;
}
.mast-sub:hover { filter: brightness(1.12); }

@media (max-width: 640px) {
  .mast-nav { display: none; }
  .wordmark-kicker { display: none; }
}

/* ---------- the wire strip --------------------------------- */

.wire {
  font-family: var(--mono);
  border-bottom: 1px solid var(--rule);
  font-size: 9.5px;
  letter-spacing: 0.076em;
  text-transform: uppercase;
  color: var(--t-40);
}
.wire-inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  height: 34px;
  white-space: nowrap;
  overflow: hidden;
}
.wire-live {
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
}
.wire-dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ---------- front page -------------------------------------- */

main { display: block; }

.lead {
  padding-block: clamp(2.5rem, 6vw, 5rem) clamp(2rem, 4vw, 3.5rem);
  border-bottom: 1px solid var(--rule);
}
.lead-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3.5rem);
  align-items: start;
}
@media (max-width: 860px) {
  .lead-grid { grid-template-columns: 1fr; }
}

.slug {
  font-family: var(--mono);
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-size: 9.5px;
  letter-spacing: 0.084em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}
.slug::before {
  content: "";
  width: 18px;
  height: 1px;
  background: currentColor;
}

.lead-title {
  font-family: var(--display);
  margin: 0 0 1rem;
  font-size: clamp(1.9rem, 4.6vw, 3.15rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.lead-title a { transition: color 0.15s ease; }
.lead-title a:hover { color: var(--green); }

.lead-excerpt {
  margin: 0 0 1.5rem;
  font-size: 15px;
  line-height: 1.62;
  color: var(--t-80);
  max-width: 56ch;
}

.byline {
  font-family: var(--mono);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-size: 9.5px;
  letter-spacing: 0.067em;
  text-transform: uppercase;
  color: var(--t-40);
}
.byline strong { font-weight: 500; color: var(--t-80); }
.byline .sep { color: var(--t-20); }

.lead-figure {
  border: 1px solid var(--rule);
  background: var(--ground-raised);
  overflow: hidden;
}
.lead-figure img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }

/* ---------- headline list ----------------------------------- */

.feed { padding-block: clamp(2rem, 5vw, 3.5rem) 4rem; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--rule);
}
.section-head h2 {
  font-family: var(--mono);
  margin: 0;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.092em;
  text-transform: uppercase;
  color: var(--t-60);
}
.section-head .count {
  font-size: 9.5px;
  letter-spacing: 0.067em;
  color: var(--t-20);
}

.headline {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: clamp(1rem, 3vw, 2.25rem);
  padding-block: 1.4rem;
  border-bottom: 1px solid var(--rule-soft);
  transition: background 0.15s ease;
}
.headline:hover { background: rgba(4,5,10,0.028); }

.headline-date {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.050em;
  text-transform: uppercase;
  color: var(--t-40);
  padding-top: 0.32em;
  white-space: nowrap;
}

.headline-title {
  font-family: var(--display);
  margin: 0 0 0.4rem;
  font-size: clamp(1.02rem, 1.9vw, 1.28rem);
  font-weight: 500;
  line-height: 1.32;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}
.headline-title a { transition: color 0.15s ease; }
.headline:hover .headline-title a { color: var(--green); }

.headline-excerpt {
  margin: 0 0 0.6rem;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--t-60);
  max-width: 62ch;
}

.headline-meta {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.067em;
  text-transform: uppercase;
  color: var(--t-40);
}
.headline-meta .tag { color: var(--accent); }

@media (max-width: 640px) {
  .headline { grid-template-columns: 1fr; gap: 0.5rem; }
  .headline-date { padding-top: 0; }
}

/* ---------- article ----------------------------------------- */

.article { padding-block: clamp(2.5rem, 6vw, 4.5rem) 4rem; }

.article-head {
  max-width: 46rem;
  padding-bottom: 1.75rem;
  margin-bottom: 2.25rem;
  border-bottom: 1px solid var(--rule);
}
.article-title {
  font-family: var(--display);
  margin: 0 0 1rem;
  font-size: clamp(1.7rem, 3.7vw, 2.5rem);
  font-weight: 500;
  line-height: 1.14;
  letter-spacing: -0.022em;
  text-wrap: balance;
}
.article-standfirst {
  margin: 0 0 1.5rem;
  font-size: 16.5px;
  line-height: 1.55;
  color: var(--t-80);
  color: var(--t-80);
}

.article-figure { margin: 0 0 2.25rem; }
.article-figure img { width: 100%; border: 1px solid var(--rule); }
.article-figure figcaption {
  font-family: var(--mono);
  margin-top: 0.65rem;
  font-size: 9.5px;
  letter-spacing: 0.059em;
  text-transform: uppercase;
  color: var(--t-40);
}

.article-body {
  max-width: var(--measure);
  font-size: 15.5px;
  line-height: 1.72;
  color: var(--t-80);
}
.article-body :where(p, ul, ol, blockquote, pre, figure, h2, h3, hr) { margin: 0; }
.article-body > * + * { margin-top: 1.35em; }
.article-body strong { color: var(--t-100); font-weight: 500; }
.article-body em { font-style: italic; }

.article-body h2,
.article-body h3 {
  font-family: var(--display);
  margin-top: 2.4em;
  margin-bottom: -0.35em;
  color: var(--t-100);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.article-body h2 { font-size: 1.22rem; }
.article-body h3 { font-size: 1.06rem; }

.article-body a {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  text-decoration-color: rgba(7,112,74,0.42);
}
.article-body a:hover { text-decoration-color: var(--green); }

.article-body blockquote {
  margin: 2em 0;
  padding-left: 1.4rem;
  border-left: 2px solid var(--accent);
  color: var(--t-100);
}

.article-body ul,
.article-body ol { margin: 0; padding-left: 1.3rem; }
.article-body li + li { margin-top: 0.5em; }
.article-body li::marker { color: var(--t-40); }

.article-body hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.6em 0;
}

.article-body pre {
  font-family: var(--code);
  background: var(--ground-raised);
  border: 1px solid var(--rule);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}
.article-body code {
  font-family: var(--code);
  font-size: 0.92em;
  background: rgba(4,5,10,0.055);
  padding: 0.12em 0.36em;
}
.article-body pre code { background: none; padding: 0; }

.article-body figure { margin: 2em 0; }
.article-body figcaption {
  margin-top: 0.6rem;
  font-size: 9.5px;
  letter-spacing: 0.059em;
  text-transform: uppercase;
  color: var(--t-40);
  text-align: center;
}

/* Ghost card widths */
.article-body :is(.kg-width-wide) { max-width: 1000px; width: 100vw; margin-inline: calc(50% - 50vw); padding-inline: var(--gutter); }
.article-body :is(.kg-width-full) { width: 100vw; margin-inline: calc(50% - 50vw); }

/* ---------- signup ------------------------------------------ */

.signup {
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding-block: clamp(2.5rem, 5vw, 3.75rem);
  background: var(--ground-raised);
}
.signup-inner { max-width: 46rem; margin-inline: 0; }
.signup h2 {
  font-family: var(--display);
  margin: 0 0 0.75rem;
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  font-weight: 500;
  letter-spacing: -0.01em;
}
.signup p {
  margin: 0 0 1.5rem;
  color: var(--t-60);
  font-size: 14px;
  max-width: 54ch;
}
.signup-form { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.signup-form input {
  flex: 1 1 16rem;
  min-width: 0;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--t-100);
  font-family: var(--mono);
  font-size: 14px;
  padding: 0.85em 0.9em;
  transition: border-color 0.15s ease;
}
.signup-form input::placeholder { color: var(--t-40); }
.signup-form input:focus {
  outline: none;
  border-color: var(--accent);
}
.signup-form button {
  font-family: var(--mono);
  flex: none;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--ground);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.067em;
  text-transform: uppercase;
  padding: 0.9em 1.5em;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.signup-form button:hover { filter: brightness(1.12); }
.signup-note {
  font-family: var(--mono);
  margin: 1rem 0 0;
  font-size: 9.5px;
  letter-spacing: 0.042em;
  text-transform: uppercase;
  color: var(--t-40);
}

/* ---------- pagination -------------------------------------- */

.pagination {
  font-family: var(--mono);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 2.5rem;
  font-size: 10px;
  letter-spacing: 0.067em;
  text-transform: uppercase;
  color: var(--t-40);
}
.pagination a { color: var(--t-80); }
.pagination a:hover { color: var(--green); }

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

.foot {
  font-family: var(--mono);
  border-top: 1px solid var(--rule);
  padding-block: 2.5rem 3.5rem;
  font-size: 9.5px;
  letter-spacing: 0.059em;
  text-transform: uppercase;
  color: var(--t-40);
}
.foot-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.75rem;
  align-items: center;
}
.foot-nav { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-inline-end: auto; }
.foot a:hover { color: var(--t-100); }

/* ---------- empty state ------------------------------------- */

.empty {
  font-family: var(--mono);
  padding-block: clamp(3rem, 8vw, 6rem);
  color: var(--t-40);
  font-size: 12px;
  letter-spacing: 0.059em;
  text-transform: uppercase;
}

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

/* ---------- accent role (theme setting) --------------------- */
.accent-green { --accent: var(--green); }
.accent-cyan  { --accent: var(--cyan); }
.accent-coral { --accent: var(--coral); }

/* the flat mark shows until WebGL proves it can draw the real one */
.ident.is-live img { display: none; }

/* ---------- twitch: live indicator + player ----------------- */

:root { --live: var(--coral); }

/* The wire dot idles green while filing; it goes red the moment we're live,
   which is the one colour readers already read as "happening now". */
.is-streaming .wire-live { color: var(--live); }
.is-streaming .wire-dot  { background: var(--live); }

.wire-watch {
  color: var(--live);
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
  margin-inline-start: auto;
  flex: none;
}
.wire-watch:hover { filter: brightness(1.15); }

.wire-latest { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.twitch {
  border-bottom: 1px solid var(--rule);
  background: var(--ground-raised);
  padding-block: clamp(1.5rem, 3.5vw, 2.5rem);
}

.twitch-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.twitch-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.075em;
  text-transform: uppercase;
  color: var(--live);
}

.twitch-link {
  margin-inline-start: auto;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.075em;
  text-transform: uppercase;
  color: var(--t-60);
  white-space: nowrap;
}
.twitch-link:hover { color: var(--t-100); }

.twitch-title {
  font-family: var(--display);
  margin: 0 0 0.3rem;
  font-size: clamp(1.05rem, 2.2vw, 1.4rem);
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.twitch-meta {
  font-family: var(--mono);
  margin: 0 0 1.1rem;
  font-size: 9.5px;
  letter-spacing: 0.075em;
  text-transform: uppercase;
  color: var(--t-40);
}
.twitch-meta:empty { display: none; }

.twitch-player {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #04050a;
  border: 1px solid var(--rule);
  overflow: hidden;
}
.twitch-player:empty { display: none; }
.twitch-frame { width: 100%; height: 100%; border: 0; display: block; }

/* ---------- archives (tag, author) and errors --------------- */

.archive-head {
  padding-block: clamp(2.5rem, 5vw, 4rem) clamp(1.5rem, 3vw, 2.25rem);
  border-bottom: 1px solid var(--rule);
}

.archive-title {
  font-family: var(--display);
  margin: 0 0 0.6rem;
  font-size: clamp(1.6rem, 3.4vw, 2.35rem);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.008em;
}

.archive-description {
  margin: 0 0 0.9rem;
  font-size: 15px;
  line-height: 1.6;
  color: var(--t-80);
  max-width: 54ch;
}

.archive-count {
  font-family: var(--mono);
  margin: 0;
  font-size: 9.5px;
  letter-spacing: 0.075em;
  text-transform: uppercase;
  color: var(--t-40);
}
.archive-count a { border-bottom: 1px solid var(--rule); }
.archive-count a:hover { color: var(--t-100); }

.error {
  padding-block: clamp(3.5rem, 9vw, 7rem);
}
.error-title {
  font-family: var(--display);
  margin: 0 0 0.9rem;
  font-size: clamp(1.5rem, 3.2vw, 2.2rem);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.008em;
  max-width: 20ch;
}
.error-message {
  margin: 0 0 1.75rem;
  color: var(--t-60);
  font-size: 15px;
  max-width: 54ch;
}
.error-actions {
  font-family: var(--mono);
  margin: 0;
  font-size: 9.5px;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}
.error-actions a { color: var(--accent); border-bottom: 1px solid currentColor; }

/* ---------- the enter card ---------------------------------- */

/* Hidden unless the pre-paint script says this visitor is new. The site
   underneath stays in the DOM the whole time — this covers it, it never
   replaces it, so crawlers and readers arriving on a link are unaffected. */
.enter { display: none; }

html.entering .enter {
  display: grid;
  position: fixed;
  inset: 0;
  z-index: 200;
  place-items: center;
  background: #04050a;
  opacity: 1;
  transition: opacity 0.75s ease;
}
html.entering body { overflow: hidden; }
html.entered .enter { opacity: 0; pointer-events: none; }

.enter-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.enter-ui {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  /* sits below the signature, which the scene puts in the upper half */
  margin-top: min(34vh, 20rem);
  text-align: center;
  /* the mark draws a beat after the stars; don't announce before it's there */
  opacity: 0;
  transition: opacity 0.9s ease 0.25s;
}
.enter.is-drawn .enter-ui { opacity: 1; }

.enter-kicker {
  font-family: var(--mono);
  margin: 0;
  font-size: 9.5px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.42);
}

.enter-button {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.92);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 0.95em 2.6em;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, letter-spacing 0.3s ease;
}
.enter-button:hover,
.enter-button:focus-visible {
  border-color: rgba(255,255,255,0.85);
  letter-spacing: 0.32em;
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  /* belt and braces — the inline script already skips the card entirely */
  html.entering .enter { display: none; }
  html.entering body { overflow: auto; }
}
