/*
 * my-student-loan.co.uk
 *
 * Loaded after site.css, so it only states what changes.
 *
 * The idea: a student loan is not a debt you clear, it is a deduction you
 * live with, so the page is set as the statement it is. One fact governs the
 * whole thing, and the old design buried it in a list of five identical rows:
 * you pay nine per cent of what you earn above a threshold, and nothing at all
 * on the rest. So the answer is followed by a ruled deduction ladder with the
 * pivot line, the part above the threshold, given weight and everything else
 * set back from it.
 *
 * The masthead carries an engraved balance chart on graph paper, which is
 * what a loan running thirty or forty years looks like when it is drawn.
 *
 * The sidebar is gone. A fixed icon rail is a product-dashboard device, and
 * this is a page about a debt that somebody reads once. It was the loudest
 * thing on any of these five sites saying "generated from a template".
 *
 * What it replaces: an app shell with a line-icon rail, a white card holding
 * four radio buttons that told you nothing about what you were choosing, and
 * five result rows of identical weight.
 */

/* ------------------------------------------------------------------ type */

:root {
    --step-6: 3.1rem;
    --step-7: 4.2rem;

    --font-figure: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

    /* Plum: academic, and unlike anything else in the group. */
    --accent: #3E2149;
    --accent-deep: #2A1433;
    --board: #2A1433;
}

.masthead-kicker,
.section-index {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-feature-settings: 'tnum';
}

/* -------------------------------------------------------------- masthead */

/*
 * Multiplied over the plum rather than laid on top, so the texture can only
 * darken the ground: white type here is never worse than the 13.8:1 it
 * measures on the flat colour.
 */
.masthead {
    background-color: var(--accent);
    background-image: url('/img/balance-curve.webp');
    background-size: 500px auto;
    background-blend-mode: multiply;
    color: #fff;
    padding-block: clamp(2.5rem, 7vw, 4.5rem) clamp(2rem, 5vw, 3.25rem);
    border-bottom: 5px solid var(--board);
}

.masthead-inner {
    max-width: var(--page);
    margin-inline: auto;
    padding-inline: clamp(1rem, 4vw, 2rem);
}

.masthead-kicker {
    color: #fff;
    opacity: 0.78;
    margin: 0 0 1.25rem;
}

.masthead h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5.4vw, var(--step-6));
    font-weight: 700;
    line-height: 1.04;
    letter-spacing: -0.02em;
    max-width: 16ch;
    color: #fff;
    margin: 0;
    text-wrap: balance;
}

.masthead-standfirst {
    margin: 1.15rem 0 0;
    font-size: var(--step-1);
    line-height: 1.5;
    max-width: 52ch;
    color: #fff;
    opacity: 0.9;
}

/* ---------------------------------------------------- the top navigation */

/*
 * The nav that replaced the rail. It is the same shape as the sister sites so
 * the group reads as one hand, and it scrolls away rather than sitting fixed
 * over the content.
 */
.site-nav .dark-mode-toggle {
    background: none;
    border: 0;
    padding: 0.25rem;
    cursor: pointer;
    color: inherit;
    line-height: 0;
}

.site-nav .dark-mode-toggle:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* ------------------------------------------------------------- the sheet */

.container {
    counter-reset: reference;
    max-width: var(--page);
    margin-inline: auto;
    padding-inline: clamp(1rem, 4vw, 2rem);
    padding-block: clamp(2rem, 5vw, 3.25rem) 4rem;
}

.doc-grid {
    display: grid;
    gap: clamp(0.85rem, 3vw, 2.5rem);
}

@media (min-width: 60rem) {
    .doc-grid {
        grid-template-columns: 10rem minmax(0, 1fr);
        align-items: start;
    }
}

.doc-grid + .doc-grid {
    margin-top: clamp(2.25rem, 5vw, 3.5rem);
    padding-top: clamp(2.25rem, 5vw, 3.5rem);
    border-top: 1px solid var(--rule);
}

.section-index {
    color: var(--accent);
    margin: 0;
    padding-top: 0.45rem;
    line-height: 1.4;
}

@media (min-width: 60rem) {
    .section-index {
        text-align: right;
        border-top: 2px solid var(--accent);
    }
}

.doc-prose > * + * {
    margin-top: 1rem;
}

.doc-prose p,
.doc-prose li {
    max-width: 66ch;
}

.doc-prose .lede {
    font-size: var(--step-1);
    line-height: 1.5;
    color: var(--ink);
}

