/* wonders.css — prefix: wm- (Wonder Map) */

/* ── Page shell ─────────────────────────────────────────────────────────── */

.wm-page {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 6rem); /* NavBar = 6rem */
    overflow: hidden;
    background: #f8fafc;
}

/* ── Top bar ────────────────────────────────────────────────────────────── */

.wm-topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    z-index: 10;
    align-items: center;
    justify-content: space-between;
}

.wm-topbar__title {
    font-family: 'Inter', sans-serif;
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--antologa-secondary);
    margin: 0;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Chips fill the middle, scrollable if they overflow */
.wm-topbar__filters {
    flex: 1;
    min-width: 0;
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 1px; /* prevent clipping of chip border */
}

.wm-topbar__filters::-webkit-scrollbar {
    display: none;
}

.wm-filter-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    flex-shrink: 0;
    align-self: center;
}

/* Search pinned to far right */
.wm-topbar__search {
    flex-shrink: 0;
    width: 220px;
}

.wm-filter-chip {
    font-size: 0.7125rem;   /* 5% smaller than 0.75rem */
    font-weight: 600;
    padding: 0.3em 0.875em;
    border-radius: 999rem;
    border: 1.5px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.wm-filter-chip:hover {
    border-color: var(--antologa-primary);
    color: var(--antologa-primary);
}

.wm-filter-chip--on {
    background: var(--antologa-primary);
    border-color: var(--antologa-primary);
    color: #fff;
}

/* ── Type legend bar ────────────────────────────────────────────────────── */

.wm-legend {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    gap: 0.75rem;
    padding: 0.4rem 1.25rem;
    background: #fafafa;
    border-bottom: 1px solid #e5e7eb;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    z-index: 9;
}

.wm-legend::-webkit-scrollbar {
    display: none;
}

.wm-legend__label {
    font-size: 0.6rem;
    font-weight: 800;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
    flex-shrink: 0;
    padding-right: 0.625rem;
    border-right: 1px solid #e5e7eb;
}

.wm-legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.wm-legend-item__dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wm-legend-item__name {
    font-size: 0.65rem;
    font-weight: 600;
    color: #374151;
}

/* ── Body (sidebar + map) ───────────────────────────────────────────────── */

.wm-body {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* ── Desktop sidebar ────────────────────────────────────────────────────── */

.wm-sidebar {
    width: 360px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s ease;
    z-index: 5;
}

.wm-sidebar--collapsed {
    width: 0;
    border-right: none;
}

.wm-sidebar__count {
    font-size: 0.75rem;
    color: #9ca3af;
    padding: 0.875rem 1.25rem 0.5rem;
    flex-shrink: 0;
    border-bottom: 1px solid #f3f4f6;
}

.wm-sidebar__list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.wm-sidebar__list::-webkit-scrollbar {
    width: 4px;
}

.wm-sidebar__list::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 4px;
}

/* ── Province header (sidebar + sheet grouping) ─────────────────────────── */

.wm-province-header {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--antologa-primary);
    padding: 0.625rem 1.25rem 0.25rem;
    background: #f8fafc;
    border-bottom: 1px solid #f3f4f6;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* ── Wonder card (sidebar) ──────────────────────────────────────────────── */

.wm-card {
    display: flex;
    gap: 0.875rem;
    padding: 1rem 1.25rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}

.wm-card:hover {
    background: #f8fafc;
}

.wm-card--active {
    background: #eff6ff;
    border-left: 3px solid var(--antologa-primary);
}

.wm-card__thumb {
    width: 70px;
    height: 70px;
    border-radius: 0.625rem;
    flex-shrink: 0;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.wm-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wm-card__thumb > svg {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
}

.wm-card__body {
    flex: 1;
    min-width: 0;
}

.wm-card__name {
    font-weight: 700;
    font-size: 0.875rem;
    color: #111827;
    margin: 0 0 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wm-card__location {
    font-size: 0.75rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 0.2rem;
    margin-bottom: 0.4rem;
}

.wm-card__tags {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.wm-tag {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.15em 0.6em;
    border-radius: 999rem;
}

.wm-tag--type     { background: #d5f0f0; color: #078282; }
.wm-tag--diff     { background: #fdf4e3; color: #9a6c18; }
.wm-tag--swim     { background: #d5f0f0; color: #078282; }
.wm-tag--guide    { background: #fdf4e3; color: #9a6c18; }
.wm-tag--easy     { background: #d5f0f0; color: #078282; }
.wm-tag--moderate { background: #fdf4e3; color: #9a6c18; }
.wm-tag--hard     { background: #fbe8e1; color: #c45a32; }
.wm-tag--expert   { background: #d8eaf2; color: #004f71; }

/* ── Map container ──────────────────────────────────────────────────────── */

.wm-map-wrap {
    flex: 1;
    position: relative;
    min-width: 0;
}

#wm-map {
    width: 100%;
    height: 100%;
}

/* ── MapLibre popup (replaces Leaflet tooltip) ──────────────────────────── */

.wm-ml-popup .maplibregl-popup-content {
    padding: 0 !important;
    background: transparent !important;
    border-radius: 0.75rem !important;
    box-shadow: none !important;
}

.wm-ml-popup .maplibregl-popup-tip {
    display: none !important;
}

/* ── Fit-all reset button ───────────────────────────────────────────────── */

.wm-fitall-btn {
    position: absolute;
    bottom: 2.25rem;   /* lifted clear of the Google "Google" logo */
    /* Bottom-LEFT — opposite Google's native zoom + camera/tilt controls,
       which sit bottom-right, so the two no longer overlap. */
    left: 1rem;
    z-index: 20;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #374151;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    transition: background 0.15s, box-shadow 0.15s;
}

.wm-fitall-btn:hover {
    background: #f3f4f6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ── Map loading overlay ────────────────────────────────────────────────── */

.wm-map-loading {
    position: absolute;
    inset: 0;
    background: rgba(248,250,252,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

/* ── Sidebar toggle button (desktop) ────────────────────────────────────── */

.wm-toggle-btn {
    position: absolute;
    top: 50%;
    left: 360px;   /* matches sidebar width */
    transform: translate(-50%, -50%);
    z-index: 20;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-left: none;
    border-radius: 0 8px 8px 0;
    padding: 0.75rem 0.4rem;
    cursor: pointer;
    box-shadow: 2px 0 8px rgba(0,0,0,0.08);
    transition: left 0.25s ease, transform 0.25s ease, background 0.15s;
}

/* When the sidebar collapses, the toggle moves to the map edge */
.wm-sidebar--collapsed ~ .wm-toggle-btn {
    left: 0;
    transform: translate(0, -50%);
}

.wm-toggle-btn:hover {
    background: #f3f4f6;
}

/* ── Detail drawer (slides over map on desktop) ─────────────────────────── */

.wm-detail {
    position: absolute;
    top: 0;
    right: 0;
    width: 380px;
    height: 100%;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0,0,0,0.12);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    /* Stop the browser's pull-to-refresh from firing when the user swipes
       down to dismiss the drawer on mobile. */
    overscroll-behavior: none;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    /* Promote to its own compositor layer so the slide stays smooth even when
       nearby-pin DOM work happens right after opening. */
    will-change: transform;
}

.wm-detail--open {
    transform: translateX(0);
}

.wm-detail__close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    z-index: 5;
}

.wm-detail__hero {
    width: 100%;
    height: 200px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb; /* fallback; overridden by inline type colour */
}

.wm-detail__hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wm-detail__body {
    padding: 1.25rem 1.5rem 2rem;
    flex: 1;
}

.wm-detail__province {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--antologa-primary);
    margin-bottom: 0.35rem;
}

.wm-detail__name {
    font-family: 'Inter', sans-serif;
    font-size: 1.375rem;
    font-weight: 800;
    color: #111827;
    margin: 0 0 0.75rem;
    line-height: 1.2;
}

.wm-detail__desc {
    font-size: 0.8125rem;
    line-height: 1.7;
    color: #4b5563;
    margin: 0 0 1.25rem;
}

.wm-detail__meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.625rem;
    margin-bottom: 1.25rem;
}

.wm-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.wm-meta-item__label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #9ca3af;
}

.wm-meta-item__value {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #111827;
}

.wm-detail__cta {
    margin-top: 0.5rem;
}

/* ── Mobile filter bar (chips + search icon, sits below the map) ─────────── */

.wm-mobile-bar {
    display: none; /* unhidden in mobile media query */
    flex-shrink: 0;
    align-items: center;
    height: 3.25rem;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    overflow: hidden;
}

.wm-mobile-search-btn,
.wm-mobile-list-btn {
    flex-shrink: 0;
    width: 3.25rem;
    height: 3.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    transition: color 0.15s;
}

.wm-mobile-search-btn { border-right: 1px solid #f3f4f6; }
.wm-mobile-list-btn   { border-left:  1px solid #f3f4f6; }

.wm-mobile-search-btn:active,
.wm-mobile-list-btn:active { color: var(--antologa-primary); }

.wm-mobile-bar__chips {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0 0.625rem;
}

.wm-mobile-bar__chips::-webkit-scrollbar { display: none; }

/* ── Mobile floating search overlay (over map) ───────────────────────────── */

.wm-mobile-search-bar {
    display: none; /* desktop: hidden regardless of Blazor state */
    position: absolute;
    top: 0.625rem;
    left: 0.625rem;
    right: 0.625rem;
    z-index: 50;
    align-items: center;
    gap: 0.375rem;
    background: #fff;
    border-radius: 0.875rem;
    box-shadow: 0 4px 16px rgba(0,0,0,0.18);
    padding: 0.25rem 0.375rem 0.25rem 0.75rem;
}

/* ── Mobile bottom sheet ────────────────────────────────────────────────── */

.wm-sheet {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 1.25rem 1.25rem 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    z-index: 40;
    max-height: 70dvh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.wm-sheet--open {
    transform: translateY(0);
}

/* Large tap-friendly handle area */
.wm-sheet__handle {
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.wm-sheet__handle::after {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
}

.wm-sheet__list {
    padding: 0 0 1.5rem;
}

/* ── Popup card (used inside MapLibre popup) ─────────────────────────────── */

.wm-tooltip-card {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 6px 24px rgba(0,0,0,0.16);
    padding: 0.75rem 0.875rem;
    min-width: 180px;
    max-width: 240px;
    font-family: 'Inter', sans-serif;
    pointer-events: none;
}

.wm-tt-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.wm-tt-emoji {
    font-size: 1.375rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}

.wm-tt-name {
    font-weight: 700;
    font-size: 0.8125rem;
    color: #111827;
    margin: 0;
    line-height: 1.25;
}

.wm-tt-loc {
    font-size: 0.7rem;
    color: #6b7280;
    margin: 0.125rem 0 0;
}

.wm-tt-tags {
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.wm-tt-tag {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.15em 0.55em;
    border-radius: 999rem;
}

.wm-tt-hint {
    font-size: 0.6rem;
    color: #9ca3af;
    text-align: center;
    margin: 0;
}

/* ── Marker cluster badge ────────────────────────────────────────────────── */

.wm-cluster {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,0.28);
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 0.75rem;
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wm-cluster:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 18px rgba(0,0,0,0.35);
}

.wm-cluster--small  { background: #0ea5e9; }
.wm-cluster--medium { background: #078282; }
.wm-cluster--large  { background: #004F71; }

/* ── Detail drag handle (visible on mobile only) ─────────────────────────── */

.wm-detail__handle-bar {
    display: none; /* shown only in mobile media query */
    flex-shrink: 0;
    width: 100%;
    min-height: 1.5rem;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.wm-detail__handle-bar::after {
    content: '';
    display: block;
    width: 2.75rem;
    height: 0.25rem;
    background: #d1d5db;
    border-radius: 999rem;
}

/* ── Detail backdrop (mobile only — dismisses on tap) ────────────────────── */

.wm-detail-backdrop {
    display: none;
}

/* ── Mobile: map-first layout ───────────────────────────────────────────── */

@media (max-width: 768px) {
    /* Top NavBar (6rem) + bottom nav (5rem). Mobile bar is inside wm-page. */
    .wm-page {
        height: calc(100dvh - 6rem - 5rem);
    }

    /* Hide desktop chrome */
    .wm-topbar    { display: none; }
    .wm-legend    { display: none; }
    .wm-sidebar   { display: none; }
    .wm-toggle-btn{ display: none; }

    /* Show the bottom filter bar */
    .wm-mobile-bar { 
        display: flex; 
        z-index: 1000;
    }

    /* Show the mobile list sheet */
    .wm-sheet {
        display: flex;
        flex-direction: column;
    }

    /* Detail drawer: fixed above the bottom nav, full-width bottom sheet */
    .wm-detail {
        position: fixed;
        bottom: 5rem;   /* sit right above bottom nav */
        left: 0;
        right: 0;
        width: 100%;
        height: 80dvh;
        top: auto;
        border-radius: 1.25rem 1.25rem 0 0;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.18);
        transform: translateY(110%);
        z-index: 900;
    }

    .wm-detail--open {
        transform: translateY(0);
    }

    /* Fit-all bottom-LEFT (opposite Google's controls), lifted clear of the
       filter bar / Google logo below it. */
    .wm-fitall-btn {
        bottom: 3.25rem;
        left: 0.75rem;
        right: auto;
    }

    /* Sheet handle has extra padding so thumb can reach it */
    .wm-sheet__handle {
        min-height: 2.75rem;
    }

    /* Floating search bar visible on mobile */
    .wm-mobile-search-bar {
        display: flex;
    }

    /* Drag handle — visible at top of the bottom sheet */
    .wm-detail__handle-bar {
        display: flex;
        min-height: 1.75rem;
    }

    /* Dim backdrop behind the open detail sheet — tap to dismiss */
    .wm-detail-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.35);
        z-index: 899; /* just below .wm-detail z-index: 900 */
        cursor: pointer;
    }
}
