/* Syncrize shared tool "app mode" (mobile).
 *
 * Loaded by each stepper tool AFTER its own inline <style>, so these rules
 * win. Keyed on the class vocabulary every tool shares (content-grid /
 * step-panel / step-actions / option-card / result-card / table-wrap), so a
 * tool built on that skeleton inherits the same native-app feel on a phone:
 * touch-sized sliders, full-bleed screens, a pinned bottom action bar,
 * unmistakable selectable cards, and no sideways scroll.
 *
 * The bat finder is the reference implementation and carries its own copy
 * inline; every other stepper tool pulls this file.
 */

/* ---- Touch-first range slider. Native thumbs are tiny and hard to grab on
   a phone; give a tall track and a finger-sized thumb, cross-browser. ---- */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 44px;
    margin: 4px 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    touch-action: pan-y;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, #cfe0ef, #a9c7e2);
}

input[type="range"]::-moz-range-track {
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, #cfe0ef, #a9c7e2);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 32px;
    height: 32px;
    margin-top: -11px;
    border-radius: 50%;
    background: #2f71aa;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(23, 48, 79, 0.32);
    transition: transform 0.08s ease, background 0.12s ease;
}

input[type="range"]::-moz-range-thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2f71aa;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(23, 48, 79, 0.32);
    transition: transform 0.08s ease, background 0.12s ease;
}

input[type="range"]:active::-webkit-slider-thumb {
    transform: scale(1.14);
    background: #245c8c;
}

input[type="range"]:active::-moz-range-thumb {
    transform: scale(1.14);
    background: #245c8c;
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
    outline: 3px solid rgba(47, 113, 170, 0.45);
    outline-offset: 2px;
}

input[type="range"]:focus-visible::-moz-range-thumb {
    outline: 3px solid rgba(47, 113, 170, 0.45);
    outline-offset: 2px;
}

/* ---- Grid overflow guard. Grid/flex items default to min-width:auto, so a
   wide table pushes the whole page sideways. Cap it so .table-wrap's own
   overflow-x scroll takes over instead. ---- */