.notes {
    list-style: none;
    margin: 1.25rem 0 0;
    padding: 0;
}

.notes li {
    border-top: 1px solid var(--rule);
    padding-block: 0.7rem;
}

.notes li:last-child {
    border-bottom: 1px solid var(--rule);
}

/* -------------------------------------------------------------- the form */

.calculator-card {
    border: 1px solid var(--rule-strong);
    border-top: 5px solid var(--accent);
    background: var(--card);
    padding: clamp(1.25rem, 4vw, 2.25rem);
    border-radius: 0;
    box-shadow: none;
}

.input-group {
    margin: 0 0 1.75rem;
}

.input-group label,
.plan-legend {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 0.4rem;
}

/*
 * A ruled line rather than a box. The rule takes the accent on focus and the
 * outline is kept as well, because a colour change alone is not a focus
 * indicator for anyone who cannot see the colour.
 */
.calculator-card input[type='number'] {
    width: 100%;
    border: 0;
    border-bottom: 2px solid var(--rule-strong);
    border-radius: 0;
    background: transparent;
    padding: 0.3rem 0 0.4rem;
    font-family: var(--font-figure);
    font-size: 1.3rem;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    box-shadow: none;
}

.calculator-card input[type='number']:hover {
    border-bottom-color: var(--ink-soft);
}

.calculator-card input[type='number']:focus-visible {
    border-bottom-color: var(--accent);
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.calculator-card input::placeholder {
    /* #6B747E on white is 4.75:1, so the hint reads rather than ghosts. */
    color: var(--muted);
    font-size: 1rem;
}

.field-hint {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.82rem;
    color: var(--muted);
    max-width: 46ch;
}

/*
 * Four plans that previously said only "Plan 1" to "Plan 5", which is no help
 * at all to somebody who does not know which one they are on. Each option now
 * prints its own threshold, because the threshold is the whole difference
 * between them and the reason the answer changes.
 */
.plan-selector {
    display: grid;
    gap: 0;
    /* It is a fieldset now, so its default chrome has to go first. */
    border: 0;
    border-top: 1px solid var(--rule);
    padding: 0;
    margin: 0 0 1.75rem;
    min-width: 0;
}

.plan-legend {
    padding: 0;
    margin-bottom: 0.5rem;
}

.plan-option {
    background: none;
    border: 0;
    border-bottom: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

.plan-option label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.75rem 0.25rem;
    cursor: pointer;
    font-weight: 600;
    color: var(--ink);
}

.plan-option input[type='radio'] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

/* The mark is drawn on the label so the control stays reachable by keyboard. */
.plan-option label::before {
    content: '';
    flex: 0 0 auto;
    width: 0.85rem;
    height: 0.85rem;
    margin-right: 0.15rem;
    border: 2px solid var(--rule-strong);
    border-radius: 50%;
    align-self: center;
}

.plan-option input[type='radio']:checked + label::before {
    border-color: var(--accent);
    background: var(--accent);
    box-shadow: inset 0 0 0 3px var(--card);
}

.plan-option input[type='radio']:checked + label {
    color: var(--accent);
}

.plan-option input[type='radio']:focus-visible + label {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.plan-name {
    flex: 1 1 auto;
}

.plan-threshold {
    font-family: var(--font-figure);
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    white-space: nowrap;
    letter-spacing: 0.06em;
}

.calculate-btn {
    display: block;
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 0;
    padding: 0.95rem 1.5rem;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: none;
    margin: 0;
}

@media (min-width: 46rem) {
    .calculate-btn {
        width: auto;
        min-width: 20rem;
    }
}

.calculate-btn:hover {
    background: var(--board);
}

.calculate-btn:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

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

.results {
    display: none;
    margin-top: 2.25rem;
}

.results.show {
    display: block;
}

.monthly-repayment {
    background: var(--board);
    color: #fff;
    padding: clamp(1.5rem, 5vw, 2.5rem);
    border: 0;
    border-radius: 0;
    text-align: left;
}

.monthly-repayment .label {
    display: block;
    color: #fff;
    opacity: 0.72;
    margin-bottom: 0.6rem;
}

.monthly-repayment .amount {
    display: block;
    font-family: var(--font-figure);
    font-size: clamp(2.6rem, 11vw, var(--step-7));
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
    color: #fff;
}

.annual-repayment {
    display: block;
    margin-top: 0.9rem;
    font-family: var(--font-figure);
    font-size: 1rem;
    color: #fff;
    opacity: 0.85;
}

/*
 * The deduction ladder. Five rows that used to carry identical weight, now
 * read as a worked sum with one line given the emphasis: the slice above the
 * threshold, which is the only part of your salary the loan ever touches.
 */
.result-details {
    border: 1px solid var(--rule-strong);
    border-top: 0;
    background: var(--card);
    padding: clamp(1.1rem, 3.5vw, 1.75rem);
    border-radius: 0;
    box-shadow: none;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1.5rem;
    padding: 0.55rem 0;
    border-top: 1px solid var(--rule);
    background: none;
    border-radius: 0;
    box-shadow: none;
}

.result-item:first-child {
    border-top: 0;
}

.result-label {
    color: var(--ink-soft);
    font-size: 0.94rem;
}

.result-value {
    font-family: var(--font-figure);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--ink);
}

/*
 * The pivot. Everything above this line is context and everything below it is
 * arithmetic; this is the number that decides the answer.
 */
.result-item--pivot {
    border-top: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    margin: 0.35rem 0;
    padding: 0.8rem 0;
}

.result-item--pivot .result-label {
    color: var(--ink);
    font-weight: 700;
}

.result-item--pivot .result-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
}

