/* =========================================
   MasqproT.com - Styles
   Masquerade Protocol - Forest-Green Surveillance
   ========================================= */

/* CSS Custom Properties */
:root {
    --protocol-black: #0B1A0F;
    --canopy-dark: #1A2E1A;
    --phosphor-green: #3DDB5E;
    --mask-gold: #C4A35A;
    --fog-white: #E8EDE9;
    --lichen-gray: #7A8F7A;
    --redaction-red: #8B2D2D;
    --deep-moss: #0F2B14;

    --font-display: 'Cormorant Garamond', 'Georgia', serif;
    --font-body: 'Libre Baskerville', 'Georgia', serif;
    --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

    --elastic: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --elastic-out: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

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

body {
    background-color: var(--protocol-black);
    color: var(--fog-white);
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.85;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =========================================
   Scanline Overlay (HUD Layer)
   ========================================= */
#scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.06) 0px,
        rgba(0, 0, 0, 0.06) 1px,
        transparent 1px,
        transparent 3px
    );
    opacity: 1;
    transition: opacity 0.3s ease;
}

#scanline-overlay.interference {
    opacity: 1;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15) 0px,
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 3px
    );
}

/* =========================================
   Protocol Level Indicator (HUD Layer)
   ========================================= */
#protocol-indicator {
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.protocol-label {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 0.15em;
    color: var(--lichen-gray);
    text-transform: uppercase;
}

.protocol-number {
    font-family: var(--font-mono);
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--phosphor-green);
    text-shadow: 0 0 15px rgba(61, 219, 94, 0.5), 0 0 30px rgba(61, 219, 94, 0.2);
    line-height: 1;
    transition: text-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 1.5em;
    text-align: center;
    height: 1.2em;
}

.protocol-number.flicker {
    animation: protocolFlicker 0.6s ease;
}

@keyframes protocolFlicker {
    0% { opacity: 1; }
    15% { opacity: 0.2; }
    30% { opacity: 1; }
    45% { opacity: 0.3; }
    60% { opacity: 1; }
    75% { opacity: 0.15; }
    90% { opacity: 1; }
    100% { opacity: 1; }
}

/* LED segment display styling */
.protocol-number::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(61, 219, 94, 0.03) 50%,
        transparent 100%
    );
    pointer-events: none;
}

/* =========================================
   Fog Layer (Deepest)
   ========================================= */
#fog-layer {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    z-index: 1;
    pointer-events: none;
    background:
        radial-gradient(ellipse 80% 60% at 20% 30%, rgba(15, 43, 20, 0.8) 0%, transparent 60%),
        radial-gradient(ellipse 70% 50% at 80% 70%, rgba(26, 46, 26, 0.6) 0%, transparent 55%),
        radial-gradient(ellipse 90% 70% at 50% 50%, rgba(11, 26, 15, 0.9) 0%, transparent 70%),
        radial-gradient(ellipse 60% 80% at 30% 80%, rgba(15, 43, 20, 0.5) 0%, transparent 50%);
    will-change: transform;
}

/* =========================================
   Mask Layer
   ========================================= */
#mask-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    will-change: transform;
}

.mask-silhouette {
    position: absolute;
    color: var(--mask-gold);
    opacity: 0.04;
    will-change: transform;
}

.mask-1 {
    width: 280px;
    height: 200px;
    top: 5%;
    left: -5%;
    transform: rotate(-15deg);
}

.mask-2 {
    width: 320px;
    height: 150px;
    top: 35%;
    right: -8%;
    transform: rotate(10deg);
}

.mask-3 {
    width: 200px;
    height: 300px;
    top: 55%;
    left: 8%;
    transform: rotate(-8deg);
}

.mask-4 {
    width: 260px;
    height: 160px;
    top: 75%;
    right: 5%;
    transform: rotate(20deg);
}

.mask-5 {
    width: 240px;
    height: 170px;
    top: 15%;
    right: 25%;
    transform: rotate(-5deg);
}

/* =========================================
   Bubble Layer
   ========================================= */
#bubble-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
    overflow: hidden;
    will-change: transform;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(61, 219, 94, 0.12), transparent 70%);
    border: 1px solid rgba(196, 163, 90, 0.1);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: bubbleRise var(--duration) linear infinite, bubblePulse 4s var(--elastic) infinite;
    will-change: transform, opacity;
    opacity: var(--bubble-opacity, 0.1);
}

@keyframes bubbleRise {
    0% {
        transform: translateY(110vh) translateX(0);
        opacity: 0;
    }
    10% {
        opacity: var(--bubble-opacity, 0.1);
    }
    90% {
        opacity: var(--bubble-opacity, 0.1);
    }
    100% {
        transform: translateY(-10vh) translateX(var(--drift, 20px));
        opacity: 0;
    }
}

@keyframes bubblePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

/* =========================================
   Main Content Area
   ========================================= */
#parallax-container {
    position: relative;
    z-index: 10;
}

