/* ==========================================================================
   OhMyCity — live 3D map of Málaga. Uses the design tokens from site.css.
   ========================================================================== */

.omc {
    position: relative;
    height: calc(100vh - var(--header-h) - var(--status-h));
    height: calc(100dvh - var(--header-h) - var(--status-h) - env(safe-area-inset-bottom, 0px));
    min-height: 420px;
    overflow: hidden;
    background: var(--bg);
    font-family: var(--font-mono);
}
.omc-map { position: absolute; inset: 0; contain: strict; }
.omc-map canvas { outline: none; }

/* Scanline + vignette overlay so the map reads as part of the console */
.omc::after {
    content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 2;
    background:
        repeating-linear-gradient(0deg, rgba(0, 0, 0, .05) 0 1px, transparent 1px 3px),
        radial-gradient(ellipse at 50% 40%, transparent 55%, color-mix(in srgb, var(--bg) 70%, transparent) 100%);
}
:root[data-theme="light"] .omc::after { background: radial-gradient(ellipse at 50% 40%, transparent 60%, color-mix(in srgb, var(--bg) 60%, transparent) 100%); }

.omc-panel, .omc-detail, .omc-tools, .omc-fallback { position: absolute; z-index: 5; }

/* ---------- Left HUD panel ---------- */
.omc-panel {
    top: 16px; left: 16px; width: 300px; max-height: calc(100% - 32px);
    display: flex; flex-direction: column;
    background: color-mix(in srgb, var(--surface) 97%, transparent);
}
.omc-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.omc-head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.omc-title { font: 700 20px/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.02em; }
.omc-title em { font-style: normal; color: var(--link); }
.omc-sub { margin-top: 6px; font-size: 11px; color: var(--subtle); }
.omc-live { display: inline-flex; align-items: center; gap: 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.12em; color: var(--danger); }
.omc-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); animation: pulse 1.6s ease-in-out infinite; }
.omc-collapse { display: none; }
.omc-body { overflow-y: auto; scrollbar-width: thin; }

.omc-section { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.omc-section:last-child { border-bottom: 0; }
.omc-section h2 { font: 500 10px var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--subtle); margin-bottom: 8px; }
.omc-section h2::before { content: "// "; color: var(--link); }

.omc-layers { list-style: none; display: grid; gap: 2px; }
.omc-layer { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 7px 6px; cursor: pointer; font-size: 12.5px; color: var(--text); border: 1px solid transparent; }
.omc-layer:hover { border-color: var(--line-strong); }
.omc-layer input { position: absolute; opacity: 0; pointer-events: none; }
.omc-swatch { width: 14px; height: 14px; border: 2px solid var(--swatch); background: var(--swatch); }
.omc-layer input:not(:checked) ~ .omc-swatch { background: transparent; }
.omc-layer input:not(:checked) ~ .omc-layer-name { color: var(--subtle); text-decoration: line-through; }
.omc-layer input:focus-visible ~ .omc-swatch { outline: 2px solid var(--link); outline-offset: 2px; }
.omc-layer-name small { display: block; font-size: 10px; color: var(--subtle); margin-top: 1px; text-decoration: none; }
.omc-count { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }

.omc-feed { list-style: none; display: grid; gap: 4px; }
.omc-feed button { width: 100%; text-align: left; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 8px; padding: 7px 8px; border: 1px solid var(--line); background: var(--bg); font: 400 12px var(--font-mono); color: var(--text); }
.omc-feed button:hover { border-color: var(--link); }
.omc-feed .k { font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 1px 5px; border: 1px solid currentColor; align-self: start; }
.omc-feed .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.omc-feed .m { grid-column: 2; font-size: 10.5px; color: var(--subtle); }
.omc-empty { font-size: 11.5px; color: var(--subtle); }
.omc-note { font-size: 10.5px; line-height: 1.5; color: var(--subtle); }
.omc-note a { color: var(--muted); text-decoration: underline; }

.k-accident { color: var(--danger); }
.k-v16 { color: var(--warn); }
.k-incident { color: var(--cyan); }
.k-closed { color: var(--danger); }
.k-work { color: var(--link); }
.k-camera { color: var(--muted); }
.k-bus { color: var(--cyan); }
.k-plane { color: var(--text); }
.k-ship { color: var(--cyan); }
.k-radar { color: var(--warn); }
.k-parking { color: var(--cyan); }

/* ---------- Map tools ---------- */
.omc-tools { right: 16px; bottom: 16px; display: grid; gap: 6px; }
.omc-tools button { width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-strong); background: color-mix(in srgb, var(--surface) 97%, transparent); color: var(--text); font: 700 12px var(--font-mono); }
.omc-tools button:hover, .omc-tools button[aria-pressed="true"] { border-color: var(--link); color: var(--link); }
.omc-compass svg { transition: transform .1s linear; }

/* ---------- Way into the street-level game: a small chip beside the tools ---------- */
.omc-walk { position: absolute; z-index: 5; right: 66px; bottom: 44px; display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line-strong); background: color-mix(in srgb, var(--surface) 97%, transparent); color: var(--text); font: 500 11.5px var(--font-mono); text-decoration: none; }
.omc-walk:hover, .omc-walk:focus-visible { border-color: var(--link); color: var(--link); }
.omc-walk-sheet { display: none; }
.omc-walk-k { font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--link); }

