/*
Theme Name: Deluvia Prime
Theme URI: https://deluviaprime.com
Author: Deluvia Prime
Description: A serialized story of the world before the flood. Dark literary theme with gate landing, sidebar navigation, chapter reading, and lore accordion.
Version: 1.0.1
Requires at least: 6.0
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: deluvia-prime
*/

/* ============================================
   RESET & ROOT VARIABLES
   ============================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --deep: #181d28;
  --night: #1c2230;
  --lapis: #222a3e;
  --lapis-mid: #2a3458;
  --slate: #323e62;
  --gold: #e4b44a;
  --gold-dim: #c4a048;
  --gold-warm: #d4a040;
  --flora: #5aaa3a;
  --flora-glow: #80d050;
  --bone: #f4f1e8;
  --parch: #e8e2d6;
  --text: #e0d8cc;
  --text-dim: #b0a898;
}

html { font-size: 18px; scroll-behavior: smooth; }

body {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 300;
  line-height: 1.85;
  color: var(--text);
  background: var(--deep);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection { background: var(--gold); color: var(--deep); }

/* ============================================
   THE GATE
   ============================================ */
.gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--deep);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  transition: opacity 1.2s ease;
  overflow: hidden;
}
.gate.leaving { opacity: 0; pointer-events: none; }

/* Ambient warmth */
.gate::before {
  content: '';
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  height: 500px;
  background: radial-gradient(ellipse, rgba(228,180,74,0.03) 0%, transparent 70%);
  pointer-events: none;
  animation: gate-breathe 10s ease-in-out infinite alternate;
}
@keyframes gate-breathe {
  0% { opacity: 0.6; transform: translateX(-50%) scale(1); }
  100% { opacity: 1; transform: translateX(-50%) scale(1.08); }
}

/* Decorative line above title */
.gate-ornament {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1.8rem;
  opacity: 0.45;
}
.gate-ornament-line {
  width: 40px;
  height: 1px;
  background: var(--gold-dim);
}
.gate-ornament-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold-dim);
}
body.night-mode .gate-ornament-dot {
  background: var(--flora-glow);
  box-shadow: 0 0 10px rgba(128,208,80,0.5), 0 0 25px rgba(128,208,80,0.2);
}

.gate-eyebrow {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 1rem;
  opacity: 0.8;
}

.gate-title {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 700;
  font-size: clamp(2.8rem, 6.5vw, 5rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bone);
  line-height: 1.15;
  margin-bottom: 1rem;
}

.gate-subtitle {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 300;
  font-style: italic;
  font-size: 1rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  margin-bottom: 3rem;
  max-width: 320px;
}

.gate-enter {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold);
  padding: 0.85rem 2.6rem;
  border: 1px solid rgba(228,180,74,0.2);
  background: transparent;
  cursor: pointer;
  transition: all 0.4s;
}
.gate-enter:hover {
  border-color: rgba(228,180,74,0.5);
  background: rgba(228,180,74,0.04);
  box-shadow: 0 0 50px rgba(228,180,74,0.05);
}

.gate-flora-hint {
  position: absolute;
  bottom: 3rem;
  font-size: 0.68rem;
  font-style: italic;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 3s ease 6s;
}
.gate-flora-hint.show { opacity: 0.5; }
body.night-mode .gate-flora-hint { color: var(--flora); }

/* ============================================
   CELLAR INTERIOR
   ============================================ */
