/* =============================================
   diplomatic.wiki - Styles
   A surreal encyclopedia of diplomatic absurdity
   ============================================= */

/* ---- @property for conic sun animation ---- */
@property --sun-angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

/* ---- CSS Custom Properties ---- */
:root {
    /* Palette */
    --diplomatic-midnight: #0E0E1A;
    --embassy-charcoal: #1A1A2E;
    --consulate-slate: #2A2A3E;
    --parchment: #E8DCC8;
    --faded-ink: #B8B0A0;
    --treaty-gold: #C4A265;
    --diplomatic-vermillion: #8B3A3A;
    --consular-teal: #3A6B6B;
    --spectral-lavender: #4A3A6B;
    --muted-bronze: #6B6358;

    /* Dream panel custom properties */
    --continent-opacity: 0.2;
    --mountain-scale: 1;
    --sun-rotation: 0deg;
    --dream-hue: 0deg;
}

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

html {
    scroll-behavior: smooth;
    background: var(--diplomatic-midnight);
}

body {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-size: 18px;
    line-height: 1.7;
    letter-spacing: 0.01em;
    color: var(--faded-ink);
    background: var(--diplomatic-midnight);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- Grain Overlay ---- */
.grain-svg {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

.grain-overlay {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    z-index: 9999;
    pointer-events: none;
    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.65' 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;
    animation: grainShift 0.5s steps(5) infinite;
}

@keyframes grainShift {
    0% { transform: translate(0, 0); }
    20% { transform: translate(-1px, 1px); }
    40% { transform: translate(1px, -1px); }
    60% { transform: translate(-1px, -1px); }
    80% { transform: translate(1px, 1px); }
    100% { transform: translate(0, 0); }
}

/* ---- Top Treaty Gold Line ---- */
.top-line {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--treaty-gold);
    z-index: 1000;
}

/* ---- Wordmark ---- */
.wordmark {
    position: fixed;
    top: 16px;
    left: 20px;
    font-family: 'Libre Baskerville', serif;
    font-size: 11px;
    font-weight: 400;
    color: var(--parchment);
    z-index: 1000;
    opacity: 1;
    transition: opacity 1.5s ease;
    letter-spacing: 0.02em;
}

.wordmark.faded {
    opacity: 0.3;
}

/* ---- Split-Screen Container ---- */
.split-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
    position: relative;
}

/* ---- Dossier Panel (Left) ---- */
.dossier-panel {
    background: var(--diplomatic-midnight);
    position: relative;
    z-index: 2;
}

/* ---- Wiki Entry ---- */
.wiki-entry {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    padding: 120px 0 80px 0;
    position: relative;
    transition: filter 800ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.wiki-entry.blurred {
    filter: blur(8px);
    opacity: 0.4;
}

.entry-inner {
    max-width: 520px;
    margin: 0 auto;
    padding: 0 40px;
    width: 100%;
}

.entry-content {
    position: relative;
}

/* ---- Entry Titles ---- */
.entry-title {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(32px, 4vw, 56px);
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--parchment);
    margin-bottom: 32px;
    position: relative;
}

/* ---- Entry Body ---- */
.entry-body {
    margin-bottom: 24px;
    position: relative;
}

/* ---- Classified Stamp Overlay ---- */
.classified-stamp::before {
    content: attr(data-stamp);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-12deg);
    font-family: 'DM Sans', sans-serif;
    font-size: 72px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--diplomatic-vermillion);
    opacity: 0.08;
    pointer-events: none;
    white-space: nowrap;
    z-index: 1;
}

/* ---- Marginal Notes ---- */
.marginal-note {
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted-bronze);
    margin-bottom: 16px;
    position: relative;
}

.entry-content > .marginal-note:last-child {
    margin-top: 24px;
    margin-bottom: 0;
    padding-top: 16px;
    border-top: 1px solid rgba(196, 162, 101, 0.15);
}

/* ---- Cross-Reference Cards ---- */
.cross-reference-card {
    width: 180px;
    height: 80px;
    perspective: 600px;
    cursor: pointer;
    margin: 24px 0;
    display: inline-block;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 600ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.cross-reference-card:hover .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    border: 1px solid rgba(196, 162, 101, 0.3);
    background: var(--embassy-charcoal);
}

.card-front {
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--treaty-gold);
}

.card-back {
    transform: rotateY(180deg);
    font-family: 'Cormorant Garamond', serif;
    font-size: 13px;
    font-style: italic;
    color: var(--parchment);
    background: var(--consulate-slate);
    border-color: rgba(196, 162, 101, 0.5);
}

/* ---- Interstitial Zones ---- */
.interstitial-zone {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--consulate-slate);
    position: relative;
    overflow: hidden;
    transition: filter 800ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.interstitial-text {
    font-family: 'Cormorant Garamond', serif;
    font-size: 22px;
    font-style: italic;
    font-weight: 400;
    color: var(--parchment);
    opacity: 0.6;
    text-align: center;
    max-width: 400px;
    padding: 0 40px;
    line-height: 1.6;
}

.interstitial-colophon {
    margin-top: 24px;
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-style: normal;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--treaty-gold);
    opacity: 0.4;
}

.interstitial-final {
    min-height: 50vh;
}

