/* ============================================================
   historygrapher.com — Styles
   Dark-academia cartographic studio
   ============================================================ */

:root {
    --aged-vellum: #F4ECD8;
    --foxed-cream: #E8D9B8;
    --burnt-umber-ink: #3B2F2F;
    --saddle-leather: #6B4226;
    --gilt-edge: #C8B078;
    --marginalia-sepia: #8B7355;
    --archive-dust: #D4C4A8;
    --cartographer-red: #8C3B3B;
    --body-text: #4A3C31;
    --deep-brown: #5C4A3A;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--aged-vellum);
    color: var(--body-text);
    font-family: 'Lora', serif;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
}

/* ---- Atlas Hero ---- */
.atlas-hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--aged-vellum);
    position: relative;
    padding: 40px;
}

.atlas-map {
    width: 90%;
    max-width: 1000px;
    height: auto;
}

/* Lat/lon line draw animation */
.lat-line {
    stroke-dasharray: 1800;
    stroke-dashoffset: 1800;
    animation: drawLine 1.2s ease forwards;
}

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

/* Coastline reveal */
.coastline {
    stroke-dasharray: 3000;
    stroke-dashoffset: 3000;
    animation: drawCoast 2.5s ease 1.2s forwards;
}

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

/* Wind lines */
.wind-line {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawLine 2s ease 2s forwards;
}

/* Compass hero */
.compass-line-hero {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    animation: drawLine 1.5s ease 3s forwards;
}

.compass-text-hero {
    font-family: 'Caveat', cursive;
    font-size: 10px;
    fill: var(--saddle-leather);
    opacity: 0;
    animation: fadeIn 0.5s ease 4.2s forwards;
}

.compass-rose-hero circle {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: drawLine 1.5s ease 3s forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.atlas-tagline {
    font-family: 'Playfair Display SC', serif;
    font-size: 1.2rem;
    letter-spacing: 0.2em;
    color: var(--saddle-leather);
    margin-top: 32px;
    opacity: 0;
    animation: fadeIn 0.8s ease 4.5s forwards;
}

/* ---- Archive Content ---- */
.archive-content {
    position: relative;
    max-width: 960px;
    margin: 0 auto;
    padding: 80px 40px 120px;
}

/* ---- Timeline Spine ---- */
.timeline-spine {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    transform: translateX(-50%);
    z-index: 1;
}

.spine-line {
    width: 1px;
    height: 100%;
    background: linear-gradient(
        to bottom,
        var(--burnt-umber-ink) 0%,
        var(--burnt-umber-ink) 30%,
        transparent 30.5%,
        transparent 31.5%,
        var(--burnt-umber-ink) 32%,
        var(--burnt-umber-ink) 60%,
        transparent 60.5%,
        transparent 61%,
        transparent 61.5%,
        var(--burnt-umber-ink) 62%,
        var(--burnt-umber-ink) 100%
    );
    background-size: 1px 20px;
}

/* ---- Timeline Markers ---- */
.timeline-marker {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: -20px;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.major-event::before {
    content: '';
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--saddle-leather);
    border: 2px solid var(--gilt-edge);
    display: block;
}

.major-event.pulse::before {
    animation: markerPulse 0.8s ease-out;
}

@keyframes markerPulse {
    0% { box-shadow: 0 0 0 0 rgba(200,176,120,0.5); }
    100% { box-shadow: 0 0 0 12px rgba(200,176,120,0); }
}

.minor-event::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--archive-dust);
    border: 1px solid var(--saddle-leather);
    display: block;
}

.pivotal-moment::before {
    content: '';
    width: 16px;
    height: 16px;
    background: var(--cartographer-red);
    border: 2px solid var(--gilt-edge);
    transform: rotate(45deg);
    display: block;
    animation: pivotalPulse 2s ease-in-out infinite;
}

@keyframes pivotalPulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

.marker-year {
    font-family: 'Cormorant SC', 'Playfair Display SC', serif;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    color: var(--marginalia-sepia);
    white-space: nowrap;
}

/* ---- Document Blocks ---- */
.doc-block {
    position: relative;
    margin-bottom: 120px;
    width: 420px;
    max-width: 100%;
    opacity: 0;
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.doc-block.visible {
    opacity: 1;
    transform: translateX(0) !important;
}

.side-left {
    margin-right: auto;
    transform: translateX(-40px);
}

.side-right {
    margin-left: auto;
    transform: translateX(40px);
}

/* Tilt 3D on hover */
.doc-inner {
    transition: transform 0.2s ease;
}

/* ---- Manuscript Page ---- */
.manuscript-page .doc-inner {
    background: var(--aged-vellum);
    padding: 32px 32px 32px 40px;
    position: relative;
    clip-path: polygon(0% 0%, 98% 1%, 100% 3%, 99% 15%, 100% 30%, 98% 50%, 100% 70%, 99% 85%, 100% 97%, 97% 100%, 2% 100%, 0% 98%);
    background-image: repeating-radial-gradient(
        circle at 50% 50%,
        rgba(139,115,85,0.02) 0px,
        transparent 1px,
        transparent 3px
    );
}

.manuscript-page .doc-inner::before {
    content: '';
    position: absolute;
    left: 28px;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(140,59,59,0.15);
}

.era-title {
    font-family: 'Playfair Display SC', serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3rem);
    letter-spacing: 0.15em;
    color: var(--burnt-umber-ink);
    margin-bottom: 24px;
}

