/*
 * PENANCE WIKI - 15TH CENTURY MANUSCRIPT STYLE
 * Dark Gothic Aesthetic with Human Leather Texture
 * Inspired by medieval illuminated manuscripts and grimoires
 */

@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@400;700&family=Crimson+Pro:wght@400;600;700&family=Libre+Baskerville:ital@0;1&display=swap');

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    overflow-y: auto;
}

:root {
    /* Gothic Color Palette */
    --parchment-dark: #1a1410;
    --leather-brown: #2b1f17;
    --blood-red: #4a0e0e;
    --dark-red: #6b1a1a;
    --blackish-red: #2d0a0a;
    --bone-white: #d4c5b0;
    --aged-gold: #8b7355;
    --shadow-black: #0a0604;
    --crimson-text: #8b0000;

    /* Textures */
    --leather-texture: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="4" /></filter><rect width="400" height="400" filter="url(%23noise)" opacity="0.15"/></svg>');
}

body {
    font-family: 'Libre Baskerville', 'Crimson Pro', Georgia, serif;
    background-color: var(--parchment-dark);
    background-image:
        /* Horizontal paper grain lines (like the parchment headers) */
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 1px,
            rgba(212, 197, 176, 0.04) 1px,
            rgba(212, 197, 176, 0.04) 2px,
            transparent 2px,
            transparent 4px,
            rgba(212, 197, 176, 0.025) 4px,
            rgba(212, 197, 176, 0.025) 5px
        ),
        /* Subtle vertical fibers (less prominent) */
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 3px,
            rgba(212, 197, 176, 0.015) 3px,
            rgba(212, 197, 176, 0.015) 4px
        ),
        /* Organic variation spots */
        radial-gradient(circle at 20% 30%, rgba(212, 197, 176, 0.03) 0%, transparent 5%),
        radial-gradient(circle at 80% 60%, rgba(212, 197, 176, 0.025) 0%, transparent 8%),
        radial-gradient(circle at 40% 80%, rgba(212, 197, 176, 0.02) 0%, transparent 6%),
        radial-gradient(circle at 60% 20%, rgba(212, 197, 176, 0.035) 0%, transparent 7%),
        /* Base gradient */
        var(--leather-texture),
        linear-gradient(to bottom, var(--leather-brown) 0%, var(--parchment-dark) 50%, var(--shadow-black) 100%);
    background-attachment: fixed;
    color: var(--bone-white);
    line-height: 1.75;
    letter-spacing: 0.02em;
    overflow-x: hidden;
    overflow-y: auto;
    margin: 0;
    padding: 0;
}

/* Figure and image utilities */
.codex-figure {
    background: rgba(10, 6, 4, 0.5);
    border: 1px solid var(--dark-red);
    padding: 0.75rem;
    margin: 1.25rem 0;
    box-shadow: 0 6px 18px rgba(0,0,0,0.5);
}
.codex-figure img {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid rgba(139,0,0,0.5);
    background: #2b1f17;
}
.codex-figure figcaption {
    font-size: 0.95rem;
    color: var(--aged-gold);
    margin-top: 0.5rem;
    text-align: center;
}
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}
.image-grid .codex-figure { margin: 0; }
.codex-figure .credit { display: block; opacity: 0.7; font-style: italic; font-size: 0.85rem; }

/* Torn “rip” edge and light parallax for featured images */
.rip-parallax {
    position: relative;
    overflow: hidden;
    /* Torn top and bottom edges using a jagged clip-path */
    clip-path: polygon(
        0 2%, 5% 0, 10% 2%, 15% 0, 20% 3%, 25% 1%, 30% 3%, 35% 0, 40% 2%, 45% 1%,
        50% 3%, 55% 0, 60% 2%, 65% 1%, 70% 3%, 75% 0, 80% 2%, 85% 1%, 90% 3%, 95% 0,
        100% 2%, 100% 98%, 95% 100%, 90% 98%, 85% 100%, 80% 97%, 75% 99%, 70% 97%, 65% 100%,
        60% 98%, 55% 99%, 50% 97%, 45% 100%, 40% 98%, 35% 99%, 30% 97%, 25% 100%, 20% 98%,
        15% 99%, 10% 97%, 5% 100%, 0 98%
    );
}
.rip-parallax img {
    will-change: transform;
    transform: translateY(var(--parallax, 0px));
    transition: transform 0.06s linear;
}

