/* inked/assets/css/studios-v2/map.css */
/**
 * Studios Listing v2 — Map View Styles
 * Grid/Map toggle, MapLibre GL JS overrides, address search,
 * popup cards, responsive.
 *
 * Migration: — Leaflet replaced by MapLibre GL JS
 */

/* ======================================================
   MAP CONTAINER
   ====================================================== */

.studios-map-wrapper {
    max-width: var(--container-max, none);
    margin: var(--space-6) auto 0;
    padding: 0 var(--gutter);
}

#studiosMap {
    width: 100%;
    height: 600px;
    border-radius: var(--radius-lg, 12px);
    border: 1px solid var(--color-border, var(--color-border));
    background: var(--color-bg-card, var(--color-bg-card));
}

/* When map view is active, hide grid and load more */
.map-view-active .studios-grid {
    display: none;
}

.map-view-active .studios-scroll-sentinel,
.map-view-active .studios-scroll-spinner {
    display: none;
}

/* ======================================================
   VIEW TOGGLE BUTTONS
   ====================================================== */

.studios-view-toggle {
    display: flex;
    gap: 4px;
    margin-left: 8px;
    flex-shrink: 0;
}

.view-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: var(--radius-sm, 4px);
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast, 150ms);
    line-height: 1;
    min-width: 44px;
    min-height: 44px;
}

.view-toggle-btn:hover {
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--color-text);
}

.light-theme .view-toggle-btn:hover {
    border-color: rgba(0, 0, 0, 0.2);
    color: var(--color-text);
}

.view-toggle-btn.active {
    background: var(--color-brand-accent, var(--color-brand-accent));
    color: var(--color-bg);
    border-color: var(--color-brand-accent, var(--color-brand-accent));
}

.view-toggle-btn svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* ======================================================
   ADDRESS SEARCH BAR
   ====================================================== */

.studios-map-search {
    position: relative;
    margin-bottom: 12px;
}

.studios-map-search input {
    width: 100%;
    padding: 10px 16px;
    border-radius: var(--radius-md, 8px);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    font-size: var(--text-sm);
    font-family: inherit;
    transition: border-color var(--transition-fast, 150ms);
    box-sizing: border-box;
    min-height: 44px;
}

.studios-map-search input::placeholder {
    color: var(--color-text-muted, var(--color-text-muted));
}

.studios-map-search input:focus {
    outline: none;
    border-color: var(--color-brand-accent, var(--color-brand-accent));
}

.light-theme .studios-map-search input {
    background: var(--color-white);
    border-color: rgba(0, 0, 0, 0.12);
    color: var(--color-text);
}

.studios-map-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--color-bg-card, var(--color-bg-card));
    border: 1px solid var(--color-border, var(--color-border));
    border-radius: var(--radius-md, 8px);
    max-height: 240px;
    overflow-y: auto;
    display: none;
    margin-top: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.light-theme .studios-map-search-results {
    background: var(--color-white);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.studios-map-search-item {
    padding: 10px 16px;
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--color-text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: background var(--transition-fast, 150ms);
}

.studios-map-search-item:last-child {
    border-bottom: none;
}

.studios-map-search-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.light-theme .studios-map-search-item {
    color: var(--color-text);
    border-bottom-color: rgba(0, 0, 0, 0.05);
}

.light-theme .studios-map-search-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

/* ======================================================
   MAPLIBRE POPUP OVERRIDES — Dark/Light theme support
   ====================================================== */

.maplibregl-popup-content {
    background: var(--color-bg-card, var(--color-bg-card)) !important;
    color: var(--color-text) !important;
    border-radius: var(--radius-md, 8px) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6) !important;
    border: 1px solid var(--color-border, var(--color-border)) !important;
    padding: 12px !important;
}

.maplibregl-popup-tip {
    border-top-color: var(--color-bg-card, var(--color-bg-card)) !important;
}

.maplibregl-popup-close-button {
    color: var(--color-text-muted);
    font-size: var(--text-lg);
    padding: 4px 8px;
}

.maplibregl-popup-close-button:hover {
    color: var(--color-text);
    background: transparent;
}

/* Light theme variants */
.light-theme .maplibregl-popup-content {
    background: var(--color-white) !important;
    color: var(--color-text) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

.light-theme .maplibregl-popup-tip {
    border-top-color: var(--color-white) !important;
}

.light-theme .maplibregl-popup-close-button {
    color: var(--color-text-muted);
}

.light-theme .maplibregl-popup-close-button:hover {
    color: var(--color-border);
}

/* ======================================================
   POPUP CARD (mini studio card)
   ====================================================== */

.studio-map-popup {
    display: flex;
    gap: 10px;
    max-width: 260px;
}

.popup-photo {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm, 4px);
    object-fit: cover;
    flex-shrink: 0;
}

.popup-info {
    flex: 1;
    min-width: 0;
}

