/* ============================================
   gabs.wiki - Dark Academia Reading Room
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --bg-primary: #1a1118;
    --bg-secondary: #2d1f2b;
    --bg-tertiary: #3d2a38;
    --text-primary: #e8dfd4;
    --text-secondary: #9b8a7a;
    --accent-gold: #c9a84c;
    --accent-warm: #a6583c;
    --highlight: #f4e8c1;
    --border-accent: #5c4350;
    --text-heading-h1: #f0e6d6;
    --text-heading-h2: #c9a84c;
    --mono-color: #8a7b6c;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 17px;
    line-height: 1.8;
    font-weight: 400;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Paper Texture Overlay --- */
#paper-texture {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.03;
}

#paper-texture::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* --- Candle Glow Effect --- */
#candle-glow {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 800px;
    height: 800px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(201, 168, 76, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: 999;
    will-change: transform;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Playfair Display', Georgia, serif;
}

h1 {
    font-size: 56px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--text-heading-h1);
    letter-spacing: 0.04em;
}

h2 {
    font-size: 28px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-heading-h2);
}

h3 {
    font-size: 21px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-heading-h2);
}

/* --- Chapters / Sections --- */
.chapter {
    position: relative;
}

/* --- Section Dividers --- */
.section-divider {
    display: flex;
    justify-content: center;
    padding: 40px 0;
}

.divider-line {
    width: 100%;
    max-width: 600px;
    height: 20px;
}

/* ============================================
   CHAPTER I: The Archive Opens (Frontispiece)
   ============================================ */
.frontispiece {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-primary);
    position: relative;
}

.frontispiece-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 640px;
    padding: 20px;
}

.cartouche-border {
    width: 100%;
    height: auto;
    max-width: 600px;
}

/* SVG path-draw animation */
.cartouche-draw {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: draw-cartouche 2.5s ease-in-out forwards;
    animation-delay: 0.5s;
}

.corner-ornament {
    stroke-dasharray: 60;
    stroke-dashoffset: 60;
    animation: draw-corner 1s ease-in-out forwards;
    animation-delay: 1.5s;
}

.vine-detail {
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: draw-vine 1.2s ease-in-out forwards;
    animation-delay: 2s;
}

@keyframes draw-cartouche {
    to { stroke-dashoffset: 0; }
}

@keyframes draw-corner {
    to { stroke-dashoffset: 0; }
}

@keyframes draw-vine {
    to { stroke-dashoffset: 0; }
}

/* Frontispiece text */
.frontispiece-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 2;
}

.site-title {
    opacity: 0;
    animation: fade-in 800ms ease-in-out forwards;
    animation-delay: 2.8s;
}

.site-subtitle {
    font-family: 'Crimson Pro', Georgia, serif;
    font-style: italic;
    font-weight: 400;
    font-size: 20px;
    color: var(--text-secondary);
    opacity: 0;
    animation: fade-in 800ms ease-in-out forwards;
    animation-delay: 3.1s;
    margin-top: 12px;
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Scroll indicator */
.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: fade-in 600ms ease-in-out forwards;
    animation-delay: 3.8s;
}

.manicule-down {
    animation: pulse-manicule 2s ease-in-out infinite;
    animation-delay: 4s;
}

@keyframes pulse-manicule {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ============================================
   CHAPTER II: The Reading Room
   ============================================ */
.reading-room {
    background-color: var(--bg-primary);
    padding: 0 20px 80px;
}

.two-column-layout {
    display: grid;
    grid-template-columns: 62% 38%;
    gap: 40px;
    max-width: 1100px;
    margin: 0 auto;
}

.main-column {
    padding-right: 20px;
}

.chapter-heading {
    margin-bottom: 40px;
}

.chapter-number {
    font-family: 'DM Mono', monospace;
    font-size: 14px;
    font-weight: 400;
    color: var(--mono-color);
    margin-right: 8px;
    letter-spacing: 0.02em;
}

/* Text blocks */
.text-block {
    margin-bottom: 32px;
}

.text-block p {
    color: var(--text-primary);
}

/* Drop capital */
.drop-capital-wrapper {
    float: left;
    margin-right: 8px;
    margin-top: 4px;
}

.drop-capital {
    display: block;
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: 72px;
    line-height: 0.8;
    color: var(--text-heading-h1);
    background-color: var(--bg-secondary);
    padding: 8px 12px 4px;
    float: left;
    position: relative;
}

.drop-capital::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px solid var(--accent-gold);
    opacity: 0.3;
}

/* Marginalia Rail */
.marginalia-rail {
    border-left: 1px solid var(--bg-tertiary);
    padding-left: 24px;
    position: relative;
}

.annotation {
    margin-bottom: 40px;
    transition: opacity 400ms ease-out, transform 400ms ease-out;
}

.annotation.hidden {
    opacity: 0;
    transform: translateX(20px);
}

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

.annotation-icon {
    display: block;
    margin-bottom: 8px;
}

