/* ─────────────────────────────────────────────────────────────
   Mobile polish. Loaded last, so it can tidy up after every page.
   - Touch targets reach ~44px (Apple's guideline). Where a bigger box would shift the
     layout, the hit area grows with padding and an equal negative margin instead.
   - Form fields are 16px on touch screens, so iOS doesn't zoom the page when you tap one.
   - Nothing scrolls the page sideways.
   ───────────────────────────────────────────────────────────── */

/* Fields: iOS Safari zooms into any field under 16px. Keep them all at 16px on touch screens. */
@media (pointer: coarse), (max-width: 1020px) {
    input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { font-size: 16px !important; }
}

/* Hidden radios in segmented controls must not take up width (they made Add to collection
   scroll sideways on phones). */
.seg label { position: relative; }
.seg input { width: 1px !important; height: 1px !important; min-height: 0 !important; margin: 0; padding: 0 !important; left: 0; top: 0; }

/* Smoother momentum and no grey flash on tap */
html { -webkit-tap-highlight-color: rgba(38, 58, 104, 0.12); }

@media (pointer: coarse) {
    /* Header: unit switch and brand */
    .units a { min-width: 44px; min-height: 40px; }
    .site-header .units a { min-width: 40px; min-height: 36px; }
    .site-header .brand { padding: 7px 0; }

    /* Breadcrumbs: bigger hit area, same look */
    .crumbs a { display: inline-block; padding: 10px 0; margin: -10px 0; }

    /* Small text links that stand on their own */
    a.clear, .clear.small, .dn-more, .hero-newbie, .fn-links a, .pc-room, .worn-cta a, .fs-quotes small a { padding-block: 10px; margin-block: -10px; }
    .linkish, .ri-more .linkish, .recent-head button { min-height: 40px; padding: 8px 6px !important; margin: -8px -6px; }
    .ri-more { gap: 14px; }

    /* Sizes and sort toggles */
    .sizes a { min-width: 46px; min-height: 44px; }
    .sort-toggle a { padding: 10px 14px; }
    .save-btn { min-height: 44px; }
    .fit-badge { padding-block: 8px; }

    /* Community controls */
    .act { min-height: 44px; padding: 0 12px; }
    .feed-kinds a { padding: 9px 14px; }
    .fn-rooms a { min-height: 44px; }
    .cz-tool { width: 44px; height: 44px; }
    a.pc-name { display: inline-block; padding: 8px 0; margin: -8px 0; }

    /* Fit guide jump bar and lineup */
    .fit-jump a { min-height: 44px; }
    .rack-nav button { width: 44px; height: 44px; }

    /* Footer links: 44px rows */
    .foot-grid a { padding: 11px 0; }
    .foot-bottom a { display: inline-block; padding: 10px 0; margin: -10px 0; }

    /* Size chart: the size links in the header fill their whole cell */
    table.chart thead th a { display: block; padding: 10px 6px; margin: -10px -6px; }

    /* Lists of links: leaderboard names, best-fit chips, brand tables, Learn contents */
    .leader-list a { padding-block: 7px; }
    .recs a { min-height: 42px; }
    .brand-chart th[scope=row] a { display: inline-block; padding: 10px 0; margin: -10px 0; }
    .guide-toc a, .toc a { min-height: 44px; }
    .ri-side > a { display: block; }
    details:not(.filters):not(.waist-pill) > summary { min-height: 44px; display: flex; align-items: center; }
    .maker-name { padding-block: 8px; }
    .cz-title { min-height: 44px; }
}

@media (max-width: 760px) {
    /* Footer: twelve links read better as two columns on a phone */
    .foot-grid > div:has(> h4 + a) { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
    .foot-grid > div:has(> h4 + a) h4 { grid-column: 1 / -1; }

    /* Small print that was under 12px */
    .lu small { font-size: 0.72rem; }
    .fr-plate figcaption { font-size: 0.82rem; }
    .typical dd small { font-size: 0.76rem; }
    .rank small { font-size: 0.78rem; }
    .cz-row .field label small { font-size: 0.74rem; }
    .badge { font-size: 0.7rem; }
}

/* Fades on sideways-scrolling strips, set by nav.js, so it's clear there's more to swipe */
.fade-end { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
.fade-start { -webkit-mask-image: linear-gradient(to right, transparent, #000 36px); mask-image: linear-gradient(to right, transparent, #000 36px); }
.fade-start.fade-end { -webkit-mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, transparent, #000 36px, #000 calc(100% - 36px), transparent); }

@media (max-width: 600px) {
    /* Community: search gets its own full-width row above the tabs instead of being squeezed off the end */
    .feed-tabs { flex-wrap: wrap; }
    .feed-search { order: -1; width: 100%; margin: 0; padding: 0 0 4px; }
    .feed-search input, .feed-search input:focus { width: 100%; }
    /* Room chips can swipe (the fade shows there's more) */
    .fn-rooms { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .fn-rooms::-webkit-scrollbar { display: none; }
}
@media (max-width: 420px) {
    /* Post headers: drop the @handle on small phones; name, rank, time and kind stay */
    .pc .pc-meta > span:first-child { display: none; }
    .pc .pc-meta { margin-left: 4px; }
}
