@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700;900&family=Cinzel:wght@400;600&family=IM+Fell+English:ital@0;1&display=swap');

:root {
  --bg:         #080705;
  --border:     #2e2318;
  --border2:    #4a3520;
  --text:       #cfc0a0;
  --muted:      #6b5a3e;
  --accent:     #b85c20;
  --gold:       #c8923a;
  --gold2:      #e8b84a;
  --gold-dim:   #7a5a22;
  --font-display: 'Cinzel Decorative', serif;
  --font-heading: 'Cinzel', serif;
  --font-body:    'IM Fell English', serif;
}

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

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.9;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Grain ── */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Border canvases ── */
.border-canvas {
  display: block;
  position: relative;
  z-index: 10;
}

.border-top,
.border-bottom {
  width: 100%;
  height: 32px;
}

.border-top  { margin-bottom: 0; }
.border-bottom { margin-top: 0; }

.border-side {
  position: fixed;
  top: 0;
  width: 28px;
  height: 100vh;
  z-index: 10;
  pointer-events: none;
}

.border-left  { left: 0; }
.border-right { right: 0; }

/* ── Layout ── */
.site-wrap {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ── Star seal ── */
.star-wrap {
  display: flex;
  justify-content: center;
  padding: 5rem 0 1.5rem;
  animation: fadeIn 1.4s ease both;
}

/* ── Header ── */
.site-header {
  text-align: center;
  padding: 0.5rem 0 3rem;
  animation: fadeIn 1.4s 0.2s ease both;
}

.title-rule {
  height: 1px;
  margin: 0.6rem auto;
  width: 80%;
  background: linear-gradient(to right, transparent, var(--gold-dim), var(--gold2), var(--gold-dim), transparent);
}

.site-title {
  font-family: var(--font-display);
  font-size: clamp(3rem, 10vw, 12rem);
  font-weight: 900;
  color: #cc2244;
  line-height: 1;
  text-shadow:
    0 0 60px #e8b84a44,
    0 0 120px #c8923a22,
    0 2px 4px #00000099;
  letter-spacing: 0.04em;
}

.site-subtitle {
  margin-top: 0.9rem;
  font-family: var(--font-heading);
  font-size: 0.78rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--text);
  text-align: center;
  max-width: 620px;
  margin-left: auto;
  margin-right: auto;
}

/* ── Nav ── */
.site-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.4rem;
  padding: 1rem 0 1.8rem;
  font-family: var(--font-heading);
  font-size: 2rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  animation: fadeIn 1.4s 0.4s ease both;
  font-weight: 600;
}

.site-nav a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.25s;
}
.site-nav a:hover { color: var(--gold); }
.nav-sep { color: var(--gold-dim); font-size: 0.5rem; }

/* ── Ornament bar ── */
.ornament-bar {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0 2rem;
  animation: fadeIn 1.4s 0.5s ease both;
}
.ornament-bar canvas { max-width: 100%; }
.ornament-bar--slim { margin: 1.5rem 0; }

/* ── Section head ── */
.section-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  margin-bottom: 1.8rem;
}

.section-label {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.section-diamond {
  display: inline-block;
  width: 5px;
  height: 5px;
  background: var(--gold-dim);
  transform: rotate(45deg);
}

/* ── Synopsis ── */
.synopsis {
  padding: 2rem 2.5rem;
  animation: fadeIn 1.4s 0.6s ease both;
  background: #e8d9b8;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
  border: 1px solid #c4a97a;
  border-radius: 2px;
  max-width: 600px;
  margin: 0 auto;
  box-shadow: 0 0 40px #00000066, inset 0 0 30px #c8923a0a;
}

.synopsis p {
  font-style: italic;
  font-size: 1.5rem;
  text-align: center;
  color: #3a1a0a;
  opacity: 1;
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.9;
}

/* ── Mid rule ── */
.mid-rule {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2.8rem 0;
}
.mid-rule span:first-child,
.mid-rule span:last-child {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border2));
}
.mid-rule span:last-child {
  background: linear-gradient(to left, transparent, var(--border2));
}
.mid-glyph {
  font-size: 0.6rem;
  color: var(--gold-dim);
  flex-shrink: 0;
}

/* ── Book ── */
.book {
  margin-bottom: 2.5rem;
}

.book-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.8rem 0.6rem;
  border-bottom: 1px solid var(--border2);
  margin-bottom: 0.5rem;
}

.book-num {
  font-family: var(--font-heading);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
}

.book-title {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1rem;
  color: var(--muted);
}

/* ── Chapter list ── */
.chapter-list {
  list-style: none;
  border-top: 1px solid var(--border2);
}

.chapter-list li { border-bottom: 1px solid var(--border); }

.chapter-entry {
  display: grid;
  grid-template-columns: 2.8rem 1px 1fr auto;
  align-items: center;
  gap: 1.2rem;
  padding: 1.1rem 0.6rem;
  text-decoration: none;
  color: var(--text);
  transition: background 0.2s, padding-left 0.25s;
  cursor: pointer;
}

.chapter-entry:hover {
  background: #1a130d;
  padding-left: 1.2rem;
}

.chapter-entry:hover .ch-num { color: var(--gold2); }
.chapter-entry:hover .ch-title { color: var(--gold); }
.chapter-entry:hover .ch-arrow { opacity: 1; color: var(--gold); }

.ch-num {
  font-family: var(--font-heading);
  font-size: 1rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-align: right;
  transition: color 0.2s;
}

.ch-divider {
  display: block;
  width: 1px;
  height: 1.4rem;
  background: var(--border2);
}

.ch-title {
  font-style: italic;
  font-size: 1rem;
  transition: color 0.2s;
}

