/* ==========================================================================
   soning.stream — a generative horizontal-scroll canvas for reasoning
   Palette: #0E0E14 #14141E #4A8ABE #BE4A8A #8ABE4A #F0F0F4 #8A8A9E
   Fonts:   EB Garamond (display), Public Sans (body), Inconsolata (labels)
   ========================================================================== */

:root {
    --bg: #0E0E14;
    --surface: rgba(20, 20, 30, 0.8);
    --stream-blue: #4A8ABE;
    --stream-magenta: #BE4A8A;
    --stream-green: #8ABE4A;
    --text: #F0F0F4;
    --text-muted: #8A8A9E;
    --panel-count: 8;

    --font-display: "EB Garamond", "Lora", Georgia, serif;
    --font-body: "Public Sans", "Inter", system-ui, sans-serif;
    --font-mono: "Inconsolata", "Space Mono", ui-monospace, monospace;
}

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

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 20% 30%, rgba(74, 138, 190, 0.08), transparent 60%),
        radial-gradient(circle at 80% 70%, rgba(190, 74, 138, 0.07), transparent 60%),
        radial-gradient(circle at 50% 90%, rgba(138, 190, 74, 0.06), transparent 60%);
    z-index: 1;
    mix-blend-mode: screen;
}

/* ==========================================================================
   Horizontal Stream
   ========================================================================== */

.stream {
    position: relative;
    display: flex;
    flex-direction: row;
    width: max-content;
    height: 100vh;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x proximity;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    z-index: 2;
}

.stream::-webkit-scrollbar { display: none; }

.panel {
    position: relative;
    flex: 0 0 100vw;
    width: 100vw;
    height: 100vh;
    scroll-snap-align: start;
    overflow: hidden;
    isolation: isolate;
}

/* ==========================================================================
   Flow Field Background Layers (conic-gradient stacks)
   Each variant uses 3 layers at Fibonacci rotation rates.
   ========================================================================== */

.flow-field {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
}

.flow-field::before,
.flow-field::after,
.flow-field > .field-layer {
    content: "";
    position: absolute;
    inset: -30%;
    border-radius: 50%;
    mix-blend-mode: screen;
    filter: blur(16px);
    transform: rotate(var(--angle, 0deg));
    will-change: transform;
}

.flow-field::before {
    background: conic-gradient(
        from 0deg at 30% 40%,
        transparent 0deg,
        rgba(74, 138, 190, 0.22) 60deg,
        transparent 140deg,
        rgba(190, 74, 138, 0.18) 220deg,
        transparent 320deg
    );
    animation: spin-a 21s linear infinite;
}

.flow-field::after {
    background: conic-gradient(
        from 180deg at 70% 60%,
        transparent 0deg,
        rgba(138, 190, 74, 0.20) 80deg,
        transparent 160deg,
        rgba(74, 138, 190, 0.18) 240deg,
        transparent 340deg
    );
    animation: spin-b 13s linear infinite reverse;
}

.flow-field > .field-layer {
    background: conic-gradient(
        from 45deg at 50% 50%,
        rgba(190, 74, 138, 0.15),
        transparent 120deg,
        rgba(138, 190, 74, 0.13) 240deg,
        transparent 360deg
    );
    animation: spin-c 8s linear infinite;
}

@keyframes spin-a { to { transform: rotate(360deg); } }
@keyframes spin-b { to { transform: rotate(-360deg); } }
@keyframes spin-c { to { transform: rotate(360deg); } }

/* variant: swarm — additional small particle overlay */
.flow-field[data-variant="swarm"]::before { filter: blur(10px); }
.flow-field[data-variant="swarm"]::after { filter: blur(22px); }

/* variant: voronoi — sharper edges, using clip-path pattern */
.flow-field[data-variant="voronoi"]::before { filter: blur(6px) contrast(1.15); }
.flow-field[data-variant="voronoi"]::after  { filter: blur(28px) contrast(1.05); }

/* Panel-specific color cast (spatial color mapping: left=blue → right=green) */
.panel[data-panel="0"] .flow-field { filter: hue-rotate(-10deg); }
.panel[data-panel="1"] .flow-field { filter: hue-rotate(0deg); }
.panel[data-panel="2"] .flow-field { filter: hue-rotate(20deg); }
.panel[data-panel="3"] .flow-field { filter: hue-rotate(40deg); }
.panel[data-panel="4"] .flow-field { filter: hue-rotate(60deg); }
.panel[data-panel="5"] .flow-field { filter: hue-rotate(80deg); }
.panel[data-panel="6"] .flow-field { filter: hue-rotate(100deg); }
.panel[data-panel="7"] .flow-field { filter: hue-rotate(120deg); }

