/* ============================================================
   ADDR ENVOY — styles.css
   Diplomatic Embassy Glassmorphism Theme
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --deep-obsidian: #0a0f1a;
    --midnight-slate: #141b2d;
    --parchment-cream: #f0e6d0;
    --warm-silver: #d4d0c8;
    --diplomatic-gold: #c9a84c;
    --seal-crimson: #8b2500;
    --envoy-teal: #2a7f8a;
    --shield-green: #3d8b5f;
    --muted-burgundy: #4a1a2e;
    --deep-edge: #050811;
    --deep-ink: #2a2a3a;

    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(201, 168, 76, 0.2);
    --glass-border-strong: rgba(201, 168, 76, 0.3);
    --glass-inset: inset 0 1px 0 rgba(255, 255, 255, 0.05);

    --spring-ease: cubic-bezier(0.16, 1, 0.3, 1);
    --max-width: 960px;
}

/* --- Reset & Base --- */
*, *::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: 'Source Sans 3', sans-serif;
    font-size: 17px;
    line-height: 1.7;
    color: var(--warm-silver);
    background: var(--deep-obsidian);
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Noise Texture Overlay (frosted glass imperfection) --- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 4 4' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='1' cy='1' r='0.5' fill='white' opacity='0.5'/%3E%3Ccircle cx='3' cy='3' r='0.5' fill='white' opacity='0.3'/%3E%3C/svg%3E");
    background-size: 4px 4px;
}

/* --- Corridor Depth Background --- */
#corridor-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, var(--deep-obsidian) 0%, var(--deep-edge) 100%);
}

#corridor-lines {
    width: 100%;
    height: 100%;
    opacity: 1;
}

.depth-line {
    stroke: rgba(201, 168, 76, 0.05);
    stroke-width: 0.5;
}

/* --- Sections --- */
.section {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 48px;
}

/* --- Glass Panel Base --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: var(--glass-inset), 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: 48px;
    max-width: var(--max-width);
    width: 100%;
    position: relative;
    overflow: hidden;
}

/* Noise texture on glass panels */
.glass-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 6 6' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='1' cy='1' r='0.6' fill='white' opacity='0.4'/%3E%3Ccircle cx='4' cy='4' r='0.4' fill='white' opacity='0.3'/%3E%3Ccircle cx='2' cy='5' r='0.3' fill='white' opacity='0.2'/%3E%3C/svg%3E");
    background-size: 6px 6px;
    border-radius: 12px;
}

/* --- Typography --- */
.section__heading {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--parchment-cream);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5), 0 -1px 0 rgba(201, 168, 76, 0.15);
    margin-bottom: 24px;
}

.section__text {
    color: var(--warm-silver);
    font-weight: 400;
    line-height: 1.7;
    max-width: 680px;
}

.mono-text {
    font-family: 'DM Mono', monospace;
    font-size: 14px;
    letter-spacing: 0.04em;
    color: var(--diplomatic-gold);
}

/* --- Hero Section (Anteroom) --- */
.section--hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* Diplomatic Seal */
.seal {
    margin-bottom: 48px;
    opacity: 0;
}

.seal.active {
    opacity: 1;
}

.seal__svg {
    width: clamp(180px, 30vw, 300px);
    height: clamp(180px, 30vw, 300px);
    animation: sealRotate 60s linear infinite;
}

.seal.scaled .seal__svg {
    animation: sealRotate 60s linear infinite;
}

@keyframes sealRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.seal__radial {
    stroke: var(--diplomatic-gold);
    stroke-width: 0.5;
    stroke-dasharray: 140;
    stroke-dashoffset: 140;
    opacity: 0;
}

.seal__radial.animate {
    opacity: 1;
    animation: drawLine 1500ms ease-out forwards;
    animation-delay: calc(var(--i) * 100ms + 300ms);
}

@keyframes drawLine {
    to { stroke-dashoffset: 0; }
}

.seal__ring {
    fill: none;
    stroke: var(--diplomatic-gold);
    stroke-width: 1;
    stroke-dasharray: 820;
    stroke-dashoffset: 820;
    opacity: 0;
}

