/* ════════════════════════════════════════════════════════════
   TOPNAV — Matching maishouai.top exactly
   · Outer: fixed top-0 z-50 pointer-events-none
   · Container: max-w-7xl mx-auto px-4 md:px-6
   · Nav: h-16 (default) → h-12 + glassmorphism (scrolled)
   ════════════════════════════════════════════════════════════ */

/* Override Bootstrap's prefers-reduced-motion: reduce rule.
   Bootstrap sets transition-duration: 0.01ms !important on ALL
   elements when reduced motion is enabled, which kills the nav
   glassmorphism transition. We restore it unconditionally. */
.topnav-container,
.topnav-inner {
  transition-duration: 0.7s !important;
}
/* Restore hamburger line transitions (Bootstrap/animations.css kills them) */
.topnav-mobile-toggle .hamb-line-top,
.topnav-mobile-toggle .hamb-line-mid,
.topnav-mobile-toggle .hamb-line-bot {
  transition-duration: 0.35s !important;
}

/* ── Outer fixed shell ── */
.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
}

/* ── Container: centers nav with max-width + padding ── */
.topnav-container {
  max-width: 80rem;                /* max-w-7xl = 1280px */
  margin: 0 auto;
  padding: 0 1rem;                 /* px-4 */
  pointer-events: auto;            /* clicks pass through header but land on nav */
  transition: max-width 700ms cubic-bezier(0.16, 1, 0.3, 1),
              padding 700ms cubic-bezier(0.16, 1, 0.3, 1);
}
@media (min-width: 768px) {
  .topnav-container {
    padding: 0 1.5rem;             /* md:px-6 */
  }
}

/* ════════════════════════════════════════════════════════════════
   Nav bar — default state (top of page)
   Only structural + size classes — NO background/blur/radius/shadow
   ════════════════════════════════════════════════════════════════ */
.topnav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;                    /* h-16 = 64px */
  padding: 0 0.5rem;               /* px-2 */
  transition: height 700ms cubic-bezier(0.16, 1, 0.3, 1),
              padding 700ms cubic-bezier(0.16, 1, 0.3, 1),
              border-radius 700ms cubic-bezier(0.16, 1, 0.3, 1),
              background-color 700ms cubic-bezier(0.16, 1, 0.3, 1),
              backdrop-filter 700ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 700ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ════════════════════════════════════════════════════════════════
   Nav bar — scrolled state (glassmorphism)
   BOTH container and nav change classes simultaneously
   ════════════════════════════════════════════════════════════════ */

/* Container narrows + gains top padding */
.topnav-container.is-scrolled {
  max-width: 52rem;                /* max-w-[52rem] = 832px */
  padding: 0.75rem 0.75rem 0;     /* pt-3 px-3 */
}

/* Nav shrinks + glassmorphism */
.topnav-inner.is-scrolled {
  height: 3rem;                    /* h-12 = 48px */
  padding-left: 1rem;              /* pl-4 → 16px */
  padding-right: 0.375rem;         /* pr-1.5 → 6px */
  border-radius: calc(var(--radius) * 2.4);  /* rounded-2xl = 28.8px */
  background-color: color-mix(in srgb, var(--background) 60%, transparent);
  backdrop-filter: blur(40px);     /* backdrop-blur-2xl */
  -webkit-backdrop-filter: blur(40px);
  box-shadow:
    0 2px 16px -6px rgba(0,0,0,0.08),
    0 0 0 0.5px color-mix(in srgb, var(--border) 50%, transparent);
}
[data-bs-theme="dark"] .topnav-inner.is-scrolled {
  box-shadow:
    0 2px 16px -6px rgba(0,0,0,0.4),
    0 0 0 0.5px color-mix(in srgb, var(--border) 50%, transparent);
}

/* ── Brand (logo + text) ── */
.topnav-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;             /* gap-2.5 */
  text-decoration: none;
  color: var(--foreground);
  flex-shrink: 0;
}
.topnav-brand:visited {
  color: var(--foreground);
}
.topnav-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem; height: 1.75rem; /* size-7 */
  border-radius: 1rem;             /* rounded-lg = 16px */
  flex-shrink: 0;
  overflow: hidden;
  transition: transform 300ms;
}
.topnav-brand:hover .topnav-logo {
  transform: scale(1.05);
}
.topnav-logo img {
  width: 100%; height: 100%;
  object-fit: contain;
  border-radius: var(--radius-lg);
}
.topnav-logo svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.topnav-brand-text {
  font-size: 0.875rem;           /* text-sm */
  font-weight: var(--fw-semibold);
  letter-spacing: -0.025em;      /* tracking-tight */
}

/* ── Desktop links container ── */
.topnav-links {
  display: none;
  align-items: center;
  gap: 0.125rem;
}
@media (min-width: 640px) {
  .topnav-links { display: flex; }
}