.cellar { display: none; min-height: 100vh; }
.cellar.open { display: flex; animation: fadeIn 1.5s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* SIDEBAR */
.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--night);
  border-right: 1px solid rgba(228,180,74,0.05);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.sb-header {
  padding: 1.6rem 1.4rem 0.8rem;
  border-bottom: 1px solid rgba(228,180,74,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sb-title {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 700;
  font-size: 0.75rem;
  white-space: nowrap;
  letter-spacing: 0.14em;
  overflow: hidden;
  text-transform: uppercase;
  color: var(--bone);
  text-shadow: 0 0 20px rgba(228,180,74,0.25), 0 0 40px rgba(228,180,74,0.08);
  cursor: pointer;
  transition: all 0.3s;
}
.sb-title:hover { color: var(--gold); text-shadow: 0 0 24px rgba(228,180,74,0.35), 0 0 50px rgba(228,180,74,0.12); }
.sb-collapse-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 0.65rem;
  cursor: pointer;
  padding: 0.2rem;
  transition: all 0.3s;
  line-height: 1;
  flex-shrink: 0;
  white-space: nowrap;
}
.sb-collapse-btn:hover { color: var(--gold-dim); }

.sb-nav { flex: 1; padding: 0; }

.sb-link {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.9rem 1.4rem;
  cursor: pointer;
  transition: all 0.25s;
  border-left: 2px solid transparent;
  text-decoration: none;
}
.sb-link-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 0.2rem;
  opacity: 0.35;
  transition: opacity 0.3s;
}
.sb-link-icon svg { width: 100%; height: 100%; fill: none; stroke: var(--gold-dim); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.sb-link:hover .sb-link-icon,
.sb-link.active .sb-link-icon { opacity: 0.7; }
.sb-link:hover { background: rgba(228,180,74,0.015); }
.sb-link.active { border-left-color: var(--gold-dim); background: rgba(228,180,74,0.02); }

.sb-link-name {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 400;
  font-size: 0.88rem;
  color: var(--parch);
  display: block;
  transition: color 0.3s;
}
.sb-link.active .sb-link-name,
.sb-link:hover .sb-link-name { color: var(--bone); }

.sb-link-desc {
  font-size: 0.62rem;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 0.2rem;
  display: block;
  opacity: 0.75;
}

.sb-foot {
  padding: 1.4rem;
  border-top: 1px solid rgba(228,180,74,0.05);
}
.sb-flora-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.sb-flora-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--flora);
  opacity: 0.2;
  transition: all 1.5s;
}
body.night-mode .sb-flora-dot {
  opacity: 0.9;
  background: var(--flora-glow);
  box-shadow: 0 0 10px rgba(128,208,80,0.5), 0 0 20px rgba(128,208,80,0.2);
}
.sb-flora-text {
  font-size: 0.6rem;
  color: var(--text-dim);
  opacity: 0.55;
  font-style: italic;
}
body.night-mode .sb-flora-text { color: var(--flora); opacity: 0.6; }


/* MAIN */
.main {
  flex: 1;
  margin-left: 250px;
  min-height: 100vh;
  background: var(--deep);
  position: relative;
}

