/* ===== navigation ===== */
.navbar {
  position: fixed;
  top: 24px;
  left: 24px;
  right: 24px;
  margin: 0 auto;
  max-width: 1100px;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 14px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 100;
  transition: background 0.3s ease, border-color 0.3s ease;
}

.logo-mark {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  text-decoration: none;
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.3px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}

.brand-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.15;
}

.tagline {
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.logo-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--logo-bg);
  color: var(--logo-fg);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px -4px rgba(0, 0, 0, 0.35);
}

.divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 auto;
}

.nav-links a,
.dropdown-toggle {
  position: relative;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: 999px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s, background 0.2s;
}

.nav-links a:hover,
.dropdown-toggle:hover,
.dropdown-toggle.active {
  color: var(--text);
  background: var(--hover);
}

.nav-links a.active {
  color: var(--text);
}

.nav-links a.active::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 4px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}

.dropdown-toggle.active::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 4px;
  height: 2px;
  border-radius: 2px;
  background: var(--text);
}

.dropdown-toggle::after {
  display: none;
}

.caret {
  display: inline-block;
  font-size: 0.85rem;
  line-height: 1;
  transition: transform 0.2s ease;
}

/* ===== Dropdown ===== */
.dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 180px;
  padding: 6px;
  border-radius: 16px;
  background: var(--menu-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
}

.dropdown:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown:hover .caret {
  transform: rotate(180deg);
}

.dropdown-menu a {
  display: block;
  padding: 9px 14px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.dropdown-menu a:hover {
  color: var(--text);
  background: var(--hover);
}

/* ===== Actions ===== */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.2s;
}

.theme-toggle:hover {
  background: var(--hover);
  transform: translateY(-2px);
}

.theme-toggle:focus,
.theme-toggle:focus-visible {
  outline: none;
}

.icon-sun { color: #facc15; }
.icon-moon { color: #3b82f6; }

.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

.btn-join {
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 999px;
  background: #ffffff;
  color: #000000;
  border: 1px solid #ffffff;
  white-space: nowrap;
  transition: transform 0.2s, box-shadow 0.25s;
}

.btn-join:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .btn-join {
  border-color: #111111;
}

/* ===== Auth area (name + sign out) ===== */
.nav-auth {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 2px;
}

.nav-user {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.btn-signout {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}

.btn-signout:hover {
  color: var(--text);
  border-color: var(--text);
}

/* ===== Welcome toast ===== */
.welcome-toast {
  position: fixed;
  top: 96px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(560px, calc(100vw - 48px));
  padding: 14px 18px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
  animation: welcome-in 0.35s ease;
}

.welcome-toast--hide {
  opacity: 0;
  transform: translateX(-50%) translateY(-10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.welcome-toast-close {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.welcome-toast-close:hover {
  color: var(--text);
  border-color: var(--text);
}

@keyframes welcome-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ===== Responsive ===== */
@media (max-width: 1150px) {
  .navbar { gap: 10px; padding: 10px 14px; }
  .nav-links a, .dropdown-toggle { padding: 10px 12px; }
}

@media (max-width: 1000px) {
  .tagline { display: none; }
}

@media (max-width: 880px) {
  .navbar {
    top: 14px;
    left: 14px;
    right: 14px;
    border-radius: 28px;
    gap: 8px;
    padding: 8px 12px;
  }
  .divider { display: none; }
  .brand { font-size: 1rem; letter-spacing: 0.2px; }

  /* Collapsed nav: only Home + More are rendered (see bar.js) */
  .nav-links {
    margin: 0;
    gap: 2px;
  }
  .nav-links a,
  .dropdown-toggle { padding: 8px 10px; font-size: 0.88rem; }

  /* More menu right-aligned so it stays on screen */
  .dropdown-menu { left: auto; right: 0; min-width: 200px; }

  /* Theme + Join pinned to the right edge */
  .nav-actions { margin-left: auto; }

  .btn-join { padding: 8px 16px; font-size: 0.85rem; }

  /* Compact auth area on small screens */
  .nav-user { display: none; }
  .btn-signout { padding: 6px 12px; font-size: 0.8rem; }
}

@media (max-width: 420px) {
  .navbar { gap: 6px; padding: 6px 10px; }
  .logo-dot { width: 30px; height: 30px; }
  .brand { font-size: 0.9rem; }
  .nav-links a,
  .dropdown-toggle { padding: 7px 8px; font-size: 0.84rem; }
  .theme-toggle { width: 34px; height: 34px; }
  .btn-join { padding: 7px 12px; font-size: 0.82rem; }
  .dropdown-menu { min-width: 180px; }
}

/* Touch devices (or small screens): dropdown opens on tap via .open */
@media (max-width: 880px), (hover: none) {
  .dropdown:hover .dropdown-menu {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
  }
  .dropdown:hover .caret { transform: rotate(0deg); }
  .dropdown.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }
  .dropdown.open .caret { transform: rotate(180deg); }
}
