/*
 * smp-calculator.co.uk
 *
 * Loaded after site.css, so it only has to state what changes.
 *
 * The idea: statutory maternity pay is not one figure, it is a shape over time.
 * Six weeks at ninety per cent of what you were earning, then thirty-three at a
 * flat rate that is usually a good deal less. Anyone planning around it needs to
 * see the drop, not just the total. So the answer is drawn as a schedule: a
 * strip split six to thirty-three, the two rates set against each other, and
 * the total underneath. The masthead is a printed week scale.
 *
 * On register: the reader is a pregnant woman working out whether she can
 * afford the leave she is entitled to. Plum rather than pink, a text serif
 * rather than a soft rounded sans, and no encouragement. Plain, adult and
 * specific is the respectful choice here, and it is also the distinctive one.
 *
 * What it replaces: "Calculate Your Statutory Maternity Pay" over a white
 * rounded card, a total set at the same size as the heading above it, and four
 * breakdown rows that buried the one fact that matters, which is that the money
 * falls off a cliff in week seven.
 */

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

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

    /*
     * Spectral: a text serif with enough weight to carry a masthead and enough
     * warmth to read as something written for a person rather than issued at
     * one.
     */
    --font-display: 'Spectral', Georgia, 'Times New Roman', serif;
    --font-figure: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;

    --accent: #6E2757;
    --accent-deep: #521D41;
    --accent-tint: #F3EAF0;
    --board: #3C1430;
}

.masthead-kicker,
.section-index,
.field-name,
.form-legend,
.schedule-label,
.band-weeks,
.total-label,
.result-label,
.breakdown-label {
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-feature-settings: 'tnum';
}

/* --------------------------------------------------------- the running head */

/* The nav carries the colour on every page, so the site does not go quiet past the tool. */
.site-nav {
    background: var(--board);
    border-bottom: 0;
}

.site-nav .nav-brand,
.site-nav .nav-brand:hover {
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
}

.nav-links a {
    color: #fff;
    text-decoration: none;
    opacity: 0.88;
    padding-block: 0.2rem;
    border-bottom: 2px solid transparent;
}

.nav-links a:hover {
    opacity: 1;
    border-bottom-color: rgba(255, 255, 255, 0.6);
}

/* Current page marked by a rule and a weight, not by colour alone. */
.nav-links a[aria-current] {
    opacity: 1;
    font-weight: 700;
    border-bottom-color: #fff;
}

.nav-links a:focus-visible,
.site-nav .nav-brand:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}

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

/*
 * Full bleed. The week scale is multiplied over the accent rather than laid on
 * top, which can only darken the ground: white on this band is never worse than
 * white on the flat accent, which measures 10.0:1.
 */
.masthead {
    background-color: var(--accent);
    background-image: url('/img/week-scale.webp');
    background-size: 1024px 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 {
    display: block;
    color: #fff;
    opacity: 0.82;
    margin-bottom: 1.1rem;
}

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

.masthead-standfirst {
    margin-top: 1.1rem;
    font-size: var(--step-1);
    line-height: 1.5;
    max-width: 50ch;
    color: #fff;
    opacity: 0.92;
}

/* --------------------------------------------------------------- the grid */

.doc {
    padding-block: clamp(2rem, 5vw, 3.5rem) 3rem;
}

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

@media (min-width: 60rem) {
    .doc-grid {
        grid-template-columns: 9rem 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);
    padding-top: 0.4rem;
}

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

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

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

.calculator-card .form-legend {
    color: var(--accent);
    margin-bottom: 1.5rem;
}

.fields {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1.75rem;
}

.fields > li {
    display: grid;
    grid-template-columns: 1.7rem minmax(0, 1fr);
    column-gap: 0.6rem;
    align-items: baseline;
    margin: 0;
}

.field-num {
    font-family: var(--font-figure);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

.field-name {
    display: block;
    color: var(--ink-soft);
    margin-bottom: 0.4rem;
}

/*
 * Ruled baselines rather than boxes. 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'],
.calculator-card input[type='date'] {
    width: 100%;
    border: 0;
    border-bottom: 2px solid var(--rule-strong);
    border-radius: 0;
    background: transparent;
    padding: 0.35rem 0 0.45rem;
    font-family: var(--font-figure);
    font-size: 1.05rem;
    color: var(--ink);
    box-shadow: none;
}

.calculator-card input:hover {
    border-bottom-color: var(--ink-soft);
}

.calculator-card input: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 is readable rather than a ghost. */
    color: var(--muted);
    font-family: var(--font-body);
    font-size: 0.92rem;
}

.field-hint,
.help-text {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.82rem;
    color: var(--muted);
}

/* The eight payslip boxes are a grid of weeks, so they are set as one. */
.payslip-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(7rem, 100%), 1fr));
    gap: 1rem;
    margin-block: 1rem;
}

