/*
 * The free tool pages' shared layout (TOOLS-PLAN 3.1, site/lib/free-tools/page-parts.php): every tool page of the
 * engine loads it after site.css, then its family's file (ft-calc.css, ft-lookup.css …). Tokens only
 * (assets/css/nf/tokens.css). The document generators keep free-tools.css.
 *
 *   1. First screen    .ft-top (a compact hero, so the tool starts within the first screen on a 390 px phone), .ft-trust,
 *                      .ft-tool (the section that holds the tool)
 *   2. Sections        .ft-section > .ft-narrow > .ft-h2 / .ft-h3; .ft-howto (the 3 steps), .ft-method, .ft-facts,
 *                      .ft-limits, .ft-sources, .ft-report, .ft-note, .ft-data (tables with a caption), .ft-soft (the
 *                      one Nexfield line), .ft-versions, .ft-privacy-line; .ft-table-wrap > .ft-table (the tables of
 *                      facts of nf_ft_table(), site/lib/free-tools/lookup-parts.php: charts, rules, codes), .ft-table-note
 *   3. Feedback        .ft-toast (+ .ft-toast__undo), html.ft-has-bar (a family's bottom bar is on screen)
 *   4. Print           the H1 and the tool only: no menu, steps, method, questions or footer
 */

/* =========================================================================
   1. First screen
   ========================================================================= */
.ft-top {
    padding-block: var(--sp-5) var(--sp-6);
    background: var(--c-surface-2);
    border-bottom: 1px solid var(--c-line);
}

.ft-top .breadcrumbs {
    margin-bottom: var(--sp-4);
}

.ft-top .hero__title {
    font-size: clamp(1.75rem, 1.25rem + 2.2vw, 2.75rem);
    line-height: 1.1;
}

.ft-top .hero__lead {
    max-width: 46rem;
}

.ft-trust {
    margin: var(--sp-3) 0 0;
}

/* the tool right under the first screen's words: on a 390 px phone it starts within the first screen */
.ft-top {
    padding-bottom: var(--sp-5);
}

.ft-tool {
    padding-block: var(--sp-4) var(--sp-8);
}

/* the sections after the tool: one rhythm, no doubled section padding between two short blocks */
.ft-section {
    padding-block: var(--sp-10);
}

@media (min-width: 960px) {
    .ft-top { padding-block: var(--sp-8); }
    .ft-tool { padding-block: var(--sp-8) var(--sp-12); }
    .ft-section { padding-block: var(--sp-12); }
}

/* two plain sections in a row ("How to use it", then "How it works") are one rhythm apart, not two paddings */
.ft-section:not(.section--muted) + .ft-section:not(.section--muted) {
    padding-top: 0;
}

/* =========================================================================
   2. Sections
   ========================================================================= */
/* a readable measure on the same left edge as the hero, the tool and the questions (not a centred column) */
.ft-narrow > * {
    max-width: 56rem;
}

.ft-h2 {
    margin: 0 0 var(--sp-4);
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    line-height: var(--lh-snug);
    color: var(--c-ink);
}

.ft-h3 {
    margin: var(--sp-6) 0 var(--sp-2);
    font-size: var(--fs-lg);
    font-weight: var(--fw-semibold);
    color: var(--c-ink);
}

/* the steps show their numbers (base.css takes list markers off every list) */
.ft-howto {
    display: grid;
    gap: var(--sp-3);
    margin: 0;
    padding-left: 1.5em;
    list-style: decimal;
    color: var(--c-text);
    line-height: var(--lh-relaxed);
}

.ft-howto li::marker {
    font-weight: var(--fw-bold);
    color: var(--c-ink);
}

.ft-method {
    display: grid;
    gap: var(--sp-2);
    padding: var(--sp-5);
    color: var(--c-ink);
    font-variant-numeric: tabular-nums;
    background: var(--c-surface-2);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
    overflow-wrap: anywhere;
}

.ft-method p {
    margin: 0;
}

.ft-facts {
    display: grid;
    margin: var(--sp-5) 0 0;
}

.ft-facts__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: var(--sp-4);
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--c-line);
}

.ft-facts__row dt {
    font-weight: var(--fw-semibold);
    color: var(--c-ink);
}

.ft-facts__row dd {
    margin: 0;
}

.ft-limits {
    margin: var(--sp-4) 0 0;
    color: var(--c-text-2);
}

.ft-sources {
    display: grid;
    gap: var(--sp-2);
    margin: 0;
    padding-left: 1.25em;
    color: var(--c-text-2);
    list-style: disc;
}

.ft-sources a,
.ft-report a,
.ft-versions a {
    color: var(--c-brand);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ft-report {
    margin: var(--sp-4) 0 0;
    font-size: var(--fs-sm);
}

/* a text link with a 44 px target */
.ft-report a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

.ft-note {
    margin: 0 0 var(--sp-4);
    font-size: var(--fs-sm);
    color: var(--c-muted);
}

.ft-data {
    width: 100%;
    max-width: 40rem;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
    background: var(--c-surface);
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
}

.ft-data th,
.ft-data td {
    padding: var(--sp-3) var(--sp-4);
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--c-line);
}