/* ---------------------------------------------------------- the reference */

.info-section {
    counter-increment: reference;
    position: relative;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin: 0 !important;
}

@media (min-width: 60rem) {
    .info-section {
        padding-left: 11rem;
    }
}

.info-section + .info-section {
    margin-top: clamp(2.25rem, 5vw, 3.5rem) !important;
    padding-top: clamp(2.25rem, 5vw, 3.5rem);
    border-top: 1px solid var(--rule);
}

.info-section h2 {
    font-family: var(--font-display);
    font-size: var(--step-3);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin-bottom: 0.7rem;
    max-width: 30ch;
}

.info-section h2::before {
    content: counter(reference, decimal-leading-zero);
    display: block;
    margin-bottom: 0.5rem;
    font-family: var(--font-figure);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--accent);
}

@media (min-width: 60rem) {
    .info-section h2::before {
        position: absolute;
        left: 0;
        width: 9rem;
        margin: 0;
        padding-top: 0.5rem;
        text-align: right;
        border-top: 2px solid var(--accent);
    }
}

.info-section h3 {
    font-family: var(--font-display);
    font-size: var(--step-1);
    font-weight: 700;
    margin-top: 1.6rem;
    margin-bottom: 0.3rem;
}

.info-section p,
.info-section li {
    max-width: 66ch;
}

/*
 * The plan comparison table. Money in tabular figures so the threshold column
 * reads down, and a rule under the head rather than a filled band.
 */
.plan-table,
.info-section table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.94rem;
    margin: 1rem 0;
}

.plan-table th,
.plan-table td,
.info-section table th,
.info-section table td {
    border-top: 1px solid var(--rule);
    padding: 0.55rem 0.75rem 0.55rem 0;
    text-align: left;
    vertical-align: baseline;
}

.plan-table thead th,
.info-section table thead th {
    border-top: 0;
    border-bottom: 2px solid var(--accent);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    background: none;
}

.plan-table td + td,
.info-section table td + td {
    font-family: var(--font-figure);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* --------------------------------------------------------- inside pages */

.masthead--page {
    padding-block: clamp(1.75rem, 4.5vw, 2.75rem) clamp(1.5rem, 3.5vw, 2rem);
    border-bottom-width: 4px;
}

.masthead--page h1 {
    font-size: clamp(1.7rem, 4.2vw, var(--step-5));
    max-width: 26ch;
}

.article-card {
    background: none;
    border: 0;
    border-top: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: none;
    padding: 1.4rem 0 1.5rem;
    margin: 0;
}

.article-card:last-of-type {
    border-bottom: 1px solid var(--rule);
}

.article-card h2,
.article-card h3 {
    font-family: var(--font-display);
    font-size: var(--step-2);
    font-weight: 700;
    line-height: 1.2;
    margin: 0.2rem 0 0.4rem;
    max-width: 38ch;
}

.article-date,
.read-more {
    font-family: var(--font-figure);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    background: none;
    border: 0;
    padding: 0;
}

.faq-item {
    background: none;
    border: 0;
    border-top: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: none;
    padding: 1.1rem 0;
    margin: 0;
}

.faq-item:last-of-type {
    border-bottom: 1px solid var(--rule);
}

.faq-item > h2,
.faq-item > h3,
.faq-question {
    font-family: var(--font-display);
    font-size: var(--step-0);
    font-weight: 700;
    margin: 0 0 0.3rem;
}

.faq-item p,
.faq-item li,
.faq-answer {
    color: var(--ink-soft);
    max-width: 66ch;
}

.article-summary {
    color: var(--ink-soft);
    max-width: 66ch;
}

/* The subtitle under an interior heading, left over from the app shell. */
.tagline {
    color: var(--muted);
}

.app-footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--rule);
    font-size: 0.88rem;
    color: var(--muted);
}