.payslip-input label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.3rem;
}

.earnings-calculator,
.date-calculator {
    border-top: 1px solid var(--rule);
    padding-top: 1.25rem;
    margin-top: 1.5rem;
}

.earnings-calculator h3,
.date-calculator h3 {
    font-family: var(--font-display);
    font-size: var(--step-1);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.average-result,
.date-results {
    background: none !important;
    border: 0;
    border-left: 4px solid var(--accent);
    border-radius: 0;
    box-shadow: none;
    padding: 0.35rem 0 0.35rem 1rem !important;
    margin-top: 1rem;
    color: var(--ink-soft);
}

.average-result-value {
    font-family: var(--font-display);
    font-size: var(--step-3);
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

.calculate-btn,
.calculate-average-btn {
    background: var(--accent);
    color: #fff;
    border: 0;
    border-radius: 0;
    padding: 0.9rem 1.5rem;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
}

.calculate-btn {
    margin-top: 2rem;
    width: 100%;
}

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

.calculate-btn:hover,
.calculate-average-btn:hover {
    background: var(--accent-deep);
}

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

.toggle-calculator,
.clear-history-btn {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--rule-strong);
    border-radius: 0;
    padding: 0.5rem 1rem;
    font-family: var(--font-body);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
}

.toggle-calculator:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.clear-history-btn:hover {
    border-color: var(--bad);
    color: var(--bad);
}

/* ----------------------------------------------------------- the schedule */

.results {
    border-top: 0;
    padding-top: 0;
    margin-top: clamp(1.75rem, 4vw, 2.5rem);
}

.schedule-label {
    display: block;
    color: var(--accent);
    margin-bottom: 0.6rem;
}

/*
 * The strip is the point of the page: six weeks against thirty-three, drawn to
 * scale, so the drop in week seven is something you see rather than something
 * you have to work out from two rows of a table. It is decoration of a fact
 * that the text below states in full, so it is hidden from assistive tech
 * rather than duplicated into it.
 */
.schedule-strip {
    display: flex;
    height: 2.25rem;
    border: 1px solid var(--ink);
}

/*
 * Both halves take a fill that clears 3:1 against the page, so the split is
 * visible as two filled areas rather than one bar trailing off into the paper,
 * and the division between them is drawn as a rule as well as a tonal step: the
 * 2.7:1 between the two fills is a reinforcement, never the only signal.
 */
.strip-first {
    flex: 6;
    background: var(--accent);
}

.strip-rest {
    flex: 33;
    /* #A87595 on white is 3.7:1. */
    background: #A87595;
    border-left: 1px solid var(--ink);
}

.schedule-bands {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0;
}

@media (min-width: 40rem) {
    .schedule-bands {
        grid-template-columns: 6fr 33fr;
    }
}

.band {
    padding: 1rem 0 1.25rem;
    border-bottom: 1px solid var(--rule);
    min-width: 0;
}

@media (min-width: 40rem) {
    .band-rest {
        padding-left: 1.5rem;
        border-left: 1px solid var(--rule);
    }
}

.band-weeks {
    display: block;
    color: var(--muted);
}

.band-rate {
    display: block;
    margin-top: 0.35rem;
    font-family: var(--font-display);
    font-size: var(--step-4);
    font-weight: 700;
    line-height: 1.05;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.band-note {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
    max-width: 34ch;
}

.band-total {
    display: block;
    margin-top: 0.6rem;
    font-family: var(--font-figure);
    font-size: 0.95rem;
    color: var(--ink-soft);
    font-variant-numeric: tabular-nums;
}

.band-total::before {
    content: 'Paid over the period: ';
    color: var(--muted);
}

/*
 * The total. It was set at the size of a section heading in a bordered box that
 * looked exactly like the three boxes around it.
 */
.total-panel {
    background-color: var(--accent);
    background-image: url('/img/week-scale.webp');
    background-size: 1024px auto;
    background-blend-mode: multiply;
    color: #fff;
    padding: clamp(1.5rem, 4vw, 2.25rem);
    margin-top: 1.75rem;
}

.total-label {
    display: block;
    color: #fff;
    opacity: 0.82;
}

.total-amount,
.result-value {
    display: block;
    margin-top: 0.3rem;
    font-family: var(--font-display);
    font-size: clamp(2.8rem, 11vw, var(--step-7));
    font-weight: 700;
    line-height: 0.95;
    letter-spacing: -0.03em;
    color: #fff;
    font-variant-numeric: tabular-nums;
}

#eligibilityMessage {
    margin-top: 1.5rem;
}

/*
 * Whether you qualify is a yes or a no, so it is said in words on a ruled stub.
 * The rule colour agrees with the word; it never carries the meaning alone.
 */
#eligibilityMessage > div {
    background: none !important;
    border: 0;
    border-left: 4px solid var(--muted);
    border-radius: 0;
    box-shadow: none;
    padding: 0.35rem 0 0.35rem 1rem !important;
    color: var(--ink-soft);
}

