/* Klein ML — shared styles for index.html and every post page.
   Pixel display type (Pixelify Sans) to match the pixel K mark;
   accent is International Klein Blue. */

:root {
  --bg:       #ffffff;
  --ink:      #111111;
  --muted:    #5c5f66;
  --surface:  #f6f7f9;
  --surface-2:#eceef2;
  --rule:     #d9dce3;
  --accent:   #002fa7;          /* International Klein Blue */
  --accent-hover: #00237d;
  --accent-ink: #ffffff;        /* text on blue */
  --accent-soft: #e8edfb;
  --accent-deep: #002fa7;       /* blue safe for text on white */
  --link:     #002fa7;
  --band-1:   #dfe6fb;
  --band-2:   #f7f9fe;
  --code-bg:  #0a0a0a;
  --code-ink: #e8eaed;

  --display: "Pixelify Sans", "Courier New", monospace;
  --text:    "Google Sans Text", "Helvetica Neue", Arial, sans-serif;
  --mono:    "Google Sans Code", ui-monospace, "SF Mono", Menlo, monospace;

  --radius: 6px;                /* cards and boxes: near-square, like the pixels */
  --measure: 44rem;
  --wide: 78rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:       #0b0b0c;
    --ink:      #ececec;
    --muted:    #9a9ea6;
    --surface:  #161719;
    --surface-2:#202226;
    --rule:     #2e3036;
    --accent:   #3d63ff;
    --accent-hover: #5b7cff;
    --accent-soft: #111a3d;
    --accent-deep: #9db2ff;
    --link:     #9db2ff;
    --band-1:   #0c1538;
    --band-2:   #0b0b0c;
    --code-bg:  #000000;
  }
}

:root[data-theme="dark"] {
  --bg:     #0b0b0c;
  --ink:    #ececec;
  --muted:  #9a9ea6;
  --surface:  #161719;
  --surface-2:#202226;
  --rule:   #2e3036;
  --accent:   #3d63ff;
  --accent-hover: #5b7cff;
  --accent-soft: #111a3d;
  --accent-deep: #9db2ff;
  --link:   #9db2ff;
  --band-1:   #0c1538;
  --band-2:   #0b0b0c;
  --code-bg:  #000000;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.125rem;
  line-height: 1.7;
}

h1, h2, h3, .wordmark, .btn, .cat, .eyebrow {
  font-family: var(--display);
  font-weight: 400;
}

a { color: inherit; }

a:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

img { max-width: 100%; height: auto; }

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.bar {
  max-width: var(--wide);
  height: 4rem;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.35rem;
  font-weight: 500;
  text-decoration: none;
  letter-spacing: 0;
}

.wordmark .mark { width: 1.9rem; height: 1.9rem; flex: none; }

.wordmark .pixel-word { height: 0.95rem; width: auto; display: block; }

.mark { border-radius: 0; image-rendering: pixelated; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mark { box-shadow: 0 0 0 1px var(--rule); }
}
:root[data-theme="dark"] .mark { box-shadow: 0 0 0 1px var(--rule); }

.wordmark .sub {
  color: var(--muted);
  padding-left: 0.6rem;
  border-left: 1px solid var(--rule);
  font-weight: 400;
}

.top-nav { display: flex; align-items: center; gap: 0.5rem; font-family: var(--display); }

.top-nav a {
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
}

.top-nav a:hover { background: var(--surface-2); }

.top-nav a.btn, .btn {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 500;
}

.top-nav a.btn:hover { background: var(--accent-hover); }

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

.shell {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

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

.hero { padding: 1rem 0 2rem; }

.hero h1 {
  font-size: clamp(2.5rem, 7vw, 4rem);
  line-height: 1.05;
  letter-spacing: 0;
  margin: 0 0 0.75rem;
}

.hero .lede { max-width: 40rem; margin: 0; font-size: 1.2rem; line-height: 1.5; color: var(--muted); }

.cat {
  align-self: flex-start;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
}

.feature {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 8fr);
  gap: 0.6rem;
  border-radius: var(--radius);
}

.feature-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 2rem;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--band-1), var(--band-2));
}

.feature-text .cat { margin-bottom: 1.25rem; }

.feature h2 {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: 0;
  margin: 0 0 1rem;
}

.feature h2 a { text-decoration: none; }
.feature h2 a:hover { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 3px; text-underline-offset: 5px; }

.feature-text > p { margin: 0; font-size: 1.05rem; line-height: 1.6; }

.feature-foot { margin-top: auto; padding-top: 2.5rem; }

.by { margin: 0 0 1rem; font-size: 0.95rem; line-height: 1.5; }
.by time { display: block; font-weight: 500; }
.by span { color: var(--muted); font-size: 0.9rem; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1.5rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-family: var(--display);
  font-weight: 500;
  font-size: 1rem;
  text-decoration: none;
}

.pill:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.feature-img { display: block; border-radius: var(--radius); overflow: hidden; min-height: 18rem; }
.feature-img img { width: 100%; height: 100%; object-fit: cover; display: block; }

section { margin-top: 4.5rem; }