/* ── Nav links ── */
.topnav-link {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.75rem;  /* py-1.5 px-3 */
  border-radius: 1rem;      /* rounded-lg = 16px */
  font-size: 13px;
  font-weight: var(--fw-medium);
  color: var(--muted-foreground);
  text-decoration: none;
  white-space: nowrap;
  transition: color 200ms, background 200ms;
}
.topnav-link:hover {
  color: var(--foreground);
  background: var(--muted);
}
.topnav-link.active {
  color: var(--foreground);
}

/* ── Divider ── */
.topnav-divider {
  display: block;
  width: 1px;
  height: 1rem;
  margin: 0 0.5rem;
  background: color-mix(in srgb, var(--border) 40%, transparent);
  flex-shrink: 0;
}

/* ── Icon button (theme toggle, language, etc - matching shadcn) ── */
.topnav-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem; height: 2.25rem; /* h-9 w-9 = 36px */
  border-radius: 1rem;             /* rounded-lg = 16px */
  border: 1px solid transparent;
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
  transition: all 200ms;
  flex-shrink: 0;
  position: relative;
  outline: none;
  user-select: none;
  background-clip: padding-box;
}
.topnav-icon-btn:hover {
  background: var(--muted);
  color: var(--foreground);
}
[data-bs-theme="dark"] .topnav-icon-btn:hover {
  background: color-mix(in srgb, var(--muted) 50%, transparent);
}
.topnav-icon-btn:active {
  transform: translateY(1px);
}
.topnav-icon-btn:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent);
}
.topnav-icon-btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}
.topnav-icon-btn svg {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 1.2rem; height: 1.2rem;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  transition: all 0.3s ease;
}

/* ── Theme toggle sun/moon swap (matching shadcn animation) ── */
.topnav-icon-btn .theme-sun {
  transform: scale(1) rotate(0deg);
}
.topnav-icon-btn .theme-moon {
  transform: scale(0) rotate(90deg);
}
[data-bs-theme="dark"] .topnav-icon-btn .theme-sun {
  transform: scale(0) rotate(-90deg);
}
[data-bs-theme="dark"] .topnav-icon-btn .theme-moon {
  transform: scale(1) rotate(0deg);
}

/* ── Theme dropdown menu ── */
.theme-toggle-wrap {
  position: relative;
}
.theme-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 130px;
  padding: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  z-index: 100;
}
.theme-dropdown-menu.open {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.theme-opt {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.375rem 0.5rem;
  border: none;
  background: transparent;
  color: var(--foreground);
  font-size: 0.8125rem;
  cursor: pointer;
  border-radius: 0.5rem;
  text-align: left;
  transition: background 150ms;
}
.theme-opt:hover {
  background: var(--muted);
}
.theme-opt.active {
  background: var(--muted);
  font-weight: 500;
}
.theme-opt svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

/* ── Notification bell ── */
.notif-wrap {
  position: relative;
}
.notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid var(--background);
}
.notif-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 320px;
  max-height: 400px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  z-index: 100;
  overflow: hidden;
}
.notif-dropdown.open {
  display: block;
}
.notif-header {
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  color: var(--foreground);
}
.notif-list {
  max-height: 340px;
  overflow-y: auto;
}
.notif-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 150ms;
}
.notif-item:hover {
  background: var(--muted);
}
.notif-item:last-child {
  border-bottom: none;
}
.notif-item-title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--foreground);
  margin-bottom: 2px;
}
.notif-item-preview {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.notif-item-time {
  font-size: 0.6875rem;
  color: var(--muted-foreground);
  margin-top: 4px;
  opacity: 0.7;
}
.notif-item.is-top .notif-item-title::before {
  content: '📌 ';
}
.notif-empty {
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}
.notif-loading {
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

/* ── Desktop nav links container ── */
.topnav-desktop {
  display: none;
  align-items: center;
  gap: 0.125rem;
}
@media (min-width: 640px) {
  .topnav-desktop { display: flex; }
}
.topnav-desk-link {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  border-radius: 1rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-foreground);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s;
}
.topnav-desk-link:hover { color: var(--foreground); background: var(--muted); }
.topnav-desk-link.active { color: var(--foreground); }

/* ── Mobile actions (theme + hamburger) ── */
.topnav-mobile-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
@media (min-width: 640px) {
  .topnav-mobile-actions { display: none; }
}

/* ── Mobile login button (matching target) ── */
.topnav-mobile-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.5rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--foreground) !important;
  color: var(--background) !important;
  text-decoration: none;
  opacity: 0;
  transform: translateY(16px);
  will-change: transform, opacity;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.topnav-mobile-menu.open .topnav-mobile-login {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 350ms;
}
.topnav-mobile-login:visited { color: var(--background) !important; }
.topnav-mobile-login:hover { opacity: 0.9; }
.topnav-mobile-login:active { opacity: 0.8; }

