/* The Reading Room: paper, ink, stamps. */
:root {
  --desk: #e6dcc7;
  --paper: #f7f1e3;
  --card: #fffcf4;
  --ink: #2a241c;
  --ink-2: #554c40;
  --pencil: #857b6e;
  --rule: #cfc1a6;
  --rule-soft: #e2d7c0;
  --blue-line: rgba(74, 108, 158, 0.17);
  --red-line: rgba(176, 62, 46, 0.42);
  --stamp-red: #a8322a;
  --stamp-blue: #2c4c7c;
  --stamp-green: #3b6a48;
  --stamp-gray: #7a7166;
  --hl: rgba(255, 214, 82, 0.55);
  --serif: "EB Garamond", "Garamond", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --display: "Cormorant Garamond", "EB Garamond", Garamond, Georgia, serif;
  --mono: "Courier Prime", "Courier New", Courier, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--desk);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(255,255,255,0.35), rgba(255,255,255,0) 55%),
    radial-gradient(ellipse at 80% 100%, rgba(120,90,50,0.10), rgba(0,0,0,0) 60%);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.55;
  font-variant-numeric: oldstyle-nums;
  padding: 28px 16px 60px;
}
/* paper grain over everything */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 50;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .32 0 0 0 0 .26 0 0 0 0 .17 0 0 0 .5 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  opacity: 0.16;
  mix-blend-mode: multiply;
}

.sheet {
  position: relative;
  max-width: 1180px;
  margin: 0 auto;
  background-color: var(--paper);
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600'><filter id='m'><feTurbulence type='fractalNoise' baseFrequency='.012' numOctaves='2'/><feColorMatrix values='0 0 0 0 .55 0 0 0 0 .45 0 0 0 0 .28 0 0 0 .09 0'/></filter><rect width='100%' height='100%' filter='url(%23m)'/></svg>"),
    radial-gradient(ellipse at center, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0) 70%);
  padding: 44px 56px 36px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.6) inset,
    0 2px 3px rgba(60,40,15,0.10),
    0 14px 40px rgba(60,40,15,0.16);
  border: 1px solid #ddd0b6;
}

/* ---------- masthead ---------- */
.masthead { text-align: center; }
.kicker {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-2);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 8px;
}
.kicker-mid { flex: 1; text-align: center; }
.title {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(48px, 9vw, 104px);
  line-height: 0.95;
  letter-spacing: -0.01em;
  margin: 22px 0 8px;
}
.title em { font-style: italic; font-weight: 500; color: var(--stamp-red); }
.tagline {
  font-style: italic; font-size: 21px; color: var(--ink-2);
  margin: 0 auto 18px; max-width: 40em;
}
.double-rule { border-top: 3px double var(--ink); opacity: 0.75; margin: 6px 0 0; }

/* ---------- stamps ---------- */
.stamp {
  display: inline-block;
  font-family: var(--mono); font-weight: 700;
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--stamp-red);
  border: 2px solid currentColor; border-radius: 4px;
  padding: 2px 8px 1px;
  transform: rotate(-4deg);
  opacity: 0.86;
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='60'><filter id='s'><feTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='2'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.4 2.15'/></filter><rect width='100%' height='100%' filter='url(%23s)'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='60'><filter id='s'><feTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='2'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.4 2.15'/></filter><rect width='100%' height='100%' filter='url(%23s)'/></svg>");
  white-space: nowrap;
}
.stamp.blue { color: var(--stamp-blue); transform: rotate(3deg); }
.stamp.green { color: var(--stamp-green); transform: rotate(-2deg); }
.stamp.gray { color: var(--stamp-gray); transform: rotate(2deg); }
.stamp.press { animation: press 0.42s cubic-bezier(.2,.9,.25,1.15) both; }
@keyframes press {
  0% { transform: scale(1.9) rotate(-10deg); opacity: 0; }
  60% { opacity: 0.95; }
  100% { opacity: 0.86; }
}
.stamp-mode.live { color: var(--stamp-green); }
.stamp-mode.live::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; margin-right: 7px; vertical-align: 1px;
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: 0.25; } }

