/* freedom.study - Dark Academia Scholarly Reading Room */

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

:root {
    --dark-oak: #1C1410;
    --leather-dark: #241C14;
    --reading-surface: #2E2418;
    --candlelight: #C8A96E;
    --parchment-text: #C8B898;
    --aged-brass: #8B7A5E;
    --margin-note: #6B5D48;
    --spine-line: #3A2E20;
    --deep-library: #140E08;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: 1.1rem;
    line-height: 1.9;
    background-color: var(--deep-library);
    color: var(--parchment-text);
    overflow-x: hidden;
    transition: background-color 0.5s ease;
}

body.loaded {
    background-color: var(--dark-oak);
}

/* Candle Glow */
.candle-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse 50% 60% at 50% 30%, rgba(200,169,110,0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    transition: opacity 1.5s ease;
}

body.loaded .candle-glow {
    opacity: 1;
}

/* ==================== HERO ==================== */
#hero {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-content {
    text-align: center;
}

.hero-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.hero-freedom {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(3.5rem, 9vw, 7rem);
    color: var(--candlelight);
    letter-spacing: 0.04em;
    line-height: 1;
    opacity: 0;
}

.hero-freedom.revealed {
    opacity: 1;
}

.hero-freedom .char {
    display: inline-block;
    filter: blur(4px);
    opacity: 0;
    transition: filter 200ms ease, opacity 200ms ease;
}

.hero-freedom .char.clear {
    filter: blur(0);
    opacity: 1;
}

.ornamental-rule {
    width: 40vw;
    max-width: 400px;
}

.rule-svg {
    width: 100%;
    height: 20px;
    opacity: 0;
    transition: opacity 800ms ease;
}

body.loaded .rule-svg {
    opacity: 1;
}

.hero-study {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(2rem, 5vw, 4rem);
    color: var(--aged-brass);
    letter-spacing: 0.04em;
    line-height: 1;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 400ms ease, transform 400ms ease;
}

body.loaded .hero-study {
    opacity: 1;
    transform: translateY(0);
}

/* ==================== CHAPTER NAVIGATION ==================== */
#chapters {
    position: relative;
    z-index: 2;
    padding: 0 clamp(1rem, 4vw, 3rem);
    border-bottom: 1px solid var(--spine-line);
}

.chapter-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    white-space: nowrap;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.chapter-tabs::-webkit-scrollbar {
    display: none;
}

.tab {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    font-variant: small-caps;
    color: var(--aged-brass);
    background: var(--leather-dark);
    border: 1px solid var(--spine-line);
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    padding: 12px 24px;
    cursor: pointer;
    transition: background 200ms ease, border-top-color 200ms ease;
    flex-shrink: 0;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 200ms ease, transform 200ms ease, background 200ms ease;
}

.tab.visible {
    opacity: 1;
    transform: translateY(0);
}

.tab.active {
    background: var(--reading-surface);
    border-top: 2px solid var(--candlelight);
    margin-bottom: -1px;
}

.tab:hover {
    background: var(--reading-surface);
}

/* ==================== ESSAY BODY ==================== */
#essay {
    position: relative;
    z-index: 2;
    padding: clamp(3rem, 6vw, 6rem) 24px;
    background-image: repeating-linear-gradient(
        transparent 0,
        transparent calc(1.9 * 1.1rem - 1px),
        rgba(200, 169, 110, 0.03) calc(1.9 * 1.1rem - 1px),
        rgba(200, 169, 110, 0.03) calc(1.9 * 1.1rem)
    );
}

.essay-column {
    max-width: 680px;
    margin: 0 auto;
    position: relative;
}

.essay-section {
    margin-bottom: 4rem;
    position: relative;
}

.essay-heading {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: 1.5rem;
    color: var(--candlelight);
    margin-bottom: 1.5rem;
    line-height: 1.3;
    letter-spacing: 0.04em;
}

.essay-body {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: 1.1rem;
    line-height: 1.9;
    color: var(--parchment-text);
    margin-bottom: 1.5rem;
}

.drop-cap {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: 3.5rem;
    color: var(--candlelight);
    float: left;
    margin-right: 8px;
    line-height: 0.85;
    transform: scale(0.8);
    transition: transform 400ms ease;
}

.drop-cap.scaled {
    transform: scale(1);
}

.section-ornament {
    text-align: center;
    margin: 3rem 0;
    opacity: 0;
    transition: opacity 500ms ease;
}

.section-ornament.visible {
    opacity: 1;
}

/* Marginalia */
.marginalia {
    position: absolute;
    left: -220px;
    width: 180px;
    opacity: 0;
    transition: opacity 500ms ease;
}

.marginalia.right {
    left: auto;
    right: -220px;
}

.marginalia.visible {
    opacity: 1;
}

.margin-connector {
    position: absolute;
    right: -20px;
    top: 8px;
    width: 20px;
    height: 1px;
    background: var(--spine-line);
    opacity: 0.3;
}

.margin-connector.right {
    left: -20px;
    right: auto;
}

.margin-text {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-style: italic;
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--margin-note);
}

/* Marginalia collapse on narrow screens */
@media (max-width: 1100px) {
    .marginalia {
        position: static;
        width: 100%;
        padding: 0.75rem 1rem;
        margin-bottom: 1rem;
        border-left: 2px solid var(--spine-line);
        opacity: 1;
    }

    .marginalia.right {
        right: auto;
    }

    .margin-connector {
        display: none;
    }
}

/* ==================== FOOTER ==================== */
#footer {
    position: relative;
    z-index: 2;
    background: var(--deep-library);
    padding: 3rem 2rem;
}

.bookshelf {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    max-width: 600px;
    margin: 0 auto;
}

.spine {
    width: 1px;
    height: 40px;
    background: var(--spine-line);
    flex-shrink: 0;
}

.footer-text {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--aged-brass);
    padding: 0 2rem;
    white-space: nowrap;
}