/* =========================================
   Protocol Stages
   ========================================= */
.protocol-stage {
    min-height: 100vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10vh 5vw;
}

.stage-content {
    max-width: 60%;
    position: relative;
    z-index: 5;
}

/* =========================================
   Stage Titles (Cormorant Garamond)
   ========================================= */
.stage-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(2.5rem, 7vw, 6rem);
    letter-spacing: 0.15em;
    font-variant: small-caps;
    color: var(--fog-white);
    margin-bottom: 3rem;
    line-height: 1.1;
}

#stage-0 .stage-title {
    font-size: clamp(3.5rem, 10vw, 9rem);
    color: var(--phosphor-green);
    text-shadow: 0 0 40px rgba(61, 219, 94, 0.3), 0 0 80px rgba(61, 219, 94, 0.1);
    text-align: center;
    margin-bottom: 1.5rem;
}

.char-wrap {
    display: inline-block;
    opacity: 0;
    transform: scale(1.5);
    transition: opacity 0.8s var(--elastic), transform 0.8s var(--elastic);
}

.char-wrap.stamped {
    opacity: 1;
    transform: scale(1);
}

.stage-subtitle {
    font-family: var(--font-display);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: var(--mask-gold);
    text-align: center;
    letter-spacing: 0.1em;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1s ease 0.8s, transform 1s ease 0.8s;
}

.stage-subtitle.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stamp animation for titles entering viewport */
.stage-title.animate-in .char-wrap {
    animation: stampIn 0.8s var(--elastic) forwards;
}

/* =========================================
   Hero Mask SVG Overlay
   ========================================= */
.mask-overlay-svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60vw;
    max-width: 600px;
    pointer-events: none;
    z-index: -1;
}

.hero-mask {
    width: 100%;
    height: auto;
    animation: maskDistort 8s ease-in-out infinite;
}

@keyframes maskDistort {
    0%, 100% { transform: scale(1) rotate(0deg); filter: blur(0px); }
    25% { transform: scale(1.02) rotate(0.5deg); filter: blur(0.5px); }
    50% { transform: scale(0.98) rotate(-0.3deg); filter: blur(1px); }
    75% { transform: scale(1.01) rotate(0.2deg); filter: blur(0.3px); }
}

/* =========================================
   Torn-Edge Containers
   ========================================= */
.torn-container {
    position: relative;
    padding: 2.5rem 3rem;
    margin: 2rem 0;
    background: rgba(26, 46, 26, 0.4);
    border-left: 2px solid rgba(196, 163, 90, 0.15);
    opacity: 0;
    transform: scale(0.92) rotate(-1deg);
    transition: opacity 0.8s ease, transform 0.8s var(--elastic);
}

.torn-container.visible {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.torn-right {
    clip-path: polygon(
        0% 0%,
        98% 0%,
        100% 3%,
        97% 8%,
        100% 15%,
        98% 22%,
        100% 30%,
        97% 38%,
        100% 45%,
        99% 55%,
        100% 62%,
        97% 70%,
        100% 78%,
        98% 85%,
        100% 92%,
        97% 100%,
        0% 100%
    );
}

.torn-left {
    clip-path: polygon(
        3% 0%,
        100% 0%,
        100% 100%,
        2% 100%,
        0% 93%,
        3% 86%,
        0% 78%,
        2% 70%,
        0% 63%,
        3% 55%,
        0% 47%,
        2% 40%,
        0% 32%,
        3% 24%,
        0% 16%,
        2% 8%,
        0% 2%
    );
    border-left: none;
    border-right: 2px solid rgba(196, 163, 90, 0.15);
}

/* =========================================
   Body Text
   ========================================= */
.body-text {
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.85;
    color: var(--fog-white);
    margin-bottom: 1.5rem;
}

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

/* =========================================
   Redaction Bars
   ========================================= */
.redaction-bar {
    position: relative;
    margin: 1.5rem 0;
    min-height: 2em;
    cursor: default;
}

.redacted-text {
    font-family: var(--font-body);
    font-size: 1.125rem;
    line-height: 1.85;
    color: var(--phosphor-green);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.redaction-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--protocol-black);
    border-left: 3px solid var(--redaction-red);
    transition: transform 1.2s var(--elastic), opacity 1.2s ease;
    transform-origin: left center;
    z-index: 2;
}

/* Noise texture on redaction bar */
.redaction-bar::after {
    content: 'CLASSIFIED';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    color: var(--redaction-red);
    opacity: 0.4;
    z-index: 3;
    transition: opacity 0.6s ease;
}

/* Declassification stages */
.redaction-bar.reveal-25::before {
    background: linear-gradient(
        90deg,
        var(--protocol-black) 0%,
        transparent 20%,
        var(--protocol-black) 25%,
        var(--protocol-black) 40%,
        transparent 45%,
        var(--protocol-black) 50%,
        var(--protocol-black) 100%
    );
}

