/* ============================================================
   HISTORYGRAPHER.NET - RETRO-FUTURISTIC OBSERVATORY STYLES
   ============================================================ */

/* Root Variables */
:root {
    /* Colors */
    --deep-observatory: #0B0E17;
    --condensation-glass: rgba(15, 20, 35, 0.72);
    --amber-phosphor: #E8A84C;
    --frost-signal: #7EB8D4;
    --frost-white: #E2E8F0;
    --signal-gray: #8A95A8;
    --crt-green: #4ADE80;
    --frosted-panel: rgba(30, 40, 65, 0.55);
    --warm-ember: #D4785A;
    --ice-line: rgba(126, 184, 212, 0.18);
    --dark-bg: #111827;
    --dark-bg-alt: #0F1628;

    /* Dimensions */
    --sidebar-width: 280px;
    --sidebar-width-mobile: 0;

    /* Typography */
    --font-display: 'Anybody', sans-serif;
    --font-body: 'Space Grotesk', sans-serif;
    --font-mono: 'IBM Plex Mono', monospace;
}

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

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

html {
    scroll-behavior: smooth;
}

body {
    background: linear-gradient(165deg, var(--deep-observatory) 0%, var(--dark-bg) 40%, var(--dark-bg-alt) 100%);
    color: var(--frost-white);
    font-family: var(--font-body);
    line-height: 1.75;
    position: relative;
    overflow-x: hidden;
}

/* Noise/Grain Texture */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' result='noise'/%3E%3C/filter%3E%3Crect width='100' height='100' fill='%23fff' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    opacity: 0.03;
    pointer-events: none;
    z-index: 1000;
}

/* Scan lines */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.02),
        rgba(255, 255, 255, 0.02) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 999;
}

/* ============================================================
   LAYOUT STRUCTURE
   ============================================================ */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--condensation-glass);
    backdrop-filter: blur(16px) saturate(140%);
    border-right: 1px solid var(--ice-line);
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 32px;
}

.viewport {
    margin-left: var(--sidebar-width);
    position: relative;
}

.channel {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px 40px;
    position: relative;
}

/* ============================================================
   SIDEBAR COMPONENTS
   ============================================================ */

.logotype {
    text-align: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: clamp(0.875rem, 1.2vw, 1.1rem);
    letter-spacing: 0.35em;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.logotype-text {
    display: block;
    color: var(--frost-white);
}

.logotype-net {
    display: block;
    color: var(--amber-phosphor);
    font-size: 0.75em;
    letter-spacing: 0.25em;
}

/* Timeline Scrubber */
.timeline-scrubber {
    position: relative;
    height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    flex-grow: 1;
    min-height: 120px;
}

.timeline-line {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--frost-signal);
    opacity: 0.3;
    transform: translateX(-50%);
}

.timeline-marker {
    position: relative;
    z-index: 10;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.led-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(232, 168, 76, 0.8), rgba(232, 168, 76, 0.2));
    box-shadow: 0 0 8px rgba(232, 168, 76, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.3);
    transition: all 0.3s ease;
}

.timeline-marker.active .led-indicator {
    background: radial-gradient(circle at 30% 30%, rgba(74, 222, 128, 0.9), rgba(74, 222, 128, 0.2));
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

/* Navigation */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.nav-link {
    color: var(--signal-gray);
    text-decoration: none;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 8px 12px;
    border-left: 2px solid transparent;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: block;
}

.nav-link:hover,
.nav-link.active {
    color: var(--amber-phosphor);
    border-left-color: var(--amber-phosphor);
    padding-left: 14px;
}

/* Signal Strength */
.signal-strength {
    display: flex;
    gap: 4px;
    justify-content: center;
    margin-top: auto;
}

.signal-bar {
    width: 3px;
    height: calc(8px + var(--i) * 3px);
    background: var(--amber-phosphor);
    border-radius: 2px;
    opacity: 0.5;
    animation: signalWave 1.5s ease-in-out infinite;
    animation-delay: calc(var(--i) * 80ms);
}

@keyframes signalWave {
    0%, 100% {
        opacity: 0.5;
        transform: scaleY(1);
    }
    50% {
        opacity: 1;
        transform: scaleY(1.3);
    }
}

/* ============================================================
   HERO SECTION
   ============================================================ */

#section-1 {
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.hero-canvas-wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
}

#lissajousCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.hero-text {
    position: relative;
    z-index: 10;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: bounceIn 1s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 0.3s;
}

.hero-title {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 7vw, 6rem);
    font-weight: 700;
    font-variation-settings: 'wdth' 125;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--amber-phosphor);
    transition: font-variation-settings 0.4s ease;
}

.hero-title:hover {
    font-variation-settings: 'wdth' 100;
}

.hero-subtitle {
    font-family: var(--font-mono);
    font-size: clamp(0.875rem, 1.2vw, 1.1rem);
    color: var(--frost-signal);
    font-weight: 400;
    letter-spacing: 0.08em;
}

/* ============================================================
   SECTION TITLES & GENERAL
   ============================================================ */

.section-title {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 700;
    font-variation-settings: 'wdth' 125;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--frost-white);
    margin-bottom: 40px;
    text-align: center;
    animation: bounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Bounce-in animation */
@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: translateY(40px) scale(0.92);
    }
    60% {
        opacity: 1;
        transform: translateY(-8px) scale(1.02);
    }
    80% {
        transform: translateY(3px) scale(0.99);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}

/* ============================================================
   WAVEFORM ARCHIVE SECTION
   ============================================================ */

#section-2 {
    padding: 80px 40px;
}

.waveforms-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.waveform-card {
    position: relative;
    height: 200px;
    animation: bounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: calc(var(--i) * 80ms);
}

