/* ============================================
   UNDO.QUEST - Time-Reversal VHS Glitch
   ============================================ */

:root {
    --void: #08080f;
    --surface: #14142a;
    --text: #e0e0f0;
    --glitch-r: #ff3366;
    --glitch-b: #33ccff;
    --violet: #9933ff;
    --amber: #ffaa33;
    --scan: #2a2a4a;
}

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

html {
    background: var(--void);
}

body {
    font-family: 'Work Sans', sans-serif;
    color: var(--text);
    background: var(--void);
    overflow-x: hidden;
    line-height: 1.7;
}

/* === Scan Line Overlay === */
#scanline-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 2px,
        rgba(42,42,74,0.12) 2px,
        rgba(42,42,74,0.12) 4px
    );
    pointer-events: none;
    z-index: 1000;
    transition: opacity 2s ease;
}

/* === VHS Rewind Bar === */
#rewind-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    z-index: 1001;
    overflow: hidden;
}

.rewind-r, .rewind-g, .rewind-b {
    position: absolute;
    top: 0;
    width: 60px;
    height: 1px;
}

.rewind-r {
    background: var(--glitch-r);
    top: 0;
    animation: scanBar 3s linear infinite;
}

.rewind-g {
    background: var(--text);
    top: 1.5px;
    animation: scanBar 3s linear infinite 0.1s;
}

.rewind-b {
    background: var(--glitch-b);
    top: 3px;
    animation: scanBar 3s linear infinite 0.2s;
}

@keyframes scanBar {
    0% { left: -60px; }
    100% { left: 100%; }
}

/* === Diagonal Sections === */
.diagonal-section {
    position: relative;
    min-height: 100vh;
    background: var(--surface);
    padding: 8rem 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clip-forward {
    clip-path: polygon(0 8%, 100% 0, 100% 92%, 0 100%);
    margin-top: -5vh;
    margin-bottom: -5vh;
}

.clip-reverse {
    clip-path: polygon(0 0, 100% 8%, 100% 100%, 0 92%);
    margin-top: -5vh;
    margin-bottom: -5vh;
}

#tracking-signal {
    background: var(--void);
    clip-path: none;
}

#zero-point {
    background: var(--void);
    clip-path: none;
    min-height: 80vh;
}

.section-inner {
    max-width: 750px;
    width: 100%;
    position: relative;
    z-index: 5;
}

.zero-center {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* === Glitch on Entry === */
.glitch-on-entry {
    animation: none;
}

.glitch-on-entry.glitching {
    animation: glitchFrame 0.15s steps(1) 1;
}

@keyframes glitchFrame {
    0% { transform: translateX(4px); filter: hue-rotate(90deg); }
    50% { transform: translateX(-2px); filter: hue-rotate(45deg); }
    100% { transform: translateX(0); filter: none; }
}

/* === Vibrate Section === */
.vibrate-section {
    animation: none;
}

.vibrate-section.vibrating {
    animation: vibrate 0.05s steps(2) infinite;
}

@keyframes vibrate {
    0% { transform: translateX(0.5px); }
    50% { transform: translateX(-0.5px); }
    100% { transform: translateX(0.5px); }
}

/* === Typography === */
.timestamp-display {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
}

.ts-zero {
    font-size: clamp(3rem, 7vw, 5rem);
    position: relative;
}

.section-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    color: var(--text);
    letter-spacing: 0.08em;
    margin-bottom: 2rem;
}

/* === Chromatic Aberration === */
.chromatic {
    position: relative;
    display: inline-block;
}

.chromatic::before,
.chromatic::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    mix-blend-mode: screen;
}

.chromatic::before {
    color: var(--glitch-r);
    opacity: 0.5;
    transform: translate(-2px, 0);
}

.chromatic::after {
    color: var(--glitch-b);
    opacity: 0.5;
    transform: translate(2px, 0);
}

.chromatic-intense::before {
    transform: translate(-4px, 1px);
}

.chromatic-intense::after {
    transform: translate(4px, -1px);
}

/* === Glitch Title === */
.glitch-title {
    position: relative;
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin: 1.5rem 0;
}

.glitch-layer {
    display: block;
}

.glitch-main {
    color: var(--text);
    position: relative;
    z-index: 2;
}

.glitch-r {
    position: absolute;
    top: 0;
    left: -3px;
    color: var(--glitch-r);
    opacity: 0.5;
    mix-blend-mode: screen;
    z-index: 1;
}

.glitch-b {
    position: absolute;
    top: 0;
    left: 3px;
    color: var(--glitch-b);
    opacity: 0.5;
    mix-blend-mode: screen;
    z-index: 1;
}

.subtitle-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(0.75rem, 0.85vw, 0.85rem);
    color: var(--violet);
    letter-spacing: 0.05em;
}

.body-text {
    font-family: 'Work Sans', sans-serif;
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    font-weight: 400;
    color: var(--text);
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.body-text.fade-scroll {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.body-text.fade-scroll.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* === Echo Blocks (ghost text) === */
.echo-block {
    margin: 1.5rem 0;
    position: relative;
}

.echo-text {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text);
    opacity: 0.12;
    text-shadow: -2px 0 var(--glitch-r), 2px 0 var(--glitch-b);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* === VHS Tracking Lines === */
.vhs-tracking {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    overflow: hidden;
}

.vhs-tracking::before {
    content: '';
    position: absolute;
    width: 102%;
    height: 4px;
    background: rgba(224,224,240,0.08);
    transform: scaleX(1.02) translateX(3px);
    animation: vhsTrack 20s steps(1) infinite;
}

@keyframes vhsTrack {
    0% { top: 10%; opacity: 0; }
    2% { opacity: 1; }
    3% { opacity: 0; }
    15% { top: 35%; opacity: 0; }
    17% { opacity: 0.8; }
    18% { opacity: 0; }
    40% { top: 65%; opacity: 0; }
    42% { opacity: 1; }
    43% { opacity: 0; }
    70% { top: 82%; opacity: 0; }
    72% { opacity: 0.6; }
    73% { opacity: 0; }
    100% { top: 95%; opacity: 0; }
}

/* === Rewind Arrows === */
.rewind-arrows {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem 0;
    position: relative;
    z-index: 5;
}

.arrow-icon {
    width: 24px;
    height: 24px;
    animation: slideLeft 0.8s ease-in-out infinite;
}

.arrow-delay-1 {
    animation-delay: 0.15s;
}

.arrow-delay-2 {
    animation-delay: 0.3s;
}

@keyframes slideLeft {
    0%, 100% { transform: translateX(0); opacity: 0.6; }
    50% { transform: translateX(-8px); opacity: 1; }
}

/* === Zero Point === */
.zero-message {
    font-family: 'Work Sans', sans-serif;
    font-style: italic;
    font-size: clamp(1.1rem, 1.5vw, 1.4rem);
    color: var(--text);
    margin-top: 2rem;
    opacity: 0.7;
}

.zero-domain {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--violet);
    margin-top: 3rem;
    opacity: 0.4;
}

/* === Responsive === */
@media (max-width: 768px) {
    .clip-forward {
        clip-path: polygon(0 3%, 100% 0, 100% 97%, 0 100%);
    }

    .clip-reverse {
        clip-path: polygon(0 0, 100% 3%, 100% 100%, 0 97%);
    }

    .diagonal-section {
        padding: 6rem 1.5rem;
    }

    .glitch-r { left: -2px; }
    .glitch-b { left: 2px; }
}
