/*
 * CLAUDE-PUB-UX-ADDR-AUTH-001 — selector de ubicaciones como popover, «Entrar» visible para invitados y hoja de
 * primera ubi. Solo tokens MM-DS (mm-tokens.css); íconos Lucide vía ux_icon. Liquid glass con contraste AA:
 * el vidrio lleva un fondo casi opaco para que el mapa y las tarjetas no se lean a través del texto.
 */

/* ---------- Chips que abren el popover (ahora <button>) ---------- */
.mobile-map-app__location-display {
    font: inherit;
    font-size: inherit;
    font-weight: 700;
    color: var(--mm-text-strong);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    text-align: left;
}

.mobile-map-app__location-display .mobile-map-app__pin-icon {
    color: var(--mm-brand-500);
    flex: 0 0 auto;
}

.mobile-map-app__location-display .mobile-map-app__service-caret,
.mobile-map-app__service-pill .mobile-map-app__service-caret {
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    transition: transform 160ms ease-out;
}

.mobile-map-app__location-display.is-open .mobile-map-app__service-caret,
.mobile-map-app__service-pill.is-open .mobile-map-app__service-caret {
    transform: rotate(180deg);
}

.mobile-map-app__location-display:focus-visible,
.mobile-map-app__service-pill:focus-visible,
.mobile-map-app__signin-button:focus-visible {
    outline: 2px solid var(--mm-focus);
    outline-offset: 2px;
}

/* ---------- Popover ---------- */
.mobile-map-app__header .mobile-map-app__location-switcher.is-location-menu,
.mobile-map-app__header .mobile-map-app__location-switcher.is-service-menu {
    position: absolute;
    /* top/left/width los fija map-shell a partir del chip que lo abrió (anclado). */
    top: var(--popover-top, 6rem);
    left: var(--popover-left, 1rem);
    right: auto;
    width: var(--popover-width, min(22rem, calc(100vw - 2rem)));
    z-index: var(--mm-z-overlay);
    display: grid;
    gap: 0.25rem;
    padding: 0.5rem;
    max-height: min(60dvh, 32rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--mm-border);
    border-radius: var(--mm-radius-lg);
    background: rgba(255, 255, 255, 0.97);
    -webkit-backdrop-filter: blur(var(--mm-blur-glass)) saturate(160%);
    backdrop-filter: blur(var(--mm-blur-glass)) saturate(160%);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.06);
    transform-origin: top center;
    animation: location-popover-in 160ms ease-out;
}

@keyframes location-popover-in {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.location-popover__title {
    margin: 0;
    padding: 0.45rem 0.75rem 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--mm-text-muted);
}

.location-popover__list {
    display: grid;
    gap: 0.15rem;
}

.location-popover__empty {
    margin: 0;
    padding: 0.5rem 0.75rem 0.75rem;
    color: var(--mm-text-muted);
    font-size: 0.9rem;
}

.location-popover__option,
.location-popover__action {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    min-height: 3.25rem;
    padding: 0.6rem 0.75rem;
    border: 0;
    border-radius: var(--mm-radius-md, 12px);
    background: transparent;
    color: var(--mm-text-strong);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.location-popover__option:hover,
.location-popover__action:hover {
    background: var(--mm-surface-muted);
}

.location-popover__option:focus-visible,
.location-popover__action:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--mm-focus);
}

.location-popover__option.is-active {
    background: var(--mm-surface-brand);
}

.location-popover__option[aria-disabled="true"] {
    cursor: default;
    opacity: 0.6;
}

.location-popover__icon {
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: var(--mm-radius-full);
    background: var(--mm-brand-50);
    color: var(--mm-text-brand);
}

.location-popover__icon svg,
.location-popover__check svg {
    width: 1.15rem;
    height: 1.15rem;
}

.location-popover__text {
    display: grid;
    gap: 0.1rem;
    min-width: 0;
}

.location-popover__text strong {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--mm-text-strong);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.location-popover__text span {
    font-size: 0.82rem;
    color: var(--mm-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.location-popover__check {
    display: inline-grid;
    place-items: center;
    width: 1.25rem;
    color: var(--mm-text-brand);
}

/* El filtro de servicio no lleva ícono a la izquierda. */
.mobile-map-app__header .mobile-map-app__location-switcher.is-service-menu .location-popover__option {
    grid-template-columns: minmax(0, 1fr) auto;
}

.mobile-map-app__location-switcher.is-service-menu .location-popover__text span {
    white-space: normal;
    line-height: 1.3;
}

.location-popover__actions {
    display: grid;
    gap: 0.15rem;
    margin-top: 0.25rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--mm-border);
}

.location-popover__action {
    grid-template-columns: auto minmax(0, 1fr);
    font-weight: 600;
    color: var(--mm-text-brand);
}

.location-popover__action.is-active {
    background: var(--mm-surface-brand);
}

/* ---------- «Entrar» para invitados ---------- */
.mobile-map-app__signin-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: 2.75rem;
    padding: 0 1rem;
    border-radius: var(--mm-radius-full);
    background: var(--mm-brand-500);
    color: var(--mm-on-brand);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: var(--mm-shadow-brand, 0 8px 20px rgba(242, 127, 13, 0.25));
    transition: background-color 150ms ease-out, transform 150ms ease-out;
}

