/* ============================================================
   THE READING ROOM — the multiverse's library
   The author site's reading pages: one paper column floating
   in the starfield, a bookmark ribbon that fills as you read,
   part dividers, drop caps, poem stanzas. Same house — the
   galaxy, the gold, the star cursor.
   ============================================================ */

/* self-hosted fonts (latin subset) — zero external requests */
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 500 800;
  font-display: swap;
  src: url("../fonts/bricolage-grotesque.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/jetbrains-mono.woff2") format("woff2");
}
@font-face {
  font-family: "Space Grotesk";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("../fonts/space-grotesk.woff2") format("woff2");
}
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/cormorant-garamond.woff2") format("woff2");
}
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("../fonts/cormorant-garamond-italic.woff2") format("woff2");
}

:root {
  --bg: #07070f;
  --bg-2: #0d0b16;
  --ink: #f2efe4;
  --muted: #a29eb6;
  --faint: #6f6b84;
  --line: rgba(255, 255, 255, 0.09);
  --card: rgba(255, 255, 255, 0.028);
  --card-hover: rgba(255, 255, 255, 0.055);
  --gold: #e8c67a;
  --gold-bright: #ffd97a;
  --gold-deep: #a97e28;
  --accent: var(--gold);
  --accent-2: #8fb4ff;
  --paper: #f1ebdd;
  --paper-ink: #2b2620;
  --paper-faint: #8a7a5e;
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-body: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "Consolas", monospace;
  --radius: 18px;
  --nav-h: 96px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(232, 198, 122, 0.4); color: #fff; }

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
ul, ol { list-style: none; }

:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: fixed;
  top: -60px;
  left: 16px;
  z-index: 1000;
  padding: 10px 18px;
  background: var(--gold);
  color: #241a04;
  border-radius: 10px;
  font-weight: 600;
  transition: top 0.25s;
}
.skip-link:focus { top: 12px; }

/* ============ ambient background ============ */

#starfield {
  position: fixed;
  inset: 0;
  z-index: -3;
  display: block;
}

/* the barred spiral — the multiverse's signature */
#galaxy {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(155vmin, 1600px);
  height: min(155vmin, 1600px);
  margin: calc(min(155vmin, 1600px) / -2) 0 0 calc(min(155vmin, 1600px) / -2);
  z-index: -2;
  border-radius: 50%;
  background: url("images/galaxy.jpg") center / cover no-repeat;
  opacity: 0.5;
  filter: saturate(1.2) brightness(0.9);
  -webkit-mask-image: radial-gradient(circle, #000 0%, rgba(0,0,0,0.85) 36%, transparent 70%);
  mask-image: radial-gradient(circle, #000 0%, rgba(0,0,0,0.85) 36%, transparent 70%);
  animation: galaxySpin 240s linear infinite;
  will-change: transform, opacity;
  pointer-events: none;
}
@keyframes galaxySpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
/* soft vignette so text always wins */
#vignette {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 120% 90% at 50% 0%, rgba(7, 7, 15, 0.3) 0%, transparent 55%),
    radial-gradient(ellipse 140% 100% at 50% 110%, rgba(7, 7, 15, 0.82) 0%, transparent 60%);
}

/* ============ star cursor ============ */

.cursor-star {
  position: fixed;
  top: 0; left: 0;
  z-index: 9999;
  pointer-events: none;
  font-size: 17px;
  line-height: 1;
  color: var(--gold-bright);
  text-shadow: 0 0 12px rgba(255, 217, 122, 0.85);
  display: none;
  will-change: transform;
}
body.has-cursor .cursor-star { display: block; }
body.has-cursor,
body.has-cursor a,
body.has-cursor button { cursor: none; }

/* ============ bookmark ribbon (reading progress) ============
   lives on the text pages only — the room is a gallery, not a book */

.ribbon {
  position: fixed;
  top: 0;
  right: 20px;
  width: 16px;
  height: 0;
  z-index: 60;
  display: none;
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 55%, var(--gold-deep) 100%);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 9px), 50% 100%, 0 calc(100% - 9px));
  box-shadow: 0 0 16px rgba(232, 198, 122, 0.35);
  transition: height 0.12s linear;
  pointer-events: none;
}
.ribbon.on-page { display: block; }

/* ============ nav ============ */

#site-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 48px);
  transition: background 0.35s, border-color 0.35s, backdrop-filter 0.35s;
  border-bottom: 1px solid transparent;
}
#site-nav.scrolled {
  background: rgba(7, 7, 15, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom-color: var(--line);
}

.brand { display: inline-flex; align-items: center; }
/* the logo in the nav — screen blend lets its starfield-black
   dissolve into whatever is behind the bar */
.brand-logo {
  height: 88px;
  width: auto;
  mix-blend-mode: screen;
  filter: drop-shadow(0 0 16px rgba(255, 214, 140, 0.28)) saturate(1.05);
  transition: filter 0.3s;
}
.brand:hover .brand-logo {
  filter: drop-shadow(0 0 26px rgba(255, 214, 140, 0.5)) saturate(1.15);
}

