/* books.v-sag.com — the library. Cosmic / gold theme, matched to the house. */

:root {
  --bg: #07090f;
  --bg-soft: #0d1018;
  --panel: rgba(20, 24, 36, 0.6);
  --panel-2: rgba(28, 33, 50, 0.78);
  --ink: #f3f1ea;
  --ink-dim: #b3b2c4;
  --ink-faint: #767690;
  --line: rgba(255, 255, 255, 0.09);
  --line-2: rgba(255, 255, 255, 0.14);
  --gold: #e8b873;
  --gold-2: #f0d9a8;
  --sky: #6fa8dc;
  --accent: var(--gold);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --maxw: 1180px;
  --read: 40rem;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

.serif { font-family: "Fraunces", "Cormorant Garamond", Georgia, serif; }

/* ---- cosmic backdrop ---- */
.stars, .glow { position: fixed; inset: 0; pointer-events: none; }
.stars {
  z-index: -2;
  background-color: var(--bg);
  background-image:
    radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,.7), transparent),
    radial-gradient(1px 1px at 70% 20%, rgba(255,255,255,.5), transparent),
    radial-gradient(1px 1px at 40% 70%, rgba(255,255,255,.6), transparent),
    radial-gradient(1px 1px at 85% 60%, rgba(255,255,255,.4), transparent),
    radial-gradient(1.5px 1.5px at 55% 45%, rgba(255,255,255,.5), transparent),
    radial-gradient(1px 1px at 12% 82%, rgba(255,255,255,.5), transparent),
    radial-gradient(1px 1px at 92% 90%, rgba(255,255,255,.4), transparent);
  opacity: .55;
}
.glow {
  z-index: -1;
  background:
    radial-gradient(60vmax 50vmax at 75% -10%, rgba(232,184,115,.10), transparent 70%),
    radial-gradient(50vmax 50vmax at 5% 110%, rgba(111,168,220,.10), transparent 70%);
}

a { color: inherit; text-decoration: none; }

/* ---- shell ---- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(1.2rem, 4vw, 2.4rem); }

.nav {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(12px);
  background: linear-gradient(to bottom, rgba(7,9,15,.88), rgba(7,9,15,.3));
  border-bottom: 1px solid var(--line);
}
.nav__in { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { display: flex; align-items: baseline; gap: .6rem; letter-spacing: .04em; }
.brand b { font-weight: 700; }
.brand span { color: var(--ink-faint); font-size: .82rem; letter-spacing: .18em; text-transform: uppercase; }
.nav__links { display: flex; gap: 1.4rem; font-size: .9rem; }
.nav__links a { color: var(--ink-dim); transition: color .2s var(--ease); }
.nav__links a:hover { color: var(--gold-2); }
.nav__links a.here { color: var(--ink); }

.eyebrow {
  font-size: .76rem; letter-spacing: .22em; text-transform: uppercase;
  color: var(--gold); font-weight: 600;
}

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .72rem 1.3rem; border-radius: 999px;
  font-size: .92rem; font-weight: 500; cursor: pointer;
  border: 1px solid var(--line-2); background: transparent; color: var(--ink);
  transition: transform .2s var(--ease), background .2s, border-color .2s, color .2s;
}
.btn:hover { transform: translateY(-2px); border-color: var(--gold); }
.btn--gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color: #1a1206; border-color: transparent; font-weight: 600;
}
.btn--gold:hover { box-shadow: 0 10px 30px rgba(232,184,115,.25); }
.btn--ghost { color: var(--ink-dim); }

/* ---- status badge ---- */
.badge {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 600;
  padding: .32rem .7rem; border-radius: 999px; border: 1px solid var(--line-2);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge--live { color: var(--gold-2); border-color: rgba(232,184,115,.4); }
.badge--writing { color: var(--sky); border-color: rgba(111,168,220,.4); }

/* ============ HOME / LIBRARY ============ */
.hero { padding: clamp(3.5rem, 9vw, 7rem) 0 clamp(2rem, 5vw, 3.5rem); }
.hero h1 {
  font-weight: 600; line-height: 1.04; letter-spacing: -.01em;
  font-size: clamp(2.6rem, 7vw, 5rem); margin: .5rem 0 1.1rem;
}
.hero h1 em { font-style: italic; color: var(--gold-2); }
.hero .lead { color: var(--ink-dim); font-size: clamp(1.05rem, 2.2vw, 1.3rem); max-width: 40rem; }

.shelf { display: grid; gap: clamp(1.5rem, 3vw, 2.2rem); padding-bottom: clamp(3rem,7vw,5rem); }

.feature {
  display: grid; grid-template-columns: minmax(0, 240px) 1fr; gap: clamp(1.4rem, 3vw, 2.6rem);
  align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px;
  padding: clamp(1.4rem, 3vw, 2.4rem); position: relative; overflow: hidden;
  transition: border-color .3s var(--ease), transform .3s var(--ease);
}
.feature::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(40vmax 30vmax at 100% 0, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%);
  opacity: .8;
}
.feature:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.cover-shell { position: relative; }
.cover {
  display: block; width: 100%; aspect-ratio: 2/3; object-fit: cover;
  border-radius: 10px; box-shadow: 0 24px 60px rgba(0,0,0,.55), 0 0 0 1px var(--line);
  background: var(--bg-soft);
}
.feature__body { position: relative; z-index: 1; }
.feature__body h2 {
  font-weight: 600; font-size: clamp(1.7rem, 4vw, 2.6rem); line-height: 1.05; margin: .6rem 0 .3rem;
}
.feature__sub { color: var(--gold-2); font-style: italic; font-size: 1.05rem; margin-bottom: .9rem; }
.feature__hook { color: var(--ink-dim); max-width: 38rem; margin-bottom: 1.3rem; }
.feature__cta { display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; }
.feature__meta { color: var(--ink-faint); font-size: .85rem; margin-top: .9rem; }
.progressbar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; margin: .2rem 0 .4rem; max-width: 22rem; }
.progressbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--sky), #a9cdf0); }