/* Background tear reveal band (shows an image “behind the page”) */
.tear-reveal {
    position: relative;
    height: var(--tear-height, clamp(220px, 34vw, 520px));
    margin: 1.5rem 0 2rem 0;
    overflow: hidden;
}
.tear-reveal .tear-bg {
    position: absolute;
    inset: 0;
    background-size: var(--tear-bg-size, cover);
    background-position: var(--tear-bg-position, center center);
    transform: translateY(var(--tearParallax, 0px));
    will-change: transform;
    transition: transform 0.06s linear;
}
/* Top torn edge */
.tear-reveal::before,
.tear-reveal::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 38px;
    z-index: 2;
    background:
        repeating-linear-gradient(0deg, rgba(212,197,176,0.12) 0 2px, rgba(212,197,176,0.05) 2px 4px),
        linear-gradient(180deg, rgba(139,115,85,0.85), rgba(43,31,23,0.65));
    box-shadow: 0 12px 24px rgba(0,0,0,0.6);
}
.tear-reveal::before {
    top: 0;
    clip-path: polygon(
        0% 0%, 6% 55%, 12% 25%, 18% 60%, 24% 30%, 30% 65%, 36% 35%, 42% 60%,
        48% 28%, 54% 62%, 60% 32%, 66% 58%, 72% 30%, 78% 64%, 84% 34%, 90% 58%, 96% 38%, 100% 55%,
        100% 100%, 0% 100%
    );
}
/* Bottom torn edge */
.tear-reveal::after {
    bottom: 0;
    transform: scaleY(-1);
    clip-path: polygon(
        0% 0%, 6% 55%, 12% 25%, 18% 60%, 24% 30%, 30% 65%, 36% 35%, 42% 60%,
        48% 28%, 54% 62%, 60% 32%, 66% 58%, 72% 30%, 78% 64%, 84% 34%, 90% 58%, 96% 38%, 100% 55%,
        100% 100%, 0% 100%
    );
}

/* Section banner/header in parchment tone */
.section-banner {
    background: linear-gradient(
        to bottom,
        rgba(212, 197, 176, 0.12),
        rgba(26, 20, 16, 0.35)
    );
    border: 1px solid var(--dark-red);
    padding: 0.6rem;
    margin: 1.5rem 0 2rem 0;
    box-shadow: 0 10px 24px rgba(0,0,0,0.55);
    text-align: center;
}
.section-banner .banner-img {
    display: block;
    margin: 0 auto;
    width: auto;
    max-width: min(100%, 1100px);
    height: auto;
    max-height: clamp(220px, 34vw, 560px);
    background: #2b1f17;
    border: 1px solid rgba(139,0,0,0.5);
}

/* Decorative Page Border */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 20px solid transparent;
    border-image: linear-gradient(
        135deg,
        var(--dark-red) 0%,
        var(--blackish-red) 25%,
        var(--blood-red) 50%,
        var(--blackish-red) 75%,
        var(--dark-red) 100%
    ) 20;
    pointer-events: none;
    z-index: 9999;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.8);
}

/* Gothic Header */
.header {
    background: linear-gradient(to bottom, var(--blackish-red), var(--blood-red));
    border-bottom: 4px double var(--dark-red);
    padding: 2rem 3rem;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.9);
    text-align: center;
}

.header::before {
    content: '⸸';
    position: absolute;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.5rem;
    color: var(--dark-red);
    opacity: 0.5;
}

.header::after {
    content: '⸸';
    position: absolute;
    right: 2rem;
    top: 50%;
    transform: translateY(-50%) scaleX(-1);
    font-size: 2.5rem;
    color: var(--dark-red);
    opacity: 0.5;
}