.redaction-bar.reveal-50::before {
    background: linear-gradient(
        90deg,
        var(--protocol-black) 0%,
        transparent 10%,
        var(--protocol-black) 18%,
        transparent 30%,
        var(--protocol-black) 38%,
        transparent 52%,
        var(--protocol-black) 60%,
        transparent 72%,
        var(--protocol-black) 80%,
        transparent 90%,
        var(--protocol-black) 100%
    );
}

.redaction-bar.reveal-75::before {
    opacity: 0.3;
    transform: scaleX(0.5) translateX(-20%);
}

.redaction-bar.reveal-75::after {
    opacity: 0;
}

.redaction-bar.reveal-75 .redacted-text {
    opacity: 0.6;
}

.redaction-bar.reveal-100::before {
    opacity: 0;
    transform: scaleX(0);
}

.redaction-bar.reveal-100::after {
    opacity: 0;
}

.redaction-bar.reveal-100 .redacted-text {
    opacity: 1;
}

/* =========================================
   Data Intercept blocks
   ========================================= */
.data-intercept {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8vh;
    padding: 1.2rem 1.5rem;
    border: 1px solid rgba(61, 219, 94, 0.15);
    background: rgba(11, 26, 15, 0.6);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s var(--elastic);
}

.data-intercept.visible {
    opacity: 1;
    transform: translateY(0);
}

.intercept-label {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.15em;
    color: var(--phosphor-green);
    text-transform: uppercase;
}

.intercept-value {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    color: var(--fog-white);
}

.intercept-timestamp {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    color: var(--lichen-gray);
}

/* =========================================
   Protocol Stamps
   ========================================= */
.protocol-stamp {
    position: absolute;
    color: var(--mask-gold);
    opacity: 0.2;
    width: 120px;
    height: 120px;
    animation: stampRotate 60s linear infinite;
}

.stamp-1 {
    top: 5%;
    right: -15%;
}

.stamp-2 {
    top: 8%;
    left: -18%;
}

.stamp-3 {
    bottom: 10%;
    right: -12%;
}

.stamp-4 {
    top: 3%;
    right: -10%;
}

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

.protocol-stamp.snap {
    animation: stampSnap 0.6s var(--elastic) forwards;
}

@keyframes stampSnap {
    0% { transform: rotate(-15deg) scale(0.8); opacity: 0; }
    100% { transform: rotate(0deg) scale(1); opacity: 0.2; }
}

/* =========================================
   Stage 5: Core
   ========================================= */
.stage-core {
    text-align: center;
    max-width: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.core-title {
    color: var(--fog-white);
    font-size: clamp(2rem, 5vw, 4.5rem);
    margin-bottom: 3rem;
}

.core-text {
    font-family: var(--font-display);
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.3rem, 2.5vw, 2rem);
    line-height: 1.7;
    color: var(--fog-white);
    max-width: 600px;
    margin-bottom: 4rem;
}

.core-stamp {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.3em;
    color: var(--phosphor-green);
    border: 1px solid var(--phosphor-green);
    padding: 0.8rem 2rem;
    opacity: 0;
    transform: scale(1.3);
    transition: opacity 1s ease, transform 1s var(--elastic);
}

.core-stamp.visible {
    opacity: 1;
    transform: scale(1);
}

/* =========================================
   Responsive Design
   ========================================= */
@media (max-width: 768px) {
    .stage-content {
        max-width: 90%;
    }

    .stage-core {
        max-width: 85%;
    }

    .torn-container {
        padding: 1.5rem 2rem;
    }

    #protocol-indicator {
        bottom: 20px;
        left: 20px;
    }

    .protocol-number {
        font-size: 1.8rem;
        text-shadow: none;
    }

    .protocol-label {
        font-size: 0.5rem;
    }

    .mask-silhouette {
        display: none;
    }

    #fog-layer {
        background:
            radial-gradient(ellipse 100% 80% at 50% 50%, rgba(15, 43, 20, 0.9) 0%, transparent 70%);
    }

    .protocol-stamp {
        width: 80px;
        height: 80px;
    }

    .stamp-1, .stamp-3 { right: -5%; }
    .stamp-2, .stamp-4 { left: -5%; }

    .mask-overlay-svg {
        width: 80vw;
    }
}

@media (max-width: 480px) {
    .stage-content {
        max-width: 95%;
    }

    .torn-container {
        padding: 1.2rem 1.5rem;
        clip-path: none;
    }

    .body-text {
        font-size: 1rem;
    }

    .protocol-stamp {
        display: none;
    }
}

/* =========================================
   Selection Styling
   ========================================= */
::selection {
    background: rgba(61, 219, 94, 0.3);
    color: var(--fog-white);
}

::-moz-selection {
    background: rgba(61, 219, 94, 0.3);
    color: var(--fog-white);
}

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

::-webkit-scrollbar-track {
    background: var(--protocol-black);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--lichen-gray);
}