.popup-name {
    font-weight: var(--font-weight-semibold);
    font-size: var(--text-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popup-location {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popup-rating {
    font-size: var(--text-sm);
    color: var(--color-brand-accent);
    margin-top: 4px;
}

.popup-reviews {
    color: var(--color-text-muted);
    font-size: var(--text-3xs);
}

.popup-link {
    display: inline-block;
    margin-top: 6px;
    font-size: var(--text-sm);
    color: var(--color-brand-accent);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
    transition: opacity var(--transition-fast, 150ms);
}

.popup-link:hover {
    opacity: 0.8;
}

/* ======================================================
   MAPLIBRE CONTROLS — theme override
   ====================================================== */

.maplibregl-ctrl-group button {
    background-color: var(--color-bg-card, var(--color-bg-card)) !important;
    color: var(--color-text) !important;
    border-color: var(--color-border, var(--color-border)) !important;
}

.light-theme .maplibregl-ctrl-group button {
    background-color: var(--color-white) !important;
    color: var(--color-border) !important;
}

/* Attribution — compact ⓘ icon, minimal footprint (MapTiler ToS requires visible attribution) */
.maplibregl-ctrl-attrib {
    font-size: 10px !important;
    opacity: 0.4;
    transition: opacity 0.2s;
}
.maplibregl-ctrl-attrib:hover {
    opacity: 0.9;
}

/* Compact mode: small transparent background */
.maplibregl-ctrl-attrib.maplibregl-compact {
    min-height: 20px;
    padding: 0;
    margin: 0 10px 10px 0;
    background: transparent !important;
    box-shadow: none !important;
}

/* The ⓘ button */
.maplibregl-ctrl-attrib-button {
    width: 22px !important;
    height: 22px !important;
    background-color: var(--color-overlay-scrim-light) !important;
    border-radius: 50% !important;
    cursor: pointer;
}
.light-theme .maplibregl-ctrl-attrib-button {
    background-color: rgba(255,255,255,0.5) !important;
}

/* When collapsed (no [open] attr on details), hide inner text completely */
.maplibregl-ctrl-attrib.maplibregl-compact:not([open]) .maplibregl-ctrl-attrib-inner {
    display: none !important;
}

/* When expanded (user clicked ⓘ), show in styled panel */
.maplibregl-ctrl-attrib.maplibregl-compact[open] {
    background: var(--color-bg-card, var(--color-bg-card)) !important;
    padding: 4px 28px 4px 8px !important;
    border-radius: var(--radius-sm, 4px) !important;
    border: 1px solid var(--color-border, var(--color-border)) !important;
    opacity: 0.9;
}
.maplibregl-ctrl-attrib.maplibregl-compact[open] .maplibregl-ctrl-attrib-inner {
    display: block;
    color: var(--color-text-muted, var(--color-text-muted));
}
.maplibregl-ctrl-attrib.maplibregl-compact[open] .maplibregl-ctrl-attrib-inner a {
    color: var(--color-text-secondary, var(--color-text-secondary));
}
.light-theme .maplibregl-ctrl-attrib.maplibregl-compact[open] {
    background: var(--color-white) !important;
    border-color: rgba(0,0,0,0.1) !important;
}
.light-theme .maplibregl-ctrl-attrib.maplibregl-compact[open] .maplibregl-ctrl-attrib-inner a {
    color: var(--color-text-muted);
}

/* ======================================================
   WEBGL FALLBACK
   ====================================================== */

.map-unsupported {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-text-muted);
    text-align: center;
    padding: var(--space-10);
}

/* ======================================================
   BACK TO LIST BUTTON (mobile floating)
   ====================================================== */

.studios-back-to-list {
    display: none;
    position: fixed;
    /* Reserves bottom-nav height (56px) + safe-area-inset + spacing.
       Prevents overlay over .bottom-nav (z:90). See SPEC INK-DEV-VISUAL-FIX-2026-05-06 #1+#3+#4. */
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + var(--space-3, 12px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    padding: 10px 24px;
    border-radius: 100px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    font-size: var(--text-sm);
    font-weight: var(--font-weight-medium);
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    transition: all var(--transition-fast, 150ms);
    min-height: 44px;
    min-width: 44px;
}

.studios-back-to-list:hover {
    background: var(--color-brand-accent, var(--color-brand-accent));
    color: var(--color-bg);
    border-color: var(--color-brand-accent, var(--color-brand-accent));
}

.light-theme .studios-back-to-list {
    background: var(--color-white);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

/* ======================================================
   RESPONSIVE
   ====================================================== */

@media (max-width: 900px) {
    #studiosMap {
        height: 500px;
    }

    .studios-view-toggle {
        margin-left: 0;
    }
}

@media (max-width: 540px) {
    .studios-map-wrapper {
        padding: 0 16px;
    }

    .map-view-active #studiosMap {
        height: calc(100vh - 180px);
        border-radius: 0;
    }

    .map-view-active .studios-back-to-list {
        display: block;
    }

    /* Full-width map on mobile */
    .map-view-active .studios-map-wrapper {
        padding: 0;
    }

    .map-view-active .studios-map-search {
        padding: 0 16px;
    }
}