.ch-arrow {
  font-size: 0.85rem;
  color: var(--muted);
  opacity: 0.4;
  transition: opacity 0.2s, color 0.2s;
}

.chapter-coming {
  display: grid;
  grid-template-columns: 2.8rem 1px 1fr;
  align-items: center;
  gap: 1.2rem;
  padding: 1.1rem 0.6rem;
  opacity: 0.3;
  cursor: default;
}

.chapter-coming .ch-title { font-style: italic; font-size: 0.95rem; }

/* ── Footer ── */
.site-footer {
  text-align: center;
  padding: 2rem 0 3rem;
  margin-top: 1rem;
}

.site-footer canvas {
  display: block;
  margin: 0 auto 1rem;
  opacity: 0.5;
}

.site-footer p {
  font-family: var(--font-heading);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.6;
}

/* ── Chapter page ── */
.chapter-back {
  padding: 2rem 0 0;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.chapter-back a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.chapter-back a:hover { color: var(--gold); }

.chapter-header {
  text-align: center;
  padding: 2rem 0 1rem;
  animation: fadeIn 1.2s ease both;
}

.chapter-title-large {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 5vw, 3rem);
  color: var(--gold2);
  letter-spacing: 0.08em;
  line-height: 1.2;
  margin-top: 0.8rem;
  text-shadow: 0 0 40px #e8b84a33;
}

.chapter-body {
  padding: 0.5rem 0 1rem;
  animation: fadeIn 1.2s 0.3s ease both;
}

.chapter-body p {
  margin-bottom: 1.6rem;
  text-align: justify;
  hyphens: auto;
}

.chapter-body p:first-child::first-letter {
  font-family: var(--font-display);
  font-size: 4.2rem;
  float: left;
  line-height: 0.78;
  margin: 0.08em 0.14em 0 0;
  color: var(--gold2);
  text-shadow: 0 0 24px #e8b84a55;
}

.chapter-footer-nav {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.chapter-footer-nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.chapter-footer-nav a:hover { color: var(--gold); }

/* ── Animation ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive / Mobile ── */
@media (max-width: 640px) {

  /* Hide side border strips on mobile — too narrow to fit */
  .border-side { display: none; }

  /* Give content room to breathe without side strips */
  .site-wrap { padding: 0 1.2rem; }

  /* Shrink star image */
  .star-wrap { padding: 2.5rem 0 1rem; }
  .star-wrap img { width: 160px !important; }

  /* Title scales via clamp already but cap it sensibly */
  .site-title { font-size: clamp(2.8rem, 14vw, 5rem); }

  /* Subtitle smaller and tighter */
  .site-subtitle {
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    max-width: 100%;
  }

  /* Header less bottom padding */
  .site-header { padding: 0.5rem 0 1.5rem; }

  /* ── Nav: stack vertically ── */
  .site-nav {
    flex-direction: column;
    gap: 0.2rem;
    font-size: 1rem;
    letter-spacing: 0.15em;
    padding: 0.8rem 0 1.2rem;
  }

  /* Hide the separators between nav items on mobile */
  .nav-sep { display: none; }

  /* Each nav link gets its own row */
  .nav-link {
    display: block;
    padding: 0.4rem 0;
    width: 100%;
    text-align: center;
    text-decoration: none;
  }

  /* Dropdown button same treatment */
  .nav-dropdown { width: 100%; text-align: center; }
  .nav-dropdown-btn {
    font-size: 1rem !important;
    letter-spacing: 0.15em;
    padding: 0.4rem 0;
    width: 100%;
  }

  /* Dropdown menu full width on mobile */
  .nav-dropdown-menu {
    position: static;
    transform: none;
    left: auto;
    min-width: 100%;
    width: 100%;
    margin-top: 0;
    box-shadow: none;
    border-left: none;
    border-right: none;
  }

  /* Synopsis parchment block — smaller padding on mobile */
  .synopsis {
    padding: 1.2rem 1.2rem;
    max-width: 100%;
  }

  .synopsis p {
    font-size: 1.1rem;
    max-width: 100%;
  }

  /* Book title wraps gracefully */
  .book-head { flex-wrap: wrap; gap: 0.4rem; }

  /* Chapter entries — slightly tighter */
  .chapter-entry { gap: 0.8rem; padding: 1rem 0.4rem; }
  .chapter-coming { gap: 0.8rem; padding: 1rem 0.4rem; }

  /* Footer */
  .site-footer { padding: 1.5rem 0 2rem; }

  /* Chapter pages */
  .chapter-back { padding: 1.2rem 0 0; }
  .chapter-body p:first-child::first-letter { font-size: 3rem; }
  .parchment-text { padding: 1.5rem 1.2rem; font-size: 1.1rem; }
}

/* ── Nav dropdown ── */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text);
  padding: 0;
  transition: color 0.25s;
}

.nav-dropdown-btn:hover,
.nav-dropdown-btn.active { color: var(--gold); }

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 0.8rem);
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  background: #12100c;
  border: 1px solid var(--border2);
  list-style: none;
  z-index: 200;
  box-shadow: 0 8px 32px #00000088;
}

.nav-dropdown-menu::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold), transparent);
}

.nav-dropdown-menu.open { display: block; }

.nav-dropdown-menu li { border-bottom: 1px solid var(--border); }
.nav-dropdown-menu li:last-child { border-bottom: none; }

.nav-dropdown-menu a {
  display: block;
  padding: 0.8rem 1.2rem;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s, background 0.2s, padding-left 0.2s;
}

.nav-dropdown-menu a:hover {
  color: var(--gold);
  background: #1a130d;
  padding-left: 1.6rem;
}
