/* ============================================
   Boxplot Tutorial - Styles
   ============================================ */

:root {
    --bg: #0a0a0f;
    --bg-soft: #12121a;
    --bg-card: #15151f;
    --bg-card-hover: #1a1a25;
    --text: #f0f0f5;
    --text-secondary: #8888a0;
    --text-muted: #55556a;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --accent: #8080ff;
    --accent-2: #ff80c0;
    --accent-3: #80ffd0;
    --q1: #6cb6ff;
    --median: #ff9b6c;
    --q3: #b48cff;
    --whisker: #80ffd0;
    --outlier: #ff6c8e;
    --axis: #55556a;
    --code-bg: #0e0e16;
    --shadow-card: 0 1px 0 rgba(255,255,255,0.03);
    --selection-bg: rgba(128, 128, 255, 0.3);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
    --sans: 'Outfit', -apple-system, sans-serif;
    --q1-fill-1: rgba(108, 182, 255, 0.55);
    --q1-fill-2: rgba(180, 140, 255, 0.55);
    --q3-fill-1: rgba(180, 140, 255, 0.55);
    --q3-fill-2: rgba(108, 182, 255, 0.55);
    --violin-stop-1: rgba(180, 140, 255, 0.6);
    --violin-stop-2: rgba(108, 182, 255, 0.6);
    --violin-stop-3: rgba(180, 140, 255, 0.6);
}

[data-theme="light"] {
    --bg: #fafaf7;
    --bg-soft: #f0efe9;
    --bg-card: #ffffff;
    --bg-card-hover: #f6f5ef;
    --text: #1a1a24;
    --text-secondary: #5d5d72;
    --text-muted: #9999a8;
    --border: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --accent: #5b5be0;
    --accent-2: #d44a8a;
    --accent-3: #1a9b7a;
    --q1: #2670c8;
    --median: #d96329;
    --q3: #7042c8;
    --whisker: #1a9b7a;
    --outlier: #d63a5e;
    --axis: #b8b8c5;
    --code-bg: #f0efe9;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.04);
    --selection-bg: rgba(91, 91, 224, 0.2);
    --q1-fill-1: rgba(38, 112, 200, 0.30);
    --q1-fill-2: rgba(112, 66, 200, 0.30);
    --q3-fill-1: rgba(112, 66, 200, 0.30);
    --q3-fill-2: rgba(38, 112, 200, 0.30);
    --violin-stop-1: rgba(112, 66, 200, 0.45);
    --violin-stop-2: rgba(38, 112, 200, 0.45);
    --violin-stop-3: rgba(112, 66, 200, 0.45);
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

::selection { background: var(--selection-bg); color: var(--text); }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

.bg-noise {
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1000;
}

.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: -1;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
    opacity: 0.4;
}

[data-theme="light"] .bg-grid { opacity: 0.7; }

[data-theme="light"] .bg-noise { opacity: 0.4; }

/* ===== Header ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 16px 24px;
    background: linear-gradient(to bottom, var(--bg) 60%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.site-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.brand-mark {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--mono);
    font-weight: 700;
    color: var(--bg);
}

.brand-name {
    font-family: var(--mono);
    font-size: 16px;
    font-weight: 500;
}

.nav {
    display: flex;
    gap: 6px;
}

.nav a {
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
}

.nav a:hover {
    color: var(--text);
    background: var(--bg-card);
}

/* ===== Theme Toggle ===== */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-toggle {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.theme-toggle:hover {
    color: var(--text);
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }

[data-theme="light"] .theme-toggle .sun { display: block; }
[data-theme="light"] .theme-toggle .moon { display: none; }

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

/* ===== Hero ===== */
.hero {
    padding: 60px 0 80px;
    text-align: center;
}

.hero-tag {
    display: inline-block;
    padding: 4px 12px;
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--accent);
    background: rgba(128, 128, 255, 0.1);
    border: 1px solid rgba(128, 128, 255, 0.2);
    border-radius: 999px;
    margin-bottom: 20px;
}

.hero-title {
    font-size: clamp(2.5rem, 6vw, 4rem);
    font-weight: 700;
    letter-spacing: -2px;
    line-height: 1.1;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 40px;
}

/* ===== Hero Boxplot Demo ===== */
.hero-demo {
    max-width: 700px;
    margin: 0 auto;
    padding: 30px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.hero-demo svg {
    width: 100%;
    height: auto;
    display: block;
}

/* ===== Sections ===== */
section {
    margin: 80px 0;
}

.section-header {
    margin-bottom: 32px;
}

.section-tag {
    font-family: var(--mono);
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 8px;
}

.section-title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 600;
    letter-spacing: -1px;
    margin-bottom: 12px;
}

