/*
 * touch.css — press, focus and accessibility layer for the public website and the athlete app
 * (design package 2, 5 Dec 2026; the founder on the Apple design audit: "OK let's get going on this all in the most
 * efficient way possible").
 *
 * Loaded LAST in the head of every public and app layout (header, seo/layout, lg-app) through
 * App\Support\PageAssets::touchLink(), versioned by the file's mtime, so it needs no ?v lever of its own.
 * Rules are scoped with :root so they outrank a page's own `.x:hover` in an inline <style> further down.
 *
 * 1. Pressed state on pointer-down (Apple: feedback on press, ~scale(.97), 100 ms ease-out, transform/opacity/background
 *    only). Built from an explicit list plus one opt-in class, `.sp-press` (`.sp-press--card` for a large card).
 * 2. One focus ring (`:focus-visible`), and a replacement wherever a rule removed the outline and left nothing.
 * 3. prefers-reduced-motion / prefers-reduced-transparency / prefers-contrast.
 * 4. The filled-button colour: white text on #00A99D is 2.9:1; the founder chose "Deeper teal, white text" (5 Dec 2026).
 *    --sp-btn-fill is the one variable for it (5.1:1 on white); the bright teal (--theme-clr) stays for accents and links.
 * 5. An invisible 44 px hit area on the small close and icon buttons, without changing how they look.
 */

:root {
    --sp-btn-fill: #007C74;
    --sp-btn-fill-hover: #00655F;
    --sp-ring: #007C74;
    --sp-ring-width: 2px;
    --sp-ring-offset: 2px;
    --sp-press-scale: .97;
    --sp-press-scale-card: .985;
    --sp-press-ease: 100ms ease-out;
}

/* ---- 1. Pressed state --------------------------------------------------------------------------------------- */

/* Buttons, pills and tabs: they shrink a little under the finger. */
:root :is(
    .sp-press,
    .sp-back, .sp-apphdr__action,
    .sh__signin, .sh__add, .sh__search, .sh__place, .sh__me, .sh__logout,
    .primary-btn, .btn-theme-bg, .form-btn, .login-btn, .filters-sheet-apply,
    .gl-btn, .gl-door, .gl-close,
    .spw-register, .spw-slim__go, .spw-bar__cta, .spe-bar__cta, .swh-search__go,
    .sps__btn, .sps__door, .sps__close,
    .spx-btn, .spx-types__tab, .spx-chip__x, .sp-more__btn,
    .rp-btn, .hf-btn, .hf-lgb__x,
    .atp-cbtn, .atp-fbtn, .atp-own-btn, .atp-fp__clap, .atp-pop__close, .atp-fpm__x, .atp-fpr__x,
    .fps__btn, .mg-btn, .gw-gate__btn, .gw-bar__btn,
    .sp-sheet__close, .spl__close, .sp-memenu__x, .ask-send
) {
    -webkit-tap-highlight-color: transparent;
    transition-property: transform, opacity, background-color, border-color, color, box-shadow;
    transition-duration: 100ms;
    transition-timing-function: ease-out;
}
:root :is(
    .sp-press,
    .sp-back, .sp-apphdr__action,
    .sh__signin, .sh__add, .sh__search, .sh__place, .sh__me, .sh__logout,
    .primary-btn, .btn-theme-bg, .form-btn, .login-btn, .filters-sheet-apply,
    .gl-btn, .gl-door, .gl-close,
    .spw-register, .spw-slim__go, .spw-bar__cta, .spe-bar__cta, .swh-search__go,
    .sps__btn, .sps__door, .sps__close,
    .spx-btn, .spx-types__tab, .spx-chip__x, .sp-more__btn,
    .rp-btn, .hf-btn, .hf-lgb__x,
    .atp-cbtn, .atp-fbtn, .atp-own-btn, .atp-fp__clap, .atp-pop__close, .atp-fpm__x, .atp-fpr__x,
    .fps__btn, .mg-btn, .gw-gate__btn, .gw-bar__btn,
    .sp-sheet__close, .spl__close, .sp-memenu__x, .ask-send
):active:not(:disabled, [aria-disabled="true"], .is-own) {
    transform: scale(var(--sp-press-scale));
    opacity: .88;
}
/* The tab bar's tabs are tall and narrow: the tab dims, its icon and label shrink. */
:root .sp-tabbar__tab { -webkit-tap-highlight-color: transparent; transition: opacity 100ms ease-out; }
:root .sp-tabbar__tab > * { transition: transform 100ms ease-out; }
:root .sp-tabbar__tab:active { opacity: .6; }
:root .sp-tabbar__tab:active > * { transform: scale(.92); }

