/* ============================================================================
   HIL.ST - Design Language Implementation
   Glitch aesthetic, signal/noise bands, CRT scan-line energy
   ============================================================================ */

/* CSS Custom Properties */
:root {
    /* Colors */
    --color-deep-burgundy: #6B1D3A;
    --color-cream: #F5EDE0;
    --color-blood-signal: #C4244A;
    --color-dark-ground: #1A0E14;
    --color-warm-ash: #8C7D75;
    --color-copper-trace: #B87333;
    --color-pale-blush: #F0D9D0;

    /* Typography */
    --font-display: 'Source Sans 3', sans-serif;
    --font-body: 'Source Serif 4', serif;
    --font-code: 'JetBrains Mono', monospace;

    /* Layout */
    --content-width: 70%;
    --glitch-width: 40%;
    --gutter: 24px;
}

/* ============================================================================
   RESET & GLOBAL
   ============================================================================ */

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-body);
    color: var(--color-cream);
    background-color: var(--color-deep-burgundy);
    line-height: 1.7;
    letter-spacing: 0.01em;
    text-rendering: optimizeLegibility;
    font-feature-settings: 'liga' 1, 'kern' 1;
    overflow-x: hidden;
    position: relative;
}

/* CRT Scan-line Overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(245, 237, 224, 0.03) 0px,
        rgba(245, 237, 224, 0.03) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 2000;
}

/* ============================================================================
   FREQUENCY BAR (Navigation)
   ============================================================================ */

.frequency-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: var(--color-dark-ground);
    border-bottom: 1px solid var(--color-blood-signal);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--gutter);
    z-index: 1000;
    animation: barFlicker 0.3s infinite;
}

.frequency-bar::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg,
        var(--color-blood-signal) 0%,
        var(--color-copper-trace) 50%,
        var(--color-blood-signal) 100%
    );
    animation: borderFlicker 0.15s infinite;
    opacity: 0.8;
}

.domain-name {
    font-family: var(--font-code);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    color: var(--color-cream);
    text-transform: uppercase;
}

.frequency-meters {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    height: 30px;
}

.meter {
    width: 4px;
    height: calc(var(--meter-height) * 30px);
    background: linear-gradient(180deg, var(--color-blood-signal), var(--color-copper-trace));
    animation: meterPulse 1s ease-in-out infinite;
    opacity: 0.8;
}

.meter:nth-child(2n) {
    animation-delay: 0.15s;
}

.meter:nth-child(3n) {
    animation-delay: 0.3s;
}

/* ============================================================================
   CONTENT WRAPPER & LAYOUT
   ============================================================================ */

.content-wrapper {
    padding-top: 48px;
}

section {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: 4rem var(--gutter);
    position: relative;
    overflow: hidden;
}

/* Signal bands (content-bearing) */
.signal-band {
    background-color: var(--color-deep-burgundy);
    color: var(--color-cream);
    flex-direction: row;
    gap: 4rem;
}

.signal-band::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(196, 36, 74, 0.1) 0px,
        rgba(196, 36, 74, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    animation: scanLineScroll 8s linear infinite;
}

/* Noise bands (decorative interference) */
.noise-band {
    background-color: var(--color-dark-ground);
    height: 15vh;
    min-height: auto;
    padding: 0;
    display: grid;
    place-items: center;
    position: relative;
}

.noise-band-dark {
    background-color: #0A0608;
}

.noise-band-final {
    height: 30vh;
}

/* ============================================================================
   GLITCH TEXTURE (Animated Noise)
   ============================================================================ */

.glitch-texture {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(196, 36, 74, 0.3) 0px,
        rgba(196, 36, 74, 0.3) 2px,
        rgba(184, 115, 51, 0.2) 2px,
        rgba(184, 115, 51, 0.2) 4px,
        transparent 4px,
        transparent 8px
    );
    background-size: 100% 8px;
    animation: glitchShift 0.5s steps(5, end) infinite;
    opacity: 0.6;
}

.glitch-texture-inverted {
    background: repeating-linear-gradient(
        90deg,
        rgba(245, 237, 224, 0.2) 0px,
        rgba(245, 237, 224, 0.2) 3px,
        rgba(196, 36, 74, 0.3) 3px,
        rgba(196, 36, 74, 0.3) 6px
    );
    animation: glitchShiftH 0.5s steps(5, end) infinite;
}

/* ============================================================================
   CONTENT PACKETS (Data Containers)
   ============================================================================ */

.content-packet {
    position: relative;
    z-index: 10;
    width: var(--content-width);
    max-width: 600px;
    margin-left: 8vw;
    border: 1px solid var(--color-cream);
    padding: 2.5rem;
    background: rgba(0, 0, 0, 0.3);
}

.content-packet-dark {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(245, 237, 224, 0.5);
}

/* Signal dark variant */
.signal-dark {
    background-color: var(--color-dark-ground);
    color: var(--color-cream);
}

