/* ============================================================
   The Library — reading room. Lavender wash, mauve secondary,
   editorial typography with drop caps and ruled notes.
   ============================================================ */

:root {
  --purple-900: #2E1A34;
  --purple-800: #472850;
  --purple-700: #5E3568;
  --purple: #7A4686;
  --purple-300: #B08CB8;
  --purple-200: #D3BFD8;
  --purple-100: #EFE7F1;
  --gold-800: #86642F;
  --gold-700: #A87E3F;
  --gold: #C69A58;
  --gold-300: #DDC194;
  --gold-200: #ECD9BC;
  --indigo: #3D417B;
  --teal: #478D9A;
  --plum: #593640;
  --mauve: #9A6B7E;
  --mauve-light: #C9A9B5;
  --mauve-wash: #F6F0F2;
  --ink: #201826;
  --slate: #5B5560;
  --line: #E7E2EA;
  --wash: #F3EFF5;
  --surface: #FAF9FB;
  --white: #FFFFFF;

  --font-display: "Ubuntu", "Segoe UI", system-ui, sans-serif;
  --font-mono: "Ubuntu Mono", Consolas, monospace;
  --font-body: "Mulish", system-ui, sans-serif;

  --shadow-sm: 0 1px 2px rgba(32,24,38,.06);
  --shadow-md: 0 8px 24px rgba(32,24,38,.08);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --container: 1080px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--mauve-light); color: var(--purple-900); }

.container { max-width: var(--container); margin: 0 auto; padding: 0 clamp(20px, 4vw, 44px); }

h1, h2 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; color: var(--purple-900); margin: 0 0 .4em; }
p { margin: 0 0 1em; }
a { color: var(--purple); }

.eyebrow {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .18em; color: var(--gold-800); margin-bottom: 16px;
}

/* reading progress */
.reading-bar { position: fixed; top: 0; left: 0; right: 0; height: 2.5px; z-index: 120; }
#readFill { height: 100%; width: 0; background: linear-gradient(90deg, var(--mauve), var(--gold)); }

/* ---------- nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 14px 0;
  background: rgba(250,249,251,.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s;
}
.nav.scrolled { border-bottom-color: var(--line); }
.nav-inner {
  max-width: var(--container); margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 44px);
  display: flex; align-items: center; justify-content: space-between;
}
.nav-brand img { height: 28px; width: auto; display: block; }
.nav-links { display: flex; gap: 26px; }
.nav-links a { font-size: 14px; font-weight: 700; color: var(--ink); text-decoration: none; position: relative; }
.nav-links a::after {
  content: ""; position: absolute; left: 0; bottom: -4px; height: 1.5px; width: 100%;
  background: var(--mauve); transform: scaleX(0); transform-origin: 100% 50%;
  transition: transform .3s var(--ease-out);
}
.nav-links a:hover::after { transform: scaleX(1); transform-origin: 0 50%; }
@media (max-width: 640px) {
  .nav-links { gap: 16px; }
  .nav-links a { font-size: 12.5px; white-space: nowrap; }
  .nav-brand img { height: 23px; }
}
@media (max-width: 480px) {
  .nav-links a[href="#shelf"], .nav-links a[href="#glossary"] { display: none; }
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  padding: 170px 0 90px;
  background:
    radial-gradient(ellipse 70% 60% at 85% 20%, var(--mauve-wash), transparent 65%),
    var(--surface);
  overflow: hidden;
}
.hero-burst {
  position: absolute; right: clamp(-60px, 4vw, 120px); top: 90px;
  width: clamp(180px, 24vw, 320px); height: auto;
  opacity: .8;
}
.hero h1 { font-size: clamp(42px, 7vw, 76px); line-height: 1.02; }
.hero-sub { color: var(--slate); max-width: 56ch; font-size: 17.5px; margin: 22px 0 34px; }
.hero-meta {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: 13px; color: var(--mauve);
}
.hero-meta i { width: 4px; height: 4px; border-radius: 50%; background: var(--gold); }

/* ---------- sections ---------- */
.section-head { margin-bottom: 44px; }
.section-head h2 { font-size: clamp(28px, 4vw, 40px); }
.section-sub { color: var(--slate); max-width: 56ch; }

.notes { padding: 40px 0 90px; }

/* ---------- note (accordion) ---------- */
.note {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
  margin-bottom: 14px;
  overflow: hidden;
  transition: box-shadow .3s, border-color .3s;
}
.note.open { box-shadow: var(--shadow-md); border-color: var(--purple-200); }
.note-head {
  display: grid;
  grid-template-columns: 90px 1fr auto 28px;
  gap: 18px; align-items: center;
  width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
  padding: 24px 26px;
  font-family: var(--font-body);
  transition: background .25s;
}
.note-head:hover { background: var(--wash); }
.note.open .note-head:hover { background: none; }
.note-no { font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; letter-spacing: .12em; color: var(--gold-700); text-transform: uppercase; }
.note-title { font-size: clamp(17px, 2vw, 21px); font-weight: 800; color: var(--purple-900); }
.note-sum { font-size: 13.5px; color: var(--slate); font-style: italic; text-align: right; max-width: 300px; }
.note-toggle {
  width: 26px; height: 26px; position: relative; justify-self: end;
}
.note-toggle::before, .note-toggle::after {
  content: ""; position: absolute; background: var(--mauve); border-radius: 1px;
  top: 50%; left: 50%;
  transition: transform .35s var(--ease-out);
}
.note-toggle::before { width: 14px; height: 2px; transform: translate(-50%, -50%); }
.note-toggle::after { width: 2px; height: 14px; transform: translate(-50%, -50%); }
.note.open .note-toggle::after { transform: translate(-50%, -50%) rotate(90deg); }
.note.open .note-toggle::before { transform: translate(-50%, -50%) rotate(180deg); }