.main::before {
  content: '';
  position: fixed;
  top: -10%;
  right: -5%;
  width: 50%;
  height: 60%;
  background: radial-gradient(ellipse, rgba(228,180,74,0.012) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.main-inner { position: relative; z-index: 1; }

/* Warm gradient strip at top of content area */
.room-atmosphere {
  height: 120px;
  background: linear-gradient(to bottom, rgba(228,180,74,0.015), transparent);
  pointer-events: none;
}

.main-content {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 2.5rem 1rem;
}

.panel { display: none; }
.panel.active { display: block; animation: panelIn 0.5s ease; }
@keyframes panelIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Room header */
.room-eyebrow {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-dim);
  opacity: 0.7;
  margin-bottom: 0.5rem;
}

.room-title {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 600;
  font-size: 2rem;
  color: var(--bone);
  margin-bottom: 0.5rem;
  letter-spacing: 0.04em;
}

.room-sub {
  font-size: 0.9rem;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 2rem;
  line-height: 1.7;
}

.room-rule {
  width: 40px;
  height: 1px;
  background: rgba(228,180,74,0.15);
  margin-bottom: 2.5rem;
}

/* ---- CHEVRON BORDER ---- */
.chevron-border {
  max-width: 580px;
  margin: 2rem auto;
  height: 12px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='12' viewBox='0 0 20 12'%3E%3Cpath d='M0 2 L10 10 L20 2' stroke='rgba(154,122,48,0.16)' stroke-width='1' fill='none'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-position: center;
}


/* ---- CHAPTER CARDS ---- */
.ch-grid { display: flex; flex-direction: column; gap: 2px; }

.ch-card {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.3rem 1.4rem;
  background: rgba(12,16,24,0.4);
  border: 1px solid rgba(228,180,74,0.03);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
  position: relative;
}
.ch-card:hover {
  background: rgba(24,32,64,0.25);
  border-color: rgba(228,180,74,0.08);
}

/* Leaf icon */
.ch-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(90,170,58,0.06);
  border: 1px solid rgba(90,170,58,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.15rem;
  transition: all 0.4s;
}
.ch-icon svg {
  width: 12px;
  height: 12px;
  fill: var(--flora);
  opacity: 0.5;
  transition: all 0.4s;
}
.ch-card:hover .ch-icon {
  background: rgba(90,170,58,0.1);
  border-color: rgba(90,170,58,0.18);
}
.ch-card:hover .ch-icon svg { opacity: 0.8; }

body.night-mode .ch-icon {
  background: rgba(128,208,80,0.1);
  border-color: rgba(128,208,80,0.25);
  box-shadow: 0 0 12px rgba(128,208,80,0.1);
}
body.night-mode .ch-icon svg {
  fill: var(--flora-glow);
  opacity: 0.8;
  filter: drop-shadow(0 0 4px rgba(128,208,80,0.5));
}
body.night-mode .ch-card:hover .ch-icon {
  background: rgba(128,208,80,0.15);
  border-color: rgba(128,208,80,0.35);
  box-shadow: 0 0 18px rgba(128,208,80,0.15);
}
body.night-mode .ch-card:hover .ch-icon svg { opacity: 1; }

.ch-body { flex: 1; }

.ch-meta { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.25rem; }
.ch-num {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 500;
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.ch-new {
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--deep);
  background: var(--gold);
  padding: 0.08rem 0.4rem;
  border-radius: 2px;
}

.ch-title {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 500;
  font-size: 1.25rem;
  color: var(--parch);
  margin-bottom: 0.2rem;
  transition: color 0.3s;
  letter-spacing: 0.02em;
}
.ch-card:hover .ch-title { color: var(--bone); }

.ch-excerpt {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.6;
  opacity: 0.8;
}

/* ---- WINDOWSILL ---- */
.sill-text {
  font-size: 1rem;
  line-height: 2;
  color: var(--text);
  margin-bottom: 1.3rem;
}
.sill-text em { color: var(--parch); }

.sub-form {
  display: flex;
  max-width: 100%;
  margin-top: 2rem;
}
.sub-form input {
  flex: 1;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.86rem;
  font-weight: 300;
  padding: 0.8rem 1rem;
  background: var(--night);
  border: 1px solid rgba(228,180,74,0.1);
  border-right: none;
  border-radius: 3px 0 0 3px;
  color: var(--text);
  outline: none;
  transition: border-color 0.3s;
}
.sub-form input::placeholder { color: var(--text-dim); opacity: 0.35; }
.sub-form input:focus { border-color: var(--gold-dim); }
.sub-form button {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 600;
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.8rem 1.4rem;
  background: rgba(228,180,74,0.06);
  border: 1px solid rgba(228,180,74,0.1);
  border-radius: 0 3px 3px 0;
  color: var(--gold);
  cursor: pointer;
  transition: all 0.3s;
}
.sub-form button:hover { background: rgba(228,180,74,0.12); border-color: var(--gold-dim); }
.sub-note {
  margin-top: 1.2rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  opacity: 0.5;
  font-style: italic;
}

/* ---- LORE CARDS ---- */
.lore-card {
  border-bottom: 1px solid rgba(228,180,74,0.04);
  cursor: pointer;
}
.lore-card:last-child { border-bottom: none; }

.lore-head {
  display: flex;
  align-items: center;
  padding: 1.1rem 0;
  gap: 0.5rem;
}

.lore-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--parch);
  flex: 1;
  letter-spacing: 0.02em;
  transition: color 0.3s;
}
.lore-card:hover .lore-title { color: var(--bone); }

.lore-toggle {
  font-size: 0.9rem;
  color: var(--text-dim);
  transition: transform 0.3s, color 0.3s;
  opacity: 0.4;
}
.lore-card.open .lore-toggle { transform: rotate(45deg); color: var(--gold-dim); opacity: 0.7; }

.lore-body { max-height: 0; overflow: hidden; transition: max-height 0.5s ease; }
.lore-card.open .lore-body { max-height: 500px; }
.lore-body-inner { padding: 0 0 1.2rem; }
.lore-body p {
  font-size: 0.9rem;
  line-height: 1.9;
  color: var(--text);
  margin-bottom: 0.8rem;
}
.lore-body p:last-child { margin-bottom: 0; }
.lore-aside {
  font-size: 0.74rem;
  font-style: italic;
  color: var(--text-dim);
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(228,180,74,0.04);
  opacity: 0.75;
}

