/* «Фотографии» on the map (static/js/map/map_photos.js). */

/* The layers sheet opened from the «Фотографии» item shows only this section. */
#layer-switcher-menu[data-view="photos"] .map-layers-section:not([data-layers-section="photos"]) {
    display: none !important;
}

#layer-switcher-menu .map-layer-row__icon.is-photos { color: #ea580c; background: rgba(249, 115, 22, 0.12); }

.map-photos-sources {
    display: grid;
    gap: 2px;
    margin: 4px 0 0;
    transition: opacity 160ms;
}

.map-photos-sources.is-off { opacity: 0.5; }

#layer-switcher-menu .map-photos-source {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 6px 8px 6px 20px;
    border-radius: 12px;
    cursor: pointer;
}

#layer-switcher-menu .map-photos-source:hover { background: #f8fafc; }

.map-photos-source__dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--photo-ring, #f97316);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--photo-ring, #f97316) 18%, transparent);
}

.map-photos-source__text { display: grid; min-width: 0; gap: 1px; }

.map-photos-source__text b {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #0f172a;
    font-size: 13px;
    font-weight: 700;
}

.map-photos-source__text b em {
    padding: 1px 7px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #475569;
    font-size: 11px;
    font-style: normal;
    font-weight: 700;
}

.map-photos-source__text small { color: #64748b; font-size: 12px; line-height: 1.35; }

.map-photos-note {
    margin: 8px 8px 2px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.45;
}

.map-photos-note:empty { display: none; }

/* Launcher on a computer: a dot while the layer is on. */
.map-window-launcher__item[data-map-window="photos"].is-on span::after {
    content: "";
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 6px;
    border-radius: 50%;
    background: #f97316;
    vertical-align: middle;
}

/* ------------------------------------------------------------------ */
/* Thumbnails on the map.                                              */
/* ------------------------------------------------------------------ */
/* MapLibre places the marker with its own transform: the button itself never
   animates or scales, or it trails the map. The thumbnail inside does. */
.map-photo-marker {
    display: block;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}

.map-photo-marker:hover,
.map-photo-marker:focus-visible { z-index: 3; outline: none; }

.map-photo-marker__face {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    border: 2px solid #ffffff;
    border-radius: 12px;
    background: #e2e8f0 linear-gradient(135deg, #e2e8f0, #cbd5e1);
    box-shadow: 0 0 0 2px var(--photo-ring, #64748b), 0 6px 16px rgba(15, 23, 42, 0.28);
    transition: transform 140ms ease;
}

.map-photo-marker:hover .map-photo-marker__face,
.map-photo-marker:focus-visible .map-photo-marker__face { transform: scale(1.12); }

.map-photo-marker img {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    object-fit: cover;
}

.map-photo-marker.is-broken img { visibility: hidden; }

.map-photo-marker--cluster {
    width: 50px;
    height: 50px;
}

.map-photo-marker--cluster .map-photo-marker__face {
    box-shadow: 0 0 0 2px var(--photo-ring, #0f172a), 4px 4px 0 -1px #ffffff, 4px 4px 0 1px rgba(15, 23, 42, 0.25), 0 8px 18px rgba(15, 23, 42, 0.3);
}

.map-photo-marker__count {
    position: absolute;
    top: -9px;
    right: -11px;
    min-width: 24px;
    padding: 2px 6px;
    border: 2px solid #ffffff;
    border-radius: 999px;
    background: #0f172a;
    color: #ffffff;
    font: 700 11px/1.3 var(--font-text);
    text-align: center;
}

/* ------------------------------------------------------------------ */
/* The photo viewer.                                                   */
/* ------------------------------------------------------------------ */
.map-photo-viewer {
    position: fixed;
    inset: 0;
    z-index: 10100;
    display: grid;
    place-items: center;
    padding: 24px;
    font-family: var(--font-text);
}

.map-photo-viewer__backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(2, 6, 23, 0.82);
    cursor: zoom-out;
}

.map-photo-viewer__frame {
    position: relative;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    width: min(1040px, 100%);
    max-height: calc(100dvh - 48px);
    margin: 0;
    overflow: hidden;
    border-radius: 20px;
    background: #0b1220;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5);
}

.map-photo-viewer__stage {
    position: relative;
    display: grid;
    min-height: 240px;
    place-items: center;
    background: #020617;
}

.map-photo-viewer__image {
    display: block;
    max-width: 100%;
    max-height: calc(100dvh - 190px);
    object-fit: contain;
}

.map-photo-viewer__nav {
    position: absolute;
    top: 50%;
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    font-size: 28px;
    line-height: 1;
    transform: translateY(-50%);
    cursor: pointer;
}

.map-photo-viewer__nav.is-prev { left: 14px; }
.map-photo-viewer__nav.is-next { right: 14px; }
.map-photo-viewer.is-single .map-photo-viewer__nav { display: none; }

.map-photo-viewer__count {
    position: absolute;
    bottom: 12px;
    left: 50%;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(2, 6, 23, 0.7);
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    transform: translateX(-50%);
}

.map-photo-viewer__count:empty { display: none; }

.map-photo-viewer__caption {
    display: grid;
    gap: 4px;
    padding: 14px 64px 16px 18px;
    background: #ffffff;
    color: #0f172a;
}

.map-photo-viewer__source {
    justify-self: start;
    padding: 2px 9px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--photo-ring, #64748b) 14%, #ffffff);
    color: var(--photo-ring, #475569);
    font-size: 12px;
    font-weight: 700;
}

.map-photo-viewer__title { font-size: 16px; font-weight: 750; line-height: 1.3; }
.map-photo-viewer__details { color: #64748b; font-size: 13px; }
.map-photo-viewer__details:empty { display: none; }

.map-photo-viewer__link {
    justify-self: start;
    margin-top: 2px;
    color: #ea580c;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.map-photo-viewer__link:hover { text-decoration: underline; }
.map-photo-viewer__link[hidden] { display: none; }

.map-photo-viewer__close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

html[data-theme="dark"] #layer-switcher-menu .map-photos-source:hover { background: rgba(148, 163, 184, 0.12); }
html[data-theme="dark"] .map-photos-source__text b { color: #e2e8f0; }
html[data-theme="dark"] .map-photo-viewer__caption { background: #0f172a; color: #e2e8f0; }

@media (max-width: 767px) {
    .map-photo-viewer { padding: 0; }
    .map-photo-viewer__frame { width: 100%; height: 100dvh; max-height: none; border-radius: 0; }
    .map-photo-viewer__image { max-height: calc(100dvh - 170px); }
    .map-photo-viewer__nav { width: 40px; height: 40px; }
    .map-photo-viewer__caption { padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px)); }
    .map-photo-viewer__close { top: calc(10px + env(safe-area-inset-top, 0px)); }
    .map-photo-marker { width: 38px; height: 38px; }
    .map-photo-marker--cluster { width: 46px; height: 46px; }
}
