/* ============================================================
   Address Envoy v2 - Diplomatic Correspondence Infrastructure
   ============================================================ */

/* Custom Properties (all DESIGN.md palette colors) */
:root {
    --bg-parchment: #f4f1ec;
    --bg-slate: #1c2333;
    --text-charcoal: #2d2d2d;
    --text-inverse: #e8e4dd;
    --accent-copper: #9b7d5a;
    --accent-brass: #7a6544;
    --border-gray: #c8c4bc;
    --seal-red: #8b3a3a;

    --font-headline: 'Space Grotesk', sans-serif;
    --font-body: 'IBM Plex Sans', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.72;
    color: var(--text-charcoal);
    background-color: var(--bg-parchment);
    overflow-x: hidden;
}

/* ============================================================
   Navigation
   ============================================================ */

.nav {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    padding: 24px;
}

.nav-logo {
    background: none;
    border: none;
    cursor: pointer;
    display: inline-block;
    position: relative;
    padding: 4px 0;
}

.nav-logo-text {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-charcoal);
    transition: color 0.3s ease;
}

/* Copper underline beneath AE logo */
.nav-logo::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: var(--accent-copper);
}

.nav-panel {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.25s ease-out, opacity 0.25s ease-out;
    margin-top: 16px;
}

.nav-panel.is-open {
    max-height: 60px;
    opacity: 1;
}

.nav-links {
    display: flex;
    gap: 32px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-gray);
}

.nav-link {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-charcoal);
    text-decoration: none;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--accent-copper);
}

/* Nav color inversion on dark backgrounds */
.nav--inverted .nav-logo-text,
.nav--inverted .nav-link {
    color: var(--text-inverse);
}

/* ============================================================
   Copper Thread (continuous chain-of-custody line)
   ============================================================ */

.copper-thread {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

#copper-path {
    stroke-dasharray: 10000;
    stroke-dashoffset: 10000;
    transition: stroke-dashoffset 0.05s linear;
}

/* ============================================================
   Sections - General
   ============================================================ */

.section {
    position: relative;
    min-height: 100vh;
    width: 100%;
    z-index: 2;
}

/* ============================================================
   Fade Reveal Animation
   ============================================================ */

.fade-reveal {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

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

/* ============================================================
   Section 1: Opening (Split Screen - Sealed State)
   ============================================================ */

.section-opening {
    overflow: hidden;
}

.split-grid {
    display: grid;
    min-height: 100vh;
    width: 100%;
    position: relative;
}

.split-grid--opening {
    grid-template-columns: 55fr 45fr;
}

.split-left {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background-color: var(--bg-parchment);
}

.split-right {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background-color: var(--bg-slate);
}

.split-title {
    font-family: var(--font-headline);
    font-size: clamp(2rem, 5vw, 4.5rem);
    letter-spacing: 0.02em;
}

.split-title--light {
    font-weight: 500;
    color: var(--text-charcoal);
}

.split-title--dark {
    font-weight: 300;
    color: var(--text-inverse);
}

/* Copper Divider (vertical line between split halves) */
.split-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 55%;
    width: 1px;
    background-color: var(--accent-copper);
    transform-origin: center;
    z-index: 5;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

/* ============================================================
   Section 2: Privacy Thesis (Unsealed State)
   ============================================================ */

.section-thesis {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-parchment);
    position: relative;
}

.thesis-container {
    max-width: 520px;
    padding: 48px 24px;
    margin-inline: auto;
    text-align: center;
    position: relative;
    z-index: 3;
}

.thesis-text {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--text-charcoal);
    line-height: 1.72;
}

/* Ruled ledger lines (consulate registry evocation) */
.ledger-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: linear-gradient(transparent 47px, rgba(200, 196, 188, 0.4) 47px, rgba(200, 196, 188, 0.4) 48px, transparent 48px);
    background-size: 100% 48px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
}

.ledger-lines.is-visible {
    opacity: 1;
}

/* ============================================================
   Sections 3-5: How It Works (Three Stages)
   ============================================================ */

.section-stage {
    display: flex;
    align-items: center;
    background-color: var(--bg-parchment);
    position: relative;
}

.split-grid--stage {
    grid-template-columns: 55fr 45fr;
    width: 100%;
}

.split-grid--reversed {
    grid-template-columns: 45fr 55fr;
}

.stage-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background-color: var(--bg-parchment);
}

.stage-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px 64px;
    background-color: var(--bg-parchment);
}

.split-right-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background-color: var(--bg-parchment);
}

.split-left-content {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    background-color: var(--bg-parchment);
}

.split-right-content.stage-text,
.split-left-content.stage-text {
    flex-direction: column;
    align-items: flex-start;
    padding: 48px 64px;
}

