/* APOLO · Fase 56 · Mapa real de Nuevo Chimbote: fondo (acceso, recuperación y portada), modo explorador y selector del CEO.
   Las teselas las pinta public/js/tvci-map.js. CSP enforce: sin estilos en línea en las vistas. */

/* ── Motor de mapa ── */
.tvm { overflow: hidden; background: var(--bg-2); }
.tvm__tiles { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.tvm__tile { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; opacity: 0; transition: opacity .25s ease; user-select: none; -webkit-user-drag: none; }
.tvm__tile.is-ready { opacity: 1; }
.tvm__tile.is-failed { visibility: hidden; }
.tvm--dim .tvm__tiles { filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.9) saturate(.65); }
.tvm__attr { position: absolute; right: 0; bottom: 0; z-index: 3; margin: 0; padding: 2px 7px; border-radius: 7px 0 0 0; background: color-mix(in srgb, var(--surface) 90%, transparent); color: var(--muted); font-size: 10.5px; line-height: 1.5; }
.tvm__attr a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.tvm__attr--fixed { position: fixed; z-index: 5; pointer-events: auto; }
.tvm__offline { position: absolute; left: 50%; top: 12px; z-index: 3; width: max-content; max-width: calc(100% - 90px); margin: 0; padding: 6px 12px; transform: translateX(-50%); border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); font-size: 12px; text-align: center; }
.tvm__offline[hidden] { display: none; }

/* ── Fondo cartográfico y velo de lectura ── */
.tp-map { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.tp-map.tvm { position: fixed; }
.tp-map .tvm__offline { display: none; }
.tp-map__dots { position: absolute; inset: 0; z-index: 1; overflow: hidden; }
.tp-map__dot { position: absolute; left: 0; top: 0; width: 12px; height: 12px; margin: -6px 0 0 -6px; border: 2px solid #fff; border-radius: 50%; background: var(--accent); box-shadow: 0 2px 8px rgba(0, 0, 0, .45); }
.tp-map__dot::after { content: ""; position: absolute; inset: -9px; border: 2px solid var(--accent); border-radius: 50%; opacity: 0; animation: tp-map-pulse 3.2s ease-out infinite; }
.tp-map__dot:nth-child(2n)::after { animation-delay: 1.1s; }
.tp-map__dot:nth-child(3n)::after { animation-delay: 2.1s; }
@keyframes tp-map-pulse { 0% { transform: scale(.35); opacity: .75; } 80%, 100% { transform: scale(1.35); opacity: 0; } }
.tp-map__veil { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
.tp-map__veil--full { background:
    radial-gradient(ellipse 48% 56% at 29% 36%, color-mix(in srgb, var(--bg) 70%, transparent) 0%, color-mix(in srgb, var(--bg) 46%, transparent) 55%, transparent 100%),
    linear-gradient(90deg, color-mix(in srgb, var(--bg) 44%, transparent) 0%, color-mix(in srgb, var(--bg) 26%, transparent) 55%, color-mix(in srgb, var(--bg) 36%, transparent) 100%),
    linear-gradient(0deg, color-mix(in srgb, var(--bg) 72%, transparent) 0%, transparent 22%); }
.tp-map--echo { opacity: .75; }
.tp-map__veil--echo { background: color-mix(in srgb, var(--bg) 82%, transparent); }
.tp-auth__intro, .tp-auth__foot { position: relative; }
.tp-auth__headline, .tp-auth__lead, .tp-auth__foot p { text-shadow: 0 1px 2px var(--bg), 0 0 18px var(--bg); }
.tp-auth__lead, .tp-auth__foot p { color: color-mix(in srgb, var(--text) 82%, var(--muted)); }
.tp-auth__features li { background: color-mix(in srgb, var(--surface) 88%, transparent); }
.tp-auth__grid { padding-bottom: 30px; }
@media (max-width: 1024px) {
    .tp-map__veil--full { background: color-mix(in srgb, var(--bg) 58%, transparent); }
}

/* ── Botón de entrada ── */
.tpx-open-row { margin: 14px 0 0; }
.tpx-open-row:has(> [hidden]) { margin: 0; }
.tp-auth__intro .tpx-open-row { margin: 2px 0 14px; }
@media (max-width: 1024px) { .tp-auth__intro .tpx-open-row { margin: 14px 0 0; } }
.tpx-open { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border)); border-radius: 999px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--text); font: 600 14px/1.2 var(--font); cursor: pointer; box-shadow: 0 10px 24px -16px var(--accent); transition: transform .2s ease, background .2s ease, border-color .2s ease; }
.tpx-open[hidden] { display: none; }
.tpx-open .ic { color: var(--accent); }
.tpx-open:hover { transform: translateY(-2px); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 20%, var(--surface)); }

