/* ============================================================
   talegrapher.com - Styles
   Late 19th-century printing house broadsheet aesthetic
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --aged-parchment: #f4ede4;
    --walnut-ink: #5c4a3a;
    --deep-vermillion: #a63d2f;
    --lampblack: #1c1714;
    --tarnished-gold: #b8943e;
    --faded-indigo: #4a5d7a;
    --foxed-cream: #ebe3d5;
}

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

::selection {
    background-color: var(--tarnished-gold);
    color: #ffffff;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Libre Baskerville', 'Georgia', serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    color: var(--walnut-ink);
    background-color: var(--aged-parchment);
    font-feature-settings: "liga" 1, "kern" 1;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    /* Paper texture via inset vignette */
    box-shadow: inset 0 0 120px rgba(92,74,58,0.08);
}

/* Paper grain noise texture */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px 256px;
}

/* --- Reading Progress Indicator --- */
.progress-indicator {
    position: fixed;
    left: 12px;
    top: 0;
    width: 3px;
    height: 100vh;
    background: rgba(92,74,58,0.12);
    z-index: 1000;
}

.progress-fill {
    width: 100%;
    height: 0%;
    background: var(--walnut-ink);
    transition: height 0.1s linear;
}

/* --- Masthead Section --- */
.masthead {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--lampblack);
    position: relative;
    overflow: hidden;
    transition: background-color 2s ease;
}

.masthead.revealed {
    background-color: var(--aged-parchment);
}

.masthead-inner {
    text-align: center;
    padding: 2rem;
    max-width: 800px;
    width: 100%;
}

.masthead-rule-top,
.masthead-rule-bottom {
    height: 1px;
    background: var(--walnut-ink);
    margin: 1rem auto;
    max-width: 600px;
    opacity: 0;
    transition: opacity 1.5s ease 2.5s;
}

.masthead.revealed .masthead-rule-top,
.masthead.revealed .masthead-rule-bottom {
    opacity: 0.6;
}

.masthead-device {
    margin: 0 auto 2rem;
    opacity: 0;
    transition: opacity 1.5s ease 2s;
}

.masthead.revealed .masthead-device {
    opacity: 1;
}

.masthead-title {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 900;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--lampblack);
    margin: 0 0 1.5rem;
    line-height: 1.1;
}

.masthead .masthead-title {
    color: var(--aged-parchment);
}

.masthead.revealed .masthead-title {
    color: var(--lampblack);
    transition: color 2s ease;
}

.letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    animation: letterReveal 0.4s ease forwards;
    animation-delay: calc(0.8s + var(--delay) * 60ms);
}

@keyframes letterReveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.masthead-rule-svg {
    max-width: 600px;
    margin: 0 auto 1.5rem;
    opacity: 0;
    transition: opacity 1s ease 2s;
}

.masthead.revealed .masthead-rule-svg {
    opacity: 1;
}

.rule-draw {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    animation: drawRule 1.5s ease forwards;
    animation-delay: 2s;
}

@keyframes drawRule {
    to {
        stroke-dashoffset: 0;
    }
}

.masthead-tagline {
    font-family: 'IM Fell English', 'Georgia', serif;
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--walnut-ink);
    opacity: 0;
    transition: opacity 1.5s ease 2.8s;
    margin-bottom: 0.75rem;
}

.masthead.revealed .masthead-tagline {
    opacity: 1;
}

.masthead-dateline {
    font-family: 'Libre Baskerville', 'Georgia', serif;
    font-style: italic;
    font-variant: small-caps;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    color: var(--faded-indigo);
    opacity: 0;
    transition: opacity 1.5s ease 3.2s;
}

.masthead.revealed .masthead-dateline {
    opacity: 1;
}

/* --- Sticky Masthead --- */
.sticky-masthead {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: var(--aged-parchment);
    border-bottom: 1px solid rgba(92,74,58,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
    opacity: 0;
    transform: translateY(-100%);
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 2px 8px rgba(28,23,20,0.06);
}

.sticky-masthead.visible {
    opacity: 1;
    transform: translateY(0);
}

.sticky-title {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 900;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--lampblack);
}

/* --- Main Broadsheet --- */
.broadsheet {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 3rem 4rem;
    position: relative;
}

