/*
============================================================
TheriansHub — app-nav.css
Estilos del shell de navegación social (sidebar desktop, topbar y bottom-nav
móviles) + el switcher de idioma. Extraídos de feed.css (Bloque 5, Tarea 5)
para reutilizarlos donde aparece el menú: /community/ y las vistas internas de
BuddyPress. Se encola en ambos contextos (ver inc/enqueue.php). El markup lo
generan template-parts/global/app-nav.php + inc/app-nav.php.
============================================================
*/


/* ============================================================
   TOPBAR (mobile only)
   ============================================================ */

.th-feed-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    /* 3 zonas: (+) izquierda · brand centrado · acciones derecha.
       Grid 1fr auto 1fr mantiene el brand centrado en el viewport
       porque las dos columnas laterales son iguales; un flex
       space-between lo dejaría descentrado al ser la zona de
       acciones más ancha que el (+). Pieza solo-móvil (se oculta
       en ≥1024px más abajo). */
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

/* (+) crear post: anclado al borde izquierdo de su columna (si no,
   el enlace se estiraría a todo el ancho de la columna 1fr). */
.th-feed-topbar__action--create {
    justify-self: start;
}

.th-feed-topbar__brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
    color: var(--color-text);
}

.th-feed-topbar__brand:hover {
    text-decoration: none;
}

.th-feed-topbar__logo {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
}

/* Topbar móvil estilo Instagram: solo logo, sin wordmark a la vista.
   Patrón visually-hidden: el texto queda OCULTO visualmente pero sigue
   en el árbol de accesibilidad (es el nombre accesible del enlace del
   logo para lectores de pantalla) y en el HTML para SEO. La clase es
   EXCLUSIVA de la topbar — el sidebar de escritorio usa .th-feed-nav__name,
   no afectado. Se retira la tipografía previa: con el texto oculto era
   código muerto. */
.th-feed-topbar__name {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.th-feed-topbar__actions {
    display: flex;
    gap: var(--space-1);
    justify-self: end;
}

.th-feed-topbar__action {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    color: var(--color-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--duration-fast) var(--ease);
}

.th-feed-topbar__action svg {
    width: 22px;
    height: 22px;
}

.th-feed-topbar__action:hover {
    background: var(--color-surface-2);
}


/* ============================================================
   LANGUAGE SWITCHER (Polylang)
   home.css NO se carga en el feed logueado, así que portamos
   aquí los estilos base del switcher. Markup generado por
   therianshub_render_language_switcher() (inc/helpers.php).
   ============================================================ */

.th-lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.th-lang-switcher__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: var(--space-1) var(--space-2);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-muted);
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast) var(--ease),
                background-color var(--duration-fast) var(--ease);
}

.th-lang-switcher__item:hover {
    color: var(--color-text);
    background: var(--color-surface-2);
    text-decoration: none;
}

.th-lang-switcher__item.is-active {
    color: var(--color-brand);
    font-weight: 700;
}

.th-lang-switcher__flag {
    display: block;
    flex: 0 0 auto;
}

/* Móvil: en la topbar, compacto — solo banderas, ocultamos el código. */
.th-feed-topbar__actions .th-lang-switcher__code {
    display: none;
}

.th-feed-topbar__actions .th-lang-switcher__item {
    gap: 0;
    padding: var(--space-2);
}


/* ============================================================
   BOTTOM NAV (mobile only)
   ============================================================ */

.th-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: var(--space-2) var(--space-2) calc(var(--space-2) + env(safe-area-inset-bottom, 0));
}

.th-bottom-nav__item {
    flex: 1;
    background: none;
    border: none;
    padding: var(--space-2) 0;
    color: var(--color-text-muted);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    transition: color var(--duration-fast) var(--ease);
    font-family: var(--font-sans);
    font-size: 0.6875rem;
    font-weight: 600;
}

.th-bottom-nav__item svg {
    width: 24px;
    height: 24px;
}

.th-bottom-nav__item:hover {
    color: var(--color-text);
    text-decoration: none;
}

.th-bottom-nav__item--active {
    color: var(--color-brand);
}

.th-bottom-nav__item--active:hover {
    color: var(--color-brand);
}

/* CTA central "+" (botón Crear) */
.th-bottom-nav__item--cta {
    flex: 0 0 auto;
    padding: 0;
}

.th-bottom-nav__cta-circle {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--color-brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: -8px var(--space-3) 0; /* sale ligeramente por encima */
    box-shadow: var(--shadow-md);
    transition: background var(--duration-fast) var(--ease),
                transform var(--duration-fast) var(--ease);
}

.th-bottom-nav__cta-circle svg {
    width: 22px;
    height: 22px;
}

.th-bottom-nav__item--cta:hover .th-bottom-nav__cta-circle {
    background: var(--color-brand-hover);
    transform: translateY(-2px);
}


/* ============================================================
   Sidebar (nav): oculto en móvil. El display:none se separó de la
   regla agrupada ".th-feed-nav, .th-feed-widgets" de feed.css (Tarea 5);
   la parte .th-feed-widgets se quedó en feed.css.
   ============================================================ */