.header-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: 3rem;
    font-weight: 700;
    color: var(--bone-white);
    text-shadow:
        2px 2px 4px var(--shadow-black),
        0 0 20px rgba(139, 0, 0, 0.5);
    letter-spacing: 0.15em;
    margin-bottom: 0.5rem;
}

.header-subtitle {
    font-family: 'Libre Baskerville', serif;
    color: var(--aged-gold);
    font-size: 0.95rem;
    font-style: italic;
    letter-spacing: 0.25em;
    text-transform: uppercase;
}

/* Container Layout */
.container {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: calc(100vh - 160px);
    margin: 0 20px 0 20px;
    max-height: calc(100vh - 160px);
    overflow: visible;
}

/* Gothic Sidebar */
.sidebar {
    background: transparent;
    border-right: 4px double var(--dark-red);
    padding: 2rem 1.5rem 3rem 1.5rem;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.8);
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 160px);
    /* Ensure scrollbar is visible and functional */
    scrollbar-width: thin;
    scrollbar-color: var(--blood-red) var(--shadow-black);
    --scroll-indicator-opacity: 0.8;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: none;
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}

/* Scroll indicator at bottom of sidebar */
.sidebar::after {
    content: '▼ Scroll for more ▼';
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    display: block;
    padding: 1rem;
    background: linear-gradient(to top, rgba(26, 20, 16, 1) 0%, rgba(26, 20, 16, 0.9) 50%, transparent 100%);
    text-align: center;
    font-size: 0.75rem;
    color: var(--aged-gold);
    opacity: var(--scroll-indicator-opacity, 0.8);
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.nav-section {
    margin-bottom: 2.5rem;
    position: relative;
    border-bottom: 1px solid var(--blood-red);
    padding-bottom: 1.5rem;
    z-index: 1;
}

.nav-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.nav-title {
    font-family: 'Cinzel Decorative', serif;
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 1rem;
    color: var(--dark-red);
    letter-spacing: 0.15em;
    text-align: center;
    text-shadow: 1px 1px 2px var(--shadow-black);
    position: relative;
}

.nav-title::after {
    content: '';
    display: block;
    width: 60%;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--dark-red), transparent);
    margin: 0.5rem auto 0;
}

.nav-link {
    display: block;
    color: var(--bone-white);
    text-decoration: none;
    padding: 0.6rem 0.75rem;
    font-size: 0.875rem;
    border-left: 3px solid transparent;
    padding-left: 1rem;
    margin-bottom: 0.35rem;
    transition: all 0.3s ease;
    position: relative;
    font-family: 'Crimson Pro', serif;
}

.nav-link::before {
    content: '›';
    font-family: 'Libre Baskerville', 'Crimson Pro', Georgia, serif;
    position: absolute;
    left: 0.25rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    color: var(--dark-red);
    font-size: 1.2em;
    font-weight: bold;
}

.nav-link:hover {
    border-left-color: var(--dark-red);
    color: var(--aged-gold);
    padding-left: 1.25rem;
}

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

.nav-link.active {
    border-left-color: var(--bone-white);
    font-weight: 700;
    background: rgba(75, 14, 14, 0.2);
}

/* Main Content Area */
.content {
    padding: 3rem 3rem 0 80px; /* 100px offset from left border + 20px padding, no bottom padding to prevent gap */
    background: linear-gradient(to bottom,
        rgba(26, 20, 16, 0.85),
        rgba(10, 6, 4, 0.9)
    );
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
    position: relative;
    width: 100%;
    box-sizing: border-box;
    overflow-y: auto;
    max-height: calc(100vh - 160px);
}

.content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--leather-texture);
    opacity: 0.2;
    pointer-events: none;
}

.breadcrumb {
    font-family: 'Crimson Pro', serif;
    font-size: 0.85rem;
    color: var(--aged-gold);
    margin-bottom: 2rem;
    font-style: italic;
    position: relative;
    z-index: 1;
}

