/* ==========================================================================
   compound-interest.theme.css — TFSA / RRSP / non-registered comparison

   Loaded AFTER styles.css and tool-base.css. Wrapper is
   `<div class="tool-app ci-app">` — `.tool-app` is what pulls in the shared
   print invariants; this file owns everything else.

   VAR INDIRECTION (same pattern as the other three themes, on purpose)
   The block below re-declares the TOOL's own variable names on `.ci-app` and
   maps each onto a site token. tool-base.css overrides those same names inside
   @media print. Do not "simplify" it by inlining site tokens into the rules —
   the indirection is what lets the print block re-theme the whole tool by
   changing ten values.

   DO NOT re-declare here what tool-base.css already owns in print: the body
   reset, `color-scheme: light` + the ten light vars, `.wrap`, the `.print-only`
   masthead, the `.grid` flex fix, the page-break atoms, or print-color-adjust on
   `.chart-track`/`.chart-fill`. This file adds only what is specific to this
   tool — and one thing tool-base explicitly does NOT cover: the SVG chart's own
   strokes, which are a different class and do not inherit its
   print-color-adjust rule.

   TOUCH: this tool shipped WITH the 44px pass rather than joining the debt pile
   the other three carry. Sizes are `px`, never `rem` — styles.css:1142 drops
   `:root { font-size: 15px }` at 480px, so a rem-based 44px target renders 41px
   on exactly the phones that need it most.
   ========================================================================== */

.ci-app {
    /* screen palette → site tokens */
    --bg: var(--color-bg-primary);
    --card: var(--color-surface);
    --raised: var(--color-raised);
    --ink: var(--color-text-primary);
    --dim: var(--color-text-secondary);
    --muted: var(--color-text-muted);
    --line: var(--color-border);
    --line-strong: var(--color-border-strong);
    --accent: var(--color-primary);
    --accent-soft: rgba(229, 163, 68, 0.12);

    /* the three series. Ratified in DESIGN.md 2026-08-09 as the third series
       case — "alternatives compared across a parameter". Contrast measured
       against surface / raised / ink before entry: 8.60/7.98/9.10,
       7.05/6.54/7.45, 5.39/5.00/5.70. All clear AA on all three. */
    --s-tfsa: var(--color-primary);
    --s-rrsp: #4FB08A;
    --s-nreg: #7E8AA2;

    font-family: var(--font-primary);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
}

/* styles.css styles h1-h3/p for editorial page copy. Inside an app they fight
   the tool's own scale. `color: inherit` here is also half of why this tool's
   print masthead comes out dark — see the tool-base comment on .print-only h1. */
.ci-app h1,
.ci-app h2,
.ci-app h3,
.ci-app p {
    font-family: inherit;
    color: inherit;
    margin: 0;
    letter-spacing: normal;
}

.ci-app .wrap {
    max-width: 1180px;
    margin: 0 auto;
    /* 112px clears the fixed navbar. */
    padding: 112px 2rem 96px;
}

/* ---------- layout: two columns, answer sticky ---------- */
/* Decided in the design review (D3). The answer panel stays visible while a
   slider is dragged — this tool is not read, it is watched. */

.ci-app .grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 26px;
    align-items: start;
}

.ci-app .col-side .panel {
    position: sticky;
    top: 92px;
}

/* ---------- cards ---------- */

.ci-app .panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    margin-bottom: 18px;
}

.ci-app .panel > h2 {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 500;
    color: var(--muted);
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
}

.ci-app .panel > .body {
    padding: 18px;
}

.ci-app .note {
    color: var(--dim);
    font-size: 0.86rem;
    line-height: 1.55;
}

.ci-app .footnote {
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.5;
    margin-top: 14px;
}

/* ---------- the answer ---------- */