.annotation-text {
    font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    font-weight: 300;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.annotation-text em {
    font-style: italic;
}

/* ============================================
   CHAPTER III: The Index
   ============================================ */
.the-index {
    background-color: var(--bg-primary);
    padding: 0 20px 80px;
}

.index-container {
    max-width: 900px;
    margin: 0 auto;
}

.index-container .chapter-heading {
    text-align: center;
}

/* Catalog entries */
.catalog-entry {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    cursor: pointer;
    transition: background-color 200ms ease;
    border-bottom: 1px solid rgba(92, 67, 80, 0.3);
}

.catalog-entry:hover {
    background-color: var(--bg-secondary);
}

.catalog-entry:hover .entry-title {
    color: var(--accent-gold);
}

.catalog-entry:hover .fleuron-spin {
    transform: rotate(90deg);
}

.entry-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 600;
    font-size: 18px;
    color: var(--text-heading-h1);
    white-space: nowrap;
    transition: color 200ms ease;
    flex-shrink: 0;
}

.entry-rule {
    flex: 1;
    margin: 0 20px;
    min-width: 60px;
    display: flex;
    align-items: center;
}

.fleuron-rule {
    width: 100%;
    height: 12px;
}

.fleuron-spin {
    transition: transform 300ms ease-out;
    transform-origin: 100px 6px;
}

.entry-folio {
    font-family: 'DM Mono', monospace;
    font-weight: 400;
    font-size: 14px;
    color: var(--mono-color);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ============================================
   CHAPTER IV: The Annotations
   ============================================ */
.the-annotations {
    background-color: var(--bg-primary);
    padding: 0 20px 80px;
}

.annotations-container {
    max-width: 700px;
    margin: 0 auto;
}

.annotations-container .chapter-heading {
    text-align: center;
    margin-bottom: 60px;
}

/* Pull quote blocks */
.pull-quote-block {
    text-align: center;
    margin-bottom: 60px;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 600ms ease-in-out, transform 600ms ease-in-out;
}

.pull-quote-block.visible {
    opacity: 1;
    transform: translateY(0);
}

.quote-ornament {
    display: block;
    margin: 0 auto 20px;
}

.pull-quote-block blockquote {
    position: relative;
    padding: 24px 0;
    border-top: 1px solid var(--border-accent);
    border-bottom: 1px solid var(--border-accent);
}

.pull-quote-block blockquote p {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 400;
    font-style: italic;
    font-size: 22px;
    line-height: 1.7;
    color: var(--highlight);
}

/* ============================================
   CHAPTER V: The Colophon (Footer)
   ============================================ */
.the-colophon {
    background-color: var(--bg-primary);
    padding: 0 20px 80px;
    text-align: center;
}

.tailpiece {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 600ms ease-in-out, transform 600ms ease-in-out;
}

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

.tailpiece-ornament {
    display: block;
}

.colophon-text {
    text-align: center;
}

.colophon-text p {
    font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    font-weight: 400;
    font-size: 13px;
    line-height: 1.8;
    color: var(--text-secondary);
    font-variant: small-caps;
    text-transform: lowercase;
    letter-spacing: 0.12em;
}

/* ============================================
   Reveal-on-scroll (base state)
   ============================================ */
.reveal-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 600ms ease-in-out, transform 600ms ease-in-out;
}

.reveal-on-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ============================================
   Selection Styling
   ============================================ */
::selection {
    background-color: rgba(201, 168, 76, 0.3);
    color: var(--highlight);
}

/* ============================================
   Responsive: < 768px
   ============================================ */
@media (max-width: 768px) {
    h1 {
        font-size: 36px;
    }

    h2 {
        font-size: 24px;
    }

    .site-subtitle {
        font-size: 16px;
    }

    .frontispiece-inner {
        max-width: 340px;
    }

    .two-column-layout {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .main-column {
        padding-right: 0;
    }

    .marginalia-rail {
        border-left: none;
        border-top: 1px solid var(--bg-tertiary);
        padding-left: 0;
        padding-top: 24px;
        margin-top: 24px;
    }

    .annotation.hidden {
        transform: translateX(0);
    }

    .annotation {
        padding: 12px 16px;
        background-color: var(--bg-secondary);
        border-radius: 4px;
        margin-bottom: 16px;
        cursor: pointer;
    }

    .catalog-entry {
        padding: 12px 8px;
    }

    .entry-title {
        font-size: 15px;
    }

    .entry-rule {
        margin: 0 10px;
    }

    .pull-quote-block blockquote p {
        font-size: 18px;
    }

    .drop-capital {
        font-size: 52px;
    }

    .index-container,
    .annotations-container {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 28px;
        letter-spacing: 0.02em;
    }

    .frontispiece-inner {
        max-width: 280px;
    }

    .entry-rule {
        display: none;
    }

    .catalog-entry {
        justify-content: space-between;
    }
}
