/* Stats: Functional Curve, Versus Similar Decks and Suggested Fixes. Load order matters. */
/* ============================================
   FUNCTIONAL CURVE — CAST TIMING WINDOW
   ============================================ */

.functional-curve-container {
    min-height: 240px;
}

/* ── Main wrapper ── */
.fc-main-wrapper {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    width: 100%;
    position: relative;
}

.fc-svg-host {
    width: 100%;
}

.fc-plot-svg {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}

.fc-empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85em;
    text-align: center;
    padding: var(--space-5) 0;
}

.chart-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.chart-title-row.centered {
    justify-content: center;
    position: relative;
}

.chart-title-row .chart-title {
    margin: 0;
}

/* ── SVG text and grid ── */

.fc-axis-label {
    font-size: 8px;
    fill: var(--text-muted);
    font-family: inherit;
}

.fc-axis-label-main {
    font-size: 10px;
    font-weight: 700;
    fill: var(--text-secondary);
    font-family: inherit;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.fc-band-label {
    font-size: 9px;
    font-weight: 700;
    fill: var(--text-secondary);
    font-family: inherit;
}

.fc-grid-line {
    stroke: var(--border-color);
    stroke-width: 1;
    opacity: 0.6;
}

/* ── Cells: shade is the share of simulated games castable by that turn ── */

.fc-cell {
    transition: filter 0.12s;
    cursor: default;
}

.fc-cell:hover {
    filter: brightness(1.3);
}

/* The on-curve column (turn = mana value) is outlined so the eye can tell
   whether the shading has reached it. */
.fc-cell-curve {
    stroke: var(--text-secondary);
    stroke-width: 1;
    stroke-dasharray: 2 1.5;
}

/* Per-card lane: a line from the best-case turn to the typical turn */
.fc-lane-line {
    stroke: var(--fc-sweet-spot);
    stroke-width: 3px;
    stroke-linecap: round;
    pointer-events: none;
}

/* Typical turn never arrives by turn 12: the line runs off the chart */
.fc-lane-line-open {
    stroke-dasharray: 4 3;
    opacity: 0.7;
}

/* The part of a lane that falls after the card's play window */
.fc-lane-line-late {
    stroke: var(--fc-less-value);
}

/* Faint wash over the turns past a card's best */
.fc-lane-past {
    fill: rgba(0, 0, 0, 0.18);
    pointer-events: none;
}

.fc-marker-curve-late {
    fill: var(--fc-reactive);
}

/* X spells and friends keep getting better after they land */
.fc-lane-tail {
    stroke: var(--fc-sweet-spot);
    stroke-width: 1.5px;
    stroke-dasharray: 2 3;
    opacity: 0.55;
    pointer-events: none;
}

/* Pre-game: a star before turn one */
.fc-marker-pregame {
    fill: var(--fc-less-value);
    stroke: rgba(0, 0, 0, 0.55);
    stroke-width: 0.6px;
    pointer-events: none;
}

/* Behind curve: the stretch between the on-curve dot and the average */
.fc-lane-line-behind {
    stroke-dasharray: 3 3;
    opacity: 0.75;
}

/* A second spell face's casting window, staggered below the primary */
.fc-lane-line.fc-face {
    stroke: var(--fc-face);
    stroke-width: 2.2px;
}

.fc-marker-fast.fc-face {
    fill: var(--fc-face);
}

.fc-marker-curve.fc-face {
    fill: var(--fc-face);
    opacity: 0.9;
}

/* The simulated average: a small tick on the line */
.fc-marker-avg {
    fill: var(--fc-sweet-spot);
    stroke: rgba(0, 0, 0, 0.55);
    stroke-width: 0.6px;
    pointer-events: none;
}

.fc-marker-avg.fc-face {
    fill: var(--fc-face);
}

/* Other ways to pay for the card */
.fc-marker-land {
    fill: var(--success-color);
    stroke: rgba(0, 0, 0, 0.45);
    stroke-width: 0.5px;
    pointer-events: none;
}

.fc-marker-alt-cheap {
    fill: var(--card-bg);
    stroke: var(--fc-sweet-spot);
    stroke-width: 1.2px;
    pointer-events: none;
}

.fc-lane-reach {
    stroke: var(--fc-less-value);
    stroke-width: 1.5px;
    stroke-dasharray: 1.5 2.5;
    opacity: 0.8;
    pointer-events: none;
}

.fc-marker-alt-more {
    fill: var(--card-bg);
    stroke: var(--fc-less-value);
    stroke-width: 1.4px;
    pointer-events: none;
}

.fc-marker-later {
    fill: var(--card-bg);
    stroke: var(--fc-reactive);
    stroke-width: 1.4px;
    pointer-events: none;
}

/* ── Hover panel ── */

.fc-hover {
    position: absolute;
    pointer-events: none;
    z-index: var(--z-dropdown);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-2-5);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
    color: var(--text-color);
    font-size: 11px;
}

