/* ============================================================
   ERYNDAL LORE BOOK — CSS
   Design: Dark fantasy tome with rich typography
   ============================================================ */

/* --- CSS Variables & Design Tokens --- */
:root {
    --bg-deepest: #0a0a0f;
    --bg-dark: #0f0f18;
    --bg-page: #12121e;
    --bg-card: #181828;
    --bg-card-hover: #1e1e30;
    --bg-sidebar: #0d0d16;

    --text-primary: #e8e4dc;
    --text-secondary: #b0a99a;
    --text-muted: #7a7468;
    --text-heading: #f0ebe0;
    --text-accent: #d4af37;

    --accent-gold: #d4af37;
    --accent-gold-dim: #a8882c;
    --accent-gold-glow: rgba(212, 175, 55, 0.15);
    --accent-warm: #c9a040;

    --border-subtle: rgba(212, 175, 55, 0.08);
    --border-light: rgba(212, 175, 55, 0.15);
    --border-medium: rgba(212, 175, 55, 0.25);

    --shadow-glow: 0 0 30px rgba(212, 175, 55, 0.08);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --font-display: 'Cinzel Decorative', 'Cinzel', serif;
    --font-heading: 'Cinzel', serif;
    --font-body: 'Cormorant Garamond', 'Georgia', serif;
    --font-ui: 'Inter', sans-serif;

    --transition-fast: 0.2s ease;
    --transition-med: 0.4s ease;
    --transition-slow: 0.7s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 18px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-deepest);
    color: var(--text-primary);
    min-height: 100vh;
    overflow: hidden;
    line-height: 1.85;
}

::selection {
    background: rgba(212, 175, 55, 0.3);
    color: #fff;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 175, 55, 0.3);
}

/* --- Ambient Particles --- */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: var(--accent-gold);
    border-radius: 50%;
    opacity: 0;
    animation: float-particle linear infinite;
}

@keyframes float-particle {
    0% {
        opacity: 0;
        transform: translateY(100vh) scale(0);
    }
    10% {
        opacity: 0.6;
        transform: scale(1);
    }
    90% {
        opacity: 0.3;
    }
    100% {
        opacity: 0;
        transform: translateY(-10vh) scale(0);
    }
}


/* ============================================================
   COVER PAGE
   ============================================================ */
.cover-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: var(--bg-deepest);
    background-image: 
        radial-gradient(ellipse at 50% 0%, rgba(212, 175, 55, 0.05) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 100%, rgba(139, 69, 19, 0.04) 0%, transparent 60%);
    transition: opacity 0.8s ease, transform 0.8s ease;
    overflow: hidden;
}

.cover-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4af37' fill-opacity='0.02'%3E%3Cpath d='m36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.cover-page.hidden {
    opacity: 0;
    transform: scale(1.05);
    pointer-events: none;
}

.cover-ornament {
    width: 200px;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-gold-dim), transparent);
    position: relative;
}

.cover-ornament.top {
    margin-bottom: 3rem;
}

.cover-ornament.bottom {
    margin-top: 3rem;
}

.cover-ornament::before {
    content: '◆';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: var(--accent-gold-dim);
    font-size: 0.5rem;
}

.cover-content {
    text-align: center;
    position: relative;
    z-index: 1;
}

.cover-subtitle-top {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
    animation: fadeInUp 1s ease 0.3s both;
}

.cover-title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 0.08em;
    line-height: 1.1;
    text-shadow: 0 0 60px rgba(212, 175, 55, 0.3), 0 0 120px rgba(212, 175, 55, 0.1);
    animation: fadeInUp 1s ease 0.5s both;
}

.cover-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
    animation: fadeInUp 1s ease 0.7s both;
}

.divider-ornament {
    color: var(--accent-gold-dim);
    font-size: 0.6rem;
}

.divider-line {
    width: 120px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-gold-dim), transparent);
}

.cover-subtitle {
    font-family: var(--font-heading);
    font-size: clamp(1rem, 3vw, 1.5rem);
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    animation: fadeInUp 1s ease 0.9s both;
}

.cover-description {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-muted);
    font-style: italic;
    font-weight: 300;
    margin-top: 1rem;
    line-height: 1.6;
    animation: fadeInUp 1s ease 1.1s both;
}