/* ---------- preview notice ---------- */
.notice {
  margin: 26px auto 8px;
  max-width: 900px;
  padding: 16px 22px 14px;
  background: #fbf4d9;
  border: 1px solid #e6d49a;
  box-shadow: 2px 3px 0 rgba(120, 95, 30, 0.10);
  transform: rotate(-0.35deg);
  position: relative;
}
.notice::before { /* tape */
  content: ""; position: absolute; top: -11px; left: 50%; width: 110px; height: 22px;
  margin-left: -55px; transform: rotate(-2deg);
  background: rgba(236, 226, 196, 0.75);
  border: 1px solid rgba(190, 175, 140, 0.45);
}
.notice p { margin: 0 0 12px; font-size: 17px; }
.smallcaps { font-variant-caps: all-small-caps; letter-spacing: 0.06em; font-weight: 600; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.btn {
  font-family: var(--mono); font-size: 14px; font-weight: 700;
  color: var(--paper); background: var(--ink);
  border: 0; border-radius: 3px; padding: 8px 14px; cursor: pointer;
  box-shadow: 0 2px 0 rgba(0,0,0,0.25);
}
.btn:hover { background: #40362a; }
.btn:focus-visible, .btn-speed:focus-visible { outline: 2px dashed var(--stamp-blue); outline-offset: 3px; }
.btn-quiet { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn-quiet:hover { background: rgba(0,0,0,0.05); }
.speed { display: inline-flex; gap: 4px; }
.btn-speed {
  font-family: var(--mono); font-size: 13px; background: transparent; color: var(--ink-2);
  border: 1px solid var(--rule); border-radius: 3px; padding: 5px 8px; cursor: pointer;
}
.btn-speed[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); background: rgba(255,255,255,0.5); }
.replay-clock { font-family: var(--mono); font-size: 13px; color: var(--pencil); }

/* ---------- section heads ---------- */
section { margin-top: 38px; }
.section-head {
  font-family: var(--mono); font-weight: 700; font-size: 13px;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-2);
  display: flex; align-items: center; gap: 14px;
  margin: 0 0 16px;
}
.section-head::before, .section-head::after { content: ""; flex: 1; border-top: 1px solid var(--rule); }
.section-head::before { flex: 0 0 28px; }
.hint { margin: -8px 0 14px; color: var(--pencil); font-style: italic; font-size: 16px; }

/* ---------- lede ---------- */
.lede-cols { column-count: 2; column-gap: 44px; column-rule: 1px solid var(--rule-soft); }
.lede-cols p { margin: 0 0 14px; text-align: justify; hyphens: auto; }
.dropcap::first-letter {
  font-family: var(--display); font-weight: 600; float: left;
  font-size: 4.1em; line-height: 0.82; padding: 6px 8px 0 0; color: var(--stamp-red);
}

/* ---------- funnel ---------- */
.funnel {
  display: grid; grid-template-columns: 1fr 90px 1fr 90px 1fr; align-items: center;
  text-align: center;
  padding: 22px 0 18px;
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.funnel .big {
  font-family: var(--display); font-weight: 600; font-size: clamp(40px, 5.6vw, 66px); line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
}
.funnel .cap { font-style: italic; color: var(--ink-2); margin-top: 4px; }
.funnel .sofar { font-family: var(--mono); font-size: 13px; color: var(--pencil); margin-top: 6px; }
.funnel-arrow svg { width: 90px; height: 32px; fill: none; stroke: var(--pencil); stroke-width: 2; stroke-linecap: round; }
.pencil-bar {
  width: 70%; margin: 10px auto 0; height: 7px;
  border-bottom: 1px solid var(--rule);
  position: relative;
}
.pencil-bar span {
  position: absolute; left: 0; bottom: 1px; height: 5px; width: 0;
  background: repeating-linear-gradient(115deg, rgba(42,36,28,0.65) 0 2px, rgba(42,36,28,0.2) 2px 4px);
  border-radius: 2px; min-width: 3px;
  transition: width 0.6s ease;
}

/* ---------- trays ---------- */
.trays { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px 20px; }
.tray {
  position: relative;
  background: rgba(255, 255, 255, 0.28);
  border: 1px solid var(--rule-soft);
  border-radius: 2px;
  padding: 12px 14px 14px;
  min-height: 268px;
}
.tray-no { font-family: var(--mono); font-size: 12px; color: var(--pencil); letter-spacing: 0.1em; }
.tray-name { font-family: var(--display); font-weight: 600; font-size: 25px; line-height: 1.1; margin: 2px 0 0; }
.tray-count {
  font-family: var(--display); font-weight: 600; font-size: 38px; line-height: 1.1;
  font-variant-numeric: lining-nums tabular-nums;
}
.tray-sub { font-family: var(--mono); font-size: 12px; color: var(--ink-2); min-height: 18px; }
.tray-desc { font-size: 15px; color: var(--ink-2); font-style: italic; line-height: 1.35; margin: 6px 0 10px; min-height: 60px; }
.tray-count.bump { animation: bump 0.5s ease; }
@keyframes bump { 30% { color: var(--stamp-red); } }

.stack { position: relative; height: 138px; }
.stack .icard { position: absolute; left: 0; right: 0; }
.stack .icard:nth-child(1) { top: 0; z-index: 3; }
.stack .icard:nth-child(2) { top: 8px; left: 6px; right: -6px; z-index: 2; }
.stack .icard:nth-child(3) { top: 16px; left: 12px; right: -12px; z-index: 1; }
/* the cards underneath show only their edges: a pile, not a smudge */
.stack .icard:nth-child(n+2) > * { visibility: hidden; }
.stack .empty { font-style: italic; color: var(--pencil); font-size: 15px; padding-top: 18px; }

/* index card */
.icard {
  background-color: var(--card);
  /* blue rules sit just under each 20px line of title text, never through it; the red rule is a border (::before) */
  background-image: repeating-linear-gradient(to bottom, transparent 0 19px, var(--blue-line) 19px 20px);
  background-position: 0 30px;
  background-size: 100% calc(100% - 30px);
  background-repeat: no-repeat;
  border: 1px solid #e4d9c3;
  box-shadow: 0 1px 2px rgba(70,50,20,0.14), 0 4px 10px rgba(70,50,20,0.06);
  padding: 6px 10px 8px;
  min-height: 118px;
  transform: rotate(var(--tilt, 0deg));
}
.icard::before { content: ""; position: absolute; left: 0; right: 0; top: 25px; border-top: 1.5px solid var(--red-line); }
.stack .icard:nth-child(n+2)::before { visibility: hidden; }
.icard .foot { margin-top: 6px; min-height: 20px; text-align: right; }
.icard .meta {
  font-family: var(--mono); font-size: 11px; color: var(--ink-2);
  display: flex; justify-content: space-between; gap: 8px;
  height: 20px; overflow: hidden; white-space: nowrap;
}
.icard .t {
  font-size: 15px; line-height: 20px; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.icard .stamp { font-size: 10px; padding: 1px 6px 0; }
.icard.enter { animation: drop 0.45s cubic-bezier(.2,.8,.2,1) both; }
@keyframes drop {
  0% { transform: translate(-14px, -22px) rotate(-6deg); opacity: 0; }
  100% { transform: rotate(var(--tilt, 0deg)); opacity: 1; }
}

/* ---------- desk + ledger ---------- */
.two-col { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 40px; }
.desk-card::before { /* drawn as a border so it stays one clean line on a tilted card */
  content: ""; position: absolute; left: 0; right: 0; top: 40px;
  border-top: 2px solid var(--red-line);
}
.desk-card {
  position: relative;
  background-color: var(--card);
  border: 1px solid #e4d9c3;
  box-shadow: 0 2px 4px rgba(70,50,20,0.14), 0 12px 26px rgba(70,50,20,0.10);
  padding: 14px 22px 22px;
  transform: rotate(-0.4deg);
  margin-bottom: 18px;
}
.desk-card .meta { font-family: var(--mono); font-size: 12px; color: var(--ink-2); height: 24px; overflow: hidden; }
.desk-card h3 { font-family: var(--display); font-weight: 600; font-size: 28px; line-height: 1.15; margin: 16px 0 2px; }
.desk-card .byline { font-style: italic; color: var(--ink-2); margin-bottom: 12px; }
.reader-row {
  display: grid; grid-template-columns: 118px 1fr auto; align-items: center; gap: 12px;
  font-family: var(--mono); font-size: 14px; padding: 5px 0;
}
.reader-row .who { font-weight: 700; }
.reader-row .line { height: 10px; position: relative; }
.reader-row .line svg { width: 100%; height: 10px; overflow: visible; }
.reader-row .line path { fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; opacity: 0.75; }
/* a pencil line that keeps writing itself while the reader works */
.reader-row.reading .line path { stroke-dasharray: 320; stroke-dashoffset: 320; animation: write 2.8s ease-in-out infinite; }
.reader-row.waiting .line path { opacity: 0.22; stroke-dasharray: 2 6; }
@keyframes write { 0% { stroke-dashoffset: 320; } 75% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 0; opacity: 0.2; } }
.reader-row .what { color: var(--ink-2); white-space: nowrap; }
.reader-row.reading .what { background: linear-gradient(104deg, transparent 1%, var(--hl) 3%, var(--hl) 95%, transparent 99%); padding: 0 4px; }
.desk-stamps { display: flex; flex-wrap: wrap; gap: 10px 12px; margin-top: 16px; min-height: 26px; }
.desk-empty { font-style: italic; color: var(--pencil); padding: 30px 0; text-align: center; }

.ledger {
  list-style: none; margin: 0; padding: 0;
  font-family: var(--mono); font-size: 13.5px; line-height: 1.45;
  max-height: 560px; overflow-y: auto;
  border-top: 1px solid var(--rule-soft);
}
.ledger li { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding: 8px 2px 10px; border-bottom: 1px solid var(--rule-soft); }
.ledger time { color: var(--pencil); }
.ledger li.k-kept span::before { content: "✓ "; color: var(--stamp-green); font-weight: 700; }
.ledger li.k-note span { font-style: italic; color: var(--stamp-red); }

/* the readers, under the desk */
.readers { margin-top: 26px; }
.readers h4 { font-family: var(--mono); font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-2); margin: 0 0 10px; }
.readers dl { margin: 0; display: grid; grid-template-columns: 128px 1fr; gap: 10px 14px; }
.readers dt { font-family: var(--mono); font-weight: 700; font-size: 14px; padding-top: 3px; }
.readers dd { margin: 0; font-size: 16px; line-height: 1.4; color: var(--ink-2); }
.ledger li.new { animation: typein 0.5s ease both; }
@keyframes typein { from { opacity: 0; transform: translateY(-6px); background: var(--hl); } to { opacity: 1; } }

/* ---------- pinned board ---------- */
.pinned { display: grid; grid-template-columns: repeat(3, 1fr); gap: 26px 22px; padding-top: 8px; }
.note {
  position: relative;
  background: #fffdf6;
  border: 1px solid #e7dcc5;
  box-shadow: 0 2px 3px rgba(70,50,20,0.12), 0 8px 18px rgba(70,50,20,0.07);
  padding: 22px 18px 14px;
  transform: rotate(var(--tilt, 0deg));
}
.note .clip { position: absolute; top: -14px; left: 22px; width: 18px; height: 42px; }
.note .clip path { fill: none; stroke: #8f8c86; stroke-width: 2.2; stroke-linecap: round; }
.note p { margin: 0 0 12px; font-size: 16px; line-height: 1.45; }
.note .by { font-family: var(--mono); font-size: 11.5px; color: var(--ink-2); border-top: 1px dashed var(--rule); padding-top: 8px; }
.note .by em { font-family: var(--serif); font-size: 13.5px; }
.note.enter { animation: drop 0.5s cubic-bezier(.2,.8,.2,1) both; }

.more-notes { display: none; }

/* ---------- rules + colophon ---------- */
.rules-list { margin: 0; padding-left: 26px; columns: 2; column-gap: 44px; }
.rules-list li { margin: 0 0 12px; break-inside: avoid; }
.pencil { font-family: var(--mono); font-size: 13px; color: var(--stamp-blue); }
.colophon { margin-top: 44px; text-align: center; color: var(--ink-2); font-size: 16px; }
.colophon p { margin: 12px 0 0; }
.colophon .updated { font-family: var(--mono); font-size: 12px; color: var(--pencil); }

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .sheet { padding: 34px 30px 30px; }
  .trays { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .pinned { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  body { padding: 0; font-size: 17px; }
  .sheet { padding: 24px 18px 26px; border: 0; }
  .kicker { font-size: 11px; }
  .kicker-mid { display: none; }
  .tagline { font-size: 18px; }
  .lede-cols { column-count: 1; }
  .lede-cols p { text-align: left; }
  .funnel { grid-template-columns: 1fr; gap: 4px; }
  .funnel-arrow svg { display: none; }
  .funnel-arrow::after { content: "↓"; font-size: 26px; line-height: 1; color: var(--pencil); }
  .trays { grid-template-columns: 1fr; gap: 14px; }
  .tray { min-height: 0; display: grid; grid-template-columns: 1fr auto; column-gap: 12px; padding: 10px 12px 12px; }
  .tray > .tray-no, .tray > .tray-name, .tray > .tray-sub, .tray > .tray-desc, .tray > .stack { grid-column: 1 / -1; }
  .tray > .tray-count { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 34px; }
  .tray > .tray-no { grid-column: 1; }
  .tray > .tray-name { grid-column: 1; font-size: 23px; }
  .tray-desc { min-height: 0; font-size: 15px; margin: 4px 0 8px; }
  .stack { height: auto; }
  .stack .icard { position: relative; left: auto; right: auto; top: auto; min-height: 0; }
  .stack .icard:nth-child(n+2) { display: none; }
  .pinned { grid-template-columns: 1fr; }
  .pinned:not(.all) .note:nth-child(n+4) { display: none; }
  .more-notes:not([hidden]) { display: inline-block; margin-top: 18px; }
  .rules-list { columns: 1; }
  .reader-row { grid-template-columns: 96px 1fr auto; font-size: 13px; }
  .desk-card h3 { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