.manuscript-page p {
    margin-bottom: 1em;
}

/* ---- Index Card ---- */
.index-card .doc-inner {
    background: var(--foxed-cream);
    border-radius: 8px;
    padding: 24px;
    width: 380px;
    max-width: 100%;
    max-height: 280px;
    overflow: hidden;
    box-shadow: 4px 4px 12px rgba(59,47,47,0.15);
}

.card-header-line {
    height: 1px;
    background: var(--gilt-edge);
    margin-bottom: 16px;
}

.card-title {
    font-family: 'Courier Prime', monospace;
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    color: var(--deep-brown);
    margin-bottom: 12px;
    text-transform: uppercase;
}

.card-text {
    font-family: 'Courier Prime', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--deep-brown);
    margin-bottom: 12px;
}

.card-ref {
    font-family: 'Courier Prime', monospace;
    font-size: 0.75rem;
    color: var(--marginalia-sepia);
    display: block;
}

/* ---- Newspaper Clipping ---- */
.newspaper-clipping .doc-inner {
    background: var(--aged-vellum);
    padding: 24px;
    clip-path: polygon(1% 0%, 100% 1%, 99% 100%, 0% 99%);
    transform: rotate(-0.5deg);
}

.newspaper-headline {
    font-family: 'Playfair Display SC', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 3vw, 2rem);
    letter-spacing: 0.1em;
    color: var(--burnt-umber-ink);
    margin-bottom: 16px;
    border-bottom: 1px solid var(--archive-dust);
    padding-bottom: 8px;
}

.newspaper-columns {
    column-count: 2;
    column-gap: 1.5rem;
    column-rule: 1px solid var(--archive-dust);
}

.newspaper-columns p {
    font-size: 0.9rem;
    margin-bottom: 0.8em;
}

/* ---- Sealed Envelope ---- */
.sealed-envelope .doc-inner {
    background: var(--archive-dust);
    border: 1px solid var(--saddle-leather);
    padding: 24px;
    position: relative;
    cursor: pointer;
}

.sealed-envelope .doc-inner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: var(--archive-dust);
    border-bottom: 1px solid var(--saddle-leather);
    clip-path: polygon(0 0, 50% 100%, 100% 0);
    transition: transform 0.5s ease;
    transform-origin: top center;
}

.sealed-envelope.opened .doc-inner::before {
    transform: perspective(300px) rotateX(-160deg);
}

.envelope-body {
    text-align: center;
    padding-top: 32px;
}

.wax-seal {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, rgba(180,80,80,0.9) 0%, var(--cartographer-red) 40%, var(--saddle-leather) 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    transition: transform 0.2s ease, box-shadow 0.3s ease;
}

.wax-seal:hover {
    transform: scale(1.08);
    box-shadow: 0 0 16px rgba(200,176,120,0.2);
}

.seal-letter {
    font-family: 'Playfair Display SC', serif;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--aged-vellum);
}

.envelope-text {
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: 0.95rem;
    color: var(--burnt-umber-ink);
}

.envelope-hidden {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease;
    margin-top: 16px;
}

.sealed-envelope.opened .envelope-hidden {
    max-height: 300px;
}

.envelope-hidden p {
    font-size: 0.9rem;
    color: var(--body-text);
}

/* ---- Marginalia Track ---- */
.marginalia-track {
    position: fixed;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 80px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    z-index: 10;
}

.margin-annotation {
    font-family: 'Caveat', cursive;
    font-size: 0.75rem;
    color: var(--marginalia-sepia);
    opacity: 0.7;
    display: block;
    line-height: 1.4;
}

.margin-annotation.rotated {
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

/* ---- Compass Scroll Indicator ---- */
.compass-scroll-indicator {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 50;
    opacity: 0.7;
}

#compass-needle {
    transform-origin: 24px 24px;
    transition: transform 0.2s ease;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .archive-content {
        padding: 60px 20px 80px;
    }

    .timeline-spine {
        left: 20px;
    }

    .doc-block {
        width: 100%;
        margin-left: 40px;
        margin-right: 0;
    }

    .side-left,
    .side-right {
        margin-left: 40px;
        margin-right: 0;
    }

    .timeline-marker {
        left: -20px;
    }

    .marginalia-track {
        display: none;
    }

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

    .index-card .doc-inner {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .atlas-hero {
        padding: 20px;
    }

    .doc-block {
        margin-left: 30px;
    }
}
