/* ============================================================
   Joshua — The Odyssey of an Ordinary Man
   Shared Stylesheet · style.css
   ============================================================ */

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

/* ── CSS Variables ── */
:root {
  /* Gold palette */
  --gold-bright:  #f0c040;
  --gold-main:    #d4a017;
  --gold-deep:    #a07010;
  --gold-text:    #f5d060;

  /* Misc */
  --cream:        #f5ede0;
  --parchment:    #fff3db;
  --white:        #ffffff;
  --red-hi:       #e03030;
  --red-mid:      #a01818;
  --red-lo:       #cc2828;
  --bg-dark:      #0d0906;

  /* Layout */
  --border-pad:   8.5vw;
  --toc-width:    320px;

  /*
    ── DARK TEXT PALETTE (for pages with light/parchment backgrounds) ──
    Used on: dedication.html, the-book.html, ch-*.html, contents.html
  */
  --ink:          #1a1008;   /* headings, strong emphasis   */
  --ink-mid:      #2e1e0a;   /* body text                   */
  --ink-light:    #5a3e1e;   /* numbers, secondary text     */

  --shadow-strong:
    drop-shadow(0 0 1px rgba(0,0,0,1))
    drop-shadow(0 1px 1px rgba(0,0,0,0.5))
    drop-shadow(0 1px 1px rgba(0,0,0,0.6))
    drop-shadow(0 1px 1px rgba(0,0,0,0.7))
    drop-shadow(0 1px 1px rgba(0,0,0,0.8))
    drop-shadow(0 1px 1px rgba(0,0,0,0.9));

  --shadow-mild:
    0 0 2px rgba(0,0,0,0.9),
    1px 0 2px rgba(0,0,0,0.9),
    -1px 0 2px rgba(0,0,0,0.9),
    0 1px 2px rgba(0,0,0,0.9),
    0 -1px 2px rgba(0,0,0,0.9);

  --shadow-pg:
    0 1px 2px rgba(60,30,0,0.18),
    0 0   1px rgba(60,30,0,0.10);
}

/* ── Base ── */
html, body {
  min-height: 100%;
  font-family: Georgia, serif;
  overflow-x: hidden;
}

body {
  background: url('images/cover2.webp') center 28% / cover no-repeat fixed;
  background-color: var(--bg-dark);
  min-height: 100vh;
}

/* ── Navigation ── */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  padding: 0.85rem 2rem;
  background: linear-gradient(180deg, rgba(0,0,0,0.75) 0%, transparent 100%);
}

nav a {
  font-family: serif;
  font-size: 0.8rem;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--white);
  text-decoration: none;
  opacity: 0.55;
  padding: 0.25rem 0.35rem;
  transition: opacity 0.22s, color 0.22s;
  position: relative;
}
nav a::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 50%; right: 50%;
  height: 1px;
  background: var(--gold-main);
  transition: left 0.25s, right 0.25s;
}
nav a:hover,
nav a.active { opacity: 1; color: var(--gold-text); }
nav a.active::after { left: 0; right: 0; }

/* ── Gold Gradient Text ── */
.gold-text {
  background: linear-gradient(180deg,
    #ffe680 0%, #f5c520 18%, #d4970a 38%,
    #f0c030 55%, #c88a08 72%, #f5d050 88%, #a06808 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: var(--shadow-strong);
}

.gold-text-light {
  background: linear-gradient(180deg,
    #fde99a 0%, #e8b820 30%, #c98808 65%, #e8c040 100%
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: var(--shadow-strong);
}

/* ── Gold Rule ── */
.gold-rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-main), transparent);
  opacity: 0.55;
  margin: 0 auto;
}


.top-block {
  position: relative;
  z-index: 10;
  width: 100%;
  text-align: center;
  padding: 0.5rem var(--border-pad);
  animation: fadeDown 1.1s ease both;
  margin-bottom: 0.5rem;
}

.top-rule-bottom {
  width: clamp(80px, 22vw, 260px);
  margin-top: 1.1rem;
}

/* ── Section label ── */
.section-label {
  font-family: Georgia, serif;
  font-size: 3rem;
  letter-spacing: 0.48em;
  color: white;
  filter: var(--shadow-strong);
  text-transform: uppercase;
  display: block;
}

