/*
 * Portal público de Fracciona (mapa a pantalla completa).
 * Identidad: las teselas naranjas y el círculo gris del logo. Los pines son teselas
 * (naranja = venta, verde azulado = renta) y los grupos usan el círculo gris.
 */
:root {
    --ink: #233446;
    --muted: #5d6b7a;
    --line: #e2e6eb;
    --paper: #ffffff;
    --glass: rgba(255, 255, 255, 0.9);
    --sale: #d9480f;
    --rent: #0b7285;
    --other: #697a8d;
    --cluster: #697a8d;
    --focus: #1971c2;
    --radius-tile: 9px;
    --radius-panel: 16px;
    --shadow-float: 0 1px 2px rgba(35, 52, 70, 0.12), 0 8px 24px rgba(35, 52, 70, 0.14);
    --bar-height: 56px;
    font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--ink);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body.portal {
    height: 100%;
    margin: 0;
    background: #e9ecef;
}

body.portal {
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

.portal a {
    color: inherit;
}

.portal :focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Barra superior */
.portal-bar {
    position: fixed;
    inset: 0 0 auto 0;
    z-index: 20;
    height: var(--bar-height);
    padding: 0 16px;
    padding-top: env(safe-area-inset-top);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(35, 52, 70, 0.08);
}

.portal-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.01em;
    text-decoration: none;
}

.portal-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Marca larga o con atribución (<x-brand-wordmark>); "Fracciona" sola no usa estas reglas. */
.portal-brand {
    min-width: 0;
}

.portal-brand .brand-lockup {
    display: inline-flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.15;
}

.portal-brand .brand-name--long,
.portal-brand .brand-lockup-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-brand .brand-name--long,
.portal-brand .brand-lockup--long .brand-lockup-name {
    font-size: 16px;
}

.portal-brand .brand-lockup-tagline {
    overflow: hidden;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--muted);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.portal-nav {
    flex-shrink: 0;
}

.portal-lang {
    display: inline-flex;
    padding: 2px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--paper);
}

.portal-lang a {
    min-width: 36px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    color: var(--muted);
}

.portal-lang a[aria-current="true"] {
    background: var(--ink);
    color: #fff;
}

.portal-link,
.portal-button {
    padding: 7px 12px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
}

.portal-link:hover {
    background: rgba(35, 52, 70, 0.06);
}

.portal-button {
    background: var(--ink);
    color: #fff !important;
}

.portal-button:hover {
    background: #16222f;
}

/* Mapa */
.portal-main {
    position: fixed;
    inset: 0;
}

.portal-map {
    position: absolute;
    inset: 0;
}

/* Pines: teselas con casa, como las del logo */
.portal-pin {
    position: relative;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-tile);
    border: 2px solid #fff;
    background: var(--other);
    color: #fff;
    box-shadow: 0 1px 3px rgba(35, 52, 70, 0.35);
    transform-origin: 50% 100%;
    transition: transform 120ms ease-out;
}

.portal-pin::after {
    content: "";
    position: absolute;
    bottom: -7px;
    left: 50%;
    width: 8px;
    height: 8px;
    margin-left: -4px;
    background: inherit;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg);
    z-index: -1;
}

.portal-pin--sale {
    background: var(--sale);
}

.portal-pin--rent {
    background: var(--rent);
}

.portal-pin:hover,
.portal-pin.is-selected {
    transform: scale(1.18);
}

.portal-pin.is-selected {
    box-shadow: 0 0 0 3px var(--ink), 0 2px 6px rgba(35, 52, 70, 0.4);
}

.portal-cluster {
    display: grid;
    place-items: center;
    min-width: 38px;
    height: 38px;
    padding: 0 8px;
    border-radius: 999px;
    border: 3px solid #fff;
    background: var(--cluster);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 1px 4px rgba(35, 52, 70, 0.35);
}

.portal-cluster--large {
    min-width: 46px;
    height: 46px;
    font-size: 15px;
}

.portal-me {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--focus);
    border: 3px solid #fff;
    box-shadow: 0 0 0 6px rgba(25, 113, 194, 0.2);
}

/* Estado (cargando, vacío, error) */
.portal-status {
    position: fixed;
    top: calc(var(--bar-height) + 12px);
    left: 50%;
    z-index: 15;
    transform: translateX(-50%);
    max-width: calc(100% - 32px);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--paper);
    box-shadow: var(--shadow-float);
    font-size: 14px;
    font-weight: 500;
}