/* ------------------------------------------------------------ dark mode */

/*
 * The plum is dark enough to read on white but sits too close to a dark
 * ground. #C79BD4 on #14161A is 7.8:1.
 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --board: #1E0E26;
    }

    :root:not([data-theme='light']) .section-index,
    :root:not([data-theme='light']) .article-date,
    :root:not([data-theme='light']) .read-more,
    :root:not([data-theme='light']) .info-section h2::before,
    :root:not([data-theme='light']) .plan-table thead th,
    :root:not([data-theme='light']) .result-item--pivot .result-value,
    :root:not([data-theme='light']) .plan-option input[type='radio']:checked + label {
        color: #C79BD4;
    }

    :root:not([data-theme='light']) .section-index,
    :root:not([data-theme='light']) .info-section h2::before,
    :root:not([data-theme='light']) .plan-table thead th,
    :root:not([data-theme='light']) .result-item--pivot {
        border-color: #C79BD4;
    }

    :root:not([data-theme='light']) .plan-option input[type='radio']:checked + label::before {
        border-color: #C79BD4;
        background: #C79BD4;
    }
}

:root[data-theme='dark'] {
    --board: #1E0E26;
}

:root[data-theme='dark'] .section-index,
:root[data-theme='dark'] .info-section h2::before,
:root[data-theme='dark'] .result-item--pivot .result-value {
    color: #C79BD4;
}

/* ---------------------------------------------------------------- print */

@media print {
    .site-nav,
    .app-footer,
    .book-plug,
    ins.adsbygoogle {
        display: none !important;
    }

    .masthead {
        background: none;
        color: #000;
        border-bottom: 2px solid #000;
    }

    .masthead h1,
    .masthead-standfirst,
    .masthead-kicker {
        color: #000;
        opacity: 1;
    }

    .monthly-repayment {
        background: none;
        border: 2px solid #000;
    }

    .monthly-repayment .label,
    .monthly-repayment .amount,
    .annual-repayment {
        color: #000;
        opacity: 1;
    }
}

/* ------------------------------------------------------------ focus ring */

/*
 * site.css removes the outline on :focus for inputs, selects, textareas and
 * buttons. For anyone navigating by keyboard that is a 2.4.7 failure, and the
 * rules above only put it back on the controls this restyle touched: the
 * textarea on the contact form was left with no indicator at all. This is the
 * backstop for everything focusable, and it is last in the file so it wins on
 * order against the equal-specificity rules in site.css.
 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/*
 * A placeholder is a hint, not a value.
 *
 * The fields on these pages were enlarged so the figure people type is legible
 * at the scale of the answer. At that size a placeholder set in the input's own
 * colour and weight reads as a filled field, and somebody arrives at a form that
 * looks already answered. Every field here carries a visible label, so the
 * placeholder is free to recede.
 */
input::placeholder,
textarea::placeholder {
    color: color-mix(in srgb, currentColor 38%, transparent);
    font-size: 0.66em;
    font-weight: 400;
    letter-spacing: 0.04em;
    opacity: 1;
}

/* placeholder specificity */
.calculator-card input::placeholder,
.calculator-card textarea::placeholder,
input[type="text"]::placeholder,
input[type="number"]::placeholder,
input[type="search"]::placeholder {
    color: color-mix(in srgb, currentColor 38%, transparent);
    font-size: 0.66em;
    font-weight: 400;
    letter-spacing: 0.04em;
    opacity: 1;
}

/* --------------------------------------------------- validation messages */

/*
 * These replaced alert(). A modal stops the page, loses your place on a
 * phone, and never says which field it is about. role="alert" on the slot
 * gets the message announced where it sits.
 */
.field-error {
    display: none;
    margin-top: 0.45rem;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.35;
    color: #A8251B;
}

.field-error.show {
    display: block;
}

input[aria-invalid='true'] {
    border-color: #A8251B;
}

@media (prefers-color-scheme: dark) {
    .field-error {
        color: #F2A9A2;
    }
}

body.dark-mode .field-error {
    color: #F2A9A2;
}