.btn-open {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 2.5rem;
    padding: 0.85rem 2.5rem;
    background: transparent;
    border: 1px solid var(--accent-gold-dim);
    color: var(--accent-gold);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-med);
    animation: fadeInUp 1s ease 1.3s both;
    position: relative;
    overflow: hidden;
}

.btn-open::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(212,175,55,0.1), transparent);
    opacity: 0;
    transition: opacity var(--transition-med);
}

.btn-open:hover {
    border-color: var(--accent-gold);
    box-shadow: 0 0 30px rgba(212, 175, 55, 0.15), inset 0 0 30px rgba(212, 175, 55, 0.05);
    transform: translateY(-2px);
}

.btn-open:hover::before {
    opacity: 1;
}

.btn-icon {
    font-size: 1.1rem;
    transition: transform var(--transition-med);
}

.btn-open:hover .btn-icon {
    transform: translateX(4px);
}

/* ============================================================
   BOOK READER
   ============================================================ */
.book-reader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
    z-index: 50;
    background: var(--bg-dark);
}

.book-reader.active {
    opacity: 1;
    pointer-events: all;
}

/* --- Top Bar --- */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1.5rem;
    background: rgba(15, 15, 24, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-subtle);
    z-index: 30;
    flex-shrink: 0;
}

.btn-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    transition: transform var(--transition-fast);
}

.btn-menu:hover {
    transform: scale(1.1);
}

.btn-menu span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--accent-gold-dim);
    border-radius: 1px;
    transition: all var(--transition-fast);
}

.btn-menu:hover span {
    background: var(--accent-gold);
}

.top-bar-title {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.page-indicator {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: -380px;
    width: 380px;
    max-width: 85vw;
    height: 100%;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    z-index: 60;
    transition: left var(--transition-med);
    display: flex;
    flex-direction: column;
    box-shadow: 10px 0 40px rgba(0,0,0,0.5);
}

.sidebar.open {
    left: 0;
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-med);
}

.sidebar-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--accent-gold);
}

.btn-close-sidebar {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    transition: color var(--transition-fast);
}

