/*
 * Cabecera del sitio (escritorio + panel lateral móvil).
 * La altura sigue en --site-header-height porque muchas páginas calculan su margen con ella.
 */
:root {
    --sh-ink: var(--site-theme-text, #1f1a12);
    --sh-muted: var(--site-theme-muted, #756c62);
    --sh-surface: var(--site-theme-surface, #fbf7f0);
    --sh-border: var(--site-theme-border, rgba(31, 26, 18, 0.12));
    --sh-accent: #d0a25f;
    --sh-hover: rgba(208, 162, 95, 0.16);
    --sh-cta: #d9235f;
    --sh-cta-hover: #b9184b;
    --sh-radius: 12px;
    --sh-shadow: 0 18px 44px rgba(31, 26, 18, 0.16);
}

:root {
    --sh-danger: #b42344;
}

:root[data-site-theme="dark"] {
    --sh-danger: #ff8aa1;
    --sh-hover: rgba(242, 189, 115, 0.14);
    --sh-accent: #f2bd73;
    --sh-shadow: 0 22px 54px rgba(0, 0, 0, 0.45);
}

/* ---- Barra ---- */
#header.site-header,
#header.site-header.header-scrolled,
#header.site-header.header-inner-pages {
    background: color-mix(in srgb, var(--sh-surface) 94%, transparent);
    backdrop-filter: saturate(1.2) blur(12px);
    -webkit-backdrop-filter: saturate(1.2) blur(12px);
    border-bottom: 1px solid var(--sh-border);
    transition: box-shadow 200ms ease, background-color 200ms ease;
}

#header.site-header.header-scrolled {
    box-shadow: 0 10px 30px rgba(31, 26, 18, 0.1);
}

.site-header__bar {
    display: flex;
    align-items: center;
    gap: 16px;
    height: 100%;
    min-width: 0;
}

#header .site-header__logo {
    flex: 0 0 auto;
    display: inline-flex;
    line-height: 0;
}

#header .site-header__logo img {
    width: 52px;
    max-width: 52px;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(31, 26, 18, 0.12);
}

/* ---- Navegación principal (escritorio) ---- */
.site-nav {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    justify-content: center;
}

.site-nav__list {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

#header .site-nav__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: 999px;
    color: var(--sh-ink);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

#header .site-nav__link:hover,
#header .site-nav__link:focus-visible,
.site-menu[open] > .site-nav__link {
    background: var(--sh-hover);
    color: var(--sh-ink);
}

#header .site-nav__link.is-active {
    background: var(--sh-hover);
    color: var(--sh-ink);
    font-weight: 700;
}

.site-nav__link .bi-chevron-down,
.site-account__trigger .bi-chevron-down {
    font-size: 0.7rem;
    transition: transform 150ms ease;
}

.site-menu[open] > summary .bi-chevron-down {
    transform: rotate(180deg);
}

/* ---- Desplegables ---- */
.site-menu {
    position: relative;
}

.site-menu > summary {
    list-style: none;
}

.site-menu > summary::-webkit-details-marker {
    display: none;
}

.site-menu__panel {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 1000;
    min-width: 240px;
    margin: 0;
    padding: 6px;
    list-style: none;
    border: 1px solid var(--sh-border);
    border-radius: 14px;
    background: var(--sh-surface);
    box-shadow: var(--sh-shadow);
    animation: site-menu-in 140ms ease-out;
}

.site-menu__panel ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-menu__panel--account {
    left: auto;
    right: 0;
    width: 290px;
}

@keyframes site-menu-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#header .site-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--sh-ink);
    font: inherit;
    font-size: 0.93rem;
    font-weight: 500;
    line-height: 1.3;
    text-align: left;
    text-decoration: none;
    white-space: normal;
    cursor: pointer;
}

#header .site-menu__item[hidden] {
    display: none;
}

#header .site-menu__item .bi {
    width: 18px;
    color: var(--sh-muted);
    font-size: 1rem;
    text-align: center;
}

#header .site-menu__item:hover,
#header .site-menu__item:focus-visible {
    background: var(--sh-hover);
    color: var(--sh-ink);
}

#header .site-menu__item--danger,
#header .site-menu__item--danger .bi {
    color: var(--sh-danger);
}

