/*
 * sick-pay-calculator.co.uk
 *
 * Loaded after site.css, so it only has to state what changes.
 *
 * The idea: SSP is not really a sum, it is a question about which days count.
 * Three waiting days that pay nothing, qualifying days that do, and a hard stop
 * at twenty-eight weeks. So the page is the absence record card an employer
 * keeps: a ruled grid of day cells with the days that do not qualify hatched
 * out, printed in the blue of a form you are handed rather than choose.
 *
 * The register matters more here than on the pay calculators. People arrive at
 * this one ill, often worried about money, sometimes while being managed out.
 * It should read as plain and official, like something issued, not like a
 * product trying to be friendly at them.
 *
 * What it replaces: a white rounded card on off-white, a section headed "What
 * This Site Does", and a total that was set at the same size as the heading
 * above it.
 */

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

:root {
    /* The house scale tops out at 2.49rem, so the top is extended for the total. */
    --step-6: 3rem;
    --step-7: 4.2rem;

    /*
     * Libre Franklin. Franklin Gothic is the face of the printed public notice,
     * which is exactly the voice a statutory entitlement should be written in.
     */
    --font-display: 'Libre Franklin', 'Helvetica Neue', Arial, sans-serif;
    --font-figure: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;

    --accent: #1F4B7A;
    --accent-deep: #16375A;
    --accent-tint: #E9EFF6;
    --board: #102B48;
}

.masthead-kicker,
.section-index,
.field-name,
.form-legend,
.total-label,
.eligibility-check strong,
.summary-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 becomes the band that appears on every page, so the site does not go
 * quiet the moment you leave the calculator. It is the solid board colour, with
 * the texture kept for the masthead below it.
 */
.site-nav {
    background: var(--board);
    border-bottom: 0;
}

.site-nav .nav-brand {
    color: #fff;
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.site-nav .nav-brand:hover {
    color: #fff;
}

.nav-links a {
    color: #fff;
    text-decoration: none;
    /* White at 0.9rem on #102B48 is 13:1, so it stays legible without a tint. */
    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 page */

/*
 * The masthead sits outside the container so it can bleed to the window edge,
 * and the container keeps its own gutter for everything below.
 */
.masthead-inner {
    max-width: var(--page);
    margin-inline: auto;
    padding-inline: clamp(1rem, 4vw, 2rem);
}

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

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

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

.masthead h1 {
    font-family: var(--font-display);
    font-size: clamp(2.1rem, 6vw, var(--step-6));
    font-weight: 700;
    line-height: 1.04;
    letter-spacing: -0.02em;
    max-width: 19ch;
    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-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 */

/*
 * Numbered entries on ruled baselines, the way a form is filled in, rather than
 * fields sitting in rounded boxes. The rule takes the accent on focus and the
 * outline stays, because a colour change alone is not a focus indicator.
 */
.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;
}

@media (min-width: 46rem) {
    .fields {
        grid-template-columns: 1fr 1fr;
    }
}

.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;
}

.calculator-card input[type='number'],
.calculator-card input[type='date'],
.feature-card input[type='number'],
.feature-card input[type='date'],
.feature-card textarea {
    width: 100%;
    border: 0;
    border-bottom: 2px solid var(--rule-strong) !important;
    border-radius: 0;
    background: transparent;
    padding: 0.35rem 0 0.45rem !important;
    font-family: var(--font-figure);
    font-size: 1.05rem;
    color: var(--ink);
    box-shadow: none;
}

.feature-card textarea {
    font-family: var(--font-body);
    font-size: 0.95rem;
    min-height: 2.4rem;
    resize: vertical;
}

.calculator-card input:hover,
.feature-card input:hover,
.feature-card textarea:hover {
    border-bottom-color: var(--ink-soft) !important;
}

.calculator-card input:focus-visible,
.feature-card input:focus-visible,
.feature-card textarea:focus-visible {
    border-bottom-color: var(--accent) !important;
    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);
}

