/* =============================================
   COMPLETENGINE.NET — Corrupted Naval Command Interface
   ============================================= */

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

html {
    scroll-snap-type: y proximity;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    background: #0A1628;
    color: #C0C8D4;
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Typography --- */
.hero-heading {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(3rem, 8vw, 7rem);
    letter-spacing: 0.08em;
    line-height: 0.95;
    color: #E8ECF1;
    text-transform: uppercase;
    position: relative;
    z-index: 2;
}

.hero-text-inner {
    background: linear-gradient(90deg, #8BA4C4, #E8ECF1, #8BA4C4);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: metallic-sheen 4s ease-in-out infinite;
}

@keyframes metallic-sheen {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.hero-sub {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: clamp(0.9rem, 1.8vw, 1.4rem);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #8BA4C4;
    margin-top: 1.5rem;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.section-title {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    letter-spacing: 0.08em;
    line-height: 0.95;
    color: #E8ECF1;
    text-transform: uppercase;
    margin-bottom: 2rem;
}

.deck-label {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #4A7FB5;
    position: absolute;
    top: 40px;
    left: 30px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    opacity: 0.6;
}

.body-text {
    font-family: 'Inter', sans-serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: #C0C8D4;
}

.body-text strong {
    font-weight: 500;
    color: #E8ECF1;
}

/* --- Background Grid --- */
.bg-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
    background-image:
        linear-gradient(to right, rgba(42, 63, 95, 0.15) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(42, 63, 95, 0.15) 1px, transparent 1px);
    background-size: 120px 120px;
}

.bg-grid.visible {
    opacity: 1;
}

.bg-grid.dimmed {
    opacity: 0.33;
}

/* Grid pulse dots */
.grid-pulse {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #8BA4C4;
    opacity: 0;
    pointer-events: none;
    animation: grid-pulse-fade 1.5s ease-out forwards;
}

@keyframes grid-pulse-fade {
    0% { opacity: 0.8; transform: scale(1); }
    100% { opacity: 0; transform: scale(2.5); }
}

/* --- Scan-line Overlay --- */
.scan-line {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: #4A7FB5;
    opacity: 0.3;
    z-index: 100;
    pointer-events: none;
    animation: scan-line-descend 8s linear infinite;
}

.scan-line.accelerated {
    animation-duration: 1s;
}

.scan-line.stopped {
    animation-play-state: paused;
    opacity: 0;
}

@keyframes scan-line-descend {
    0% { top: -1px; }
    100% { top: 100vh; }
}

/* --- Deck Navigation --- */
.deck-nav {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.deck-nav-item {
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.deck-nav-label {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 600;
    font-size: 0.65rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #8BA4C4;
    transition: color 0.3s ease, opacity 0.3s ease;
    opacity: 0.5;
}

.deck-nav-label.redacted {
    background: #2A3F5F;
    color: transparent;
    display: inline-block;
    min-width: 55px;
    height: 10px;
}

.deck-nav-label.revealed {
    background: none;
    color: #8BA4C4;
    height: auto;
}

.deck-nav-item.active .deck-nav-label.revealed {
    color: #E8ECF1;
    opacity: 1;
}

/* --- Main Container --- */
.main-container {
    position: relative;
    z-index: 1;
    perspective: 1000px;
}

/* --- Deck Base --- */
.deck {
    position: relative;
    min-height: 100vh;
    padding: 80px 80px 80px 80px;
    scroll-snap-align: start;
    overflow: hidden;
}

/* --- DECK-01: Signal Origin --- */
.deck-01 {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    background: #0A1628;
}

.deck-01-waveform {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.deck-01-waveform::before {
    content: '';
    position: absolute;
    top: 30%;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(180deg, #132B47, #2A3F5F);
    opacity: 0.3;
    clip-path: polygon(0% 50%, 5% 45%, 10% 50%, 15% 55%, 20% 50%, 25% 40%, 30% 50%, 35% 60%, 40% 50%, 45% 42%, 50% 50%, 55% 58%, 60% 50%, 65% 44%, 70% 50%, 75% 56%, 80% 50%, 85% 46%, 90% 50%, 95% 54%, 100% 50%, 100% 100%, 0% 100%);
    animation: waveform-breathe 6s ease-in-out infinite;
}

@keyframes waveform-breathe {
    0%, 100% {
        clip-path: polygon(0% 50%, 5% 47%, 10% 50%, 15% 53%, 20% 50%, 25% 46%, 30% 50%, 35% 54%, 40% 50%, 45% 48%, 50% 50%, 55% 52%, 60% 50%, 65% 48%, 70% 50%, 75% 52%, 80% 50%, 85% 49%, 90% 50%, 95% 51%, 100% 50%, 100% 100%, 0% 100%);
    }
    50% {
        clip-path: polygon(0% 50%, 5% 38%, 10% 50%, 15% 62%, 20% 50%, 25% 35%, 30% 50%, 35% 65%, 40% 50%, 45% 38%, 50% 50%, 55% 62%, 60% 50%, 65% 40%, 70% 50%, 75% 60%, 80% 50%, 85% 42%, 90% 50%, 95% 58%, 100% 50%, 100% 100%, 0% 100%);
    }
}

.deck-01-content {
    position: relative;
    z-index: 2;
    max-width: 80%;
}

/* Glitch effect on hero heading */
.hero-heading.glitch {
    animation: glitch-shear 120ms steps(3) forwards;
}

.hero-heading.glitch .hero-text-inner {
    -webkit-text-fill-color: #E8ECF1;
    text-shadow:
        3px 0 #FF3B5C,
        -3px 0 #00E5FF;
}

@keyframes glitch-shear {
    0% {
        clip-path: inset(0 0 80% 0);
        transform: translateX(-3px);
    }
    33% {
        clip-path: inset(30% 0 40% 0);
        transform: translateX(3px);
    }
    66% {
        clip-path: inset(60% 0 10% 0);
        transform: translateX(-2px);
    }
    100% {
        clip-path: inset(0 0 0 0);
        transform: translateX(0);
    }
}

/* Typewriter reveal for hero */
.hero-heading .hero-text-inner {
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    width: 0;
    transition: none;
}

.hero-heading .hero-text-inner.typing {
    animation: typewriter-reveal 1.2s steps(13, end) forwards;
}

@keyframes typewriter-reveal {
    0% { width: 0; }
    100% { width: 100%; }
}

/* Character micro-glitch during typing */
.hero-heading .hero-text-inner.typing-glitch {
    transform: translateX(2px);
    transition: transform 60ms ease;
}

/* --- DECK-02: Architecture --- */
.deck-02 {
    background: linear-gradient(135deg, #0A1628 0%, #0F2239 50%, #0A1628 100%);
}

.deck-02-content {
    display: flex;
    gap: 0;
    align-items: flex-start;
    margin-top: 2rem;
    min-height: 60vh;
}

.deck-02-left {
    flex: 0 0 58%;
    padding-right: 40px;
}

.deck-02-divider {
    width: 1px;
    align-self: stretch;
    background: linear-gradient(to bottom, transparent, #4A7FB5, transparent);
    box-shadow: 0 0 8px rgba(74, 127, 181, 0.3);
    flex-shrink: 0;
}

.deck-02-right {
    flex: 0 0 40%;
    padding-left: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.schematic-svg {
    width: 100%;
    max-width: 400px;
    height: auto;
}

.schematic-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.5s ease;
}

.schematic-svg.animate .schematic-path {
    stroke-dashoffset: 0;
}

/* Text reveal groups */
.text-reveal-group {
    margin-bottom: 1.5rem;
}

.reveal-line {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

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

/* --- DECK-03: Systems --- */
.deck-03 {
    background: #0A1628;
}

.systems-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 2rem;
}

.system-bar {
    position: relative;
    max-height: 60px;
    overflow: hidden;
    border: 1px solid #2A3F5F;
    background: linear-gradient(135deg, #132B47 0%, #1A3454 40%, #132B47 60%, #0F2239 100%);
    transition: max-height 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
    cursor: default;
}

.system-bar.expanded {
    max-height: 350px;
}

.bar-glitch-streak {
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: #00E5FF;
    z-index: 3;
    pointer-events: none;
}

.system-bar.expanding .bar-glitch-streak {
    animation: bar-streak 200ms ease-out forwards;
}

@keyframes bar-streak {
    0% { width: 0; }
    100% { width: 100%; opacity: 0; }
}

.bar-content {
    display: flex;
    gap: 24px;
    padding: 16px 24px;
    min-height: 200px;
}

.bar-image {
    flex: 0 0 200px;
    height: 180px;
    position: relative;
    border: 1px solid #2A3F5F;
}

.bar-image::before,
.bar-image::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border-color: #4A7FB5;
    border-style: solid;
}

.bar-image::before {
    top: 4px;
    left: 4px;
    border-width: 1px 0 0 1px;
}

.bar-image::after {
    bottom: 4px;
    right: 4px;
    border-width: 0 1px 1px 0;
}

.bar-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.bar-title {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: clamp(0.9rem, 1.8vw, 1.2rem);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #8BA4C4;
    margin-bottom: 0.75rem;
}

/* --- DECK-04: Waveform Analysis --- */
.deck-04 {
    background: #0A1628;
    position: relative;
}

.waveform-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.waveform-svg {
    width: 100%;
    height: 100%;
}

.deck-04-content {
    position: relative;
    z-index: 2;
}

.waveform-text-blocks {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    max-width: 700px;
    margin-top: 3rem;
}

.waveform-text-block {
    padding: 2rem;
    background: rgba(10, 22, 40, 0.85);
    border: 1px solid rgba(42, 63, 95, 0.5);
    backdrop-filter: blur(4px);
}

/* --- DECK-05: Transmission End --- */
.deck-05 {
    background: #0A1628;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 80vh;
}

.deck-05-content {
    max-width: 600px;
}

.deck-05-heading {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.08em;
    line-height: 0.95;
    color: #E8ECF1;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.deck-05-heading.visible {
    opacity: 1;
}

.deck-05-rule {
    width: 0;
    height: 1px;
    background: #4A7FB5;
    margin: 2rem auto;
    transition: width 0.8s ease;
}

.deck-05-rule.visible {
    width: 200px;
}

.deck-05-subtext {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #6B7D94;
    opacity: 0;
    transition: opacity 0.6s ease 0.4s;
}

.deck-05-subtext.visible {
    opacity: 1;
}

/* --- Section Wave Dividers --- */
.section-wave-divider {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 3;
    pointer-events: none;
}

.wave-divider-svg {
    width: 100%;
    height: 100%;
}

.wave-divider-svg path {
    stroke-dasharray: 3000;
    stroke-dashoffset: 3000;
    transition: stroke-dashoffset 1.5s ease;
}

.wave-divider-svg.animate path {
    stroke-dashoffset: 0;
}

/* --- Glitch Overlay (DECK-05 closing) --- */
.glitch-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0A1628;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.05s ease;
}

.glitch-overlay.flash {
    opacity: 1;
}

.glitch-overlay.fade-out {
    transition: opacity 1s ease;
    opacity: 0;
}

/* --- Glitch Strips (section transitions) --- */
.glitch-strips {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 150;
    pointer-events: none;
}

.glitch-strip {
    position: absolute;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(10, 22, 40, 0.8);
    opacity: 0;
}

.glitch-strip.active {
    animation: strip-shear 80ms ease-out forwards;
}

@keyframes strip-shear {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    50% {
        opacity: 1;
        transform: translateX(var(--strip-offset));
    }
    100% {
        opacity: 0;
        transform: translateX(0);
    }
}

/* --- Generic Glitch Effect (applied to any element) --- */
.micro-glitch {
    animation: micro-glitch-anim 100ms steps(2) forwards;
}

@keyframes micro-glitch-anim {
    0% {
        transform: translateX(-2px);
        filter: hue-rotate(90deg);
    }
    50% {
        transform: translateX(2px);
        filter: hue-rotate(-90deg);
    }
    100% {
        transform: translateX(0);
        filter: none;
    }
}

/* --- Metallic Surface Treatment --- */
.metallic-surface {
    background: linear-gradient(135deg, #132B47 0%, #1A3454 40%, #132B47 60%, #0F2239 100%);
    transition: background 0.4s ease;
}

.metallic-surface:hover {
    background: linear-gradient(145deg, #132B47 0%, #1A3454 40%, #132B47 60%, #0F2239 100%);
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .deck {
        padding: 60px 30px;
    }

    .deck-02-content {
        flex-direction: column;
    }

    .deck-02-left {
        flex: 1;
        padding-right: 0;
        margin-bottom: 2rem;
    }

    .deck-02-divider {
        width: 100%;
        height: 1px;
        align-self: auto;
        margin: 2rem 0;
    }

    .deck-02-right {
        flex: 1;
        padding-left: 0;
    }

    .bar-content {
        flex-direction: column;
    }

    .bar-image {
        flex: none;
        width: 100%;
        height: 120px;
    }

    .deck-nav {
        right: 10px;
    }

    .deck-label {
        left: 15px;
    }
}

@media (max-width: 600px) {
    .deck {
        padding: 40px 20px;
    }

    .hero-heading {
        font-size: clamp(2.5rem, 10vw, 4rem);
    }

    .deck-nav {
        display: none;
    }
}