.stage-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-copper);
    margin-bottom: 12px;
    display: block;
}

.stage-heading {
    font-family: var(--font-headline);
    font-weight: 500;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.02em;
    color: var(--text-charcoal);
    margin-bottom: 24px;
}

.stage-body {
    font-family: var(--font-body);
    font-weight: 400;
    color: var(--text-charcoal);
    max-width: 520px;
    line-height: 1.72;
}

/* Envelope Schematics (technical SVG line drawings) */
.envelope-schematic {
    width: 100%;
    max-width: 400px;
    height: auto;
}

.envelope-schematic--centered {
    max-width: 600px;
}

/* Path-draw animation for SVG lines */
.env-line {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 0.6s ease;
}

.env-line.is-drawn {
    stroke-dashoffset: 0;
}

.env-text {
    opacity: 0;
    transition: opacity 0.4s ease 0.5s;
}

.env-text.is-drawn {
    opacity: 1;
}

/* Stage 3: Merged centered layout */
.section-stage--merged {
    display: flex;
    align-items: center;
    justify-content: center;
}

.stage-merged-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 48px 24px;
    max-width: 800px;
    margin-inline: auto;
    gap: 48px;
}

.stage-merged-text {
    text-align: center;
}

.stage-merged-text .stage-body {
    margin-inline: auto;
}

/* ============================================================
   Section 6: Trust Indicators (asymmetric vertical rhythm)
   ============================================================ */

.section-trust {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background-color: var(--bg-parchment);
    min-height: 60vh;
    position: relative;
}

.trust-block {
    max-width: 520px;
    padding: 0 24px;
    margin-inline: auto;
    position: relative;
}

/* Top-third placement */
.trust-block--top {
    padding-top: 15vh;
}

/* Center placement */
.trust-block--center {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 25vh;
}

.section-trust--middle {
    align-items: center;
}

/* Bottom-third placement */
.section-trust--bottom {
    align-items: flex-end;
}

.trust-block--bottom {
    padding-bottom: 15vh;
}

.trust-statement {
    font-family: var(--font-headline);
    font-weight: 300;
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    letter-spacing: 0.02em;
    color: var(--text-charcoal);
    text-align: center;
    line-height: 1.5;
}

/* Wax Seal - the ONLY colored element on the page */
.wax-seal {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #a34545, var(--seal-red) 50%, #6b2a2a);
    box-shadow: 0 2px 8px rgba(139, 58, 58, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 32px;
    transform: scale(0);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wax-seal.is-visible {
    transform: scale(1);
}

.wax-seal:hover {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

.wax-seal-text {
    font-family: var(--font-mono);
    font-size: 0.625rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    color: var(--text-inverse);
    text-transform: uppercase;
}

/* ============================================================
   Section 7: Closing (Mirror Split Screen - Resealed State)
   ============================================================ */

.section-closing {
    overflow: hidden;
}

.split-grid--closing {
    grid-template-columns: 45fr 55fr;
}

.split-left--dark {
    background-color: var(--bg-slate);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.split-right--light {
    background-color: var(--bg-parchment);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

.split-grid--closing .split-divider {
    left: 45%;
}

.closing-tagline-part {
    font-family: var(--font-headline);
    font-weight: 300;
    font-size: clamp(1.25rem, 2.5vw, 2rem);
    letter-spacing: 0.02em;
}

.split-left--dark .closing-tagline-part {
    color: var(--text-inverse);
}

.split-right--light .closing-tagline-part {
    color: var(--text-charcoal);
}

/* ============================================================
   Responsive (below 768px: stacked layout)
   ============================================================ */

@media (max-width: 768px) {
    /* Opening and closing splits become stacked */
    .split-grid--opening,
    .split-grid--closing {
        grid-template-columns: 1fr;
    }

    .split-grid--opening .split-left,
    .split-grid--opening .split-right {
        min-height: 50vh;
    }

    .split-grid--closing .split-left--dark,
    .split-grid--closing .split-right--light {
        min-height: 50vh;
    }

    /* Copper divider becomes horizontal */
    .split-divider {
        top: auto;
        bottom: 50%;
        left: 0 !important;
        right: 0;
        width: 100%;
        height: 1px;
    }

    /* Stage splits become stacked */
    .split-grid--stage,
    .split-grid--reversed {
        grid-template-columns: 1fr;
    }

    .stage-diagram {
        min-height: 40vh;
    }

    .stage-text,
    .split-right-content.stage-text,
    .split-left-content.stage-text {
        padding: 32px 24px;
    }

    /* Nav links stack vertically on mobile */
    .nav-links {
        flex-direction: column;
        gap: 16px;
    }

    .nav-panel.is-open {
        max-height: 200px;
    }
}
