/* speedOfLight — app styles.
   The hero's CSS-gradient stars are load-bearing twice over: they are the
   backdrop behind the transparent WebGL canvas, and the entire fallback
   when WebGL is unavailable. Don't remove them. */

/* ---- Design tokens ----
   One accent (indigo) for interaction. The two frame colours are the ones the
   physics charts use, so the results tiles read as the same legend: orange is
   the traveler's ship, blue is Earth. */
:root {
    --sol-bg: #f4f3ee;
    --sol-surface: #ffffff;
    --sol-tint: #fbfaf7;
    --sol-line: #e4e2da;
    --sol-ink: #1c1f26;
    --sol-muted: #5a5e68;
    --sol-accent: #4338ca;
    --sol-accent-hover: #3730a3;
    --sol-accent-soft: #eceafd;
    --sol-ship: #c2410c;
    --sol-ship-soft: #fff1e8;
    --sol-earth: #1d5fb4;
    --sol-earth-soft: #e8f1fc;
    --sol-radius: 16px;
    --sol-radius-sm: 12px;
    --sol-shadow: 0 1px 2px rgba(20, 22, 30, 0.05), 0 8px 24px rgba(20, 22, 30, 0.06);
}

body {
    background: var(--sol-bg);
    color: var(--sol-ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
    letter-spacing: -0.01em;
}

/* ---- Bootstrap accent overrides ---- */

.btn-primary {
    --bs-btn-bg: var(--sol-accent);
    --bs-btn-border-color: var(--sol-accent);
    --bs-btn-hover-bg: var(--sol-accent-hover);
    --bs-btn-hover-border-color: var(--sol-accent-hover);
    --bs-btn-active-bg: #312e81;
    --bs-btn-active-border-color: #312e81;
    --bs-btn-disabled-bg: var(--sol-accent);
    --bs-btn-disabled-border-color: var(--sol-accent);
    font-weight: 600;
}
.btn-outline-primary {
    --bs-btn-color: var(--sol-accent);
    --bs-btn-border-color: var(--sol-accent);
    --bs-btn-hover-bg: var(--sol-accent);
    --bs-btn-hover-border-color: var(--sol-accent);
    --bs-btn-active-bg: var(--sol-accent);
    --bs-btn-active-border-color: var(--sol-accent);
    font-weight: 600;
}
.form-range::-webkit-slider-thumb { background: var(--sol-accent); }
.form-range::-moz-range-thumb { background: var(--sol-accent); }
.form-range::-webkit-slider-runnable-track { background: var(--sol-line); }
.form-range::-moz-range-track { background: var(--sol-line); }
.form-control:focus,
.form-select:focus {
    border-color: var(--sol-accent);
    box-shadow: 0 0 0 0.2rem rgba(67, 56, 202, 0.18);
}
.dropdown-item.active,
.dropdown-item:active { background-color: var(--sol-accent); }

/* ---- Hero ---- */

.hero-section {
    position: relative;
    overflow: hidden;
    background-color: #060818;
    background-image:
        radial-gradient(1px 1px at 20% 30%, #fff, transparent),
        radial-gradient(1px 1px at 40% 70%, rgba(255, 255, 255, 0.8), transparent),
        radial-gradient(2px 2px at 55% 20%, rgba(255, 255, 255, 0.9), transparent),
        radial-gradient(1px 1px at 70% 55%, #fff, transparent),
        radial-gradient(2px 2px at 85% 35%, rgba(255, 255, 255, 0.7), transparent),
        radial-gradient(1px 1px at 10% 80%, rgba(255, 255, 255, 0.8), transparent),
        radial-gradient(1px 1px at 90% 85%, #fff, transparent),
        radial-gradient(2px 2px at 30% 10%, rgba(255, 255, 255, 0.6), transparent),
        linear-gradient(160deg, #0b1030 0%, #060818 45%, #1a0b2e 100%);
    color: white;
    padding: 5.5rem 1rem;
    margin-bottom: 2.5rem;
    border-radius: 24px;
    min-height: 300px;
    box-shadow: 0 18px 48px rgba(6, 8, 24, 0.35);
}

.hero-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* The starfield renders behind the copy, so the copy carries its own contrast */
.hero-content {
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 14px rgba(3, 6, 20, 0.9), 0 0 4px rgba(3, 6, 20, 0.7);
}
.hero-content h1 {
    font-weight: 700;
    letter-spacing: -0.03em;
}
.hero-content .lead {
    margin-left: auto;
    margin-right: auto;
    color: rgba(255, 255, 255, 0.88);
}
.hero-content .btn {
    text-shadow: none;
    font-weight: 600;
    border-radius: 999px;
    padding-left: 1.6rem;
    padding-right: 1.6rem;
}
.hero-content .btn-outline-light {
    border-color: rgba(255, 255, 255, 0.55);
}

@media (max-width: 575.98px) {
    .hero-section { padding: 3.5rem 1rem; border-radius: 18px; }
    .hero-content .d-flex { flex-direction: column; gap: 0.6rem; align-items: stretch; }
    .hero-content .btn { margin: 0 !important; }
}

/* ---- Segmented tab control ---- */

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    background: var(--sol-surface);
    border: 1px solid var(--sol-line);
    border-radius: 999px;
    box-shadow: var(--sol-shadow);
    margin-left: auto;
    margin-right: auto;
    width: max-content;
    max-width: 100%;
}
.segmented .nav-link {
    color: var(--sol-muted);
    font-weight: 600;
    border-radius: 999px;
    padding: 0.5rem 1rem;
}
.segmented .nav-link:hover { color: var(--sol-ink); }
.nav-pills {
    --bs-nav-pills-link-active-bg: var(--sol-accent);
}
.nav-pills .nav-link.active {
    background-color: var(--sol-accent);
}

/* ---- Cards ---- */

.card {
    border: 1px solid var(--sol-line);
    border-radius: var(--sol-radius);
    background: var(--sol-surface);
    box-shadow: var(--sol-shadow);
}
.card-header {
    background: var(--sol-surface);
    border-bottom: 1px solid var(--sol-line);
    padding: 1rem 1.35rem;
    font-weight: 600;
}
.card-header h3,
.card-header h4,
.card-header h5 {
    font-weight: 650;
    font-size: 1.1rem;
}
.card-body {
    padding: 1.35rem;
}

/* Icon chip used in every card heading */
.icon-chip {
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 10px;
    background: var(--sol-accent-soft);
    color: var(--sol-accent);
    flex: none;
}
.card-heading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Results card: a left rule in accent, nothing else shouting */
.calculation-card {
    border-left: 4px solid var(--sol-accent);
}
.calculation-card .card-body { padding-top: 1.25rem; }

/* ---- Results tiles ----
   Replace the old badge list. Colours match the physics charts' frames. */
.result-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: 1fr;
}
@media (min-width: 768px) {
    .result-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.stat {
    background: var(--sol-tint);
    border: 1px solid var(--sol-line);
    border-radius: var(--sol-radius-sm);
    padding: 0.9rem 1rem;
    min-width: 0;
}
.stat-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sol-muted);
}
.stat-value {
    margin-top: 0.3rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.stat--primary .stat-value {
    font-size: clamp(1.2rem, 2.4vw, 1.6rem);
    font-weight: 700;
    line-height: 1.2;
}
.stat--ship { background: var(--sol-ship-soft); border-color: #fed7b8; }
.stat--ship .stat-label { color: var(--sol-ship); }
.stat--earth { background: var(--sol-earth-soft); border-color: #bfd7f3; }
.stat--earth .stat-label { color: var(--sol-earth); }
.stat--accent { background: var(--sol-accent-soft); border-color: #cfcaf6; }
.stat--accent .stat-label { color: var(--sol-accent); }
.result-note {
    font-size: 0.85rem;
    color: var(--sol-muted);
    margin: 0 0 1rem;
}
.result-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sol-muted);
    margin: 1.1rem 0 0.6rem;
}

/* ---- Journey cards ----
   The category colour is a left edge, not a full header bar. */
.card-journey {
    --cat: var(--sol-accent);
    border-left: 4px solid var(--cat);
    border-radius: var(--sol-radius-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.card-journey .card-body {
    padding: 1.1rem 1.15rem 0.5rem;
}
.card-journey .card-title {
    font-size: 1.05rem;
    font-weight: 650;
    line-height: 1.3;
    margin-bottom: 0.35rem;
}
.card-category {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sol-muted);
    margin-bottom: 0.4rem;
}
.card-journey .card-text {
    font-size: 0.92rem;
    color: #3b3f48;
}
.card-journey .card-footer {
    background: transparent;
    border-top: 1px solid var(--sol-line);
    padding: 0.7rem 1.15rem;
}
.card-journey .btn { font-weight: 600; }

/* Hover lift only where a real hover exists, so tapping a card on a phone
   doesn't leave it stuck in the raised state. */
@media (hover: hover) {
    .card-journey:hover {
        transform: translateY(-4px);
        box-shadow: 0 14px 28px rgba(20, 22, 30, 0.12);
    }
}

/* Search and sort bar */
#journeySearch,
.input-group-text {
    background-color: var(--sol-surface);
}
.input-group .btn-outline-secondary {
    border-color: var(--sol-line);
    color: var(--sol-muted);
    background: var(--sol-surface);
}

/* ---- Warp jump (starfield.js promotes the hero canvas fullscreen) ---- */

.hero-canvas.is-warping {
    position: fixed;
    inset: 0;
    z-index: 1055;
}

.warp-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1054;
    background: rgba(2, 4, 16, 0.96);
    opacity: 0;
    transition: opacity 0.12s ease;
    pointer-events: none;
}
.warp-backdrop.visible { opacity: 1; }

.warp-text {
    position: fixed;
    inset: 0;
    z-index: 1056;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-align: center;
    text-shadow: 0 0 18px rgba(140, 180, 255, 0.9), 0 2px 6px rgba(0, 0, 0, 0.8);
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
    padding: 0 1rem;
}
.warp-text.visible { opacity: 1; }
.warp-text .warp-destination { font-size: clamp(1.6rem, 5vw, 3rem); font-weight: 700; }
.warp-text .warp-distance { font-size: clamp(1rem, 3vw, 1.4rem); opacity: 0.85; }

.warp-flash {
    position: fixed;
    inset: 0;
    z-index: 1057;
    background: #fff;
    opacity: 0;
    pointer-events: none;
}

.warp-glow {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 46vmin;
    height: 46vmin;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(170, 200, 255, 0.9) 0%, rgba(170, 200, 255, 0) 60%);
    opacity: 0;
    z-index: 0;
    pointer-events: none;
}

/* ---- SVG visualizations (physics-viz.js) ---- */

.viz-root {
    /* dataviz-validated palette: Earth frame vs ship frame series,
       gridline + label ink. Text always wears ink, never series color. */
    --viz-earth: #2a78d6;
    --viz-ship: #eb6834;
    --viz-grid: #e1e0d9;
    --viz-ink: #6b6a64;   /* axis labels: >= 4.5:1 on white */
    --viz-body-ink: #212529;
}

.viz-mount svg {
    width: 100%;
    height: auto;
    display: block;
}

.viz-mount text {
    font-family: inherit;
}

.viz-card-head {
    background: var(--sol-tint);
}

.viz-caption {
    font-size: 0.875rem;
    color: var(--sol-muted);
    margin-top: 0.6rem;
    margin-bottom: 0;
    font-variant-numeric: tabular-nums;
}

/* Live marker on the gamma curve follows the slider smoothly */
.gc-marker {
    transition: transform 80ms linear;
}

/* Length-contraction ship squashes along x only; text lives outside this group.
   transform-box: fill-box makes `center` resolve against the group's own bbox. */
.lx-ship-art {
    transform: scaleX(var(--contract, 1));
    transform-box: fill-box;
    transform-origin: center;
    transition: transform 250ms ease-out;
}

.lx-flame {
    animation: lx-flicker 1.4s ease-in-out infinite;
}
@keyframes lx-flicker {
    0%, 100% { opacity: 0.75; }
    50% { opacity: 1; }
}

/* Hover tooltips shared by the gamma curve and the journey ladder */
.viz-has-tip {
    position: relative;
}
.viz-tip {
    position: absolute;
    z-index: 5;
    pointer-events: none;
    transform: translate(-50%, calc(-100% - 12px));
    background: rgba(28, 31, 38, 0.94);
    color: #fff;
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    font-size: 0.75rem;
    line-height: 1.4;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.1s ease;
}
.viz-tip.visible {
    opacity: 1;
}
.viz-tip-title {
    font-weight: 600;
}

/* Keyboard focus on interactive chart parts. */
.gc-hit:focus,
.ld-dot:focus {
    outline: none;
}
.gc-hit:focus-visible,
.ld-dot:focus-visible {
    stroke: var(--sol-accent);
    stroke-width: 3;
}

/* Journey ladder: scrolls sideways on narrow screens instead of shrinking
   its labels to nothing. */
.viz-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.viz-scroll > svg {
    min-width: 720px;
}

/* Reach-marker flags on the journey ladder slide with the slider */
.ladder-reach {
    transition: transform 120ms ease-out;
}

/* ---- Footer and nav ---- */

.site-back {
    color: var(--sol-muted);
    font-weight: 600;
    text-decoration: none;
}
.site-back:hover { color: var(--sol-ink); }

footer.site-footer {
    color: var(--sol-muted);
}

/* ---- Reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
    .card-journey { transition: none; }
    .card-journey:hover { transform: none; }
    .warp-backdrop, .warp-text { transition: none; }
    .gc-marker, .lx-ship-art, .ladder-reach { transition: none; }
    .lx-flame { animation: none; }
}
