/* =========================================================
   diplomacy.bar - Pop-Art Diplomatic Dossier
   ========================================================= */

/* --- CSS Custom Properties --- */
:root {
    --desk-mahogany: #4A0E0E;
    --dossier-night: #2B0A0A;
    --aged-vellum: #F2E6D0;
    --foxed-parchment: #E8D5B0;
    --carbon-black: #1A1412;
    --diplomatic-seal: #C41E3A;
    --treaty-gilt: #C4943A;
    --fountain-pen: #1B3A5C;
    --censored: #0D0D0D;

    --font-display: 'Alfa Slab One', serif;
    --font-heading: 'Bitter', serif;
    --font-body: 'Special Elite', monospace;
    --font-stamp: 'Rubik Mono One', monospace;
}

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background-color: var(--desk-mahogany);
    color: var(--carbon-black);
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    position: relative;
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Circuit Traces SVG --- */
.circuit-traces {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    pointer-events: none;
    opacity: 0.5;
}

.trace {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: trace-flow 20s linear infinite;
}

.trace-2 { animation-delay: -4s; }
.trace-3 { animation-delay: -8s; }
.trace-4 { animation-delay: -12s; }
.trace-5 { animation-delay: -16s; }

@keyframes trace-flow {
    0% { stroke-dashoffset: 1000; }
    100% { stroke-dashoffset: -1000; }
}

/* --- Tab Navigation --- */
.dossier-tabs {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tab {
    display: block;
    padding: 10px 14px 10px 18px;
    font-family: var(--font-heading);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-decoration: none;
    color: var(--carbon-black);
    background: var(--foxed-parchment);
    clip-path: polygon(30% 0%, 100% 0%, 100% 100%, 30% 100%, 0% 50%);
    transition: transform 0.3s ease, background 0.3s ease, color 0.3s ease;
    transform: translateX(10px);
}

.tab:hover,
.tab.active {
    transform: translateX(0);
    background: var(--aged-vellum);
    color: var(--diplomatic-seal);
}

.tab.active {
    background: var(--diplomatic-seal);
    color: var(--aged-vellum);
}

/* --- Desk Surface Texture --- */
.desk-surface {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 30% 40%, rgba(74,14,14,0.8) 0%, transparent 70%),
        radial-gradient(circle at 70% 60%, rgba(43,10,10,0.6) 0%, transparent 60%),
        linear-gradient(135deg, var(--desk-mahogany) 0%, var(--dossier-night) 100%);
    z-index: 0;
}

.desk-surface::after {
    content: '';
    position: absolute;
    inset: 0;
    background: 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.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
    opacity: 0.5;
    z-index: 1;
}

/* --- Desk Gap Between Sections --- */
.desk-gap {
    height: clamp(30vh, 40vh, 50vh);
    position: relative;
    background:
        radial-gradient(circle at 50% 50%, rgba(74,14,14,0.3) 0%, transparent 70%),
        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.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}

/* --- Scenes --- */
.scene {
    position: relative;
    z-index: 5;
}

/* SCENE 1: DOSSIER COVER */
.scene-cover {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    z-index: 10;
}

.dossier-folder {
    position: relative;
    width: clamp(320px, 60vw, 700px);
    height: clamp(400px, 70vh, 600px);
    z-index: 5;
}

.folder-cover {
    position: absolute;
    left: 0;
    width: 100%;
    height: 50%;
    background: var(--foxed-parchment);
    transition: transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94), clip-path 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden;
}

.folder-cover::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 73% 28%, rgba(139,90,43,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at center, transparent 60%, rgba(74,14,14,0.1) 100%),
        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='1' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
}

.folder-top {
    top: 0;
    border-radius: 4px 4px 0 0;
    clip-path: inset(0 0 0 0);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 2;
}

.folder-top.open {
    clip-path: inset(0 0 100% 0);
    transform: translateY(-30vh);
}

.folder-bottom {
    bottom: 0;
    border-radius: 0 0 4px 4px;
    clip-path: inset(0 0 0 0);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 1;
}

.folder-bottom.open {
    clip-path: inset(100% 0 0 0);
    transform: translateY(30vh);
}

.folder-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 3;
}

.folder-title {
    font-family: var(--font-display);
    font-size: clamp(1.6rem, 4vw, 3rem);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.05;
    color: var(--carbon-black);
    margin-bottom: 0.5rem;
}