.ci-app .figs {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.ci-app .fig {
    background: var(--card);
    padding: 13px 15px;
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.ci-app .fig .lab {
    font-family: var(--font-mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    flex: 1;
}

.ci-app .fig .amt {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    letter-spacing: -0.01em;
}

.ci-app .fig .delta {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--muted);
    min-width: 74px;
    text-align: right;
}

/* The winner is marked with a tint + the accent figure, never a semantic
   colour. None of the three wrappers is "good" or "bad" — tinting the leader
   green would say the RRSP is CORRECT rather than LARGER. Same argument
   DESIGN.md already settled for pro/con. */
.ci-app .fig.win {
    background: var(--raised);
}

.ci-app .fig.win .amt {
    color: var(--accent);
}

.ci-app .fig .winmark {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    margin-left: 6px;
}

/* Verdict: ALWAYS neutral. No .ok/.warn/.bad variants exist here, deliberately.
   Tinted background + full hairline border — never a coloured left border,
   which is an AI-slop pattern and appears in zero shipped tools. */
.ci-app .verdict {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--raised);
    border: 1px solid var(--line);
    color: var(--dim);
    font-size: 0.88rem;
    line-height: 1.6;
}

.ci-app .verdict b {
    color: var(--ink);
    font-family: var(--font-mono);
    font-weight: 500;
}

.ci-app .verdict.empty {
    color: var(--muted);
}

/* ---------- controls ---------- */

.ci-app .field {
    margin-bottom: 16px;
}

.ci-app .field > label {
    display: block;
    font-size: 0.82rem;
    color: var(--dim);
    margin-bottom: 6px;
}

/* Labels stay visible when the field has content — a placeholder is never the
   only label. */
.ci-app input[type="number"],
.ci-app input[type="text"],
.ci-app select {
    width: 100%;
    background: var(--raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 15px;
    padding: 9px 11px;
    min-height: 44px;
}

.ci-app input:focus-visible,
.ci-app select:focus-visible,
.ci-app input[type="range"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.ci-app .row2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Sliders. Native <input type=range> on purpose: keyboard operation, focus and
   screen-reader semantics all come free, and a custom control would have to
   re-earn every one of them. */
.ci-app input[type="range"] {
    width: 100%;
    height: 44px;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
}

.ci-app input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    background: var(--raised);
    border-radius: var(--radius-full);
}

.ci-app input[type="range"]::-moz-range-track {
    height: 6px;
    background: var(--raised);
    border-radius: var(--radius-full);
}

.ci-app input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    margin-top: -8px;
    border-radius: var(--radius-full);
    background: var(--accent);
    border: none;
}

.ci-app input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--accent);
}

.ci-app .seg {
    display: flex;
    gap: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.ci-app .seg button {
    flex: 1;
    min-height: 44px;
    background: var(--raised);
    border: none;
    border-right: 1px solid var(--line);
    color: var(--dim);
    font-family: var(--font-primary);
    font-size: 0.84rem;
    cursor: pointer;
}

.ci-app .seg button:last-child {
    border-right: none;
}

.ci-app .seg button.on {
    background: var(--accent);
    color: #14100a;
}

/* An unverified jurisdiction is disabled and says why. Same posture as
   it-budget's rateDefault() refusing an uncited rate. */
.ci-app select option:disabled {
    color: var(--muted);
}

.ci-app .src-note {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--muted);
    margin-top: 5px;
}

/* ---------- crossover chart ---------- */

.ci-app .chart-wrap {
    margin-top: 4px;
}

.ci-app .xchart {
    width: 100%;
    height: auto;
    display: block;
}

.ci-app .xchart .ax,
.ci-app .xchart .gridline {
    stroke: var(--line);
    stroke-width: 1;
}

.ci-app .xchart text {
    font-family: var(--font-mono);
    font-size: 9.5px;
    fill: var(--muted);
}

.ci-app .xchart .series {
    fill: none;
    stroke-width: 2;
}

/* Series identity is carried by SHAPE as well as hue — flat / sloped / dashed —
   so the chart never depends on colour. Required by the DESIGN.md line-chart
   rule; it is what makes greyscale and background-graphics-off survivable. */
.ci-app .xchart .s-tfsa { stroke: var(--s-tfsa); }
.ci-app .xchart .s-rrsp { stroke: var(--s-rrsp); }
.ci-app .xchart .s-nreg { stroke: var(--s-nreg); stroke-dasharray: 5 4; }

.ci-app .xchart .endlab { font-size: 10px; }
.ci-app .xchart .lab-tfsa { fill: var(--s-tfsa); }
.ci-app .xchart .lab-rrsp { fill: var(--s-rrsp); }
.ci-app .xchart .lab-nreg { fill: var(--s-nreg); }

.ci-app .xchart .cross {
    stroke: var(--accent);
    stroke-width: 1;
    stroke-dasharray: 3 3;
    opacity: 0.6;
    fill: none;
}

.ci-app .xchart .youline {
    stroke: var(--ink);
    stroke-width: 1;
    opacity: 0.3;
}