.section-desc {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 700px;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow-card);
}

.card:hover { border-color: var(--border-hover); }

/* ===== Anatomy SVG Diagram ===== */
.anatomy-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: stretch;
}

@media (max-width: 768px) {
    .anatomy-grid { grid-template-columns: 1fr; }
}

.anatomy-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.anatomy-card svg {
    width: 100%;
    height: auto;
    display: block;
}

.anatomy-legend {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-top: 16px;
}

.legend-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s;
}

.legend-item:hover { background: var(--bg-card-hover); }
.legend-item.active { background: rgba(128, 128, 255, 0.1); border: 1px solid rgba(128, 128, 255, 0.3); }
.legend-item { border: 1px solid transparent; }

.legend-swatch {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
    margin-top: 3px;
}

.legend-text {
    flex: 1;
    min-width: 0;
}

.legend-text strong {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
}

.legend-text span {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ===== Interactive Builder ===== */
.builder {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 24px;
}

@media (max-width: 900px) {
    .builder { grid-template-columns: 1fr; }
}

.controls {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.control-group {
    margin-bottom: 22px;
}

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

.control-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}

.control-label span:first-child {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.control-label .value {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--accent);
}

.control-slider {
    width: 100%;
    height: 4px;
    background: var(--bg-soft);
    border-radius: 2px;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    cursor: pointer;
}

.control-slider::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg);
    box-shadow: 0 0 0 1px var(--accent);
}

.control-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg);
    box-shadow: 0 0 0 1px var(--accent);
}

.preset-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.preset-btn {
    padding: 6px 12px;
    font-family: var(--mono);
    font-size: 12px;
    background: var(--bg-soft);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    color: var(--text);
    border-color: var(--accent);
}

.preset-btn.active {
    color: var(--accent);
    background: rgba(128, 128, 255, 0.1);
    border-color: var(--accent);
}

/* ===== Live Data Points ===== */
.dot-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 16px;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    min-height: 60px;
    margin-top: 16px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.7;
    transition: all 0.3s;
}

.dot.outlier { background: var(--outlier); opacity: 1; }

/* ===== Stats Summary ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 16px;
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-cell {
    padding: 12px;
    background: var(--bg-soft);
    border-radius: var(--radius-sm);
    text-align: center;
}

.stat-cell .label {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.stat-cell .val {
    font-family: var(--mono);
    font-size: 16px;
    font-weight: 600;
}

/* ===== Boxplot Visualization (large) ===== */
.viz {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    overflow: hidden;
}

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

/* ===== Comparison Grid ===== */
.compare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.compare-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.compare-card h4 {
    font-size: 15px;
    margin-bottom: 4px;
}

.compare-card .desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    min-height: 32px;
}

.compare-card svg {
    width: 100%;
    height: 140px;
    display: block;
}

/* ===== Steps / Steps ===== */
.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.step {
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    position: relative;
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: var(--bg);
    font-family: var(--mono);
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 12px;
}

.step h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.step p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ===== Decision Tree ===== */
.tree {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
}

.tree-question {
    text-align: center;
    padding: 16px;
    background: rgba(128, 128, 255, 0.1);
    border: 1px solid rgba(128, 128, 255, 0.3);
    border-radius: var(--radius-md);
    font-weight: 500;
    margin-bottom: 20px;
}

.tree-branches {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 700px) {
    .tree-branches { grid-template-columns: 1fr; }
}

.tree-branch {
    padding: 20px;
    background: var(--bg-soft);
    border-radius: var(--radius-md);
}

.tree-branch .answer {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--accent-3);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.tree-branch.yes .answer { color: var(--accent-3); }
.tree-branch.no .answer { color: var(--accent-2); }

.tree-branch h4 {
    font-size: 15px;
    margin-bottom: 6px;
}

.tree-branch p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ===== Variations ===== */
.variations {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.variation {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.variation h4 {
    font-size: 16px;
    margin-bottom: 6px;
}

.variation p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.variation svg {
    width: 100%;
    height: 160px;
    display: block;
    margin-top: auto;
}

/* ===== Code Block ===== */
.code {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-top: 16px;
    overflow-x: auto;
}

.code pre {
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
}

.code .kw { color: var(--accent); }
.code .fn { color: var(--accent-3); }
.code .num { color: var(--accent-2); }
.code .com { color: var(--text-muted); font-style: italic; }

/* ===== Footer ===== */
.site-footer {
    padding: 40px 24px;
    text-align: center;
    border-top: 1px solid var(--border);
    margin-top: 80px;
}

.site-footer p {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .nav { display: none; }
    .container { padding: 24px 16px 60px; }
    section { margin: 60px 0; }
    .hero { padding: 30px 0 50px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}