/* Jaroha's reader tools (Views/Shared/Tools/_Tool.cshtml, js/tools.js): the same look on a tool's own page and
   inside an article. Colours come from the public site's --nr-* variables, with the article page's fallbacks. */
.jt {
    --jt-ink: var(--nr-ink, #0f253d);
    --jt-text: var(--nr-text, #23303d);
    --jt-muted: var(--nr-muted, #5d6b79);
    --jt-rule: var(--nr-rule, #dde3e8);
    --jt-wash: var(--nr-wash, #f3f6f8);
    --jt-teal: var(--nr-teal, #1fb8be);
    --jt-teal-ink: var(--nr-teal-ink, #0b6f75);
    margin: 2rem 0;
    border: 1px solid var(--jt-rule);
    border-top: 3px solid var(--jt-teal);
    border-radius: 6px;
    background: #fff;
    color: var(--jt-text);
    font-family: var(--nr-sans, 'Public Sans', 'Inter', system-ui, sans-serif);
    padding: 1.1rem 1.25rem 1rem;
}

.jt-kicker {
    margin: 0;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--jt-teal-ink);
}

.jt-title {
    margin: .15rem 0 1rem;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--jt-ink);
}

.jt-body {
    display: grid;
    gap: 1.25rem;
}

@media (min-width: 720px) {
    .jt-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

.jt-form {
    display: grid;
    gap: .75rem;
    margin: 0;
}

.jt-field label {
    display: block;
    font-size: .875rem;
    font-weight: 600;
    margin-bottom: .25rem;
    color: var(--jt-ink);
}

.jt-input {
    display: flex;
    align-items: center;
    border: 1px solid var(--jt-rule);
    border-radius: 4px;
    background: #fff;
}

.jt-input:focus-within,
.jt-field select:focus {
    outline: 2px solid var(--jt-teal);
    outline-offset: 1px;
}

.jt-input span {
    padding: 0 .6rem;
    color: var(--jt-muted);
    font-size: .9375rem;
}

.jt-input--money span { padding-right: 0; }

.jt-input input,
.jt-field select {
    flex: 1;
    min-width: 0;
    width: 100%;
    border: 0;
    background: transparent;
    padding: .55rem .6rem;
    font-size: 1rem;
    color: var(--jt-text);
    font-variant-numeric: tabular-nums;
}

.jt-input input:focus { outline: none; }

.jt-field select {
    border: 1px solid var(--jt-rule);
    border-radius: 4px;
}

.jt-hint {
    margin: .25rem 0 0;
    font-size: .8125rem;
    color: var(--jt-muted);
}

.jt-results {
    background: var(--jt-wash);
    border-radius: 6px;
    padding: 1rem;
}

.jt-results dl { margin: 0; display: grid; gap: .1rem; }

.jt-result {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .45rem 0;
    border-bottom: 1px solid var(--jt-rule);
}

.jt-result:last-child { border-bottom: 0; }

.jt-result dt { font-weight: 400; color: var(--jt-muted); font-size: .9375rem; }

.jt-result dd {
    margin: 0;
    font-weight: 700;
    color: var(--jt-ink);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.jt-result--lead { display: block; padding-bottom: .75rem; }
.jt-result--lead dt { font-size: .875rem; }
.jt-result--lead dd { text-align: left; font-size: 2rem; line-height: 1.2; color: var(--jt-teal-ink); }

.jt-problem {
    margin: 0 0 .5rem;
    padding: .5rem .75rem;
    border-left: 3px solid #c2410c;
    background: #fff7ed;
    color: #7c2d12;
    font-size: .9375rem;
}

/* While the form has a problem, everything worked out from the last good numbers fades, charts and the live bar too,
   so an old answer never reads as the answer to what is typed now. */
.jt-has-problem dl, .jt-has-problem .jt-chart, .jt-has-problem .jt-years, .jt-has-problem .jt-table-wrap, .jt-has-problem .jt-live { opacity: .35; transition: opacity .15s; }

.jt-years { margin-top: 1rem; }

.jt-years summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--jt-teal-ink);
}

.jt-table-wrap { overflow-x: auto; margin-top: .5rem; max-height: 22rem; overflow-y: auto; }

.jt-years table { width: 100%; border-collapse: collapse; font-size: .875rem; font-variant-numeric: tabular-nums; }

.jt-years th,
.jt-years td { padding: .35rem .5rem; border-bottom: 1px solid var(--jt-rule); text-align: right; }

.jt-years th:first-child { text-align: left; }

.jt-years thead th { position: sticky; top: 0; background: #fff; color: var(--jt-ink); }

.jt-note {
    margin: .9rem 0 0;
    font-size: .8125rem;
    color: var(--jt-muted);
}

.jt-note a { color: var(--jt-teal-ink); font-weight: 600; }

/* The tools index (/tools). */
.jt-index-group + .jt-index-group { margin-top: 2rem; }

.jt-index-list {
    list-style: none;
    padding: 0;
    margin: .75rem 0 0;
    display: grid;
    gap: 1rem;
}

@media (min-width: 720px) {
    .jt-index-list { grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); }
}

.jt-index-card {
    display: block;
    height: 100%;
    padding: 1rem 1.1rem;
    border: 1px solid var(--nr-rule, #dde3e8);
    border-top: 3px solid var(--nr-teal, #1fb8be);
    border-radius: 6px;
    color: inherit;
    text-decoration: none;
}

.jt-index-card:hover,
.jt-index-card:focus { border-color: var(--nr-teal, #1fb8be); }

.jt-index-card strong { display: block; font-size: 1.1rem; color: var(--nr-ink, #0f253d); }

.jt-index-card span { display: block; margin-top: .3rem; font-size: .9375rem; color: var(--nr-muted, #5d6b79); }

/* The retirement simulator: inputs in small groups, a bar per year of savings, and a warning colour when it runs short. */
.jt-group {
    display: grid;
    gap: .75rem;
    margin: 0;
    padding: 0 0 .75rem;
    border: 0;
    border-bottom: 1px solid var(--jt-rule);
}

.jt-group:last-of-type { border-bottom: 0; padding-bottom: 0; }

.jt-group legend {
    margin-bottom: .25rem;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--jt-teal-ink);
}

.jt-short [data-out="lasts"],
.jt-short [data-out="extra"] { color: #b42318; }

.jt-chart { margin: 1rem 0 0; }

.jt-bars {
    display: flex;
    align-items: flex-end;
    gap: 1px;
    height: 8rem;
    border-bottom: 1px solid var(--jt-rule);
}

/* One column per year: the average-returns bar, with the 10th-90th percentile band of the simulated markets behind it. */
.jt-col {
    position: relative;
    display: flex;
    align-items: flex-end;
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
}

.jt-band {
    position: absolute;
    left: 0;
    right: 0;
    background: var(--jt-teal);
    opacity: .22;
}

.jt-bar {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    background: var(--jt-teal);
    border-radius: 2px 2px 0 0;
}

.jt-bars--band .jt-bar { opacity: .85; }

.jt-bar--retired { background: var(--jt-ink); }

.jt-chart figcaption {
    margin-top: .4rem;
    font-size: .8125rem;
    color: var(--jt-muted);
}

.jt-key {
    display: inline-block;
    width: .7rem;
    height: .7rem;
    margin: 0 .2rem 0 .1rem;
    border-radius: 2px;
    background: var(--jt-teal);
    vertical-align: -.05rem;
}

.jt-key--retired { margin-left: .6rem; background: var(--jt-ink); }

.jt-key--band { margin-left: .6rem; background: var(--jt-teal); opacity: .3; }

/* A figure that just changed lights up for a moment. */
.jt-changed { animation: jt-changed 1.2s ease-out; }

@keyframes jt-changed {
    from { background-color: rgba(31, 184, 190, .35); }
    to { background-color: transparent; }
}

@media (prefers-reduced-motion: reduce) {
    .jt-changed { animation: none; outline: 2px solid rgba(31, 184, 190, .6); outline-offset: 2px; }
}

/* The headline figures repeated under the inputs; on a phone they stay at the bottom of the screen while the form scrolls. */
.jt-live {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: .25rem 1rem;
    margin: 1rem 0 0;
    padding: .6rem .8rem;
    background: var(--jt-wash);
    border-radius: 6px;
    font-size: .9375rem;
}

.jt-short .jt-live [data-out="lasts"] { color: #b42318; }

@media (max-width: 719px) {
    .jt-live {
        position: sticky;
        bottom: 0;
        z-index: 1;
        box-shadow: 0 -2px 8px rgba(15, 37, 61, .12);
    }
}

/* On a wide screen the results stay in view beside the form while the form scrolls. */
@media (min-width: 720px) {
    .jt-results { position: sticky; top: 1rem; align-self: start; }
    .jt-live { display: none; }
}

/* Health calculators and trackers: two or three small fields side by side, the Add button, the list of entries. */
.jt-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: .75rem;
}

.jt-pair--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.jt-pair[hidden], [data-units][hidden] { display: none; }

.jt-add {
    justify-self: start;
    padding: .55rem 1.1rem;
    border: 0;
    border-radius: 4px;
    background: var(--jt-teal-ink);
    color: #fff;
    font-weight: 700;
}

.jt-add:hover, .jt-add:focus { background: var(--jt-ink); }

.jt-entries {
    list-style: none;
    margin: .5rem 0;
    padding: 0;
}

.jt-entries li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: .35rem 0;
    border-bottom: 1px solid var(--jt-rule);
    font-size: .9375rem;
}

.jt-remove {
    border: 1px solid var(--jt-rule);
    border-radius: 4px;
    background: #fff;
    color: var(--jt-muted);
    font-size: .8125rem;
    padding: .2rem .55rem;
}

.jt-remove:hover, .jt-remove:focus { color: #b42318; border-color: #b42318; }

.jt-tracker .jt-chart { margin-top: 1rem; }