.seal__ring--outer {
    stroke-dasharray: 817;
    stroke-dashoffset: 817;
    opacity: 1;
}

.seal__ring--mid {
    stroke-dasharray: 660;
    stroke-dashoffset: 660;
    opacity: 0.6;
}

.seal__ring--inner {
    stroke-dasharray: 503;
    stroke-dashoffset: 503;
    opacity: 0.3;
}

.seal__ring.animate {
    animation: drawRing 800ms ease-out forwards;
}

.seal__ring--outer.animate {
    animation-delay: 1500ms;
}

.seal__ring--mid.animate {
    animation-delay: 2300ms;
}

.seal__ring--inner.animate {
    animation-delay: 2600ms;
}

@keyframes drawRing {
    to { stroke-dashoffset: 0; }
}

.seal__shield {
    fill: none;
    stroke: var(--diplomatic-gold);
    stroke-width: 1.5;
    opacity: 0;
    stroke-dasharray: 300;
    stroke-dashoffset: 300;
}

.seal__shield.animate {
    animation: drawShield 1000ms ease-out forwards;
    animation-delay: 2800ms;
}

@keyframes drawShield {
    0% { opacity: 0; stroke-dashoffset: 300; }
    10% { opacity: 1; }
    100% { opacity: 1; stroke-dashoffset: 0; }
}

.seal__text {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.2em;
    fill: var(--parchment-cream);
    opacity: 0;
}

.seal__text.animate {
    animation: fadeIn 600ms ease-out forwards;
    animation-delay: 3200ms;
}

.seal__text--footer {
    font-size: 8px;
    opacity: 0.3;
    animation: none;
}

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

/* Seal scale-down after intro */
.seal.scaled {
    transition: transform 800ms var(--spring-ease);
    transform: scale(0.5);
}

/* Hero Content */
.hero-content {
    text-align: center;
    opacity: 0;
}

.hero-content.visible {
    opacity: 1;
    transition: opacity 600ms ease-out;
}

.hero__title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--parchment-cream);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5), 0 -1px 0 rgba(201, 168, 76, 0.15);
    margin-bottom: 32px;
    min-height: 1.2em;
}

.typewriter-cursor {
    font-family: 'DM Mono', monospace;
    color: var(--diplomatic-gold);
    animation: blink 530ms step-end infinite;
    font-weight: 400;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.hero__subtitle-panel {
    display: inline-block;
    padding: 20px 40px;
    opacity: 0;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
    transition: opacity 600ms ease-out, backdrop-filter 600ms ease-out, -webkit-backdrop-filter 600ms ease-out;
}

.hero__subtitle-panel.visible {
    opacity: 1;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.hero__subtitle {
    font-family: 'Source Sans 3', sans-serif;
    font-size: clamp(1rem, 2vw, 1.3rem);
    font-weight: 400;
    color: var(--warm-silver);
    letter-spacing: 0.02em;
}

/* --- Scroll Reveal Animations --- */
.scroll-reveal {
    opacity: 0;
    transition: opacity 700ms var(--spring-ease), transform 700ms var(--spring-ease), backdrop-filter 800ms ease-out;
}

.scroll-reveal[data-direction="left"] {
    transform: perspective(800px) rotateY(8deg) translateX(-60px);
}

.scroll-reveal[data-direction="right"] {
    transform: perspective(800px) rotateY(-8deg) translateX(60px);
}

.scroll-reveal[data-direction="below"] {
    transform: translateY(40px);
    filter: blur(4px);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: none;
    filter: blur(0);
}

/* --- Panel Offsets (z-pattern) --- */
.panel--left {
    margin-left: 0;
    margin-right: auto;
    max-width: var(--max-width);
}

.panel--offset-left {
    margin-left: 0;
    margin-right: auto;
    transform-origin: left center;
}

.panel--offset-center {
    margin-left: auto;
    margin-right: auto;
}

.panel--offset-right {
    margin-left: auto;
    margin-right: 0;
    transform-origin: right center;
}

/* Gold top-border draw animation */
.panel--offset-left.revealed,
.panel--offset-center.revealed,
.panel--offset-right.revealed {
    border-top: 2px solid var(--diplomatic-gold);
    animation: borderDraw 600ms ease-out forwards;
}

@keyframes borderDraw {
    from { border-top-color: transparent; }
    to { border-top-color: var(--diplomatic-gold); }
}

/* Chamber Panels layout */
.chamber-panels {
    display: flex;
    flex-direction: column;
    gap: 48px;
    max-width: var(--max-width);
    width: 100%;
}

.chamber-panels .glass-panel {
    max-width: 85%;
}

.panel__icon {
    margin-bottom: 24px;
}

/* Icon draw animation */
.icon-draw {
    opacity: 0;
}

.revealed .icon-draw {
    opacity: 1;
}

.icon-draw rect,
.icon-draw polyline,
.icon-draw path,
.icon-draw line {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
}

.revealed .icon-draw rect,
.revealed .icon-draw polyline,
.revealed .icon-draw path,
.revealed .icon-draw line {
    animation: iconDraw 800ms ease-out forwards;
}

@keyframes iconDraw {
    to { stroke-dashoffset: 0; }
}

/* --- Address Demo --- */
.address-demo {
    display: flex;
    align-items: center;
    gap: 32px;
    margin-top: 32px;
    flex-wrap: wrap;
    justify-content: center;
}

.address-demo__real,
.address-demo__envoy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.address-line {
    font-family: 'Source Sans 3', sans-serif;
    font-size: 17px;
    color: var(--warm-silver);
    position: relative;
    display: inline-block;
    overflow: hidden;
}

.address-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--diplomatic-gold) 0%, var(--diplomatic-gold) 100%);
    transform: translateX(-101%);
    transition: transform 600ms ease-out;
}