section > h2 { font-size: clamp(1.75rem, 4vw, 2.5rem); letter-spacing: 0; margin: 0 0 1.5rem; }

.posts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: 1.5rem;
}

.posts li { display: flex; }

.posts a {
  display: flex;
  flex-direction: column;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  text-decoration: none;
  transition: background 0.15s;
}

.posts a:hover { background: var(--surface-2); }

.posts img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; }

.card-body { display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem; padding: 1.5rem; flex: 1; }

.posts h3 { font-size: 1.6rem; line-height: 1.2; letter-spacing: 0; margin: 0; }

.posts a:hover h3 { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 3px; text-underline-offset: 5px; }

.posts time { margin-top: auto; padding-top: 0.5rem; color: var(--muted); font-size: 0.9rem; }

.tags { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.85rem; }

/* ---------- article: title band ---------- */

.band {
  background: linear-gradient(180deg, var(--band-1) 0%, var(--band-2) 100%);
  padding: 2.5rem 1.5rem 3rem;
}

.band-inner { max-width: 56rem; margin: 0 auto; }

.crumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0 0 3rem;
  font-family: var(--display);
  font-size: 0.9rem;
}

.crumbs a { color: var(--link); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span { color: var(--muted); }

.band h1 {
  font-size: clamp(2.4rem, 6.5vw, 4.25rem);
  line-height: 1.08;
  letter-spacing: 0;
  margin: 0 0 2rem;
}

.meta { display: flex; gap: 1.5rem 2.25rem; align-items: baseline; padding-bottom: 2rem; }

.meta .when { margin: 0; flex: none; font-size: 0.9rem; line-height: 1.6; color: var(--muted); }
.meta .when time, .meta .when .read { display: block; }

.meta .dek { margin: 0; font-family: var(--text); font-size: clamp(1.2rem, 2.4vw, 1.6rem); line-height: 1.4; color: var(--muted); }

.byline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.byline p { margin: 0; line-height: 1.4; }
.byline strong { display: block; font-family: var(--display); font-weight: 500; font-size: 0.95rem; }
.byline span { color: var(--muted); font-size: 0.9rem; }

.share {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--display);
  font-weight: 500;
  font-size: 1rem;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
}

.share:hover { background: var(--accent); color: var(--accent-ink); }

.hero-img { margin: 0; }
.hero-img img { display: block; width: 100%; height: clamp(16rem, 42vw, 40rem); object-fit: cover; }

/* ---------- article: body ---------- */

.post-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, var(--measure)) minmax(0, 1fr);
  gap: 0 2rem;
  padding-top: 3rem;
  max-width: none;
}

.post-shell > main { grid-column: 2; }

.toc {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  width: 15rem;
  position: sticky;
  top: 5.5rem;
  align-self: start;
  font-family: var(--display);
  font-size: 0.9rem;
  line-height: 1.4;
}

.toc details { border-radius: var(--radius); background: var(--surface); padding: 0.4rem 1.1rem 0.8rem; }

.toc summary {
  cursor: pointer;
  list-style: none;
  padding: 0.7rem 0;
  font-weight: 500;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
}

.toc summary::-webkit-details-marker { display: none; }
.toc summary::after { content: "⌃"; transition: transform 0.15s; }
.toc details:not([open]) summary::after { transform: rotate(180deg); }

.toc ol { list-style: none; margin: 0; padding: 0.4rem 0 0; border-top: 1px solid var(--rule); }

.toc li { margin: 0; }

.toc a {
  display: block;
  padding: 0.55rem 0 0.55rem 0.7rem;
  margin-left: -0.7rem;
  border-left: 3px solid transparent;
  text-decoration: none;
  color: var(--muted);
}

.toc a:hover { color: var(--ink); }
.toc a.on { color: var(--ink); border-left-color: var(--accent); font-weight: 500; }

.article { max-width: var(--measure); margin: 0 auto; }

.article h2 {
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: 0;
  margin: 3.5rem 0 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
  scroll-margin-top: 5rem;
}

.article h3 { font-size: 1.35rem; font-weight: 500; margin: 2.25rem 0 0.5rem; }

.article p, .article ul, .article ol { margin: 0 0 1.4rem; }

.article ul, .article ol { padding-left: 1.4rem; }

.article li { margin-bottom: 0.5rem; padding-left: 0.2rem; }

.article li::marker { color: var(--accent-deep); }

.article a { color: var(--link); text-decoration: none; }

.article a:hover { text-decoration: underline; text-underline-offset: 3px; }

.article blockquote {
  margin: 2.5rem 0;
  padding: 0.25rem 0 0.25rem 1.5rem;
  border-left: 6px solid var(--accent);
  font-family: var(--display);
  font-size: 1.6rem;
  line-height: 1.35;
}

code, pre, .table td.num { font-family: var(--mono); font-size: 0.88em; }

code { background: var(--accent-soft); padding: 0.1em 0.38em; border-radius: 6px; }

pre {
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  line-height: 1.6;
  margin: 1.75rem 0;
}

pre code { background: none; padding: 0; }

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 2rem 0;
  font-size: 1rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}