.note-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .6s var(--ease-out);
}
.note-prose {
  padding: 6px 26px 8px;
  max-width: 68ch;
  overflow: hidden;
}
.note-prose p { color: #3A3340; font-size: 16.5px; margin-bottom: 1.15em; }
.note-prose strong { color: var(--purple-800); }
.dropcap {
  float: left;
  font-family: var(--font-display); font-weight: 700;
  font-size: 58px; line-height: .82;
  color: var(--purple);
  padding: 6px 10px 0 0;
}
.note-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 26px 22px;
  border-top: 1px dashed var(--line);
  margin: 0 0 0;
}
.note-src { font-family: var(--font-mono); font-size: 12px; color: var(--mauve); }
.print-btn {
  font-family: var(--font-body); font-size: 13px; font-weight: 700;
  color: var(--purple); background: none; cursor: pointer;
  border: 1.5px solid var(--purple-200); border-radius: 100px;
  padding: 7px 16px;
  transition: all .25s;
}
.print-btn:hover { border-color: var(--purple); background: var(--purple-100); }

/* ---------- bookshelf ---------- */
.shelf {
  padding: 90px 0;
  background: linear-gradient(180deg, var(--mauve-wash), var(--surface));
  border-top: 1px solid var(--line);
}
.shelf-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px;
}
.book {
  display: flex; gap: 16px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
  text-decoration: none;
  transition: transform .3s var(--ease-out), box-shadow .3s;
}
.book:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.book-spine {
  flex: 0 0 10px; border-radius: 4px;
  background: var(--spine, var(--purple));
  position: relative;
}
.book-spine::after {
  content: ""; position: absolute; left: 0; right: 0; top: 12px; height: 2px;
  background: rgba(255,255,255,.55);
}
.book-info { display: flex; flex-direction: column; gap: 3px; }
.book-info strong { font-size: 15.5px; font-weight: 800; color: var(--purple-900); line-height: 1.3; }
.book-info em { font-size: 12.5px; color: var(--gold-700); font-style: normal; font-weight: 700; }
.book-info span { font-size: 13.5px; color: var(--slate); line-height: 1.5; margin-top: 5px; }
@media (max-width: 860px) { .shelf-grid { grid-template-columns: 1fr; } }

/* ---------- glossary ---------- */
.glossary { padding: 90px 0; }
.gloss-grid {
  columns: 3; column-gap: 18px;
}
@media (max-width: 980px) { .gloss-grid { columns: 2; } }
@media (max-width: 640px) { .gloss-grid { columns: 1; } }
.gloss-card {
  break-inside: avoid;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  margin-bottom: 18px;
  transition: border-color .25s, transform .25s var(--ease-out);
}
.gloss-card:hover { border-color: var(--mauve-light); transform: translateY(-2px); }
.gloss-term {
  font-weight: 800; font-size: 15.5px; color: var(--purple-900);
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: 0 0 6px;
}
.gloss-term .g-tag {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--mauve); border: 1px solid var(--mauve-light);
  padding: 2px 7px; border-radius: 4px; white-space: nowrap;
}
.gloss-def { font-size: 14px; color: var(--slate); margin: 0; }

/* ---------- close ---------- */
.close-cta {
  padding: clamp(80px, 10vw, 130px) 0;
  background: var(--purple-900);
}
.close-cta h2 { color: #fff; font-size: clamp(26px, 3.6vw, 38px); max-width: 24ch; }
.close-cta p { color: var(--purple-200); max-width: 58ch; margin-bottom: 26px; }
.btn-gold {
  display: inline-block; padding: 14px 28px;
  background: var(--gold); color: var(--purple-900);
  font-size: 15px; font-weight: 700; border-radius: 9px; text-decoration: none;
  transition: transform .25s var(--ease-out), background .25s, box-shadow .25s;
}
.btn-gold:hover { background: var(--gold-300); transform: translateY(-2px); box-shadow: 0 10px 28px rgba(198,154,88,.3); }

/* ---------- footer ---------- */
.footer { background: var(--ink); padding: 56px 0; color: var(--purple-200); }
.footer-grid { display: flex; justify-content: space-between; gap: 40px; flex-wrap: wrap; }
.footer-logo { height: 26px; width: auto; margin-bottom: 16px; }
.footer-line { font-size: 14px; color: var(--purple-300); max-width: 44ch; }
.footer-meta { font-size: 13.5px; text-align: right; }
.footer-meta p { margin: 0 0 8px; }
.footer-meta a { color: var(--gold-300); }
.footer-credit { color: var(--purple-300); opacity: .75; }
@media (max-width: 700px) { .footer-meta { text-align: left; } }

/* ---------- note responsive ---------- */
@media (max-width: 760px) {
  .note-head { grid-template-columns: 1fr 28px; grid-template-areas: "no toggle" "title toggle" "sum sum"; gap: 6px 12px; }
  .note-no { grid-area: no; }
  .note-title { grid-area: title; }
  .note-sum { grid-area: sum; text-align: left; max-width: none; }
  .note-toggle { grid-area: toggle; }
}

/* ---------- reveal ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .7s var(--ease-out), transform .7s var(--ease-out); }
.reveal.in { opacity: 1; transform: none; }

/* ---------- print: only the open note ---------- */
@media print {
  body * { visibility: hidden; }
  .note.printing, .note.printing * { visibility: visible; }
  .note.printing { position: absolute; left: 0; top: 0; width: 100%; border: none; box-shadow: none; }
  .note.printing .note-body { max-height: none !important; overflow: visible; }
  .note.printing .note-toggle, .note.printing .print-btn { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .reveal { opacity: 1; transform: none; }
}