.calculate-btn,
.calculate-rtw-btn,
.add-leave-btn {
    margin-top: 2rem;
    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 {
    width: 100%;
}

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

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

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

/* Secondary actions should not shout as loudly as the one that gives an answer. */
.save-calc-btn,
.clear-history-btn {
    margin-top: 1.5rem;
    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;
}

.save-calc-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

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

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

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

/*
 * Eligibility is the first thing to say and it is a yes or a no, so it is
 * stamped rather than tinted: a heavy rule, tracked caps and a word. The
 * state is never carried by colour on its own.
 */
.eligibility-check {
    background: none;
    border: 0;
    border-left: 6px solid var(--good);
    border-radius: 0;
    box-shadow: none;
    padding: 0.35rem 0 0.35rem 1rem;
    margin-bottom: 1.5rem;
    color: var(--ink);
}

.eligibility-check.not-eligible {
    border-left-color: var(--bad);
}

.eligibility-check strong {
    display: block;
    color: var(--good);
    margin-bottom: 0.3rem;
}

.eligibility-check.not-eligible strong {
    color: var(--bad);
}

/* The itemised days, set as a ruled statement with the counts in a money column. */
.result-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    background: none;
    border: 0;
    border-bottom: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: none;
    padding: 0.55rem 0;
}

.result-label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.result-value {
    font-family: var(--font-figure);
    font-size: 1rem;
    font-weight: 500;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/*
 * The figure the visitor came for. It was previously set at the size of a
 * section heading, inside the same box as everything else.
 */
.total-result {
    background-color: var(--accent);
    background-image: url('/img/record-card.webp');
    background-size: 1024px auto;
    background-blend-mode: multiply;
    color: #fff;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: clamp(1.5rem, 4vw, 2.25rem);
    margin-top: 1.75rem;
}

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

.total-amount {
    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;
}

.warning-box {
    background: none;
    border: 0;
    border-left: 4px solid var(--warn);
    border-radius: 0;
    box-shadow: none;
    padding: 0.2rem 0 0.2rem 1rem;
    color: var(--ink-soft);
}

/* ------------------------------------------------- the supporting tools */

/*
 * The tracker, the history and the return-to-work date were three more cards
 * exactly as loud as the answer. They become ruled sections under an accent
 * rule, which says "and then" rather than "and also".
 */
.feature-card {
    background: none;
    border: 0;
    border-top: 3px solid var(--accent);
    border-radius: 0;
    box-shadow: none;
    padding: 1.5rem 0 0;
    margin-top: clamp(2rem, 5vw, 3rem);
}

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

.tracker-section,
.rtw-calculator {
    margin-top: 1.25rem;
}

.sick-leave-input,
.rtw-input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr));
    gap: 1.25rem;
    align-items: end;
}

.sick-leave-input label,
.rtw-input-grid label {
    display: block;
    font-size: 0.72rem !important;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 0.4rem !important;
}

.add-leave-btn {
    margin-top: 0;
}

.leave-summary {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 2px solid var(--ink);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr));
    gap: 1.25rem;
}

.summary-item {
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
}

.summary-label {
    display: block;
    color: var(--muted);
}

.summary-value {
    display: block;
    margin-top: 0.25rem;
    font-family: var(--font-display);
    font-size: var(--step-4);
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

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

.empty-state p {
    color: var(--muted);
}

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

/*
 * Fourteen class names all resolved to one white box with a 1px border, a 10px
 * radius and a soft shadow, so an answer, an aside and a blog teaser carried
 * identical weight. Reference material gets rules and space, and the shadow
 * goes: nothing on a printed page floats.
 */
.info-section,
.content-card,
.info-card,
.faq-card,
.card,
.result-box,
.email-box,
.contact-box,
.faq-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);
}

.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;
}

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

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

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

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

.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.04;
    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: #15212D;
        --board: #0B1D31;
    }

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

    :root:not([data-theme='light']) .calculator-card {
        border-top-color: #8FB6DE;
    }

    :root:not([data-theme='light']) .feature-card {
        border-top-color: #8FB6DE;
    }
}

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

/* ------------------------------------------------------ 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-rtw-btn:focus-visible,
.add-leave-btn:focus-visible,
.save-calc-btn:focus-visible,
.clear-history-btn:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

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

/*
 * People print this to show an employer or to put with a fit note, so the
 * figures print and the chrome does not.
 */
@media print {
    .site-nav,
    .editorial-footer,
    .book-plug,
    .save-calc-btn,
    .clear-history-btn,
    .calculate-btn,
    .calculate-rtw-btn,
    .add-leave-btn {
        display: none !important;
    }

    .masthead,
    .total-result {
        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'],
select[aria-invalid='true'],
textarea[aria-invalid='true'] {
    border-color: #A8251B;
}

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

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

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

#history-label {
    display: block;
    width: 100%;
    max-width: 28rem;
    margin-bottom: 0.7rem;
    padding: 0.6rem 0.75rem;
    font: inherit;
    border: 2px solid var(--rule);
    background: transparent;
    color: inherit;
}

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