/*
 * my-stamp-duty.co.uk
 *
 * Loaded after site.css, so it only has to state what changes.
 *
 * The idea: stamp duty is the one tax most people meet as a physical mark on a
 * document. It is charged in bands, and the banding is the whole story: almost
 * nobody who asks "what will the stamp duty be" understands that they are not
 * charged one rate on the whole price. So the page is set as the duty stamp and
 * the tax table behind it. An impressed revenue rosette across the masthead,
 * the consideration written in as you would write it on a deed, and the answer
 * broken back out into the slices it was actually charged on, ruled like a
 * table in a statute rather than listed like receipt lines.
 *
 * What it replaces: an h1 that read "What This Site Does", sat below the
 * calculator inside a grey information box, and a breakdown of the bands set in
 * the same weight and size as the surrounding body copy, so the one piece of
 * information the site exists to give was indistinguishable from the furniture.
 */

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

:root {
    /*
     * The house scale is a 1.2 ratio topping out at 2.488rem, so an h1 and an
     * h2 are nearly the same size and hierarchy ends up being a weight change.
     * The top is extended rather than the ratio altered, so prose keeps its
     * voice and only the things that should be large become large.
     */
    --step-6: 3.2rem;
    --step-7: 4.6rem;

    /* The colour the stamp is impressed in, for rules and the band table. */
    --board: #55261B;

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

/*
 * Small caps with tracking for anything naming a field, a section or a column,
 * as against anything read as prose. One mannerism, doing the work the old
 * design gave to bold 14px sans.
 */
.section-mark,
.masthead-kicker,
.field-name,
.stamp-duty-amount .label,
.buyer-type legend {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    font-feature-settings: 'tnum';
}

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

/*
 * Full bleed: an impressed stamp runs off the edge of the paper it is struck
 * on. The rosette field is multiplied over the accent rather than sitting on
 * top of it, and multiply can only darken, so white type on this band is never
 * worse than white on the flat accent whatever the image turns out to be.
 */
.masthead {
    background-color: var(--accent);
    background-image: url('/img/revenue-stamp.webp');
    background-size: cover;
    background-position: center;
    background-blend-mode: multiply;
    color: #fff;
    /* An impressed stamp is a deep, heavy block, not a strip. */
    padding-block: clamp(3rem, 8vw, 5.5rem) clamp(2.25rem, 5vw, 3.5rem);
    border-bottom: 4px solid var(--board);
}

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

.masthead-kicker {
    display: block;
    color: #fff;
    /* 0.75 put this at 4.12:1 on the accent, under AA for text this size. */
    opacity: 0.85;
    margin-bottom: 1.25rem;
}

.masthead h1 {
    font-family: var(--font-display);
    font-size: clamp(2.1rem, 5.5vw, var(--step-6));
    font-weight: 700;
    line-height: 1.03;
    letter-spacing: -0.02em;
    max-width: 17ch;
    color: #fff;
    margin: 0;
}

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

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

.sheet {
    max-width: var(--page);
    margin-inline: auto;
    padding-inline: clamp(1rem, 4vw, 2rem);
    padding-block: clamp(2rem, 5vw, 3.5rem) 4rem;
}

/*
 * An editorial grid rather than one centred column: the margin carries the
 * section mark the way a schedule numbers its parts, and prose runs in a real
 * measure beside it. Below 60rem it collapses and the mark sits above its
 * section, which is where it reads on a phone anyway.
 */
.sheet-grid {
    display: grid;
    gap: clamp(1rem, 3vw, 2.5rem);
}

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

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

.section-mark {
    color: var(--accent);
    padding-top: 0.5rem;
    margin: 0;
}

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

/* ------------------------------------------------------ the consideration */

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

/*
 * There is only one figure to give, so it is given the room one figure
 * deserves: written across the sheet on a ruled line, the way the
 * consideration is written onto a transfer, rather than typed into a box the
 * same size as everything else.
 */
.consideration .field-name {
    display: block;
    color: var(--ink-soft);
    margin-bottom: 0.5rem;
}

.consideration input[type='number'] {
    width: 100%;
    border: 0;
    border-bottom: 2px solid var(--ink);
    border-radius: 0;
    background: transparent;
    padding: 0.2rem 0 0.35rem;
    font-family: var(--font-display);
    font-size: clamp(1.9rem, 6vw, 2.9rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    box-shadow: none;
    transition: none;
}

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

.consideration input::placeholder {
    /* --muted is 4.75:1 on white: a readable hint rather than a ghost. */
    color: var(--muted);
    font-weight: 400;
    letter-spacing: 0;
}

.consideration .field-hint {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--muted);
}

/*
 * Two ruled options rather than two pills. Which one applies changes the
 * answer by up to eleven thousand pounds, so it is given the weight of a
 * declaration on a form and not of a toggle.
 */
.buyer-type {
    margin-top: 2rem;
    display: grid;
    gap: 0;
    border: 0;
    padding: 0;
}

.buyer-type legend {
    color: var(--muted);
    padding: 0;
    margin-bottom: 0.75rem;
}

.buyer-option {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.85rem 0;
    border-top: 1px solid var(--rule);
    background: none;
    border-radius: 0;
    margin: 0;
}

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

.buyer-option input[type='radio'] {
    accent-color: var(--accent);
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
    flex: none;
}

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

.buyer-option label {
    font-weight: 600;
    cursor: pointer;
    margin: 0;
}

.buyer-option .option-note {
    display: block;
    font-weight: 400;
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.15rem;
}

.calculate-btn {
    margin-top: 2rem;
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    border-radius: 0;
    padding: 1rem 1.75rem;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    box-shadow: none;
    transform: none;
}

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

.calculate-btn:hover {
    background: var(--accent-deep);
    border-color: var(--accent-deep);
    transform: none;
    box-shadow: none;
}

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

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

.results {
    display: none;
    margin-top: 2.5rem;
    border: 1px solid var(--rule-strong);
    border-left: 6px solid var(--accent);
    border-radius: 0;
    background: var(--card);
    box-shadow: none;
    padding: 0;
}

.results.show {
    display: block;
}

.stamp-duty-amount {
    padding: clamp(1.5rem, 4vw, 2.25rem);
    background: none;
    border: 0;
    border-radius: 0;
    text-align: left;
}

.stamp-duty-amount .label {
    display: block;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

/*
 * The figure people came for. It was 2rem and centred, which put it within a
 * whisker of the section headings around it.
 */
.stamp-duty-amount .amount {
    display: block;
    font-family: var(--font-display);
    font-size: clamp(2.6rem, 10vw, var(--step-7));
    font-weight: 700;
    line-height: 0.98;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

.result-item {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem clamp(1.5rem, 4vw, 2.25rem);
    border-top: 1px solid var(--rule);
    background: none;
    border-radius: 0;
    font-size: 0.95rem;
}

.result-label {
    color: var(--muted);
}

.result-value {
    font-family: var(--font-figure);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/*
 * The bands, which are the actual answer to "why that much". Set as a tax
 * table: each slice on its own ruled row, the duty on that slice right
 * aligned in tabular figures, and a heavier rule under the last one so the
 * column visibly adds up to the figure printed above it.
 */
.breakdown {
    padding: clamp(1.25rem, 4vw, 2.25rem);
    border-top: 2px solid var(--ink);
    background: none;
    border-radius: 0;
}

.breakdown h3 {
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 0.75rem;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--rule);
    background: none;
    border-radius: 0;
    font-size: 0.95rem;
}

.breakdown-item span:first-child {
    color: var(--ink-soft);
}

.breakdown-item span:last-child {
    font-family: var(--font-figure);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.breakdown-item:last-child {
    border-bottom: 2px solid var(--ink);
    font-weight: 700;
}

.breakdown-item:last-child span:first-child {
    color: var(--ink);
}

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

/*
 * Everything below the tool is reference material, so it is set as reference
 * material: one measure, real rules between sections, and no boxes. The old
 * page put the introduction, the explanation and the rate tables each into
 * their own grey panel, which made three things of identical weight out of an
 * introduction, a definition and the rates themselves.
 */
.info-section {
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

.sheet 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.75rem;
    max-width: 32ch;
}

.sheet h3 {
    font-family: var(--font-display);
    font-size: var(--step-1);
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 0.35rem;
}

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

/*
 * The published rates, set as the statute table they are: figures right
 * aligned in tabular numerals, a rule under the head, and nothing else.
 */
.rate-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 0;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    max-width: 34rem;
}

.rate-table th {
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: left;
    padding: 0 0 0.6rem;
    border-bottom: 2px solid var(--ink);
    background: none;
}

.rate-table th:last-child,
.rate-table td:last-child {
    text-align: right;
}

.rate-table td {
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--rule);
    background: none;
    font-family: var(--font-figure);
    font-variant-numeric: tabular-nums;
    font-size: 0.95rem;
}

.rate-table tr:last-child td {
    border-bottom: 2px solid var(--ink);
}

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

/*
 * The accent is a dark oxblood: right against white, too close to a dark
 * ground. On dark it lifts for anything that has to be read as text or rule.
 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --board: #A05540;
    }

    :root:not([data-theme='light']) .section-mark,
    :root:not([data-theme='light']) .stamp-duty-amount .amount {
        color: #E0A18C;
    }

    :root:not([data-theme='light']) .masthead {
        border-bottom-color: #A05540;
    }

    :root:not([data-theme='light']) .results {
        border-left-color: #E0A18C;
    }
}

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

:root[data-theme='dark'] .section-mark,
:root[data-theme='dark'] .stamp-duty-amount .amount {
    color: #E0A18C;
}

:root[data-theme='dark'] .results {
    border-left-color: #E0A18C;
}

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

/*
 * People print this to put with the mortgage paperwork or to send to a
 * conveyancer, so the figure and the bands print and the furniture does not.
 */
@media print {
    .site-nav,
    .calculate-btn,
    .gov-footer,
    .book-plug {
        display: none !important;
    }

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

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

    .results {
        display: block;
    }

    .stamp-duty-amount .amount {
        color: #000;
    }
}

/* ------------------------------------------------- the rest of the pages */

/*
 * A homepage with a voice and interior pages without one is the usual way this
 * kind of site gives itself away, so every page gets the same band. It is set
 * shorter here and carries no standfirst, because on a guide or an article the
 * first paragraph is the standfirst and printing two would be repeating
 * yourself.
 */
.masthead-slim {
    padding-block: clamp(1.75rem, 4.5vw, 2.75rem) clamp(1.5rem, 3.5vw, 2.25rem);
}

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

/*
 * Long-form pages are one column of prose, so they get a measure and rules
 * rather than the two column grid, which has nothing to put in its margin.
 */
.sheet > .info-section + .info-section,
.sheet > .content-card + .content-card {
    margin-top: clamp(2rem, 5vw, 3.5rem);
    padding-top: clamp(2rem, 5vw, 3.5rem);
    border-top: 1px solid var(--rule);
}

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

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

/*
 * site.css removes the focus outline from every input, select and textarea and
 * replaces it with a 3px ring in --accent-tint, which is a near-white wash:
 * against the white card it measures about 1.05:1, so it is not an indicator.
 * On .btn-primary, .btn-secondary and .btn-tertiary it removes the outline and
 * puts nothing back at all, which leaves a keyboard user with no way of telling
 * where they are. That is a WCAG 2.2 AA failure on 2.4.7, not a refinement.
 *
 * This restores a real indicator on everything that takes focus. It is set on
 * :focus-visible rather than :focus so a mouse click does not draw it, which is
 * the behaviour the original rules were presumably reaching for.
 */
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;
    box-shadow: none;
}

/*
 * On the masthead the ground is the accent itself, so an accent outline would
 * be invisible. White is the only thing guaranteed to read there, and the band
 * is never lighter than the flat accent because the texture is multiplied.
 */
.masthead a:focus-visible,
.masthead button:focus-visible {
    outline-color: #fff;
}

/*
 * 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 */
.consideration input::placeholder,
.consideration textarea::placeholder,
.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 and status */

/*
 * The estate used alert() for every validation failure. A modal is unreadable
 * on a phone, says nothing about which field is wrong, and blocks the page for
 * someone working at speed, so the message now sits under the field it belongs
 * to. The red is checked against this site's own paper rather than reused from
 * another site.
 */

:root {
    --form-error: #A3231B;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --form-error: #FFB4AB;
    }
}

:root[data-theme='dark'] {
    --form-error: #FFB4AB;
}

.form-error {
    margin: 0.4rem 0 0;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--form-error);
}

.form-error[hidden] {
    display: none;
}

[aria-invalid='true'] {
    border-color: var(--form-error);
}

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

.breakdown-note {
    margin: 0.75rem 0 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--ink-soft);
}