/* ---- READING VIEW ---- */
.reading-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-dim);
  text-decoration: none;
  cursor: pointer;
  margin-bottom: 2.5rem;
  background: none; border: none;
  transition: color 0.3s;
  opacity: 0.75;
}
.reading-back:hover { color: var(--gold); opacity: 1; }

.reading-head { text-align: center; margin-bottom: 3rem; }
.reading-head .ch-num { display: block; margin-bottom: 0.8rem; }
.reading-head h1 {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 500;
  font-size: 2.2rem;
  color: var(--bone);
  letter-spacing: 0.05em;
  margin-bottom: 1.5rem;
}
.reading-rule { width: 40px; height: 1px; background: rgba(228,180,74,0.2); margin: 0 auto; }

.prose { max-width: 580px; margin: 0 auto; }
.prose p {
  font-size: 1.05em;
  line-height: 2.1;
  color: var(--text);
  margin-bottom: 1.5rem;
  text-indent: 1.5em;
}
.prose p:first-child { text-indent: 0; }
.prose p:first-child::first-letter {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 700;
  font-size: 3.4rem;
  float: left;
  line-height: 0.78;
  margin: 0.08em 0.12em 0 0;
  color: var(--gold);
}
.prose em { color: var(--parch); }
.prose hr {
  border: none;
  margin: 2.8rem auto;
  max-width: 180px;
  height: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='10' viewBox='0 0 18 10'%3E%3Cpath d='M0 2 L9 8 L18 2' stroke='rgba(184,149,62,0.14)' stroke-width='1' fill='none'/%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-position: center;
}

/* ---- FOOTER ---- */
.cellar-foot {
  margin-left: 250px;
  padding: 3rem 2.5rem;
  text-align: center;
}
.cf-text {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.55rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-dim);
  opacity: 0.3;
}

/* ---- TIME TAG ---- */
.time-tag {
  position: fixed; bottom: 1.2rem; right: 1.4rem; z-index: 100;
  font-size: 0.72rem; letter-spacing: 0.08em;
  color: var(--text-dim); opacity: 0;
  transition: opacity 1s; pointer-events: none;
  font-style: italic;
}
.time-tag.vis { opacity: 0.6; pointer-events: auto; cursor: default; }
body.night-mode .time-tag { color: var(--flora); }

/* Constellation overlay on hover */
.constellation-overlay {
  position: fixed;
  inset: 0;
  z-index: 99;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.5s ease;
}
.constellation-overlay.show { opacity: 1; }
.constellation-star {
  position: absolute;
  border-radius: 50%;
  background: rgba(228,210,160,0.7);
}
body.night-mode .constellation-star { background: rgba(128,208,80,0.6); }
.constellation-line {
  position: absolute;
  height: 1px;
  transform-origin: left center;
  background: rgba(228,210,160,0.12);
}
body.night-mode .constellation-line { background: rgba(128,208,80,0.1); }

/* ---- COLLAPSIBLE SIDEBAR ---- */
.sidebar { transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), width 0.4s cubic-bezier(0.4, 0, 0.2, 1), top 0.4s ease; }
body.sb-collapsed .sidebar { transform: translateX(-250px); }
body.sb-collapsed .main { margin-left: 0; }
body.sb-collapsed .cellar-foot { margin-left: 0; }
body.sb-collapsed .autoscroll-bar { left: 0; }
body.sb-collapsed .reading-progress { left: 0; }
.main { transition: margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1); }
.cellar-foot { transition: margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1); }

.sb-expand-btn {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 55;
  background: var(--night);
  border: 1px solid rgba(228,180,74,0.1);
  border-radius: 3px;
  color: var(--gold-dim);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.4rem 0.55rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s;
  line-height: 1;
}
.sb-expand-btn:hover { border-color: rgba(228,180,74,0.3); color: var(--gold); }
body.sb-collapsed .sb-expand-btn { opacity: 1; pointer-events: auto; }
.sb-key-hint {
  display: inline-block;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.55rem;
  font-style: normal;
  padding: 0.1rem 0.35rem;
  border: 1px solid rgba(228,180,74,0.2);
  border-radius: 3px;
  color: var(--gold-dim);
  margin-left: 0.3rem;
  vertical-align: middle;
  opacity: 0.7;
}