/* Ruled margins / crop-mark frame */
.broadsheet::before {
    content: '';
    position: absolute;
    top: 24px;
    left: 24px;
    right: 24px;
    bottom: 24px;
    border: 1px solid rgba(92,74,58,0.3);
    pointer-events: none;
    z-index: 1;
}

/* --- Sections --- */
.section {
    margin-bottom: 4rem;
    position: relative;
}

/* --- Broadsheet Columns --- */
.broadsheet-columns {
    column-count: 3;
    column-width: 18rem;
    column-gap: 2.5rem;
    column-rule: 1px solid var(--walnut-ink);
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.broadsheet-columns p {
    text-indent: 1.5em;
    margin-bottom: 1rem;
    break-inside: avoid;
}

.broadsheet-columns .drop-cap-paragraph {
    text-indent: 0;
}

/* --- Drop Caps --- */
.drop-cap {
    float: left;
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 900;
    font-size: clamp(5rem, 8vw, 8rem);
    line-height: 0.75;
    color: var(--deep-vermillion);
    padding: 0 0.15em 0 0;
    text-shadow: 2px 2px 0 rgba(92,74,58,0.15);
    shape-outside: margin-box;
    transform: scale(0);
    opacity: 0;
    transition: transform 0.6s ease, opacity 0.6s ease;
}

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

/* --- Pull Quotes --- */
.pull-quote {
    break-inside: avoid;
    margin: 2rem 0;
    padding: 1.5rem 1.5rem 1.5rem 2rem;
    border-left: 4px solid var(--deep-vermillion);
    background: var(--foxed-cream);
    position: relative;
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

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

.pull-quote p {
    font-family: 'Libre Baskerville', 'Georgia', serif;
    font-style: italic;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    line-height: 1.6;
    color: var(--walnut-ink);
    text-indent: 0;
    margin-bottom: 0;
}

/* --- Ornamental Dividers --- */
.ornamental-divider {
    margin: 3rem auto;
    max-width: 800px;
    text-align: center;
}

/* --- Section III: Archive Layout --- */
.archive-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2.5rem;
    position: relative;
}

.archive-layout::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    right: calc(33.333% + 1.25rem);
    width: 1px;
    background: var(--walnut-ink);
    opacity: 0.4;
}