.mobile-map-app__signin-button:hover {
    background: var(--mm-brand-hover, var(--mm-brand-600));
}

.mobile-map-app__signin-button:active {
    transform: scale(0.97);
}

.mobile-map-app__signin-icon {
    width: 1.05rem;
    height: 1.05rem;
}

/* «Entrar» ocupa el lugar de la campana del invitado (su único aviso era «Completa tu cuenta», que ya cubren
   Entrar y Crear cuenta). La campana sigue en el HTML y vuelve en cuanto hay sesión. */
.mobile-map-app__icon-button--notify.is-guest {
    display: none;
}

.mobile-map-app__signin-button {
    flex: 0 0 auto;
}

@media (max-width: 859px) {
    /* Logo siempre centrado: las columnas laterales miden lo mismo, sin importar qué haya a la derecha. */
    .mobile-map-app__header .mobile-map-app__header-top {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        align-items: center;
    }

    .mobile-map-app__header-top > .mobile-map-app__icon-button--menu {
        justify-self: start;
    }

    .mobile-map-app__header-top > .mobile-map-app__brand-logo {
        justify-self: center;
    }

    .mobile-map-app__header .mobile-map-app__header-actions {
        justify-self: end;
        margin-left: 0;
        min-width: 0;
    }

    .mobile-map-app__header .mobile-map-app__header-top {
        column-gap: 0.5rem;
    }

    .mobile-map-app__signin-button {
        padding: 0 0.7rem;
        font-size: 0.86rem;
    }
}

@media (min-width: 860px) {
    /* La última columna era de 3.2rem para la campana; para el invitado mide lo que mida «Entrar». */
    .mobile-map-app__header .mobile-map-app__header-top--guest {
        grid-template-columns: minmax(13.5rem, 15.5rem) minmax(28rem, 1fr) auto auto auto;
    }
}

@media (max-width: 400px) {
    .mobile-map-app__signin-icon {
        display: none;
    }
}

/* Menú lateral: Entrar y Crear cuenta con ícono. */
.mobile-map-app__menu-actions a.mobile-map-app__menu-signin,
.mobile-map-app__menu-actions a.mobile-map-app__menu-signup {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    font-weight: 700;
}

.mobile-map-app__menu-actions a.mobile-map-app__menu-signin {
    background: var(--mm-brand-500);
    color: var(--mm-on-brand);
}

.mobile-map-app__menu-action-icon {
    width: 1.1rem;
    height: 1.1rem;
}

/* Hoja de acceso: «Crear cuenta» como acción visible. */
.mobile-map-app__auth-signup-copy {
    margin: 0.75rem 0 0.4rem;
    color: var(--mm-text-muted);
    text-align: center;
}

.mobile-map-app__auth-signup {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.9rem;
    border: 1px solid var(--mm-border-strong, #CBD5E1);
    border-radius: var(--mm-radius-full);
    background: var(--mm-surface);
    color: var(--mm-text-strong);
    font-weight: 700;
    text-decoration: none;
}

.mobile-map-app__auth-signup:hover {
    background: var(--mm-surface-brand);
}

.mobile-map-app__auth-signup:focus-visible {
    outline: 2px solid var(--mm-focus);
    outline-offset: 2px;
}

.mobile-map-app__auth-signup-icon {
    width: 1.1rem;
    height: 1.1rem;
    color: var(--mm-text-brand);
}

/* ---------- Hoja «¿Dónde te buscamos antojos?» ---------- */
.first-address-sheet {
    position: fixed;
    inset: 0;
    z-index: var(--mm-z-modal);
    display: grid;
    align-items: end;
    justify-items: center;
}

.first-address-sheet[hidden] {
    display: none;
}

/* Difumina el fondo en lugar de oscurecerlo (estilo de Public). */
.first-address-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(255, 247, 237, 0.28);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    backdrop-filter: blur(12px) saturate(140%);
    opacity: 0;
    transition: opacity 200ms ease-out;
}