/* author block */
.author {
  display: grid; grid-template-columns: 1fr; gap: 1rem;
  border-top: 1px solid var(--line); padding: clamp(3rem,6vw,4.5rem) 0;
}
.author h3 { font-weight: 600; font-size: clamp(1.6rem,3.5vw,2.2rem); margin-bottom: .3rem; }
.author .kicker { color: var(--ink-faint); margin-bottom: 1.4rem; }
.author p { color: var(--ink-dim); max-width: 46rem; margin-bottom: .9rem; }

.footer {
  border-top: 1px solid var(--line); padding: 2.4rem 0 3.2rem;
  color: var(--ink-faint); font-size: .86rem;
  display: flex; flex-wrap: wrap; gap: 1.2rem; justify-content: space-between; align-items: center;
}
.footer a { color: var(--ink-dim); }
.footer a:hover { color: var(--gold-2); }

/* ============ BOOK DETAIL ============ */
.book { display: grid; grid-template-columns: minmax(0, 300px) 1fr; gap: clamp(2rem,5vw,4rem); padding: clamp(2.5rem,6vw,4.5rem) 0 2rem; align-items: start; }
.book__cover-col { position: sticky; top: 90px; }
.book__cta { display: flex; flex-direction: column; gap: .7rem; margin-top: 1.3rem; }
.book h1 { font-weight: 600; font-size: clamp(2.2rem,5vw,3.4rem); line-height: 1.04; margin: .6rem 0 .2rem; }
.book__sub { color: var(--gold-2); font-style: italic; font-size: 1.2rem; margin-bottom: 1.2rem; }
.book__blurb p { color: var(--ink-dim); margin-bottom: 1rem; max-width: 44rem; }
.epigraph {
  border-left: 2px solid var(--gold); padding: .2rem 0 .2rem 1.2rem; margin: 1.8rem 0;
  font-family: "Fraunces", Georgia, serif; font-style: italic; color: var(--ink); max-width: 40rem;
}
.epigraph cite { display: block; font-style: normal; font-size: .85rem; color: var(--ink-faint); margin-top: .5rem; letter-spacing: .04em; }

.toc { margin-top: 2.4rem; }
.toc h4 { font-size: .78rem; letter-spacing: .2em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: .9rem; }
.toc ol { list-style: none; }
.toc li a, .toc li span {
  display: flex; align-items: baseline; gap: .8rem; padding: .7rem .2rem;
  border-bottom: 1px solid var(--line); transition: color .2s, padding-left .2s var(--ease);
}
.toc li a:hover { padding-left: .6rem; color: var(--gold-2); }
.toc .tnum { color: var(--ink-faint); font-size: .8rem; min-width: 5.5rem; letter-spacing: .04em; }
.toc .ttitle { font-family: "Fraunces", Georgia, serif; font-size: 1.05rem; flex: 1; }
.toc .tlock { color: var(--ink-faint); font-size: .78rem; }
.toc li.locked span { color: var(--ink-faint); cursor: default; }
.toc li.locked .ttitle { color: var(--ink-dim); }

