/*
 * how-long-until-payday.co.uk
 *
 * Loaded after site.css, so it only states what changes.
 *
 * The idea: the thing being waited for is a wage slip, so the page is set as
 * one. The masthead is continuous stationery, the paper wage slips were
 * printed on, with its sprocket holes and tear perforations and alternating
 * stippled bands. The countdown is the figure printed on it, and the budget
 * helper below reads as the deductions block underneath.
 *
 * Register matters more here than anywhere else in the group. People arrive
 * on this page because they are skint and counting, and the old copy met them
 * with "watch the countdown magic happen" and "that glorious moment". That
 * voice is not warm, it is chirpy at somebody having a hard week. The new
 * copy is plain and it does not congratulate anybody.
 *
 * What it replaces: a stack of white rounded cards, four identical countdown
 * tiles, three identical stat tiles, and six section headings that were
 * genuinely invisible, carrying a transparent text fill left behind when a
 * gradient was stripped out from under them.
 */

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

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

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

    /* Manila: the brown of a wage packet, and warm without being cheerful. */
    --accent: #7A3A17;
    --accent-deep: #5E2B0F;
    --board: #5E2B0F;
}

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

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

/*
 * Multiplied over the manila rather than laid on top of it, so the stationery
 * can only darken the ground: white type here is never worse than the 8.6:1
 * it measures on the flat colour.
 */
.masthead {
    background-color: var(--accent);
    background-image: url('/img/stationery.webp');
    background-size: 560px 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.8;
    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: 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.92;
}

/* ------------------------------------------------------------- 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 slip */

/*
 * Every block on this page was a white rounded card with a soft shadow, so an
 * FAQ and the answer carried the same weight. They are now ruled sheets: a
 * hairline, a top rule in the accent, no radius and no shadow.
 */
.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);
    margin: 0 0 clamp(1.5rem, 4vw, 2.25rem);
}

.card-title {
    font-family: var(--font-display);
    font-size: var(--step-3);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.015em;
    margin: 0 0 0.8rem;
    max-width: 30ch;
    color: var(--ink);
}

.form-group {
    margin: 0 0 1.5rem;
}

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

.optional-badge {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--muted);
    background: none;
    border: 0;
    border-radius: 0;
    padding: 0;
    margin-left: 0.4rem;
}

/*
 * Ruled fields, not 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.
 */
.card input[type='date'],
.card input[type='time'],
.card input[type='number'],
.card select {
    width: 100%;
    border: 0;
    border-bottom: 2px solid var(--rule-strong);
    border-radius: 0;
    background-color: transparent;
    padding: 0.35rem 0 0.45rem;
    font-family: var(--font-figure);
    font-size: 1.05rem;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    box-shadow: none;
    transition: none;
}

.card select {
    appearance: none;
    padding-right: 1.6rem;
    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;
}

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

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

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

.cta-button {
    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-top: 0.5rem;
}

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

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

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

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

#results {
    display: none;
    margin-top: 2rem;
}

#results.show {
    display: block;
}

/*
 * Four identical tiles became one printed line, weighted the way the news
 * actually is: the days are what anybody wants, and hours, minutes and
 * seconds are detail. Setting all four at the same size made the seconds look
 * as important as the fortnight.
 */
.countdown-display {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 clamp(1rem, 4vw, 2.5rem);
    background: var(--board);
    color: #fff;
    padding: clamp(1.5rem, 5vw, 2.5rem);
}

.countdown-unit {
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.countdown-number {
    font-family: var(--font-figure);
    font-size: clamp(1.8rem, 6vw, 2.6rem);
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    color: #fff;
}

.countdown-label {
    margin-top: 0.45rem;
    color: #fff;
    opacity: 0.7;
}

/* The days are the answer, so they are set at four times the rest. */
.countdown-unit:first-child {
    flex: 1 0 100%;
    margin-bottom: 1.25rem;
}

.countdown-unit:first-child .countdown-number {
    font-size: clamp(3.4rem, 17vw, var(--step-7));
    font-weight: 700;
}

.countdown-unit:first-child .countdown-label {
    opacity: 0.8;
}

.countdown-message {
    border: 1px solid var(--rule-strong);
    border-top: 0;
    background: var(--card);
    padding: clamp(1.1rem, 3.5vw, 1.5rem);
    margin: 0;
    font-size: 0.98rem;
    line-height: 1.6;
    color: var(--ink-soft);
}

.copy-button {
    display: inline-block;
    margin-top: 1.25rem;
    background: transparent;
    border: 1px solid var(--rule-strong);
    border-radius: 0;
    padding: 0.55rem 1rem;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink);
    cursor: pointer;
    box-shadow: none;
}

