/* recycle.digital - Glitch Terminal Data Recovery */

:root {
    --void: #0A0A0F;
    --phosphor-green: #39FF85;
    --glitch-red: #FF3B5C;
    --scan-cyan: #00D4FF;
    --clean-amber: #FFB347;
    --dim-gray: #4A4A5A;
    --resolved-white: #F0F0F5;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Space Grotesk', sans-serif;
    background-color: var(--void);
    color: var(--phosphor-green);
    overflow-x: hidden;
}

/* CRT Scanline Overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        transparent 0px,
        transparent 1px,
        rgba(0, 0, 0, 0.03) 1px,
        rgba(0, 0, 0, 0.03) 2px
    );
    z-index: 9999;
}

.section {
    min-height: 100vh;
    position: relative;
}

.section__header {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: var(--phosphor-green);
    letter-spacing: 0.05em;
    padding: 2rem 4rem;
}

.section__header--dark {
    color: var(--void);
}

/* ========== SECTION 1: BOOT SEQUENCE ========== */

.section--boot {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--void);
    position: relative;
}

.boot__terminal {
    max-width: 700px;
    width: 90%;
    position: relative;
}

.boot__output {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(0.85rem, 1.5vw, 1.1rem);
    color: var(--phosphor-green);
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-all;
}

.boot__cursor {
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.1rem;
    color: var(--phosphor-green);
    animation: blink 0.8s steps(2) infinite;
}

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

.glitch-band {
    position: absolute;
    left: 0;
    right: 0;
    height: 4px;
    top: -4px;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
}

.glitch-band.active {
    opacity: 1;
    animation: glitchSweep 0.8s ease-out forwards;
}

@keyframes glitchSweep {
    0% { top: 0; opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

/* ========== SECTION 2: FRAGMENT GRID ========== */

.section--fragments {
    background-color: var(--void);
    padding: 2rem 4rem 6rem;
    min-height: 200vh;
    position: relative;
}

.scanline-sweep {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--phosphor-green);
    opacity: 0.15;
    animation: scanDown 8s linear infinite;
    pointer-events: none;
    z-index: 5;
}

@keyframes scanDown {
    0% { top: 0; }
    100% { top: 100%; }
}

.fragment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 4px;
    max-width: 1200px;
    margin: 0 auto;
}

.fragment {
    background: rgba(10, 10, 15, 0.8);
    border: 1px solid rgba(57, 255, 133, 0.1);
    padding: 0.5rem;
    overflow: hidden;
    position: relative;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.fragment.in-view {
    opacity: 1;
}

.fragment--small {
    min-height: 120px;
}

.fragment--medium {
    grid-column: span 2;
    min-height: 180px;
}

.fragment--large {
    grid-column: span 3;
    grid-row: span 2;
    min-height: 240px;
}

.fragment__label {
    font-family: 'Fira Code', monospace;
    font-size: 0.65rem;
    color: var(--dim-gray);
    display: block;
    margin-top: 0.5rem;
}

.fragment__hex {
    font-family: 'Fira Code', monospace;
    font-size: 0.7rem;
    line-height: 1.4;
    color: var(--dim-gray);
    word-break: break-all;
    overflow: hidden;
}

.fragment__hex .highlight {
    color: var(--phosphor-green);
}

.fragment__pixels {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 1px;
    height: 100%;
}

.fragment__pixels .px {
    width: 100%;
    aspect-ratio: 1;
}

.fragment__waveform {
    display: flex;
    align-items: flex-end;
    gap: 1px;
    height: 80px;
    padding-top: 0.5rem;
}

.fragment__waveform .bar {
    flex: 1;
    background: var(--phosphor-green);
    min-width: 2px;
    opacity: 0.7;
}

.fragment__text-corrupt {
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    color: var(--dim-gray);
    line-height: 1.6;
    padding: 0.5rem;
}

.corrupt {
    color: var(--glitch-red);
}

.fragment__decompose {
    width: 100%;
    height: 100%;
}

.decompose-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(10, 1fr);
    gap: 1px;
    width: 100%;
    height: 200px;
}

.decompose-grid .cell {
    transition: transform 2s ease;
}

/* ========== SECTION 3: PROCESSING PIPELINE ========== */