/* ==========================================================================
   Bubbles
   ========================================================================== */

.bubble-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    overflow: hidden;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    mix-blend-mode: screen;
    box-shadow:
        inset 0 0 30px rgba(255, 255, 255, 0.08),
        0 0 40px rgba(255, 255, 255, 0.05);
    will-change: transform, opacity;
    animation-name: rise, bob;
    animation-timing-function: linear, ease-in-out;
    animation-iteration-count: infinite, infinite;
}

@keyframes rise {
    0%   { transform: translate3d(var(--dx, 0), 15vh, 0) scale(0.6); opacity: 0; }
    10%  { opacity: 0.85; }
    90%  { opacity: 0.85; }
    100% { transform: translate3d(calc(var(--dx, 0) + var(--sway, 30px)), -120vh, 0) scale(1); opacity: 0; }
}

@keyframes bob {
    0%, 100% { margin-left: 0; }
    50%      { margin-left: var(--bob, 24px); }
}

/* ==========================================================================
   Panel Content
   ========================================================================== */

.panel-content {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    max-width: 780px;
    padding: clamp(2.5rem, 6vw, 6rem);
    gap: 1.4rem;
}

.panel-content.align-right {
    align-items: flex-end;
    text-align: right;
    margin-left: auto;
}

.panel-content.align-center {
    align-items: center;
    text-align: center;
    margin: 0 auto;
    max-width: 860px;
}

.gen-label {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--stream-green);
    padding: 0.35rem 0.7rem;
    border: 1px solid rgba(138, 190, 74, 0.35);
    border-radius: 2px;
    background: rgba(14, 14, 20, 0.5);
}

.display {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(2.5rem, 6vw, 5rem);
    line-height: 1.08;
    letter-spacing: 0.01em;
    color: var(--text);
}

.display em, .heading em, .pull-quote em, .body-italic em {
    font-style: italic;
    font-weight: 400;
    background: linear-gradient(90deg, var(--stream-blue), var(--stream-magenta), var(--stream-green));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.heading {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(2rem, 4.6vw, 3.6rem);
    line-height: 1.12;
    letter-spacing: 0.01em;
    color: var(--text);
    max-width: 20ch;
}

.heading.center { max-width: 28ch; }
.heading.huge { font-size: clamp(4rem, 14vw, 12rem); font-style: italic; font-weight: 400; }

.body, .body-lead, .body-large, .body-italic {
    font-family: var(--font-body);
    color: var(--text-muted);
    max-width: 56ch;
}

.body { font-size: 1rem; line-height: 1.75; }
.body-lead { font-size: 1.15rem; line-height: 1.7; color: #C8C8D4; }
.body-large { font-size: 1.25rem; line-height: 1.65; color: #C8C8D4; max-width: 48ch; }
.body-italic { font-family: var(--font-display); font-size: 1.2rem; line-height: 1.6; color: var(--text); font-style: italic; }

.body-large.center, .body.center { margin: 0 auto; }

.pull-quote {
    font-family: var(--font-display);
    font-size: 1.4rem;
    line-height: 1.5;
    font-style: italic;
    color: var(--text);
    border-left: 2px solid var(--stream-magenta);
    padding-left: 1.2rem;
    max-width: 40ch;
}

.caption {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    margin-top: 2rem;
    opacity: 0.6;
    animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.35; transform: translateX(0); }
    50%      { opacity: 0.85; transform: translateX(6px); }
}

.thought-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-style: italic;
    color: var(--text);
}

.thought-list li {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.bullet {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--stream-blue), var(--stream-magenta));
    flex-shrink: 0;
}

.thought-list li:nth-child(2) .bullet { background: linear-gradient(135deg, var(--stream-magenta), var(--stream-green)); }
.thought-list li:nth-child(3) .bullet { background: linear-gradient(135deg, var(--stream-green), var(--stream-blue)); }

/* Bridge graphic on the "link" panel */
.bridge {
    display: flex;
    align-items: center;
    gap: 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    margin-top: 1rem;
}

.bridge .node {
    padding: 0.6rem 1rem;
    border: 1px solid rgba(240, 240, 244, 0.25);
    border-radius: 4px;
    color: var(--text);
    background: rgba(20, 20, 30, 0.6);
    white-space: nowrap;
}

