/* ============================================
   SIM-AI.ORG - Glitch Aesthetic Styles
   ============================================ */

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

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

body {
    background: #2a1a1e;
    color: #d8d0c8;
    font-family: 'Libre Baskerville', serif;
    font-size: clamp(15px, 1.5vw, 18px);
    line-height: 1.8;
    overflow-x: hidden;
}

/* ============================================
   Opening Sequence Overlays
   ============================================ */

#opening-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 1000;
    pointer-events: none;
    opacity: 1;
    transition: opacity 200ms ease;
}

#opening-overlay.fade-out {
    opacity: 0;
}

#flash-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #fff;
    z-index: 999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 50ms ease;
}

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

/* ============================================
   Split Section Layout
   ============================================ */

.split-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

.split-section.ratio-60-40 {
    grid-template-columns: 3fr 2fr;
}

.split-section.ratio-40-60 {
    grid-template-columns: 2fr 3fr;
}

.panel {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-content {
    padding: clamp(30px, 5vw, 80px);
    width: 100%;
    max-width: 680px;
}

/* Panel Colors */
.panel-burgundy {
    background: #5c1a2a;
}

.panel-cream {
    background: #f0e4d4;
}

.panel-charcoal {
    background: #2a1a1e;
}

/* ============================================
   Slide-Reveal Animations
   ============================================ */

.slide-from-left {
    transform: translateX(-100px);
    opacity: 0;
    transition: transform 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 500ms ease;
}

.slide-from-right {
    transform: translateX(100px);
    opacity: 0;
    transition: transform 500ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 500ms ease;
}

.slide-from-left.revealed,
.slide-from-right.revealed {
    transform: translateX(0);
    opacity: 1;
}

/* Hero specific: controlled by JS opening sequence */
#hero .slide-from-left,
#hero .slide-from-right {
    transition: none;
}

#hero .slide-from-left.revealed,
#hero .slide-from-right.revealed {
    transition: transform 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 600ms ease;
}

/* ============================================
   Typography
   ============================================ */

.hero-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(80px, 18vw, 220px);
    letter-spacing: 0.06em;
    line-height: 0.9;
    text-transform: uppercase;
    color: #f0e4d4;
    text-shadow: -3px 0 #3ae8d8, 3px 0 #e83a7d;
    position: relative;
}

#ai-title {
    color: #5c1a2a;
    text-shadow: -3px 0 #e83a7d, 3px 0 #3ae8d8;
}

.hero-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 150ms ease, transform 150ms ease;
}

.hero-title .letter.visible {
    opacity: 1;
    transform: translateY(0);
}

.section-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(40px, 8vw, 96px);
    letter-spacing: 0.06em;
    line-height: 1;
    text-transform: uppercase;
    color: #f0e4d4;
    text-shadow: -2px 0 #3ae8d8, 2px 0 #e83a7d;
    margin-bottom: 30px;
}

.panel-cream .section-title,
.section-title.dark {
    color: #5c1a2a;
    text-shadow: -2px 0 #e83a7d, 2px 0 #3ae8d8;
}

.body-text {
    font-family: 'Libre Baskerville', serif;
    font-size: clamp(15px, 1.5vw, 18px);
    line-height: 1.8;
    color: #d8d0c8;
    margin-bottom: 20px;
}

.body-text.dark,
.panel-cream .body-text {
    color: #2a1a1e;
}

.glitch-label {
    font-family: 'Share Tech Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #e83a7d;
    display: block;
    margin-bottom: 12px;
}

.glitch-label.dark {
    color: #5c1a2a;
}

/* ============================================
   Research Items
   ============================================ */

.research-item {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(232, 58, 125, 0.2);
}

.research-label {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(22px, 3vw, 32px);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #3ae8d8;
    margin-bottom: 10px;
}

.research-label.dark {
    color: #5c1a2a;
}

.panel-cream .research-item {
    border-bottom-color: rgba(92, 26, 42, 0.2);
}

.simulation-params {
    margin-top: 40px;
    padding: 20px;
    background: rgba(92, 26, 42, 0.1);
}

.simulation-params .glitch-label {
    margin-bottom: 6px;
}

/* ============================================
   Error Block
   ============================================ */

.error-block {
    margin-top: 30px;
    padding: 20px;
    background: rgba(200, 42, 42, 0.15);
    border-left: 3px solid #c82a2a;
}

.error-block .glitch-label {
    color: #c82a2a;
    margin-bottom: 6px;
}

/* ============================================
   Transmission Log
   ============================================ */

.transmission-log {
    margin-top: 20px;
}

.log-entry {
    margin-bottom: 25px;
    padding-left: 15px;
    border-left: 2px solid #e83a7d;
}

.log-entry .glitch-label {
    color: #3ae8d8;
}

.log-entry .body-text {
    font-size: 14px;
    margin-bottom: 0;
}

