/* ==========================================================================
   miris.bar - Dark Academia Archive
   ========================================================================== */

/* --- CSS Custom Properties --- */
:root {
    /* Palette */
    --midnight-mahogany: #1a1209;
    --ink-well: #0d0a05;
    --aged-vellum: #f4ede1;
    --foxed-cream: #ede6d6;
    --tarnished-gold: #c4a265;
    --burnished-brass: #d4b87a;
    --lampblack: #1c1812;
    --faded-ink: #5c5347;
    --parchment-glow: #e8dcc8;
    --library-shadow: #1a1209;
    --candlelit-amber: #2e2212;
    --deep-oxblood: #2a1018;
    --sidebar-spine: #2a1f14;
    --crimson-thread: #8a3a3a;
    --cork-bg: #b8976a;
    --cork-noise: #8a6e4a;
    --push-pin-red: #cc3333;

    /* Typography */
    --font-mono: 'IBM Plex Mono', monospace;
    --font-serif: 'Cormorant Garamond', serif;
    --font-display: 'Playfair Display', serif;
}

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-mono);
    font-weight: 400;
    color: var(--lampblack);
    background-color: var(--ink-well);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* --- SVG Defs (hidden) --- */
.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* ==========================================================================
   Hero Section - Full Screen Narrative Entry
   ========================================================================== */

.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--ink-well);
    background-image: radial-gradient(ellipse at 30% 20%, var(--candlelit-amber) 0%, var(--midnight-mahogany) 40%, var(--deep-oxblood) 100%);
    background-size: 0% 0%;
    background-position: 30% 20%;
    background-repeat: no-repeat;
    animation: lampOn 1200ms 500ms ease-out forwards;
    overflow: hidden;
}

@keyframes lampOn {
    0% { background-size: 0% 0%; }
    100% { background-size: 300% 300%; }
}

.hero-content {
    text-align: center;
    z-index: 2;
}

.hero-title {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    color: var(--parchment-glow);
    opacity: 0;
    animation: fadeIn 800ms 700ms ease-out forwards;
    letter-spacing: -0.02em;
}

.hero-line {
    width: 0;
    height: 1px;
    background-color: var(--tarnished-gold);
    margin: 1.5rem auto;
    animation: drawLine 600ms 1100ms ease-out forwards;
}

@keyframes drawLine {
    0% { width: 0; }
    100% { width: 40vw; }
}

.hero-subtitle {
    font-family: var(--font-serif);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    color: var(--parchment-glow);
    opacity: 0;
    animation: fadeIn 800ms 1500ms ease-out forwards;
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* ==========================================================================
   Sidebar - Book Spine Navigation
   ========================================================================== */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 48px;
    height: 100vh;
    background: var(--sidebar-spine);
    background-image:
        linear-gradient(180deg, rgba(0,0,0,0.3) 0%, transparent 10%, transparent 90%, rgba(0,0,0,0.3) 100%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 20px,
            rgba(196,162,101,0.06) 20px,
            rgba(196,162,101,0.06) 21px
        );
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    border-right: 1px solid rgba(196,162,101,0.15);
    box-shadow: 2px 0 8px rgba(0,0,0,0.4);
}

.spine-marker {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 6px;
    position: relative;
    transition: transform 200ms ease;
}

.spine-marker:hover {
    transform: scaleX(1.3);
}

.marker-line {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--tarnished-gold);
    opacity: 0.5;
    border-radius: 1px;
    transition: opacity 400ms ease, background-color 400ms ease, box-shadow 400ms ease;
}

.spine-marker.active .marker-line {
    opacity: 1;
    background-color: var(--burnished-brass);
    box-shadow: 0 0 6px rgba(196,162,101,0.4);
    animation: markerPulse 2s ease-in-out infinite;
}

@keyframes markerPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.spine-marker.passed .marker-line {
    opacity: 0.85;
    background-color: var(--tarnished-gold);
}

/* ==========================================================================
   Desk Surface - Main Content Area
   ========================================================================== */

