/* Eddy Mixing — 3D viz left, slice plots below, controls right */

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

body {
    background: var(--bg-warm, #f5f5f5);
    color: var(--text-primary, #2d2d2d);
    font-family: 'EB Garamond', Georgia, serif;
    min-height: 100vh;
    cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' style='font-size:24px'><text y='24'>☁️</text></svg>") 13 5, auto;
}

/* Raining cloud on clickable / form elements. */
a, button, [role="button"],
input[type="range"], input[type="checkbox"], input[type="number"], input[type="radio"],
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button,
label, select, summary,
.toggle-btn, .action-btn, .plot-cell {
    cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' style='font-size:24px'><text y='24'>🌧️</text></svg>") 13 5, pointer;
}

/* Lightning cloud on click */
a:active, button:active, [role="button"]:active {
    cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='32' height='32' style='font-size:24px'><text y='24'>⛈️</text></svg>") 13 5, pointer;
}

.content {
    max-width: 1400px;
    margin: 0 auto;
    padding: calc(var(--header-height, 64px) + 1.5rem) 1rem 3rem;
}

/* ─── App layout: viz left, controls right ─────────────────────────────── */
.app-layout {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.viz-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ─── 3D canvas ───────────────────────────────────────────────────────── */
.three-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1.5 / 1;
    background: linear-gradient(180deg, #f7f6f2 0%, #ecead9 100%);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    border: 1px solid #e0e0e0;
}

#three-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.three-overlay {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    pointer-events: none;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-size: 0.7rem;
    color: rgba(45, 45, 45, 0.55);
}

.three-stat {
    font-variant-numeric: tabular-nums;
}

/* ─── Plot row (three slices) ──────────────────────────────────────────── */
.plots-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
}

.plot-cell {
    position: relative;
    aspect-ratio: 1 / 1;
    background: #fafaf7;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

/* 1D line plots are wider than tall — keep them comfortable to read */
.plots-row-1d { margin-top: 0.1rem; }
.plot-cell-1d {
    aspect-ratio: 2 / 1;
    background: #fff;
}

.plot-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* The three 2D slice plots are clickable — clicking sets the active 3D plane.
   Subtle hover ring matches the rest of the site's hover affordance without
   competing with the colormap. */
.plots-row:not(.plots-row-1d) .plot-cell {
    transition: box-shadow 0.15s ease;
}
.plots-row:not(.plots-row-1d) .plot-cell:hover {
    box-shadow: 0 1px 4px rgba(0,0,0,0.05), inset 0 0 0 2px rgba(33,150,243,0.4);
}

.plot-title {
    position: absolute;
    top: 0.4rem;
    right: 0.5rem;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-size: 0.7rem;
    font-style: italic;
    color: rgba(45, 45, 45, 0.45);
    pointer-events: none;
}

.plot-axislabel {
    position: absolute;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-size: 0.65rem;
    color: rgba(45, 45, 45, 0.55);
    pointer-events: none;
}
.plot-axislabel.x {
    bottom: 0.25rem;
    right: 0.4rem;
}
.plot-axislabel.y {
    top: 0.25rem;
    left: 0.4rem;
}

/* ─── Right column: controls ──────────────────────────────────────────── */
.controls-column {
    flex: 0 0 290px;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: sticky;
    top: calc(var(--header-height, 64px) + 1rem);
}

.controls-panel {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-size: 0.82rem;
}

.controls-body { padding: 0.85rem 0.95rem; }

.control-group { margin-bottom: 0.6rem; }
.control-group:last-child { margin-bottom: 0; }

.control-group label {
    display: block;
    margin-bottom: 0.25rem;
    color: var(--text-primary, #2d2d2d);
    font-size: 0.8rem;
}

.control-group label span {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.control-group.checkbox-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.control-group.checkbox-group label {
    margin-bottom: 0;
    flex: 1;
}

.control-group.checkbox-group input[type="checkbox"] {
    margin-left: 0.5rem;
    accent-color: #2196F3;
}

.control-divider {
    border: none;
    border-top: 1px solid #eee;
    margin: 0.7rem 0;
}

/* Range sliders */
input[type="range"] {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(to right, #ccc, #888);
    outline: none;
    -webkit-appearance: none;
    accent-color: #2196F3;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: white;
    border: 2px solid #2196F3;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: border-color 0.15s ease;
}
input[type="range"]::-webkit-slider-thumb:hover { border-color: #1565C0; }
input[type="range"]::-moz-range-thumb {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: white;
    border: 2px solid #2196F3;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Select inputs */
.select-input {
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    font-family: inherit;
    font-size: 0.8rem;
    color: var(--text-primary, #2d2d2d);
    transition: border-color 0.15s ease;
}
.select-input:hover { border-color: #888; }
.select-input:focus { outline: none; border-color: #2196F3; }

/* Toggle button group */
.toggle-group {
    display: flex;
    gap: 0;
    margin-top: 0.2rem;
}
.toggle-btn {
    flex: 1;
    padding: 0.32rem 0.4rem;
    border: 1px solid #ccc;
    background: #fff;
    font-size: 0.76rem;
    font-family: inherit;
    color: var(--text-muted, #6b6b6b);
    transition: all 0.15s ease;
    white-space: nowrap;
}
.toggle-btn:first-child { border-radius: 4px 0 0 4px; }
.toggle-btn:last-child { border-radius: 0 4px 4px 0; }
.toggle-btn:not(:first-child) { border-left: none; }
.toggle-btn.active {
    background: var(--text-primary, #2d2d2d);
    color: #fff;
    border-color: var(--text-primary, #2d2d2d);
}

/* Action buttons */
.button-row {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.25rem;
}
.action-btn {
    flex: 1;
    padding: 0.42rem 0.6rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    background: #fff;
    font-family: inherit;
    font-size: 0.8rem;
    transition: all 0.15s ease;
    color: var(--text-primary, #2d2d2d);
}
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.action-btn.primary {
    background: #2196F3;
    color: #fff;
    border-color: #2196F3;
}
.action-btn.primary:hover:not(:disabled) {
    background: #1976D2;
    border-color: #1976D2;
}
.action-btn:hover:not(:disabled):not(.primary) {
    background: #f0f0f0;
}
.action-btn.recording {
    background: #c0392b;
    color: #fff;
    border-color: #c0392b;
}
.action-btn.recording:hover {
    background: #a52a1f;
    border-color: #a52a1f;
}

/* About section */
.about-section {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.about-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
    font-size: 0.8rem;
    color: var(--text-muted, #6b6b6b);
    text-align: left;
    transition: color 0.15s ease;
}
.about-toggle:hover { color: var(--text-primary, #2d2d2d); }
.about-toggle.open { border-bottom: 1px solid #e0e0e0; }
.about-label { font-weight: 500; }
.about-arrow { font-size: 0.7rem; }
.about-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 1rem;
}
.about-content.open {
    max-height: 1400px;
    padding: 0.75rem 1rem 1rem;
}
.about-content p {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
    color: var(--text-primary, #2d2d2d);
}
.about-content ul {
    margin: 0 0 0.75rem 1.25rem;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1.55;
}
.about-content li { margin-bottom: 0.4rem; }
.about-content p:last-child { margin-bottom: 0; }
.about-content strong { font-weight: 600; }

/* Mobile */
@media (max-width: 900px) {
    .app-layout { flex-direction: column; }
    .viz-area { width: 100%; }
    .controls-column {
        flex: none;
        width: 100%;
        position: static;
    }
    .plots-row {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }
}