.waveform-visual {
    width: 100%;
    height: 120px;
    background: rgba(11, 14, 23, 0.5);
    border-radius: 8px 8px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

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

.waveform-path {
    stroke-linecap: round;
    stroke-linejoin: round;
}

.waveform-frost-card {
    background: var(--frosted-panel);
    backdrop-filter: blur(12px) saturate(140%);
    border: 1px solid var(--ice-line);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.waveform-period {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--amber-phosphor);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.waveform-description {
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--frost-white);
    font-weight: 400;
}

/* ============================================================
   OSCILLOGRAPH SECTION
   ============================================================ */

#section-3 {
    padding: 80px 40px;
}

.oscillograph-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    aspect-ratio: 1;
}

.oscillograph-svg {
    width: 100%;
    height: 100%;
    animation: bounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.oscillograph-sweep {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    background: conic-gradient(from 0deg at 50% 50%, transparent 0deg, rgba(232, 168, 76, 0.2) 45deg, transparent 90deg);
    animation: sweep 8s linear infinite;
    pointer-events: none;
    border-radius: 50%;
}

@keyframes sweep {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ============================================================
   DEEP TIME SECTION
   ============================================================ */

#section-4 {
    padding: 80px 40px;
    perspective: 1000px;
}

.deep-time-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

.deep-time-panel {
    background: var(--frosted-panel);
    backdrop-filter: blur(12px) saturate(140%);
    border: 1px solid var(--ice-line);
    padding: 32px;
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transform: translateZ(calc(var(--depth, 1) * 20px));
    animation: bounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: calc(var(--depth, 1) * 80ms);
}

.deep-time-panel h3 {
    font-family: var(--font-display);
    font-size: clamp(1.25rem, 2vw, 1.75rem);
    font-weight: 700;
    color: var(--amber-phosphor);
    margin-bottom: 12px;
    letter-spacing: 0.08em;
}

.deep-time-panel p {
    font-size: clamp(0.875rem, 1.1vw, 1rem);
    color: var(--frost-white);
    line-height: 1.6;
}

/* ============================================================
   TRANSMISSION LOG SECTION
   ============================================================ */

#section-5 {
    padding: 80px 40px;
}

.transmission-log {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.transmission-line {
    background: var(--frosted-panel);
    backdrop-filter: blur(12px) saturate(140%);
    border: 1px solid var(--ice-line);
    padding: 16px 20px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: clamp(0.75rem, 1vw, 0.95rem);
    color: var(--crt-green);
    display: flex;
    gap: 12px;
    box-shadow: 0 0 8px rgba(74, 222, 128, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.06);
    animation: bounceIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.transmission-timestamp {
    color: var(--amber-phosphor);
    flex-shrink: 0;
    min-width: 100px;
    font-weight: 500;
}

.transmission-text {
    flex: 1;
    font-variant-numeric: tabular-nums;
}

.transmission-line:nth-child(1) {
    animation-delay: 0.1s;
}
.transmission-line:nth-child(2) {
    animation-delay: 0.18s;
}
.transmission-line:nth-child(3) {
    animation-delay: 0.26s;
}
.transmission-line:nth-child(4) {
    animation-delay: 0.34s;
}
.transmission-line:nth-child(5) {
    animation-delay: 0.42s;
}
.transmission-line:nth-child(6) {
    animation-delay: 0.50s;
}
.transmission-line:nth-child(7) {
    animation-delay: 0.58s;
}
.transmission-line:nth-child(8) {
    animation-delay: 0.66s;
}

/* ============================================================
   SCANLINES
   ============================================================ */

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-image: repeating-linear-gradient(
        0deg,
        rgba(255, 255, 255, 0.015),
        rgba(255, 255, 255, 0.015) 1px,
        transparent 1px,
        transparent 2px
    );
    z-index: 998;
}

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

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0;
    }

    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: auto;
        flex-direction: row;
        padding: 16px;
        backdrop-filter: blur(12px) saturate(130%);
        z-index: 50;
    }

    .sidebar-content {
        flex-direction: row;
        gap: 16px;
        align-items: center;
        justify-content: space-between;
    }

    .logotype {
        margin-bottom: 0;
        font-size: 0.75rem;
    }

    .timeline-scrubber {
        height: auto;
        width: 100%;
        flex-direction: row;
        gap: 12px;
        flex-grow: 0;
        min-height: auto;
    }

    .timeline-line {
        position: static;
        width: 100%;
        height: 2px;
    }

    .sidebar-nav {
        flex-direction: row;
        gap: 8px;
        flex-grow: 0;
        overflow-x: auto;
    }

    .nav-link {
        font-size: 0.65rem;
        white-space: nowrap;
    }

    .signal-strength {
        gap: 3px;
    }

    .channel {
        padding: 100px 20px 60px;
        margin-top: 0;
    }

    .viewport {
        margin-left: 0;
        margin-top: 60px;
    }

    #section-1 {
        margin-top: -60px;
        padding-top: 100px;
    }

    .section-title {
        font-size: clamp(1.5rem, 4vw, 2.5rem);
        margin-bottom: 24px;
    }

    .waveforms-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .hero-title {
        font-size: clamp(1.75rem, 5vw, 3rem);
    }
}

@supports (backdrop-filter: blur(0)) {
    .sidebar {
        background: var(--condensation-glass);
    }

    .waveform-frost-card,
    .deep-time-panel,
    .transmission-line {
        background: var(--frosted-panel);
    }
}

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(0)) {
    .sidebar {
        background: rgba(15, 20, 35, 0.92);
    }

    .waveform-frost-card,
    .deep-time-panel,
    .transmission-line {
        background: rgba(30, 40, 65, 0.75);
    }
}