.portal-status[hidden] {
    display: none;
}

.portal-status-action {
    border: 0;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.portal-legend {
    position: fixed;
    left: 16px;
    bottom: calc(24px + env(safe-area-inset-bottom));
    z-index: 10;
    display: flex;
    gap: 12px;
    margin: 0;
    padding: 6px 12px;
    list-style: none;
    border-radius: 999px;
    background: var(--glass);
    box-shadow: var(--shadow-float);
    font-size: 13px;
    font-weight: 500;
}

.portal-legend[hidden] {
    display: none;
}

.portal-legend li {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.portal-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.portal-legend-swatch--sale {
    background: var(--sale);
}

.portal-legend-swatch--rent {
    background: var(--rent);
}

.portal-locate {
    margin: 0 10px 10px 0;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 2px;
    background: #fff;
    color: var(--ink);
    box-shadow: rgba(0, 0, 0, 0.3) 0 1px 4px -1px;
    cursor: pointer;
}

/* Tarjeta del inmueble: panel lateral en escritorio, hoja inferior en móvil */
.portal-card {
    position: fixed;
    z-index: 25;
    top: calc(var(--bar-height) + 16px);
    right: 16px;
    width: 380px;
    max-height: calc(100% - var(--bar-height) - 32px);
    overflow-y: auto;
    border-radius: var(--radius-panel);
    background: var(--paper);
    box-shadow: var(--shadow-float);
}

.portal-card[hidden] {
    display: none;
}

.portal-card-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(35, 52, 70, 0.25);
    cursor: pointer;
}

.portal-photo {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    background: #eef1f4;
}

.portal-photo--empty {
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 14px;
}

.portal-card-content {
    padding: 16px 18px 18px;
}

.portal-op {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.portal-op::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--other);
}

.portal-op--sale::before {
    background: var(--sale);
}

.portal-op--rent::before {
    background: var(--rent);
}

.portal-card h2,
.portal-fallback-list h2 {
    margin: 6px 0 4px;
    font-size: 20px;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.portal-card h2:focus {
    outline: none;
}

.portal-price {
    margin: 0 0 10px;
    font-size: 18px;
    font-weight: 700;
}

.portal-price small {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.portal-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin: 0 0 10px;
    padding: 0;
    list-style: none;
    font-size: 14px;
}

.portal-place,
.portal-excerpt,
.portal-note {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 14px;
}

.portal-note {
    color: #8a5a00;
}

.portal-agency {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    font-size: 14px;
}

.portal-agency img {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
}

.portal-cta {
    display: block;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--ink);
    color: #fff !important;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
}

.portal-cta:hover {
    background: #16222f;
}

.portal-card-loading {
    padding: 48px 18px;
    color: var(--muted);
    text-align: center;
}

/* Respaldo sin mapa */
.portal-fallback {
    position: absolute;
    inset: var(--bar-height) 0 0 0;
    overflow-y: auto;
    padding: 24px 16px 48px;
    background: #f5f6f8;
}

.portal-fallback[hidden] {
    display: none;
}

.portal-fallback > h1,
.portal-fallback > p {
    max-width: 1080px;
    margin-left: auto;
    margin-right: auto;
}

.portal-fallback > h1 {
    margin-top: 8px;
    margin-bottom: 4px;
    font-size: 24px;
    letter-spacing: -0.01em;
}

.portal-fallback > p {
    color: var(--muted);
}

.portal-fallback-list {
    max-width: 1080px;
    margin: 16px auto 0;
    padding: 0;
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 16px;
}

.portal-fallback-list > li {
    overflow: hidden;
    border-radius: var(--radius-panel);
    background: var(--paper);
    box-shadow: 0 1px 2px rgba(35, 52, 70, 0.08);
}

.portal-noscript {
    position: fixed;
    top: calc(var(--bar-height) + 16px);
    left: 16px;
    right: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--paper);
}

@media (max-width: 640px) {
    .portal-bar {
        padding: 0 12px;
    }

    .portal-brand span {
        display: none;
    }

    .portal-link {
        padding: 7px 8px;
    }

    .portal-card {
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto;
        max-height: 72vh;
        border-radius: var(--radius-panel) var(--radius-panel) 0 0;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .portal-card .portal-photo {
        aspect-ratio: 16 / 8;
    }

    .portal-legend {
        left: 12px;
        bottom: calc(16px + env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    .portal-pin {
        transition: none;
    }
}
