/* judge.quest - Dark-Academia Manuscript */

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

html { scroll-behavior: smooth; }

body {
    background: #1A1410;
    color: #3D2B1F;
    font-family: 'Crimson Text', serif;
    font-weight: 400;
    font-size: 17px;
    line-height: 1.8;
    overflow-x: hidden;
}

/* Candle Glow Overlay (opening) */
#candle-glow-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(ellipse at 50% 50%, rgba(184, 134, 11, 0.05) 0%, transparent 50%);
    z-index: 5;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.2);
    transition: opacity 2s ease, transform 2s ease;
}

#candle-glow-overlay.active {
    opacity: 1;
    transform: scale(1);
}

/* Ambient Candle Flicker */
#ambient-flicker {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(ellipse at 50% 30%, rgba(184, 134, 11, 0.03) 0%, transparent 60%);
    z-index: 1;
    pointer-events: none;
    animation: candleFlicker 4s ease-in-out infinite alternate;
}

@keyframes candleFlicker {
    0% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
    100% { opacity: 0.7; transform: scale(0.98); }
}

/* Sidebar */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 200px;
    height: 100%;
    z-index: 50;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(60, 40, 20, 0.4) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(50, 30, 15, 0.3) 0%, transparent 50%),
        linear-gradient(180deg, #1A1410 0%, #1E1814 50%, #1A1410 100%);
    border-right: 1px solid rgba(139, 115, 85, 0.2);
    padding: 40px 16px;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 800ms ease, transform 800ms ease;
}

#sidebar.visible {
    opacity: 1;
    transform: translateX(0);
}

.sidebar-title {
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-size: 16px;
    color: #7A6B5A;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(139, 115, 85, 0.2);
}

#toc {
    list-style: none;
}

.toc-entry {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 4px;
    cursor: pointer;
    position: relative;
    transition: color 200ms ease;
}

.toc-entry:hover {
    color: #B8860B;
}

.manicule-container {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    opacity: 0;
    transform: translateX(-8px);
    transition: opacity 200ms ease, transform 200ms ease;
}

.toc-entry:hover .manicule-container,
.toc-entry.active .manicule-container {
    opacity: 1;
    transform: translateX(0);
}

.manicule {
    display: block;
}

.toc-text {
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-size: 14px;
    color: #7A6B5A;
    flex-shrink: 0;
    transition: color 200ms ease;
}

.toc-entry:hover .toc-text,
.toc-entry.active .toc-text {
    color: #B8860B;
}

.toc-dots {
    flex: 1;
    border-bottom: 1px dotted rgba(139, 115, 85, 0.3);
    margin: 0 4px;
    min-width: 8px;
}

.toc-numeral {
    font-family: 'EB Garamond', serif;
    font-weight: 500;
    font-style: italic;
    font-size: 14px;
    color: #7A6B5A;
    flex-shrink: 0;
}

.toc-check {
    font-size: 12px;
    color: #B8860B;
    opacity: 0;
    transition: opacity 200ms ease;
    margin-left: 4px;
    flex-shrink: 0;
}

.toc-entry.completed .toc-check {
    opacity: 1;
}

/* Main Content */
#main-content {
    margin-left: 200px;
    padding: 60px 40px 80px;
    max-width: calc(640px + 200px + 80px);
    position: relative;
    z-index: 10;
}

/* Manuscript Pages */
.manuscript-page {
    background: #EDE4D0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    padding: 48px;
    margin-bottom: 0;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 800ms ease-out, transform 800ms ease-out, box-shadow 300ms ease;
}

.manuscript-page.revealed {
    opacity: 1;
    transform: translateY(0);
}

.manuscript-page:hover {
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.page-inner-border {
    border: 1px solid rgba(139, 115, 85, 0.4);
    padding: 32px;
}

/* Title Page */
.title-page .title {
    font-family: 'EB Garamond', serif;
    font-weight: 500;
    font-style: italic;
    font-size: 48px;
    color: #2C1810;
    letter-spacing: 0.02em;
    text-align: center;
    margin-bottom: 16px;
}

.subtitle {
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-size: 18px;
    color: #7A6B5A;
    text-align: center;
    margin-bottom: 24px;
}

.ornamental-divider {
    text-align: center;
}

/* Illuminated Initial / Drop Cap */
.drop-cap {
    float: left;
    font-family: 'EB Garamond', serif;
    font-weight: 500;
    font-size: 72px;
    line-height: 0.85;
    color: #B8860B;
    margin-right: 12px;
    margin-top: 4px;
    padding: 4px 8px;
    border: 1px solid #8B7355;
    position: relative;
}

.drop-cap:hover {
    animation: candlePulse 600ms ease-in-out;
}

@keyframes candlePulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Section Elements */
.section-numeral {
    font-family: 'EB Garamond', serif;
    font-weight: 500;
    font-style: italic;
    font-size: 28px;
    color: #B8860B;
    text-align: center;
    margin-bottom: 12px;
    letter-spacing: 0.1em;
}

.section-heading {
    font-family: 'EB Garamond', serif;
    font-weight: 500;
    font-style: italic;
    font-size: 28px;
    color: #2C1810;
    letter-spacing: 0.02em;
    margin-bottom: 16px;
    line-height: 1.3;
}

.manuscript-page p {
    color: #3D2B1F;
    margin-bottom: 16px;
}

.manuscript-page p:last-child {
    margin-bottom: 0;
}

.marginalia-note {
    font-family: 'IM Fell English', serif;
    font-style: italic;
    font-size: 14px;
    color: #7A6B5A;
    border-left: 2px solid rgba(139, 115, 85, 0.3);
    padding-left: 16px;
    margin-top: 24px;
}

/* Dark Gaps */
.dark-gap {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.gap-numeral {
    font-family: 'EB Garamond', serif;
    font-weight: 500;
    font-style: italic;
    font-size: 36px;
    color: rgba(184, 134, 11, 0.15);
    opacity: 0;
    transition: opacity 600ms ease;
}

.gap-numeral.visible {
    opacity: 1;
}

/* Wax Seal */
#wax-seal {
    text-align: center;
    padding: 60px 0;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 600ms ease, transform 600ms ease;
}

#wax-seal.revealed {
    opacity: 1;
    transform: scale(1);
}

/* Responsive */
@media (max-width: 768px) {
    #sidebar {
        display: none;
    }

    #main-content {
        margin-left: 0;
        padding: 24px 16px 60px;
        max-width: 100%;
    }

    .manuscript-page {
        padding: 24px;
    }

    .page-inner-border {
        padding: 16px;
    }

    .title-page .title {
        font-size: 36px;
    }

    .section-heading {
        font-size: 24px;
    }

    .drop-cap {
        font-size: 56px;
    }

    .dark-gap {
        height: 80px;
    }
}
