/* ===== Studies section — blog-style index + article pages =====
   Loaded after styles.css. Chart colours follow the validated dark-mode
   categorical palette (see research/README-studies.md); text never wears
   a series colour. */

.studies-root {
    --series-1: #3987e5;   /* blue   — primary / single-series bars      */
    --series-2: #d95926;   /* orange — second series (e.g. Phantom)      */
    --series-3: #199e70;   /* aqua   — third series                       */
    --series-4: #c98500;   /* yellow — fourth series                      */
    --series-muted: #4a5063; /* de-emphasis grey for context bars         */
    --viz-grid: #2a2f3d;
    --viz-axis: #353b4d;
}

/* ---------- Index (blog list) ---------- */
.studies-intro {
    max-width: 720px; margin: -8px auto 28px; text-align: center;
    color: var(--text-secondary); font-size: 0.92rem; line-height: 1.6;
}
.studies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px; margin-bottom: 40px;
}
.study-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden;
    display: flex; flex-direction: column;
    transition: border-color 0.15s, transform 0.15s;
}
.study-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.study-card-link { text-decoration: none; color: inherit; display: flex; flex-direction: column; flex: 1; }
.study-card-cover {
    height: 120px; position: relative; overflow: hidden;
    background: linear-gradient(135deg, rgba(57,135,229,0.18), rgba(255,70,85,0.10));
    display: flex; align-items: flex-end; padding: 14px 16px;
}
.study-card-cover.is-warmup { background: linear-gradient(135deg, rgba(57,135,229,0.22), rgba(25,158,112,0.12)); }
.study-card-cover.is-shields { background: linear-gradient(135deg, rgba(201,133,0,0.20), rgba(57,135,229,0.10)); }
.study-card-cover.is-rifles { background: linear-gradient(135deg, rgba(217,89,38,0.22), rgba(57,135,229,0.14)); }
.study-card-cover.is-curse { background: linear-gradient(135deg, rgba(255,70,85,0.22), rgba(62,207,142,0.10)); }
.study-card-cover.is-streaks { background: linear-gradient(135deg, rgba(144,133,233,0.22), rgba(217,89,38,0.12)); }
.study-card-cover svg { position: absolute; right: 14px; top: 14px; width: 44px; height: 44px; opacity: 0.55; color: var(--text-primary); }
.study-eyebrow {
    font-size: 0.66rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
    color: var(--accent);
}
.study-eyebrow.is-soon { color: var(--yellow); }
.study-card-body { padding: 14px 16px 6px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.study-card-title { font-size: 1.05rem; font-weight: 800; color: var(--text-primary); line-height: 1.3; }
.study-card-deck { font-size: 0.84rem; color: var(--text-secondary); line-height: 1.55; }
.study-card-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 10px 16px 14px; border-top: 1px solid var(--border);
    font-size: 0.74rem; color: var(--text-muted);
}
.study-card-foot .read { color: var(--text-primary); font-weight: 700; }
.study-card:hover .read { color: var(--accent); }
.studies-method {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 20px 22px; margin-bottom: 40px; font-size: 0.86rem; line-height: 1.6; color: var(--text-secondary);
}
.studies-method h3 { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; }
.studies-method ul { margin: 6px 0 0 18px; }
.studies-method li { margin-bottom: 4px; }

/* ---------- Article ---------- */
.study-article { max-width: 880px; margin: 0 auto 60px; }
.study-back {
    display: inline-flex; align-items: center; gap: 6px; margin: 22px 0 14px;
    font-size: 0.78rem; font-weight: 700; color: var(--text-secondary); text-decoration: none;
}
.study-back:hover { color: var(--text-primary); }
.study-head { margin-bottom: 22px; }
.study-head h1 {
    font-size: 2.1rem; font-weight: 800; letter-spacing: -0.5px; line-height: 1.15;
    margin: 8px 0 10px; color: var(--text-primary);
}
.study-deck { font-size: 1.02rem; color: var(--text-secondary); line-height: 1.6; max-width: 760px; }
.study-meta {
    display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 14px;
    font-size: 0.76rem; color: var(--text-muted);
}
.study-meta b { color: var(--text-secondary); font-weight: 600; }
.study-tldr {
    background: linear-gradient(180deg, rgba(57,135,229,0.10), rgba(57,135,229,0.03));
    border: 1px solid rgba(57,135,229,0.35); border-radius: var(--radius-lg);
    padding: 16px 20px; margin: 0 0 26px;
}
.study-tldr .label { font-size: 0.68rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--blue); margin-bottom: 8px; }
.study-tldr ul { margin: 0 0 0 18px; font-size: 0.92rem; line-height: 1.6; color: var(--text-primary); }
.study-tldr li { margin-bottom: 4px; }
.studies-tldr { max-width: 960px; margin: 0 auto 28px; }
.studies-tldr ul { font-size: 0.9rem; }
.studies-tldr li { margin-bottom: 8px; }
.studies-tldr a { color: var(--text-primary); text-decoration: none; }
.studies-tldr a:hover { color: var(--accent); }
.study-section { margin: 0 0 30px; }
.study-section h2 { font-size: 1.3rem; font-weight: 800; margin: 0 0 10px; color: var(--text-primary); letter-spacing: -0.2px; }
.study-section h3 { font-size: 1rem; font-weight: 700; margin: 18px 0 8px; color: var(--text-primary); }
.study-section p { font-size: 0.93rem; line-height: 1.7; color: var(--text-secondary); margin: 0 0 12px; }
.study-section p strong, .study-section li strong { color: var(--text-primary); }
.study-section ul, .study-section ol { margin: 0 0 12px 20px; font-size: 0.92rem; line-height: 1.65; color: var(--text-secondary); }
.study-section li { margin-bottom: 4px; }
.study-section a { color: var(--blue); text-decoration: none; }
.study-section a:hover { text-decoration: underline; }
.study-note {
    border-left: 3px solid var(--yellow); background: rgba(245,197,66,0.06);
    padding: 10px 14px; border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.85rem; color: var(--text-secondary); margin: 12px 0 14px; line-height: 1.6;
}
.study-note.is-info { border-left-color: var(--blue); background: rgba(91,141,234,0.06); }
.study-loading { color: var(--text-muted); font-size: 0.85rem; padding: 18px 0; display: flex; align-items: center; gap: 10px; }