.desk-surface {
    position: relative;
    padding: 80px 48px 120px 72px;
    min-height: 100vh;
    background-color: var(--midnight-mahogany);
    background-image:
        radial-gradient(ellipse at 30% 20%, var(--candlelit-amber) 0%, var(--midnight-mahogany) 40%, var(--deep-oxblood) 100%),
        repeating-linear-gradient(
            0.5deg,
            transparent,
            transparent 3px,
            rgba(46,34,18,0.15) 3px,
            rgba(46,34,18,0.15) 4px
        );
}

/* ==========================================================================
   Folio Sheets - Primary Content Blocks
   ========================================================================== */

.folio-sheet {
    position: relative;
    background-color: var(--aged-vellum);
    padding: 3rem 3.5rem;
    margin-bottom: 100px;
    color: var(--lampblack);
    box-shadow:
        2px 2px 4px rgba(0,0,0,0.2),
        4px 4px 8px rgba(0,0,0,0.3),
        8px 8px 16px rgba(0,0,0,0.15);
    clip-path: polygon(
        0% 0.5%,
        2% 0%,
        15% 0.3%,
        30% 0%,
        48% 0.4%,
        65% 0%,
        80% 0.2%,
        98% 0%,
        100% 0.8%,
        99.8% 15%,
        100% 35%,
        99.6% 55%,
        100% 75%,
        99.8% 90%,
        100% 99%,
        98% 100%,
        82% 99.7%,
        65% 100%,
        48% 99.5%,
        30% 100%,
        15% 99.8%,
        2% 100%,
        0% 99.5%,
        0.2% 85%,
        0% 65%,
        0.3% 45%,
        0% 25%,
        0.2% 10%
    );
}

/* Stacked paper layers behind folio sheets */
.folio-sheet::before,
.folio-sheet::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -6px;
    right: -8px;
    bottom: -5px;
    background-color: var(--foxed-cream);
    z-index: -1;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.2);
    border-radius: 1px;
}

.folio-sheet::before {
    transform: rotate(1.2deg);
    opacity: 0.7;
    top: -6px;
    left: -10px;
    right: -4px;
    bottom: -8px;
}

.folio-sheet::after {
    transform: rotate(-0.8deg);
    opacity: 0.5;
    top: -3px;
    left: -4px;
    right: -12px;
    bottom: -6px;
}

.folio-content {
    position: relative;
    z-index: 1;
}

/* Drop Caps */
.folio-content > p:first-of-type::first-letter {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 3.5em;
    float: left;
    margin-right: 0.1em;
    margin-top: 0.05em;
    line-height: 0.85;
    color: var(--tarnished-gold);
}

.folio-content > p {
    margin-bottom: 1.25rem;
    font-size: 16px;
    line-height: 1.75;
}

.folio-content > p em {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 1.05em;
}

/* Section Headings */
.section-heading {
    font-family: var(--font-display);
    font-weight: 900;
    font-style: italic;
    font-size: clamp(2.5rem, 7vw, 5rem);
    color: var(--lampblack);
    margin-bottom: 2rem;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

/* Chapter Markers */
.chapter-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 2px solid var(--tarnished-gold);
    border-radius: 50%;
    margin-bottom: 1.5rem;
}

.chapter-numeral {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 1rem;
    color: var(--tarnished-gold);
    line-height: 1;
}

/* Library Acquisition Stamps */
.stamp-mark {
    position: absolute;
    width: 44px;
    height: 44px;
    border: 2px solid var(--crimson-thread);
    border-radius: 50%;
    opacity: 0.25;
    pointer-events: none;
}

/* Links */
.folio-content a {
    color: var(--tarnished-gold);
    text-decoration: none;
    background-image: linear-gradient(var(--tarnished-gold), var(--tarnished-gold));
    background-size: 0% 1px;
    background-repeat: no-repeat;
    background-position: left bottom;
    transition: background-size 300ms ease;
}

.folio-content a:hover {
    background-size: 100% 1px;
    color: var(--burnished-brass);
}

/* ==========================================================================
   Index Cards
   ========================================================================== */

.index-card {
    position: relative;
    width: 260px;
    min-height: 160px;
    background-color: var(--foxed-cream);
    padding: 1.2rem 1.4rem;
    box-shadow:
        2px 2px 4px rgba(0,0,0,0.15),
        4px 4px 8px rgba(0,0,0,0.1);
    background-image:
        repeating-linear-gradient(
            180deg,
            transparent,
            transparent 23px,
            #c4b8a8 23px,
            #c4b8a8 24px
        );
    z-index: 2;
    transition: transform 200ms ease-out, box-shadow 200ms ease-out;
}

