/*
 * OD-134 (owner, 2026-11-26) — the rules of a race's results page that only it uses: «Encuentra tu resultado» (the box, its
 * finisher cards), the certificate links of the names (table, podiums, cards), the advanced search's counted distance tabs and
 * the «preparing your certificate» notice. Loaded only by templates/site/race_results.twig, after base.css and site.css, in
 * the `pages` layer (the results page's other rules stay in site.css: the hero, the table, the podiums, the distribution).
 */
@layer pages {
    /* ---- OD-134 «Encuentra tu resultado»: the first thing of the page — one big box (name or bib, every distance), its
       answers as finisher cards whose name downloads the certificate; then the advanced search by distance. */
    .c-rs-finder {
        position: relative;
        padding: var(--space-l);
        border: var(--border-hairline) solid var(--color-border);
        border-inline-start: 0.5rem solid var(--color-signal);
        border-radius: var(--radius-m);
        background:
            repeating-conic-gradient(var(--color-border) 0 25%, transparent 0 50%) right top / 0.75rem 0.75rem repeat-y,
            var(--color-surface-alt);
    }

    .c-results .c-rs-finder > h2.c-rs-finder__title {
        margin: 0 0 var(--space-2xs);
        padding: 0;
        font-size: var(--text-3xl);
        background: none;
    }

    .c-rs-finder__lead {
        margin: 0 0 var(--space-m);
        max-inline-size: 60ch;
        font-size: var(--text-l);
    }

    .c-rs-finder__form {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-s);
        padding-inline-end: var(--space-m);
    }

    .c-rs-finder__input.c-input {
        flex: 1 1 16rem;
        min-inline-size: 0;
        min-block-size: 3.5rem;
        font-size: var(--text-xl);
        font-weight: var(--weight-semibold);
    }

    .c-rs-finder__submit.c-button {
        min-block-size: 3.5rem;
        padding-inline: var(--space-l);
        font-size: var(--text-l);
    }

    .c-rs-finder__status {
        margin: var(--space-s) 0 0;
        font-weight: var(--weight-semibold);
    }

    .c-rs-finder__status:empty {
        display: none;
    }

    .c-rs-finder__hits {
        display: grid;
        grid-template-columns: minmax(0, 1fr); /* a long name or the button never widens a card past the panel */
        gap: var(--space-s);
        margin: var(--space-s) 0 0;
        padding: 0 var(--space-m) 0 0;
        list-style: none;
    }

    .c-rs-hit {
        padding: var(--space-s) var(--space-m);
        border: var(--border-hairline) solid var(--color-border);
        border-radius: var(--radius-m);
        background: var(--color-bg);
    }

    .c-rs-hit > p {
        margin: 0;
    }

    .c-rs-hit__name {
        font-family: var(--font-display);
        font-size: var(--text-xl);
        font-weight: var(--weight-bold);
        line-height: 1.2;
    }

    .c-rs-hit__link {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: var(--space-2xs) var(--space-m);
        min-block-size: var(--control-height);
        color: var(--color-text);
        text-decoration: none;
    }

    .c-rs-hit__who {
        overflow-wrap: anywhere;
    }

    .c-rs-hit__link:hover .c-rs-hit__who {
        text-decoration: underline;
        text-decoration-thickness: 0.12em;
        text-underline-offset: 0.18em;
    }

    .c-rs-hit__cta {
        display: inline-flex;
        align-items: center;
        gap: var(--space-2xs);
        min-block-size: 2.5rem;
        padding-inline: var(--space-m);
        border-radius: var(--radius-s);
        background: var(--color-primary);
        color: var(--color-on-primary);
        font-family: var(--font-sans);
        font-size: var(--text-s);
        font-weight: var(--weight-bold);
        letter-spacing: var(--tracking-label);
        text-transform: uppercase;
        white-space: nowrap;
    }

    .c-rs-hit__cta::before {
        content: "";
        inline-size: 0.5rem;
        block-size: 0.5rem;
        margin-block-start: -0.25rem;
        border-inline-end: 0.15rem solid currentColor;
        border-block-end: 0.15rem solid currentColor;
        transform: rotate(45deg);
    }

    .c-rs-hit__link:hover .c-rs-hit__cta {
        background: var(--color-primary-hover);
    }

    .c-rs-hit__where {
        color: var(--color-muted);
        font-weight: var(--weight-semibold);
    }

    .c-rs-hit__facts {
        display: flex;
        flex-wrap: wrap;
        gap: var(--space-2xs) var(--space-l);
        margin: var(--space-2xs) 0 0;
    }

    .c-rs-hit__fact {
        display: flex;
        gap: var(--space-2xs);
        align-items: baseline;
    }

    .c-rs-hit__fact dt {
        color: var(--color-muted);
        font-size: var(--text-s);
    }

    .c-rs-hit__fact dd {
        margin: 0;
        font-weight: var(--weight-bold);
    }

    /* The names of the table, the podiums and the search: the certificate link (a small «PDF» tag says what a tap does). */
    .c-rs-cert {
        color: inherit;
        text-decoration: underline;
        text-decoration-color: color-mix(in srgb, var(--color-signal) 70%, transparent);
        text-decoration-thickness: 0.1em;
        text-underline-offset: 0.2em;
    }

    .c-rs-cert:hover {
        color: var(--color-link-hover, var(--color-link));
        text-decoration-color: currentColor;
    }

    .c-rs-cert.c-rs-hit__link,
    .c-rs-cert.c-rs-hit__link:hover {
        color: var(--color-text);
        text-decoration: none;
    }

    .c-results-table .c-rs-cert::after,
    .c-podium__name .c-rs-cert::after {
        content: "PDF";
        content: "PDF" / "";
        display: inline-block;
        margin-inline-start: 0.4em;
        padding: 0 0.3em;
        border: 1px solid currentColor;
        border-radius: var(--radius-s);
        font-size: 0.68em;
        font-weight: var(--weight-bold);
        letter-spacing: 0.04em;
        line-height: 1.5;
        vertical-align: 0.15em;
        opacity: 0.75;
    }

    /* Its own line under the count (the count of a full table has no final period). */
    .c-results__cert-note {
        display: block;
        color: var(--color-muted);
    }

    .c-rs-advanced > p.c-rs-advanced__lead {
        margin: 0 0 var(--space-m);
    }

    .c-rs-advanced > .c-results__courses {
        margin-block-end: var(--space-m);
    }

    .c-rs .c-results__courses a {
        flex-direction: column;
        gap: 0;
        padding-block: var(--space-2xs);
        line-height: 1.15;
    }

    .c-results__course-count {
        font-family: var(--font-sans);
        font-size: var(--text-xs);
        font-weight: var(--weight-semibold);
        letter-spacing: 0;
        text-transform: none;
        opacity: 0.8;
    }

    /* The «preparing your certificate» note of site-results.js (a tap is never left without an answer). */
    .c-rs-toast {
        position: fixed;
        z-index: 60;
        inset-inline: var(--space-m);
        inset-block-end: var(--space-l);
        margin: 0 auto;
        max-inline-size: 26rem;
        padding: var(--space-s) var(--space-m);
        border-radius: var(--radius-m);
        background: #2d1d47;
        box-shadow: 0 0.75rem 2rem rgb(12 7 18 / 0.35);
        color: #f1edf8;
        font-weight: var(--weight-semibold);
        text-align: center;
        opacity: 0;
        transform: translateY(0.75rem);
        pointer-events: none;
        transition: opacity var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
    }

    .c-rs-toast.is-on {
        opacity: 1;
        transform: none;
    }

    @media (prefers-reduced-motion: reduce) {
        .c-rs-toast {
            transition: none;
            transform: none;
        }
    }

    @media (max-width: 40rem) {
        .c-rs-finder {
            padding: var(--space-m);
        }

        .c-results .c-rs-finder > h2.c-rs-finder__title {
            font-size: var(--text-2xl);
        }

        .c-rs-finder__submit.c-button {
            flex: 1 1 100%;
        }

        .c-rs-finder__hits {
            padding-inline-end: 0;
        }

        .c-rs-hit {
            padding: var(--space-s);
        }

        .c-rs-hit__cta {
            inline-size: 100%;
            justify-content: center;
            padding-inline: var(--space-s);
            letter-spacing: 0.02em;
            white-space: normal;
            text-align: center;
        }
    }
}