/* Large cards that are one link: they give way less. */
:root :is(.sp-press--card, .spx-card__link),
.register_section .register_sports .box-select-card input + label {
    -webkit-tap-highlight-color: transparent;
    transition-property: transform, opacity, background-color, box-shadow;
    transition-duration: 100ms;
    transition-timing-function: ease-out;
}
:root :is(.sp-press--card, .spx-card__link):active,
.register_section .register_sports .box-select-card input + label:active {
    transform: scale(var(--sp-press-scale-card));
}
/* The Explore card's own press read #FAFBFB on white — invisible. */
:root .spx-card__link:active { background: #EEF2F2; }

/* List rows: a row does not shrink (it would pull away from its neighbours); it darkens, as an iOS table cell does. */
:root :is(.sp-press--row, .atp-res, .atp-pb, .mg-row, .spp__row, .spx-row, .spx-agenda__link, .spx-askrow__link,
          .sp-memenu__row, .sp-more__list > a, .sp-more__list > button) {
    -webkit-tap-highlight-color: transparent;
}
:root :is(.sp-press--row, .atp-res, .atp-pb, .mg-row, .spp__row, .spx-row, .spx-agenda__link, .spx-askrow__link,
          .sp-memenu__row, .sp-more__list > a, .sp-more__list > button):active {
    background-color: #EEF2F2;
    transition: background-color 100ms ease-out;
}
/* A row that holds its own buttons (a result's claps, a message's actions) stays still while one of them is pressed. */
:root :is(.atp-res, .atp-pb, .mg-row, .spp__row):active:has(:is(button, a, [role="button"]):active) {
    background-color: transparent;
}

/* ---- 2. One focus ring ---------------------------------------------------------------------------------------- */

:root :is(
    .sp-press, .sp-press--card, .sp-press--row,
    .sp-back, .sp-apphdr__action,
    .sh__signin, .sh__add, .sh__search, .sh__place, .sh__me, .sh__logout,
    .sh__navlink, .sh__link,
    .primary-btn, .btn-theme-bg, .form-btn, .login-btn, .filters-sheet-apply,
    .gl-btn, .gl-door, .gl-close,
    .spw-register, .spw-slim__go, .spw-bar__cta, .spe-bar__cta, .swh-search__go,
    .sps__btn, .sps__door, .sps__close,
    .spx-btn, .spx-types__tab, .spx-chip__x, .sp-more__btn, .spx-card__link,
    .spx-row, .spx-agenda__link, .spx-askrow__link, .sp-memenu__row,
    .rp-btn, .hf-btn, .hf-lgb__x,
    .atp-cbtn, .atp-fbtn, .atp-own-btn, .atp-fp__clap, .atp-pop__close, .atp-fpm__x, .atp-fpr__x,
    .atp-res, .atp-pb, .mg-row, .spp__row,
    .fps__btn, .mg-btn, .gw-gate__btn, .gw-bar__btn,
    .sp-sheet__close, .spl__close, .sp-memenu__x, .ask-send, .scroll_btn
):focus-visible {
    outline: var(--sp-ring-width) solid var(--sp-ring) !important;
    outline-offset: var(--sp-ring-offset);
    box-shadow: 0 0 0 calc(var(--sp-ring-width) + var(--sp-ring-offset)) rgba(255, 255, 255, .9);
}
/* (outline is !important because magnific.css, imported on every page, sets a { outline: 0 !important }.)
   Rows sit edge to edge: their ring goes inside. */
:root :is(.sp-press--row, .atp-res, .mg-row, .spp__row, .spx-row, .spx-agenda__link, .sp-memenu__row):focus-visible {
    outline-offset: calc(var(--sp-ring-width) * -1);
    box-shadow: none;
}

/* Where a stylesheet took the outline away and left nothing in its place (verified 5 Dec 2026):
   - style.css  [class^="search_for"] fields, .search_blk input, .offering_by_location select: the pill around them rings.
   - style.css  .scroll_btn: ringed above.
   - site-web.css .spp__field input (the search palette's field): its row underlines in the deep teal.
   - athlete-page.css .atp-res:focus-visible (a #FAFBFB tint only): ringed above.
   - free-posts.css .atp-fpm__fin (the link field) underlines; .atp-fpm__emoq (the emoji search) rings.
   - app-explore.css .spx-search input: already shows its border in teal on :focus-within, so it is left. */
:root :is([class^="search_for"], .search_blk, .offering_by_location):focus-within {
    outline: var(--sp-ring-width) solid var(--sp-ring) !important;
    outline-offset: var(--sp-ring-offset);
}
:root .spp__field:focus-within { box-shadow: inset 0 -2px 0 var(--sp-ring); }
:root .atp-fpm__fin:focus { border-bottom-color: var(--sp-ring); box-shadow: 0 1px 0 var(--sp-ring); }
:root .atp-fpm__emoq:focus-within { outline: var(--sp-ring-width) solid var(--sp-ring) !important; outline-offset: 2px; border-radius: 10px; }

/* ---- 5. 44 px hit areas for small close and icon buttons (nothing visible changes) ------------------------------ */

/* :where() weighs nothing: a button its own stylesheet places absolutely (.atp-pop__close, .hf-lgb__x) stays where it is;
   one with no position of its own becomes the box its hit area is measured from. (.sp-memenu__x is already 44 px.) */
:where(.sp-sheet__close, .spl__close, .sps__close, .gl-close, .spx-chip__x, .hf-lgb__x,
       .atp-pop__close, .atp-fpm__x, .atp-fpr__x) {
    position: relative;
}
:root :is(.sp-sheet__close, .spl__close, .sps__close, .gl-close, .spx-chip__x, .hf-lgb__x,
          .atp-pop__close, .atp-fpm__x, .atp-fpr__x)::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: max(100%, 44px);
    height: max(100%, 44px);
    transform: translate(-50%, -50%);
}