.index-card:hover {
    transform: rotate(0deg) scale(1.03) !important;
    box-shadow:
        4px 4px 8px rgba(0,0,0,0.2),
        8px 8px 16px rgba(0,0,0,0.15),
        12px 12px 24px rgba(0,0,0,0.1);
}

.card-content {
    position: relative;
    z-index: 1;
}

.card-title {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--lampblack);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.card-body {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--faded-ink);
    line-height: 1.65;
}

.card-body em {
    font-family: var(--font-serif);
    font-style: italic;
}

/* Push Pins */
.push-pin {
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 8px;
    background-color: var(--push-pin-red);
    border-radius: 50%;
    box-shadow:
        0 1px 2px rgba(0,0,0,0.4),
        inset 0 -1px 1px rgba(0,0,0,0.2),
        inset 0 1px 1px rgba(255,255,255,0.2);
    z-index: 10;
}

/* ==========================================================================
   Marginalia Strips
   ========================================================================== */

.marginalia-strip {
    position: absolute;
    width: 180px;
    z-index: 3;
    padding: 0.5rem;
}

.marginalia-right {
    right: 3%;
}

.marginalia-left {
    left: 4%;
}

.marginalia-text {
    font-family: var(--font-serif);
    font-weight: 400;
    font-style: italic;
    font-size: clamp(0.85rem, 1.5vw, 1rem);
    color: var(--parchment-glow);
    line-height: 1.55;
    margin-bottom: 1rem;
    opacity: 0.75;
}

.marginalia-text em {
    font-style: normal;
    text-decoration: underline;
    text-decoration-color: rgba(196,162,101,0.4);
    text-underline-offset: 2px;
}

/* ==========================================================================
   Pull Quotes
   ========================================================================== */

.pull-quote {
    position: relative;
    margin: 2.5rem 1rem 2.5rem 2rem;
    padding: 1rem 0;
}

.pull-quote blockquote {
    font-family: var(--font-serif);
    font-weight: 600;
    font-size: clamp(1.3rem, 3vw, 2.2rem);
    color: var(--lampblack);
    line-height: 1.4;
    text-indent: -0.5em;
}

.pull-quote cite {
    display: block;
    margin-top: 0.75rem;
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--faded-ink);
    font-style: normal;
}

.pq-open,
.pq-close {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: 4em;
    color: var(--tarnished-gold);
    opacity: 0.2;
    position: absolute;
    line-height: 1;
    pointer-events: none;
}

.pq-open {
    top: -0.3em;
    left: -0.6em;
}

.pq-close {
    bottom: 0.4em;
    right: -0.2em;
}

/* ==========================================================================
   Ink Blot Dividers
   ========================================================================== */

.ink-blot-divider {
    width: 70%;
    margin: 20px auto 60px;
    opacity: 1;
}

.ink-blot-divider svg {
    width: 100%;
    height: 40px;
}

/* ==========================================================================
   Cork Board Section
   ========================================================================== */

.cork-board-section {
    position: relative;
    margin: 40px 0 100px;
    padding: 2.5rem 3rem;
    width: 85%;
    margin-left: 7%;
}

.cork-board-heading {
    font-family: var(--font-display);
    font-weight: 900;
    font-style: italic;
    font-size: clamp(2rem, 5vw, 3.5rem);
    color: var(--parchment-glow);
    margin-bottom: 2rem;
    opacity: 0.85;
}

.cork-surface {
    position: relative;
    background-color: var(--cork-bg);
    min-height: 500px;
    border-radius: 2px;
    padding: 2rem;
    box-shadow:
        inset 0 0 20px rgba(0,0,0,0.2),
        4px 4px 12px rgba(0,0,0,0.4);
    overflow: hidden;
}

