/* ============================================
   causality.club - Blobitecture Observatory
   Midnight-blue palette, bounce-enter animation,
   organic dashboard layout with bokeh backgrounds.
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --abyss-navy: #0a0e1a;
    --midnight-indigo: #111b33;
    --deep-cobalt: #1a2a4d;
    --electric-violet: #7b5cff;
    --nebula-pink: #e84393;
    --star-white: #e8eaf0;
    --cosmic-gray: #8892a8;
    --plasma-cyan: #00d4ff;
    --supernova-orange: #ff6b35;
    --void-black: #060810;

    --font-display: 'Nunito', sans-serif;
    --font-body: 'Varela Round', sans-serif;
    --font-mono: 'Space Mono', monospace;

    --bounce-enter: cubic-bezier(0.34, 1.56, 0.64, 1);
    --smooth-ease: cubic-bezier(0.37, 0, 0.63, 1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--abyss-navy);
    color: var(--star-white);
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    line-height: 1.65;
    letter-spacing: 0.015em;
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Utility --- */
.hidden {
    opacity: 0;
    transform: translateY(40px) scale(0.9);
}

/* ============================================
   OBSERVATORY DOME (Top 55vh)
   ============================================ */
#observatory-dome {
    position: relative;
    width: 100%;
    height: 55vh;
    min-height: 420px;
    border-radius: 60px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    clip-path: ellipse(55% 50% at 50% 50%);
    z-index: 2;
}

/* Bokeh Container */
#bokeh-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.bokeh-circle {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.3);
    pointer-events: none;
}

.bokeh-circle.animate-in {
    animation: bokehEnter 800ms var(--bounce-enter) forwards;
}

@keyframes bokehEnter {
    to {
        opacity: var(--bokeh-opacity, 0.25);
        transform: scale(1);
    }
}

/* Pulse animation for the largest bokeh circles */
@keyframes bokehPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* Decorative Blobs */
.blob {
    position: absolute;
    border-radius: 40% 60% 50% 70% / 60% 40% 70% 50%;
    opacity: 0.1;
    pointer-events: none;
    z-index: 0;
    animation: blobMorph 14s var(--smooth-ease) infinite alternate;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: linear-gradient(135deg, var(--midnight-indigo), var(--deep-cobalt));
    top: -100px;
    left: -80px;
    animation-duration: 16s;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: linear-gradient(225deg, var(--deep-cobalt), var(--midnight-indigo));
    top: 50px;
    right: -60px;
    animation-duration: 12s;
    animation-delay: -4s;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: linear-gradient(180deg, var(--midnight-indigo), var(--deep-cobalt));
    bottom: -80px;
    left: 30%;
    animation-duration: 15s;
    animation-delay: -8s;
}

@keyframes blobMorph {
    0% {
        border-radius: 40% 60% 50% 70% / 60% 40% 70% 50%;
    }
    100% {
        border-radius: 60% 40% 70% 50% / 40% 60% 50% 70%;
    }
}

/* Hero Content */
#hero-content {
    position: relative;
    z-index: 10;
    text-align: center;
    padding: 2rem;
}

#hero-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(2.8rem, 7vw, 6rem);
    letter-spacing: -0.02em;
    color: var(--star-white);
    transition: opacity 600ms var(--bounce-enter), transform 600ms var(--bounce-enter);
}

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

#hero-subtitle {
    font-family: var(--font-body);
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.15rem);
    color: var(--cosmic-gray);
    margin-top: 0.75rem;
    transition: opacity 500ms ease, transform 500ms ease;
}

#hero-subtitle.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ============================================
   NERVE CENTER (Middle Band ~25vh)
   ============================================ */
#nerve-center {
    position: relative;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 40px 5%;
    min-height: 25vh;
    align-items: stretch;
}