#eligibilityMessage .success {
    border-left-color: var(--good);
}

#eligibilityMessage .success strong {
    color: var(--good);
}

#eligibilityMessage .error,
#eligibilityMessage .warning {
    border-left-color: var(--bad);
}

#eligibilityMessage .error strong,
#eligibilityMessage .warning strong {
    color: var(--bad);
}

#eligibilityMessage strong {
    display: block;
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 0.3rem;
}

/* ------------------------------------------------- retiring the box rule */

.info-section,
.content-card,
.info-card,
.faq-card,
.card,
.result-box,
.email-box,
.contact-box,
.faq-section,
.history-section,
.info-box {
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
}

.info-box {
    border-left: 4px solid var(--accent);
    padding: 0.2rem 0 0.2rem 1rem;
    margin-block: 1.25rem;
    color: var(--ink-soft);
}

.history-section {
    border-top: 3px solid var(--accent);
    padding-top: 1.5rem;
    margin-top: clamp(2rem, 5vw, 3rem);
}

.history-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.article-card,
.blog-card,
.history-item {
    background: none;
    border: 0;
    border-top: 1px solid var(--rule-strong);
    border-radius: 0;
    box-shadow: none;
    padding: 0.9rem 0 1.1rem;
}

.article-card:hover,
.blog-card:hover {
    border-top-color: var(--accent);
    box-shadow: none;
}

.empty-history p {
    color: var(--muted);
    border-top: 1px solid var(--rule);
    padding-top: 1rem;
}

.blog-grid,
.related-grid,
.card-grid {
    gap: 0 2rem;
}

/* --------------------------------------------------- reference typography */

.reference h2,
.info-section h2,
.history-header h2 {
    font-family: var(--font-display);
    font-size: var(--step-4);
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: -0.02em;
    margin-bottom: 0.6rem;
    max-width: 28ch;
}

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

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

