/* ==========================================================================
   Community Run Calendar — Mobile View  (mobile.css)
   Scoped to .crc-mobile-app / #crc-mobile-app
   Depends on style.css for --crc-* variables, .crc-badge, .crc-dist-pill,
   .crc-checkbox-label, .crc-checkbox-pill, .badge-{slug}-label classes.
   ========================================================================== */

/* ── Container ─────────────────────────────────────────────────────────── */

.crc-mobile-app {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    -webkit-tap-highlight-color: transparent;
    color: #1d1d1f;
    background: #f2f2f7;
}

/* ── Toolbar (normal flow, just below the map) ─────────────────────────── */

.crcm-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    height: 52px;
    background: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
}

/* ── Toolbar Buttons ───────────────────────────────────────────────────── */

.crcm-toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 999px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    border: none;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    white-space: nowrap;
    box-sizing: border-box;
    transition: opacity 0.15s, transform 0.15s;
}

.crcm-toolbar-btn:active {
    opacity: 0.72;
    transform: scale(0.96);
}

.crcm-btn-create {
    background: #2563eb;
    color: #fff;
    flex-shrink: 0;
}

.crcm-btn-filter {
    position: relative;
    background: #e5e5ea;
    color: #1d1d1f;
    flex: 1;
    max-width: 160px;
    margin-left: auto;
}

.crcm-btn-filter svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: currentColor;
}

.crcm-btn-filter[aria-expanded="true"] {
    background: #2563eb;
    color: #fff;
}

/* ── Active-filter Badge ───────────────────────────────────────────────── */

.crcm-filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #ea580c;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    box-sizing: border-box;
    animation: crcm-pop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes crcm-pop {
    from { transform: scale(0.4); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

/* ── Filter Panel ──────────────────────────────────────────────────────── */

.crcm-filter-panel {
    background: #fff;
    border-bottom: 1px solid rgba(60, 60, 67, 0.12);
    padding: 0 16px;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
                padding    0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.crcm-filter-panel.is-open {
    max-height: 900px;
    padding: 20px 16px;
}

/* ── Filter Sections ───────────────────────────────────────────────────── */

.crcm-filter-section {
    margin-bottom: 18px;
}

.crcm-filter-section:last-of-type {
    margin-bottom: 0;
}

.crcm-filter-section--row {
    display: flex;
    gap: 12px;
}

.crcm-filter-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

/* ── Distance range slider (dual-handle) ─────────────────────────────────── */

.crcm-distance-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.crcm-distance-label {
    font-size: 11px;
    font-weight: 700;
    color: #007aff;
    background: rgba(0, 122, 255, 0.08);
    padding: 4px 12px;
    border-radius: 999px;
    transition: color 0.24s, background 0.24s;
    white-space: nowrap;
}

.crcm-distance-label.zone-hm {
    color: #ff6b35;
    background: rgba(255, 107, 53, 0.1);
}

.crcm-distance-label.zone-m {
    color: #34c759;
    background: rgba(52, 199, 89, 0.1);
}

/* Outer container — 32 px high so thumbs don't clip */
.crcm-range-slider {
    position: relative;
    height: 32px;
    display: flex;
    align-items: center;
    margin-bottom: 30px;
    --crc-thumb-color: #007aff;
}

/* ── Track & fill ─────────────────────────────────────────── */

.crcm-range-track,
.crcm-range-fill {
    position: absolute;
    height: 6px;
    border-radius: 999px;
    left: 0;
    right: 0;
    pointer-events: none;
}

.crcm-range-track {
    background: #e5e5ea;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.crcm-range-fill {
    background: #007aff;
    width: 100%;
    transition: background 0.24s;
}

/* ── Range inputs (stacked) ───────────────────────────────── */

.crcm-range-input {
    position: absolute;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    outline: none;
    z-index: 3;
}

/* ── Webkit thumb ─────────────────────────────────────────── */

.crcm-range-input::-webkit-slider-runnable-track { background: transparent; }

.crcm-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    pointer-events: all;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fff;
    border: 2.5px solid var(--crc-thumb-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
    cursor: grab;
    transition: border-color 0.24s, transform 0.14s;
    touch-action: pan-x;
}

.crcm-range-input:active::-webkit-slider-thumb {
    cursor: grabbing;
    transform: scale(1.18);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2);
}

/* ── Firefox thumb ────────────────────────────────────────── */

.crcm-range-input::-moz-range-track { background: transparent; }
.crcm-range-input::-moz-range-thumb {
    pointer-events: all;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    border: 2.5px solid var(--crc-thumb-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
    cursor: grab;
    transition: border-color 0.24s;
}

/* ── Tick marks ───────────────────────────────────────────── */

.crcm-slider-ticks {
    position: absolute;
    bottom: -26px;
    left: 0;
    right: 0;
    pointer-events: none;
}

.crcm-slider-tick {
    position: absolute;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.3px;
    opacity: 0.75;
}

.crcm-slider-tick::before {
    content: '';
    display: block;
    width: 2px;
    height: 5px;
    background: currentColor;
    border-radius: 2px;
}

.crcm-slider-tick--hm { color: #ff6b35; }
.crcm-slider-tick--m  { color: #34c759; }

.crcm-filter-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #6e6e73;
    margin-bottom: 6px;
}

/* ── Inputs ────────────────────────────────────────────────────────────── */

.crcm-input {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    background: #f2f2f7;
    font-family: inherit;
    font-size: 15px;
    color: #1d1d1f;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.18s, box-shadow 0.18s;
}

.crcm-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

/* Date row: input + clear button side by side */
.crcm-date-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.crcm-date-row .crcm-input {
    flex: 1;
    min-width: 0;
}

.crcm-clear-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: none;
    background: #f2f2f7;
    border-radius: 10px;
    font-size: 20px;
    line-height: 1;
    color: #6e6e73;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
    padding: 0;
    box-sizing: border-box;
}

.crcm-clear-btn:active {
    background: #e5e7eb;
}

/* ── Race type pills (reuse existing .crc-checkbox-* from style.css) ──── */

.crcm-pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.crcm-pill-row .crc-checkbox-label {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}

.crcm-pill-row .crc-checkbox-pill {
    padding: 8px 16px;
    font-size: 13px;
}

/* ── Filter Footer ─────────────────────────────────────────────────────── */

.crcm-filter-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(60, 60, 67, 0.1);
}

.crcm-apply-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 50px;
    border: none;
    border-radius: 12px;
    background: #2563eb;
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s, transform 0.15s;
    box-sizing: border-box;
}

.crcm-apply-btn:active {
    opacity: 0.8;
    transform: scale(0.98);
}

/* ── Map Wrapper ───────────────────────────────────────────────────────── */

.crcm-map-wrap {
    position: relative;
    width: 100%;
    height: 200px;
    background: #dde2e7;
}

.crcm-map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ── Tap-to-activate Overlay ───────────────────────────────────────────── */

.crcm-map-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.36);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.25s;
}