.site-menu__label {
    margin: 8px 12px 4px;
    color: var(--sh-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.site-menu__footer {
    margin-top: 6px !important;
    padding-top: 6px !important;
    border-top: 1px solid var(--sh-border);
}

/* ---- Acciones de la derecha ---- */
.site-header__actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

#header .site-header__cta {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 999px;
    background: var(--sh-cta);
    color: #fff;
    font-size: 0.93rem;
    font-weight: 800;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: 0 10px 22px rgba(217, 35, 95, 0.26);
    transition: background-color 150ms ease, transform 150ms ease;
}

#header .site-header__cta:hover,
#header .site-header__cta:focus-visible {
    background: var(--sh-cta-hover);
    color: #fff;
    transform: translateY(-1px);
}

#header .site-header__login {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border: 1px solid var(--sh-border);
    border-radius: 999px;
    color: var(--sh-ink);
    font-size: 0.93rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

#header .site-header__login:hover,
#header .site-header__login.is-active {
    background: var(--sh-hover);
}

.site-account__trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 3px;
    border: 1px solid var(--sh-border);
    border-radius: 999px;
    color: var(--sh-ink);
    cursor: pointer;
    transition: background-color 150ms ease;
}

.site-account__trigger:hover,
.site-account[open] > .site-account__trigger {
    background: var(--sh-hover);
}

.site-account__who {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 10px 12px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--sh-border);
}

.site-account__who > div {
    display: grid;
    min-width: 0;
}

.site-account__who strong {
    color: var(--sh-ink);
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-account__who span {
    color: var(--sh-muted);
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Avatar ---- */
.site-avatar {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    overflow: hidden;
    border-radius: 50%;
    background: var(--sh-accent);
    color: #1f1a12;
    font-size: 0.95rem;
    font-weight: 800;
}

.site-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.site-avatar--lg {
    width: 44px;
    height: 44px;
    font-size: 1.15rem;
}

.site-header__profile,
.site-header__burger {
    display: none;
}

/* ---- Panel lateral (móvil) ---- */
.site-drawer[hidden] {
    display: none;
}

.site-drawer {
    position: fixed;
    inset: 0;
    z-index: 10000;
}

.site-drawer__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 12, 8, 0.48);
    opacity: 0;
    transition: opacity 200ms ease;
}

.site-drawer__panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    width: min(88vw, 380px);
    background: var(--sh-surface);
    box-shadow: -18px 0 50px rgba(0, 0, 0, 0.22);
    transform: translateX(100%);
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.site-drawer.is-open .site-drawer__backdrop {
    opacity: 1;
}

.site-drawer.is-open .site-drawer__panel {
    transform: translateX(0);
}

.site-drawer__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px 20px;
    border-bottom: 1px solid var(--sh-border);
}

.site-drawer__title {
    color: var(--sh-ink);
    font-size: 1.05rem;
    font-weight: 800;
}

.site-drawer__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: var(--sh-hover);
    color: var(--sh-ink);
    font-size: 1.1rem;
}

.site-drawer__body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px 12px 20px;
    -webkit-overflow-scrolling: touch;
}

.site-drawer__user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 6px;
    border: 1px solid var(--sh-border);
    border-radius: 14px;
    color: var(--sh-ink);
    text-decoration: none;
}

.site-drawer__user > span {
    display: grid;
    flex: 1 1 auto;
    min-width: 0;
}

.site-drawer__user strong,
.site-drawer__user small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site-drawer__user small {
    color: var(--sh-muted);
}

.site-drawer__user > .bi {
    color: var(--sh-muted);
}

.site-drawer__guest {
    padding: 14px;
    margin-bottom: 6px;
    border: 1px solid var(--sh-border);
    border-radius: 14px;
}

.site-drawer__guest p {
    margin: 0 0 10px;
    color: var(--sh-muted);
    font-size: 0.92rem;
}