/* ── Author line (white text, cover pages) ── */
.author-line {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: clamp(1.9rem, 2.9vw, 2rem);
  letter-spacing: 0.05em;
  color: white;
  filter: var(--shadow-strong);
  display: block;
}

/* ── Divider ── */
.divider {
  width: 70px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-main), transparent);
  margin: 0 auto;
  opacity: 0.5;
}

/* ── Prose (white text, index/cover page) ── */
.prose {
  font-family: serif;
  font-size: clamp(1rem, 1.55vw, 1.5rem);   /* fixed: min was larger than max */
  color: white;
  filter: var(--shadow-strong);
  font-style: italic;
  padding: 2rem;
}
.prose .hl {
  font-style: italic;
  font-size: clamp(1rem, 1.55vw, 1.5rem);
}
.prose p { padding: 2px 0; }

/* ── CTA Button ── */
.btn {
  font-family: serif;
  font-size: 0.57rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  background: none;
  border: 1px solid rgba(212,160,23,0.5);
  color: var(--gold-text);
  padding: 0.65rem 1.7rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.3s, border-color 0.3s, color 0.3s;
}
.btn:hover {
  background: rgba(212,160,23,0.12);
  border-color: var(--gold-main);
  color: #ffe680;
}

/* ── Footer ── */
.footer {
  position: relative;
  z-index: 10;
  width: 100%;
  text-align: center;
  padding: 1rem 2rem;
  font-family: serif;
  font-size: 0.5rem;
  letter-spacing: 0.3em;
  color: var(--gold-main);
  opacity: 0.4;
  border-top: 1px solid rgba(212,160,23,0.1);
  margin-top: auto;
}

/* ══════════════════════════════════════
   PAGE NAVIGATION ARROWS
══════════════════════════════════════ */
.page-nav {
  position: fixed;
  bottom: 2.2rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.3s, transform 0.3s;
  opacity: 0.88;
  animation: fadeInNav 1.4s 0.5s ease both;
}
.page-nav:hover        { opacity: 1; transform: translateX(5px); }
.page-nav.nav-prev     { left: 2rem; }
.page-nav.nav-prev:hover { transform: translateX(-5px); }
.page-nav.nav-next     { right: 2rem; }

.page-nav-label {
  font-family: serif;
  font-size: 0.56rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--gold-text);
  white-space: nowrap;
  text-shadow:
    0 0 10px rgba(212,160,23,0.7),
    0 0 3px rgba(0,0,0,1),
    0 2px 8px rgba(0,0,0,0.9);
}

.page-nav-arrow {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center,
    rgba(30,18,4,0.82) 0%, rgba(10,6,2,0.70) 100%
  );
  box-shadow:
    0 0 0 1px rgba(212,160,23,0.75),
    0 0 0 4px rgba(212,160,23,0.12),
    0 0 18px 4px rgba(212,160,23,0.3),
    0 4px 24px rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  transition: background 0.3s, box-shadow 0.3s;
}
.page-nav-arrow::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(212,160,23,0.25);
  transition: border-color 0.3s, inset 0.3s;
}
.page-nav:hover .page-nav-arrow {
  background: radial-gradient(circle at center,
    rgba(60,36,6,0.88) 0%, rgba(20,12,2,0.80) 100%
  );
  box-shadow:
    0 0 0 1px rgba(240,192,64,0.95),
    0 0 0 5px rgba(212,160,23,0.18),
    0 0 30px 10px rgba(212,160,23,0.45),
    0 4px 32px rgba(0,0,0,0.75);
}
.page-nav:hover .page-nav-arrow::before {
  border-color: rgba(212,160,23,0.55);
  inset: -9px;
}
.page-nav-arrow svg {
  width: 20px;
  height: 20px;
  stroke: var(--gold-bright);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  filter:
    drop-shadow(0 0 6px rgba(212,160,23,1))
    drop-shadow(0 0 2px rgba(255,220,80,0.8));
}

/* ══════════════════════════════════════
   CHAPTER READING AREA
══════════════════════════════════════ */
.chapter-body {
  position: relative;
  z-index: 10;
  width: 85%;
  padding: 1.5rem var(--border-pad) 8rem;
  animation: fadeIn 1s 0.2s ease both;
  flex: 1;
}

