/*
 * uniform-tax-rebate.co.uk
 *
 * Loaded after site.css, so it only states what changes.
 *
 * The idea: this is a claim, and the thing being claimed for is a uniform. So
 * the masthead is the cloth, drawn as the diagonal rib of cotton drill with
 * two rows of lockstitch running through it, and everything under it is set
 * as the claim form: fields boxed in a hairline grid the way a paper form
 * boxes them, and the answer printed as a claim line, the working spelled out
 * as one equation across a ruled strip rather than buried in a paragraph.
 *
 * Boxes are allowed here, where they were thrown out on the other sites,
 * because a form genuinely has boxes. The difference is that these are ruled
 * cells sharing hairlines, not white cards floating on off-white with a soft
 * shadow under each one.
 *
 * Typeface: Public Sans throughout, which is a civic gothic rather than a
 * display face. The site previously led on Fraunces, a wobbly optical serif
 * that is fashionable and wrong: nobody's tax claim should look playful.
 *
 * What it replaces: a white card holding an h1 and three dropdowns, two
 * identical result tiles, and the working set as four bolded fragments.
 */

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

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

    --font-display: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-body: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-figure: 'Roboto Mono', ui-monospace, 'SF Mono', Menlo, monospace;

    /* Workwear navy: the colour of drill overalls and of every uniform form. */
    --accent: #1B3355;
    --accent-deep: #0F2039;
    --board: #0F2039;
}

body {
    font-family: var(--font-body);
}

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

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

/*
 * The cloth. Multiplied over the navy rather than laid on top of it, so it can
 * only darken the ground: white type here is never worse than the 12.7:1 it
 * measures on the flat colour.
 */
.masthead {
    background-color: var(--accent);
    background-image: url('/img/twill.webp');
    background-size: 420px 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: 800;
    line-height: 1.02;
    letter-spacing: -0.025em;
    max-width: 17ch;
    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 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 */

/*
 * A boxed grid, sharing hairlines, the way a paper form rules its fields.
 * The trade goes full width because it is the only field that matters and it
 * carries a list of seventy occupations.
 */
.claim-form {
    border: 1px solid var(--rule-strong);
    border-top: 5px solid var(--accent);
    background: var(--card);
    border-radius: 0;
    box-shadow: none;
}

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

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

    .fields > li:first-child {
        grid-column: 1 / -1;
    }

    .fields > li:nth-child(3) {
        border-left: 1px solid var(--rule);
    }
}

.fields > li {
    padding: clamp(1rem, 3vw, 1.5rem);
}

.fields > li + li {
    border-top: 1px solid var(--rule);
}

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

.field-num {
    font-family: var(--font-figure);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
    margin-right: 0.5rem;
}

/*
 * The native select chrome is replaced with a ruled field and a drawn marker.
 * Focus takes a thicker rule and keeps the outline, because a colour change
 * alone is not a focus indicator for anyone who cannot see the colour.
 */
.claim-form select {
    width: 100%;
    border: 0;
    border-bottom: 2px solid var(--rule-strong);
    border-radius: 0;
    background-color: transparent;
    padding: 0.35rem 1.6rem 0.45rem 0;
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--ink);
    box-shadow: none;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%),
        linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
    background-position: right 0.75rem center, right 0.4rem center;
    background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
    background-repeat: no-repeat;
}

.claim-form select:hover {
    border-bottom-color: var(--ink-soft);
}

.claim-form select:focus-visible {
    border-bottom-color: var(--accent);
    outline: 3px solid var(--accent);
    outline-offset: 3px;
}

.claim-form optgroup {
    font-weight: 700;
    font-style: normal;
    color: var(--ink);
}

.help-text,
.field-hint {
    display: block;
    margin-top: 0.5rem;
    margin-bottom: 0;
    font-size: 0.82rem;
    line-height: 1.5;
    color: var(--muted);
    max-width: 58ch;
}

.claim-form button {
    display: block;
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: 0;
    border-top: 1px solid var(--rule);
    border-radius: 0;
    padding: 1.05rem 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;
}

.claim-form button:hover {
    background: var(--board);
}

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

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

.results {
    display: none;
}

.results.show {
    display: block;
    border-top: 1px solid var(--rule-strong);
}

/*
 * The claim line. The total is the largest thing on the page, the annual
 * figure sits under it as the smaller of the two, and the working runs as one
 * printed equation across a ruled strip rather than as four bolded fragments
 * in a paragraph. This is the part of the page that could not belong to any
 * other site in the group.
 */