.table th, .table td { text-align: left; padding: 0.8rem 1.1rem; border-bottom: 1px solid var(--rule); }
.table tr:last-child td { border-bottom: 0; }
.table th { font-family: var(--display); font-weight: 500; background: var(--accent-soft); }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.figure { margin: 2.5rem 0; }

.article img { border-radius: var(--radius); display: block; }

.figure figcaption { color: var(--muted); font-size: 0.9rem; line-height: 1.5; margin-top: 0.75rem; }

.center { text-align: center; margin: 1.5rem 0; }

.stat { text-align: center; margin: 2.5rem 0; padding: 2.25rem 1.5rem; border-radius: var(--radius); background: var(--accent-soft); }

.article .stat h2, .article .stat h3 {
  margin: 0 0 0.35rem;
  padding: 0;
  border: 0;
  font-weight: 500;
  font-size: clamp(1.8rem, 5vw, 2.75rem);
}

.article hr { border: 0; border-top: 1px solid var(--rule); margin: 3rem 0; }

.article-foot { margin-top: 4rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); color: var(--muted); font-size: 0.95rem; }
.article-foot p { margin: 0; }
.article-foot p + p { margin-top: 0.75rem; }
.article .back { color: var(--ink); font-family: var(--display); font-weight: 500; }
.article .back:hover { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }

/* ---------- listen to article ---------- */

.listen { margin: 0 0 2.5rem; }

.listen-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-height: 3.75rem;
  padding: 0.4rem 0.6rem 0.4rem 0.5rem;
  border-radius: 999px;
  background: var(--surface);
  overflow: hidden;
  font-family: var(--display);
}

.listen-play {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.9rem;
  height: 2.9rem;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}

.listen-play:hover { background: var(--accent-hover); }

.listen-title { font-weight: 500; font-size: 1.05rem; }

.listen-status { margin-left: auto; color: var(--muted); font-size: 0.9rem; white-space: nowrap; }

.listen-info {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink);
  cursor: pointer;
}

.listen-info:hover { background: var(--surface-2); }

.listen-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: transparent; }
.listen-progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.4s; }

.listen-opts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
  margin-top: 0.75rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  background: var(--surface);
  font-family: var(--display);
  font-size: 0.95rem;
}

.listen-opts[hidden] { display: none; }

.listen-opts label { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 500; }

.listen-opts select {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
}

.listen-opts p { flex-basis: 100%; margin: 0; color: var(--muted); font-family: var(--text); font-size: 0.85rem; line-height: 1.5; }

.speaking {
  background: var(--accent-soft);
  box-shadow: 0 0 0 0.45rem var(--accent-soft);
  border-radius: 0.3rem;
  transition: background 0.2s;
}

@media (max-width: 40rem) {
  .listen-title { font-size: 0.98rem; }
  .listen-status { display: none; }
  .listen-info { margin-left: auto; }
}

/* ---------- live hero (canvas over the cover image) ---------- */

.hero-live {
  position: relative;
  aspect-ratio: 1200 / 630;
  overflow: hidden;
  line-height: 0;
  background: #030a2a;
  user-select: none;
  -webkit-user-select: none;
  touch-action: pan-y;
  cursor: grab;
}

.hero-live img,
.hero-live canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* ---------- empty state (no posts yet) ---------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  padding: 2.5rem 2rem;
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--band-1), var(--band-2));
}

.empty-mark { width: 3.5rem; height: 3.5rem; color: var(--accent); margin: -0.6rem 0 0.5rem -0.8rem; }

.empty-title { margin: 0; font-family: var(--display); font-size: clamp(1.7rem, 3vw, 2.4rem); line-height: 1.15; }

.empty p { margin: 0; color: var(--muted); }
.empty .empty-title { color: var(--ink); }
.empty a { color: var(--link); }

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

.site-footer { background: var(--surface); border-top: 1px solid var(--rule); }

.site-footer .inner {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 3rem 1.5rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--muted);
}

.site-footer p { margin: 0 0 1rem; max-width: 42rem; }

.foot-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--ink);
}

.foot-brand .mark { width: 1.6rem; height: 1.6rem; }

.foot-links { display: flex; gap: 1.5rem; margin: 0; }

.foot-links a { color: var(--ink); text-decoration: none; font-weight: 500; }
.foot-links a:hover { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }

/* ---------- responsive ---------- */

@media (max-width: 72rem) {
  .post-shell { display: block; max-width: var(--measure); padding-top: 2rem; }
  .toc { position: static; width: auto; justify-self: stretch; margin: 0 0 2rem; }
}

@media (max-width: 52rem) {
  .feature { grid-template-columns: minmax(0, 1fr); }
  .feature-img { min-height: 0; aspect-ratio: 16 / 9; }
}

@media (max-width: 40rem) {
  body { font-size: 1.0625rem; }
  .bar { padding: 0 1rem; }
  .wordmark .sub { display: none; }
  .shell { padding: 2rem 1rem 4rem; }
  .band { padding: 1.75rem 1rem 2rem; }
  .crumbs { margin-bottom: 2rem; }
  .meta { flex-direction: column; gap: 0.75rem; }
  .feature-text { padding: 1.5rem; }
  .article blockquote { font-size: 1.3rem; }
}