/* ---------- The visitor's own position: a dot inside the city, a small line at the bottom outside it ---------- */
.omc-tools button[hidden] { display: none; }
.omc-me { width: 16px; height: 16px; border-radius: 50%; background: var(--link); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .55), 0 0 12px var(--link); }
.omc-me::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--link); animation: omc-me 1.8s ease-out infinite; }
@keyframes omc-me { from { transform: scale(1); opacity: .9; } to { transform: scale(3.6); opacity: 0; } }
.omc-geo { position: absolute; z-index: 5; right: 66px; bottom: 80px; max-width: min(440px, calc(100% - 100px)); padding: 4px 8px; border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--muted); font: 400 10.5px/1.45 var(--font-mono); text-align: right; pointer-events: none; }
.omc-geo[hidden], .omc-geo-sheet { display: none; }

/* ---------- Detail drawer ---------- */
.omc-detail {
    top: 16px; right: 16px; width: 340px; max-height: calc(100% - 32px - 200px);
    display: flex; flex-direction: column;
    background: color-mix(in srgb, var(--surface) 98%, transparent);
}
.omc-detail[hidden] { display: none; }
.omc-detail-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--subtle); }
.omc-detail-bar button { width: 30px; height: 30px; border: 1px solid var(--line-strong); color: var(--muted); font-size: 14px; }
.omc-detail-bar button:hover { border-color: var(--danger); color: var(--danger); }
.omc-detail-body { padding: 14px; overflow-y: auto; }
.omc-detail h3 { font: 600 18px/1.2 var(--font-display); margin-bottom: 8px; overflow-wrap: anywhere; }
.omc-detail p { font: 400 13.5px/1.55 var(--font-body); color: var(--muted); margin-bottom: 10px; }
.omc-kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; font-size: 12px; margin-bottom: 10px; }
.omc-kv dt { color: var(--subtle); text-transform: uppercase; font-size: 10px; letter-spacing: 0.1em; padding-top: 2px; }
.omc-kv dd { color: var(--text); overflow-wrap: anywhere; }
.omc-cam { position: relative; aspect-ratio: 4 / 3; background: #000; border: 1px solid var(--line-strong); margin-bottom: 10px; overflow: hidden; }
.omc-cam img { width: 100%; height: 100%; object-fit: cover; display: block; }
.omc-cam .rec { position: absolute; top: 8px; left: 8px; font-size: 10px; font-weight: 700; letter-spacing: 0.1em; color: #fff; background: rgba(0, 0, 0, .55); padding: 2px 6px; }
.omc-cam .rec::before { content: "● "; color: #ff3b6b; }
.omc-cam .ts { position: absolute; right: 8px; bottom: 8px; font-size: 10px; color: #fff; background: rgba(0, 0, 0, .55); padding: 2px 6px; }
.omc-cam-fail { display: grid; place-items: center; height: 100%; padding: 16px; text-align: center; font-size: 12px; color: #a09c98; }
.omc-detail .btn { width: 100%; }

.omc-fallback { inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }
.omc-fallback[hidden] { display: none; }

/* MapLibre chrome, restyled */
.omc .maplibregl-ctrl-attrib { background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--subtle); font: 400 10px var(--font-mono); }
.omc .maplibregl-ctrl-attrib a { color: var(--muted); }
.omc .maplibregl-ctrl-bottom-right { right: 62px; }
.omc .maplibregl-ctrl-scale { background: transparent; border-color: var(--line-strong); color: var(--subtle); font: 400 10px var(--font-mono); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .omc-detail { width: 300px; }
}
@media (max-width: 860px) {
    .omc-panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 62%; border-left: 0; border-right: 0; border-bottom: 0; }
    .omc-panel.hud::after { display: none; }
    .omc-collapse { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 1px solid var(--line-strong); color: var(--text); font-size: 14px; }
    .omc-panel.is-collapsed .omc-body { display: none; }
    .omc-panel.is-collapsed .omc-sub { display: none; }
    .omc-head { padding: 10px 14px; }
    .omc-title { font-size: 17px; }
    .omc-layers { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 8px; }
    .omc-layer-name small { display: none; }
    /* The map tools sit in one row along the top, clear of the bottom sheet; the sheet and the
       detail card stack above them so nothing can cover their close buttons. */
    .omc-tools { top: 10px; left: 10px; right: 10px; bottom: auto; grid-auto-flow: column; grid-auto-columns: minmax(0, 44px); justify-content: end; gap: 5px; }
    .omc-tools button { width: 100%; }
    .omc-walk-map { display: none; }
    .omc-walk-sheet { display: inline-flex; right: 10px; bottom: 100%; margin-bottom: 10px; }
    .omc-geo-map { display: none; }
    .omc-geo-sheet:not([hidden]) { display: block; right: 10px; bottom: calc(100% + 46px); max-width: calc(100% - 20px); }
    .omc-panel { z-index: 6; }
    .omc-detail { z-index: 7; top: 60px; left: 10px; right: 10px; width: auto; max-height: 55%; }
    .omc .maplibregl-ctrl-bottom-right, .omc .maplibregl-ctrl-bottom-left { display: none; }
}
@media (max-width: 420px) {
    .omc-layers { grid-template-columns: minmax(0, 1fr); }
}