.btn-close-sidebar:hover {
    color: var(--text-primary);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-section {
    margin-bottom: 0.5rem;
}

.sidebar-section-title {
    font-family: var(--font-heading);
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0.8rem 1.5rem 0.4rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.6rem 1.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    border-left: 2px solid transparent;
}

.sidebar-item:hover {
    background: rgba(212, 175, 55, 0.04);
    border-left-color: var(--accent-gold-dim);
}

.sidebar-item.active {
    background: rgba(212, 175, 55, 0.08);
    border-left-color: var(--accent-gold);
}

.sidebar-item-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-item-label {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.sidebar-item:hover .sidebar-item-label,
.sidebar-item.active .sidebar-item-label {
    color: var(--text-primary);
}

.sidebar-item-category {
    font-family: var(--font-ui);
    font-size: 0.55rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-left: auto;
    flex-shrink: 0;
}

/* --- Page Container --- */
.page-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    padding: 2rem 1.5rem;
    scroll-behavior: smooth;
}

.page-wrapper {
    width: 100%;
    max-width: 720px;
    position: relative;
}

/* --- Page Content Typography --- */
.page-content {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.page-content.transitioning {
    opacity: 0;
    transform: translateY(20px);
}

/* Chapter page */
.chapter-header {
    text-align: center;
    padding: 4rem 0 3rem;
}

.chapter-number {
    font-family: var(--font-ui);
    font-size: 0.65rem;
    letter-spacing: 0.35em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.chapter-title {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: 700;
    color: var(--accent-gold);
    line-height: 1.2;
    letter-spacing: 0.04em;
    text-shadow: 0 0 40px rgba(212, 175, 55, 0.2);
    margin-bottom: 1rem;
}

.chapter-ornament {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1.5rem 0;
}

.chapter-ornament .line {
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-gold-dim), transparent);
}

.chapter-ornament .symbol {
    color: var(--accent-gold-dim);
    font-size: 0.7rem;
}

.chapter-intro {
    font-family: var(--font-body);
    font-size: 1.05rem;
    font-style: italic;
    font-weight: 300;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.8;
    max-width: 580px;
    margin: 0 auto;
}

/* Deity page */
.deity-header {
    text-align: center;
    padding: 2rem 0 2.5rem;
    position: relative;
}

.deity-category-badge {
    display: inline-block;
    font-family: var(--font-ui);
    font-size: 0.55rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    padding: 0.3rem 1rem;
    border: 1px solid var(--border-light);
    border-radius: 20px;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
}

.deity-name {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.deity-title {
    font-family: var(--font-heading);
    font-size: clamp(0.85rem, 2vw, 1rem);
    font-weight: 400;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

.deity-epithet {
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-style: italic;
    font-weight: 300;
    color: var(--text-muted);
    margin-top: 0.6rem;
    line-height: 1.6;
}

.deity-color-bar {
    width: 60px;
    height: 3px;
    border-radius: 2px;
    margin: 1.5rem auto 0;
}

/* Content Sections */
.content-section {
    margin-bottom: 2.5rem;
}

.section-title {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--accent-gold);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.section-icon {
    font-size: 0.85rem;
}

.content-text {
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: var(--text-primary);
    line-height: 1.9;
    font-weight: 400;
}

.content-text p {
    margin-bottom: 1.2rem;
    text-align: justify;
    text-justify: inter-word;
}

.content-text p:last-child {
    margin-bottom: 0;
}

/* Quote */
.deity-quote {
    position: relative;
    margin: 2rem 0;
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.04), rgba(212, 175, 55, 0.02));
    border-left: 2px solid var(--accent-gold-dim);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.deity-quote p {
    font-family: var(--font-body);
    font-size: 1.15rem;
    font-style: italic;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.8;
    margin: 0;
}

.deity-quote::before {
    content: '"';
    position: absolute;
    top: -0.3rem;
    left: 0.6rem;
    font-family: var(--font-display);
    font-size: 3rem;
    color: var(--accent-gold-dim);
    opacity: 0.3;
    line-height: 1;
}

/* Enmities */
.enmity-block {
    margin-bottom: 1.5rem;
    padding: 1.2rem 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    transition: border-color var(--transition-fast);
}

.enmity-block:hover {
    border-color: var(--border-light);
}

.enmity-title {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.6rem;
    letter-spacing: 0.02em;
}

.enmity-text {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* Symbols */
.symbols-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.symbol-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.symbol-tag:hover {
    border-color: var(--border-light);
    background: rgba(212, 175, 55, 0.04);
}

.symbol-bullet {
    font-size: 0.5rem;
}

/* Creation text */
.creation-text {
    font-family: var(--font-body);
    font-size: 1.15rem;
    color: var(--text-primary);
    line-height: 2;
    font-weight: 400;
}

.creation-text p {
    margin-bottom: 1.5rem;
    text-indent: 2rem;
    text-align: justify;
    text-justify: inter-word;
}

.creation-text p:first-child {
    text-indent: 0;
}

.creation-text p:first-child::first-letter {
    font-family: var(--font-display);
    font-size: 3.5rem;
    float: left;
    line-height: 1;
    margin-right: 0.5rem;
    margin-top: 0.15rem;
    color: var(--accent-gold);
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
}

/* --- Bottom Nav --- */
.bottom-nav {
    display: flex;
    align-items: center;
    padding: 0.8rem 1.5rem;
    background: rgba(10, 10, 18, 0.97);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-light);
    gap: 0.8rem;
    flex-shrink: 0;
    z-index: 30;
}

.btn-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.08), rgba(212, 175, 55, 0.03));
    border: 1px solid var(--border-medium);
    color: var(--accent-gold);
    font-family: var(--font-heading);
    font-size: 0.72rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    padding: 0.65rem 1.4rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.35s ease;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

.btn-nav::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(212, 175, 55, 0.05));
    opacity: 0;
    transition: opacity 0.35s ease;
}

.btn-nav:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.12), 0 0 6px rgba(212, 175, 55, 0.08);
    transform: translateY(-1px);
}

.btn-nav:hover::before {
    opacity: 1;
}

.btn-nav:active {
    transform: translateY(0);
}

.btn-nav:disabled {
    opacity: 0.2;
    cursor: default;
    pointer-events: none;
    box-shadow: none;
    transform: none;
}

.nav-arrow {
    font-size: 1.15rem;
    line-height: 1;
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

.nav-label {
    position: relative;
    z-index: 1;
}

.btn-prev:hover .nav-arrow {
    transform: translateX(-3px);
}

.btn-next:hover .nav-arrow {
    transform: translateX(3px);
}

.bottom-nav-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.progress-bar-container {
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 1px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold-dim), var(--accent-gold));
    border-radius: 1px;
    transition: width var(--transition-med);
    width: 0%;
}