.folder-subtitle {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: clamp(1rem, 2vw, 1.4rem);
    color: var(--fountain-pen);
    letter-spacing: 0.02em;
}

/* Classification Stamp */
.stamp {
    position: absolute;
    font-family: var(--font-stamp);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: clamp(0.7rem, 1.2vw, 0.95rem);
    color: var(--diplomatic-seal);
    border: 2px solid var(--diplomatic-seal);
    padding: 4px 12px;
    filter: blur(0.3px);
    opacity: 0;
    transform-origin: center center;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.stamp.visible {
    opacity: 0.85;
}

.stamp-classified {
    top: 15%;
    right: 8%;
    transform: rotate(-12deg);
}

.stamp-review {
    bottom: 8%;
    left: 5%;
    transform: rotate(-8deg);
}

.stamp-eyes-only {
    top: 10%;
    right: 5%;
    transform: rotate(-15deg);
}

.stamp-approved {
    top: 8%;
    right: 8%;
    transform: rotate(-10deg);
}

.stamp-confidential {
    top: 12%;
    right: 6%;
    transform: rotate(-13deg);
}

.stamp-draft {
    top: 10%;
    right: 10%;
    transform: rotate(-9deg);
}

/* Wax Seal */
.wax-seal {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #D4343E 0%, #C41E3A 40%, #8B1528 100%);
    box-shadow:
        inset 0 2px 4px rgba(255,255,255,0.2),
        inset 0 -3px 6px rgba(0,0,0,0.3),
        0 3px 8px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.seal-letter {
    font-family: var(--font-display);
    font-size: 1.6rem;
    color: var(--treaty-gilt);
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.cover-seal {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
}

/* Red String */
.red-string {
    position: absolute;
    bottom: 20%;
    left: 5%;
    width: 60%;
    height: 60px;
    z-index: 3;
    opacity: 0.8;
}

.string-button {
    position: absolute;
    bottom: calc(20% + 15px);
    left: calc(5% + 60% + 5px);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--diplomatic-seal);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    z-index: 3;
}

/* Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    z-index: 10;
    animation: float-down 2s ease-in-out infinite;
}

.scroll-text {
    font-family: var(--font-stamp);
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    color: var(--treaty-gilt);
    display: block;
    margin-bottom: 8px;
}

.scroll-arrow {
    width: 20px;
    height: 20px;
    border-right: 2px solid var(--treaty-gilt);
    border-bottom: 2px solid var(--treaty-gilt);
    transform: rotate(45deg);
    margin: 0 auto;
}

@keyframes float-down {
    0%, 100% { opacity: 0.6; transform: translateX(-50%) translateY(0); }
    50% { opacity: 1; transform: translateX(-50%) translateY(8px); }
}

/* --- Document Panels (shared styles) --- */
.document-panel {
    position: relative;
    background: var(--aged-vellum);
    padding: clamp(30px, 5vw, 60px);
    box-shadow:
        0 1px 3px rgba(0,0,0,0.12),
        0 4px 12px rgba(0,0,0,0.08),
        0 12px 40px rgba(0,0,0,0.06);
    opacity: 0;
    transform: translateY(30px);
    transition:
        transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.4s ease,
        z-index 0s;
    cursor: default;
}

.document-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 73% 28%, rgba(139,90,43,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at center, transparent 60%, rgba(74,14,14,0.12) 100%);
    pointer-events: none;
    border-radius: inherit;
}

.document-panel::after {
    content: '';
    position: absolute;
    inset: 0;
    background: 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='1' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
    border-radius: inherit;
}

/* Fold line */
.document-panel .memo-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 0.5px;
    height: 100%;
    background: rgba(0,0,0,0.04);
    pointer-events: none;
}

.document-panel.visible {
    opacity: 1;
    transform: translateY(0) rotate(var(--rotation, 0deg));
}

.document-panel:hover {
    transform: scale(1.02) rotate(0deg);
    box-shadow:
        0 2px 6px rgba(0,0,0,0.15),
        0 8px 24px rgba(0,0,0,0.12),
        0 20px 60px rgba(0,0,0,0.1);
    z-index: 100;
}

/* --- SCENE 2: Briefing Panel --- */
.scene-briefing {
    z-index: 20;
    padding-bottom: 5vh;
}

.panel-briefing {
    width: clamp(320px, 70vw, 900px);
    margin: 0 auto;
    margin-left: 8vw;
    position: relative;
    z-index: 20;
}