.fc-hover-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-2);
    margin-bottom: var(--space-1-5);
}

.fc-hover-name {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fc-hover-meta {
    color: var(--text-muted);
    white-space: nowrap;
    font-size: 0.92em;
}

.fc-hover-grid {
    display: grid;
    grid-template-columns: minmax(80px, 1.4fr) minmax(50px, 1fr) 44px 48px 44px;
    gap: var(--space-0-5) var(--space-2);
    align-items: baseline;
}

.fc-hover-h {
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    text-align: right;
}

.fc-hover-h:first-child,
.fc-hover-h:nth-child(2) {
    text-align: left;
}

.fc-hover-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
}

.fc-hover-cost {
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fc-hover-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.fc-lane-never {
    font-size: 7px;
    fill: var(--text-muted);
    font-style: italic;
    font-family: inherit;
    pointer-events: none;
}

.fc-lane-name {
    font-size: 7.5px;
    fill: var(--text-color);
    font-family: inherit;
    pointer-events: none;
    paint-order: stroke;
    stroke: var(--card-bg);
    stroke-width: 2px;
    stroke-linejoin: round;
}

/* Best-case marker (a diamond) and typical-turn tick */
.fc-marker-fast {
    fill: var(--fc-sweet-spot);
    stroke: rgba(0, 0, 0, 0.45);
    stroke-width: 0.5px;
    pointer-events: none;
}

.fc-marker-curve {
    fill: var(--fc-less-value);
    stroke: rgba(0, 0, 0, 0.45);
    stroke-width: 0.5px;
    pointer-events: none;
}

.fc-lane .fc-hover-target {
    cursor: pointer;
    pointer-events: all;
}

.fc-lane:hover .fc-lane-line,
.fc-lane:hover .fc-lane-tail {
    filter: brightness(1.3);
}

/* ── Tooltip ── */

/* ── Controls and legend ── */

.fc-controls-row {
    display: flex;
    justify-content: flex-end;
    padding: var(--space-1) 0;
}

.fc-lane-toggle {
    align-self: center;
    background: var(--button-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.72em;
    padding: var(--space-1) var(--space-3-5);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
    letter-spacing: 0.03em;
    z-index: 10;
    position: relative;
}

.fc-lane-toggle:hover {
    background: var(--entry-hover-bg);
    color: var(--text-color);
}

.fc-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: center;
    margin-top: var(--space-1);
    font-size: 0.72em;
    color: var(--text-muted);
}

.fc-legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.fc-mark-sample {
    flex: none;
    width: 30px;
    height: 14px;
    overflow: visible;
}

/* The explainer's guide to the marks */
.fc-explain-marks {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: var(--space-1-5) var(--space-2-5);
    align-items: start;
}

.fc-explain-marks li {
    display: contents;
}

.fc-explain-marks .fc-mark-sample {
    margin-top: 3px;
}

.fc-explain-marks strong {
    color: var(--text-color);
    margin-right: var(--space-1);
}

.fc-hover .cz-mana-symbols,
.stat-explain-detail .cz-mana-symbols {
    display: inline-flex;
    gap: var(--space-px);
    vertical-align: middle;
}

.fc-hover .mana-symbol,
.stat-explain-detail .mana-symbol {
    width: 12px;
    height: 12px;
}

.fc-hover-summary {
    margin: 0 0 var(--space-1-5);
    color: var(--text-secondary);
}

.fc-hover-more {
    grid-column: 1 / -1;
    color: var(--text-muted);
    font-style: italic;
}

.fc-insights {
    margin-top: var(--space-1-5);
}

/* ============================================
   VERSUS SIMILAR DECKS
   ============================================ */

.population-empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85em;
    text-align: center;
    padding: var(--space-5) 0;
}