.th-feed-nav {
    display: none; /* móvil = oculta */
}


/* ============================================================
   DESKTOP (≥ 1024px) — sidebar nav
   ============================================================ */
@media (min-width: 1024px) {

    /* Ocultar barras solo-móvil */
    .th-feed-topbar,
    .th-bottom-nav {
        display: none;
    }

    /* Mostrar sidebar nav */
    .th-feed-nav {
        display: block;
    }

    /* ----- Sidebar izquierda (nav) ----- */
    .th-feed-nav {
        position: sticky;
        top: var(--space-6);
        padding: var(--space-6) 0;
        width: 100%;
        max-width: 240px;
        justify-self: start;
    }

    .th-feed-nav__brand {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        text-decoration: none;
        color: var(--color-text);
        padding: 0 var(--space-3);
        margin-bottom: var(--space-6);
    }

    .th-feed-nav__brand:hover {
        text-decoration: none;
    }

    .th-feed-nav__logo {
        width: 32px;
        height: 32px;
        flex: 0 0 auto;
    }

    .th-feed-nav__name {
        font-family: var(--font-serif);
        font-style: italic;
        font-weight: 600;
        font-size: 1.25rem;
        letter-spacing: -0.01em;
    }

    .th-feed-nav__list {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        gap: var(--space-1);
    }

    .th-feed-nav__item {
        display: flex;
        align-items: center;
        gap: var(--space-3);
        padding: 12px var(--space-3);
        border-radius: var(--radius-lg);
        color: var(--color-text);
        text-decoration: none;
        font-weight: 600;
        font-size: 0.9375rem;
        transition: background var(--duration-fast) var(--ease),
                    color var(--duration-fast) var(--ease);
    }

    .th-feed-nav__item:hover {
        background: var(--color-surface-2);
        text-decoration: none;
    }

    .th-feed-nav__item svg {
        width: 22px;
        height: 22px;
        flex: 0 0 auto;
    }

    .th-feed-nav__item--active {
        color: var(--color-brand);
        background: var(--color-brand-soft);
    }

    .th-feed-nav__item--active:hover {
        background: var(--color-brand-soft);
        color: var(--color-brand);
    }

    /* Switcher de idioma bajo el nav, separado por un borde sutil. */
    .th-feed-nav__lang {
        margin-top: var(--space-4);
        padding-top: var(--space-4);
        padding-left: var(--space-3);
        border-top: 1px solid var(--color-border);
    }
}

/* ==========================================================================
   Menú de usuario del shell (avatar + <details> desplegable). Reutilizado en
   topbar (móvil) y sidebar (escritorio). CSS-only (<details>), sin JS. Solo
   tokens. El panel flota con borde (sin sombra hardcodeada; si se quiere
   drop-shadow habría que añadir un token --shadow-*).
   ========================================================================== */
.th-user-menu {
	position: relative;
}
.th-user-menu__summary {
	list-style: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	gap: var(--space-2);
}
.th-user-menu__summary::-webkit-details-marker { display: none; }

.th-user-menu__avatar img,
.th-user-menu__avatar .avatar {
	width: 32px;
	height: 32px;
	border-radius: var(--radius-full);
	display: block;
	object-fit: cover;
}
.th-user-menu__name {
	font-weight: 600;
	font-size: 0.9rem;
	color: var(--color-text);
}

/* Panel desplegable (flota; abre según contexto). */
.th-user-menu__panel {
	position: absolute;
	z-index: 100;
	min-width: 180px;
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: var(--space-2);
	background: var(--color-surface-2);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-md);
}
/* Sidebar (escritorio): abre HACIA ARRIBA, ancho de la columna. */
.th-feed-nav .th-user-menu__panel {
	bottom: calc(100% + var(--space-2));
	left: 0;
	right: 0;
}
/* Topbar (móvil): abre HACIA ABAJO, alineado a la derecha. */
.th-feed-topbar .th-user-menu__panel {
	top: calc(100% + var(--space-2));
	right: 0;
}

/* Ítems */
.th-user-menu__item {
	display: block;
	padding: var(--space-2) var(--space-3);
	border-radius: var(--radius-sm);
	font-size: 0.875rem;
	color: var(--color-text);
	text-decoration: none;
}
.th-user-menu__item:hover {
	background: var(--color-surface);
	text-decoration: none;
}
.th-user-menu__item--danger { color: var(--color-danger); }
.th-user-menu__item--danger:hover {
	background: color-mix(in srgb, var(--color-danger) 12%, transparent);
}

/* Bloque de usuario en el SIDEBAR: separador + look Slack (abajo del nav). */
.th-feed-nav .th-user-menu {
	margin-top: var(--space-3);
	padding-top: var(--space-3);
	border-top: 1px solid var(--color-border);
}
.th-feed-nav .th-user-menu__summary {
	padding: var(--space-2) var(--space-3);
	border-radius: var(--radius-md);
}
.th-feed-nav .th-user-menu__summary:hover { background: var(--color-surface-2); }

/* En la TOPBAR el bloque es compacto: solo avatar (el nombre se oculta). */
.th-feed-topbar .th-user-menu__name { display: none; }
