@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;800&family=Lora:ital,wght@0,500;0,600;0,700;1,500&family=Montserrat:wght@500;600;700;800&family=Noto+Sans+KR:wght@400;500;700&family=Noto+Sans+TC:wght@400;500;700&family=Noto+Serif+KR:wght@400;700&family=Noto+Serif+TC:wght@400;600;700&family=Playfair+Display:ital,wght@0,600;0,700;0,800;1,600&family=Space+Grotesk:wght@500;700&display=swap');

/* Ensure all numerals across the entire UI use full-height modern lining numbers (not old-style descending figures) */
*, body, h1, h2, h3, h4, h5, h6, .font-lore-heading, .font-serif-tc, .font-sans-tc {
  font-variant-numeric: lining-nums proportional-nums;
  font-feature-settings: "lnum" 1;
}

/* Base Font Families */
.font-serif-tc { font-family: 'Noto Serif TC', 'Noto Serif KR', serif; }
.font-sans-tc { font-family: 'Noto Sans TC', 'Noto Sans KR', sans-serif; }
.font-lore-heading { font-family: 'Playfair Display', 'Cinzel', 'Noto Serif TC', 'Noto Serif KR', serif; }
.font-cyber-mono { font-family: 'Space Grotesk', 'Noto Sans TC', monospace; }

/* Dynamic Heading Font Presets */
body.heading-font-playfair .font-lore-heading {
  font-family: 'Playfair Display', 'Noto Serif TC', 'Noto Serif KR', serif;
}
body.heading-font-cinzel .font-lore-heading {
  font-family: 'Cinzel', 'Noto Serif TC', 'Noto Serif KR', serif;
}
body.heading-font-lora .font-lore-heading {
  font-family: 'Lora', 'Noto Serif TC', 'Noto Serif KR', serif;
}
body.heading-font-montserrat .font-lore-heading {
  font-family: 'Montserrat', 'Noto Sans TC', 'Noto Sans KR', sans-serif;
}

/* ========================================================
   THEMES PALETTES
   ======================================================== */

/* 1. FEVER ERA: Warm Nostalgic Diary / Cream Paper */
body.theme-fever {
  --bg-main: #f8f4ec;
  --bg-card: #fdfbf7;
  --bg-surface: #ede7d9;
  --border-color: rgba(94, 69, 44, 0.15);
  --text-main: #2d241e;
  --text-muted: #796656;
  --accent: #b45309;
  --accent-glow: rgba(180, 83, 9, 0.12);
  --badge-bg: #e6dcce;
  --badge-text: #453223;
  --header-bg: rgba(248, 244, 236, 0.92);
}

/* 2. THE WORLD ERA: Dystopian Strictland / Cyberpunk Resistance */
body.theme-the-world {
  --bg-main: #0d0f12;
  --bg-card: #15181e;
  --bg-surface: #1d212a;
  --border-color: rgba(204, 255, 0, 0.22);
  --text-main: #f0f3f6;
  --text-muted: #8b949e;
  --accent: #d4ff00;
  --accent-glow: rgba(212, 255, 0, 0.15);
  --badge-bg: rgba(212, 255, 0, 0.1);
  --badge-text: #d4ff00;
  --header-bg: rgba(13, 15, 18, 0.94);
}

/* 3. GOLDEN HOUR ERA: Twilight / Celestial Blue & Gold */
body.theme-golden-hour {
  --bg-main: #0c1222;
  --bg-card: #131b32;
  --bg-surface: #1a2544;
  --border-color: rgba(229, 178, 93, 0.25);
  --text-main: #f4f6fa;
  --text-muted: #9aa8c7;
  --accent: #f0be65;
  --accent-glow: rgba(240, 190, 101, 0.15);
  --badge-bg: rgba(240, 190, 101, 0.12);
  --badge-text: #f0be65;
  --header-bg: rgba(12, 18, 34, 0.94);
}

/* 4. CLASSIC SEPIA (Book Novel) */
body.theme-sepia {
  --bg-main: #f4ecd8;
  --bg-card: #faf5e8;
  --bg-surface: #e8dcbf;
  --border-color: rgba(60, 40, 20, 0.12);
  --text-main: #332211;
  --text-muted: #725e4a;
  --accent: #8c4a1e;
  --accent-glow: rgba(140, 74, 30, 0.1);
  --badge-bg: #e2d2ae;
  --badge-text: #3c2411;
  --header-bg: rgba(244, 236, 216, 0.94);
}

/* 5. OLED DARK */
body.theme-dark {
  --bg-main: #121212;
  --bg-card: #1c1c1e;
  --bg-surface: #28282b;
  --border-color: rgba(255, 255, 255, 0.1);
  --text-main: #e8e8ed;
  --text-muted: #8e8e93;
  --accent: #60a5fa;
  --accent-glow: rgba(96, 165, 250, 0.15);
  --badge-bg: rgba(255, 255, 255, 0.08);
  --badge-text: #60a5fa;
  --header-bg: rgba(18, 18, 18, 0.94);
}