.population-rows {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.population-row {
    display: grid;
    grid-template-columns: minmax(90px, 1.2fr) 52px minmax(80px, 2fr) 58px;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.8em;
    padding: 3px 0;
}

.population-label {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.population-value {
    color: var(--text-color);
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* The band is a percentile axis: 0% at the left edge, 100% at the right.
   The middle 10-90% is the published spread (solid); the outer tenths are
   interpolated tails (dashed). The median tick sits at 50% and is taller
   than the dot so it still shows when the dot lands on it. */
.population-band {
    position: relative;
    height: 16px;
    display: block;
}

.population-band-track {
    position: absolute;
    left: 10%;
    right: 10%;
    top: 6px;
    height: 4px;
    background: rgba(var(--accent-rgb), 0.22);
}

.population-band-tail {
    position: absolute;
    top: 7px;
    width: 10%;
    height: 0;
    border-top: 2px dashed rgba(var(--accent-rgb), 0.32);
}

.population-band-tail-low {
    left: 0;
}

.population-band-tail-high {
    right: 0;
}

.population-band-median {
    position: absolute;
    left: 50%;
    top: 0;
    width: 2px;
    height: 16px;
    margin-left: -1px;
    background: var(--text-muted);
    opacity: 0.85;
}

.population-band-marker {
    position: absolute;
    top: 3px;
    width: 10px;
    height: 10px;
    margin-left: -5px;
    border-radius: var(--radius-round);
    background: var(--accent-color);
    box-shadow: 0 0 0 1.5px var(--card-bg);
}

/* Only a value the banners call out changes the dot, and only to the
   warning tone: there is no "good" color on this chart. */
.population-row.population-flagged .population-band-marker {
    background: var(--warning-color);
}

.population-pct {
    color: var(--text-muted);
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.population-insights {
    margin-top: var(--space-2);
}

/* ============================================
   SUGGESTED FIXES
   ============================================ */

.fixes-empty,
.fix-loading {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.82em;
    padding: var(--space-1-5) 0;
}

.fix-issue {
    border: 1px solid var(--border-color);
    border-left-width: 3px;
    border-radius: var(--radius-lg);
    padding: var(--space-2) var(--space-2-5);
    margin-bottom: var(--space-2);
    background: rgba(var(--accent-rgb), 0.03);
}

.fix-issue.insight-critical { border-left-color: var(--danger-color); }
.fix-issue.insight-warning { border-left-color: var(--warning-color); }
.fix-issue.insight-info { border-left-color: var(--accent-color); }
.fix-issue.insight-success { border-left-color: var(--success-color); }

.fix-header {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
}

.fix-icon {
    font-size: 0.9em;
}

.fix-title {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9em;
}

.fix-source {
    margin-left: auto;
    font-size: 0.7em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.fix-why-main {
    margin: var(--space-1) 0 var(--space-1-5);
    font-size: 0.8em;
    color: var(--text-secondary);
}

.fix-candidates {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.fix-row {
    display: grid;
    grid-template-columns: minmax(200px, 1.2fr) minmax(0, 1.3fr) auto;
    align-items: center;
    gap: var(--space-3);
    font-size: 0.8em;
    padding: var(--space-2) 0;
    border-top: 1px dashed var(--border-color);
}

/* The card cell: thumbnail, name, small print */
.fix-card-cell {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
}

.fix-thumb-btn {
    cursor: pointer;
    display: block;
    flex: none;
    width: 72px;
    border-radius: var(--radius-sm);
}

.fix-thumb-wrap {
    width: 72px;
}

.fix-thumb-wrap-small {
    width: 40px;
}

.fix-thumb-wrap .card-action-bar {
    padding: var(--space-0-5);
}

.fix-thumb-wrap-small .card-action-bar {
    display: none;
}

.fix-row .card-face-title-primary {
    line-height: 1.2;
}

.fix-row .card-face-title-secondary {
    line-height: 1.2;
}

.fix-card-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: var(--space-px);
}

.fix-card-meta {
    color: var(--text-muted);
    font-size: 0.85em;
}

/* Swap: one bordered group, the carousel choosing what the Swap button cuts */
.fix-swap {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--button-bg);
    overflow: hidden;
}

.fix-swap .fix-swap-btn {
    border: none;
    border-left: 1px solid var(--border-color);
    border-radius: 0;
    background: rgba(var(--accent-rgb), 0.08);
}

.fix-carousel {
    display: flex;
    align-items: center;
    gap: var(--space-0-5);
    padding: 2px 3px;
}

.fix-carousel-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2em;
    line-height: 1;
    padding: 2px 5px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-family: inherit;
}

.fix-carousel-btn:hover {
    background: var(--entry-hover-bg);
    color: var(--text-color);
}

.fix-carousel-pick {
    display: flex;
    align-items: center;
    gap: var(--space-1-5);
    width: 176px;
    min-width: 0;
    background: none;
    border: none;
    padding: var(--space-px) var(--space-0-5);
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
    border-radius: var(--radius-sm);
}

.fix-carousel-pick:hover .fix-cut-name {
    text-decoration: underline;
}

.fix-cut-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.fix-cut-kicker {
    font-size: 0.68em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.fix-cut-name {
    font-weight: 600;
    font-size: 0.88em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fix-cut-meta {
    font-size: 0.74em;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Loading: the rows' shape, shimmering */
.fix-skeleton {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.fix-skeleton-row {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) 240px;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-top: 1px dashed var(--border-color);
}

.fix-skeleton-btns {
    display: flex;
    flex-direction: column;
    gap: var(--space-1-5);
}

.fix-skeleton-thumb,
.fix-skeleton-line,
.fix-skeleton-btn {
    display: block;
    background: linear-gradient(
        90deg,
        var(--border-color) 25%,
        color-mix(in srgb, var(--border-color) 30%, transparent) 50%,
        var(--border-color) 75%
    );
    background-size: 200% 100%;
    animation: fixShimmer 1.6s infinite;
}

.fix-skeleton-thumb {
    width: 72px;
    aspect-ratio: 63 / 88;
    border-radius: var(--radius-sm);
}

.fix-skeleton-lines {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.fix-skeleton-line {
    height: 9px;
    border-radius: var(--radius-pill);
}

.fix-skeleton-btn {
    height: 26px;
    border-radius: var(--radius-md);
}

@keyframes fixShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* The deck is already at its size limit */
.fix-full-warning {
    border: 1px solid var(--warning-border);
    background: var(--warning-bg);
    color: var(--warning-color);
    border-radius: var(--radius-md);
    padding: var(--space-1-5) var(--space-2-5);
    font-size: 0.8em;
    margin-bottom: var(--space-1);
}

.fix-card {
    color: var(--text-color);
    font-weight: 600;
    text-align: left;
}

.fix-card-link {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    color: var(--accent-color);
}

.fix-card-link:hover {
    text-decoration: underline;
}

.fix-why {
    display: flex;
    flex-direction: column;
    gap: var(--space-0-5);
    min-width: 0;
}

.fix-why-primary {
    color: var(--text-secondary);
}

.fix-why-secondary {
    color: var(--text-muted);
    font-size: 0.88em;
}

.fix-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-1-5);
    justify-self: end;
}

.fix-add {
    align-self: stretch;
}

.fix-action,
.fix-reroll {
    background: var(--button-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-color);
    font-size: 0.85em;
    padding: 3px 10px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.fix-action:hover:not(:disabled),
.fix-reroll:hover {
    background: var(--entry-hover-bg);
}

.fix-action:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.fix-reroll {
    align-self: flex-end;
    color: var(--text-muted);
    font-size: 0.75em;
    margin-top: var(--space-1);
}

.fix-cut-group {
    padding: var(--space-1) 0;
}

.fix-cut-label {
    font-size: 0.8em;
    color: var(--text-secondary);
    font-weight: 600;
}

.fixes-modal .fixes-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding-top: var(--space-1);
}

.fixes-more {
    align-self: center;
    margin: var(--space-1-5) 0;
}

.fixes-footnote {
    margin: var(--space-2-5) 0 0;
    font-size: 0.72em;
    color: var(--text-muted);
    font-style: italic;
}

@media (max-width: 640px) {
    .fix-row {
        grid-template-columns: 1fr;
        gap: var(--space-1-5);
    }
    .fix-actions {
        justify-self: stretch;
    }
    .fix-carousel {
        flex: 1;
        min-width: 0;
    }
    .fix-carousel-pick {
        flex: 1;
        width: auto;
    }
    .fix-skeleton-row {
        grid-template-columns: 72px minmax(0, 1fr);
    }
    .fix-skeleton-btns {
        display: none;
    }
}

/* ── Explainer table ── */

.fc-explain-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8em;
    margin-top: var(--space-1-5);
}

.fc-explain-table th,
.fc-explain-table td {
    text-align: left;
    padding: 3px 6px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.fc-explain-table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.04em;
}

.fc-explain-table td:first-child {
    color: var(--text-color);
}