.ft-data th {
    font-weight: var(--fw-regular);
    color: var(--c-text-2);
}

.ft-data td {
    text-align: right;
    color: var(--c-ink);
    /* a worked example may print words ("Within the 200 A service") or a long list: it wraps, never the page */
    overflow-wrap: break-word;
}

.ft-data tr:last-child th,
.ft-data tr:last-child td {
    border-bottom: 0;
}

.ft-data__result th,
.ft-data__result td {
    font-weight: var(--fw-semibold);
    color: var(--c-ink);
}

/* the answer the example works to, above the other results */
.ft-data__main td {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
}

.ft-data tr:not(.ft-data__result) + .ft-data__result th,
.ft-data tr:not(.ft-data__result) + .ft-data__result td {
    border-top: 2px solid var(--c-line-strong);
}

.ft-soft {
    margin: var(--sp-6) 0 0;
    color: var(--c-text);
}

.ft-soft a {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    font-weight: var(--fw-semibold);
    color: var(--c-brand);
}

.ft-versions {
    display: grid;
    /* two columns on a 390 px phone */
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: var(--sp-1) var(--sp-4);
    margin: 0;
    padding: 0;
    list-style: none;
}

.ft-versions li {
    display: flex;
    align-items: center;
    min-height: 44px;
}

.ft-versions [aria-current] {
    font-weight: var(--fw-semibold);
    color: var(--c-ink);
}

.ft-privacy-line {
    margin: var(--sp-3) 0 0;
    font-size: var(--fs-sm);
    color: var(--c-muted);
}

/* "Delete saved data" beside the privacy line: a full target, not a line of text */
.ft-privacy-line .btn--link {
    min-height: 44px;
}

/* ---- tables of facts (nf_ft_table): a wide one scrolls in its own box, never the page */
.ft-table-wrap {
    max-width: 100%;
    margin: 0 0 var(--sp-6);
    overflow-x: auto;
    border: 1px solid var(--c-line);
    border-radius: var(--r-lg);
}

.ft-table-wrap:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.ft-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--fs-sm);
    font-variant-numeric: tabular-nums;
    background: var(--c-surface);
}

.ft-table caption {
    padding: var(--sp-3) var(--sp-4);
    font-weight: var(--fw-semibold);
    color: var(--c-ink);
    text-align: left;
    background: var(--c-surface-2);
    border-bottom: 1px solid var(--c-line);
}

.ft-table th,
.ft-table td {
    padding: var(--sp-2) var(--sp-4);
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--c-line);
}

.ft-table thead th {
    font-weight: var(--fw-semibold);
    color: var(--c-text-2);
    white-space: nowrap;
}

.ft-table tbody th {
    font-weight: var(--fw-semibold);
    color: var(--c-ink);
}

.ft-table tbody tr:last-child th,
.ft-table tbody tr:last-child td {
    border-bottom: 0;
}

.ft-table .ft-table__num {
    text-align: right;
}

.ft-table code {
    font-family: var(--font-mono);
    font-size: 0.95em;
    color: var(--c-ink);
    /* a serial or a code is read against a data plate: never split over two lines (the table scrolls in its box) */
    white-space: nowrap;
}

.ft-table .is-match th,
.ft-table .is-match td {
    background: var(--c-brand-soft);
}

.ft-table-note {
    margin: calc(-1 * var(--sp-4)) 0 var(--sp-6);
    font-size: var(--fs-sm);
    color: var(--c-muted);
}

/* =========================================================================
   3. Feedback: the status with Undo, and room for a family's bottom bar
   ========================================================================= */
.ft-toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
    z-index: var(--z-toast);
    display: none;
    align-items: center;
    gap: var(--sp-4);
    max-width: calc(100vw - 2 * var(--sp-4));
    padding: var(--sp-2) var(--sp-2) var(--sp-2) var(--sp-4);
    color: #fff;
    background: var(--c-dark);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-lg);
    transform: translateX(-50%);
}

.ft-toast.is-open {
    display: flex;
}

.ft-toast__undo {
    min-height: 44px;
    padding: 0 var(--sp-3);
    font: inherit;
    font-weight: var(--fw-semibold);
    color: #fff;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: var(--r-md);
    cursor: pointer;
}

.ft-toast__undo:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

html.ft-has-bar .ft-toast {
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

/* a focused field scrolls clear of a family's bottom bar */
html.ft-has-bar {
    scroll-padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
}

/* =========================================================================
   4. Print: the H1 and the tool with its result
   ========================================================================= */
@media print {
    .ft-body main > :not(.ft-top):not(.ft-tool),
    .ft-top .breadcrumbs,
    .ft-trust,
    .ft-privacy-line,
    .ft-toast {
        display: none !important;
    }

    .ft-top {
        padding: 0 0 8pt;
        background: none;
        border: 0;
    }

    .ft-top .hero__lead {
        font-size: 10pt;
    }
}
