/* ================================================
   paraoligm.com — Midnight Broadcast Stylesheet
   ================================================ */

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

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

body {
    background-color: #060B1A;
    color: #C5CAE9;
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.85;
    overflow-x: hidden;
    position: relative;
}

/* --- Grain Overlay (persistent, animated) --- */
.grain-svg {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.06;
    animation: grainShift 0.8s steps(10, end) infinite;
}

@keyframes grainShift {
    0% { transform: translate(0, 0); }
    10% { transform: translate(-1px, 1px); }
    20% { transform: translate(2px, -1px); }
    30% { transform: translate(-2px, 2px); }
    40% { transform: translate(1px, -2px); }
    50% { transform: translate(-1px, -1px); }
    60% { transform: translate(2px, 1px); }
    70% { transform: translate(-2px, -2px); }
    80% { transform: translate(1px, 2px); }
    90% { transform: translate(-1px, 0); }
    100% { transform: translate(0, 0); }
}

/* --- Opening Screen --- */
#opening-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #060B1A;
    z-index: 10000;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.8s ease-out;
}

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

#opening-screen.hidden {
    display: none;
}

/* --- Sidebar --- */
#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: #0B1026;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transform: translateX(-280px);
    transition: transform 0.6s cubic-bezier(0.25, 0.1, 0.25, 1);
    border-right: 1px solid #1E2A5E;
}

#sidebar.visible {
    transform: translateX(0);
}

.sidebar-inner {
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    gap: 48px;
}

.sidebar-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: opacity 0.3s ease;
    opacity: 0.7;
}

.sidebar-label:nth-child(1) { transform: rotate(-1.5deg); }
.sidebar-label:nth-child(2) { transform: rotate(0.8deg); }
.sidebar-label:nth-child(3) { transform: rotate(-2deg); }
.sidebar-label:nth-child(4) { transform: rotate(1.2deg); }
.sidebar-label:nth-child(5) { transform: rotate(-0.5deg); }
.sidebar-label:nth-child(6) { transform: rotate(1.8deg); }

.sidebar-label:hover {
    opacity: 1;
}

.sidebar-label:hover .label-text {
    color: #6B7FD7;
    text-shadow: 0 0 12px rgba(107, 127, 215, 0.4);
}

.sidebar-label:hover .led {
    background: #6B7FD7;
    box-shadow: 0 0 8px rgba(107, 127, 215, 0.6);
}

.led {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #3D2C7C;
    flex-shrink: 0;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.sidebar-label:nth-child(1) .led { animation: ledPulse1 2.5s ease-in-out infinite; }
.sidebar-label:nth-child(2) .led { animation: ledPulse2 3.8s ease-in-out infinite; }
.sidebar-label:nth-child(3) .led { animation: ledPulse1 5.2s ease-in-out infinite; }
.sidebar-label:nth-child(4) .led { animation: ledPulse2 2.5s ease-in-out infinite; }
.sidebar-label:nth-child(5) .led { animation: ledPulse1 3.8s ease-in-out infinite; }
.sidebar-label:nth-child(6) .led { animation: ledPulse2 5.2s ease-in-out infinite; }

@keyframes ledPulse1 {
    0%, 100% { background: #3D2C7C; box-shadow: none; }
    50% { background: #6B7FD7; box-shadow: 0 0 6px rgba(107, 127, 215, 0.5); }
}

@keyframes ledPulse2 {
    0%, 100% { background: #6B7FD7; box-shadow: 0 0 6px rgba(107, 127, 215, 0.5); }
    50% { background: #3D2C7C; box-shadow: none; }
}

.label-text {
    font-family: 'Special Elite', monospace;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    letter-spacing: 0.08em;
    color: #8E99C4;
    transition: color 0.3s ease, text-shadow 0.3s ease;
    white-space: nowrap;
}

/* --- Main Content --- */
#main-content {
    margin-left: 280px;
    padding-left: 60px;
    padding-right: 40px;
    position: relative;
    opacity: 0;
    transition: opacity 0.8s ease, filter 0.3s ease;
}

#main-content.visible {
    opacity: 1;
}

#main-content.blurred {
    filter: blur(3px);
}

/* Wireframe grid background */
#main-content::before {
    content: '';
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    bottom: 0;
    background-image:
        linear-gradient(#1E2A5E 1px, transparent 1px),
        linear-gradient(90deg, #1E2A5E 1px, transparent 1px);
    background-size: 48px 48px;
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

/* --- Broadcast Segments --- */
.broadcast-segment {
    min-height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1;
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.1, 0.25, 1), transform 0.8s cubic-bezier(0.25, 0.1, 0.25, 1);
}

.broadcast-segment.revealed {
    opacity: 1;
    transform: translateY(0);
}

.segment-content {
    max-width: 680px;
    width: 100%;
    position: relative;
}

/* --- Dashed Section Dividers --- */
.broadcast-segment + .atmospheric-interlude {
    border-top: 1px dashed #1E2A5E;
}

/* --- Channel Numbers --- */
.channel-number {
    display: block;
    font-family: 'Special Elite', monospace;
    font-size: clamp(0.75rem, 1.2vw, 0.9rem);
    letter-spacing: 0.08em;
    color: #8E99C4;
    margin-bottom: 12px;
}

/* --- Section Titles --- */
.section-title {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3rem);
    color: #E8EAF6;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-bottom: 24px;
}

/* --- Hero Title --- */
.hero-title {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(3.2rem, 10vw, 7rem);
    color: #E8EAF6;
    letter-spacing: -0.02em;
    line-height: 1.1;
    display: inline;
}

.hero-cursor {
    display: inline-block;
    width: 2px;
    height: 0.85em;
    background: #D4A0B9;
    vertical-align: baseline;
    margin-left: 4px;
    animation: cursorBlink 530ms step-start infinite;
    position: relative;
    top: 0.05em;
}

@keyframes cursorBlink {
    0%, 60% { opacity: 1; }
    60.01%, 100% { opacity: 0; }
}

.typewriter-cursor.ghost {
    animation: none;
    opacity: 0.3;
}

/* --- Body Text --- */
.body-text {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.85;
    color: #C5CAE9;
    max-width: 600px;
}

/* Typewriter target hidden state (before animation) */
.typewriter-target.typewriter-pending {
    visibility: hidden;
}

.typewriter-target.typewriter-active {
    visibility: visible;
}

.typewriter-target.typewriter-done {
    visibility: visible;
}

/* Inline typewriter cursor */
.typewriter-inline-cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: #D4A0B9;
    vertical-align: text-bottom;
    margin-left: 2px;
    animation: cursorBlink 530ms step-start infinite;
}

.typewriter-inline-cursor.ghost {
    animation: none;
    opacity: 0.3;
}

/* --- Signal Bars --- */
.signal-bars {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 48px;
}

.signal-bar {
    height: 1px;
    background: #1E2A5E;
}

/* --- Atmospheric Interludes --- */
.atmospheric-interlude {
    height: 200px;
    background: linear-gradient(to bottom, #060B1A, #0B1026, #060B1A);
    position: relative;
    z-index: 1;
}

/* --- Mobile Toggle --- */
#mobile-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 32px;
    height: 24px;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
}

.toggle-bar {
    display: block;
    width: 100%;
    height: 2px;
    background: #8E99C4;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#mobile-toggle.open .toggle-bar:nth-child(1) {
    transform: rotate(45deg) translateY(11px);
}

#mobile-toggle.open .toggle-bar:nth-child(2) {
    opacity: 0;
}