/* ---- READING PROGRESS BAR ---- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 250px;
  right: 0;
  height: 2px;
  z-index: 200;
  background: transparent;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.admin-bar .gate { top: 32px; }
.admin-bar .sidebar { top: 32px; }
.admin-bar .sb-expand-btn { top: calc(1rem + 32px); }
.admin-bar .mob-head { top: 32px; }
.admin-bar .reading-progress { top: 32px; }
.reading-progress.active { opacity: 1; }
.reading-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition: width 0.1s linear;
  border-radius: 0 1px 1px 0;
  box-shadow: 0 0 6px rgba(228,180,74,0.3);
}

/* ---- READING BOTTOM FADE ---- */
.main::after {
  content: '';
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(to top, var(--deep) 0%, transparent 100%);
  pointer-events: none;
  z-index: 10;
}

/* ---- CHAPTER NAV (prev/next) ---- */
.ch-nav {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 1rem;
  max-width: 580px;
  margin: 3rem auto 1rem;
}
.ch-nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.2rem;
  background: rgba(25,30,42,0.6);
  border: 1px solid rgba(228,180,74,0.06);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  text-decoration: none;
}
.ch-nav-btn:hover {
  background: rgba(36,46,80,0.3);
  border-color: rgba(228,180,74,0.14);
}
.ch-nav-btn.next { text-align: right; }
.ch-nav-btn.disabled {
  opacity: 0.25;
  pointer-events: none;
}
.ch-nav-label {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.55rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-dim);
}
.ch-nav-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--parch);
  transition: color 0.3s;
}
.ch-nav-btn:hover .ch-nav-title { color: var(--bone); }

/* ---- LORE TOOLTIPS ---- */
.lore-term {
  color: var(--gold-dim);
  border-bottom: 1px dotted rgba(184,149,62,0.3);
  cursor: pointer;
  transition: color 0.2s;
}
.lore-term:hover { color: var(--gold); }
.lore-tooltip {
  position: fixed;
  width: 280px;
  padding: 1rem 1.2rem;
  background: var(--lapis);
  border: 1px solid rgba(228,180,74,0.15);
  border-radius: 6px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(228,180,74,0.04);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 500;
  transform: translateY(4px);
}
.lore-tooltip.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.lore-tooltip-title {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.lore-tooltip-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--gold-dim);
}
.lore-tooltip-text {
  display: block;
  font-size: 0.78rem;
  line-height: 1.25;
  color: var(--text);
  font-style: italic;
}
body.night-mode .lore-tooltip {
  border-color: rgba(128,208,80,0.15);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5), 0 0 12px rgba(128,208,80,0.05);
}
body.night-mode .lore-tooltip-title::before { background: var(--flora-glow); }

/* ---- CURSOR SPORES ---- */
.spore {
  position: fixed;
  pointer-events: none;
  z-index: 9998;
  border-radius: 50%;
  background: var(--flora);
  opacity: 0;
}
body.night-mode .spore { background: var(--flora-glow); }

/* ---- MOBILE ---- */
.mob-head {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  padding: 1rem 1.2rem;
  background: var(--night);
  border-bottom: 1px solid rgba(228,180,74,0.05);
  align-items: center; justify-content: space-between;
}
.mob-title {
  font-family: 'Cinzel', Georgia, serif;
  font-weight: 600; font-size: 0.7rem;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--gold-dim);
}
.mob-actions { display: flex; align-items: center; gap: 0.8rem; }
.mob-btn { background: none; border: none; color: var(--text-dim); font-size: 1.3rem; cursor: pointer; }
.mob-scroll-btn {
  display: none; /* shown only on mobile */
  background: none; border: none;
  color: var(--text-dim); cursor: pointer;
  padding: 0.2rem; line-height: 1; transition: color 0.3s;
}
.mob-scroll-btn svg { width: 14px; height: 14px; display: block; }.mob-scroll-btn.active { color: var(--gold); }
.mob-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 45; }
.mob-overlay.show { display: block; }