/* ---- 3. Accessibility preferences ----------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    /* No press scale; the dim and the background shift stay, they are feedback without motion. */
    :root :is(
        .sp-press, .sp-press--card,
        .sp-tabbar__tab, .sp-back, .sp-apphdr__action,
        .sh__signin, .sh__add, .sh__search, .sh__place, .sh__me, .sh__logout,
        .primary-btn, .btn-theme-bg, .form-btn, .login-btn, .filters-sheet-apply,
        .gl-btn, .gl-door, .gl-close,
        .spw-register, .spw-slim__go, .spw-bar__cta, .spe-bar__cta, .swh-search__go,
        .sps__btn, .sps__door, .sps__close,
        .spx-btn, .spx-types__tab, .spx-chip__x, .sp-more__btn, .spx-card__link,
        .rp-btn, .hf-btn, .hf-lgb__x,
        .atp-cbtn, .atp-fbtn, .atp-own-btn, .atp-fp__clap, .atp-pop__close, .atp-fpm__x, .atp-fpr__x,
        .fps__btn, .mg-btn, .gw-gate__btn, .gw-bar__btn,
        .sp-sheet__close, .spl__close, .sp-memenu__x, .ask-send, .atp-share-big
    ):is(:active, :hover) {
        transform: none;
    }
    .register_section .register_sports .box-select-card input + label:is(:active, :hover) { transform: none; }
    :root .sp-tabbar__tab:active > * { transform: none; }

    /* Sheets, menus and drawers fade instead of sliding: the panel takes its place at once, invisible, and fades in;
       on the way out it fades first and then leaves. Each open state is the one its own stylesheet uses. */
    .spx-sheet__panel,
    html.is-app .sp-sheet__panel,
    .spw-slim {
        opacity: 0;
        transition: opacity 200ms ease, visibility 0s linear 200ms, transform 0s linear 200ms !important;
    }
    .spx-sheet.is-open .spx-sheet__panel,
    html.is-app .sp-sheet.is-open .sp-sheet__panel,
    .spw-slim.is-on {
        opacity: 1;
        transition: opacity 200ms ease, visibility 0s, transform 0s !important;
    }
    .filters-panel {
        opacity: 0;
        transition: opacity 200ms ease, transform 0s linear 200ms !important;
    }
    .filters-panel.filters-panel--open {
        opacity: 1;
        transition: opacity 200ms ease, transform 0s !important;
    }
    .ask-side { opacity: 0; transition: opacity 200ms ease, transform 0s linear 200ms !important; }
    .ask-side.is-open { opacity: 1; transition: opacity 200ms ease, transform 0s !important; }
    /* The app's tab bar steps aside for the keyboard with a fade, not a slide. */
    html.is-app .sp-tabbar { transition: opacity 150ms ease, transform 0s !important; }
    html.is-app.is-keyboard .sp-tabbar { opacity: 0; transition: opacity 150ms ease, transform 0s linear 150ms !important; }
    /* Hover lifts and nudges elsewhere on the site. */
    .register_section .register_sports .box-select-card input + label { transition: box-shadow .12s; }
    html { scroll-behavior: auto; }
}

@media (prefers-reduced-transparency: reduce) {
    /* Every blurred surface becomes solid: caught by the property itself, since style.css and app-explore.css blur a
       handful of surfaces each by their own selectors. */
    :root * { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
    .spw-slim { background: #fff; }
}

@media (prefers-contrast: more) {
    :root {
        --sp-ring: #004D48;
        --sp-ring-width: 3px;
        --sp-btn-fill: #006A63;
        --sp-btn-fill-hover: #004D48;
    }
    /* Outlined controls and cards get a border that holds against white. */
    :root :is(.hf-btn, .atp-cbtn, .atp-fbtn--on, .sps__door, .gl-btn--line, .mg-btn--ghost, .spx-btn--ghost,
              .spx-card, .hf-card, .spx-search, .sh__search, .sh__place, .spx-types__tab) {
        border-color: #3E4848 !important;
    }
    html.is-app .sp-tabbar { border-top-color: #3E4848; }
}