.first-address-sheet__card {
    position: relative;
    width: min(100%, 30rem);
    display: grid;
    gap: 0.9rem;
    padding: 0.75rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
    border: 1px solid var(--mm-glass-border);
    border-radius: var(--mm-radius-xl) var(--mm-radius-xl) 0 0;
    background: rgba(255, 255, 255, 0.94);
    -webkit-backdrop-filter: blur(var(--mm-blur-glass)) saturate(170%);
    backdrop-filter: blur(var(--mm-blur-glass)) saturate(170%);
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.14);
    transform: translateY(16px);
    opacity: 0;
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 200ms ease-out;
}

.first-address-sheet__card:focus {
    outline: none;
}

.first-address-sheet.is-visible .first-address-sheet__backdrop,
.first-address-sheet.is-visible .first-address-sheet__card {
    opacity: 1;
    transform: none;
}

.first-address-sheet__grabber {
    justify-self: center;
    width: 2.5rem;
    height: 0.3rem;
    border-radius: var(--mm-radius-full);
    background: var(--mm-border);
}

.first-address-sheet__badge {
    display: inline-grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border-radius: var(--mm-radius-full);
    background: var(--mm-surface-brand);
    color: var(--mm-text-brand);
}

.first-address-sheet__badge-icon {
    width: 1.5rem;
    height: 1.5rem;
}

.first-address-sheet__title {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.2;
    font-weight: var(--mm-font-weight-bold);
    color: var(--mm-text-strong);
    text-wrap: balance;
}

.first-address-sheet__copy {
    margin: -0.4rem 0 0;
    color: var(--mm-text-muted);
    line-height: 1.45;
}

.first-address-sheet__types {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    border: 0;
}

.first-address-sheet__types legend {
    margin-bottom: 0.45rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--mm-text);
}

.first-address-sheet__type {
    position: relative;
}

.first-address-sheet__type input {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
    cursor: pointer;
}

.first-address-sheet__type span {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 2.75rem;
    padding: 0 0.5rem;
    border: 1px solid var(--mm-border-strong, #CBD5E1);
    border-radius: var(--mm-radius-full);
    background: var(--mm-surface);
    color: var(--mm-text);
    font-weight: 600;
    font-size: 0.92rem;
    transition: background-color 150ms ease-out, border-color 150ms ease-out;
}

.first-address-sheet__type input:checked + span {
    border-color: var(--mm-brand-500);
    background: var(--mm-surface-brand);
    color: var(--mm-text-strong);
}

.first-address-sheet__type input:focus-visible + span {
    outline: 2px solid var(--mm-focus);
    outline-offset: 2px;
}

.first-address-sheet__type-icon {
    width: 1.05rem;
    height: 1.05rem;
    color: var(--mm-text-brand);
}

.first-address-sheet__actions {
    display: grid;
    gap: 0.5rem;
}

.first-address-sheet__primary,
.first-address-sheet__secondary,
.first-address-sheet__skip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 3rem;
    border-radius: var(--mm-radius-full);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.first-address-sheet__primary {
    border: 0;
    background: var(--mm-brand-500);
    color: var(--mm-on-brand);
}

.first-address-sheet__primary:hover {
    background: var(--mm-brand-hover, var(--mm-brand-600));
}

.first-address-sheet__secondary {
    border: 1px solid var(--mm-border-strong, #CBD5E1);
    background: var(--mm-surface);
    color: var(--mm-text-strong);
}

.first-address-sheet__secondary:hover {
    background: var(--mm-surface-muted);
}

.first-address-sheet__skip {
    min-height: 2.75rem;
    border: 0;
    background: transparent;
    color: var(--mm-text-muted);
    font-weight: 600;
}

.first-address-sheet__primary:focus-visible,
.first-address-sheet__secondary:focus-visible,
.first-address-sheet__skip:focus-visible {
    outline: 2px solid var(--mm-focus);
    outline-offset: 2px;
}

.first-address-sheet__action-icon {
    width: 1.15rem;
    height: 1.15rem;
}

@media (min-width: 860px) {
    .first-address-sheet {
        align-items: center;
    }

    .first-address-sheet__card {
        border-radius: var(--mm-radius-xl);
        padding: 1.25rem 1.5rem 1.5rem;
    }

    .first-address-sheet__grabber {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mobile-map-app__location-switcher.is-location-menu,
    .mobile-map-app__location-switcher.is-service-menu {
        animation: none;
    }

    .first-address-sheet__card,
    .first-address-sheet__backdrop,
    .mobile-map-app__service-caret {
        transition: none;
    }
}