.chapter-body .chapter-img {
  display: block;
  width: 100%;
  max-width: 520px;
  height: auto;
  margin: 2rem auto;
  border-radius: 2px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.1);
}

.chapter-body .chapter-img.image-sm {
  display: block;
  text-align: left;
  width: 200px;
  border-radius: 2px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.1);
}

.page-title {
  font-family: Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  line-height: 1.3;
  display: block;
}

/* Chapter inner heading */
.chapter-title {
  font-family: Georgia, serif;
  font-weight: 700;
  font-size: clamp(1.2rem, 2.2vw, 1.6rem);
  line-height: 1.3;
  color: var(--ink-mid);
  text-shadow: var(--shadow-pg);
  text-align: center;
  margin-bottom: 0.6rem;
}

.chapter-title-rule {
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(160,112,16,0.5), transparent);
  margin: 0.6rem auto 2rem;
}

/* Chapter subtitle */
.chapter-subtitle {
  font-family: Georgia, serif;
  font-weight: 700;
  font-size: clamp(0.75rem, 1.6vw, 1.2rem);
  line-height: 1.5;
  color: var(--ink-soft);
  text-shadow: var(--shadow-pg);
  text-align: center;
  margin-top: -0.2rem;
  margin-bottom: 1.2rem;
  letter-spacing: 0.02em;
  opacity: 0.9;
}

/* Body paragraphs — dark ink on light bg */
.chapter-body p {
  font-family: Georgia, serif;
  font-size: clamp(1.2rem, 1.4vw, 1.6rem);
  line-height: 1.85;
  color: var(--ink-mid);
  text-shadow: var(--shadow-pg);
  margin-bottom: 1.4rem;
  text-align: justify;
}
.chapter-body p:last-child { margin-bottom: 0; }

.chapter-body p.light-heading {
  font-family: Georgia, serif;
  font-size: clamp(1rem, 1.6vw, 1.25rem) !important;
  font-weight: 700;
  color: var(--ink) !important;
  text-shadow: var(--shadow-pg) !important;
  letter-spacing: 0.06em;
  border-bottom: 1px solid rgba(160,112,16,0.3);
  padding-bottom: 0.4rem;
  margin-top: 0.8rem !important;
  margin-bottom: 0 !important;
}

/* Placeholder for empty chapters */
.chapter-placeholder {
  font-family: Georgia, serif;
  font-style: italic;
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  color: rgba(40,20,5,0.25);
  text-align: center;
  padding: 4rem 0;
  border: 1px dashed rgba(160,112,16,0.2);
  border-radius: 2px;
}
.chapter-body ul,
.chapter-body ol {
  font-family: Georgia, serif;
  font-size: clamp(1rem, 1.4vw, 1.2rem);
  line-height: 1.85;
  color: var(--ink-mid);
  text-shadow: var(--shadow-pg);
  margin: 0 0 1.4rem 1.4rem;
  padding: 0;
}

.chapter-body li {
  margin-bottom: 0.6rem;
}

.chapter-body li:last-child {
  margin-bottom: 0;
}
/* ══════════════════════════════════════
   SLIDING TOC DRAWER
══════════════════════════════════════ */
.toc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 290;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}
.toc-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.toc-drawer {
  position: fixed;
  top: 0; left: 0;
  height: 100%;
  width: var(--toc-width);
  max-width: 88vw;
  z-index: 300;
  background: linear-gradient(160deg, rgba(12,7,2,0.97) 0%, rgba(20,12,3,0.97) 100%);
  border-right: 1px solid rgba(212,160,23,0.3);
  box-shadow: 4px 0 40px rgba(0,0,0,0.9);
  transform: translateX(-100%);
  transition: transform 0.38s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.toc-drawer.open { transform: translateX(0); }

.toc-header {
  padding: 1.8rem 1.5rem 1rem;
  border-bottom: 1px solid rgba(212,160,23,0.2);
  flex-shrink: 0;
}
.toc-header-label {
  font-family: serif;
  font-size: 1rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--gold-text);
  text-shadow: 0 0 8px rgba(212,160,23,0.5), 0 0 2px rgba(0,0,0,1);
  display: block;
  margin-bottom: 0.3rem;
}
.toc-header-book {
  font-family: Georgia, serif;
  font-size: 1.1rem;
  font-style: italic;
  color: rgba(255,255,255,0.5);
  filter: drop-shadow(0 0 1px rgba(0,0,0,1));
  display: block;
}