.crcm-map-overlay:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: -3px;
}

.crcm-map-overlay.is-activated {
    opacity: 0;
    pointer-events: none;
}

.crcm-map-overlay-text {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #1d1d1f;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
}

.crcm-map-overlay-text svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ── Event List ────────────────────────────────────────────────────────── */

.crcm-event-list {
    display: flex;
    flex-direction: column;
    background: #f2f2f7;
    padding: 8px 0 24px;
}

/* ── Loading / Empty ───────────────────────────────────────────────────── */

.crcm-loading,
.crcm-no-events {
    padding: 48px 24px;
    text-align: center;
    color: #6e6e73;
    font-size: 15px;
}

/* ── Media-Object Card ─────────────────────────────────────────────────── */

.crcm-card {
    display: flex;
    align-items: stretch;
    background: #fff;
    border-bottom: 1px solid rgba(60, 60, 67, 0.1);
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.12s;
}

.crcm-card:first-child {
    border-top: 1px solid rgba(60, 60, 67, 0.1);
}

.crcm-card:active {
    background: #f2f2f7;
}

/* ── Today's event highlight ─────────────────────────────────────────────── */

.crcm-card.is-today {
    background: rgba(52, 199, 89, 0.04);
    border-left: 3.5px solid #34c759;
    border-bottom-color: rgba(52, 199, 89, 0.2);
}

.crcm-card.is-today:first-child {
    border-top-color: rgba(52, 199, 89, 0.2);
}

/* "I DAG" chip over the thumbnail */
.crcm-today-chip {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    background: #34c759;
    color: #fff;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
    box-shadow: 0 1px 6px rgba(52, 199, 89, 0.5);
    pointer-events: none;
}

/* Make the thumbnail wrapper relative so the chip positions correctly */
.crcm-card-thumb {
    position: relative;
}

/* Date row turns green on today's card */
.crcm-card.is-today .is-today-date { color: #34c759; font-weight: 700; }
.crcm-card.is-today .is-today-date svg { stroke: #34c759; }

/* ── Card Thumbnail ────────────────────────────────────────────────────── */

.crcm-card-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    align-self: center;
    margin: 12px 0 12px 12px;
    border-radius: 10px;
    overflow: hidden;
    background: #e5e5ea;
    position: relative;
}

.crcm-card-thumb img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center;
}

.crcm-card-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    background: linear-gradient(135deg, #f2f2f7 0%, #e5e5ea 100%);
}

/* ── Card Body ─────────────────────────────────────────────────────────── */

.crcm-card-body {
    flex: 1;
    min-width: 0;
    padding: 12px 14px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    justify-content: center;
}

/* ── Badge row ─────────────────────────────────────────────────────────── */

.crcm-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 1px;
}

/* Override absolute positioning from style.css .crc-badge */
.crcm-card-badges .crc-badge {
    position: static !important;
    display: inline-block;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 999px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: #fff;
    line-height: 1.5;
}

/* ── Card Title ────────────────────────────────────────────────────────── */

.crcm-card-title {
    font-size: 15px;
    font-weight: 700;
    color: #1d1d1f;
    margin: 0;
    line-height: 1.3;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ── Card Meta ─────────────────────────────────────────────────────────── */

.crcm-card-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 1px;
}

.crcm-card-meta-row {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #6e6e73;
    overflow: hidden;
}

.crcm-card-meta-row svg {
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    stroke: #aeaeb2;
    fill: none;
}

.crcm-card-meta-row span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ── Distance pills (reuse .crc-dist-pill from style.css) ─────────────── */

.crcm-card-dist {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

/* Slightly smaller pills in the compact card */
.crcm-card-dist .crc-dist-pill {
    font-size: 10px;
    padding: 2px 7px;
}

/* ── Flatpickr inside the filter panel ────────────────────────────────── */

.crcm-filter-panel .flatpickr-calendar {
    font-family: inherit;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
}