.breadcrumb a {
    color: var(--bone-white);
    text-decoration: none;
    border-bottom: 1px dotted var(--aged-gold);
}

.breadcrumb a:hover {
    color: var(--dark-red);
    border-bottom-color: var(--dark-red);
}

/* Typography - Gothic Manuscript Style */
.content h1 {
    font-family: 'Cinzel Decorative', serif;
    font-size: 2.75rem;
    margin-bottom: 1.5rem;
    color: var(--bone-white);
    border-bottom: 3px double var(--dark-red);
    padding-bottom: 1rem;
    text-align: center;
    text-shadow: 2px 2px 4px var(--shadow-black);
    letter-spacing: 0.08em;
    position: relative;
    z-index: 1;
}

.content h1::first-letter {
    font-size: 3.5rem;
    color: var(--dark-red);
    float: none;
    line-height: normal;
    margin-right: 0;
    text-shadow: 3px 3px 6px var(--shadow-black);
}

.content h2 {
    font-family: 'Cinzel Decorative', serif;
    font-size: 2rem;
    margin-top: 3rem;
    margin-bottom: 1.25rem;
    color: var(--dark-red);
    text-shadow: 1px 1px 2px var(--shadow-black);
    border-left: 6px solid var(--blood-red);
    padding-left: 1.5rem;
    letter-spacing: 0.08em;
    position: relative;
    z-index: 1;
}

.content h3 {
    font-family: 'Crimson Pro', serif;
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--aged-gold);
    font-weight: 600;
    font-style: italic;
    position: relative;
    z-index: 1;
}

.content p {
    margin-bottom: 1.25rem;
    color: var(--bone-white);
    text-align: justify;
    hyphens: auto;
    position: relative;
    z-index: 1;
}

.content p:first-of-type::first-letter {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--dark-red);
    float: left;
    line-height: 0.85;
    margin-right: 0.05em;
    margin-top: 0.1em;
    font-family: 'Cinzel Decorative', serif;
}

/* Lists with Gothic Style */
.content ul,
.content ol {
    margin-left: 2.5rem;
    margin-bottom: 1.5rem;
    color: var(--bone-white);
    position: relative;
    z-index: 1;
}

.content li {
    margin-bottom: 0.75rem;
    line-height: 1.8;
}

.content li::marker {
    color: var(--dark-red);
}

/* Gothic Tables */
.content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2.5rem 0;
    background: rgba(10, 6, 4, 0.8);
    border: 2px solid var(--blood-red);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
    position: relative;
    z-index: 1;
}

.content th,
.content td {
    border: 1px solid var(--dark-red);
    padding: 1rem;
    text-align: left;
}

.content th {
    background: linear-gradient(to bottom, var(--blood-red), var(--blackish-red));
    font-family: 'Cinzel Decorative', serif;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: var(--bone-white);
    letter-spacing: 0.08em;
    text-shadow: 1px 1px 2px var(--shadow-black);
}

.content tr:nth-child(even) {
    background: rgba(43, 31, 23, 0.3);
}

.content tr:hover {
    background: rgba(75, 14, 14, 0.2);
}

/* Links - Illuminated Style */
.content a {
    color: var(--aged-gold);
    text-decoration: none;
    border-bottom: 1px dotted var(--aged-gold);
    transition: all 0.3s ease;
}

.content a:hover {
    color: var(--dark-red);
    border-bottom: 1px solid var(--dark-red);
    text-shadow: 0 0 8px rgba(139, 0, 0, 0.5);
}

/* Code Blocks - Grimoire Style */
.content code {
    background: rgba(10, 6, 4, 0.9);
    border: 1px solid var(--blood-red);
    padding: 0.25rem 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: var(--aged-gold);
}

.content pre {
    background: rgba(10, 6, 4, 0.95);
    border: 2px solid var(--blood-red);
    border-left: 6px solid var(--dark-red);
    padding: 1.5rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.8);
}