/* ------------------------------------------------ the interior page heads */

.page-header,
.header-section,
.container > header {
    padding-block: clamp(2rem, 5vw, 3rem) 0;
    border-top: 5px solid var(--accent);
    margin-top: clamp(1.5rem, 4vw, 2.5rem);
}

.page-header h1,
.header-section h1,
.container > header h1 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 5.5vw, var(--step-6));
    font-weight: 700;
    line-height: 1.06;
    letter-spacing: -0.02em;
    max-width: 22ch;
    margin-top: 0.75rem;
}

.page-header p,
.header-section p,
.container > header p {
    font-size: var(--step-1);
    max-width: 54ch;
    color: var(--ink-soft);
}

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

@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --accent-tint: #2A1824;
        --board: #240C1C;
    }

    :root:not([data-theme='light']) .section-index,
    :root:not([data-theme='light']) .field-num,
    :root:not([data-theme='light']) .schedule-label,
    :root:not([data-theme='light']) .calculator-card .form-legend {
        /* #D18FBB on #1B1F24 is 8.0:1. */
        color: #D18FBB;
    }

    :root:not([data-theme='light']) .calculator-card,
    :root:not([data-theme='light']) .history-section {
        border-top-color: #D18FBB;
    }

    /*
     * On a dark ground the plum itself falls to 1.7:1 and the strip all but
     * disappears, so both halves lift: #D18FBB is 6.6:1 against the dark
     * surface and #8E5A7D is 3.1:1, and the first period stays the stronger of
     * the two so the reading does not invert.
     */
    :root:not([data-theme='light']) .strip-first {
        background: #D18FBB;
    }

    :root:not([data-theme='light']) .strip-rest {
        background: #8E5A7D;
    }
}

:root[data-theme='dark'] .section-index,
:root[data-theme='dark'] .field-num,
:root[data-theme='dark'] .schedule-label,
:root[data-theme='dark'] .calculator-card .form-legend {
    color: #D18FBB;
}

:root[data-theme='dark'] .strip-first {
    background: #D18FBB;
}

:root[data-theme='dark'] .strip-rest {
    background: #8E5A7D;
}

/* ------------------------------------------------------ restoring focus */

/*
 * site.css removes the outline from the inputs and from the button that gives
 * the answer, and in two of the three places it puts nothing back at all, so
 * those controls have no visible focus for anyone using a keyboard. The
 * selectors below match its specificity exactly and load after it, which is
 * what makes the outline come back. This lives here rather than in site.css
 * because that file is generated boilerplate shared across the estate.
 */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
input[type="text"]:focus-visible,
input[type="email"]:focus-visible,
input[type="number"]:focus-visible,
.calculate-btn:focus-visible,
.calculate-average-btn:focus-visible,
.toggle-calculator:focus-visible,
.clear-history-btn:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

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

@media print {
    .site-nav,
    .editorial-footer,
    .book-plug,
    .calculate-btn,
    .calculate-average-btn,
    .toggle-calculator,
    .clear-history-btn {
        display: none !important;
    }

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

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

/*
 * 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;
}

.average-weeks {
    margin-top: 0.3rem;
    font-size: 0.85rem;
    opacity: 0.8;
}

/* ------------------------------------------------------- result actions */

.result-actions {
    margin-top: 1.4rem;
}

.result-action {
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    padding: 0.7rem 1.2rem;
    color: var(--accent);
    background: none;
    border: 2px solid var(--accent);
    cursor: pointer;
}

.result-action:hover {
    color: #fff;
    background: var(--accent);
}

/*
 * The kept scenarios were divs with an onclick, so a keyboard could not reach
 * them. They are buttons now and need resetting to look as they did.
 */
button.history-item {
    display: block;
    width: 100%;
    font: inherit;
    color: inherit;
    text-align: left;
    background: none;
    cursor: pointer;
}