/* ---- DAY MODE ---- */
body.day-mode {
  --deep: #f4f1e8;
  --night: #ebe6da;
  --lapis: #ddd8cc;
  --lapis-mid: #ccc7bb;
  --slate: #b8b3a7;
  --bone: #1a1e28;
  --parch: #2a2e38;
  --text: #2c3040;
  --text-dim: #6b6560;
  --gold: #b8922a;
  --gold-dim: #9a7a20;
  --gold-warm: #a88828;
}
body.day-mode .gate-enter { border-color: rgba(154,122,48,0.3); }
body.day-mode .gate-enter:hover { border-color: rgba(154,122,48,0.6); background: rgba(154,122,48,0.06); box-shadow: 0 0 50px rgba(154,122,48,0.08); }
body.day-mode .sidebar { border-right-color: rgba(154,122,48,0.1); }
body.day-mode .sb-header { border-bottom-color: rgba(154,122,48,0.1); }
body.day-mode .sb-title { text-shadow: none; }
body.day-mode .sb-link:hover { background: rgba(154,122,48,0.04); }
body.day-mode .sb-link.active { border-left-color: var(--gold-dim); background: rgba(154,122,48,0.05); }
body.day-mode .sb-foot { border-top-color: rgba(154,122,48,0.1); }
body.day-mode .main::before { background: radial-gradient(ellipse, rgba(154,122,48,0.02) 0%, transparent 70%); }
body.day-mode .room-atmosphere { background: linear-gradient(to bottom, rgba(154,122,48,0.03), transparent); }
body.day-mode .room-rule { background: rgba(154,122,48,0.2); }
body.day-mode .ch-card { background: rgba(255,255,255,0.35); border-color: rgba(154,122,48,0.08); }
body.day-mode .ch-card:hover { background: rgba(255,255,255,0.5); border-color: rgba(154,122,48,0.18); }
body.day-mode .ch-icon { background: rgba(90,170,58,0.08); border-color: rgba(90,170,58,0.15); }
body.day-mode .ch-card:hover .ch-icon { background: rgba(90,170,58,0.14); border-color: rgba(90,170,58,0.25); }
body.day-mode .lore-tooltip { box-shadow: 0 8px 30px rgba(0,0,0,0.12), 0 0 0 1px rgba(154,122,48,0.1); border-color: rgba(154,122,48,0.25); }
body.day-mode .lore-card { border-bottom-color: rgba(154,122,48,0.08); }
body.day-mode .sub-form input { border-color: rgba(154,122,48,0.2); }
body.day-mode .sub-form button { background: rgba(154,122,48,0.08); border-color: rgba(154,122,48,0.2); }
body.day-mode .sub-form button:hover { background: rgba(154,122,48,0.15); }
body.day-mode .ch-nav-btn { background: rgba(255,255,255,0.3); border-color: rgba(154,122,48,0.1); }
body.day-mode .ch-nav-btn:hover { background: rgba(255,255,255,0.5); border-color: rgba(154,122,48,0.2); }
body.day-mode .constellation-star { background: rgba(154,122,48,0.5); }
body.day-mode .constellation-line { background: rgba(154,122,48,0.1); }
body.day-mode .chevron-border {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='12' viewBox='0 0 20 12'%3E%3Cpath d='M0 2 L10 10 L20 2' stroke='rgba(154,122,48,0.25)' stroke-width='1' fill='none'/%3E%3C/svg%3E");
}
body.day-mode .prose hr {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='10' viewBox='0 0 18 10'%3E%3Cpath d='M0 2 L9 8 L18 2' stroke='rgba(154,122,48,0.25)' stroke-width='1' fill='none'/%3E%3C/svg%3E");
}
body.day-mode .reading-rule { background: rgba(154,122,48,0.25); }
body.day-mode .gate::before { background: radial-gradient(ellipse, rgba(154,122,48,0.04) 0%, transparent 70%); }

/* ---- GATE AMBIENT PARTICLES ---- */
.gate-stars {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.gate-star {
  position: absolute;
  border-radius: 50%;
  background: rgba(228,210,160,0.4);
  animation: gate-star-drift linear infinite;
}
body.day-mode .gate-star { background: rgba(154,122,48,0.2); }
body.night-mode .gate-star { background: rgba(128,208,80,0.35); box-shadow: 0 0 6px rgba(128,208,80,0.2); }

@keyframes gate-star-drift {
  0% { transform: translateY(0) translateX(0) scale(1); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-80px) translateX(20px) scale(0.5); opacity: 0; }
}