.nerve-panel {
    background-color: var(--midnight-indigo);
    border-radius: 36px;
    padding: 28px 32px;
    position: relative;
    overflow: hidden;
    opacity: 0;
    transform: translateY(30px) scale(0.92);
    transition: transform 300ms var(--bounce-enter),
                box-shadow 300ms var(--bounce-enter),
                filter 300ms ease;
}

.nerve-panel.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    animation: panelBounceIn 600ms var(--bounce-enter) forwards;
}

@keyframes panelBounceIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.nerve-panel:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 40px rgba(123, 92, 255, 0.2);
    filter: brightness(1.08);
}

.nerve-panel:hover .panel-star {
    transform: rotate(90deg);
}

/* Panel sizing */
.panel-thesis {
    flex: 1 1 280px;
    border-radius: 40px;
    min-height: 220px;
}

.panel-orrery {
    flex: 0 1 260px;
    border-radius: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 260px;
}

.panel-feed {
    flex: 1 1 240px;
    border-radius: 32px;
    min-height: 220px;
}

.panel-manifesto {
    flex: 1 1 260px;
    border-radius: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 200px;
}

/* Panel Star Glyph */
.panel-star {
    position: absolute;
    top: 18px;
    left: 22px;
    font-family: var(--font-display);
    font-size: 1.1rem;
    color: var(--electric-violet);
    opacity: 0.6;
    transform: rotate(15deg);
    transition: transform 300ms var(--bounce-enter);
    display: inline-block;
}

/* Panel Headings */
.panel-heading {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: clamp(1.2rem, 2.5vw, 1.8rem);
    letter-spacing: -0.02em;
    color: var(--star-white);
    margin-bottom: 14px;
    padding-left: 28px;
}

/* Panel Body Text */
.panel-body {
    font-family: var(--font-body);
    color: var(--star-white);
    line-height: 1.65;
    margin-bottom: 16px;
}

.panel-fragment {
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--electric-violet);
    letter-spacing: 0.08em;
    margin-top: auto;
}

/* ============================================
   ORRERY (Concentric Rings)
   ============================================ */
.orrery-container {
    width: 180px;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px auto;
}

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

.ring {
    fill: none;
    stroke-width: 2px;
}

.ring-1 {
    stroke: var(--supernova-orange);
    animation: rotateClockwise 20s linear infinite;
    transform-origin: 100px 100px;
}

.ring-2 {
    stroke: var(--nebula-pink);
    animation: rotateCounterClockwise 30s linear infinite;
    transform-origin: 100px 100px;
}

.ring-3 {
    stroke: var(--electric-violet);
    animation: rotateClockwise 45s linear infinite;
    transform-origin: 100px 100px;
}

.ring-4 {
    stroke: var(--plasma-cyan);
    animation: rotateClockwise 60s linear infinite;
    transform-origin: 100px 100px;
}

/* Orbital dots */
.orbital-dot { fill: var(--star-white); }
.dot-1 {
    animation: rotateClockwise 20s linear infinite;
    transform-origin: 100px 100px;
}
.dot-2 {
    animation: rotateCounterClockwise 30s linear infinite;
    transform-origin: 100px 100px;
}
.dot-3 {
    animation: rotateClockwise 45s linear infinite;
    transform-origin: 100px 100px;
}
.dot-4 {
    animation: rotateClockwise 60s linear infinite;
    transform-origin: 100px 100px;
}

@keyframes rotateClockwise {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes rotateCounterClockwise {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

.orrery-label {
    font-family: var(--font-mono);
    font-size: 0.75em;
    color: var(--cosmic-gray);
    letter-spacing: 0.08em;
    text-align: center;
    margin-top: 8px;
}

.data-accent {
    color: var(--plasma-cyan);
    font-weight: 700;
}

/* ============================================
   SIGNAL FEED
   ============================================ */
.feed-container {
    width: 100%;
    flex: 1;
    overflow: hidden;
}

.feed-mask {
    height: 160px;
    overflow: hidden;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
}

.feed-scroll {
    animation: feedScroll 24s linear infinite;
}

@keyframes feedScroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(-50%); }
}