/* Special Callout Boxes - Illuminated Manuscript Style */
.content > div[style*="background"] {
    background: linear-gradient(135deg,
        rgba(75, 14, 14, 0.4),
        rgba(45, 10, 10, 0.6)
    ) !important;
    border: 2px solid var(--blood-red) !important;
    border-left: 8px solid var(--dark-red) !important;
    padding: 2rem !important;
    margin: 2.5rem 0 !important;
    box-shadow: 0 6px 30px rgba(0, 0, 0, 0.9);
    position: relative;
    z-index: 1;
}

.content > div[style*="background"]::before {
    content: 'ü';
    font-family: 'Wingdings', 'Webdings', sans-serif;
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    color: var(--dark-red);
    opacity: 0.3;
}

/* Playtest Ready Box - Special Styling */
.content > div[style*="border-left: 4px solid"] h2:first-child {
    font-family: 'Cinzel Decorative', serif !important;
    color: var(--dark-red) !important;
    text-shadow: 0 0 10px rgba(139, 0, 0, 0.5);
    letter-spacing: 0.08em;
}

/* Quote Blocks - Medieval Manuscript Style */
.content > div[style*="font-style: italic"] {
    background: rgba(10, 6, 4, 0.9) !important;
    border: 3px double var(--dark-red) !important;
    padding: 2rem !important;
    text-align: center !important;
    font-family: 'Libre Baskerville', serif !important;
    font-size: 1.1rem !important;
    color: var(--aged-gold) !important;
    letter-spacing: 0.03em;
    position: relative;
    z-index: 1;
}

.content > div[style*="font-style: italic"]::before {
    content: '"';
    position: absolute;
    top: -0.5rem;
    left: 1rem;
    font-size: 6rem;
    color: var(--blood-red);
    opacity: 0.2;
    font-family: 'Cinzel Decorative', serif;
}

/* Manuscript Quote - No drop cap for quotes */
.manuscript-quote {
    background: rgba(10, 6, 4, 0.9) !important;
    border: 3px double var(--dark-red) !important;
    padding: 2rem !important;
    text-align: center !important;
    font-family: 'Libre Baskerville', serif !important;
    font-size: 1.1rem !important;
    color: var(--aged-gold) !important;
    letter-spacing: 0.03em;
    margin: 2.5rem 0;
    position: relative;
    z-index: 1;
}

.manuscript-quote::before {
    content: '"';
    position: absolute;
    top: -0.5rem;
    left: 1rem;
    font-size: 6rem;
    color: var(--blood-red);
    opacity: 0.2;
    font-family: 'Cinzel Decorative', serif;
}

/* Prevent drop-cap on quotes and centered text */
.manuscript-quote::first-letter,
.manuscript-quote p::first-letter,
.no-drop-cap::first-letter,
p.no-drop-cap::first-letter {
    font-size: inherit !important;
    font-weight: inherit !important;
    color: inherit !important;
    float: none !important;
    line-height: inherit !important;
    margin-right: 0 !important;
    margin-top: 0 !important;
}

.quote-attribution {
    display: block;
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--bone-white);
    font-style: italic;
}

/* Mobile Responsiveness */
@media (max-width: 968px) {
    body::before {
        border-width: 10px;
    }

    .container {
        grid-template-columns: 1fr;
        margin: 0 10px 0 10px;
        max-height: none;
    }

    /* Note: Sidebar mobile styles are handled in index.html for overlay behavior */
    /* Only apply these styles to non-overlay sidebars (e.g., in iframe pages) */
    body:not(.has-mobile-menu) .sidebar {
        border-right: none;
        border-bottom: 4px double var(--dark-red);
        max-height: none;
        overflow-y: visible;
        padding: 1.5rem 1rem 2rem 1rem;
    }

    .content {
        padding: 1.75rem 1.25rem;
        max-height: none;
        overflow-y: visible;
    }

    .header-title {
        font-size: 2rem;
    }

    .content h1 {
        font-size: 2rem;
        padding-bottom: 0.75rem;
    }

    .content h2 {
        font-size: 1.5rem;
        margin-top: 2.5rem;
        margin-bottom: 1rem;
        padding-left: 1.25rem;
    }

    /* Better table handling on mobile */
    .content table {
        font-size: 0.85rem;
    }

    .content th,
    .content td {
        padding: 0.65rem 0.4rem;
    }
}