#mobile-toggle.open .toggle-bar:nth-child(3) {
    transform: rotate(-45deg) translateY(-11px);
}

/* --- Mobile Overlay --- */
#mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(6, 11, 26, 0.95);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
}

#mobile-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.mobile-overlay-inner {
    display: flex;
    flex-direction: column;
    gap: 40px;
    padding: 80px 32px;
}

/* --- Responsive: Tablet (< 900px) --- */
@media (max-width: 900px) {
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 48px;
        flex-direction: row;
        transform: translateX(0) translateY(-48px);
        border-right: none;
        border-bottom: 1px solid #1E2A5E;
    }

    #sidebar.visible {
        transform: translateX(0) translateY(0);
    }

    .sidebar-inner {
        flex-direction: row;
        gap: 24px;
        padding: 0 24px;
        align-items: center;
        overflow-x: auto;
        overflow-y: hidden;
        width: 100%;
        height: 100%;
        scrollbar-width: none;
    }

    .sidebar-inner::-webkit-scrollbar {
        display: none;
    }

    .sidebar-label {
        transform: none !important;
        flex-shrink: 0;
    }

    #main-content {
        margin-left: 0;
        padding-left: 24px;
        padding-right: 24px;
        padding-top: 48px;
    }

    #main-content::before {
        left: 0;
    }
}

/* --- Responsive: Mobile (< 540px) --- */
@media (max-width: 540px) {
    #sidebar {
        display: none;
    }

    #mobile-toggle {
        display: flex;
    }

    #mobile-overlay {
        display: block;
    }

    #main-content {
        margin-left: 0;
        padding-left: 24px;
        padding-right: 24px;
        padding-top: 24px;
    }

    #main-content::before {
        left: 0;
    }

    .hero-title {
        font-size: clamp(2.4rem, 12vw, 4rem);
    }

    .section-title {
        font-size: clamp(1.6rem, 6vw, 2.4rem);
    }
}

/* --- Layout transition blur (responsive) --- */
body.layout-transitioning #main-content {
    filter: blur(2px);
    transition: filter 0.6s ease-in-out;
}

/* --- Scan lines (very subtle CRT effect) --- */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 2px,
        rgba(6, 11, 26, 0.03) 2px,
        rgba(6, 11, 26, 0.03) 4px
    );
    pointer-events: none;
    z-index: 9998;
}

/* --- Selection color --- */
::selection {
    background: #3D2C7C;
    color: #E8EAF6;
}
