/* ============================
   historygrapher.net - Styles
   Hand-drawn cartographic journal
   ============================ */

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

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

body {
    background-color: #FDF5E6;
    color: #4A3520;
    font-family: 'Lora', Georgia, serif;
    font-size: 17px;
    line-height: 1.8;
    overflow-x: hidden;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Caveat', cursive;
    color: #3C2415;
    font-weight: 700;
}

.map-region-label {
    font-family: 'Caveat', cursive;
    font-size: 44px;
    line-height: 1.2;
    font-weight: 700;
    color: #3C2415;
    margin-bottom: 8px;
}

.era-heading {
    font-family: 'Caveat', cursive;
    font-size: 32px;
    line-height: 1.25;
    font-weight: 700;
    color: #3C2415;
    margin-bottom: 24px;
}

.legend-label {
    font-family: 'Caveat', cursive;
    font-size: 22px;
    line-height: 1.3;
    font-weight: 400;
    color: #3C2415;
}

.legend-title {
    font-family: 'Caveat', cursive;
    font-size: 28px;
    font-weight: 700;
    color: #3C2415;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid #C9A87C;
}

.annotation-text {
    font-family: 'Lora', Georgia, serif;
    font-size: 17px;
    line-height: 1.8;
    font-weight: 400;
    color: #4A3520;
    margin-top: 32px;
}

.annotation-text p {
    margin-bottom: 16px;
}

.margin-note {
    font-family: 'Satisfy', cursive;
    font-size: 18px;
    line-height: 1.5;
    color: #7A5A3C;
    margin-top: 40px;
    font-style: italic;
    opacity: 0.85;
}

/* --- Cover Section --- */
.atlas-cover {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #FDF5E6;
    overflow: hidden;
}

/* Cover border animation */
.cover-border {
    position: absolute;
    top: 40px;
    left: 40px;
    right: 40px;
    bottom: 40px;
    pointer-events: none;
}

.cover-border-top,
.cover-border-bottom,
.cover-border-left,
.cover-border-right {
    position: absolute;
    background-color: #3C2415;
}

.cover-border-top,
.cover-border-bottom {
    height: 3px;
    left: 50%;
    width: 0;
    transform: translateX(-50%);
    animation: borderExpand-h 1.2s ease-out 0.4s forwards;
}

.cover-border-top { top: 0; }
.cover-border-bottom { bottom: 0; }

.cover-border-left,
.cover-border-right {
    width: 3px;
    top: 50%;
    height: 0;
    transform: translateY(-50%);
    animation: borderExpand-v 1.2s ease-out 0.4s forwards;
}

.cover-border-left { left: 0; }
.cover-border-right { right: 0; }

@keyframes borderExpand-h {
    to { width: 100%; }
}

@keyframes borderExpand-v {
    to { height: 100%; }
}

/* Compass Rose */
.compass-rose-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120px;
    height: 120px;
    opacity: 0;
    animation: fadeIn 0.8s ease-out 0.8s forwards;
}

.compass-rose {
    width: 120px;
    height: 120px;
    animation: rotateCompass 60s linear infinite;
}

@keyframes rotateCompass {
    to { transform: rotate(360deg); }
}

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

/* Cover Title */
.cover-title-wrapper {
    position: relative;
    z-index: 2;
    text-align: center;
}

.cover-title {
    margin-bottom: 8px;
}

.title-svg {
    width: 700px;
    max-width: 90vw;
    height: 70px;
}

.title-svg text {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawText 2.5s ease-out 1.2s forwards;
    fill: #3C2415;
}

@keyframes drawText {
    0% {
        stroke-dashoffset: 2000;
        fill-opacity: 0;
    }
    60% {
        fill-opacity: 0;
    }
    100% {
        stroke-dashoffset: 0;
        fill-opacity: 1;
    }
}

.cover-subtitle {
    font-family: 'Lora', Georgia, serif;
    font-size: 28px;
    color: #7A5A3C;
    opacity: 0;
    animation: fadeInFull 0.4s ease-out 3.7s forwards;
    text-align: center;
}

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

/* Cover annotation */
.cover-annotation {
    font-family: 'Satisfy', cursive;
    font-size: 16px;
    color: #7A5A3C;
    opacity: 0;
    animation: fadeInPartial 0.6s ease-out 4.1s forwards;
    position: absolute;
    bottom: 80px;
    right: 80px;
}

@keyframes fadeInPartial {
    to { opacity: 0.6; }
}

/* --- Ink Splatters --- */
.ink-splatter-group {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
}

.ink-dot {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, #3C2415 0%, transparent 70%);
    display: block;
}

/* --- Terrain Sections --- */
.terrain-section {
    position: relative;
    min-height: 100vh;
    padding: 120px 0;
    overflow: hidden;
}

/* Contour Lines */
.contour-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.contour-path {
    fill: none;
    stroke: #C9A87C;
    stroke-width: 1;
    opacity: 0.3;
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke 0.3s ease;
}