/* Tablet Breakpoint */
@media (max-width: 1200px) and (min-width: 969px) {
    .container {
        grid-template-columns: 250px 1fr;
        margin: 0 15px 0 15px;
        max-height: calc(100vh - 140px);
    }

    .sidebar {
        max-height: calc(100vh - 140px);
    }

    .content {
        padding: 2.5rem 3rem;
        max-height: calc(100vh - 140px);
    }
}

/* Small Mobile Devices */
@media (max-width: 600px) {
    body::before {
        border-width: 5px;
    }

    .header {
        padding: 1.25rem 0.75rem;
    }

    .header-title {
        font-size: 1.5rem;
        letter-spacing: 0.1em;
    }

    .header-subtitle {
        font-size: 0.7rem;
        letter-spacing: 0.15em;
    }

    .header::before,
    .header::after {
        font-size: 1.5rem;
        left: 0.5rem;
        right: 0.5rem;
    }

    .sidebar {
        padding: 1.25rem 0.75rem 1.5rem 0.75rem;
    }

    .content {
        padding: 1.25rem 0.85rem;
    }

    .content h1 {
        font-size: 1.65rem;
        padding-bottom: 0.6rem;
    }

    .content h2 {
        font-size: 1.2rem;
        padding-left: 0.85rem;
        margin-top: 2rem;
    }

    .content h3 {
        font-size: 1.1rem;
    }

    .content p {
        text-align: left;
        hyphens: none;
    }

    /* Stack tables on very small screens */
    .content table {
        font-size: 0.75rem;
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .content th,
    .content td {
        padding: 0.45rem 0.35rem;
        font-size: 0.7rem;
    }

    /* Adjust navigation */
    .nav-section {
        margin-bottom: 1.25rem;
        padding-bottom: 0.85rem;
    }

    .nav-title {
        font-size: 0.8rem;
    }

    .nav-link {
        font-size: 0.75rem;
        padding: 0.45rem 0.5rem;
    }
}

/* Scrollbar Styling - Gothic */
::-webkit-scrollbar {
    width: 14px;
    background: var(--shadow-black);
}

::-webkit-scrollbar-track {
    background: linear-gradient(to bottom, var(--leather-brown), var(--parchment-dark));
    border: 1px solid var(--blood-red);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, var(--blood-red), var(--blackish-red));
    border: 1px solid var(--dark-red);
    border-radius: 2px;
    min-height: 40px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--dark-red);
    cursor: pointer;
}

/* Specific scrollbar for sidebar to make it more prominent */
.sidebar::-webkit-scrollbar {
    width: 16px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(to bottom, var(--dark-red), var(--blood-red));
    border: 2px solid var(--aged-gold);
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--aged-gold);
}

/* Selection Styling */
::selection {
    background: var(--blood-red);
    color: var(--bone-white);
}

::-moz-selection {
    background: var(--blood-red);
    color: var(--bone-white);
}

/* Manuscript Page Styles (for faction pages in iframe) */
.manuscript-page {
    padding: 3rem 3rem 3rem 50px; /* 30px offset from border + 20px padding */
    width: 100%;
    box-sizing: border-box;
    background: linear-gradient(to bottom,
        rgba(26, 20, 16, 0.85),
        rgba(10, 6, 4, 0.9)
    );
    min-height: 100vh;
    position: relative;
}

/* Ensure iframe content can scroll properly */
html, body {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
}

