/* ============================================
   gazza.news — Wabi-Sabi Scholarly Newsroom
   Palette: Terracotta-Warm
   Typography: Display-Bold Scholarly System
   Pattern: Magnetic
   ============================================ */

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

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

body {
    font-family: 'Libre Baskerville', Georgia, serif;
    color: #2B1D12;
    background: linear-gradient(to bottom, #C4704B, #8B4225);
    background-attachment: fixed;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    /* Warm shadow base tone: #3D2B1F */
    --shadow-warm: #3D2B1F;
}

/* --- Noise Texture Overlay --- */
#noise-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    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.85' 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;
}

/* --- Typography --- */
.site-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: clamp(48px, 8vw, 96px);
    letter-spacing: -0.03em;
    line-height: 1.05;
    color: #2B1D12;
}

.chapter-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: clamp(36px, 5vw, 64px);
    letter-spacing: -0.03em;
    line-height: 1.05;
    color: #2B1D12;
    margin-bottom: 40px;
}

.site-subtitle {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.7;
    color: #6B5744;
    max-width: 38em;
    margin-top: 24px;
}

.card-headline {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 700;
    font-size: 22px;
    line-height: 1.3;
    color: #2B1D12;
    margin-bottom: 12px;
}

.body-text {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.7;
    color: #2B1D12;
    max-width: 38em;
    margin-bottom: 24px;
}

.meta-label {
    font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    font-weight: 400;
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6B5744;
    display: block;
    margin-bottom: 6px;
}

.meta-date {
    font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    font-weight: 700;
    font-size: 20px;
    color: #2B1D12;
    margin-bottom: 12px;
}

.card-meta {
    font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    font-weight: 400;
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6B5744;
    display: block;
    margin-top: 16px;
}

.card-excerpt {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-weight: 400;
    font-size: 15px;
    line-height: 1.6;
    color: #6B5744;
}

.marginalia-note {
    font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    font-style: italic;
    font-weight: 400;
    font-size: 13px;
    line-height: 1.6;
    color: #6B5744;
    letter-spacing: 0.01em;
}

.colophon-text {
    font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.7;
    color: #F2E6D4;
    margin-bottom: 18px;
    max-width: 38em;
}

.closing-quote p {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-style: italic;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.6;
    color: #F2E6D4;
    margin-bottom: 12px;
}

.quote-attribution {
    font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    font-weight: 400;
    font-size: 13px;
    color: #D4A853;
    font-style: normal;
}

