@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&family=Playfair+Display:ital,wght@0,600;0,700;0,800;0,900;1,600&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400&display=swap");

:root {
  --paper: #ffffff;
  --ink: #101010;
  --ink-soft: #3d3d3d;
  --muted: #6a6a6a;
  --rule: #101010;
  --hairline: #d4d4d4;
  --accent: #8c1717;
  --desk: #b9bcc0;
  --serif: "Source Serif 4", Georgia, serif;
  --display: "Playfair Display", Georgia, serif;
  --sans: "DM Sans", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 0%, #ced1d5 0%, var(--desk) 55%, #a7abb0 100%);
  font-family: var(--serif);
  line-height: 1.4;
  overflow: hidden;
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 50;
  background: var(--paper);
  padding: 0.5rem;
}

/* ---------- reader shell ---------- */

.reader {
  height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.5rem 0.45rem;
}

/* The library sizes sheets from its parent's width alone, so the available
   height has to cap that width here (sheet ratio 980 / 760). One sheet is as
   tall as it is wide times 1.2895; a two-sheet spread is half that per page,
   so the same height allows a shell 1.55 times as wide. */
.book-shell {
  width: min(1180px, 97vw, calc((100vh - 3.9rem) / 1.2895));
  margin: 0 auto;
}

.reader.is-spread .book-shell {
  width: min(1720px, 97vw, calc((100vh - 3.9rem) * 1.55));
}

/* The library writes its minWidth setting onto this element as a CSS floor,
   which would push the sheet past the edge of a narrow window. The setting is
   only needed for the one-sheet-per-screen threshold, so drop the floor. */
.book {
  margin: 0 auto;
  min-width: 0 !important;
}

.page {
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(16, 16, 16, 0.12);
}

/* --page-width is measured and set by paper.js so type scales with the sheet,
   not the viewport. */
.page-body {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 3% 4.2%;
  display: flex;
  flex-direction: column;
  container-type: inline-size;
  font-size: clamp(0.66rem, calc(var(--page-width, 760px) * 0.0225), 1.3rem);
  scrollbar-width: none;
}

.page-body::-webkit-scrollbar {
  display: none;
}

.page-front .page-body,
.page-back .page-body {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.035), transparent 12%),
    var(--paper);
}

/* ---------- masthead ---------- */

.masthead {
  text-align: center;
  border-bottom: 3px double var(--rule);
  padding-bottom: 0.5em;
}

.ear-row {
  display: flex;
  justify-content: space-between;
  gap: 1em;
  font-family: var(--sans);
  font-size: 0.66em;
  line-height: 1.35;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 0.5em;
}

.ear {
  text-align: left;
  max-width: 40%;
}

.ear.right {
  text-align: right;
}

.ear strong {
  color: var(--ink);
  letter-spacing: 0.12em;
}

.nameplate {
  font-family: var(--display);
  font-weight: 900;
  font-size: 3em;
  line-height: 1;
  letter-spacing: -0.03em;
  margin: 0.26em 0 0.06em;
}

.motto {
  font-style: italic;
  font-size: 0.92em;
  margin: 0 0 0.45em;
  color: var(--ink-soft);
}

.dateline {
  display: flex;
  justify-content: space-between;
  gap: 0.6em;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 0.3em 0;
  font-family: var(--sans);
  font-size: 0.64em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.inside-strip {
  font-family: var(--sans);
  font-size: 0.64em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.45em 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.9em;
  justify-content: center;
}

.inside-strip a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--hairline);
}

.inside-strip a:hover {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

/* ---------- headlines ---------- */

.banner {
  padding: 0.45em 0 0.4em;
  border-bottom: 1px solid var(--rule);
  text-align: center;
}

.kicker {
  font-family: var(--sans);
  font-size: 0.62em;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.5em;
}

.banner-hed {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.95em;
  line-height: 1.04;
  letter-spacing: -0.015em;
  margin: 0 0 0.35em;
}

.deck {
  font-style: italic;
  font-size: 0.96em;
  line-height: 1.3;
  color: var(--ink-soft);
  max-width: 54ch;
  margin: 0 auto;
}

.deck.left {
  text-align: left;
  margin: 0 0 0.6em;
}

.hed-xl {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.62em;
  line-height: 1.08;
  margin: 0 0 0.3em;
}

.story h3 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.16em;
  line-height: 1.12;
  margin: 0 0 0.3em;
}