.content-grid > *,
.chart-grid > *,
.insight-grid > *,
.faq-grid > *,
.result-grid > *,
.detail-grid > * {
    min-width: 0;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ---- Tap targets ---- */
.action-button {
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
}

.option-card,
.option-label,
.family-choice,
.swing-choice {
    -webkit-tap-highlight-color: transparent;
}

/* ---- Selection affordance. A radio dot on every choice card, filled when
   selected, so it's obvious the cards are buttons. Works whether selection is
   a checked radio (input:checked + card) or a JS class (.is-active). ---- */
.option-card,
.family-choice-card,
.swing-choice-card {
    position: relative;
    padding-right: 46px;
    border-width: 1.5px;
    border-color: rgba(63, 120, 178, 0.32);
}

.option-card::after,
.family-choice-card::after,
.swing-choice-card::after {
    content: "";
    position: absolute;
    top: 16px;
    right: 16px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(63, 120, 178, 0.5);
    background: #fff;
    transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.option-label input:checked + .option-card::after,
.option-card.is-active::after,
.family-choice input:checked + .family-choice-card::after,
.swing-choice input:checked + .swing-choice-card::after {
    border-color: #2f71aa;
    background: radial-gradient(circle, #2f71aa 0 6px, #fff 7px);
    box-shadow: 0 0 0 3px rgba(47, 113, 170, 0.16);
}

.option-label input:checked + .option-card,
.option-card.is-active,
.family-choice input:checked + .family-choice-card,
.swing-choice input:checked + .swing-choice-card {
    box-shadow: 0 0 0 2px rgba(47, 113, 170, 0.28), 0 14px 30px rgba(103, 127, 156, 0.16);
}

/* ---- Hero "start" CTA. Big, obvious entry into the tool. ---- */
.hero-start-cta {
    margin-top: 22px;
    padding: 15px 26px;
    font-size: 1.06rem;
}

/* ============================ App mode ============================ */
@media (max-width: 640px) {
    /* Finder + result go edge-to-edge like app screens. */
    .content-grid {
        margin-left: -16px;
        margin-right: -16px;
        gap: 0;
    }

    /* Scoped to the edge-to-edge grid ON PURPOSE. Dropping the radius and side
       borders is only right for a card that has been pulled to the screen edge by
       the rule above; on a page with no .content-grid (the standings calculator)
       the same declarations leave square-cornered cards floating inside gutters.
       Keeping this conditional is what makes the file safe to load anywhere. */
    .content-grid > .finder-card,
    .content-grid > .result-card {
        border-radius: 0;
        border-left: 0;
        border-right: 0;
        box-shadow: none;
    }

    /* Desktop-luxury padding/radius is oversized on a 358px screen. */
    .finder-card,
    .result-card,
    .chart-card,
    .faq-card,
    .side-card,
    .step-panel,
    .helper-card,
    .measurement-card,
    .option-card,
    .swing-choice-card,
    .family-choice-card,
    .result-section,
    .detail-card,
    .family-picker {
        padding: 16px;
        border-radius: 18px;
    }

    .finder-card {
        padding: 18px 16px;
    }

    h1 {
        font-size: 1.9rem;
        line-height: 1.08;
    }

    h2 {
        font-size: 1.5rem;
    }

    .hero-start-cta {
        width: 100%;
        justify-content: center;
        min-height: 54px;
    }

    /* The numbered step pills wrap into a tall stack; the progress bar is
       enough on a phone. */
    .step-indicators {
        display: none;
    }

    /* Pin the step's actions to the bottom of the screen: primary is a
       full-width bar, secondary buttons share a compact row above it. */
    .step-actions {
        position: sticky;
        bottom: 0;
        z-index: 15;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        margin: 10px -16px 0;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, 0.96);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
        border-top: 1px solid rgba(195, 207, 219, 0.6);
    }

    .step-actions .action-button {
        width: auto;
        flex: 1 1 auto;
        min-height: 46px;
        font-size: 0.98rem;
    }

    .step-actions .action-button.primary {
        flex: 1 1 100%;
        order: -1;
        min-height: 54px;
        font-size: 1.05rem;
    }

    /* Post-recommendation actions stack full-width below the box. */
    .result-card .recommendation-actions .action-button,
    .result-card .result-action-stack .action-button {
        width: 100%;
        justify-content: center;
    }

    /* Any table whose cells carry data-label reflows into labelled rows so it
       reads top-to-bottom instead of scrolling sideways. */
    .table-wrap:has(td[data-label]) {
        overflow-x: visible;
    }

    .table-wrap:has(td[data-label]) table,
    .table-wrap:has(td[data-label]) thead,
    .table-wrap:has(td[data-label]) tbody,
    .table-wrap:has(td[data-label]) tr,
    .table-wrap:has(td[data-label]) td {
        display: block;
        width: 100%;
    }

    .table-wrap:has(td[data-label]) thead {
        display: none;
    }

    .table-wrap:has(td[data-label]) tr {
        margin-top: 12px;
        padding: 6px 14px;
        border: 1px solid rgba(195, 207, 219, 0.6);
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.85);
    }

    .table-wrap:has(td[data-label]) td {
        display: flex;
        justify-content: space-between;
        gap: 16px;
        padding: 9px 0;
        border-bottom: 1px solid rgba(195, 207, 219, 0.4);
        text-align: right;
    }

    .table-wrap:has(td[data-label]) tr td:last-child {
        border-bottom: 0;
    }

    .table-wrap:has(td[data-label]) td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        color: var(--ink);
        font-weight: 700;
        text-align: left;
    }
}

/* ---- Above-the-fold budget on a phone.
 *
 * A tool page opened on a phone spent most of the first screen on chrome
 * before the tool appeared: the brand + tagline, then eight nav chips that
 * wrapped into a four-row wall, then a hero whose h1 floor (clamp's MINIMUM
 * wins on a narrow screen, so 6vw never applies) rendered at 38px and took
 * four lines, then a lede paragraph and a chip row. The calculator itself
 * started a full screen down.
 *
 * These rules run at the same 640px breakpoint as the rest of this file and
 * load after each tool's inline <style>, which is what lets them win.
 * ---- */