.feed-line {
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--cosmic-gray);
    letter-spacing: 0.08em;
    padding: 4px 0;
    white-space: nowrap;
    line-height: 1.6;
}

/* ============================================
   MANIFESTO PANEL
   ============================================ */
.manifesto-quote {
    font-family: var(--font-body);
    font-size: 1.05em;
    color: var(--star-white);
    line-height: 1.7;
    font-style: italic;
    border-left: 3px solid var(--nebula-pink);
    padding-left: 18px;
    margin: 0 0 12px 0;
}

.manifesto-attribution {
    font-family: var(--font-mono);
    font-size: 0.8em;
    color: var(--cosmic-gray);
    letter-spacing: 0.08em;
}

/* ============================================
   SUBSTRATE (Bottom 20vh)
   ============================================ */
#substrate {
    position: relative;
    min-height: 20vh;
    background: radial-gradient(ellipse at center, var(--abyss-navy), var(--void-black));
    padding: 40px 5% 30px;
    overflow: hidden;
    z-index: 1;
}

#star-field {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.micro-star {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--star-white);
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    animation: twinkle var(--twinkle-duration, 4s) ease-in-out infinite alternate;
    animation-delay: var(--twinkle-delay, 0s);
}

@keyframes twinkle {
    0% { opacity: 0.2; }
    100% { opacity: 0.8; }
}

#constellation-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.constellation-line {
    stroke: var(--cosmic-gray);
    stroke-width: 1px;
    stroke-opacity: 0.2;
    fill: none;
    stroke-dasharray: var(--line-length, 100);
    stroke-dashoffset: var(--line-length, 100);
    animation: drawLine var(--draw-duration, 5s) ease forwards;
    animation-delay: var(--draw-delay, 0s);
}

@keyframes drawLine {
    to { stroke-dashoffset: 0; }
}

#substrate-content {
    position: relative;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.substrate-nav {
    display: flex;
    gap: 24px;
}

.substrate-link {
    font-family: var(--font-body);
    font-size: 0.9em;
    color: var(--cosmic-gray);
    cursor: pointer;
    transition: color 300ms ease;
    border-radius: 16px;
    padding: 6px 14px;
}

.substrate-link:hover {
    color: var(--electric-violet);
}

.substrate-status {
    display: flex;
    align-items: center;
    gap: 10px;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--supernova-orange);
    animation: livePulse 1.5s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 107, 53, 0.6);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(255, 107, 53, 0);
    }
}

.live-label {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.75em;
    color: var(--supernova-orange);
    letter-spacing: 0.12em;
}

.status-text {
    font-family: var(--font-mono);
    font-size: 0.75em;
    color: var(--cosmic-gray);
    letter-spacing: 0.08em;
}

.substrate-attribution {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.attribution-text {
    font-family: var(--font-body);
    font-size: 0.8em;
    color: var(--cosmic-gray);
    opacity: 0.6;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    #observatory-dome {
        height: 50vh;
        min-height: 340px;
        clip-path: ellipse(65% 50% at 50% 50%);
    }

    #nerve-center {
        flex-direction: column;
        padding: 30px 4%;
    }

    .nerve-panel {
        flex: 1 1 auto;
        min-height: unset;
    }

    .panel-orrery {
        flex: 1 1 auto;
    }

    #substrate-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .substrate-attribution {
        align-items: center;
    }
}

@media (max-width: 600px) {
    #observatory-dome {
        height: 45vh;
        min-height: 280px;
        clip-path: ellipse(75% 50% at 50% 50%);
        border-radius: 40px;
    }

    .nerve-panel {
        border-radius: 24px;
        padding: 22px 20px;
    }

    .substrate-nav {
        flex-wrap: wrap;
        justify-content: center;
    }
}