.ben-day-corner {
    position: absolute;
    top: 0;
    right: 0;
    width: 40%;
    height: 40%;
    background: radial-gradient(circle, #C41E3A 1px, transparent 1px);
    background-size: 6px 6px;
    opacity: 0.15;
    mask-image: linear-gradient(135deg, transparent 20%, black 80%);
    -webkit-mask-image: linear-gradient(135deg, transparent 20%, black 80%);
    pointer-events: none;
    z-index: 0;
}

.memo-header {
    border-bottom: 1px solid rgba(26,20,18,0.2);
    padding-bottom: 20px;
    margin-bottom: 30px;
    position: relative;
    z-index: 1;
}

.memo-field {
    font-family: var(--font-body);
    margin-bottom: 4px;
}

.field-label {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
}

.memo-body {
    position: relative;
    z-index: 1;
}

.memo-body p {
    margin-bottom: 1.5em;
}

/* Redaction Bars */
.redaction-bar {
    position: relative;
    width: clamp(40%, 60%, 85%);
    height: 1.1em;
    background: var(--censored);
    border-radius: 1px;
    margin: 0.8em 0;
    z-index: 2;
}

.redaction-flicker {
    animation: redaction-pulse 3s ease-in-out infinite alternate;
}

@keyframes redaction-pulse {
    0% { opacity: 0.95; }
    100% { opacity: 1.0; }
}

.redacted-inline {
    display: inline-block;
    width: 80px;
    height: 0.85em;
    background: var(--censored);
    border-radius: 1px;
    vertical-align: middle;
    margin-left: 4px;
}

/* Margin Annotations */
.margin-annotation {
    position: absolute;
    right: -20px;
    width: clamp(120px, 15vw, 180px);
    z-index: 5;
}

.annotation-1 {
    top: 35%;
    transform: rotate(-3deg);
}

.annotation-2 {
    top: 65%;
    transform: rotate(2deg);
}

.annotation-text {
    font-family: var(--font-body);
    font-size: clamp(0.7rem, 1vw, 0.85rem);
    color: var(--fountain-pen);
    line-height: 1.4;
    display: block;
    border-left: 2px solid var(--fountain-pen);
    padding-left: 8px;
    opacity: 0.8;
}

/* --- SCENE 3: Intelligence Cards --- */
.scene-intelligence {
    z-index: 30;
    padding-bottom: 5vh;
}

.intel-cards {
    position: relative;
    width: clamp(340px, 80vw, 1100px);
    margin: 0 auto;
    padding: 5vh 0;
}

.panel-intel {
    width: clamp(280px, 55vw, 650px);
    position: relative;
    margin-bottom: -8vh;
}

.panel-intel-1 {
    margin-left: 5vw;
    z-index: 31;
    background: var(--aged-vellum);
}

.panel-intel-2 {
    margin-left: 20vw;
    z-index: 32;
    background: var(--foxed-parchment);
}

.panel-intel-3 {
    margin-left: 3vw;
    z-index: 33;
    background: var(--aged-vellum);
}

.panel-intel-4 {
    margin-left: 15vw;
    z-index: 34;
    background: var(--foxed-parchment);
}

/* Coffee stain on intel card 2 */
.panel-intel-2::before {
    background:
        radial-gradient(circle at 20% 70%, rgba(139,90,43,0.1) 0%, transparent 40%),
        radial-gradient(circle at 73% 28%, rgba(139,90,43,0.08) 0%, transparent 50%),
        radial-gradient(ellipse at center, transparent 60%, rgba(74,14,14,0.12) 100%);
}

/* Ben-Day dots on intel card 3 */
.panel-intel-3::after {
    background:
        radial-gradient(circle, rgba(74,14,14,0.06) 1px, transparent 1px),
        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='1' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    background-size: 10px 10px, auto;
}

.panel-header {
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(26,20,18,0.15);
    padding-bottom: 12px;
}

.section-title {
    font-family: var(--font-display);
    font-size: clamp(1.8rem, 5vw, 3.5rem);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.05;
    color: var(--carbon-black);
}

.panel-body p {
    margin-bottom: 1.2em;
}

/* --- SCENE 4: Treaty --- */
.scene-treaty {
    z-index: 40;
    padding-bottom: 5vh;
}

.panel-treaty {
    width: clamp(400px, 80vw, 1000px);
    margin: 0 auto;
    z-index: 40;
    background: var(--aged-vellum);
}

.treaty-border {
    border: 3px solid var(--treaty-gilt);
    padding: clamp(30px, 6vw, 70px);
    position: relative;
}

.corner-flourish {
    position: absolute;
    width: 40px;
    height: 40px;
}

.corner-tl { top: -3px; left: -3px; }
.corner-tr { top: -3px; right: -3px; }
.corner-bl { bottom: -3px; left: -3px; }
.corner-br { bottom: -3px; right: -3px; }

.treaty-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 4rem);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.05;
    color: var(--carbon-black);
    text-align: center;
    margin-bottom: 2rem;
}