.copy-button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

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

/*
 * The figures under the countdown: daily budget, days remaining, cycle stats.
 * A ruled row of numbers rather than a set of bordered panels, with the money
 * in tabular figures so the columns line up.
 */
.slip-figures {
    display: grid;
    gap: 0;
    border-top: 1px solid var(--rule-strong);
    margin-top: 1.5rem;
}

@media (min-width: 40rem) {
    .slip-figures {
        grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
        border: 1px solid var(--rule-strong);
    }
}

.slip-figure {
    padding: clamp(0.9rem, 3vw, 1.25rem) 0;
    border-bottom: 1px solid var(--rule);
}

@media (min-width: 40rem) {
    .slip-figure {
        padding: clamp(0.9rem, 3vw, 1.25rem);
        border-bottom: 0;
    }

    .slip-figure + .slip-figure {
        border-left: 1px solid var(--rule);
    }
}

.slip-label {
    display: block;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.slip-value {
    display: block;
    font-family: var(--font-figure);
    font-size: clamp(1.6rem, 6vw, 2.2rem);
    font-weight: 600;
    line-height: 1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

.slip-note {
    margin: 1.25rem 0 0;
    padding-top: 1.1rem;
    border-top: 1px solid var(--rule);
    font-size: 0.94rem;
    line-height: 1.6;
    color: var(--ink-soft);
}

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

.faq-section .faq-item,
.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-question {
    font-family: var(--font-display);
    font-size: var(--step-0);
    font-weight: 700;
    margin: 0 0 0.3rem;
    color: var(--ink);
    background: none;
    border: 0;
    padding: 0;
}

.faq-answer {
    color: var(--ink-soft);
    max-width: 66ch;
    background: none;
    border: 0;
    padding: 0;
}

.info-section,
.content-section,
.guide-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,
    .content-section,
    .guide-section {
        padding-left: 11rem;
    }
}

.info-section + .info-section,
.content-section + .content-section,
.guide-section + .guide-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,
.content-section h2,
.guide-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;
    color: var(--ink);
}

.info-section h2::before,
.content-section h2::before,
.guide-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: 600;
    letter-spacing: 0.12em;
    color: var(--accent);
}

@media (min-width: 60rem) {
    .info-section h2::before,
    .content-section h2::before,
    .guide-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,
.content-section h3,
.guide-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,
.content-section p,
.content-section li,
.guide-section p,
.guide-section li {
    max-width: 66ch;
}

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

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

.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: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    background: none;
    border: 0;
    border-radius: 0;
    padding: 0;
}

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

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

    :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']) .content-section h2::before {
        color: #E8A06A;
    }

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

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

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

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

@media print {
    .site-nav,
    .util-footer,
    .copy-button,
    .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;
    }

    .countdown-display {
        background: none;
        border: 2px solid #000;
    }

    .countdown-number,
    .countdown-label {
        color: #000;
        opacity: 1;
    }
}

/*
 * Asides on the guide pages. An indented note against a rule rather than
 * another panel competing with the prose it sits inside.
 */
.tip-card {
    background: none;
    border: 0;
    border-left: 3px solid var(--accent);
    border-radius: 0;
    box-shadow: none;
    padding: 0.2rem 0 0.2rem 1.25rem;
    margin: 1.25rem 0;
    color: var(--ink-soft);
}

.tip-card p:last-child {
    margin-bottom: 0;
}

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

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

/* ------------------------------------------------------------ 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 */
.form-group input::placeholder,
.form-group 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;
}

/*
 * Two 150px squares pinned to the viewport in site.css, left over from the old
 * design. Being fixed rather than in flow, they now sit over the masthead and
 * float in the margin beside the form, reading as a rendering fault.
 */
.container::before,
.container::after {
    content: none;
}

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

.cycle-track {
    height: 0.5rem;
    margin-top: 1rem;
    background: var(--rule);
    overflow: hidden;
}

.cycle-bar {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent);
}

.slip-note[hidden] {
    display: none;
}