/* Ensure iframe body doesn't restrict height or create gaps */
iframe body {
    min-height: 100vh !important;
    height: auto !important;
    overflow-y: visible !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Remove any bottom spacing in content divs within iframes */
.content {
    margin-bottom: 0 !important;
}

.content > *:last-child {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Ensure last elements don't have excess bottom spacing */
.content > div:last-child,
.content > p:last-child,
.content > table:last-child,
.content > ul:last-child,
.content > ol:last-child,
.content > h1:last-child,
.content > h2:last-child,
.content > h3:last-child {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

.manuscript-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--leather-texture);
    opacity: 0.2;
    pointer-events: none;
}

.illuminated-header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    z-index: 1;
}

.illuminated-header .drop-cap {
    font-family: 'Cinzel Decorative', serif;
    font-size: 6rem;
    color: var(--dark-red);
    text-shadow: 3px 3px 6px var(--shadow-black);
    display: inline-block;
    vertical-align: top;
    line-height: 1;
    margin-right: -0.1em;
}

.illuminated-header .title {
    font-family: 'Cinzel Decorative', serif;
    font-size: 3rem;
    color: var(--bone-white);
    text-shadow: 2px 2px 4px var(--shadow-black);
    letter-spacing: 0.08em;
    display: inline;
    margin: 0;
    border: none;
    padding: 0;
}

.illuminated-header .subtitle {
    font-family: 'Libre Baskerville', serif;
    font-size: 1.1rem;
    color: var(--aged-gold);
    font-style: italic;
    margin-top: 1rem;
    letter-spacing: 0.05em;
}

.manuscript-text {
    margin-bottom: 1.25rem;
    color: var(--bone-white);
    text-align: justify;
    hyphens: auto;
    position: relative;
    z-index: 1;
    line-height: 1.75;
}

.manuscript-list {
    margin-left: 2.5rem;
    margin-bottom: 1.5rem;
    color: var(--bone-white);
    position: relative;
    z-index: 1;
}

.manuscript-list li {
    margin-bottom: 0.75rem;
    line-height: 1.8;
}

.manuscript-list li::marker {
    color: var(--dark-red);
}

.manuscript-table {
    width: 100%;
    border-collapse: collapse;
    margin: 2.5rem 0;
    background: rgba(10, 6, 4, 0.8);
    border: 2px solid var(--blood-red);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
    position: relative;
    z-index: 1;
}

.manuscript-table th,
.manuscript-table td {
    border: 1px solid var(--dark-red);
    padding: 1rem;
    text-align: left;
}

.manuscript-table th {
    background: linear-gradient(to bottom, var(--blood-red), var(--blackish-red));
    font-family: 'Cinzel Decorative', serif;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    color: var(--bone-white);
    letter-spacing: 0.08em;
    text-shadow: 1px 1px 2px var(--shadow-black);
}

.manuscript-table thead th {
    background: linear-gradient(to bottom, var(--blood-red), var(--blackish-red));
}

.manuscript-table tr:nth-child(even) {
    background: rgba(43, 31, 23, 0.3);
}

.manuscript-table tr:hover {
    background: rgba(75, 14, 14, 0.2);
}

.ornamental-break {
    text-align: center;
    font-size: 1.5rem;
    color: var(--dark-red);
    margin: 2rem 0;
    position: relative;
    z-index: 1;
    letter-spacing: 1rem;
}

.manuscript-footer {
    text-align: center;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 3px double var(--dark-red);
    color: var(--aged-gold);
    font-size: 0.9rem;
    position: relative;
    z-index: 1;
}

.manuscript-footer a {
    color: var(--bone-white);
    text-decoration: none;
    border-bottom: 1px dotted var(--aged-gold);
}

.manuscript-footer a:hover {
    color: var(--dark-red);
    border-bottom-color: var(--dark-red);
}

/* Mobile adjustments for manuscript pages */
@media (max-width: 968px) {
    .manuscript-page {
        padding: 2rem 1.5rem 2rem 50px; /* Reduced offset on mobile */
    }
}