@media (max-width: 640px) {
    /* Header chrome (brand, tagline, nav rail) now lives in x-app-layout so it
       reaches every page, not just the ones loading this file. */

    /* A nowrap rail only scrolls if it is allowed to be NARROWER than its own
       content. Flex and grid children default to min-width:auto — which
       resolves to the content width — so without this the rail widens its
       parent instead of scrolling, every ancestor grows with it, and
       .hero-stage (overflow:hidden) then clips the h1, lede and buttons at
       the right edge rather than showing a scrollbar. min-width:0 is what
       makes the overflow-x below actually take effect.

       Deliberately NOT solved with overflow-x:hidden on a wrapper: that makes
       the element a scroll container and would break the position:sticky
       action bar this file relies on. */
    .topbar,
    .toolbar,
    .hero,
    .hero-stage,
    .hero-grid,
    .hero-grid > *,
    .content-grid,
    .content-grid > * {
        min-width: 0;
    }

    /* `1fr` is shorthand for `minmax(auto, 1fr)`, and that `auto` floor is the
       item's max-content width — so a single-column grid still refuses to go
       narrower than its widest child. Spell the floor out as 0. */
    .hero-grid,
    .content-grid,
    .card-grid,
    .chart-grid,
    .detail-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    /* The hero's highlight chips are decorative labels, and each one is wide
       enough to claim its own row — four chips became four rows of nothing
       actionable between the intro and the CTA. Rail them like the nav. The
       text stays in the DOM (mobile-first indexing still reads it); it just
       stops costing four lines above the fold. */
    .hero .chip-row,
    .hero .summary-row {
        flex-wrap: nowrap;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 8px;
    }

    .hero .chip-row::-webkit-scrollbar,
    .hero .summary-row::-webkit-scrollbar {
        display: none;
    }

    .hero .chip-row > *,
    .hero .summary-row > * {
        flex: 0 0 auto;
    }


    /* The slider header packs a heading, a minus/plus stepper, a number input
       and a value pill onto ONE row with space-between and no wrapping. That
       needs roughly 380px, while a 390px phone leaves about 326px inside the
       step panel (viewport minus the finder-card's 16px and the step-panel's
       16px each side) — so the row pushed the page ~54px wider than the
       screen and the whole document scrolled sideways. Give the heading its
       own line and let the control span the full width beneath it. */
    .range-heading {
        flex-wrap: wrap;
        gap: 8px;
    }

    .range-heading > h3 {
        flex: 1 1 100%;
    }

    .number-control {
        display: flex;
        width: 100%;
        min-width: 0;
        justify-content: space-between;
    }

    .number-control button {
        flex: 0 0 auto;
    }

    .number-control input {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
    }

    /* One frame, not two. `.hero-stage` shares the generic card styling
       (border, background, radius, shadow, padding) with every other card, but
       it sits INSIDE `.hero`, which already draws that frame — so a phone shows
       two nested rounded boxes and the inner one spends width on padding and
       border for nothing. Keep the outer frame, flatten the inner to a plain
       wrapper. overflow/isolation/position are left alone: `.hero-art` is
       absolutely positioned inside `.hero-stage` and relies on the clip. */
    .hero .hero-stage {
        padding: 0;
        border: 0;
        border-radius: 0;
        background: none;
        box-shadow: none;
    }

    /* Same reasoning for the hero's side panel. On desktop it sits BESIDE the
       copy, where a second frame separates two columns. On a phone the grid
       collapses and it stacks underneath, so the frame becomes a box inside a
       box. Drop the chrome and keep a rule as the separator instead. */
    .hero .side-card {
        padding: 16px 0 0;
        border: 0;
        border-top: 1px solid rgba(195, 207, 219, 0.55);
        border-radius: 0;
        background: none;
        box-shadow: none;
    }

    /* clamp()'s floor is what renders on a phone, so the floor is the knob. */
    .hero h1,
    .hero-grid h1 {
        font-size: clamp(1.75rem, 7.5vw, 2.4rem);
        line-height: 1.08;
    }

    .hero {
        padding: 20px 16px;
        border-radius: 22px;
    }

    .hero .eyebrow {
        font-size: 0.72rem;
    }
}