/* ============================================
   Glitch Bands
   ============================================ */

.glitch-band {
    width: 100%;
    overflow: hidden;
    position: relative;
}

.glitch-band-center {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    height: 8px;
    z-index: 10;
    background: repeating-linear-gradient(
        90deg,
        #e83a7d 0px, #e83a7d 12px,
        #3ae8d8 12px, #3ae8d8 20px,
        #5c1a2a 20px, #5c1a2a 35px,
        #f0e4d4 35px, #f0e4d4 42px,
        #c82a2a 42px, #c82a2a 50px,
        #2a1a1e 50px, #2a1a1e 58px,
        #d8d0c8 58px, #d8d0c8 65px,
        #e83a7d 65px, #e83a7d 72px
    );
    background-size: 200% 100%;
}

.glitch-band-center.active {
    animation: glitch-scroll 100ms linear 6;
}

.glitch-band-center.stable {
    animation: none;
}

.glitch-divider {
    height: 30px;
    background: repeating-linear-gradient(
        90deg,
        #e83a7d 0px, #e83a7d 8px,
        #3ae8d8 8px, #3ae8d8 15px,
        #5c1a2a 15px, #5c1a2a 28px,
        #f0e4d4 28px, #f0e4d4 33px,
        #c82a2a 33px, #c82a2a 40px,
        #2a1a1e 40px, #2a1a1e 52px,
        #d8d0c8 52px, #d8d0c8 56px,
        #3ae8d8 56px, #3ae8d8 64px,
        #e83a7d 64px, #e83a7d 70px,
        #5c1a2a 70px, #5c1a2a 80px
    );
    background-size: 200% 100%;
    position: relative;
}

.glitch-divider::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        90deg,
        transparent 0px, transparent 20px,
        rgba(0, 0, 0, 0.3) 20px, rgba(0, 0, 0, 0.3) 22px,
        transparent 22px, transparent 45px,
        rgba(255, 255, 255, 0.15) 45px, rgba(255, 255, 255, 0.15) 47px
    );
}

.glitch-divider.glitch-active {
    animation: glitch-scroll 80ms linear 4;
}

@keyframes glitch-scroll {
    0% { background-position: 0% 0; }
    100% { background-position: 100% 0; }
}

/* ============================================
   Waveform Borders
   ============================================ */

.waveform-border {
    width: 100%;
    height: 40px;
    background: #2a1a1e;
    overflow: hidden;
}

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

.wave-path {
    fill: none;
    stroke-width: 1.5;
}

.wave-magenta {
    stroke: #e83a7d;
}

.wave-cyan {
    stroke: #3ae8d8;
}

/* ============================================
   Glitch Collage
   ============================================ */

.glitch-collage {
    position: relative;
    width: 100%;
    height: 300px;
    margin-bottom: 20px;
    overflow: hidden;
}

.glitch-collage.large {
    height: 100%;
    min-height: 400px;
}

.collage-fragment {
    position: absolute;
    overflow: hidden;
}

/* Fragment styles - JPEG artifact blocks */
.fragment-1 {
    width: 60%;
    height: 40%;
    top: 5%;
    left: 10%;
    background: #e83a7d;
    clip-path: polygon(0 0, 100% 5%, 95% 100%, 5% 95%);
    transform: skewX(-3deg);
    opacity: 0.7;
}

.fragment-1::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px, transparent 4px,
        rgba(42, 26, 30, 0.4) 4px, rgba(42, 26, 30, 0.4) 5px
    );
}

.fragment-2 {
    width: 45%;
    height: 35%;
    top: 30%;
    right: 5%;
    background: #3ae8d8;
    clip-path: polygon(5% 0, 100% 0, 95% 100%, 0 90%);
    transform: skewX(2deg);
    opacity: 0.6;
    mix-blend-mode: screen;
}

.fragment-3 {
    width: 50%;
    height: 30%;
    bottom: 10%;
    left: 20%;
    background: #5c1a2a;
    clip-path: polygon(0 10%, 100% 0, 100% 100%, 3% 95%);
    opacity: 0.8;
    filter: hue-rotate(15deg);
}

.fragment-3::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        90deg,
        transparent 0px, transparent 6px,
        rgba(232, 58, 125, 0.3) 6px, rgba(232, 58, 125, 0.3) 8px
    );
}

.fragment-4 {
    width: 30%;
    height: 25%;
    top: 15%;
    left: 50%;
    background: #c82a2a;
    clip-path: polygon(10% 0, 100% 5%, 90% 100%, 0 95%);
    opacity: 0.5;
    transform: skewX(-5deg);
}

.fragment-5 {
    width: 70%;
    height: 45%;
    top: 10%;
    left: 5%;
    background: #e83a7d;
    clip-path: polygon(0 0, 95% 3%, 100% 100%, 5% 97%);
    opacity: 0.6;
}