/* --- Pages Map Button --- */
.btn-pages-map {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.06), rgba(212, 175, 55, 0.02));
    border: 1px solid var(--border-medium);
    color: var(--accent-gold);
    font-family: var(--font-heading);
    font-size: 0.62rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-sm);
    transition: all 0.35s ease;
    position: relative;
}

.btn-pages-map::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.12), transparent);
    opacity: 0;
    transition: opacity 0.35s ease;
}

.btn-pages-map:hover {
    border-color: var(--accent-gold);
    box-shadow: 0 0 16px rgba(212, 175, 55, 0.1), 0 0 4px rgba(212, 175, 55, 0.06);
    transform: translateY(-1px);
}

.btn-pages-map:hover::before {
    opacity: 1;
}

.btn-pages-map-icon {
    font-size: 0.7rem;
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

.btn-pages-map:hover .btn-pages-map-icon {
    transform: scale(1.15);
}

.btn-pages-map-label {
    position: relative;
    z-index: 1;
}

/* --- Pages Map Modal --- */
.pages-map-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 10, 0.94);
    backdrop-filter: blur(20px);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    overflow-y: auto;
    padding: 3rem 1rem 2rem;
}

.pages-map-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.pages-map-modal {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    transform: translateY(30px) scale(0.97);
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.pages-map-overlay.visible .pages-map-modal {
    transform: translateY(0) scale(1);
}

.pages-map-header {
    text-align: center;
    padding: 0 0 2rem;
    position: relative;
    flex-shrink: 0;
}

.pages-map-title {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    color: var(--accent-gold);
    letter-spacing: 0.06em;
    text-shadow: 0 0 40px rgba(212, 175, 55, 0.25);
    margin-bottom: 0.4rem;
}

.pages-map-subtitle {
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-style: italic;
    font-weight: 300;
    color: var(--text-muted);
}

.btn-close-map {
    position: absolute;
    top: 0;
    right: 0;
    background: none;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    transition: all 0.25s ease;
}

.btn-close-map:hover {
    color: var(--accent-gold);
    border-color: var(--accent-gold-dim);
    background: rgba(212, 175, 55, 0.06);
}

/* --- Grid --- */
.pages-map-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

/* --- Chapter Dividers --- */
.pages-map-divider {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.2rem;
    padding: 0.85rem 1.5rem;
    cursor: pointer;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.06), rgba(212, 175, 55, 0.02));
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    position: relative;
    overflow: hidden;
    transition: all 0.35s ease;
    opacity: 0;
    transform: translateY(10px);
    animation: mapCardIn 0.4s ease forwards;
}

.pages-map-divider::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.35s ease;
}

.pages-map-divider:first-child {
    margin-top: 0;
}

.pages-map-divider:hover {
    border-color: var(--accent-gold);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.1), 0 0 6px rgba(212, 175, 55, 0.06);
    transform: translateY(-1px);
}

.pages-map-divider:hover::before {
    opacity: 1;
}

.pages-map-divider-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent-gold-dim), transparent);
    max-width: 80px;
    position: relative;
    z-index: 1;
}

.pages-map-divider-text {
    font-family: var(--font-heading);
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent-gold);
    white-space: nowrap;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.pages-map-divider:hover .pages-map-divider-text {
    text-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
}

