/* ============================================================
   bability.pro - Probabilistic Analytics Environment
   Color Palette: Cool grays + Signal Blue
   Fonts: IBM Plex Mono (headings/data), Inter (body)
   ============================================================ */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: #111827;
    color: #CBD5E1;
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 0.9375rem;
    line-height: 1.7;
    letter-spacing: 0.005em;
    overflow-x: hidden;
    position: relative;
}

/* --- Viewport Frame --- */
.viewport-frame {
    position: fixed;
    top: 24px;
    left: 24px;
    right: 24px;
    bottom: 24px;
    width: calc(100% - 48px);
    height: calc(100% - 48px);
    pointer-events: none;
    z-index: 100;
}

.viewport-frame #frame-rect {
    width: calc(100% - 1px);
    height: calc(100% - 1px);
    fill: none;
    stroke: #3A3F47;
    stroke-width: 1;
    stroke-dasharray: 9999;
    stroke-dashoffset: 9999;
}

.viewport-frame.animate #frame-rect {
    animation: drawFrame 400ms ease-out forwards;
}

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

/* --- Micro Grid Overlay --- */
.micro-grid {
    position: fixed;
    top: 24px;
    left: 24px;
    right: 24px;
    bottom: 24px;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    background-image:
        repeating-linear-gradient(to right, #2A2F37 0px, #2A2F37 0.5px, transparent 0.5px, transparent 20px),
        repeating-linear-gradient(to bottom, #2A2F37 0px, #2A2F37 0.5px, transparent 0.5px, transparent 20px);
    transition: opacity 300ms ease;
}

.micro-grid.visible {
    opacity: 0.18;
}

/* --- Tick Marks --- */
.tick-marks {
    position: fixed;
    pointer-events: none;
    z-index: 101;
}

.tick-marks--top {
    top: 24px;
    left: 24px;
    right: 24px;
    height: 4px;
    background-image: repeating-linear-gradient(to right, #4A5568 0px, #4A5568 1px, transparent 1px, transparent 40px);
}

.tick-marks--bottom {
    bottom: 24px;
    left: 24px;
    right: 24px;
    height: 4px;
    background-image: repeating-linear-gradient(to right, #4A5568 0px, #4A5568 1px, transparent 1px, transparent 40px);
}

.tick-marks--left {
    top: 24px;
    left: 24px;
    bottom: 24px;
    width: 4px;
    background-image: repeating-linear-gradient(to bottom, #4A5568 0px, #4A5568 1px, transparent 1px, transparent 40px);
}

.tick-marks--right {
    top: 24px;
    right: 24px;
    bottom: 24px;
    width: 4px;
    background-image: repeating-linear-gradient(to bottom, #4A5568 0px, #4A5568 1px, transparent 1px, transparent 40px);
}

/* --- Dot Navigation --- */
.dot-nav {
    position: fixed;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dot-nav__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: none;
    background-color: #4A5568;
    cursor: pointer;
    padding: 0;
    transition: background-color 300ms ease, transform 300ms ease;
}

.dot-nav__dot.active {
    background-color: #60A5FA;
    transform: scale(1.3);
}

.dot-nav__dot:hover {
    background-color: #60A5FA;
}

/* --- Main Content --- */
.main-content {
    position: relative;
    z-index: 10;
    padding: 24px;
}

/* --- Scene (Viewport Section) --- */
.scene {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 48px 24px;
    will-change: filter, opacity;
    transition: filter 0.15s linear;
}

.scene__inner {
    width: 100%;
    max-width: 1200px;
    position: relative;
}

/* --- Macro Grid (Ghost lines at panel edges) --- */
.macro-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    opacity: 0.12;
    background-image:
        linear-gradient(to right, #2A2F37 1px, transparent 1px),
        linear-gradient(to bottom, #2A2F37 1px, transparent 1px);
    background-size: calc(100% / 12) calc(100% / 8);
}

/* --- Typography --- */
h1 {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: clamp(1.75rem, 3.5vw, 2.75rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: #E2E8F0;
}

h2 {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 1.25rem;
    line-height: 1.3;
    letter-spacing: 0em;
    color: #94A3B8;
}

h3, .metric__label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.75rem;
    line-height: 1.5;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748B;
}

/* --- Panel Title with left blue accent --- */
.panel__title {
    padding-left: 12px;
    border-left: 2px solid #3B82F6;
    margin-bottom: 16px;
}

/* --- Body Text --- */
.panel__text {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 0.9375rem;
    line-height: 1.7;
    color: #CBD5E1;
    letter-spacing: 0.005em;
    margin-bottom: 16px;
}

.panel__text:last-child {
    margin-bottom: 0;
}

/* --- Data Numerics --- */
.metric__value {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    color: #E2E8F0;
    display: inline-block;
}

.metric--primary .metric__value {
    font-size: 2.5rem;
    color: #F1F5F9;
}

.metric--small .metric__value {
    font-size: 1.5rem;
    color: #E2E8F0;
}

.metric__value--hero {
    font-size: 4rem;
    color: #F1F5F9;
}

/* Data pulse animation */
.metric__value.pulse {
    animation: dataPulse 500ms ease-out;
}

@keyframes dataPulse {
    0% { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25); }
    100% { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0); }
}

/* --- Hero Scene --- */
.scene--hero .scene__inner {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.hero-viz {
    width: 100%;
    height: 50vh;
    min-height: 300px;
    max-height: 500px;
    position: relative;
    border: 1px solid #2A2F37;
    background: #1B1F27;
    overflow: hidden;
}

.hero-curve {
    width: 100%;
    height: 100%;
}

/* Probability curve fill */
.curve-fill {
    fill: #3B82F6;
    fill-opacity: 0.06;
    stroke: none;
}

/* Probability curve stroke */
.curve-stroke {
    fill: none;
    stroke: #3B82F6;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Mean indicator line */
.mean-line {
    stroke: #60A5FA;
    stroke-width: 1;
    stroke-dasharray: 6, 4;
    opacity: 0;
    transform: translateY(-100%);
    transition: opacity 300ms ease, transform 300ms ease;
}

.mean-line.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Confidence interval lines */
.ci-line {
    stroke: #4A5568;
    stroke-width: 0.5;
    stroke-dasharray: 4, 6;
    opacity: 0.5;
}

/* Axis stubs */
.axis-stub {
    position: absolute;
    background-color: #3A3F47;
}

.axis-stub--left {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 40px;
}

.axis-stub--bottom {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    height: 1px;
    width: 40px;
}

/* Hero text */
.hero-text {
    text-align: left;
}

.hero-title {
    margin-bottom: 12px;
    display: flex;
    align-items: baseline;
}

.typing-text {
    overflow: hidden;
    white-space: nowrap;
    display: inline-block;
    width: 0;
}

.typing-text.typed {
    animation: typeIn 800ms steps(24, end) forwards;
}

@keyframes typeIn {
    to {
        width: 100%;
    }
}

.typing-cursor {
    color: #3B82F6;
    animation: blink 800ms step-end infinite;
    font-weight: 400;
}

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

.hero-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    color: #64748B;
    letter-spacing: 0.02em;
}

/* Hero metrics row */
.hero-metrics {
    display: flex;
    gap: 48px;
    flex-wrap: wrap;
}

.hero-metrics .metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* --- Panel Cluster (Asymmetric Grid) --- */
.panel-cluster {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 8px;
}

.panel-cluster--findings {
    grid-template-columns: 1.5fr 1fr 1fr;
    grid-template-rows: auto auto;
}

.panel-cluster--findings .panel--scatter {
    grid-row: span 2;
}

.panel-cluster--findings .panel--narrative {
    grid-column: 2 / -1;
}

.panel-cluster--trends {
    grid-template-columns: 2fr 1fr 1fr;
    grid-template-rows: auto auto auto;
}

.panel-cluster--trends .panel--narrative {
    grid-column: 1 / -1;
}

.panel-cluster--trends .panel--wide-spark {
    grid-column: span 3;
}

/* --- Panel Base --- */
.panel {
    background: #1B1F27;
    border: 1px solid #2A2F37;
    padding: 24px;
    position: relative;
    background-image: linear-gradient(180deg, rgba(59, 130, 246, 0.05) 0%, rgba(59, 130, 246, 0.02) 100%);
}

/* Panel materialization (stagger entrance) */
.panel--stagger {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(4px);
    transition: opacity 400ms ease, transform 400ms ease, filter 400ms ease;
}

.panel--stagger.materialized {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
}

/* --- Sparkline --- */
.sparkline-container {
    margin: 12px 0;
    height: 40px;
}

.sparkline-container--wide {
    height: 60px;
}

.sparkline {
    width: 100%;
    height: 100%;
}

.sparkline--wide {
    width: 100%;
    height: 100%;
}

.sparkline__line {
    fill: none;
    stroke: #60A5FA;
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
    stroke-dasharray: 9999;
    stroke-dashoffset: 9999;
    transition: stroke-dashoffset 800ms ease;
}

.sparkline__line.drawn {
    stroke-dashoffset: 0;
}

.sparkline__dot {
    fill: #60A5FA;
    opacity: 0;
    transition: opacity 300ms ease 800ms;
}

.sparkline__dot.visible {
    opacity: 1;
}

/* --- Scatter Plot --- */
.scatter-plot {
    width: 100%;
    height: 250px;
    background: transparent;
}

.scatter-point {
    transition: opacity 400ms ease;
}

.scatter-point--dense {
    fill: #3B82F6;
    opacity: 0.5;
}

.scatter-point--sparse {
    fill: #F87171;
    opacity: 0.25;
}

/* --- Mini Distribution Curves --- */
.mini-curve {
    width: 100%;
    height: 80px;
    margin: 12px 0;
}

.mini-curve__fill {
    fill: #3B82F6;
    fill-opacity: 0.08;
}

.mini-curve__stroke {
    fill: none;
    stroke: #3B82F6;
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
}

/* --- Scene 5: Closing --- */
.scene--closing .scene__inner {
    display: flex;
    justify-content: center;
}

.closing-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

.closing-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.closing-statement {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 500;
    font-size: 1.25rem;
    color: #94A3B8;
    letter-spacing: 0em;
}

.domain-name {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 600;
    font-size: 0.875rem;
    color: #64748B;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* --- Depth Layering --- */
.scene .panel--narrative {
    opacity: 1;
}

.scene .panel--data {
    opacity: 0.85;
}

.scene .macro-grid {
    opacity: 0.08;
}

/* --- Curve Oscillation Animation --- */
@keyframes curveOscillate {
    0%, 100% { d: path(var(--curve-d-base)); }
    50% { d: path(var(--curve-d-shift)); }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .viewport-frame {
        top: 12px;
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: calc(100% - 24px);
        height: calc(100% - 24px);
    }

    .main-content {
        padding: 12px;
    }

    .scene {
        padding: 24px 12px;
    }

    .panel-cluster,
    .panel-cluster--findings,
    .panel-cluster--trends {
        grid-template-columns: 1fr;
    }

    .panel-cluster--findings .panel--scatter,
    .panel-cluster--findings .panel--narrative,
    .panel-cluster--trends .panel--narrative,
    .panel-cluster--trends .panel--wide-spark {
        grid-column: 1;
        grid-row: auto;
    }

    .hero-metrics {
        gap: 24px;
    }

    .metric--primary .metric__value {
        font-size: 1.75rem;
    }

    .metric__value--hero {
        font-size: 2.5rem;
    }

    .dot-nav {
        right: 20px;
    }

    .tick-marks--top,
    .tick-marks--bottom {
        left: 12px;
        right: 12px;
    }

    .tick-marks--left,
    .tick-marks--right {
        top: 12px;
        bottom: 12px;
    }

    .tick-marks--left { left: 12px; }
    .tick-marks--right { right: 12px; }
    .tick-marks--top { top: 12px; }
    .tick-marks--bottom { bottom: 12px; }
}