.fragment-5::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px, transparent 3px,
        rgba(240, 228, 212, 0.2) 3px, rgba(240, 228, 212, 0.2) 4px
    );
}

.fragment-6 {
    width: 55%;
    height: 35%;
    bottom: 15%;
    right: 10%;
    background: #3ae8d8;
    clip-path: polygon(5% 5%, 100% 0, 95% 95%, 0 100%);
    opacity: 0.5;
    transform: skewX(4deg);
    mix-blend-mode: screen;
}

.fragment-7 {
    width: 40%;
    height: 30%;
    top: 40%;
    left: 15%;
    background: #2a1a1e;
    clip-path: polygon(0 0, 100% 8%, 95% 100%, 5% 92%);
    opacity: 0.7;
}

.fragment-8 {
    width: 80%;
    height: 30%;
    top: 5%;
    left: 10%;
    background: #e83a7d;
    clip-path: polygon(0 0, 100% 3%, 97% 100%, 3% 97%);
    opacity: 0.6;
    transform: skewX(-2deg);
}

.fragment-8::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px, transparent 5px,
        rgba(42, 26, 30, 0.5) 5px, rgba(42, 26, 30, 0.5) 6px
    );
}

.fragment-9 {
    width: 60%;
    height: 25%;
    top: 25%;
    right: 5%;
    background: #3ae8d8;
    clip-path: polygon(8% 0, 100% 5%, 92% 100%, 0 95%);
    opacity: 0.5;
    mix-blend-mode: screen;
}

.fragment-10 {
    width: 50%;
    height: 20%;
    top: 45%;
    left: 15%;
    background: #c82a2a;
    clip-path: polygon(0 5%, 100% 0, 100% 95%, 5% 100%);
    opacity: 0.6;
    transform: skewX(3deg);
}

.fragment-11 {
    width: 70%;
    height: 25%;
    bottom: 20%;
    left: 20%;
    background: #5c1a2a;
    clip-path: polygon(3% 0, 97% 8%, 100% 100%, 0 92%);
    opacity: 0.7;
    filter: hue-rotate(-10deg);
}

.fragment-12 {
    width: 45%;
    height: 20%;
    bottom: 5%;
    right: 10%;
    background: #f0e4d4;
    clip-path: polygon(0 0, 100% 10%, 95% 100%, 5% 90%);
    opacity: 0.4;
    transform: skewX(-4deg);
}

/* ============================================
   Footer Section
   ============================================ */

.footer-section {
    min-height: 50vh;
}

.footer-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(60px, 12vw, 160px);
    letter-spacing: 0.06em;
    color: #f0e4d4;
    text-shadow: -3px 0 #3ae8d8, 3px 0 #e83a7d;
    text-transform: uppercase;
}

.footer-title.dark {
    color: #5c1a2a;
    text-shadow: -3px 0 #e83a7d, 3px 0 #3ae8d8;
}

.footer-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px clamp(20px, 5vw, 60px);
    background: rgba(42, 26, 30, 0.85);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 5;
}

.footer-overlay .glitch-label {
    margin-bottom: 0;
    color: #3ae8d8;
}

/* ============================================
   Glitch Text Effect (applied via JS)
   ============================================ */

.glitch-text {
    position: relative;
}

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

.glitch-text::before {
    color: #3ae8d8;
    clip-path: inset(0 0 60% 0);
    transform: translateX(-3px);
}

.glitch-text::after {
    color: #e83a7d;
    clip-path: inset(60% 0 0 0);
    transform: translateX(3px);
}

/* ============================================
   Responsive / Mobile Stack
   ============================================ */

@media (max-width: 768px) {
    .split-section,
    .split-section.ratio-60-40,
    .split-section.ratio-40-60 {
        grid-template-columns: 1fr;
    }

    .panel {
        min-height: 60vh;
    }

    .footer-section .panel {
        min-height: 30vh;
    }

    .hero-title {
        font-size: clamp(60px, 20vw, 120px);
    }

    .section-title {
        font-size: clamp(36px, 10vw, 60px);
    }

    .footer-overlay {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .glitch-band-center {
        height: 6px;
    }

    .glitch-divider {
        height: 20px;
    }

    .panel-content {
        padding: clamp(20px, 5vw, 40px);
    }

    .glitch-collage {
        height: 200px;
    }

    .glitch-collage.large {
        min-height: 250px;
    }
}

/* ============================================
   Scanline Overlay (CRT effect)
   ============================================ */

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: repeating-linear-gradient(
        0deg,
        transparent 0px,
        transparent 2px,
        rgba(0, 0, 0, 0.03) 2px,
        rgba(0, 0, 0, 0.03) 4px
    );
    pointer-events: none;
    z-index: 9998;
}