.byline {
  font-family: var(--sans);
  font-size: 0.66em;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 0.6em;
}

/* ---------- body text ---------- */

.columns {
  column-gap: 1.4em;
  column-rule: 1px solid var(--hairline);
  text-align: justify;
  hyphens: auto;
}

.columns-2 {
  column-count: 2;
}

.columns-3 {
  column-count: 3;
}

.columns p,
.story p {
  margin: 0 0 0.6em;
}

.story-lead .columns p:first-of-type::first-letter {
  font-family: var(--display);
  font-weight: 800;
  float: left;
  font-size: 3.1em;
  line-height: 0.78;
  padding: 0.06em 0.12em 0 0;
}

.source {
  font-family: var(--sans);
  font-size: 0.62em;
  color: var(--muted);
  margin: 0.2em 0 0.9em;
  letter-spacing: 0.01em;
}

.source a,
.jump a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(140, 23, 23, 0.35);
}

.source a:hover,
.jump a:hover {
  border-bottom-color: var(--accent);
}

.jump {
  font-family: var(--sans);
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin: 0 0 0.5em;
}

/* ---------- editor's desk ---------- */

.editor-grid {
  display: grid;
  grid-template-columns: 0.42fr 1fr;
  gap: 1.1em;
  align-items: start;
  padding-bottom: 0.8em;
  margin-bottom: 0.9em;
  border-bottom: 3px double var(--rule);
}

.editor-note h3 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.28em;
  line-height: 1.12;
  margin: 0 0 0.4em;
}

.editor-note p {
  margin: 0 0 0.5em;
}

.signoff {
  font-family: var(--sans);
  font-size: 0.72em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.kicker.left {
  text-align: left;
  margin-bottom: 0.3em;
}

/* ---------- photos ---------- */

.news-photo {
  margin: 0 0 0.7em;
}

.news-photo img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border: 1px solid var(--rule);
}

.news-photo.wide img {
  aspect-ratio: 8 / 3;
}

/* The front page carries the masthead as well, so its picture runs shallower. */
.page-front .news-photo.wide img {
  aspect-ratio: 16 / 5;
}

.news-photo figcaption,
.portrait figcaption {
  font-size: 0.7em;
  font-style: italic;
  line-height: 1.3;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--hairline);
  padding: 0.3em 0 0.35em;
}

.credit {
  display: block;
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.82em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.2em;
}

.news-photo.is-missing img {
  display: none;
}

.news-photo.is-missing figcaption::before {
  content: "Photograph unavailable offline";
  display: block;
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.8em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f1f1f1;
  border: 1px solid var(--hairline);
  padding: 2.2em 0.5em;
  text-align: center;
  margin-bottom: 0.4em;
}

.portrait {
  margin: 0 0 0.9em;
}

.portrait img {
  display: block;
  width: 100%;
  background: #f3f3f3;
  border: 1px solid var(--rule);
}

/* ---------- boxes ---------- */

.notebook,
.house-ad {
  border: 1px solid var(--rule);
  padding: 0.6em 0.7em;
  margin-bottom: 0.9em;
  background: #fafafa;
}

.notebook h4,
.house-ad h4 {
  font-family: var(--sans);
  font-size: 0.66em;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 0 0 0.5em;
  padding-bottom: 0.35em;
  border-bottom: 1px solid var(--rule);
}

.notebook p,
.house-ad p {
  margin: 0;
  font-size: 0.86em;
  font-style: italic;
}

.house-ad {
  text-align: center;
  background: #f5f5f5;
}

/* The canvas leaves slack under it; drop the house ad towards the fold. */
.games-page .house-ad {
  margin-top: auto;
}

/* ---------- section pages ---------- */

.standing-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1em;
  border-top: 3px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 0.35em 0;
  margin-bottom: 0.9em;
}

.standing-head h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.5em;
  line-height: 1.1;
  margin: 0;
}

.standing-head h2 span {
  font-style: italic;
  font-weight: 600;
}

