/* ============================================================
   Machine Readable — publication shell
   The shell is deliberately quiet: the document inside the
   frame is the product, this is the paper it's printed on.
   ============================================================ */

:root {
  color-scheme: light;
  --paper:      #fffdf8;
  --surface:    #ffffff;
  --sunken:     #f6f4ee;
  --ink:        #16150f;
  --ink-2:      #4a4841;
  --muted:      #7d7a71;
  --rule:       #e7e3d9;
  --rule-soft:  #f0ece3;
  --accent:     #c1440e;
  --accent-ink: #ffffff;
  --shadow:     0 1px 2px rgba(22,21,15,.05), 0 8px 24px -12px rgba(22,21,15,.14);
  --shadow-lg:  0 2px 4px rgba(22,21,15,.06), 0 24px 60px -28px rgba(22,21,15,.28);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --measure: 34rem;
  --wide: 68rem;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --paper:      #100f0d;
    --surface:    #171613;
    --sunken:     #1c1b17;
    --ink:        #f6f3ec;
    --ink-2:      #c5c1b6;
    --muted:      #8e8a80;
    --rule:       #2b2924;
    --rule-soft:  #211f1b;
    --accent:     #ff7d4d;
    --accent-ink: #17120e;
    --shadow:     0 1px 2px rgba(0,0,0,.5), 0 8px 24px -12px rgba(0,0,0,.7);
    --shadow-lg:  0 2px 4px rgba(0,0,0,.5), 0 24px 60px -28px rgba(0,0,0,.85);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --paper:      #100f0d;
  --surface:    #171613;
  --sunken:     #1c1b17;
  --ink:        #f6f3ec;
  --ink-2:      #c5c1b6;
  --muted:      #8e8a80;
  --rule:       #2b2924;
  --rule-soft:  #211f1b;
  --accent:     #ff7d4d;
  --accent-ink: #17120e;
  --shadow:     0 1px 2px rgba(0,0,0,.5), 0 8px 24px -12px rgba(0,0,0,.7);
  --shadow-lg:  0 2px 4px rgba(0,0,0,.5), 0 24px 60px -28px rgba(0,0,0,.85);
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

:where(a, button, summary, input, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

img, svg, iframe { max-width: 100%; }

.shell { max-width: var(--wide); margin: 0 auto; padding: 0 24px; }
.measure { max-width: var(--measure); }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

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

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar[data-stuck="true"] { border-bottom-color: var(--rule); }
.topbar .shell {
  display: flex; align-items: center; gap: 16px;
  height: 58px;
}
.topbar .brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -.01em;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar nav { display: flex; gap: 18px; margin-left: auto; align-items: center; }
.topbar nav a {
  font-size: 14px; color: var(--ink-2); text-decoration: none;
}
.topbar nav a:hover { color: var(--ink); }

.iconbtn {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--rule); border-radius: 8px;
  background: transparent; color: var(--ink-2);
  cursor: pointer;
}
.iconbtn:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 25%, var(--rule)); }
.iconbtn svg { width: 16px; height: 16px; display: block; }
:root[data-theme="dark"] .icon-sun, :root:where(:not([data-theme="light"])) .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon, :root:where(:not([data-theme="light"])) .icon-moon { display: block; }
.icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .icon-sun { display: none; }
  :root:where(:not([data-theme="light"])) .icon-moon { display: block; }
}
:root[data-theme="light"] .icon-sun { display: block; }
:root[data-theme="light"] .icon-moon { display: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 34px; padding: 0 15px;
  border: 1px solid transparent; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink);
  font: 600 14px/1 var(--sans);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--rule); font-weight: 500; }
.btn.ghost:hover { color: var(--ink); border-color: color-mix(in srgb, var(--ink) 25%, var(--rule)); filter: none; }
.btn.lg { height: 42px; padding: 0 22px; font-size: 15px; border-radius: 9px; }

/* ---------- publication header (home) ---------- */

.masthead { padding: 64px 0 40px; text-align: center; }
.masthead h1 {
  font-family: var(--serif);
  font-size: clamp(40px, 8vw, 68px);
  line-height: 1.02;
  letter-spacing: -.025em;
  font-weight: 600;
  margin: 14px 0 0;
  text-wrap: balance;
}
.masthead .tagline {
  font-family: var(--serif);
  font-size: clamp(17px, 2.4vw, 21px);
  font-style: italic;
  color: var(--muted);
  margin: 14px auto 0;
  max-width: 40rem;
  text-wrap: balance;
}
.masthead .blurb {
  margin: 22px auto 0; max-width: 38rem;
  color: var(--ink-2); font-size: 16px;
}

