/* ═══════════════════════════════════════════════════════════════════
 * topnav.css — Shared editorial pill nav (matches home.html design)
 *
 * All selectors prefixed with .topnav-v2 so legacy per-page nav CSS
 * (.nav-link, .nav-links, etc.) doesn't bleed in.
 *
 * On home, the nav lives inside .hero-stage which inverts colors to
 * white-on-glass over the hero photo. Off-hero pages get the default
 * ink-on-cream palette.
 * ═══════════════════════════════════════════════════════════════════ */

.topnav-v2 {
  position: relative;
  /* Form a stacking context above the rest of the page so the dropdowns
   * always paint over hero photocards / sticky cards / map tiles. The
   * home page's .hero-stage > * { z-index: 1; } would otherwise put the
   * nav at the same z as the hero content, and document order would
   * put the hero on top — clipping the dropdown clicks. The nav.topnav-v2
   * compound selector below bumps specificity so this wins against
   * page-level inline overrides. */
  z-index: 100;
  background: transparent;
  border-bottom: none;
  --tn-ink:        var(--ink, #131318);
  --tn-bg:         var(--bg, #faf8f3);
  --tn-ink-muted:  var(--ink-muted, #6c6a72);
  --tn-pill-bg:    rgba(255,255,255,0.55);
  --tn-pill-border:rgba(255,255,255,0.65);
  --tn-pill-shadow:0 1px 0 rgba(255,255,255,0.8) inset, 0 8px 24px rgba(20,30,50,0.06), 0 1px 2px rgba(20,30,50,0.04);
}

/* Inside hero-stage: invert to white-on-glass */
.hero-stage .topnav-v2 {
  --tn-ink: #fff;
  --tn-ink-muted: rgba(255,255,255,0.7);
  --tn-pill-bg: rgba(255,255,255,0.14);
  --tn-pill-border: rgba(255,255,255,0.26);
  --tn-pill-shadow: none;
}

.topnav-v2 .nav-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.1rem 1.25rem;
  height: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
}

.topnav-v2 .logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
}
.topnav-v2 .logo-icon {
  display: flex;
  width: 38px; height: 38px;
  background: url("/img/hogaresrd-icon.png") center / cover no-repeat;
  border-radius: 10px;
  overflow: hidden;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.topnav-v2 .logo-icon svg { display: none; }
.topnav-v2 .logo-text {
  font-family: var(--sans, system-ui, -apple-system, sans-serif);
  font-size: 1.05rem; font-weight: 700;
  color: var(--tn-ink); letter-spacing: -0.02em;
  font-style: normal;
}
.topnav-v2 .logo-text em { font-style: normal; color: var(--tn-ink); opacity: 0.85; }

.topnav-v2 .nav-center { display: flex; justify-content: center; min-width: 0; }
.topnav-v2 .nav-links {
  display: inline-flex; align-items: center; gap: 0.15rem;
  background: var(--tn-pill-bg);
  border: 1px solid var(--tn-pill-border);
  box-shadow: var(--tn-pill-shadow);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border-radius: var(--r-pill, 999px);
  padding: 5px;
  flex: 0 0 auto;
}
.topnav-v2 .nav-link {
  text-decoration: none;
  color: var(--tn-ink);
  font-family: var(--sans, system-ui, -apple-system, sans-serif);
  font-weight: 500; font-size: 0.88rem;
  padding: 0.5rem 1rem; border-radius: var(--r-pill, 999px);
  transition: all 0.15s; white-space: nowrap;
  opacity: 0.78;
}
.topnav-v2 .nav-link:hover { opacity: 1; }
.topnav-v2 .nav-link.active {
  background: var(--tn-ink);
  color: var(--tn-bg);
  opacity: 1;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
/* Inside hero-stage active link uses white pill on dark text */
.hero-stage .topnav-v2 .nav-link.active {
  background: #fff;
  color: #111;
}

.topnav-v2 .nav-actions { display: flex; align-items: center; gap: 0.55rem; flex-shrink: 0; }

/* Defensive: if any older copy of i18n.js still injects #langToggle,
   suppress it. The toggle was retired — browsers translate natively. */
.topnav-v2 #langToggle { display: none !important; }

/* Glass icon buttons */
.topnav-v2 .nav-icon {
  position: relative;
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--tn-pill-bg);
  border: 1px solid var(--tn-pill-border);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: var(--tn-pill-shadow);
  border-radius: 50%;
  color: var(--tn-ink);
  cursor: pointer;
  transition: transform 0.15s;
  text-decoration: none;
}
.topnav-v2 .nav-icon:hover { transform: translateY(-1px); }
.topnav-v2 .nav-icon svg { width: 16px; height: 16px; fill: currentColor; }
.topnav-v2 .nav-icon-dot {
  position: absolute; top: 7px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #E2483A;
  border: 2px solid rgba(255,255,255,0.95);
}

/* User chip */
.topnav-v2 .nav-user {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.2rem 0.55rem 0.2rem 0.25rem;
  background: transparent;
  border: none; cursor: pointer;
  font-family: var(--sans, system-ui, -apple-system, sans-serif);
  color: var(--tn-ink);
  transition: opacity 0.15s;
}
.topnav-v2 .nav-user:hover { opacity: 0.78; }
.topnav-v2 .nav-user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #B8A07E, #6E5847);
  color: #fff; font-size: 0.82rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(20,30,50,0.12);
}
.topnav-v2 .nav-user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.topnav-v2 .nav-user-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.18; }
.topnav-v2 .nav-user-name { font-size: 0.85rem; font-weight: 600; color: var(--tn-ink); }
.topnav-v2 .nav-user-mail { font-size: 0.72rem; color: var(--tn-ink-muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topnav-v2 .nav-user-caret { width: 12px; height: 12px; opacity: 0.5; fill: currentColor; }

/* Guest buttons */
.topnav-v2 .btn-tn-ghost,
.topnav-v2 .btn-tn-dark {
  display: inline-flex; align-items: center;
  height: 38px; padding: 0 0.95rem;
  border-radius: 999px;
  font-family: var(--sans, system-ui, -apple-system, sans-serif);
  font-size: 0.85rem; font-weight: 600;
  text-decoration: none;
  transition: all 0.15s;
  cursor: pointer;
}
.topnav-v2 .btn-tn-ghost {
  color: var(--tn-ink);
  background: var(--tn-pill-bg);
  border: 1px solid var(--tn-pill-border);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}
.topnav-v2 .btn-tn-dark {
  background: var(--tn-ink);
  color: var(--tn-bg);
  border: 1px solid var(--tn-ink);
}
.hero-stage .topnav-v2 .btn-tn-dark {
  background: #fff;
  color: #111;
  border-color: #fff;
}
.topnav-v2 .btn-tn-ghost:hover { transform: translateY(-1px); }
.topnav-v2 .btn-tn-dark:hover { transform: translateY(-1px); }

/* ── Dropdown panels (account / notifications / messages) ────────────────
 * Hard-coded colors (not CSS vars) so the panel reads correctly even when
 * the parent context inverts colors (e.g. inside .hero-stage). */
.topnav-v2 .nav-pop {
  position: absolute;
  right: 1.25rem;
  top: 70px;
  background: #fff;
  color: #131318;
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.06);
  z-index: 1000;
  font-family: var(--sans, system-ui, -apple-system, sans-serif);
  overflow: hidden;
}
.topnav-v2 .nav-pop[hidden] { display: none; }

/* Account menu — richer layout: header card + iconed rows + section dividers */
.topnav-v2 .nav-user-menu {
  width: 320px;
  padding: 0;
  display: block;
  box-shadow: 0 24px 56px rgba(15,23,42,0.16), 0 4px 14px rgba(15,23,42,0.06);
  border: 1px solid rgba(15,23,42,0.06);
}
.topnav-v2 .nav-um-head {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid rgba(15,23,42,0.08);
}
.topnav-v2 .nav-um-avatar {
  position: relative;
  flex-shrink: 0;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #B8A07E, #6E5847);
  color: #fff; font-size: 0.95rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  /* No overflow:hidden here — the presence badge needs to overflow the
     circle. The img clips itself via its own border-radius below. */
}
.topnav-v2 .nav-um-avatar img,
.topnav-v2 .nav-um-avatar > span:not(.nav-um-presence) {
  width: 100%; height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
}
.topnav-v2 .nav-um-presence {
  position: absolute;
  bottom: -1px; right: -1px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #22C55E;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.22);
  z-index: 1;
}
.topnav-v2 .nav-um-id { display: flex; flex-direction: column; min-width: 0; }
.topnav-v2 .nav-um-name {
  font-size: 0.98rem; font-weight: 700; color: #131318;
  line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topnav-v2 .nav-um-status {
  font-size: 0.82rem; color: #6c6a72;
  margin-top: 0.15rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topnav-v2 .nav-um-section {
  padding: 0.4rem 0.55rem;
  border-bottom: 1px solid rgba(15,23,42,0.08);
}
.topnav-v2 .nav-um-section:last-child { border-bottom: none; }
.topnav-v2 .nav-um-item {
  display: flex; align-items: center; gap: 0.85rem;
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: none; background: transparent;
  font-family: inherit; font-size: 0.92rem;
  color: #131318;
  text-decoration: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}
.topnav-v2 .nav-um-item:hover { background: rgba(15,23,42,0.05); }
.topnav-v2 .nav-um-icon {
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  color: #4a4a52;
}
.topnav-v2 .nav-um-icon svg { width: 18px; height: 18px; }
.topnav-v2 .nav-um-label { flex: 1; min-width: 0; }
.topnav-v2 .nav-um-meta {
  font-size: 0.78rem; color: #8a8a92;
  display: inline-flex; align-items: center; gap: 0.25rem;
}
.topnav-v2 .nav-um-meta svg { width: 14px; height: 14px; }
.topnav-v2 .nav-um-badge {
  font-size: 0.7rem; font-weight: 700;
  color: #5a3ec8; background: #ece6ff;
  padding: 0.18rem 0.5rem; border-radius: 999px;
}
.topnav-v2 .nav-um-item.danger { color: #d44a3a; }
.topnav-v2 .nav-um-item.danger .nav-um-icon { color: #d44a3a; }
.topnav-v2 .nav-um-item.danger:hover { background: rgba(212,74,58,0.08); }

/* Notification + messages dropdowns share the panel chrome */
.topnav-v2 .nav-notif-menu,
.topnav-v2 .nav-msg-menu {
  width: 360px;
  max-width: calc(100vw - 2rem);
  display: flex;
  flex-direction: column;
  max-height: 480px;
}
.topnav-v2 .nav-pop-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1rem 0.65rem;
  border-bottom: 1px solid rgba(19,19,24,0.06);
  color: #131318;
}
.topnav-v2 .nav-pop-title { font-size: 0.95rem; font-weight: 700; color: #131318; }
.topnav-v2 .nav-pop-mark {
  background: none; border: none; cursor: pointer;
  font-family: inherit; font-size: 0.78rem;
  color: #6c6a72;
  padding: 0.25rem 0.4rem; border-radius: 6px;
}
.topnav-v2 .nav-pop-mark:hover { background: rgba(19,19,24,0.06); color: #131318; }
.topnav-v2 .nav-pop-mark[disabled] { opacity: 0.4; cursor: default; }
.topnav-v2 .nav-pop-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.35rem 0;
}
.topnav-v2 .nav-pop-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: #6c6a72;
  font-size: 0.86rem;
}
.topnav-v2 .nav-pop-item {
  display: flex; align-items: flex-start; gap: 0.7rem;
  padding: 0.65rem 1rem;
  text-decoration: none;
  color: #131318;
  border-left: 3px solid transparent;
  transition: background 0.12s;
}
.topnav-v2 .nav-pop-item:hover { background: rgba(19,19,24,0.04); }
.topnav-v2 .nav-pop-item.unread { border-left-color: #E2483A; background: rgba(226,72,58,0.04); }
.topnav-v2 .nav-pop-icon {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #B8A07E, #6E5847);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  overflow: hidden;
}
.topnav-v2 .nav-pop-icon img { width: 100%; height: 100%; object-fit: cover; }
.topnav-v2 .nav-pop-icon.emoji { background: rgba(19,19,24,0.06); color: inherit; font-size: 16px; }
.topnav-v2 .nav-pop-body { flex: 1; min-width: 0; }
.topnav-v2 .nav-pop-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.15rem;
}
.topnav-v2 .nav-pop-name {
  font-size: 0.86rem; font-weight: 600; color: #131318;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topnav-v2 .nav-pop-time {
  font-size: 0.72rem;
  color: #6c6a72;
  flex-shrink: 0;
}
.topnav-v2 .nav-pop-text {
  font-size: 0.83rem; line-height: 1.35;
  color: #4a4a52;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.topnav-v2 .nav-pop-badge {
  flex-shrink: 0;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: #E2483A;
  color: #fff;
  border-radius: 9px;
  font-size: 0.68rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.topnav-v2 .nav-pop-foot {
  border-top: 1px solid rgba(19,19,24,0.06);
  padding: 0.5rem;
}
.topnav-v2 .nav-pop-foot a {
  display: block;
  text-align: center;
  padding: 0.55rem;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.84rem; font-weight: 600;
  color: #131318;
}
.topnav-v2 .nav-pop-foot a:hover { background: rgba(19,19,24,0.06); }

/* Mobile collapse — drop center pill + email line + ghost CTA */
@media (max-width: 880px) {
  .topnav-v2 .nav-inner { grid-template-columns: auto 1fr auto; gap: 0.5rem; }
  .topnav-v2 .nav-center { display: none; }
  .topnav-v2 .nav-user-meta { display: none; }
  .topnav-v2 .btn-tn-ghost { display: none; }
}

/* When the topnav is the FIRST element on a page (no hero), give it
   a subtle border + cream backdrop so it has presence. */
body > .topnav-v2:first-child {
  border-bottom: 1px solid rgba(19,19,24,0.06);
}

/* Higher-specificity z-index override for hero-stage pages (home).
   home.html sets `.hero-stage > * { z-index: 1; }` which would equal
   our base `.topnav-v2 { z-index: 100; }` rule but win by source
   order. Compound selector lifts specificity so dropdowns always
   stack above hero photocards. */
.hero-stage > nav.topnav-v2 { z-index: 100; }