.section--pipeline {
    background-color: var(--void);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4rem 2rem;
}

.pipeline__flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    max-width: 1100px;
    margin: 0 auto;
    flex-wrap: wrap;
}

.pipeline__stage {
    width: 180px;
    border: 1px solid var(--dim-gray);
    padding: 1.5rem;
    text-align: center;
    position: relative;
    background: rgba(10, 10, 15, 0.9);
}

.pipeline__stage-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin: 0 auto 0.75rem;
    animation: pulse 1.5s ease infinite;
}

.pipeline__stage--input .pipeline__stage-indicator {
    background: var(--glitch-red);
    box-shadow: 0 0 8px var(--glitch-red);
}

.pipeline__stage--parse .pipeline__stage-indicator {
    background: var(--scan-cyan);
    box-shadow: 0 0 8px var(--scan-cyan);
    animation-delay: 0.3s;
}

.pipeline__stage--clean .pipeline__stage-indicator {
    background: var(--clean-amber);
    box-shadow: 0 0 8px var(--clean-amber);
    animation-delay: 0.6s;
}

.pipeline__stage--output .pipeline__stage-indicator {
    background: var(--phosphor-green);
    box-shadow: 0 0 8px var(--phosphor-green);
    animation-delay: 0.9s;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.pipeline__stage-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 1.1rem;
    color: var(--phosphor-green);
    letter-spacing: 0.1em;
    margin-bottom: 0.25rem;
}

.pipeline__stage-desc {
    font-family: 'Fira Code', monospace;
    font-size: 0.7rem;
    color: var(--dim-gray);
    margin-bottom: 0.75rem;
}

.pipeline__hex-scroll {
    font-family: 'Fira Code', monospace;
    font-size: 0.6rem;
    color: var(--dim-gray);
    height: 40px;
    overflow: hidden;
    text-align: left;
    word-break: break-all;
}

.pipeline__connector {
    width: 120px;
    height: 40px;
    flex-shrink: 0;
}

.pipeline__flow-line {
    animation: flowDash 3s linear infinite;
}

.pipeline__flow-line--2 {
    animation-delay: -1s;
}

.pipeline__flow-line--3 {
    animation-delay: -2s;
}

@keyframes flowDash {
    from { stroke-dashoffset: 24; }
    to { stroke-dashoffset: 0; }
}

/* ========== SECTION 4: OUTPUT BUFFER ========== */

.section--output {
    background-color: var(--resolved-white);
    color: var(--void);
    min-height: 100vh;
    padding: 4rem;
    transition: background-color 0.8s ease;
}

.output__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    max-width: 1000px;
    margin: 2rem auto 0;
}

.output__block {
    padding: 1.5rem;
    min-height: 150px;
    border: 1px solid rgba(10, 10, 15, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.output__block--gradient {
    background: var(--resolved-white);
}

.output__gradient-bar {
    width: 100%;
    height: 60px;
    background: linear-gradient(90deg, var(--scan-cyan), var(--phosphor-green), var(--clean-amber));
    border-radius: 2px;
}

.output__gradient-bar--2 {
    background: linear-gradient(90deg, var(--clean-amber), var(--glitch-red), var(--scan-cyan));
}

.output__block--pixels-clean {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 1rem;
}

.output__block--pixels-clean .px-clean {
    aspect-ratio: 1;
    border-radius: 1px;
}

.output__block--text-clean {
    grid-column: span 3;
    text-align: center;
    padding: 3rem;
}

.output__text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    line-height: 1.65;
    color: var(--void);
    max-width: 600px;
    margin: 0 auto;
}

.output__text strong {
    font-weight: 700;
    color: var(--void);
}

/* ========== RESPONSIVE ========== */

@media (max-width: 768px) {
    .section--fragments {
        padding: 2rem 1rem 4rem;
    }

    .fragment--large {
        grid-column: span 2;
    }

    .pipeline__flow {
        flex-direction: column;
        gap: 1rem;
    }

    .pipeline__connector {
        transform: rotate(90deg);
        width: 60px;
        height: 30px;
    }

    .output__grid {
        grid-template-columns: 1fr;
    }

    .output__block--text-clean {
        grid-column: span 1;
    }

    .section__header {
        padding: 2rem 1.5rem;
    }
}