/* ── Login / CTA button (matching maishouai.top's shadcn button) ── */
.topnav-login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;                    /* gap-1 */
  height: 2rem;                    /* h-8 */
  padding: 0 0.875rem;            /* px-3.5 */
  border-radius: 1rem;             /* rounded-lg = 16px */
  border: 1px solid transparent;
  background: var(--color-primary);
  color: var(--color-primary-fg);
  font-size: 0.75rem;             /* text-xs */
  font-weight: var(--fw-medium);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  outline: none;
  user-select: none;
  background-clip: padding-box;
  transition: all 200ms;
}
.topnav-login-btn:hover {
  background: color-mix(in srgb, var(--color-primary) 80%, transparent);
  color: var(--color-primary-fg);
}
.topnav-login-btn:visited {
  color: var(--color-primary-fg);
}
.topnav-login-btn:active {
  transform: translateY(1px);
}
.topnav-login-btn:focus-visible {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent);
}

/* ── Mobile hamburger (matching maishouai.top) ── */
.topnav-mobile-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 1rem;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  outline: none;
  user-select: none;
  background-clip: padding-box;
  transition: all 200ms;
}
.topnav-mobile-toggle:hover { background: var(--muted); }
.topnav-mobile-toggle:focus-visible { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent); }
.topnav-mobile-toggle:active {
  transform: scale(0.9);
}
@media (min-width: 640px) {
  .topnav-mobile-toggle { display: none; }
}
/* ── Hamburger lines: CSS transition-based morph (☰ ↔ ✕) ── */
.hamb-line-top, .hamb-line-mid, .hamb-line-bot {
  position: absolute;
  left: 0;
  right: 0;
  height: 1.5px;
  border-radius: 9999px;
  background: currentColor;
  will-change: transform, opacity;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.hamb-line-top { top: 3px; }
.hamb-line-mid { top: 7px; }
.hamb-line-bot { top: 11px; }

/* Open state: ☰ → ✕ */
.topnav-mobile-toggle.is-open .hamb-line-top {
  transform: translateY(4px) rotate(45deg);
}
.topnav-mobile-toggle.is-open .hamb-line-mid {
  opacity: 0;
}
.topnav-mobile-toggle.is-open .hamb-line-bot {
  transform: translateY(-4px) rotate(-45deg);
}


/* ── Mobile offcanvas menu ── */
.topnav-mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 40;
  background-color: color-mix(in srgb, var(--background) 98%, transparent);
  -webkit-backdrop-filter: blur(40px);
  backdrop-filter: blur(40px);
  pointer-events: none;
  transform: translateZ(0);
  will-change: opacity, backdrop-filter;
  opacity: 0;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              backdrop-filter 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.topnav-mobile-menu.open {
  pointer-events: auto;
  opacity: 1;
}
@media (min-width: 640px) { .topnav-mobile-menu { display: none !important; } }

.topnav-mobile-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.topnav-mobile-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.025em;
  color: var(--muted-foreground) !important;
  text-decoration: none;
  opacity: 0;
  transform: translateY(16px);
  will-change: transform, opacity;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.topnav-mobile-link.active {
  color: var(--foreground) !important;
}
.topnav-mobile-menu.open .topnav-mobile-link {
  opacity: 1;
  transform: translateY(0);
}
.topnav-mobile-menu.open .topnav-mobile-link:nth-child(1) { transition-delay: 100ms; }
.topnav-mobile-menu.open .topnav-mobile-link:nth-child(2) { transition-delay: 200ms; }
.topnav-mobile-menu.open .topnav-mobile-link:nth-child(3) { transition-delay: 300ms; }
.topnav-mobile-menu.open .topnav-mobile-link:nth-child(4) { transition-delay: 400ms; }
.topnav-mobile-menu.open .topnav-mobile-link:nth-child(5) { transition-delay: 500ms; }
.topnav-mobile-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 2.5rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--foreground);
  color: var(--background);
  text-decoration: none;
  transition: opacity 0.2s;
}
.topnav-mobile-btn:hover {
  opacity: 0.9;
}
.topnav-mobile-btn:active {
  opacity: 0.8;
}

/* Member nav login appears after its 5 links (last at 500ms) */
.topnav-mobile-menu.open .topnav-mobile-inner .topnav-mobile-login {
  transition-delay: 550ms;
}

/* ── Content offset for fixed header ── */
.page:not(.has-sidebar) .page-wrapper {
  padding-top: 4rem;               /* match h-16 nav height */
}
@media (max-width: 639px) {
  .page:not(.has-sidebar) .page-wrapper {
    padding-top: 3.5rem;
  }
}

/* ── Hide old Bootstrap header on public pages ── */
.page:not(.has-sidebar) .frontend-header.navbar { display: none; }

/* ── Alpine.js: hide until initialized ── */
[x-cloak] { display: none !important; }
