/* ===================================================
   diplomacy.quest — Cartographic War Room
   =================================================== */

/* --- Palette Reference (DESIGN.md) ---
   Parchment Ground:   #F2E8D5
   Deep Ink:           #1C1A14
   Sepia Line:         #8B7355
   Disputed Red:       #9B3A3A
   Treaty Green:       #3A5A3A
   Coastal Blue:       #4A6A7A
   Faded Annotation:   #7A7060
   Warm Highlight:     #D4A853
   Parchment Aged:     #E8DCC5
   --- */

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

html {
    overflow: hidden;
    height: 100%;
}

body {
    background: #F2E8D5;
    color: #1C1A14;
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.25rem);
    line-height: 1.75;
    height: 100%;
    overflow: hidden;
}

/* --- SVG Filters (hidden) --- */
.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Background Plane (0.3x parallax) --- */
.background-plane {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    will-change: transform;
    background: linear-gradient(135deg, #F2E8D5 0%, #E8DCC5 100%);
}

.topo-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.5;
}

/* --- Mid-ground Plane (0.6x parallax) --- */
.midground-plane {
    position: fixed;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    will-change: transform;
    opacity: 0.4;
}

.grid-svg {
    width: 100%;
    height: 100%;
}

/* --- Scroll Container --- */
.scroll-container {
    position: relative;
    width: 100%;
    height: 100%;
    overflow-x: scroll;
    overflow-y: hidden;
    z-index: 2;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.scroll-container::-webkit-scrollbar {
    display: none;
}

.scroll-canvas {
    display: flex;
    height: 100%;
    width: max-content;
}

/* --- Territories --- */
.territory {
    position: relative;
    height: 100%;
    flex-shrink: 0;
    scroll-snap-align: center;
    display: flex;
    align-items: stretch;
}

.territory-1 { width: 100vw; }
.territory-2 { width: 140vw; }
.territory-3 { width: 120vw; }
.territory-4 { width: 160vw; }

/* Territorial wash zones — Treaty Green #3A5A3A, Coastal Blue #4A6A7A at 8% */
.territory[data-wash="green"] {
    background: #3A5A3A0F;
}

.territory[data-wash="blue"] {
    background: #4A6A7A0F;
}

/* --- Territory Content Layout (5:3 off-center grid) --- */
.territory-content {
    display: grid;
    grid-template-columns: 5fr 3fr;
    gap: clamp(2rem, 4vw, 5rem);
    align-content: center;
    padding: 8vh 6vw 8vh 8vw;
    width: 100%;
    height: 100%;
}

.territory-primary {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-self: end;
    padding-bottom: 4vh;
}

.territory-secondary {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-self: start;
    padding-top: 6vh;
    gap: 2rem;
}

/* --- Territory Headings --- */
.territory-heading {
    font-family: 'Bodoni Moda', serif;
    font-weight: 700;
    font-size: clamp(3rem, 7vw, 8rem);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    line-height: 1.05;
    color: #1C1A14;
    margin-bottom: clamp(1.5rem, 3vw, 3rem);
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 600ms ease-out, transform 600ms ease-out;
}

.territory-heading.revealed {
    opacity: 1;
    transform: translateX(0);
}

/* --- Treaty Text --- */
.treaty-text {
    max-width: 38ch;
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 600ms ease-out 120ms, transform 600ms ease-out 120ms;
}

.treaty-text.revealed {
    opacity: 1;
    transform: translateX(0);
}

.treaty-text p {
    margin-bottom: 1.25em;
    color: #1C1A14;
}

.treaty-text p:last-child {
    margin-bottom: 0;
}

/* --- Ruling Pen Underlines --- */
.ruling-pen-underline {
    position: relative;
    display: inline;
}

.ruling-pen-underline::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 100%;
    height: 2px;
    background: #8B7355;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 800ms ease-in-out;
}

.ruling-pen-underline.drawn::after {
    transform: scaleX(1);
}

/* --- Annotations / Marginalia --- */
.annotation {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 600ms ease-out, transform 600ms ease-out;
}

.annotation.revealed {
    opacity: 1;
    transform: translateX(0);
}

.annotation-coord {
    font-family: 'Inconsolata', monospace;
    font-size: 0.75rem;
    font-weight: 300;
    color: #7A7060;
    letter-spacing: 0.05em;
}

.annotation-note {
    font-family: 'Inconsolata', monospace;
    font-size: 0.75rem;
    font-weight: 400;
    color: #7A7060;
    line-height: 1.6;
    max-width: 30ch;
}

/* --- Treaty Seals --- */
.treaty-seal {
    width: 60px;
    height: 60px;
    margin-top: 2rem;
    cursor: default;
    position: relative;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 300ms ease-out, transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.treaty-seal.revealed {
    opacity: 1;
    transform: scale(1);
}

.treaty-seal svg {
    width: 100%;
    height: 100%;
    color: #9B3A3A;
}

.treaty-seal::after {
    content: attr(data-tooltip);
    position: absolute;
    top: -2rem;
    left: 70px;
    font-family: 'Inconsolata', monospace;
    font-size: 0.7rem;
    font-weight: 300;
    color: #7A7060;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 300ms ease-out;
    pointer-events: none;
}

.treaty-seal:hover::after {
    opacity: 1;
}

/* --- Border Lines --- */
.border-line {
    position: absolute;
    right: 0;
    top: 0;
    width: 10px;
    height: 100%;
    z-index: 5;
}

.border-svg {
    width: 100%;
    height: 100%;
}

.border-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    transition: stroke-dashoffset 1200ms ease-in-out;
}