.toc-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0.6rem 0 2rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(212,160,23,0.3) transparent;
}
.toc-list::-webkit-scrollbar { width: 4px; }
.toc-list::-webkit-scrollbar-thumb { background: rgba(212,160,23,0.3); border-radius: 2px; }

.toc-list li a {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  padding: 0.6rem 1.5rem;
  text-decoration: none;
  transition: background 0.18s, padding-left 0.18s;
}
.toc-list li a:hover {
  background: rgba(212,160,23,0.07);
  padding-left: 2rem;
}
.toc-list li.active a { background: rgba(212,160,23,0.1); }
.toc-list li.active a .toc-title { color: var(--gold-text); }

.toc-num {
  font-family: serif;
  font-size: 1rem;
  letter-spacing: 0.15em;
  color: var(--gold-main);
  min-width: 1.8rem;
  flex-shrink: 0;
  filter: drop-shadow(0 0 2px rgba(0,0,0,1));
}
.toc-title {
  font-family: Georgia, serif;
  font-size: 1rem;
  font-style: italic;
  color: rgba(255,255,255,0.78);
  filter: drop-shadow(0 0 1px rgba(0,0,0,1));
  line-height: 1.35;
}

/* ── TOC Toggle Button ── */
.toc-toggle {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 310;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: left 0.38s cubic-bezier(0.4,0,0.2,1);
}
.toc-toggle.shifted { left: calc(var(--toc-width) - 22px); }

.toc-toggle-label {
  font-family: serif;
  font-size: 0.38rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-text);
  text-shadow: 0 0 8px rgba(212,160,23,0.6), 0 0 2px rgba(0,0,0,1);
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  white-space: nowrap;
  transition: opacity 0.2s;
}
.toc-toggle.shifted .toc-toggle-label { opacity: 0; pointer-events: none; }

.toc-toggle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at center,
    rgba(30,18,4,0.9) 0%, rgba(10,6,2,0.8) 100%
  );
  box-shadow:
    0 0 0 1px rgba(212,160,23,0.7),
    0 0 0 4px rgba(212,160,23,0.1),
    0 0 18px 4px rgba(212,160,23,0.25),
    2px 0 20px rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.25s, background 0.25s;
  position: relative;
}
.toc-toggle-btn::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid rgba(212,160,23,0.22);
  transition: border-color 0.25s, inset 0.25s;
}
.toc-toggle:hover .toc-toggle-btn {
  background: radial-gradient(circle at center,
    rgba(60,36,6,0.92) 0%, rgba(20,12,2,0.88) 100%
  );
  box-shadow:
    0 0 0 1px rgba(240,192,64,0.95),
    0 0 0 5px rgba(212,160,23,0.18),
    0 0 28px 8px rgba(212,160,23,0.45),
    2px 0 24px rgba(0,0,0,0.75);
}
.toc-toggle:hover .toc-toggle-btn::before {
  border-color: rgba(212,160,23,0.5);
  inset: -8px;
}
.toc-toggle-btn svg {
  width: 16px;
  height: 16px;
  stroke: var(--gold-bright);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  filter: drop-shadow(0 0 5px rgba(212,160,23,0.9)) drop-shadow(0 0 2px rgba(0,0,0,1));
  transition: transform 0.35s ease;
}
.toc-toggle.shifted .toc-toggle-btn svg { transform: rotate(180deg); }

/* ══════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════ */
@keyframes fadeDown {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInNav {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 0.88; transform: translateY(0); }
}

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 820px) {
  :root { --border-pad: 5vw; --toc-width: 280px; }
}
@media (max-width: 600px) {
  :root { --border-pad: 3vw; --toc-width: 88vw; }
  .page-nav { bottom: 1.2rem; }
  .page-nav.nav-prev { left: 1rem; }
  .page-nav.nav-next { right: 1rem; }
  .page-nav-label { font-size: 0.44rem; letter-spacing: 0.2em; }
  .page-nav-arrow { width: 36px; height: 36px; }

  .top-block    { padding-top: 0.75in; }
  .chapter-body { padding-bottom: calc(0.75in + 1rem); }
}