/* ============ READER ============ */
.progress-top { position: fixed; top: 0; left: 0; height: 3px; background: var(--gold); width: 0; z-index: 50; transition: width .1s linear; }

.reader { display: grid; grid-template-columns: 260px 1fr; gap: 0; min-height: 100vh; }
.reader__nav {
  border-right: 1px solid var(--line); padding: 1.6rem 1.2rem; position: sticky; top: 62px;
  align-self: start; max-height: calc(100vh - 62px); overflow-y: auto;
}
.reader__nav .bk { font-family: "Fraunces", Georgia, serif; font-size: 1.05rem; margin-bottom: 1rem; display: block; color: var(--gold-2); }
.reader__nav ol { list-style: none; }
.reader__nav li a, .reader__nav li span {
  display: block; padding: .42rem .5rem; border-radius: 8px; font-size: .9rem; color: var(--ink-dim);
  transition: background .2s, color .2s;
}
.reader__nav li a:hover { background: var(--panel); color: var(--ink); }
.reader__nav li.active a { background: var(--panel-2); color: var(--gold-2); }
.reader__nav li.locked span { color: var(--ink-faint); display: flex; justify-content: space-between; }

.reader__main { padding: clamp(2rem,5vw,4rem) clamp(1.2rem,5vw,3rem) 6rem; }
.reading { max-width: var(--read); margin: 0 auto; }
.reading .ch-label { color: var(--gold); letter-spacing: .2em; text-transform: uppercase; font-size: .76rem; font-weight: 600; }
.reading h1 { font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: clamp(2rem,5vw,3rem); line-height: 1.08; margin: .6rem 0 2rem; }
.reading p {
  font-family: "Fraunces", "Cormorant Garamond", Georgia, serif;
  font-size: clamp(1.12rem, 1.6vw, 1.28rem); line-height: 1.85; color: #e7e4dc;
  margin-bottom: 1.3rem;
}
.reading p:first-of-type::first-letter {
  font-size: 3.4em; float: left; line-height: .82; padding: .04em .12em 0 0; color: var(--gold-2); font-weight: 600;
}
.reading code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .85em; background: var(--panel-2); padding: .1em .4em; border-radius: 5px; color: var(--gold-2); }

.chapnav { max-width: var(--read); margin: 3rem auto 0; display: flex; justify-content: space-between; gap: 1rem; border-top: 1px solid var(--line); padding-top: 1.6rem; }
.chapnav a { color: var(--ink-dim); font-size: .92rem; display: flex; flex-direction: column; gap: .2rem; max-width: 45%; }
.chapnav a:hover { color: var(--gold-2); }
.chapnav .dir { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); }
.chapnav a.next { text-align: right; margin-left: auto; }

/* gate card */
.gate {
  max-width: var(--read); margin: 1rem auto 0; text-align: center;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 20px;
  padding: clamp(2rem,5vw,3.2rem); position: relative; overflow: hidden;
}
.gate::after { content: ""; position: absolute; inset: 0; background: radial-gradient(30vmax 20vmax at 50% 0, rgba(232,184,115,.12), transparent 60%); pointer-events: none; }
.gate .eyebrow { display: block; margin-bottom: .8rem; }
.gate h2 { font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: clamp(1.5rem,3.5vw,2.1rem); margin-bottom: .8rem; position: relative; }
.gate p { color: var(--ink-dim); max-width: 32rem; margin: 0 auto 1.5rem; position: relative; }
.gate .feature__cta { justify-content: center; }

.loading { color: var(--ink-faint); text-align: center; padding: 4rem 0; }

/* ============ responsive ============ */
@media (max-width: 860px) {
  .feature { grid-template-columns: 1fr; }
  .cover-shell { max-width: 220px; }
  .book { grid-template-columns: 1fr; }
  .book__cover-col { position: static; max-width: 240px; }
  .reader { grid-template-columns: 1fr; }
  .reader__nav { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--line); }
  .nav__links { gap: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