.gate-flora-vein {
  position: absolute;
  width: 1px;
  background: linear-gradient(to top, transparent, rgba(90,170,58,0.12), transparent);
  animation: gate-vein-pulse ease-in-out infinite alternate;
  pointer-events: none;
}
body.night-mode .gate-flora-vein {
  background: linear-gradient(to top, transparent, rgba(128,208,80,0.18), transparent);
}
body.day-mode .gate-flora-vein {
  background: linear-gradient(to top, transparent, rgba(90,130,58,0.08), transparent);
}

@keyframes gate-vein-pulse {
  0% { opacity: 0.15; transform: scaleY(0.9); }
  100% { opacity: 0.6; transform: scaleY(1.05); }
}
body.day-mode .sb-expand-btn { background: var(--night); border-color: rgba(154,122,48,0.15); }
body.day-mode .sb-expand-btn:hover { border-color: rgba(154,122,48,0.35); }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--deep); }
::-webkit-scrollbar-thumb { background: var(--gold-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ---- THEME TOGGLE ---- */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.8rem;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font-family: 'Source Serif 4', Georgia, serif;
}
.theme-toggle-icon {
  font-size: 0.85rem;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.3s;
}
.theme-toggle:hover .theme-toggle-icon { opacity: 1; }
.theme-toggle-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  font-style: italic;
  opacity: 0.55;
  transition: color 0.3s, opacity 0.3s;
}
.theme-toggle:hover .theme-toggle-label { opacity: 0.8; }
.theme-toggle .sb-key-hint { margin-left: 0.2rem; }

/* ---- FONT SIZE CONTROLS ---- */
.font-size-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.font-size-btn {
  background: none;
  border: 1px solid rgba(228,180,74,0.15);
  border-radius: 3px;
  color: var(--text-dim);
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 0.65rem;
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  line-height: 1;
  transition: all 0.3s;
  opacity: 0.6;
}
.font-size-btn:hover { color: var(--gold-dim); border-color: rgba(228,180,74,0.3); opacity: 1; }
.font-size-label {
  font-size: 0.55rem;
  color: var(--text-dim);
  opacity: 0.45;
  font-style: italic;
}

/* ---- READING SHORTCUTS HINT ---- */
.reading-shortcuts {
  position: fixed;
  bottom: 1.2rem;
  left: 264px;
  z-index: 99;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.35rem 0.7rem;
  background: rgba(24,29,40,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 4px;
  opacity: 0.55;
  transition: opacity 0.6s, visibility 0.6s;
}
.reading-shortcuts:hover { opacity: 0.85; }
.reading-shortcuts.faded { opacity: 0; visibility: hidden; }
.reading-shortcuts.faded:hover { opacity: 0.85; visibility: visible; }
body.sb-collapsed .reading-shortcuts { left: 1.2rem; }
.reading-shortcut {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.55rem;
  color: var(--text-dim);
  font-style: italic;
  white-space: nowrap;
  background: none;
  border: none;
  font-family: 'Source Serif 4', Georgia, serif;
  cursor: pointer;
  padding: 0.15rem 0;
  transition: color 0.2s;
}
.reading-shortcut:hover { color: var(--gold-dim); }
.reading-shortcut-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: 'Source Serif 4', Georgia, serif;
  color: inherit;
  transition: color 0.2s;
}
.reading-shortcut-btn:hover { color: var(--gold); }
#scFontLabel {
  font-size: 0.55rem;
  color: var(--text-dim);
  font-style: italic;
  min-width: 2rem;
  text-align: center;
  cursor: pointer;
}
#scFontLabel:hover { color: var(--gold-dim); }