.claim-total {
    background: var(--board);
    color: #fff;
    padding: clamp(1.5rem, 5vw, 2.5rem);
}

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

.claim-figure {
    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;
}

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

.result-explanation {
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: clamp(1.1rem, 3.5vw, 1.6rem);
    margin: 0;
    font-family: var(--font-figure);
    font-size: 0.86rem;
    line-height: 2;
    color: var(--ink-soft);
    overflow-x: auto;
}

.result-explanation strong {
    font-weight: 400;
    color: var(--muted);
}

.result-explanation > strong:first-child {
    display: block;
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.success {
    background: none;
    border: 0;
    border-top: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: none;
    padding: clamp(1.1rem, 3.5vw, 1.6rem);
    margin: 0;
    font-size: 0.94rem;
    line-height: 1.6;
    color: var(--ink-soft);
}

.success strong {
    color: var(--ink);
}

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

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

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

.info-section + .info-section {
    margin-top: clamp(2.25rem, 5vw, 3.5rem);
    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.015em;
    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;
}

.info-box {
    background: none;
    border: 0;
    border-left: 3px solid var(--rule-strong);
    border-radius: 0;
    box-shadow: none;
    padding: 0.2rem 0 0.2rem 1.25rem;
    margin: 1.25rem 0;
}

/*
 * The trade table. HMRC publishes these rates as a table and it reads best as
 * one, with the money set in tabular figures so the column lines up.
 */
table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.94rem;
}

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

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

td:last-child {
    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: 24ch;
}

.content-card {
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

.content-card h2 {
    font-family: var(--font-display);
    font-size: var(--step-3);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.015em;
    max-width: 30ch;
}

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

.content-card p,
.content-card li {
    max-width: 66ch;
}

/*
 * The blog index. A ruled contents list, which is what it is, rather than a
 * grid of shadowed tiles each demanding the same attention.
 */
.blog-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;
}

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

.blog-card h2,
.blog-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;
}

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

/*
 * Fifty-two trades, previously fifty-two white cards in a grid, which is the
 * card problem at its worst: a reference table rendered as a wall of tiles
 * nobody can scan. It is now the table HMRC publishes, name against rate,
 * with the money in tabular figures so the column reads down.
 */
.occupation-card {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1.5rem;
    background: none;
    border: 0;
    border-top: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: none;
    padding: 0.55rem 0;
    margin: 0;
    text-align: left;
}

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

.occupation-name {
    color: var(--ink-soft);
    font-size: 0.95rem;
}

.occupation-rate {
    font-family: var(--font-figure);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    white-space: nowrap;
    color: var(--ink);
    background: none;
    border: 0;
    border-radius: 0;
    padding: 0;
}

.blog-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 {
    font-family: var(--font-display);
    font-size: var(--step-0);
    font-weight: 700;
    margin: 0 0 0.3rem;
}

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

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

@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --board: #0A1626;
    }

    /* #8AA9D0 on #14161A is 7.5:1. */
    :root:not([data-theme='light']) .section-index,
    :root:not([data-theme='light']) .field-num,
    :root:not([data-theme='light']) .blog-date,
    :root:not([data-theme='light']) .read-more,
    :root:not([data-theme='light']) .info-section h2::before,
    :root:not([data-theme='light']) thead th {
        color: #8AA9D0;
    }

    :root:not([data-theme='light']) .section-index,
    :root:not([data-theme='light']) .info-section h2::before,
    :root:not([data-theme='light']) thead th {
        border-color: #8AA9D0;
    }
}

:root[data-theme='dark'] {
    --board: #0A1626;
}

:root[data-theme='dark'] .section-index,
:root[data-theme='dark'] .field-num,
:root[data-theme='dark'] .info-section h2::before {
    color: #8AA9D0;
}

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

@media print {
    .site-nav,
    .gov-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;
    }

    .claim-total {
        background: none;
        border: 2px solid #000;
    }

    .claim-figure,
    .claim-label,
    .claim-annual {
        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 */
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;
}

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

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

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

/* ------------------------------------------------------ showing the sum */

.working-line {
    margin: 0 0 0.6rem;
    line-height: 1.5;
}

.working-line:last-of-type {
    margin-bottom: 0.9rem;
}

.working-line strong {
    display: block;
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    opacity: 0.75;
}

.working-note {
    margin: 0;
    padding-top: 0.8rem;
    border-top: 1px solid var(--rule);
    font-size: 0.9rem;
    opacity: 0.85;
}