/* KPI row / stat tiles */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 10px 0 18px; }
.stat-tile {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 12px 14px; min-width: 0;
}
.stat-tile .label { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; letter-spacing: 0.02em; }
.stat-tile .value { font-size: 1.55rem; font-weight: 800; color: var(--text-primary); line-height: 1.15; margin-top: 4px; }
.stat-tile .sub { font-size: 0.72rem; color: var(--text-secondary); margin-top: 3px; }
.stat-tile .delta { font-size: 0.78rem; font-weight: 700; margin-top: 4px; display: inline-flex; align-items: center; gap: 4px; }
.stat-tile .delta.up { color: var(--green); }
.stat-tile .delta.down { color: var(--red); }
.stat-tile .delta.flat { color: var(--text-secondary); }
.stat-tile.is-hero .value { font-size: 2.4rem; }

/* Figures */
.study-fig {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 14px 16px 10px; margin: 12px 0 18px; position: relative;
}
.study-fig .fig-title { font-size: 0.92rem; font-weight: 700; color: var(--text-primary); }
.study-fig .fig-sub { font-size: 0.76rem; color: var(--text-secondary); margin-top: 2px; margin-bottom: 8px; line-height: 1.5; }
.study-fig .fig-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 0.74rem; color: var(--text-secondary); margin: 2px 0 8px; }
.study-fig .fig-legend .key { display: inline-flex; align-items: center; gap: 6px; }
.study-fig .fig-legend .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.study-fig .fig-legend .swatch.is-line { width: 16px; height: 2px; border-radius: 1px; }
.study-fig svg { display: block; width: 100%; height: auto; overflow: visible; font-family: inherit; }
.study-fig .viz-tip {
    position: absolute; pointer-events: none; z-index: 5; display: none;
    background: #0e1015; border: 1px solid var(--border-light); border-radius: 6px;
    padding: 6px 9px; font-size: 0.74rem; color: var(--text-secondary); white-space: nowrap;
    box-shadow: var(--shadow-lg);
}
.study-fig .viz-tip b { color: var(--text-primary); font-size: 0.86rem; }
.study-fig .fig-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; font-size: 0.7rem; color: var(--text-muted); flex-wrap: wrap; }
.study-fig .fig-table-btn {
    background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
    border-radius: 999px; padding: 3px 10px; font-size: 0.7rem; font-weight: 600; cursor: pointer;
}
.study-fig .fig-table-btn:hover { color: var(--text-primary); border-color: var(--border-light); }
.study-fig .fig-table { display: none; margin-top: 8px; overflow-x: auto; }
.study-fig.show-table .fig-table { display: block; }
.study-fig .fig-table table { width: 100%; border-collapse: collapse; font-size: 0.76rem; font-variant-numeric: tabular-nums; }
.study-fig .fig-table th, .study-fig .fig-table td { padding: 5px 8px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.study-fig .fig-table th:first-child, .study-fig .fig-table td:first-child { text-align: left; }
.study-fig .fig-table th { color: var(--text-muted); font-weight: 600; font-size: 0.68rem; letter-spacing: 0.04em; text-transform: uppercase; }
.study-fig .fig-table td { color: var(--text-secondary); }
.study-fig .fig-table td:first-child { color: var(--text-primary); }

/* SVG bar marks */
.viz-bar { rx: 0; }
.viz-bar:hover, .viz-bar.is-hot { filter: brightness(1.18); }
.viz-grid line { stroke: var(--viz-grid); stroke-width: 1; }
.viz-axis line { stroke: var(--viz-axis); stroke-width: 1; }
.viz-label { fill: var(--text-secondary); font-size: 11px; }
.viz-label.is-primary { fill: var(--text-primary); font-weight: 600; }
.viz-tick { fill: var(--text-muted); font-size: 10px; }
.viz-ci { stroke: var(--text-muted); stroke-width: 1.5; }
.viz-ref { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: none; }
.viz-ref-label { fill: var(--text-muted); font-size: 10px; }

/* Plain data tables inside articles */
.study-table-wrap { overflow-x: auto; margin: 10px 0 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.study-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.study-table th, .study-table td { padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.study-table th:first-child, .study-table td:first-child { text-align: left; }
.study-table th { background: var(--bg-secondary); color: var(--text-muted); font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase; font-weight: 700; }
.study-table td { color: var(--text-secondary); }
.study-table td:first-child { color: var(--text-primary); font-weight: 600; }
.study-table tr:last-child td { border-bottom: none; }
.study-table .pos { color: var(--green); }
.study-table .neg { color: var(--red); }

/* Rank filter row (one row above the charts; scopes everything below) */
.study-filter { margin: 0 0 22px; }
.study-filter-hint { font-size: 0.74rem; color: var(--text-muted); }

/* Curse page embeds the interactive tool inside the article width */
.study-tool { margin: 6px 0 26px; }
.study-tool .toolbar { margin-bottom: 14px; }

@media (max-width: 640px) {
    .study-head h1 { font-size: 1.6rem; }
    .stat-tile.is-hero .value { font-size: 1.9rem; }
}