/* ---- Dream Panel (Right) ---- */
.dream-panel {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    background: var(--embassy-charcoal);
    z-index: 1;
}

.dream-inner {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* ---- Dream Landscape ---- */
.dream-landscape {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Continents - overlapping teal circles */
.continent {
    position: absolute;
    border-radius: 50%;
    background: var(--consular-teal);
    transition: opacity 1.2s ease-in-out, transform 1.2s ease-in-out;
}

.continent-1 {
    width: 300px;
    height: 300px;
    top: 15%;
    left: 10%;
    opacity: calc(var(--continent-opacity) * 1.5);
}

.continent-2 {
    width: 200px;
    height: 200px;
    top: 45%;
    right: 15%;
    opacity: var(--continent-opacity);
}

.continent-3 {
    width: 250px;
    height: 250px;
    bottom: 10%;
    left: 30%;
    opacity: calc(var(--continent-opacity) * 0.8);
}

/* Mountains - triangular shapes */
.mountain {
    position: absolute;
    width: 0;
    height: 0;
    transition: transform 1.2s ease-in-out, opacity 1.2s ease-in-out;
}

.mountain-1 {
    border-left: 120px solid transparent;
    border-right: 120px solid transparent;
    border-bottom: 200px solid var(--diplomatic-vermillion);
    opacity: 0.15;
    bottom: 20%;
    left: 10%;
    transform: scale(var(--mountain-scale));
}

.mountain-2 {
    border-left: 80px solid transparent;
    border-right: 80px solid transparent;
    border-bottom: 140px solid var(--diplomatic-vermillion);
    opacity: 0.1;
    bottom: 25%;
    right: 20%;
    transform: scale(var(--mountain-scale));
}

/* Conic Sun */
.conic-sun {
    position: absolute;
    width: 300px;
    height: 300px;
    bottom: 10%;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 50%;
    background: conic-gradient(from var(--sun-angle), #C4A265 0deg, transparent 30deg, #C4A265 60deg, transparent 90deg, #C4A265 120deg, transparent 150deg, #C4A265 180deg, transparent 210deg, #C4A265 240deg, transparent 270deg, #C4A265 300deg, transparent 330deg);
    opacity: 0.15;
    animation: rotateSun 120s linear infinite;
    transition: opacity 1.2s ease-in-out;
}

@keyframes rotateSun {
    from { --sun-angle: 0deg; }
    to { --sun-angle: 360deg; }
}

/* ---- Dream SVG Container ---- */
.dream-svg-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.dream-svg {
    position: absolute;
    width: 60%;
    max-width: 350px;
    height: auto;
    opacity: 0;
    transition: opacity 800ms ease;
}

.dream-svg.active {
    opacity: 1;
}

.draw-path {
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---- Dream State Label ---- */
.dream-state-label {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'DM Sans', sans-serif;
    font-size: 11px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted-bronze);
    opacity: 0.5;
}

/* ---- Spectral Lavender Glow ---- */
.dream-panel::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 400px;
    height: 400px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, var(--spectral-lavender) 0%, transparent 70%);
    opacity: 0.12;
    pointer-events: none;
    border-radius: 50%;
    filter: blur(60px);
    transition: opacity 1.2s ease-in-out;
}

/* ---- Scroll-driven Entry Animations ---- */
.wiki-entry {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 800ms cubic-bezier(0.25, 0.1, 0.25, 1),
                transform 800ms cubic-bezier(0.25, 0.1, 0.25, 1),
                filter 800ms cubic-bezier(0.25, 0.1, 0.25, 1);
}

.wiki-entry.visible {
    opacity: 1;
    transform: translateY(0);
}

.interstitial-zone {
    opacity: 0;
    transition: opacity 800ms ease, filter 800ms ease;
}

.interstitial-zone.visible {
    opacity: 1;
}

/* ---- Responsive: Mobile ---- */
@media (max-width: 768px) {
    .split-container {
        grid-template-columns: 1fr;
    }

    .dream-panel {
        position: relative;
        height: 60vh;
        order: -1;
    }

    .dossier-panel {
        order: 1;
    }

    .entry-title {
        font-size: clamp(24px, 6vw, 36px);
    }

    body {
        font-size: 16px;
    }

    .entry-inner {
        padding: 0 24px;
    }

    .wiki-entry {
        padding: 80px 0 60px 0;
        min-height: auto;
    }

    .interstitial-zone {
        min-height: 40vh;
    }

    .classified-stamp::before {
        font-size: 40px;
    }

    .cross-reference-card {
        width: 160px;
        height: 72px;
    }

    .dream-svg {
        width: 70%;
    }

    .conic-sun {
        width: 200px;
        height: 200px;
    }

    .continent-1 {
        width: 200px;
        height: 200px;
    }

    .continent-2 {
        width: 140px;
        height: 140px;
    }

    .continent-3 {
        width: 180px;
        height: 180px;
    }
}

/* ---- Selection Style ---- */
::selection {
    background: var(--treaty-gold);
    color: var(--diplomatic-midnight);
}

/* ---- Scrollbar Styling ---- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--diplomatic-midnight);
}

::-webkit-scrollbar-thumb {
    background: var(--consulate-slate);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--muted-bronze);
}