.folio-tag,
.folio {
  font-family: var(--sans);
  font-size: 0.62em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.story-lead {
  padding-bottom: 0.6em;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 0.9em;
}

/* A page carrying a single story needs no closing rule. */
.story-lead.flush {
  padding-bottom: 0;
  border-bottom: 0;
  margin-bottom: 0;
}

.pull-quote {
  font-family: var(--display);
  font-size: 1.15em;
  font-style: italic;
  line-height: 1.25;
  text-align: center;
  margin: 0 0 1em;
  padding: 0.7em 1.2em;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.pull-quote cite {
  display: block;
  font-family: var(--sans);
  font-size: 0.55em;
  font-style: normal;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.6em;
}

.folio {
  margin-top: auto;
  padding-top: 0.6em;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 0.6em;
}

/* ---------- game page ---------- */

.game-wrap {
  border: 1px solid var(--rule);
  padding: 0.35em;
  background: #101010;
  margin-bottom: 0.6em;
}

/* The game stays in its own document so its engine, styles and assets cannot
   interfere with the newspaper or future games. */
.game-frame {
  display: block;
  width: 100%;
  aspect-ratio: 760 / 600;
  border: 0;
  background: #101010;
}

/* Before start the frame has no src at all, so the placard stands in its place. */
.game-wrap.is-idle .game-frame,
.game-wrap:not(.is-idle) .game-placard {
  display: none;
}

.game-placard {
  aspect-ratio: 760 / 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  text-align: center;
  padding: 1em;
  color: #f6e3c4;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.035) 0 6px, transparent 6px 12px),
    #171310;
}

.game-placard-kicker {
  font-family: var(--sans);
  font-size: 0.62em;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #b99b6a;
  margin: 0;
}

.game-placard-title {
  font-family: var(--display);
  font-weight: 800;
  font-size: 2em;
  line-height: 1.05;
  margin: 0;
}

.game-placard-note {
  font-family: var(--sans);
  font-size: 0.64em;
  letter-spacing: 0.04em;
  color: #9c9188;
  max-width: 28ch;
  margin: 0;
}

#game-start {
  font-family: var(--sans);
  font-size: 0.82em;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  background: #f6e3c4;
  border: 2px solid #5c3317;
  padding: 0.7em 1.6em;
  cursor: pointer;
}

#game-start:hover {
  background: #fff;
}

#game-start:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.game-help {
  font-family: var(--sans);
  font-size: 0.68em;
  letter-spacing: 0.03em;
  color: var(--muted);
  text-align: center;
  margin: 0.5em 0 0.8em;
}

/* ---------- back page ---------- */

.back-body {
  justify-content: center;
  text-align: center;
  gap: 0.4em;
}

.back-hed {
  font-family: var(--display);
  font-weight: 900;
  font-size: 2.6em;
  letter-spacing: -0.03em;
  margin: 0;
}

.back-motto {
  font-style: italic;
  margin: 0.2em 0 0;
  color: var(--ink-soft);
}

.back-rule {
  border-top: 3px double var(--rule);
  margin: 1em auto;
  width: 60%;
}

.colophon {
  font-size: 0.9em;
  color: var(--ink-soft);
  max-width: 46ch;
  margin: 0 auto 0.8em;
}

.colophon.small {
  font-family: var(--sans);
  font-size: 0.66em;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- controls ---------- */

.page-controls {
  display: grid;
  grid-template-columns: 9rem minmax(9rem, 12rem) 9rem;
  justify-content: center;
  align-items: stretch;
  gap: 0;
  margin: 0 auto;
  background: #101010;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.page-controls button {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 700;
  min-height: 2.35rem;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.page-controls button:hover:not(:disabled),
.page-controls button:focus-visible {
  background: #2c2c2c;
}

.page-controls button:disabled {
  opacity: 0.3;
  cursor: default;
}

.page-status {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  padding: 0.2rem 0.6rem;
  border-inline: 1px solid rgba(255, 255, 255, 0.18);
  font-family: var(--sans);
  font-size: 0.64rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  line-height: 1.4;
}

#page-count {
  color: #b9b9b9;
}

/* ---------- page-level responsive: keyed to page width, not viewport ---------- */

@container (max-width: 560px) {
  .columns-3 {
    column-count: 2;
  }
}

@container (max-width: 420px) {
  .editor-grid {
    grid-template-columns: 0.55fr 1fr;
    gap: 0.8em;
  }

  .nameplate {
    font-size: 2.6em;
  }

  .ear-row {
    font-size: 0.6em;
  }
}

@container (max-width: 320px) {
  .editor-grid {
    grid-template-columns: 1fr;
  }

  .columns-2 {
    column-count: 1;
    text-align: left;
  }
}

/* ---------- viewport responsive ---------- */

@media (max-width: 900px) {
  .page-controls {
    grid-template-columns: 1fr 1.1fr 1fr;
    width: min(100%, 26rem);
  }
}