.contour-path.drawn {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1.5s ease-out, stroke 0.3s ease;
}

/* Terrain grid - magazine spread */
.terrain-grid {
    position: relative;
    z-index: 1;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 40px;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 40px;
}

.map-panel {
    grid-column: 1 / 5;
    position: relative;
    min-height: 400px;
    padding: 40px;
}

.annotation-column {
    grid-column: 5 / 7;
    padding: 40px 20px;
}

/* Map illustration */
.map-illustration {
    position: relative;
    width: 100%;
    margin-top: 20px;
}

.map-drawing {
    width: 100%;
    height: auto;
}

/* Trail paths */
.trail-path {
    position: absolute;
    top: 60px;
    left: 40px;
    width: calc(100% - 80px);
    height: 300px;
    pointer-events: none;
    z-index: 2;
}

.dotted-trail {
    fill: none;
    stroke: #7A5A3C;
    stroke-width: 1.5;
    stroke-dasharray: 2 6;
    stroke-dashoffset: 500;
    opacity: 0.7;
}

.dotted-trail.drawn {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1.2s ease-out;
}

.dotted-trail:hover {
    stroke-width: 2.5;
    transition: stroke-width 0.3s ease;
}

/* Legend Boxes */
.legend-box {
    background-color: #E8D5B7;
    padding: 24px;
    position: relative;
    border: 2px solid #C9A87C;
    outline: 1px solid #C9A87C;
    outline-offset: 4px;
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.legend-box.visible {
    opacity: 1;
    transform: scale(1);
}

.legend-entry {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    cursor: default;
    transition: background-color 0.3s ease;
    padding-left: 4px;
    padding-right: 4px;
    border-radius: 2px;
}

.legend-entry:hover {
    background-color: rgba(91, 127, 59, 0.08);
}

.legend-icon {
    width: 24px;
    height: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.legend-icon svg {
    width: 100%;
    height: 100%;
}

/* Scroll reveal */
.scroll-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.7s ease-out, transform 0.7s ease-out;
}

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

/* Map region hover - contour color shift */
.map-panel:hover ~ .contour-lines .contour-path,
.terrain-section:hover .contour-path.drawn {
    stroke: #5B7F3B;
    transition: stroke 0.3s ease;
}

/* --- Cartographer's Note --- */
.cartographers-note {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    overflow: hidden;
}

.note-content {
    max-width: 680px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.note-paper {
    background-color: #E8D5B7;
    padding: 60px 48px;
    border: 2px solid #C9A87C;
    outline: 1px solid #C9A87C;
    outline-offset: 4px;
    position: relative;
}

.note-paper::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    border: 1px solid #C9A87C;
    opacity: 0.4;
    pointer-events: none;
}

.note-heading {
    font-family: 'Caveat', cursive;
    font-size: 36px;
    font-weight: 700;
    color: #3C2415;
    margin-bottom: 32px;
    text-align: center;
}

.note-body {
    font-family: 'Lora', Georgia, serif;
    font-size: 17px;
    line-height: 1.8;
    color: #4A3520;
}

.note-body p {
    margin-bottom: 20px;
}

.note-body p:first-child {
    font-family: 'Satisfy', cursive;
    font-size: 20px;
    color: #7A5A3C;
}

.note-signature {
    font-family: 'Lora', Georgia, serif;
    font-size: 17px;
    color: #4A3520;
    margin-top: 32px;
}

.note-signoff {
    font-family: 'Satisfy', cursive;
    font-size: 28px;
    color: #7A5A3C;
    margin-top: 8px;
}

/* Note compass */
.note-compass {
    position: absolute;
    bottom: 60px;
    right: 60px;
    opacity: 0.2;
}

.compass-rose-small {
    width: 80px;
    height: 80px;
    animation: rotateCompass 60s linear infinite;
}

/* --- Cover splatters position fix --- */
.cover-splatters {
    z-index: 1;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .terrain-grid {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .map-panel {
        grid-column: 1 / -1;
    }

    .annotation-column {
        grid-column: 1 / -1;
        padding: 0 20px;
    }

    .cover-annotation {
        right: 40px;
        bottom: 40px;
        font-size: 14px;
    }

    .title-svg {
        width: 500px;
    }

    .map-region-label {
        font-size: 36px;
    }

    .era-heading {
        font-size: 26px;
    }
}

@media (max-width: 600px) {
    .cover-border {
        top: 20px;
        left: 20px;
        right: 20px;
        bottom: 20px;
    }

    .title-svg {
        width: 320px;
        height: 50px;
    }

    .terrain-section {
        padding: 80px 0;
    }

    .terrain-grid {
        padding: 0 20px;
    }

    .map-panel {
        padding: 20px;
    }

    .note-paper {
        padding: 40px 28px;
    }

    .map-region-label {
        font-size: 30px;
    }

    .era-heading {
        font-size: 22px;
    }

    .legend-label {
        font-size: 18px;
    }

    .cover-subtitle {
        font-size: 22px;
    }
}