#nav-links { display: flex; align-items: center; gap: clamp(16px, 2.4vw, 30px); }
#nav-links > a {
  font-size: 14.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
  transition: color 0.25s;
  position: relative;
}
#nav-links > a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: -6px;
  height: 1px;
  background: var(--gold);
  transition: right 0.3s;
}
#nav-links > a:hover { color: var(--ink); }
#nav-links > a:hover::after { right: 0; }

/* ============ main ============ */

#main {
  position: relative;
  z-index: 1;
  padding-top: calc(var(--nav-h) + clamp(40px, 8vh, 84px));
  padding-bottom: 60px;
  min-height: 100vh;
}

/* ============ the room (index) ============ */

.room-head {
  max-width: 860px;
  margin: 0 auto clamp(40px, 7vh, 72px);
  padding: 0 clamp(20px, 4vw, 48px);
  text-align: center;
}
.room-kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 18px;
}
.room-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(44px, 7.4vw, 84px);
  line-height: 1.02;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.room-title em {
  font-style: italic;
  color: var(--gold);
}
.room-sub {
  margin: 22px auto 0;
  max-width: 560px;
  color: var(--muted);
  font-size: 16.5px;
  line-height: 1.7;
}
.room-stats {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}
.room-stats span {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--card);
}
.room-stats b { color: var(--gold-bright); font-weight: 700; }

.shelf-section {
  max-width: 1080px;
  margin: 0 auto clamp(56px, 9vh, 96px);
  padding: 0 clamp(20px, 4vw, 48px);
}
.shelf-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: 26px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.shelf-head h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 3.6vw, 40px);
  letter-spacing: 0.01em;
}
.shelf-head .shelf-line {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.shelf-head .shelf-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--faint);
}

.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.work-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  position: relative;
  transition: background 0.3s, border-color 0.3s, transform 0.3s;
  overflow: hidden;
}
.work-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(420px 200px at var(--mx, 50%) var(--my, 0%), rgba(232, 198, 122, 0.09), transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.work-card:hover {
  background: var(--card-hover);
  border-color: color-mix(in srgb, var(--accent, var(--gold)) 45%, transparent);
  transform: translateY(-3px);
}
.work-card:hover::before { opacity: 1; }
.work-card .wc-cover {
  width: 54px;
  height: auto;
  border-radius: 3px;
  transform: rotate(-2.5deg);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition: transform 0.35s;
}
.work-card:hover .wc-cover { transform: rotate(0deg) scale(1.05); }
.work-card .wc-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.work-card .wc-kind {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent, var(--gold));
}
/* the Story - Complete tag keeps one consistent blue, whatever the card accent */
.work-card .wc-rapid { color: var(--accent-2); }
.bm-rapid { color: var(--accent-2); }
.work-card .wc-words {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--faint);
  white-space: nowrap;
}
.work-card h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 23px;
  line-height: 1.15;
  color: var(--ink);
}
.work-card p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  flex: 1;
}
.work-card .wc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--faint);
}
.work-card .wc-read {
  color: var(--gold);
  transition: color 0.25s, letter-spacing 0.25s;
}
.work-card:hover .wc-read { color: var(--gold-bright); letter-spacing: 0.12em; }

/* ============ the reader (a book) ============ */

.book {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 clamp(18px, 4vw, 48px);
}

.book-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(20px, 4vw, 44px);
  margin-bottom: clamp(28px, 5vh, 48px);
}
.book-head-text { flex: 1; min-width: 0; }
.book-kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent, var(--gold));
  margin-bottom: 14px;
}
.book-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(40px, 6.4vw, 72px);
  line-height: 1.02;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.book-title em { font-style: italic; color: var(--gold); }
.book-meta {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.book-meta .bm-dot { color: var(--gold-deep); }
.book-cover {
  flex: 0 0 auto;
  width: clamp(120px, 16vw, 170px);
  border-radius: 6px;
  border: 1px solid var(--line);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.6), 0 0 40px rgba(232, 198, 122, 0.12);
  transform: rotate(1.4deg);
  transition: transform 0.4s;
}
.book-cover:hover { transform: rotate(0deg) scale(1.02); }

.book-note {
  margin: -14px 0 26px;
  padding: 14px 20px;
  border-left: 2px solid var(--gold-deep);
  background: rgba(232, 198, 122, 0.06);
  border-radius: 0 10px 10px 0;
  font-size: 14.5px;
  color: var(--muted);
  font-style: italic;
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.6;
}

/* the premise — a small dossier card */
.premise {
  margin: 0 0 30px;
  padding: 22px 26px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.premise h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}
.premise p {
  font-size: 14.5px;
  color: var(--muted);
  line-height: 1.65;
  margin-bottom: 7px;
}
.premise p:last-child { margin-bottom: 0; }

/* the paper page */
.page {
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 6px;
  padding: clamp(30px, 6vw, 64px) clamp(24px, 6vw, 72px);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.55),
    inset 0 0 60px rgba(120, 96, 60, 0.12);
  position: relative;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 18.5px;
  line-height: 1.85;
  animation: pageIn 0.5s ease-out;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(12px) rotate(0.2deg); }
  to   { opacity: 1; transform: none; }
}
.page::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 34px;
  background: linear-gradient(90deg, rgba(90, 70, 40, 0.18), transparent);
  border-radius: 6px 0 0 6px;
  pointer-events: none;
}

