:root {
  --ink: #15171c;
  --ink-soft: #3a3f4a;
  --muted: #6b7280;
  --cream: #faf7f2;
  --paper: #ffffff;
  --line: #e6e2da;
  --orange: #ff5a1f;
  --orange-deep: #d8410d;
  --amber: #ffb020;
  --blue: #2563eb;
  --steel: #1f2733;
  --display: 'Archivo Black', 'Helvetica Neue', Impact, sans-serif;
  --cond: 'Barlow Condensed', 'Helvetica Neue', sans-serif;
  --text: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 1rem 4rem;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

.controls { padding: 2.5rem 0 1.5rem; }
.controls-inner { max-width: 54rem; margin: 0 auto; }

.wordmark {
  font-family: var(--display);
  font-size: clamp(1.8rem, 6vw, 3rem);
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--steel);
}

.tagline {
  font-family: var(--cond);
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.25rem 0 1.25rem;
}

#composer { display: flex; flex-wrap: wrap; gap: 0.6rem; }

#topic {
  flex: 1 1 20rem;
  min-width: 0;
  padding: 0.85rem 1rem;
  font-family: var(--text);
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--steel);
  border-radius: 2px;
}
#topic:focus { outline: 3px solid var(--amber); outline-offset: 1px; }

button {
  padding: 0.85rem 1.4rem;
  font-family: var(--cond);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--orange);
  border: 2px solid var(--orange-deep);
  border-radius: 2px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--orange-deep); }
button:disabled { opacity: 0.55; cursor: progress; }

button.ghost {
  color: var(--steel);
  background: transparent;
  border-color: var(--steel);
}
button.ghost:hover:not(:disabled) { background: var(--steel); color: var(--paper); }

.status {
  min-height: 1.4rem;
  margin: 0.9rem 0 0;
  font-family: var(--cond);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.status.working::after {
  content: '';
  display: inline-block;
  width: 0.5rem; height: 0.5rem;
  margin-left: 0.5rem;
  border-radius: 50%;
  background: var(--orange);
  animation: pulse 0.9s ease-in-out infinite;
}
.status.error { color: var(--orange-deep); }
@keyframes pulse { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }

/* ---------- the paper ---------- */

.paper {
  max-width: 54rem;
  margin: 0 auto;
  padding: 2.5rem 2.5rem 1.5rem;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 12px 34px rgba(21, 23, 28, 0.09);
}

.masthead { text-align: center; margin-bottom: 1.75rem; }
.masthead h2 {
  font-family: var(--display);
  font-size: clamp(2rem, 7vw, 3.6rem);
  letter-spacing: -0.03em;
  margin: 0.35rem 0;
  color: var(--ink);
}
.masthead-rule { height: 3px; background: var(--ink); }
.masthead-rule + h2 + .masthead-rule { height: 1px; }

.dateline {
  display: flex;
  justify-content: space-between;
  padding-top: 0.5rem;
  font-family: var(--cond);
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.lead h3 {
  font-family: var(--display);
  font-size: clamp(1.7rem, 5.5vw, 2.7rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}

.deck {
  font-family: var(--cond);
  font-size: 1.3rem;
  line-height: 1.35;
  color: var(--ink-soft);
  margin: 0 0 1.4rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
}

/* The model returns a square and signs the bottom margin with garbled
   lettering — no prompt wording stops it. Across samples that lettering never
   started above 84% of the height, so the box holds only the top 82%. */
.cut {
  width: min(100%, 22rem);
  margin: 0 auto 1.3rem;
  aspect-ratio: 1 / 0.82;
  overflow: hidden;
  background: var(--paper);
}
.cut img {
  display: block;
  width: 100%;
  /* Force any stray colour back to newsprint. */
  filter: grayscale(1) contrast(1.15);
}

.body { column-count: 2; column-gap: 2rem; column-rule: 1px solid var(--line); }
.body p { margin: 0 0 0.9rem; font-size: 1.02rem; line-height: 1.55; }
.body p:first-child::first-letter {
  float: left;
  font-family: var(--display);
  font-size: 3.3rem;
  line-height: 0.78;
  padding: 0.1rem 0.5rem 0 0;
  color: var(--orange);
}

.rail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 3px solid var(--ink);
}

.box {
  padding: 1rem 1.1rem;
  background: var(--cream);
  border: 1px solid var(--line);
  break-inside: avoid;
}
.box h4 {
  font-family: var(--cond);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 0.7rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--ink);
}
.box p, .box li { font-size: 0.95rem; line-height: 1.45; }

.facts ol { margin: 0; padding-left: 1.1rem; }
.facts li { margin-bottom: 0.55rem; }
.facts li::marker { font-family: var(--display); color: var(--blue); }

.joke .punchline { font-weight: 700; color: var(--orange-deep); margin-bottom: 0; }

.puzzle .clue { margin: 0 0 0.6rem; color: var(--muted); font-style: italic; }
.puzzle ul { margin: 0; padding: 0; list-style: none; }
.puzzle li {
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  padding: 0.2rem 0;
  border-bottom: 1px dotted var(--line);
}
.answers { margin-top: 0.7rem; font-size: 0.85rem; color: var(--muted); }
.answers summary { cursor: pointer; font-family: var(--cond); letter-spacing: 0.08em; text-transform: uppercase; }

.colophon {
  margin-top: 1.5rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
  font-family: var(--cond);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  color: var(--muted);
}

/* ---------- archive ---------- */

.archive { max-width: 54rem; margin: 2.5rem auto 0; }
.archive h4 {
  font-family: var(--cond);
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.7rem;
}
.archive ul { margin: 0; padding: 0; list-style: none; }
.archive li { border-bottom: 1px solid var(--line); }
.archive button {
  width: 100%;
  padding: 0.75rem 0.2rem;
  font-family: var(--text);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
  color: var(--ink);
  background: none;
  border: none;
}
.archive button:hover { background: none; color: var(--orange-deep); }
.archive .when { display: block; font-family: var(--cond); font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

/* ---------- print: one page ---------- */

@media print {
  @page { size: letter portrait; margin: 0.5in; }
  body { padding: 0; background: var(--paper); }
  .no-print { display: none !important; }
  .paper { max-width: none; margin: 0; padding: 0; border: none; box-shadow: none; }
  .lead h3 { font-size: 2rem; }
  .deck { font-size: 1.1rem; }
  /* The picture yields first — the story has to fit on the one sheet. */
  .cut { width: 2.4in; margin-bottom: 0.9rem; }
  .cut img { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .body p { font-size: 9.5pt; line-height: 1.4; }
  .box p, .box li { font-size: 8.5pt; }
  .rail { grid-template-columns: repeat(3, 1fr); }
}