.treaty-text {
    font-family: var(--font-heading);
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    line-height: 1.55;
    letter-spacing: 0.02em;
    color: var(--carbon-black);
}

.treaty-text p {
    margin-bottom: 1.5em;
    text-indent: 2em;
}

.treaty-text p:first-child {
    text-indent: 0;
}

.treaty-signature {
    margin-top: 3rem;
    text-align: center;
}

.signature-line {
    width: 200px;
    height: 1px;
    background: var(--carbon-black);
    margin: 0 auto 8px;
}

.signature-label {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--carbon-black);
}

.treaty-seal {
    margin: 2rem auto 0;
}

/* --- SCENE 5: The Desk --- */
.scene-desk {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 50;
    background:
        radial-gradient(circle at 50% 50%, rgba(74,14,14,0.4) 0%, transparent 60%),
        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.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.08'/%3E%3C/svg%3E");
}

.desk-final {
    text-align: center;
}

.desk-headline {
    font-family: var(--font-display);
    font-size: clamp(2.8rem, 8vw, 7rem);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.05;
    color: var(--treaty-gilt);
    margin-bottom: 2rem;
}

.desk-info {
    margin-bottom: 2.5rem;
}

.desk-contact {
    font-family: var(--font-body);
    font-size: clamp(0.85rem, 1.5vw, 1.05rem);
    color: var(--foxed-parchment);
    line-height: 1.75;
    opacity: 0.8;
}

.footer-seal {
    margin: 0 auto;
}

/* --- Stamp Animation --- */
.stamp.stamp-pop {
    animation: stamp-appear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes stamp-appear {
    0% {
        opacity: 0;
        transform: rotate(var(--stamp-rotation, -12deg)) scale(1.15);
    }
    100% {
        opacity: 0.85;
        transform: rotate(var(--stamp-rotation, -12deg)) scale(1);
    }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .dossier-tabs {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        transform: none;
        flex-direction: row;
        justify-content: center;
        background: var(--dossier-night);
        padding: 8px 0;
        gap: 2px;
    }

    .tab {
        clip-path: none;
        padding: 8px 12px;
        font-size: 0.6rem;
        transform: none;
        border-radius: 3px;
    }

    .tab:hover,
    .tab.active {
        transform: none;
    }

    .panel-briefing {
        margin-left: 5vw;
        margin-right: 5vw;
        width: auto;
    }

    .panel-intel {
        width: clamp(280px, 85vw, 500px);
    }

    .panel-intel-1 { margin-left: 3vw; }
    .panel-intel-2 { margin-left: 8vw; }
    .panel-intel-3 { margin-left: 2vw; }
    .panel-intel-4 { margin-left: 6vw; }

    .margin-annotation {
        position: relative;
        right: auto;
        top: auto;
        width: 100%;
        margin: 1em 0;
        transform: rotate(-1deg);
    }

    .panel-treaty {
        width: clamp(300px, 90vw, 600px);
    }

    .corner-flourish {
        width: 25px;
        height: 25px;
    }

    .dossier-folder {
        width: clamp(280px, 85vw, 500px);
    }

    .red-string {
        display: none;
    }

    .string-button {
        display: none;
    }
}

/* --- Ben-Day Dot Zones (applied via utility) --- */
.ben-day-tight {
    background-image: radial-gradient(circle, #C41E3A 1px, transparent 1px);
    background-size: 4px 4px;
}

.ben-day-loose {
    background-image: radial-gradient(circle, #C41E3A 1px, transparent 1px);
    background-size: 10px 10px;
}

.ben-day-subtle {
    background-image: radial-gradient(circle, var(--desk-mahogany) 1px, transparent 1px);
    background-size: 10px 10px;
    opacity: 0.1;
}