.archive-main {
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.archive-main p {
    text-indent: 1.5em;
    margin-bottom: 1rem;
}

.archive-main .drop-cap-paragraph {
    text-indent: 0;
}

.archive-main .pull-quote {
    text-indent: 0;
}

/* --- Marginalia --- */
.archive-marginalia {
    padding-top: 2rem;
}

.marginalia-note {
    margin-bottom: 2rem;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.marginalia-note.visible {
    opacity: 1;
    transform: translateY(0);
}

.marginalia-mark {
    display: block;
    font-family: 'IM Fell English', 'Georgia', serif;
    font-size: 1.2rem;
    color: var(--tarnished-gold);
    margin-bottom: 0.25rem;
}

.marginalia-note p {
    font-family: 'IM Fell English', 'Georgia', serif;
    font-style: italic;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    line-height: 1.6;
    color: var(--faded-indigo);
    text-indent: 0;
}

/* --- Section IV: Press Room --- */
.section-press-room {
    background: var(--foxed-cream);
    margin-left: -3rem;
    margin-right: -3rem;
    padding: 4rem 3rem;
}

.press-room-content {
    max-width: 42rem;
    margin: 0 auto;
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
}

.press-room-content p {
    text-indent: 1.5em;
    margin-bottom: 1rem;
}

.press-room-content .drop-cap-paragraph {
    text-indent: 0;
}

.press-room-content .pull-quote {
    text-indent: 0;
}

.press-room-device {
    text-align: center;
    margin-bottom: 3rem;
}

.quill-nib-hero {
    width: 120px;
    height: 120px;
}

/* SVG draw animation for hero quill-nib */
.svg-draw-hero {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    transition: stroke-dashoffset 3s ease;
}

.press-room-device.visible .svg-draw-hero {
    stroke-dashoffset: 0;
}

/* Press vibration animation */
@keyframes pressVibrate {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(0.5px); }
    75% { transform: translateX(-0.5px); }
}

.section-press-room.vibrating {
    animation: pressVibrate 0.033s linear 60;
}

/* --- Section V: Colophon --- */
.section-colophon {
    text-align: center;
    padding: 3rem 0 2rem;
}

.colophon-dividers {
    max-width: 600px;
    margin: 0 auto 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.colophon-ornament {
    opacity: 0;
    transition: opacity 0.8s ease;
}

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

.colophon-draw {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1.5s ease;
}

.colophon-ornament.visible .colophon-draw {
    stroke-dashoffset: 0;
}

.colophon-device {
    margin: 0 auto 2rem;
}

.quill-nib-small {
    width: 24px;
    height: 24px;
}

.colophon-box {
    max-width: 500px;
    margin: 0 auto;
    padding: 2rem;
    border: 2px double var(--walnut-ink);
}

.colophon-text {
    font-family: 'IM Fell English', 'Georgia', serif;
    font-style: italic;
    font-size: clamp(0.85rem, 1.1vw, 1rem);
    line-height: 1.7;
    color: var(--walnut-ink);
    margin-bottom: 1.5rem;
}

.colophon-edition {
    font-family: 'Libre Baskerville', 'Georgia', serif;
    font-style: italic;
    font-variant: small-caps;
    font-size: clamp(0.75rem, 1vw, 0.9rem);
    color: var(--faded-indigo);
    margin-bottom: 1rem;
}

.colophon-mark {
    font-family: 'IM Fell English', 'Georgia', serif;
    font-size: 1rem;
    color: var(--tarnished-gold);
    letter-spacing: 0.3em;
}

/* --- Vignette dimming for colophon --- */
.section-colophon .vignette-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 120px rgba(92,74,58,0.08);
    pointer-events: none;
    z-index: 998;
    transition: box-shadow 2s ease;
}

/* --- Ink Splatters --- */
.ink-splatters {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.ink-splat {
    position: absolute;
    border-radius: 50%;
    background: var(--walnut-ink);
    opacity: 0.12;
}

/* --- Scroll-triggered animation base --- */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* --- SVG draw in masthead --- */
.svg-draw {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
    animation: svgDraw 2s ease forwards;
    animation-delay: 2.5s;
}

@keyframes svgDraw {
    to {
        stroke-dashoffset: 0;
    }
}

/* --- Section headings (if any) --- */
h2 {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3rem);
    letter-spacing: 0.08em;
    color: var(--lampblack);
    margin-bottom: 1.5rem;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .broadsheet-columns {
        column-count: 2;
    }

    .archive-layout {
        grid-template-columns: 1fr;
    }

    .archive-layout::after {
        display: none;
    }

    .archive-marginalia {
        border-top: 1px solid rgba(92,74,58,0.3);
        padding-top: 1.5rem;
    }
}

@media (max-width: 640px) {
    .broadsheet {
        padding: 2rem 1.5rem 3rem;
    }

    .broadsheet::before {
        top: 12px;
        left: 12px;
        right: 12px;
        bottom: 12px;
    }

    .broadsheet-columns {
        column-count: 1;
    }

    .section-press-room {
        margin-left: -1.5rem;
        margin-right: -1.5rem;
        padding: 3rem 1.5rem;
    }

    .masthead-title {
        letter-spacing: 0.12em;
    }

    .progress-indicator {
        display: none;
    }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    .letter {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .rule-draw {
        animation: none;
        stroke-dashoffset: 0;
    }

    .svg-draw {
        animation: none;
        stroke-dashoffset: 0;
    }

    .masthead {
        transition: none;
        background-color: var(--aged-parchment);
    }

    .masthead-tagline,
    .masthead-dateline,
    .masthead-device,
    .masthead-rule-top,
    .masthead-rule-bottom,
    .masthead-rule-svg {
        opacity: 1;
        transition: none;
    }

    .masthead .masthead-title {
        color: var(--lampblack);
    }

    .animate-on-scroll {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .drop-cap {
        transform: scale(1);
        opacity: 1;
        transition: none;
    }

    .pull-quote {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .marginalia-note {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .svg-draw-hero {
        stroke-dashoffset: 0;
        transition: none;
    }

    .colophon-ornament {
        opacity: 1;
        transition: none;
    }

    .colophon-draw {
        stroke-dashoffset: 0;
        transition: none;
    }

    .section-press-room.vibrating {
        animation: none;
    }

    .sticky-masthead {
        transition: none;
    }
}