.bridge .arc {
    flex: 1;
    min-width: 120px;
    height: 2px;
    background: linear-gradient(90deg, var(--stream-blue), var(--stream-magenta), var(--stream-green));
    position: relative;
    margin: 0 -2px;
}

.bridge .arc::before,
.bridge .arc::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 8px;
    height: 8px;
    background: var(--stream-magenta);
    border-radius: 50%;
    transform: translateY(-50%);
    animation: travel 3s ease-in-out infinite;
}

.bridge .arc::before { left: 0; animation-delay: 0s; }
.bridge .arc::after { left: 0; animation-delay: 1.5s; }

@keyframes travel {
    0%   { left: 0;     opacity: 1; background: var(--stream-blue); }
    50%  { left: 50%;   background: var(--stream-magenta); }
    100% { left: calc(100% - 8px); opacity: 0.2; background: var(--stream-green); }
}

.flash {
    display: inline-block;
    color: var(--stream-green);
    animation: flicker 1.8s ease-in-out infinite;
}

@keyframes flicker {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.15); }
}

.signoff {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 2rem;
}

.sig-line {
    display: inline-block;
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--stream-magenta), transparent);
}

/* ==========================================================================
   Underline-Draw
   ========================================================================== */

.underline-draw {
    position: relative;
    display: inline-block;
    padding-bottom: 0.15em;
}

.underline-draw::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 0;
    background: linear-gradient(90deg, var(--stream-blue), var(--stream-magenta), var(--stream-green));
    transition: width 0.8s ease-out;
}

.underline-draw.drawn::after { width: 100%; }

.underline-draw.center::after {
    left: 50%;
    transform: translateX(-50%);
}

/* ==========================================================================
   Wordmark (top-left)
   ========================================================================== */

.wordmark {
    position: fixed;
    top: 1.6rem;
    left: 1.8rem;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.05rem;
    color: var(--text);
    letter-spacing: 0.02em;
    opacity: 1;
    transition: opacity 0.6s ease;
    mix-blend-mode: difference;
}

.wordmark-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--stream-magenta);
    box-shadow: 0 0 10px var(--stream-magenta);
    animation: dot-pulse 2.4s ease-in-out infinite;
}

@keyframes dot-pulse {
    0%, 100% { transform: scale(1);   opacity: 0.9; }
    50%      { transform: scale(1.3); opacity: 1; }
}

.wordmark.faded { opacity: 0.25; }

/* ==========================================================================
   Scroll Indicator
   ========================================================================== */

.scroll-indicator {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    width: min(480px, 70vw);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    pointer-events: none;
}

.scroll-progress {
    position: relative;
    width: 100%;
    height: 4px;
    background: rgba(240, 240, 244, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.scroll-progress::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: var(--progress, 0%);
    background: linear-gradient(90deg, var(--stream-blue), var(--stream-magenta), var(--stream-green));
    border-radius: 2px;
    transition: width 0.15s linear;
    box-shadow: 0 0 10px rgba(190, 74, 138, 0.5);
}

.panel-markers {
    display: flex;
    gap: 0.55rem;
}

.panel-marker {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(240, 240, 244, 0.2);
    transition: background 0.3s ease, transform 0.3s ease;
}

.panel-marker.active {
    background: var(--stream-magenta);
    transform: scale(1.6);
    box-shadow: 0 0 8px var(--stream-magenta);
}

/* ==========================================================================
   Mobile vertical fallback
   ========================================================================== */

@media (max-width: 768px) {
    html, body { overflow: auto; height: auto; }

    .stream {
        flex-direction: column;
        width: 100vw;
        height: auto;
        overflow-x: hidden;
        overflow-y: auto;
        scroll-snap-type: y proximity;
    }

    .panel {
        flex: 0 0 auto;
        width: 100vw;
        min-height: 100vh;
        scroll-snap-align: start;
    }

    .panel-content {
        padding: clamp(1.5rem, 6vw, 3rem);
        max-width: 100%;
    }

    .panel-content.align-right { align-items: flex-start; text-align: left; margin-left: 0; }
    .panel-content.align-center { align-items: center; text-align: center; }

    .scroll-indicator { width: 80vw; bottom: 1rem; }
    .wordmark { top: 1rem; left: 1rem; font-size: 0.95rem; }

    .bridge { flex-direction: column; gap: 0.6rem; }
    .bridge .arc { width: 100%; min-width: 0; height: 2px; }
}

@media (prefers-reduced-motion: reduce) {
    .flow-field::before, .flow-field::after, .flow-field > .field-layer,
    .bubble, .dot-pulse, .caption, .flash { animation: none !important; }
}