.address-line.redacting::after {
    transform: translateX(0%);
}

.address-line.redacted {
    filter: blur(3px);
    color: rgba(212, 208, 200, 0.3);
}

.envoy-line {
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 400ms ease-out, transform 400ms ease-out;
}

.envoy-line.visible {
    opacity: 1;
    transform: translateY(0);
}

.address-demo__arrow {
    opacity: 0;
    transition: opacity 400ms ease-out;
}

.address-demo__arrow.visible {
    opacity: 1;
}

/* --- Wax Seal Break --- */
.section--seal-break {
    min-height: 40vh;
    padding: 40px 48px;
}

.wax-seal {
    width: 180px;
    height: 180px;
    position: relative;
    border-radius: 50%;
    overflow: hidden;
}

.wax-seal__half {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    overflow: hidden;
    transition: transform 500ms var(--spring-ease), opacity 500ms ease-out;
}

.wax-seal__half--left {
    left: 0;
    transform-origin: left center;
}

.wax-seal__half--right {
    right: 0;
    transform-origin: right center;
}

.wax-seal__face {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, var(--diplomatic-gold), var(--seal-crimson) 60%, #5a1800);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.2), inset 0 -2px 4px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.5);
}

.wax-seal__half--right .wax-seal__face {
    margin-left: -90px;
}

.wax-seal__label {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.2em;
    color: var(--parchment-cream);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.wax-seal.broken .wax-seal__half--left {
    transform: rotate(-12deg) translateX(-20px);
    opacity: 0.6;
}

.wax-seal.broken .wax-seal__half--right {
    transform: rotate(12deg) translateX(20px);
    opacity: 0.6;
}

/* --- The Vault Section --- */
.section--vault {
    background: linear-gradient(180deg, var(--deep-obsidian) 0%, var(--deep-edge) 50%, var(--deep-obsidian) 100%);
}

.panel--vault {
    text-align: center;
    backdrop-filter: blur(30px) saturate(200%);
    -webkit-backdrop-filter: blur(30px) saturate(200%);
    position: relative;
    overflow: hidden;
}

.vault__seal-bg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 400px;
    pointer-events: none;
}

.vault-seal-ghost {
    width: 100%;
    height: 100%;
    animation: sealRotate 60s linear infinite;
}