.ci-app .chart-empty {
    color: var(--muted);
    font-size: 0.84rem;
    padding: 26px 0;
    text-align: center;
}

/* ---------- projection table ---------- */

.ci-app .table-scroll {
    overflow-x: auto;
    /* Firefox needs this explicitly; color-scheme: dark alone leaves a solid
       white bar across the dark card. */
    scrollbar-color: var(--line-strong) var(--card);
}

.ci-app table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.ci-app th {
    text-align: left;
    font-family: var(--font-mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
    color: var(--muted);
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.ci-app td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--line);
    font-family: var(--font-mono);
}

.ci-app td.num,
.ci-app th.num {
    text-align: right;
}

.ci-app .print-mirror {
    display: none;
}

/* ---------- touch / small viewports ---------- */
/* px throughout — see the header note. */

@media (max-width: 900px) {

    .ci-app .grid {
        display: flex;
        flex-direction: column;
        /* LOAD-BEARING, and the exact trap tool-base.css documents for print.
           The screen rule above sets `align-items: start` so the sticky sidebar
           hugs its content. On a COLUMN flex box that same declaration is the
           CROSS axis, so it shrink-wraps every panel to its content width and
           the inputs overflow the viewport. Caught by screenshotting at 390px,
           not by reading the CSS. */
        align-items: stretch;
    }

    /* The answer comes FIRST on a phone. Reading order on a narrow screen is
       the hierarchy, and the plan's own criterion is an answer in under 60
       seconds without instructions. */
    .ci-app .col-side {
        order: -1;
    }

    .ci-app .col-side .panel {
        position: static;
    }

    .ci-app .wrap {
        padding: 96px 1rem 72px;
    }
}

@media (max-width: 620px) {

    /* 16px minimum on anything typed into: below that, iOS Safari zooms the
       viewport on focus and does not zoom back out. */
    .ci-app input[type="number"],
    .ci-app input[type="text"],
    .ci-app select {
        font-size: 16px;
        min-height: 44px;
        padding: 10px 12px;
    }

    .ci-app .row2 {
        grid-template-columns: 1fr;
    }

    .ci-app input[type="range"]::-webkit-slider-thumb {
        width: 28px;
        height: 28px;
        margin-top: -11px;
    }

    .ci-app input[type="range"]::-moz-range-thumb {
        width: 28px;
        height: 28px;
    }

    .ci-app .fig .amt {
        font-size: 1.15rem;
    }

    .ci-app .fig .delta {
        min-width: 62px;
    }
}

/* ---------- print ---------- */
/* tool-base.css owns the reset, the light vars, .wrap, the masthead, the .grid
   flex fix and the page-break atoms. Only tool-specific rules live here. */

@media print {

    .ci-app .col-side .panel {
        position: static;
    }

    /* Controls never render a value on paper — a control cannot wrap and cannot
       size to its content, so printing one means fixing a width and silently
       clipping. syncPrintMirrors() writes a .print-mirror beside every one. */
    .ci-app input,
    .ci-app select,
    .ci-app .seg {
        display: none !important;
    }

    .ci-app .print-mirror {
        display: inline;
        font-family: var(--font-mono);
    }

    /* tool-base sets print-color-adjust on .chart-track/.chart-fill only, and
       says explicitly that a NEW fill is not covered by that rule. The SVG
       strokes are a different class, so they need it here or every line prints
       invisible when "Background graphics" is unticked — which is the default
       in Firefox's silent-print path. */
    .ci-app .xchart,
    .ci-app .xchart .series,
    .ci-app .xchart .cross,
    .ci-app .xchart .youline {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    /* Paper series colours, per the DESIGN.md table. */
    .ci-app .xchart .s-tfsa,
    .ci-app .xchart .lab-tfsa { stroke: #8a6420; fill: none; }
    .ci-app .xchart .lab-tfsa { fill: #8a6420; stroke: none; }
    .ci-app .xchart .s-rrsp { stroke: #1f7a4d; }
    .ci-app .xchart .lab-rrsp { fill: #1f7a4d; }
    .ci-app .xchart .s-nreg { stroke: #4a5568; }
    .ci-app .xchart .lab-nreg { fill: #4a5568; }

    .ci-app .figs,
    .ci-app .verdict,
    .ci-app .xchart {
        break-inside: avoid;
    }

    .ci-app .table-scroll {
        overflow: visible;
    }
}