/* ---- AUTO-SCROLL BAR ---- */
.autoscroll-bar {
  position: fixed;
  top: 0;
  left: 250px;
  right: 0;
  z-index: 201;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.5rem 1.2rem;
  background: var(--night);
  border-bottom: 1px solid rgba(228,180,74,0.08);
  transform: translateY(-100%);
  transition: transform 0.4s ease;
  pointer-events: none;
}
.admin-bar .autoscroll-bar { top: 32px; }
.autoscroll-bar.active ~ .sb-expand-btn { top: 3.2rem; }
.admin-bar .autoscroll-bar.active ~ .sb-expand-btn { top: calc(3.2rem + 32px); }
.autoscroll-bar.active {
  transform: translateY(0);
  pointer-events: auto;
}
.autoscroll-label {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.55rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
}
.autoscroll-speed {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.autoscroll-speed-btn {
  background: none;
  border: 1px solid rgba(228,180,74,0.15);
  border-radius: 3px;
  color: var(--text-dim);
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.55rem;
  cursor: pointer;
  padding: 0.15rem 0.45rem;
  line-height: 1;
  transition: all 0.3s;
  opacity: 0.6;
}
.autoscroll-speed-btn:hover { color: var(--gold-dim); border-color: rgba(228,180,74,0.3); opacity: 1; }
.autoscroll-speed-label {
  font-size: 0.55rem;
  color: var(--text-dim);
  opacity: 0.5;
  font-style: italic;
  min-width: 1.8rem;
  text-align: center;
}
.autoscroll-stop {
  background: none;
  border: 1px solid rgba(228,180,74,0.12);
  border-radius: 3px;
  color: var(--gold-dim);
  font-family: 'Cinzel', Georgia, serif;
  font-size: 0.5rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 0.2rem 0.6rem;
  transition: all 0.3s;
  opacity: 0.6;
}
.autoscroll-stop:hover { color: var(--gold); border-color: rgba(228,180,74,0.3); opacity: 1; }
.autoscroll-hint {
  font-size: 0.5rem;
  color: var(--text-dim);
  opacity: 0.35;
  font-style: italic;
}

@media (max-width: 760px) {
  /* Sidebar — off-canvas, full overlay */
  .sidebar { transform: translateX(-100%); transition: transform 0.3s; width: 280px; max-width: 80vw; }
  .sidebar.open { transform: translateX(0); }
  .sb-collapse-btn { display: none; }
  .sb-expand-btn { display: none !important; }
  .mob-head { display: flex; }

  /* Main content — no sidebar offset */
  .main { margin-left: 0; padding-top: 52px; }
  .cellar-foot { margin-left: 0; }
  .main-content { padding: 0 1rem 1rem; }

  /* Gate — tighter spacing on small screens */
  .gate-title { letter-spacing: 0.06em; }
  .gate-subtitle { font-size: 0.9rem; margin-bottom: 2rem; padding: 0 1.5rem; }
  .gate-enter { padding: 0.75rem 2rem; font-size: 0.65rem; }
  .gate-flora-hint { bottom: 1.5rem; font-size: 0.6rem; padding: 0 1rem; }
  .gate-ornament-line { width: 25px; }

  /* Panel rooms */
  .room-atmosphere { height: 50px; }
  .room-title { font-size: 1.4rem; }
  .room-subtitle { font-size: 0.85rem; padding: 0 0.5rem; }

  /* Chapter cards — larger tap targets */
  .ch-card { padding: 1rem 1rem; gap: 0.8rem; min-height: 56px; }
  .ch-title { font-size: 1.05rem; }
  .ch-icon { width: 32px; height: 32px; flex-shrink: 0; }
  .ch-icon svg { width: 11px; height: 11px; }
  .ch-excerpt { font-size: 0.78rem; -webkit-line-clamp: 2; }

  /* Reading view — full width prose */
  .reading-head h1 { font-size: 1.6rem; }
  .reading-back { margin-bottom: 1.5rem; }
  .prose { max-width: 100%; padding: 0 0.3rem; }
  .prose p { line-height: 1.95; font-size: 1em; }
  .prose p:first-child::first-letter { font-size: 3.2em; }

  /* Chapter nav — stacked */
  .ch-nav { flex-direction: column; gap: 0.8rem; }
  .ch-nav-btn { padding: 1rem 1.2rem; }
  .ch-nav-btn.next { text-align: left; }

  /* Auto-scroll bar — full width */
  .autoscroll-bar { left: 0; padding: 0.4rem 0.8rem; gap: 0.6rem; }
  .autoscroll-label { font-size: 0.5rem; }

  /* Reading progress — full width */
  .reading-progress { left: 0; }

  /* Reading shortcuts — hide on mobile (keyboard shortcuts not useful on touch) */
  .reading-shortcuts { display: none; }
  .sb-key-hint { display: none; }

  /* Mobile auto-scroll button — show */
  .mob-scroll-btn { display: inline-block; }

  /* Tooltips — constrained */
  .lore-tooltip { width: 220px; max-width: 80vw; }

  /* Time tag — larger tap area */
  .time-tag { font-size: 0.65rem; bottom: 0.8rem; right: 0.8rem; }

  /* Constellation — still works but smaller stars */
  .constellation-star { box-shadow: none; }
}