/* ---------- subscribe ---------- */

.subscribe { margin: 30px auto 0; max-width: 30rem; }
.subscribe form { display: flex; gap: 8px; }
.subscribe input[type="email"] {
  flex: 1; min-width: 0; height: 42px; padding: 0 14px;
  border: 1px solid var(--rule); border-radius: 9px;
  background: var(--surface); color: var(--ink);
  font: 15px var(--sans);
}
.subscribe input::placeholder { color: var(--muted); }
.subscribe .note { margin: 10px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.subscribe .note[data-state="error"] { color: var(--accent); }
@media (max-width: 460px) { .subscribe form { flex-direction: column; } .subscribe .btn { width: 100%; } }

.cta {
  margin: 72px 0 0;
  border-top: 1px solid var(--rule);
  padding: 44px 0 0;
  text-align: center;
}
.cta h2 {
  font-family: var(--serif); font-weight: 600; letter-spacing: -.015em;
  font-size: 27px; margin: 0; text-wrap: balance;
}
.cta p { color: var(--ink-2); margin: 10px auto 0; max-width: 32rem; font-size: 15.5px; }

/* ---------- post list ---------- */

.section-rule {
  display: flex; align-items: center; gap: 14px;
  margin: 56px 0 0;
}
.section-rule::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

.posts { display: grid; gap: 0; margin: 8px 0 0; padding: 0; list-style: none; }
.posts > li { border-bottom: 1px solid var(--rule-soft); }
.posts > li:last-child { border-bottom: 0; }

.card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 28px;
  align-items: start;
  padding: 30px 0;
  text-decoration: none;
  color: inherit;
}
.card .meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--muted); }
.card h3 {
  font-family: var(--serif); font-weight: 600;
  font-size: 25px; line-height: 1.2; letter-spacing: -.018em;
  margin: 10px 0 0; text-wrap: balance;
}
.card:hover h3 { color: var(--accent); }
.card .dek {
  margin: 8px 0 0; color: var(--ink-2); font-size: 15.5px; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.card .more { margin-top: 12px; font-size: 13.5px; color: var(--muted); font-family: var(--mono); }

.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--rule); border-radius: 4px; padding: 2px 6px;
}

/* featured (latest) */
.featured .card { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 8px 0 34px; }
.featured .card h3 { font-size: clamp(30px, 4.4vw, 42px); line-height: 1.1; letter-spacing: -.025em; }
.featured .card .dek { font-size: 18px; -webkit-line-clamp: 4; max-width: 44rem; }
/* Capped scale keeps the hero reading as a specimen of the document rather
   than as the document itself, and shows more of it. */
.featured .preview { margin-top: 24px; aspect-ratio: 16 / 9; background: var(--sunken); }
/* Shadow values are pre-multiplied: the frame is transform-scaled, so a
   normal-sized shadow would shrink to nothing. */
.featured .preview iframe { box-shadow: 0 0 0 2px var(--rule), 0 24px 70px rgba(0, 0, 0, .18); }

/* ---------- live document previews ---------- */

.preview {
  position: relative; overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--rule); border-radius: 10px;
  background: var(--sunken);
  box-shadow: var(--shadow);
  contain: paint;
}
.preview iframe {
  position: absolute; top: 0; left: 50%;
  width: 1000px; height: 1400px;
  /* The document canvas is a fixed 1000px and is sized by transform alone;
     the global max-width would otherwise reflow it before it is scaled. */
  max-width: none;
  border: 0;
  transform-origin: top center;
  transform: translateX(-50%) scale(var(--preview-scale, .26));
  pointer-events: none;
}
.preview::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, transparent 55%, color-mix(in srgb, var(--paper) 78%, transparent));
  pointer-events: none;
}
.card:hover .preview { border-color: color-mix(in srgb, var(--accent) 45%, var(--rule)); }
.preview[data-loaded="false"] iframe { opacity: 0; }
.preview iframe { transition: opacity .25s ease; }

