@import url("https://fonts.googleapis.com/css2?family=Anybody:wdth,wght@75..150,400..900&family=DM+Mono:ital,wght@0,300;0,400;0,500;1,400&display=swap");

:root {
  --paper: #F2EBDD;
  --paper2: #ECE3D1;
  --ink: #1E1A16;
  --mut: #6B6256;
  --tick: #B9AE9C;
  --rule: #1E1A16;
  --accent: #B5401F;
  --coral: #E4572E;
  --green: #2F7446;
  --card: #F2EBDD;
  --shadow: rgba(30, 26, 22, 0.12);
  --dot: rgba(30, 26, 22, 0.17);
  --display: "Anybody", "Arial Black", system-ui, sans-serif;
  --mono: "DM Mono", "Courier New", ui-monospace, monospace;
  --gut: clamp(16px, 3.9vw, 48px);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --paper: #16130F;
  --paper2: #1E1A16;
  --ink: #F2EBDD;
  --mut: #B9AE9C;
  --tick: #6B6256;
  --rule: #F2EBDD;
  --accent: #E4572E;
  --coral: #E4572E;
  --green: #6FA87A;
  --card: #1E1A16;
  --shadow: rgba(0, 0, 0, 0.45);
  --dot: rgba(242, 235, 221, 0.12);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #16130F;
    --paper2: #1E1A16;
    --ink: #F2EBDD;
    --mut: #B9AE9C;
    --tick: #6B6256;
    --rule: #F2EBDD;
    --accent: #E4572E;
    --coral: #E4572E;
    --green: #6FA87A;
    --card: #1E1A16;
    --shadow: rgba(0, 0, 0, 0.45);
    --dot: rgba(242, 235, 221, 0.12);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}
body {
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100%;
  background-color: var(--paper);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.5px);
  background-size: 24px 24px;
  background-attachment: local;
}
a { color: inherit; text-underline-offset: 4px; }
a:hover { color: var(--accent); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 4px; }

.masthead {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px var(--gut) 10px;
}
.masthead-row {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.kicker {
  margin: 0 0 10px;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--mut);
  text-transform: none;
}
h1 {
  font-family: var(--display);
  font-stretch: 125%;
  font-weight: 800;
  font-size: clamp(2.4rem, 6vw, 4.2rem);
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 0.95;
}
.sub {
  margin: 14px 0 0;
  color: var(--mut);
  font-family: var(--mono);
  font-size: 13.5px;
  max-width: 36rem;
}
.hint {
  margin: 22px 0 4px;
  color: var(--mut);
  font-size: 13.5px;
  max-width: 40rem;
}
nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-family: var(--mono);
  font-size: 13.5px;
}
nav a {
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 5px;
}
.tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
  padding-top: 4px;
}
.toggles { display: flex; gap: 8px; }
.chip {
  background: transparent;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  padding: 7px 12px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 13px;
  min-height: 36px;
}
.chip[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

#page {
  max-width: 1120px;
  margin: 0 auto 72px;
  padding: 12px var(--gut) 48px;
}
.section-title {
  margin: 36px 0 16px;
  padding-top: 12px;
  border-top: 1.5px solid var(--tick);
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mut);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 18px;
}
.story-card {
  aspect-ratio: 1;
  position: relative;
  background: var(--card);
  border: 1.5px solid var(--ink);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  box-shadow: none;
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.story-card:hover, .story-card:focus-visible {
  transform: translate(-1px, -1px);
  border-color: var(--accent);
  outline: none;
}
.story-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #F2EBDD;
}
.story-card .badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--paper);
  color: var(--accent);
  border: 1.5px solid var(--accent);
  font-family: var(--mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 0;
}
.story-card .play {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 28px;
  height: 28px;
  border-radius: 0;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  display: grid;
  place-items: center;
  font-size: 12px;
}

#board {
  position: relative;
  height: calc(100vh - 230px);
  min-height: 520px;
  overflow: hidden;
  cursor: grab;
}
#board:active { cursor: grabbing; }
#board .story-card { width: 200px; height: 200px; }
.wall-label {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mut);
  white-space: nowrap;
}

#reader-root {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
}
#reader-root[hidden] { display: none; }
.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 26, 22, 0.42);
}
.reader {
  position: relative;
  width: min(92vw, 560px);
  max-height: min(92vh, 720px);
  aspect-ratio: 1;
  overflow: auto;
  background: var(--card);
  color: var(--ink);
  border: 1.5px solid var(--ink);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  transform: none;
  background-image: radial-gradient(var(--dot) 1px, transparent 1.5px);
  background-size: 24px 24px;
}
@media (max-width: 640px) {
  .reader {
    aspect-ratio: auto;
    width: min(94vw, 560px);
    height: min(92vh, 760px);
  }
}
.reader-art {
  background: #F2EBDD;
  border-bottom: 1.5px solid var(--tick);
  flex: 0 0 auto;
}
.reader-art img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 46vh;
  object-fit: contain;
}
.reader-body { padding: 18px 20px 24px; }
.reader-kicker {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mut);
}
#reader-title {
  margin: 0 0 10px;
  font-family: var(--display);
  font-stretch: 110%;
  font-weight: 750;
  font-size: 1.45rem;
  letter-spacing: -0.015em;
  line-height: 1.15;
}
.preview { margin: 0 0 14px; }
.why {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--mut);
}
.sources {
  padding-left: 18px;
  margin: 10px 0 16px;
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.5;
}
.sources a { text-underline-offset: 3px; }
.primary-link {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 14px;
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}
.close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: var(--paper);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}
.lang-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 4px 0 12px;
}
.lang-toggle {
  display: inline-flex;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  overflow: hidden;
}
.lang-toggle button {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 13px;
}
.lang-toggle button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}
.lang-toggle button:disabled { opacity: 0.45; cursor: not-allowed; }
.lang-note {
  margin: 0;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--mut);
}

.empty, .error {
  color: var(--mut);
  padding: 28px 0;
  font-family: var(--mono);
}

@media (prefers-reduced-motion: reduce) {
  .story-card, .reader { transition: none; transform: none; }
}