.cork-noise {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.cork-surface .pinned-card {
    position: absolute;
    z-index: 2;
    margin: 0;
}

.cork-surface .pinned-card:hover {
    z-index: 5;
}

/* ==========================================================================
   Red Thread Connections
   ========================================================================== */

.red-thread {
    position: absolute;
    height: 1px;
    background-color: var(--crimson-thread);
    opacity: 0.4;
    transform-origin: left center;
    transform: scaleX(0);
    transition: transform 600ms ease-out;
    z-index: 1;
    pointer-events: none;
}

.red-thread.visible {
    transform: scaleX(1);
}

/* ==========================================================================
   Skeleton Loading
   ========================================================================== */

.skeleton-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 3rem 3.5rem;
    z-index: 10;
    background-color: var(--aged-vellum);
    opacity: 1;
    transition: opacity 400ms ease;
    pointer-events: none;
    will-change: opacity;
}

.skeleton-overlay.hidden {
    opacity: 0;
}

.skeleton-heading {
    width: 70%;
    height: 1.5em;
    background-color: var(--faded-ink);
    opacity: 0.12;
    margin-bottom: 2rem;
    border-radius: 2px;
    position: relative;
    overflow: hidden;
}

.skeleton-line {
    height: 1em;
    background-color: var(--faded-ink);
    opacity: 0.1;
    margin-bottom: calc(1.75 * 16px - 1em);
    border-radius: 1px;
    position: relative;
    overflow: hidden;
}

/* Gold shimmer animation */
.skeleton-heading::after,
.skeleton-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(196,162,101,0.08) 50%, transparent 100%);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ==========================================================================
   Book End Marker
   ========================================================================== */

.book-end-marker {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
    opacity: 0.7;
}

/* ==========================================================================
   Colophon / Footer
   ========================================================================== */

.colophon {
    background-color: var(--ink-well);
    padding: 4rem 72px;
    text-align: center;
}

.colophon-content {
    max-width: 500px;
    margin: 0 auto;
}

.colophon-rule {
    width: 60px;
    height: 1px;
    background-color: var(--tarnished-gold);
    margin: 0 auto 2rem;
    opacity: 0.5;
}

.colophon-text {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--parchment-glow);
    margin-bottom: 0.75rem;
    letter-spacing: 0.05em;
}

.colophon-meta {
    font-family: var(--font-serif);
    font-weight: 400;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--faded-ink);
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.colophon-meta em {
    font-style: normal;
    color: var(--tarnished-gold);
}

.colophon-flourish {
    margin-top: 1.5rem;
    opacity: 0.6;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 900px) {
    .desk-surface {
        padding: 60px 16px 80px 56px;
    }

    .folio-sheet {
        width: 88% !important;
        margin-left: 6% !important;
        padding: 2rem 2rem;
    }

    .marginalia-strip {
        position: relative;
        width: 100%;
        right: auto;
        left: auto;
        top: auto !important;
        padding: 1rem 6%;
        margin-bottom: 40px;
    }

    .marginalia-right,
    .marginalia-left {
        right: auto;
        left: auto;
    }

    .index-card {
        margin-left: 10% !important;
        width: 220px;
    }

    .cork-surface {
        min-height: 700px;
    }

    .cork-surface .pinned-card {
        position: relative;
        left: auto !important;
        top: auto !important;
        margin-bottom: 1rem;
        display: inline-block;
        width: calc(50% - 1rem);
        vertical-align: top;
    }

    .colophon {
        padding: 3rem 24px;
    }
}

@media (max-width: 600px) {
    .sidebar {
        width: 36px;
    }

    .marker-line {
        width: 18px;
    }

    .desk-surface {
        padding: 40px 12px 60px 44px;
    }

    .folio-sheet {
        width: 92% !important;
        margin-left: 4% !important;
        padding: 1.5rem 1.5rem;
    }

    .section-heading {
        font-size: clamp(1.8rem, 6vw, 3rem);
    }

    .cork-board-section {
        width: 92%;
        margin-left: 4%;
        padding: 1.5rem 1rem;
    }

    .cork-surface .pinned-card {
        width: 100%;
        display: block;
    }

    .index-card {
        width: 200px;
    }

    .pull-quote blockquote {
        font-size: clamp(1.1rem, 4vw, 1.6rem);
    }

    .pq-open,
    .pq-close {
        font-size: 2.5em;
    }
}