@media (max-width: 720px) {
  .card { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .card .preview { order: -1; aspect-ratio: 16 / 9; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

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

.article-head { padding: 44px 0 0; }
.article-head .kicker { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.article-head h1 {
  font-family: var(--serif); font-weight: 600;
  font-size: clamp(32px, 5.2vw, 50px); line-height: 1.08; letter-spacing: -.026em;
  margin: 16px 0 0; max-width: 22ch; text-wrap: balance;
}
.article-head .dek {
  font-family: var(--serif); font-size: clamp(18px, 2.3vw, 21px); line-height: 1.5;
  color: var(--ink-2); margin: 16px 0 0; max-width: 46rem; text-wrap: pretty;
}
.byline {
  display: flex; align-items: center; gap: 12px;
  margin: 26px 0 0; padding: 18px 0;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font-size: 14px; color: var(--muted);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink);
  font: 600 13px/1 var(--sans); letter-spacing: .02em;
  flex: none;
}
.byline .who { color: var(--ink); font-weight: 600; }
.byline .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* the frame that holds the generated document */
.doc {
  margin: 30px 0 0;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.doc-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--rule);
  background: var(--sunken);
  font-family: var(--mono); font-size: 11px; letter-spacing: .06em;
  color: var(--muted); text-transform: uppercase;
}
.doc-bar .lights { display: flex; gap: 5px; }
.doc-bar .lights i { width: 8px; height: 8px; border-radius: 50%; background: var(--rule); }
.doc-bar .spacer { flex: 1; }
.doc-bar a, .doc-bar button {
  font: inherit; text-transform: none; letter-spacing: .04em;
  color: var(--muted); background: none; border: 0; padding: 2px 4px; cursor: pointer;
  text-decoration: none;
}
.doc-bar a:hover, .doc-bar button:hover { color: var(--ink); }
.doc iframe { display: block; width: 100%; border: 0; min-height: 60vh; background: var(--surface); }
.doc:fullscreen { border-radius: 0; border: 0; }
.doc:fullscreen iframe { height: 100vh !important; }
.doc:fullscreen .doc-bar { display: none; }

.article-foot { margin: 40px 0 0; }
.article-foot .row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.article-foot .src {
  margin: 22px 0 0; font-size: 13px; color: var(--muted);
  border-left: 2px solid var(--rule); padding-left: 14px;
}

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 56px 0 0; }
.pager a {
  display: block; padding: 18px 20px; text-decoration: none;
  border: 1px solid var(--rule); border-radius: 10px; background: var(--surface);
}
.pager a:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--rule)); }
.pager .lbl { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.pager .t { font-family: var(--serif); font-size: 17px; line-height: 1.3; margin-top: 6px; display: block; }
.pager .next { text-align: right; }
.pager .empty { visibility: hidden; }
@media (max-width: 620px) { .pager { grid-template-columns: 1fr; } .pager .next { text-align: left; } }

/* ---------- prose (about) ---------- */

.prose { padding: 44px 0 0; }
.prose h1 {
  font-family: var(--serif); font-weight: 600; letter-spacing: -.025em;
  font-size: clamp(32px, 5vw, 46px); line-height: 1.1; margin: 0 0 8px;
}
.prose h2 {
  font-family: var(--serif); font-weight: 600; letter-spacing: -.015em;
  font-size: 24px; margin: 40px 0 0;
}
.prose p { color: var(--ink-2); max-width: var(--measure); font-size: 17px; }
.prose p strong, .prose li strong { color: var(--ink); font-weight: 600; }
.prose ul { color: var(--ink-2); max-width: var(--measure); padding-left: 20px; }
.prose li { margin: 6px 0; }
.prose a { color: var(--accent); }

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

.sitefoot {
  margin-top: 96px; border-top: 1px solid var(--rule);
  padding: 32px 0 56px;
  font-size: 13.5px; color: var(--muted);
}
.sitefoot .shell { display: flex; gap: 18px 26px; flex-wrap: wrap; align-items: center; }
.sitefoot a { text-decoration: none; }
.sitefoot a:hover { color: var(--ink); }
.sitefoot .end { margin-left: auto; font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; }
@media (max-width: 620px) { .sitefoot .end { margin-left: 0; width: 100%; } }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* compact article header — for issues whose document carries its own masthead */
.article-head.compact { padding: 32px 0 0; }
.article-head.compact .byline { margin-top: 16px; }

.empty-state {
  margin: 48px 0; padding: 40px 24px; text-align: center;
  border: 1px dashed var(--rule); border-radius: 12px; color: var(--muted);
}