.border-line.drawn .border-path {
    stroke-dashoffset: 0;
}

/* --- Disputed Zones --- */
.disputed-zone {
    width: 20vw;
    height: 100%;
    flex-shrink: 0;
    position: relative;
}

.disputed-zone-1 {
    background: linear-gradient(to right, #3A5A3A0F, #4A6A7A0F);
}

.disputed-zone-2 {
    background: linear-gradient(to right, #4A6A7A0F, #3A5A3A0F);
}

.disputed-zone-3 {
    background: linear-gradient(to right, #3A5A3A0F, #4A6A7A0F);
}

/* --- Compass Rose Navigation --- */
.compass-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    opacity: 0;
}

.compass-container.visible {
    opacity: 1;
    transition: opacity 400ms ease-out;
}

.compass-rose {
    width: 48px;
    height: 48px;
    cursor: pointer;
}

.compass-outer {
    transition: transform 400ms ease-out;
    transform-origin: 50px 50px;
}

.compass-rose:hover .compass-outer {
    transform: rotate(15deg);
}

.compass-needle {
    transition: transform 200ms ease-out;
    transform-origin: 50px 50px;
}

.compass-label {
    cursor: pointer;
    transition: fill 200ms ease-out;
}

.compass-label:hover {
    fill: #D4A853;
}

/* --- Progress Ruler --- */
.progress-ruler {
    width: 48px;
}

.ruler-track {
    position: relative;
    width: 100%;
    height: 4px;
    background: rgba(139, 115, 85, 0.2);
}

.ruler-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: #8B7355;
    transition: width 100ms linear;
}

.ruler-ticks {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
}

.ruler-tick {
    display: block;
    width: 1px;
    height: 6px;
    background: #8B7355;
    opacity: 0.4;
}

/* --- Scroll Hint --- */
.scroll-hint {
    position: fixed;
    bottom: 36px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 600ms ease-out;
    pointer-events: none;
}

.scroll-hint.visible {
    opacity: 1;
}

.scroll-hint.fading {
    opacity: 0;
    transition: opacity 1000ms ease-out;
}

.scroll-hint-text {
    font-family: 'Inconsolata', monospace;
    font-size: 0.7rem;
    font-weight: 300;
    color: #7A7060;
    letter-spacing: 0.3em;
}

.scroll-hint-arrow {
    width: 40px;
    height: 12px;
}

/* --- Compass Rose Draw Animation --- */
@keyframes pathDraw {
    from { stroke-dashoffset: 300; }
    to { stroke-dashoffset: 0; }
}

.compass-container .compass-outer {
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
}

.compass-container.animating .compass-outer {
    animation: pathDraw 800ms ease-out forwards;
}

.compass-container .compass-inner-ring {
    stroke-dasharray: 250;
    stroke-dashoffset: 250;
}

.compass-container.animating .compass-inner-ring {
    animation: pathDraw 600ms ease-out 200ms forwards;
}

.compass-container .compass-ticks line {
    stroke-dasharray: 20;
    stroke-dashoffset: 20;
}

.compass-container.animating .compass-ticks line {
    animation: pathDraw 400ms ease-out 800ms forwards;
}

.compass-container .compass-rhombuses polygon {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
}

.compass-container.animating .compass-rhombuses polygon {
    animation: pathDraw 600ms ease-out 1200ms forwards;
}

@keyframes needleFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.compass-container .compass-needle {
    opacity: 0;
}

.compass-container.animating .compass-needle {
    animation: needleFade 400ms ease-out 1800ms forwards;
}

.compass-container .compass-labels text {
    opacity: 0;
}

.compass-container.animating .compass-labels text {
    animation: needleFade 300ms ease-out 2000ms forwards;
}

/* --- Responsive: Vertical scroll below 768px --- */
@media (max-width: 768px) {
    html {
        overflow: auto;
        overflow-x: hidden;
    }

    body {
        overflow: auto;
        overflow-x: hidden;
    }

    .scroll-container {
        overflow-x: hidden;
        overflow-y: auto;
        height: auto;
        scroll-snap-type: y proximity;
    }

    .scroll-canvas {
        flex-direction: column;
        width: 100%;
        height: auto;
    }

    .territory {
        width: 100% !important;
        height: auto;
        min-height: 100vh;
        scroll-snap-align: start;
    }

    .territory-content {
        grid-template-columns: 1fr;
        padding: 10vh 6% 10vh 12%;
        gap: 3rem;
    }

    .territory-primary {
        align-self: auto;
        padding-bottom: 0;
    }

    .territory-secondary {
        align-self: auto;
        padding-top: 0;
    }

    .territory-heading {
        font-size: clamp(2rem, 10vw, 4rem);
    }

    .disputed-zone {
        width: 100%;
        height: 10vh;
    }

    .border-line {
        right: auto;
        bottom: 0;
        top: auto;
        width: 100%;
        height: 10px;
    }

    .border-svg {
        width: 100%;
        height: 100%;
    }

    .compass-container {
        top: 12px;
        right: 12px;
    }

    .compass-rose {
        width: 32px;
        height: 32px;
    }

    .progress-ruler {
        width: 32px;
    }

    .midground-plane {
        width: 100%;
        height: 200%;
    }

    .scroll-hint {
        display: none;
    }
}