.site-drawer__label {
    margin: 18px 10px 6px;
    color: var(--sh-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.site-drawer__list,
.site-drawer__list ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-drawer__list a,
.site-drawer__list button,
.site-drawer__group > summary {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--sh-ink);
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.site-drawer__list button[hidden] {
    display: none;
}

.site-drawer__list .bi,
.site-drawer__group > summary .bi {
    width: 20px;
    color: var(--sh-muted);
    font-size: 1.1rem;
    text-align: center;
}

.site-drawer__list a:hover,
.site-drawer__list a:focus-visible,
.site-drawer__list button:hover,
.site-drawer__group > summary:hover {
    background: var(--sh-hover);
    color: var(--sh-ink);
}

.site-drawer__list a.is-active {
    background: var(--sh-hover);
    box-shadow: inset 3px 0 0 var(--sh-accent);
}

.site-drawer__group > summary {
    list-style: none;
}

.site-drawer__group > summary::-webkit-details-marker {
    display: none;
}

.site-drawer__group .site-drawer__chevron {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 150ms ease;
}

.site-drawer__group[open] .site-drawer__chevron {
    transform: rotate(180deg);
}

.site-drawer__group ul {
    margin: 2px 0 6px 32px;
    padding-left: 10px;
    border-left: 2px solid var(--sh-border);
}

.site-drawer__group ul a {
    min-height: 42px;
    font-size: 0.95rem;
    font-weight: 500;
}

.site-drawer__foot {
    display: grid;
    gap: 8px;
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--sh-border);
}

.site-drawer__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 46px;
    padding: 10px 16px;
    border: 0;
    border-radius: 999px;
    background: var(--sh-ink);
    color: var(--sh-surface);
    font: inherit;
    font-weight: 800;
    text-decoration: none;
}

.site-drawer__button:hover {
    color: var(--sh-surface);
    opacity: 0.92;
}

.site-drawer__button[hidden] {
    display: none;
}

.site-drawer__button--cta {
    background: var(--sh-cta);
    color: #fff;
}

.site-drawer__button--cta:hover {
    background: var(--sh-cta-hover);
    color: #fff;
}

.site-drawer__button--ghost {
    border: 1px solid var(--sh-border);
    background: transparent;
    color: var(--sh-ink);
}

.site-drawer__logout {
    padding: 8px;
    border: 0;
    background: transparent;
    color: var(--sh-danger);
    font: inherit;
    font-weight: 700;
}

body.site-nav-open {
    overflow: hidden;
}

body.site-nav-open .mobile-action-bar {
    display: none !important;
}

/* ---- Escritorio estrecho ---- */
@media (max-width: 1199px) and (min-width: 992px) {
    .site-header__bar {
        gap: 10px;
    }

    #header .site-nav__link {
        padding: 8px 11px;
    }

    #header .site-header__cta {
        padding: 9px 14px;
    }
}

/* ---- Móvil y tablet ---- */
@media (max-width: 991px) {
    .site-header__bar {
        max-width: 100%;
        gap: 8px;
        padding-right: 12px;
        padding-left: 12px;
    }

    #header .site-header__logo img {
        width: 46px;
        max-width: 46px;
    }

    .site-nav,
    .site-account,
    #header .site-header__cta {
        display: none;
    }

    .site-header__actions {
        gap: 8px;
    }

    .site-header__profile {
        display: inline-flex;
        border-radius: 50%;
        line-height: 0;
    }

    .site-header__burger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        border: 1px solid var(--sh-border);
        border-radius: 12px;
        background: var(--sh-surface);
        color: var(--sh-ink);
        font-size: 1.5rem;
        line-height: 1;
    }

    #header .site-header__login {
        padding: 7px 14px;
        font-size: 0.88rem;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    /* En tablet hay sitio para el botón de entradas sin barra inferior. */
    #header .site-header__cta {
        display: inline-flex;
        padding: 8px 14px;
        font-size: 0.88rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .site-drawer__panel,
    .site-drawer__backdrop,
    .site-menu__panel {
        transition: none;
        animation: none;
    }
}

/* ---- Transiciones suaves entre páginas (Chrome/Edge/Safari recientes; el resto navega como siempre) ---- */
@media (prefers-reduced-motion: no-preference) {
    @view-transition {
        navigation: auto;
    }

    /* La cabecera y la barra inferior se quedan quietas mientras cambia el contenido. */
    #header {
        view-transition-name: site-header;
    }

    .mobile-action-bar {
        view-transition-name: site-action-bar;
    }

    ::view-transition-old(root) {
        animation: site-page-out 140ms ease-in both;
    }

    ::view-transition-new(root) {
        animation: site-page-in 220ms ease-out both;
    }
}

@keyframes site-page-out {
    to {
        opacity: 0;
    }
}

@keyframes site-page-in {
    from {
        opacity: 0;
    }
}