.vault__heading {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 3.5rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--parchment-cream);
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5), 0 -1px 0 rgba(201, 168, 76, 0.15);
    margin-bottom: 32px;
    position: relative;
    z-index: 1;
}

.vault__text {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    line-height: 1.8;
    color: var(--parchment-cream);
    max-width: 720px;
    margin: 0 auto 24px;
    position: relative;
    z-index: 1;
}

.vault__text:last-child {
    font-weight: 700;
    color: var(--diplomatic-gold);
    letter-spacing: 0.04em;
    margin-bottom: 0;
}

/* --- Exit Protocol Section --- */
.section--exit {
    min-height: 80vh;
    justify-content: center;
}

.panel--exit {
    text-align: center;
    border: 2px solid var(--diplomatic-gold);
    padding: 64px 48px;
    animation: borderPulse 3s ease-in-out infinite;
}

@keyframes borderPulse {
    0%, 100% { border-color: rgba(201, 168, 76, 0.6); }
    50% { border-color: rgba(201, 168, 76, 1); }
}

.cta-button {
    display: inline-block;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--parchment-cream);
    text-decoration: none;
    padding: 20px 48px;
    border: 1px solid var(--diplomatic-gold);
    background: rgba(201, 168, 76, 0.08);
    border-radius: 4px;
    transition: background 300ms ease, box-shadow 300ms ease, transform 200ms ease;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5), 0 -1px 0 rgba(201, 168, 76, 0.15);
}

.cta-button:hover {
    background: rgba(201, 168, 76, 0.15);
    box-shadow: 0 0 30px rgba(201, 168, 76, 0.2), inset 0 0 20px rgba(201, 168, 76, 0.05);
    transform: translateY(-2px);
}

/* --- Footer --- */
.site-footer {
    margin-top: 80px;
    text-align: center;
    width: 100%;
}

.footer__legal {
    font-size: 12px;
    color: var(--warm-silver);
    opacity: 0.5;
    margin-bottom: 32px;
}

.footer__seal {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    opacity: 0.3;
}

.footer-seal-svg {
    width: 100%;
    height: 100%;
    animation: sealRotate 60s linear infinite;
}

/* --- Diagonal Gold Lines (z-pattern reinforcement) --- */
.section--hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background:
        linear-gradient(135deg, transparent 48%, rgba(201, 168, 76, 0.08) 49%, rgba(201, 168, 76, 0.08) 49.5%, transparent 50%),
        linear-gradient(45deg, transparent 48%, rgba(201, 168, 76, 0.05) 49%, rgba(201, 168, 76, 0.05) 49.5%, transparent 50%);
}

/* --- Blurred address display on hover --- */
.mono-text.blurred {
    filter: blur(2px);
    transition: filter 300ms ease;
}

.mono-text.blurred:hover {
    filter: blur(0px);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .section {
        padding: 60px 24px;
    }

    .glass-panel {
        padding: 32px 24px;
    }

    .chamber-panels .glass-panel {
        max-width: 100%;
    }

    .address-demo {
        flex-direction: column;
        gap: 16px;
    }

    .address-demo__arrow {
        transform: rotate(90deg);
    }

    .panel--left,
    .panel--offset-left,
    .panel--offset-center,
    .panel--offset-right {
        margin-left: auto;
        margin-right: auto;
    }

    .wax-seal {
        width: 140px;
        height: 140px;
    }

    .wax-seal__face {
        width: 140px;
        height: 140px;
    }

    .wax-seal__half--right .wax-seal__face {
        margin-left: -70px;
    }

    .wax-seal__label {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .section {
        padding: 48px 16px;
    }

    .glass-panel {
        padding: 24px 16px;
    }

    .hero__subtitle-panel {
        padding: 16px 24px;
    }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .scroll-reveal {
        opacity: 1;
        transform: none;
        filter: none;
    }

    .seal {
        opacity: 1;
    }

    .seal__radial,
    .seal__ring,
    .seal__shield,
    .seal__text {
        opacity: 1;
        stroke-dashoffset: 0;
    }
}
