/* ============================================================
   GABS.WIKI - DARK ACADEMIA STYLESHEET
   ============================================================ */

/* COLOR PALETTE - REFERENCE */
:root {
    --primary-bg: #1A0A0A;
    --secondary-bg: #2B1414;
    --tertiary-surface: #3D2020;
    --card-surface: #F5ECD7;
    --card-aged: #EDE0C8;
    --primary-text: #D4C4A8;
    --primary-text-dark: #1A0A0A;
    --accent-primary: #8B2252;
    --accent-secondary: #C4956A;
    --muted-annotation: #8B6969;
    --ruled-line: #6B3A3A;
    --glow-emphasis: #D4A574;
    --variant-dark: #5A3030;
}

/* RESET & BASE STYLES */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'EB Garamond', serif;
    background-color: #1A0A0A;
    color: #D4C4A8;
    line-height: 1.75;
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    overflow-x: hidden;
    position: relative;
}

/* PAPER GRAIN TEXTURE BACKGROUND */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAIklEQVQIW2P4z8DwHwMKwOgVFApGr6BQMHoFhYLRKygUjAYAgJvcB/qqhfUAAAAASUVORK5CYII=');
    background-size: 100px 100px;
    pointer-events: none;
    mix-blend-mode: overlay;
    opacity: 0.04;
    z-index: 1;
}

/* TYPOGRAPHY */
h1, h2, h3 {
    font-weight: 600;
    letter-spacing: 0.03em;
}

h1 {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-style: italic;
    font-size: clamp(3.5rem, 10vw, 7rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-align: center;
    color: #D4C4A8;
}

h2 {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.03em;
    color: #D4C4A8;
}

h3 {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.2rem, 2vw, 1.8rem);
    letter-spacing: 0.03em;
    color: #D4C4A8;
}

p {
    margin-bottom: 1.5rem;
}

/* GRID LAYOUT STRUCTURE */
.chapter {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* ============================================================
   CHAPTER I: THE THRESHOLD
   ============================================================ */
.chapter-threshold {
    background-color: #1A0A0A;
    flex-direction: column;
    gap: 4rem;
    min-height: 100vh;
}

.threshold-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
}

.bookplate {
    border: 2px solid #C4956A;
    border-width: 2px;
    padding: 3rem 4rem;
    position: relative;
}

.bookplate::before,
.bookplate::after {
    content: '';
    position: absolute;
    left: 2rem;
    right: 2rem;
    height: 1px;
    background-color: #3D2020;
}

.bookplate::before {
    top: 1.5rem;
}

.bookplate::after {
    bottom: 1.5rem;
}

.domain-name {
    font-size: clamp(3.5rem, 10vw, 6rem);
}

.obelus-guide {
    font-size: 2rem;
    color: #8B2252;
    animation: pulse-dagger 2s ease-in-out infinite;
}