/* --- Layout --- */
.chapter {
    min-height: 100vh;
    position: relative;
    padding: 80px 5vw;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chapter-inner {
    display: grid;
    grid-template-columns: 62fr 38fr;
    gap: 40px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
    align-items: start;
}

.chapter-inner-centered {
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
}

.main-column {
    position: relative;
}

.marginalia-column {
    position: relative;
    padding-top: 40px; /* vertical offset from main content */
}

/* --- Chapter I: The Study --- */
.chapter-study {
    padding-top: 0;
    padding-bottom: 0;
}

.study-content {
    padding-top: 38vh;
}

.study-card {
    margin-top: 42vh;
}

/* --- Chapter II: The Stacks --- */
.card-cluster {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    position: relative;
}

.stack-card {
    transition: transform 600ms cubic-bezier(0.25, 0.1, 0.0, 1.0),
                box-shadow 400ms cubic-bezier(0.4, 0.0, 0.2, 1.0);
}

.stack-card-1 { transform: rotate(-1.5deg); }
.stack-card-2 { transform: rotate(2deg); }
.stack-card-3 { transform: rotate(-0.5deg); }
.stack-card-4 { transform: rotate(1.2deg); }

/* Scroll-triggered entry animation */
.stack-card.animate-in {
    opacity: 1;
    transform: translateY(0) translateX(0) rotate(var(--rotate, 0deg));
}

.stack-card:not(.animate-in) {
    opacity: 0;
    transform: translateY(30px) translateX(var(--offset-x, -10px));
}

.stack-card:nth-child(2):not(.animate-in),
.stack-card:nth-child(4):not(.animate-in) {
    --offset-x: 10px;
}

/* --- Chapter III: Margin Notes --- */
.longform-passage {
    max-width: 38em;
}

.footnote-marker {
    color: #D4763A;
    cursor: pointer;
    font-size: 0.75em;
    vertical-align: super;
    transition: color 200ms cubic-bezier(0.25, 0.1, 0.0, 1.0);
    position: relative;
}

.footnote-marker:hover {
    color: #D4A853;
}

.annotation-card {
    margin-bottom: 30px;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 500ms cubic-bezier(0.25, 0.1, 0.0, 1.0),
                transform 600ms cubic-bezier(0.25, 0.1, 0.0, 1.0),
                box-shadow 300ms cubic-bezier(0.4, 0.0, 0.2, 1.0);
}

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

.annotation-card .ink-connector {
    position: absolute;
    top: 16px;
    left: -100px;
    width: 100px;
    height: 40px;
    overflow: visible;
}

.annotation-card .ink-connector path {
    transition: stroke-dashoffset 800ms cubic-bezier(0.25, 0.1, 0.0, 1.0);
}

.annotation-card.visible .ink-connector path {
    stroke-dashoffset: 0;
}

/* Footnote hover: magnetic glow on corresponding annotation */
.annotation-card.footnote-highlight {
    box-shadow: 0 8px 32px rgba(43, 29, 18, 0.25),
                0 0 20px rgba(212, 168, 83, 0.15);
    transform: translateX(-2px);
}

/* --- Chapter IV: The Reading Room --- */
.chapter-reading-room .chapter-inner-centered {
    width: 100%;
}

.reading-room-card {
    max-width: 860px;
    width: 100%;
    padding: 60px 56px;
    position: relative;
    overflow: hidden;
}

.reading-room-title {
    text-align: center;
    margin-bottom: 48px;
}

.drop-cap {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: 72px;
    float: left;
    line-height: 0.8;
    margin-right: 8px;
    margin-top: 6px;
    color: #C4704B;
}

/* --- Chapter V: The Colophon --- */
.chapter-colophon {
    background: linear-gradient(to bottom, transparent 0%, #8B4225 30%);
}

.colophon-title {
    color: #F2E6D4;
}

.colophon-content {
    padding-top: 20px;
}

.colophon-links {
    margin: 24px 0;
}

.colophon-link {
    font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
    font-weight: 400;
    font-size: 16px;
    color: #D4763A;
    text-decoration: none;
    border-bottom: 1px solid #D4763A;
    transition: color 200ms cubic-bezier(0.25, 0.1, 0.0, 1.0),
                border-bottom-width 200ms cubic-bezier(0.25, 0.1, 0.0, 1.0);
}

.colophon-link:hover {
    color: #D4A853;
    border-bottom-width: 2px;
    border-bottom-color: #D4A853;
    background: linear-gradient(135deg, #D4763A, #C4704B);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.colophon-link:visited {
    color: #5B8A72;
    border-bottom-color: #5B8A72;
}

.quill-icon {
    margin: 32px 0 24px;
    opacity: 0.7;
}

.aldus-leaf {
    font-size: 32px;
    color: #D4A853;
    opacity: 0.6;
    text-align: left;
    margin-top: 24px;
}

.colophon-quote-card {
    margin-top: 60px;
}

.closing-quote {
    border: none;
    padding: 0;
    margin: 0;
}

/* --- Glassmorphic Cards --- */
.glass-card {
    background: rgba(242, 230, 212, 0.35);
    backdrop-filter: blur(16px) saturate(120%);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    border: 1px solid rgba(212, 168, 83, 0.3);
    border-radius: 2px;
    /* #3D2B1F at low opacity for warm directional shadow */
    box-shadow: 0 8px 32px rgba(61, 43, 31, 0.15);
    padding: 24px;
    position: relative;
    transition: transform 300ms cubic-bezier(0.4, 0.0, 0.2, 1.0),
                box-shadow 300ms cubic-bezier(0.4, 0.0, 0.2, 1.0);
}

/* Noise grain on cards (slightly more pronounced) */
.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.05;
    border-radius: 2px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='150' height='150' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
}

/* Page curl corner */
.card-page-curl {
    position: absolute;
    top: 0;
    right: 0;
    width: 28px;
    height: 28px;
    background: radial-gradient(
        circle at top right,
        #F2E6D4 0%,
        rgba(242, 230, 212, 0.6) 50%,
        transparent 70%
    );
    clip-path: polygon(100% 0, 0 0, 100% 100%);
    pointer-events: none;
    z-index: 1;
}

/* --- Chapter Dividers (Ink Rules) --- */
.chapter-divider {
    width: 100%;
    max-width: 800px;
    margin: 60px auto 0;
    padding: 0 5vw;
}

.ink-rule {
    width: 100%;
    height: 6px;
    display: block;
}

/* --- Book Spine Dividers --- */
.book-spine {
    width: 3px;
    background: #8B4225;
    position: relative;
    height: 100%;
}

.book-spine::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
}

.book-spine::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: rgba(0, 0, 0, 0.1);
}

/* --- Links --- */
a {
    color: #D4763A;
    text-decoration: none;
    border-bottom: 1px solid currentColor;
    transition: color 200ms cubic-bezier(0.25, 0.1, 0.0, 1.0),
                border-bottom-width 200ms cubic-bezier(0.25, 0.1, 0.0, 1.0);
}

a:hover {
    color: #D4A853;
    border-bottom-width: 2px;
}

a:visited {
    color: #5B8A72;
}

/* --- Responsive: Below 900px --- */
@media (max-width: 900px) {
    .chapter-inner {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .marginalia-column {
        padding-top: 0;
    }

    .marginalia-card {
        border-left: 3px solid #C4704B;
        margin-left: 16px;
        padding-left: 20px;
    }

    .study-content {
        padding-top: 20vh;
    }

    .study-card {
        margin-top: 0;
    }

    .card-cluster {
        grid-template-columns: 1fr;
    }

    .stack-card {
        transform: rotate(0deg) !important;
    }

    .annotation-card .ink-connector {
        display: none;
    }

    .reading-room-card {
        padding: 32px 24px;
    }

    .chapter {
        padding: 60px 4vw;
    }

    .chapter-inner-centered {
        padding: 0;
    }

    .colophon-quote-card {
        margin-top: 24px;
    }

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

/* --- Selection Color --- */
::selection {
    background: rgba(212, 168, 83, 0.35);
    color: #2B1D12;
}

/* --- Disable backdrop-filter for off-screen cards (controlled via JS) --- */
.glass-card.offscreen {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