@media (max-width: 600px) {
    .manuscript-page {
        padding: 1.5rem 1rem 1.5rem 30px; /* Minimal offset on small screens */
    }

    .illuminated-header .drop-cap {
        font-size: 4rem;
    }

    .illuminated-header .title {
        font-size: 2rem;
    }

    .illuminated-header .subtitle {
        font-size: 0.95rem;
    }
}

/* Remove borders from images */
img {
    border: none !important;
    box-shadow: none !important;
}

/* Falling ash/dust particles effect - fixed to viewport */
.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    background: radial-gradient(circle, rgba(212, 197, 176, 0.4) 0%, rgba(212, 197, 176, 0) 70%);
    border-radius: 50%;
    animation: falling-ash linear infinite;
    opacity: 0;
}

@keyframes falling-ash {
    0% {
        transform: translateY(-10vh) translateX(0) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    90% {
        opacity: 0.3;
    }
    100% {
        transform: translateY(110vh) translateX(var(--drift)) rotate(360deg);
        opacity: 0;
    }
}

/* Generate random particles with different sizes and speeds - falling downward */
.particle:nth-child(1) { left: 5%; width: 2px; height: 2px; animation-duration: 15s; animation-delay: 0s; --drift: -20px; }
.particle:nth-child(2) { left: 15%; width: 3px; height: 3px; animation-duration: 20s; animation-delay: 2s; --drift: 30px; }
.particle:nth-child(3) { left: 25%; width: 1px; height: 1px; animation-duration: 12s; animation-delay: 4s; --drift: -15px; }
.particle:nth-child(4) { left: 35%; width: 4px; height: 4px; animation-duration: 25s; animation-delay: 1s; --drift: 40px; }
.particle:nth-child(5) { left: 45%; width: 2px; height: 2px; animation-duration: 18s; animation-delay: 3s; --drift: -25px; }
.particle:nth-child(6) { left: 55%; width: 3px; height: 3px; animation-duration: 22s; animation-delay: 5s; --drift: 35px; }
.particle:nth-child(7) { left: 65%; width: 1px; height: 1px; animation-duration: 14s; animation-delay: 2s; --drift: -30px; }
.particle:nth-child(8) { left: 75%; width: 5px; height: 5px; animation-duration: 28s; animation-delay: 0s; --drift: 45px; }
.particle:nth-child(9) { left: 85%; width: 2px; height: 2px; animation-duration: 16s; animation-delay: 4s; --drift: -20px; }
.particle:nth-child(10) { left: 95%; width: 3px; height: 3px; animation-duration: 19s; animation-delay: 1s; --drift: 25px; }
.particle:nth-child(11) { left: 10%; width: 4px; height: 4px; animation-duration: 24s; animation-delay: 6s; --drift: -35px; }
.particle:nth-child(12) { left: 20%; width: 1px; height: 1px; animation-duration: 13s; animation-delay: 3s; --drift: 20px; }
.particle:nth-child(13) { left: 30%; width: 3px; height: 3px; animation-duration: 21s; animation-delay: 5s; --drift: -40px; }
.particle:nth-child(14) { left: 40%; width: 2px; height: 2px; animation-duration: 17s; animation-delay: 2s; --drift: 30px; }
.particle:nth-child(15) { left: 50%; width: 4px; height: 4px; animation-duration: 23s; animation-delay: 0s; --drift: -25px; }
.particle:nth-child(16) { left: 60%; width: 1px; height: 1px; animation-duration: 11s; animation-delay: 4s; --drift: 35px; }
.particle:nth-child(17) { left: 70%; width: 3px; height: 3px; animation-duration: 26s; animation-delay: 1s; --drift: -30px; }
.particle:nth-child(18) { left: 80%; width: 2px; height: 2px; animation-duration: 15s; animation-delay: 3s; --drift: 40px; }
.particle:nth-child(19) { left: 90%; width: 5px; height: 5px; animation-duration: 27s; animation-delay: 5s; --drift: -45px; }
.particle:nth-child(20) { left: 8%; width: 2px; height: 2px; animation-duration: 20s; animation-delay: 2s; --drift: 25px; }