/* ── Categorías (color propio, legible en los 4 temas) ── */
.tpx-cat--rutas { --cat: #3b82f6; }
.tpx-cat--salud { --cat: #e5484d; }
.tpx-cat--plazas { --cat: #2e9e5b; }
.tpx-cat--comida { --cat: #e5820c; }
.tpx-cat--comercio { --cat: #0f9bb3; }

/* ── Explorador ── */
body.tpx-open-body { overflow: hidden; }
.tpx { position: fixed; inset: 0; z-index: 200; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr); background: var(--bg); color: var(--text); }
.tpx[hidden] { display: none; }
.tpx__top { display: flex; align-items: center; gap: 16px; min-width: 0; padding: 12px 18px 8px; }
.tpx__back { flex: none; min-height: 44px; height: auto; }
.tpx__heading { min-width: 0; }
.tpx__heading h2 { margin: 0; font: var(--display-weight) 20px/1.25 var(--font-display); }
.tpx__heading p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.tpx__filters { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; min-width: 0; padding: 4px 18px 12px; border-bottom: 1px solid var(--border); }
.tpx-chip { display: inline-flex; flex: none; align-items: center; gap: 7px; min-height: 40px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--surface); color: var(--text); font: 500 13px/1 var(--font); cursor: pointer; }
.tpx-chip__ic { display: grid; place-items: center; color: var(--cat, var(--accent)); }
.tpx-chip[aria-pressed="true"] { border-color: var(--cat, var(--accent)); background: color-mix(in srgb, var(--cat, var(--accent)) 18%, var(--surface)); box-shadow: inset 0 0 0 1px var(--cat, var(--accent)); }
.tpx__body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; grid-template-rows: minmax(0, 1fr); min-height: 0; }
.tpx__stage { position: relative; min-width: 0; min-height: 0; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.tpx__stage.is-dragging { cursor: grabbing; }
.tpx__stage:focus-visible { outline: 2px solid var(--accent); outline-offset: -3px; }
.tpx__pins { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }

.tpx-pin { position: absolute; left: 0; top: 0; width: 32px; height: 32px; margin: -16px 0 0 -16px; padding: 0; border: 0; background: transparent; pointer-events: auto; cursor: pointer; will-change: transform; }
.tpx-pin[hidden] { display: none; }
.tpx-pin.is-off { visibility: hidden; }
.tpx-pin__dot { display: grid; place-items: center; width: 26px; height: 26px; margin: 3px; border: 2px solid #fff; border-radius: 50%; background: var(--cat); color: #fff; box-shadow: 0 4px 10px -2px rgba(0, 0, 0, .55); transition: transform .18s ease; }
.tpx-pin__dot .ic { width: 14px; height: 14px; }
.tpx-pin--featured .tpx-pin__dot { box-shadow: 0 0 0 4px color-mix(in srgb, var(--cat) 30%, transparent), 0 4px 10px -2px rgba(0, 0, 0, .55); }
.tpx-pin__tip { position: absolute; bottom: calc(100% + 4px); left: 50%; display: none; width: max-content; max-width: 220px; padding: 5px 10px; transform: translateX(-50%); border: 1px solid color-mix(in srgb, var(--cat) 60%, var(--border)); border-radius: 8px; background: var(--surface); color: var(--text); font: 600 12px/1.35 var(--font); box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .7); pointer-events: none; }
.tpx-pin:hover, .tpx-pin:focus-visible { z-index: 3; }
.tpx-pin:hover .tpx-pin__tip, .tpx-pin:focus-visible .tpx-pin__tip { display: block; }
.tpx-pin:hover .tpx-pin__dot { transform: scale(1.15); }
.tpx-pin.is-selected { z-index: 2; }
.tpx-pin.is-selected .tpx-pin__dot { transform: scale(1.3); box-shadow: 0 0 0 6px color-mix(in srgb, var(--cat) 38%, transparent), 0 6px 14px -2px rgba(0, 0, 0, .6); }

.tpx__zoom { position: absolute; top: 12px; right: 12px; z-index: 4; display: flex; flex-direction: column; gap: 6px; }
.tpx__zoom button, .tpx__card-close { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; box-shadow: 0 8px 18px -12px rgba(0, 0, 0, .7); }
.tpx__zoom button:hover, .tpx__card-close:hover { border-color: var(--accent); }

.tpx__card { position: absolute; left: 12px; bottom: 12px; z-index: 5; width: min(360px, calc(100% - 24px)); max-height: 62%; overflow: auto; padding: 16px; border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface); box-shadow: 0 24px 48px -24px rgba(0, 0, 0, .85); cursor: auto; touch-action: pan-y; user-select: text; -webkit-user-select: text; }
.tpx__card[hidden] { display: none; }
.tpx__card h3 { margin: 8px 0 4px; font: var(--display-weight) 18px/1.3 var(--font-display); overflow-wrap: anywhere; }
.tpx__card p { margin: 0; font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.tpx__card .tpx__ref { margin-bottom: 8px; color: var(--muted); }
.tpx__card-close { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; box-shadow: none; }
.tpx__badges { display: flex; flex-wrap: wrap; gap: 6px; padding-right: 44px; }
.tpx-tag { display: inline-flex; align-items: center; min-height: 22px; padding: 0 9px; border: 1px solid var(--border-strong); border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.tpx-tag[hidden] { display: none; }
.tpx-tag--sample { border-style: dashed; color: var(--muted); }

.tpx__list { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid var(--border); background: var(--bg-2); }
.tpx__count { margin: 0; padding: 10px 14px 6px; color: var(--muted); font-size: 12px; }
.tpx__list ul { flex: 1; min-height: 0; margin: 0; padding: 0 10px 12px; overflow-y: auto; list-style: none; }
.tpx__list li[hidden] { display: none; }
.tpx-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 52px; margin-bottom: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); text-align: left; cursor: pointer; }
.tpx-item:hover { border-color: var(--cat); }
.tpx-item[aria-pressed="true"] { border-color: var(--cat); background: color-mix(in srgb, var(--cat) 14%, var(--surface)); }
.tpx-item__ic { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 10px; background: color-mix(in srgb, var(--cat) 18%, transparent); color: var(--cat); }
.tpx-item__text { display: flex; flex-direction: column; min-width: 0; }
.tpx-item__text b { font-size: 13px; line-height: 1.35; overflow-wrap: anywhere; }
.tpx-item__text small { color: var(--muted); font-size: 11.5px; }
.tpx__empty { margin: 0; padding: 8px 14px; color: var(--muted); font-size: 13px; }
.tpx__empty[hidden] { display: none; }

/* ── Selector de ubicación del CEO ── */
.poix__map { position: relative; display: block; width: 100%; height: 420px; border: 1px solid var(--border-strong); border-radius: var(--radius, 12px); cursor: crosshair; touch-action: none; user-select: none; }
.poix__map.is-dragging { cursor: grabbing; }
.poix__marker { position: absolute; left: 0; top: 0; z-index: 2; width: 20px; height: 20px; margin: -10px 0 0 -10px; border: 3px solid #fff; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 35%, transparent), 0 4px 10px rgba(0, 0, 0, .5); pointer-events: none; }
.poix__marker[hidden] { display: none; }
.poix__zoom { position: absolute; top: 10px; right: 10px; z-index: 3; display: flex; flex-direction: column; gap: 6px; }
.poix__zoom button { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); cursor: pointer; }
@media (max-width: 760px) { .poix__map { height: 320px; } }

@media (max-width: 760px) {
    .tpx__top { gap: 10px; padding: 8px 12px 6px; }
    .tpx__heading h2 { font-size: 16px; }
    .tpx__heading p { font-size: 11px; }
    .tpx__back { padding: 0 10px; font-size: 12.5px; }
    .tpx__filters { gap: 6px; padding: 2px 10px 8px; }
    .tpx-chip { min-height: 36px; padding: 0 10px; font-size: 12px; gap: 5px; }
    .tpx__body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1.7fr) minmax(0, 1fr); }
    .tpx__list { border-left: 0; border-top: 1px solid var(--border); }
    .tpx__card { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 56%; padding: 12px; }
    .tpx__zoom { top: 8px; right: 8px; }
}
@media (max-height: 520px) {
    .tpx__heading p { display: none; }
    .tpx__card { max-height: 78%; }
}
@media (prefers-reduced-motion: reduce) {
    .tp-map__dot::after { animation: none; }
    .tvm__tile, .tpx-open, .tpx-pin__dot { transition: none; }
    .tpx-open:hover { transform: none; }
}
@media print { .tp-map, .tp-map__veil, .tvm__attr--fixed, .tpx, .tpx-open-row { display: none; } }