/* 6. CLEAN WHITE */
body.theme-light {
  --bg-main: #ffffff;
  --bg-card: #f9fafb;
  --bg-surface: #f3f4f6;
  --border-color: rgba(0, 0, 0, 0.08);
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-glow: rgba(37, 99, 235, 0.1);
  --badge-bg: #eff6ff;
  --badge-text: #1d4ed8;
  --header-bg: rgba(255, 255, 255, 0.94);
}

/* Dynamic CSS bindings */
body {
  background-color: var(--bg-main);
  color: var(--text-main);
  transition: background-color 0.25s ease, color 0.25s ease;
}

.ui-card {
  background-color: var(--bg-card);
  border-color: var(--border-color);
}

.ui-surface {
  background-color: var(--bg-surface);
}

.ui-border {
  border-color: var(--border-color);
}

.ui-header {
  background-color: var(--header-bg);
  border-color: var(--border-color);
}

.ui-accent {
  color: var(--accent);
}

.ui-accent-bg {
  background-color: var(--accent);
}

.ui-badge {
  background-color: var(--badge-bg);
  color: var(--badge-text);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

/* Custom Details / Summary */
summary::-webkit-details-marker {
  display: none;
}
summary {
  list-style: none;
}

/* Redacted Bar Effect (Classified Government Docs) */
.redacted-text {
  background-color: currentColor;
  color: transparent !important;
  user-select: none;
  display: inline-block;
  padding: 0 4px;
  border-radius: 2px;
  cursor: pointer;
  transition: all 0.2s;
}
.redacted-text:hover {
  background-color: transparent;
  color: var(--accent) !important;
}

/* Drawer transitions */
.drawer-backdrop {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer-panel {
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.drawer-panel.open {
  transform: translateX(0);
}

/* Paragraph Row Highlight */
.paragraph-row {
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.paragraph-row:hover {
  background-color: var(--accent-glow);
}

/* Quote Card Modal Animation */
.modal-fade-in {
  animation: fadeIn 0.2s ease-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

/* Explicit Emphasis Styling for Canon Texts */
u {
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1.5px;
}
b, strong {
  font-weight: 700;
}
i, em {
  font-style: italic;
}

/* Diary Special Styling: Red & Bold text in Golden Hour Part.2 */
.diary-red {
  color: #c84b31;
}
body.theme-golden-hour .diary-red,
body.theme-the-world .diary-red,
body.theme-dark .diary-red {
  color: #ff7b72;
}
.diary-red-bold {
  color: #c84b31;
  font-weight: 700;
}
body.theme-golden-hour .diary-red-bold,
body.theme-the-world .diary-red-bold,
body.theme-dark .diary-red-bold {
  color: #ff7b72;
  font-weight: 700;
}
.diary-speaker {
  font-weight: 700;
  margin-right: 0.5rem;
  color: var(--text-main);
  display: inline-block;
}
.diary-italic, i, em {
  font-style: italic;
}
.diary-dot {
  text-align: center;
  font-size: 0.85rem;
  line-height: 1;
  margin: 1.5rem 0 1.25rem 0;
  user-select: none;
  opacity: 0.55;
  letter-spacing: 0.25rem;
}
.diary-dot-red {
  color: #c84b31;
  opacity: 0.95;
}
body.theme-golden-hour .diary-dot-red,
body.theme-the-world .diary-dot-red,
body.theme-dark .diary-dot-red {
  color: #ff7b72;
}
.diary-box {
  border: 1.5px solid #e06c57;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 1.25rem;
  font-weight: 600;
  text-align: center;
  background-color: rgba(224, 108, 87, 0.08);
  color: #c84b31;
  font-size: 0.95em;
  letter-spacing: 0.02em;
}
body.theme-golden-hour .diary-box,
body.theme-the-world .diary-box,
body.theme-dark .diary-box {
  border-color: #ff7b72;
  background-color: rgba(255, 123, 114, 0.12);
  color: #ff8577;
}
.diary-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, #e06c57, transparent);
  margin: 2rem 0;
  opacity: 0.7;
}
body.theme-golden-hour .diary-divider,
body.theme-the-world .diary-divider,
body.theme-dark .diary-divider {
  background: linear-gradient(to right, transparent, #ff7b72, transparent);
}
.diary-footnote {
  font-size: 0.8rem;
  opacity: 0.75;
  border-top: 1px solid var(--border-color);
  padding-top: 0.5rem;
  margin-top: 1.25rem;
}
.diary-footnote-ref {
  font-size: 0.75em;
  vertical-align: super;
  color: var(--accent);
  font-weight: bold;
}

/* Bookmark pulse & active styles */
@keyframes bookmarkPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.45);
    background-color: rgba(217, 119, 6, 0.18);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(217, 119, 6, 0);
    background-color: rgba(217, 119, 6, 0.1);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0);
  }
}

.bookmark-active {
  border-left: 3px solid var(--accent) !important;
}

.bookmark-highlight {
  animation: bookmarkPulse 2.5s ease-out;
  border-left: 3px solid var(--accent) !important;
}