@keyframes pulse-dagger {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* ============================================================
   CHAPTER II: THE CATALOGUE
   ============================================================ */
.chapter-catalogue {
    background-color: #2B1414;
    min-height: 120vh;
    flex-direction: column;
    padding: 4rem 2rem;
}

.catalogue-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.section-intro {
    text-align: center;
    margin-bottom: 4rem;
    font-size: 1.5rem;
}

.typewriter-text {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    border-right: 2px solid #D4C4A8;
    animation: typewriter-reveal 3s steps(20, end) 1 forwards, cursor-blink 0.53s infinite;
}

@keyframes typewriter-reveal {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes cursor-blink {
    0%, 50%, 100% { border-right-color: #D4C4A8; }
    51%, 99% { border-right-color: transparent; }
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 3rem;
    perspective: 1000px;
}

.index-card {
    background-color: #F5ECD7;
    color: #1A0A0A;
    padding: 2rem;
    border: 1px solid #3D2020;
    position: relative;
    transform: rotate(var(--rotation, 1deg));
    opacity: 0;
    transform-origin: center;
    transition: all 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    will-change: transform, opacity;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.card-1 { --rotation: 1.5deg; }
.card-2 { --rotation: -1.2deg; }
.card-3 { --rotation: 2deg; }
.card-4 { --rotation: -1.8deg; }
.card-5 { --rotation: 1deg; }
.card-6 { --rotation: -2deg; }

.index-card.visible {
    opacity: 1;
    transform: rotate(var(--rotation, 0deg)) scale(1);
}

.card-header {
    height: 12px;
    background: linear-gradient(to right, #8B2252, transparent);
    margin: -2rem -2rem 1.5rem -2rem;
    border-bottom: 1px solid #8B2252;
}

.card-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85em;
    color: #8B2252;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    font-weight: 600;
}

.card-content {
    font-family: 'Crimson Pro', serif;
    font-size: clamp(0.75rem, 0.9vw, 0.85rem);
    line-height: 1.6;
    color: #3D2020;
}

/* Aged variant for cards */
.card-2,
.card-5 {
    background-color: #EDE0C8;
}

/* ============================================================
   CHAPTER III: THE READING ROOM
   ============================================================ */
.chapter-reading-room {
    background-color: #1A0A0A;
    min-height: 100vh;
    padding: 0;
    overflow: hidden;
}

.reading-room-content {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

.room-ceiling {
    flex: 0 0 60%;
    background-color: #1A0A0A;
    position: relative;
    filter: blur(8px);
    transition: filter 1.6s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.room-ceiling.visible {
    filter: blur(0);
}

.desk-surface {
    flex: 0 0 40%;
    background: linear-gradient(to bottom, #2B1414 0%, #1A0A0A 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    /* lamp glow effect in warm amber #D4A574 */
    box-shadow: inset 0 0 120px rgba(212, 165, 116, 0.15);
}

.text-boundary {
    max-width: 680px;
    padding: 2rem;
    color: #D4C4A8;
}

.room-text {
    margin-bottom: 1.5rem;
    line-height: 1.8;
    opacity: 0;
    transform: translateY(20px);
    transition: all 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.room-text.visible {
    opacity: 1;
    transform: translateY(0);
}

.drop-cap {
    font-family: 'Playfair Display', serif;
    font-size: 3em;
    font-style: italic;
    color: #8B2252;
    float: left;
    line-height: 1;
    margin-right: 0.1em;
    margin-bottom: 0.1em;
    padding-right: 0.2em;
    border-bottom: 1px solid #C4956A;
}

.margin-note-left {
    font-family: 'Crimson Pro', serif;
    font-style: italic;
    font-size: 0.9rem;
    color: #8B6969;
}

/* ============================================================
   CHAPTER IV: THE MARGINALIA
   ============================================================ */
.chapter-marginalia {
    background-color: #2B1414;
    min-height: 150vh;
    padding: 4rem 2rem;
}

.marginalia-wrapper {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    max-width: 1400px;
    margin: 0 auto;
}

.margin-left-primary,
.margin-right-primary {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2rem;
}

.margin-heading {
    color: #D4C4A8;
}

.margin-body {
    color: #D4C4A8;
    line-height: 1.85;
    opacity: 0;
    transform: translateX(-40px);
    transition: all 1.4s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.margin-left-primary .margin-body {
    transform: translateX(-40px);
}

.margin-right-primary .margin-body {
    transform: translateX(40px);
}

.margin-body.visible {
    opacity: 1;
    transform: translateX(0);
}

.margin-decoration {
    background-color: #1A0A0A;
    border-left: 3px solid #C4956A;
    padding: 2rem;
    margin-top: 1rem;
    /* variant color for depth contrast */
    box-shadow: inset -2px 0 0 #5A3030;
}

.margin-decoration p {
    color: #C4956A;
    font-family: 'Cormorant Garamond', serif;
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.margin-list {
    list-style: none;
    padding: 0;
}

.margin-list li {
    color: #8B6969;
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
    position: relative;
}

.margin-list li::before {
    content: '†';
    position: absolute;
    left: 0;
    color: #8B2252;
}

/* ============================================================
   CHAPTER V: THE ARCHIVE
   ============================================================ */
.chapter-archive {
    background-color: #1A0A0A;
    min-height: 100vh;
    padding: 4rem 2rem;
    position: relative;
}

.archive-content {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

.archive-title {
    text-align: center;
    margin-bottom: 3rem;
    color: #D4C4A8;
}

.pin-lines {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.pin-lines line {
    stroke: #6B3A3A;
    stroke-width: 1;
    opacity: 0.4;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.pin-lines line.drawn {
    animation: draw-line 2s ease-in-out forwards;
}

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

.archive-nodes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    position: relative;
    z-index: 2;
    margin-bottom: 3rem;
}

.archive-node {
    background-color: transparent;
    border: 1px solid #6B3A3A;
    padding: 1.5rem;
    text-align: center;
    position: relative;
    opacity: 0;
    transform: scale(0.8);
    transition: all 1.2s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.archive-node.visible {
    opacity: 1;
    transform: scale(1);
}

.node-label {
    font-family: 'Cormorant Garamond', serif;
    font-size: 1rem;
    color: #D4C4A8;
    line-height: 1.5;
}

.archive-closing {
    text-align: center;
    margin-top: 3rem;
    font-family: 'Crimson Pro', serif;
    font-size: 1rem;
    color: #8B6969;
    position: relative;
    z-index: 2;
}

#typewriter-2 {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    border-right: 2px solid #D4C4A8;
    animation: typewriter-reveal 4s steps(25, end) 0.5s forwards, cursor-blink 0.53s infinite 0.5s;
}

/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */
@media (max-width: 1024px) {
    .marginalia-wrapper {
        grid-template-columns: 1fr;
    }

    .chapter {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .bookplate {
        padding: 2rem 2.5rem;
    }

    .cards-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .archive-nodes {
        grid-template-columns: repeat(2, 1fr);
    }

    .reading-room-content {
        flex-direction: row;
    }

    .room-ceiling {
        flex: 0 0 40%;
    }

    .desk-surface {
        flex: 0 0 60%;
    }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-center {
    text-align: center;
}

.opacity-reduced {
    opacity: 0.7;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in-left {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fade-in-right {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Ensure animations respect user preferences */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