.signal-dark .content-packet {
    border-color: var(--color-copper-trace);
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */

h1, h2 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

h1 {
    font-size: clamp(2.5rem, 6vw, 5.5rem);
    margin-bottom: 1rem;
}

h2 {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    margin-bottom: 1.5rem;
    color: var(--color-pale-blush);
}

p {
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

.glitch-title {
    color: var(--color-pale-blush);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.glitch-text {
    color: var(--color-cream);
}

.glitch-text-light {
    color: var(--color-pale-blush);
}

code, .packet-label {
    font-family: var(--font-code);
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-copper-trace);
    font-weight: 400;
}

/* ============================================================================
   GLITCH ZONES (Right-side decorative areas)
   ============================================================================ */

.glitch-zone {
    position: relative;
    z-index: 5;
    width: var(--glitch-width);
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.glitch-zone.right {
    margin-left: auto;
    margin-right: 8vw;
}

/* ============================================================================
   CIRCUIT MOTIFS
   ============================================================================ */

.circuit-motif {
    width: 200px;
    height: 200px;
    color: var(--color-copper-trace);
    opacity: 0.7;
    animation: circuitPulse 2s ease-in-out infinite;
}

.circuit-group,
.circuit-group-alt {
    fill: currentColor;
    stroke: currentColor;
}

/* ============================================================================
   DATA PACKETS GRID
   ============================================================================ */

.packet-group {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 2rem 0;
}

.data-packet {
    padding: 1.5rem;
    border-left: 3px solid var(--color-blood-signal);
    background: rgba(196, 36, 74, 0.1);
    transition: all 0.3s ease;
}

.data-packet:hover {
    background: rgba(196, 36, 74, 0.2);
    border-left-color: var(--color-copper-trace);
    transform: translateX(8px);
}

.data-packet p {
    margin: 0;
    font-size: 1rem;
}

/* ============================================================================
   FREQUENCY BAR DECORATIVE (in glitch zones)
   ============================================================================ */

.frequency-bar-decorative {
    position: relative;
    width: 100%;
    height: 200px;
    border: 1px dashed var(--color-copper-trace);
    display: flex;
    align-items: center;
    justify-content: space-around;
    opacity: 0.6;
}

.frequency-dot {
    width: 8px;
    height: 8px;
    background: var(--color-blood-signal);
    border-radius: 50%;
    position: absolute;
    left: var(--dot-position);
    animation: dotPulse 1.5s ease-in-out infinite;
}

/* ============================================================================
   VISUALIZATION & ENERGY INDICATORS
   ============================================================================ */

.visualization {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 2rem 0;
    align-items: center;
}

.signal-wave {
    width: 300px;
    max-width: 100%;
    height: 40px;
    border: 1px solid var(--color-copper-trace);
    position: relative;
    overflow: hidden;
}

.signal-wave::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--color-blood-signal) 25%,
        transparent 50%,
        var(--color-copper-trace) 75%,
        transparent 100%
    );
    animation: signalScroll 1s linear infinite;
}

.energy-indicators {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin: 2rem 0;
    width: 100%;
}

.indicator {
    aspect-ratio: 1;
    border: 2px solid var(--color-copper-trace);
    position: relative;
    background: rgba(184, 115, 51, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.indicator::before {
    content: '';
    position: absolute;
    width: 2px;
    height: 100%;
    background: var(--color-blood-signal);
    animation: indicatorScan 1s linear infinite;
}

.indicator::after {
    content: attr(data-label);
    position: absolute;
    bottom: 8px;
    font-family: var(--font-code);
    font-size: 0.7rem;
    color: var(--color-copper-trace);
    text-transform: uppercase;
}

/* ============================================================================
   END MESSAGE
   ============================================================================ */

.signal-end {
    position: relative;
    z-index: 20;
    text-align: center;
}

.end-message {
    font-family: var(--font-code);
    font-size: clamp(2rem, 5vw, 3.5rem);
    letter-spacing: 0.1em;
    color: var(--color-blood-signal);
    text-transform: uppercase;
    animation: endGlitch 0.5s steps(3, end) infinite;
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

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

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

@keyframes scanLineScroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(100%); }
}

@keyframes glitchShift {
    0%, 100% { background-position: 0 0; }
    25% { background-position: 0 8px; }
    50% { background-position: 0 -8px; }
    75% { background-position: 0 4px; }
}

@keyframes glitchShiftH {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(4px); }
    50% { transform: translateX(-4px); }
    75% { transform: translateX(2px); }
}

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

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

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

@keyframes signalScroll {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes indicatorScan {
    0% { left: 0; }
    100% { left: 100%; }
}

@keyframes endGlitch {
    0% { clip-path: inset(0); }
    33% { clip-path: inset(0 0 60% 0); }
    66% { clip-path: inset(40% 0 0 0); }
    100% { clip-path: inset(0); }
}

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

@media (max-width: 1024px) {
    :root {
        --content-width: 100%;
        --glitch-width: 100%;
    }

    .signal-band {
        flex-direction: column;
        gap: 2rem;
    }

    .content-packet {
        width: 100%;
        margin-left: 0;
    }

    .glitch-zone {
        width: 100%;
        height: 300px;
        margin-right: 0;
    }

    .circuit-motif {
        width: 150px;
        height: 150px;
    }

    .energy-indicators {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    :root {
        --gutter: 16px;
    }

    .frequency-bar {
        padding: 0 12px;
        height: 44px;
    }

    section {
        padding: 2rem var(--gutter);
        min-height: auto;
    }

    .noise-band {
        height: 10vh;
    }

    h1 { font-size: clamp(2rem, 8vw, 3rem); }
    h2 { font-size: clamp(1.3rem, 5vw, 1.8rem); }
    p { font-size: clamp(0.95rem, 2vw, 1.1rem); }

    .content-packet {
        padding: 1.5rem;
    }

    .data-packet {
        padding: 1rem;
    }

    .frequency-bar-decorative {
        height: 150px;
    }

    .signal-wave {
        width: 100%;
    }

    .energy-indicators {
        grid-template-columns: 1fr;
    }

    .end-message {
        font-size: clamp(1.5rem, 4vw, 2rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