.page p { margin-bottom: 1.1em; }
.page p:last-child { margin-bottom: 0; }

/* drop cap on the very first paragraph */
.page .dropcap::first-letter {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 3.3em;
  float: left;
  line-height: 0.82;
  padding: 5px 10px 0 0;
  color: #6b4a12;
}

/* part dividers */
.part-divider {
  display: flex;
  align-items: center;
  gap: 18px;
  margin: clamp(30px, 5vw, 52px) 0 clamp(20px, 3.4vw, 34px);
  color: var(--paper-faint);
}
.part-divider::before,
.part-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(138, 122, 94, 0.55));
}
.part-divider::after {
  background: linear-gradient(90deg, rgba(138, 122, 94, 0.55), transparent);
}
.part-divider span {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  white-space: nowrap;
}
.part-divider .pd-star { color: #b08d3e; }

/* the first part divider sits closer to the top edge */
.page > .part-divider:first-child { margin-top: 0; }

/* poems — stanzas */
.poem {
  font-size: 17.5px;
  line-height: 1.9;
}
.poem p { margin-bottom: 1.6em; white-space: pre-line; }
.poem p:last-child { margin-bottom: 0; }

/* the three-voice poem: mountain / shared line / city */
.poem3 { font-size: 17.5px; line-height: 1.75; }
.p3-row {
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  gap: 0 22px;
  padding: 9px 0;
  border-bottom: 1px dotted rgba(138, 122, 94, 0.4);
}
.p3-row:last-child { border-bottom: 0; }
.p3-left  { color: #4c5a3a; }
.p3-center{
  font-style: italic;
  font-weight: 700;
  color: #6b4a12;
  text-align: center;
}
.p3-right { color: #5a4a3a; text-align: right; }

/* the end */
.the-end {
  margin-top: clamp(34px, 6vw, 60px);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--paper-faint);
}
.the-end .te-star { color: #b08d3e; display: block; font-size: 18px; letter-spacing: 0; margin-bottom: 10px; }
.the-end .te-continues {
  display: block;
  margin-top: 8px;
  letter-spacing: 0.14em;
  font-size: 10.5px;
  color: #a08a62;
}

/* related works + prev/next */
.book-nav {
  margin-top: clamp(36px, 6vh, 60px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.bn-card {
  padding: 18px 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: background 0.3s, border-color 0.3s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bn-card:hover {
  background: var(--card-hover);
  border-color: color-mix(in srgb, var(--gold) 40%, transparent);
}
.bn-card.next { text-align: right; align-items: flex-end; }
.bn-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}
.bn-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  color: var(--ink);
  line-height: 1.2;
}
.bn-card:hover .bn-title { color: var(--gold-bright); }
.bn-spacer { visibility: hidden; }

.book-related {
  margin-top: 22px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--faint);
}
.book-related a { color: var(--gold); }
.book-related a:hover { color: var(--gold-bright); text-decoration: underline; text-underline-offset: 4px; }

/* ============ footer ============ */

.footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line);
  padding: 38px clamp(20px, 4vw, 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--faint);
  font-size: 13.5px;
  background: rgba(7, 7, 15, 0.5);
  text-align: center;
}
/* the writer's seal — background removed in the asset itself */
.footer-seal {
  width: 84px;
  height: 84px;
}
.footer a { color: var(--muted); transition: color 0.25s; }
.footer a:hover { color: var(--gold-bright); }
/* ============ reveal on scroll ============ */

.reveal {
  opacity: 0;
  transform: translateY(26px);
}
.reveal.in-view { opacity: 1; transform: none; }
@media (prefers-reduced-motion: no-preference) {
  .reveal.in-view {
    animation: rise 0.7s cubic-bezier(0.2, 0.6, 0.2, 1) backwards;
    animation-delay: calc(var(--i, 0) * 70ms);
  }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(26px); }
}

/* ============ responsive ============ */

@media (max-width: 1200px) {
  .brand-logo { height: 64px; }
}

@media (max-width: 720px) {
  .ribbon, .ribbon.on-page { display: none; }
  .book-head { flex-direction: column; align-items: flex-start; }
  .book-cover { width: 130px; transform: rotate(0); }
  .book-nav { grid-template-columns: 1fr; }
  .bn-card.next { text-align: left; align-items: flex-start; }
  .p3-row { grid-template-columns: 1fr; gap: 2px 0; padding: 12px 0; }
  .p3-center { text-align: left; }
  .p3-right { text-align: left; }
  .p3-left  { color: #7c9a5a; }
  .p3-right { color: #9a8a7a; }
  .p3-row .p3-left, .p3-row .p3-right { font-size: 15.5px; }
  #nav-links { gap: 14px; }
  #nav-links > a { font-size: 13px; }

/* ============ reduced motion ============ */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  #galaxy { animation: none; }
  .reveal { opacity: 1; transform: none; }
  .cursor-star { display: none !important; }
}