/* --- Deity Block Cards --- */
.pages-map-card {
    position: relative;
    padding: 1.4rem 1.5rem 1.2rem;
    background: rgba(18, 18, 30, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 3px solid var(--card-accent-color, var(--accent-gold-dim));
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.35s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    opacity: 0;
    transform: translateY(16px);
    animation: mapCardIn 0.4s ease forwards;
}

.pages-map-card:hover {
    background: rgba(24, 24, 40, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
    border-bottom-color: var(--card-accent-color, var(--accent-gold-dim));
    transform: translateY(-3px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), 0 0 20px rgba(212, 175, 55, 0.03);
}

.pages-map-card-name {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-bottom: 0.2rem;
    line-height: 1.2;
}

.pages-map-card-domain {
    font-family: var(--font-heading);
    font-size: 0.55rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    margin-bottom: 0.9rem;
    opacity: 0.7;
}

.pages-map-card-desc {
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.6;
    flex: 1;
}

.pages-map-card-quote {
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 300;
    font-style: italic;
    color: var(--text-muted);
    line-height: 1.5;
    margin-top: 0.8rem;
    padding-top: 0.7rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

@keyframes mapCardIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Animations --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Page Transition States --- */
.page-content .fade-in-element {
    opacity: 0;
    transform: translateY(12px);
    animation: fadeInUp 0.5s ease forwards;
}

.page-content .fade-in-element:nth-child(1) { animation-delay: 0.05s; }
.page-content .fade-in-element:nth-child(2) { animation-delay: 0.1s; }
.page-content .fade-in-element:nth-child(3) { animation-delay: 0.15s; }
.page-content .fade-in-element:nth-child(4) { animation-delay: 0.2s; }
.page-content .fade-in-element:nth-child(5) { animation-delay: 0.25s; }
.page-content .fade-in-element:nth-child(6) { animation-delay: 0.3s; }
.page-content .fade-in-element:nth-child(7) { animation-delay: 0.35s; }
.page-content .fade-in-element:nth-child(8) { animation-delay: 0.4s; }
.page-content .fade-in-element:nth-child(9) { animation-delay: 0.45s; }
.page-content .fade-in-element:nth-child(10) { animation-delay: 0.5s; }
.page-content .fade-in-element:nth-child(11) { animation-delay: 0.55s; }
.page-content .fade-in-element:nth-child(12) { animation-delay: 0.6s; }

/* --- Responsive --- */
@media (max-width: 768px) {
    html {
        font-size: 16px;
    }

    .page-container {
        padding: 1.5rem 1rem;
    }

    .chapter-header {
        padding: 2rem 0 2rem;
    }

    .deity-header {
        padding: 1.5rem 0 2rem;
    }

    .deity-quote {
        padding: 1.2rem 1.2rem;
    }

    .enmity-block {
        padding: 1rem 1rem;
    }

    .btn-nav .nav-label {
        display: none;
    }

    .btn-nav {
        padding: 0.6rem 0.9rem;
    }

    .pages-map-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .pages-map-card {
        min-height: 180px;
    }

    .pages-map-overlay {
        padding: 2rem 0.8rem 1.5rem;
    }

    .content-text {
        font-size: 1rem;
    }

    .creation-text {
        font-size: 1.05rem;
    }

    .creation-text p:first-child::first-letter {
        font-size: 2.8rem;
    }
}

@media (max-width: 480px) {
    .cover-title {
        font-size: 2.5rem;
    }

    .cover-subtitle {
        font-size: 0.9rem;
    }

    .top-bar {
        padding: 0.7rem 1rem;
    }

    .bottom-nav {
        padding: 0.7rem 1rem;
    }

    .btn-pages-map-label {
        display: none;
    }

    .pages-map-grid {
        grid-template-columns: 1fr;
    }

    .pages-map-card {
        min-height: 160px;
    }

    .pages-map-card-name {
        font-size: 1.1rem;
    }
}

/* --- Deity Color Utility --- */
.color-lila { color: #FFD700; }
.color-raghul { color: #8B0000; }
.color-shikyu { color: #8B6914; }
.color-aquoon { color: #1E90FF; }
.color-gor { color: #FF4500; }
.color-yggdrasil { color: #228B22; }
.color-simorg { color: #87CEEB; }
.color-voldec { color: #9370DB; }
.color-khal { color: #4B0082; }
.color-zuto { color: #C0C0C0; }
.color-raftina { color: #FF69B4; }
.color-gleive { color: #DC143C; }
.color-aslon { color: #DAA520; }
.color-salamandra { color: #FF6347; }
.color-viper { color: #6B8E23; }
.color-karin { color: #BDB76B; }
.color-delfias { color: #ADD8E6; }
.color-sorte { color: #32CD32; }
.color-dagan { color: #800080; }
.color-arcania { color: #9400D3; }
.color-gandora { color: #FF7F50; }
.color-celestia { color: #FF00FF; }
.color-general { color: #556B2F; }
.color-zahak { color: #708090; }
.color-ophion { color: #2F4F4F; }
.color-riurran { color: #6A5ACD; }
.color-grunika { color: #A0522D; }
.color-phoenix { color: #FF8C00; }
