/* Wildflover - Topbar Navigation & User Menu */

.topbar {
  position: fixed;
  top: 16px;
  left: 50%;
  /* The topbar uses TWO axes of transform:
       · translateX(-50%) → horizontal centring.
       · translateY(--maki-tb-y) → driven by JS to slide the
         bar up off-screen on scroll-down (smart auto-hide).
     Both have to live in the same `transform` declaration
     or one would clobber the other.  `--maki-tb-y` defaults
     to 0 so untouched pages render exactly as before. */
  --maki-tb-y: 0px;
  transform: translate(-50%, var(--maki-tb-y));
  z-index: 100;
  width: calc(100% - 40px);
  /* MUST match `.db-shell { max-width }` in dashboard.css —
     otherwise the topbar brand sits at a different horizontal
     anchor than the dashboard sidebar (94px offset on a
     1920px monitor, looks like a hanging chad). Whenever the
     dashboard shell width changes, this token follows. */
  max-width: 1900px;
  /* Soft slide for the show/hide transition — anything
     longer feels laggy on long scrolls, anything shorter
     reads as "snap" instead of "glide". */
  transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1),
              opacity   0.20s ease,
              background 0.20s ease,
              border-color 0.20s ease;
  will-change: transform;
}

/* Auto-hide state — applied by maki-topbar.js when the
   visitor scrolls down past the top reveal zone. */
.topbar.is-hidden {
  --maki-tb-y: -160%;
  opacity: 0;
  pointer-events: none;
}

.topbar.scrolled { top: 12px; }

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Inner padding deliberately mirrors `.db-shell`'s
     horizontal padding (20px left / 32px right). That way
     the brand glyph sits at exactly the same X coordinate
     as the dashboard sidebar's left edge — no more
     hanging-chad misalignment when the bar floats above
     the dashboard. */
  padding: 0 14px 0 20px;
  height: 66px;
  /* solid + high-alpha background — no backdrop-filter, far cheaper on scroll */
  background: rgba(10,18,31,0.92);
  border: 1px solid rgba(186,224,255,0.10);
  border-radius: 20px;
  box-shadow:
    0 10px 36px rgba(5,10,20,0.50),
    inset 0 1px 0 rgba(186,224,255,0.08),
    0 0 0 1px rgba(186,224,255,0.02);
}

/* Left cluster: brand + language toggle */
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Brand - Maki */
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.topbar-brand:hover { opacity: 0.92; transform: translateY(-1px); }

.topbar-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background-image: url('../brand/maki-128.png');
  background-size: cover;
  background-position: center;
  position: relative;
  flex-shrink: 0;
  box-shadow:
    0 4px 14px rgba(34,211,238,0.30),
    inset 0 0 0 1px rgba(165,243,252,0.25);
}

.topbar-brand-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, transparent 60%, rgba(34,211,238,0.12));
  pointer-events: none;
}

.topbar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.topbar-brand-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.topbar-brand-domain {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  color: var(--ice-3);
  letter-spacing: 0.4px;
  margin-top: 2px;
  opacity: 0.75;
}

/* Center links */
.topbar-center {
  display: flex;
  align-items: center;
  gap: 4px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.topbar-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 11px;
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  text-decoration: none;
  position: relative;
}

.topbar-link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--ice-3);
  opacity: 0.7;
  transition: opacity 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.topbar-link-icon svg { width: 100%; height: 100%; }

.topbar-link:hover {
  color: var(--text-primary);
  background: rgba(186,224,255,0.06);
}

.topbar-link:hover .topbar-link-icon {
  color: var(--accent);
  opacity: 1;
  transform: translateY(-1px);
}

/* subtle animated underline on hover */
.topbar-link::after {
  content: '';
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 5px;
  height: 1.5px;
  border-radius: 1px;
  background: linear-gradient(90deg, transparent, var(--ice-3), transparent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.25s ease;
  opacity: 0.7;
}
.topbar-link:hover::after { transform: scaleX(1); }

.topbar-link.is-new {
  position: relative;
}
.topbar-link.is-new::before {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ice-4);
  box-shadow: 0 0 8px var(--ice-4);
}

/* Actions */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Language toggle (EN / TR) — segmented pill at the brand cluster */
.topbar-lang {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background: rgba(186,224,255,0.05);
  border: 1px solid rgba(186,224,255,0.10);
  border-radius: 999px;
  gap: 2px;
  position: relative;
}
/* Soft divider rule between the brand wordmark and the toggle —
   only when the pill sits in the left cluster on /home. */
.topbar-left .topbar-lang::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 25%;
  bottom: 25%;
  width: 1px;
  background: rgba(186,224,255,0.10);
  pointer-events: none;
}
.topbar-lang-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  /* compositor-only — no paint-heavy shadow swaps on hover */
  transition: color 0.15s ease, background 0.15s ease;
}
.topbar-lang-btn:hover { color: var(--text-secondary); }
.topbar-lang-btn.is-active {
  background: linear-gradient(135deg, var(--ice-3), var(--ice-5));
  color: #061121;
  box-shadow: 0 4px 12px rgba(34,211,238,0.30);
}

.topbar-login {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 11px;
  transition: color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  text-decoration: none;
}

.topbar-login:hover {
  color: var(--text-primary);
  background: rgba(186,224,255,0.06);
}

.topbar-login .topbar-link-icon { color: var(--ice-3); opacity: 0.7; }
.topbar-login:hover .topbar-link-icon { color: var(--accent); opacity: 1; transform: translateX(1px); }

.topbar-signup {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px 9px 20px;
  background: linear-gradient(135deg, #ecfeff 0%, #67e8f9 50%, #06b6d4 100%);
  color: #061121;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 11px;
  text-decoration: none;
  /* compositor-only hover */
  transition: transform 0.2s ease;
  box-shadow:
    0 6px 18px rgba(34,211,238,0.45),
    inset 0 1px 0 rgba(255,255,255,0.55);
  letter-spacing: 0.1px;
}

.topbar-signup-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}
.topbar-signup-icon svg { width: 100%; height: 100%; }

.topbar-signup:hover {
  transform: translateY(-1px);
  color: #061121;
}
.topbar-signup:hover .topbar-signup-icon { transform: translateX(2px); }

/* "Back to home" link — used by the unified topbar on every
   non-home page (login, register, verify, dashboard, terms,
   privacy, maintenance). Lighter than the brand signup so it
   reads as secondary navigation, not a CTA. */
.topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: 11px;
  text-decoration: none;
  transition: color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}
.topbar-back:hover {
  color: var(--text-primary);
  background: rgba(186,224,255,0.06);
}
.topbar-back-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: var(--ice-3);
  opacity: 0.8;
  transition: transform 0.18s ease, color 0.18s ease;
}
.topbar-back-icon svg { width: 100%; height: 100%; }
.topbar-back:hover .topbar-back-icon {
  color: var(--accent);
  transform: translateX(-2px);
}

/* ═══ Topbar User Menu ═══ */
.topbar-user { position: relative; }

.topbar-user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 16px 5px 5px;
  border-radius: 50px;
  background: rgba(186,224,255,0.06);
  border: 1px solid rgba(186,224,255,0.10);
  color: #fff;
  cursor: pointer;
  /* compositor-only — was `all 0.25s` which forced style recalc
     on every hover / focus / state flip */
  transition: background 0.14s ease, border-color 0.14s ease;
  font-family: inherit;
  font-size: 13.5px;
}

.topbar-user-btn:hover,
.topbar-user-btn.active {
  background: rgba(186,224,255,0.10);
  border-color: rgba(186,224,255,0.20);
}

.topbar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(96,165,250,0.45);
}

.topbar-user-avatar-default {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #93C5FD, #3B82F6);
  color: #061121;
  font-weight: 700;
  font-size: 14px;
}

.topbar-user-name {
  font-weight: 500;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-user-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  height: 12px;
  color: rgba(255,255,255,0.4);
  transition: transform 0.16s ease;
}
.topbar-user-chevron svg { width: 100%; height: 100%; }

.topbar-user-btn.active .topbar-user-chevron {
  transform: rotate(180deg);
}

/* Dropdown
   Open/close perf strategy:
   • Compositor-only properties (opacity + transform). visibility
     is toggled with `0s` so it flips synchronously alongside
     opacity — no perceptible delay when opening.
   • 130ms duration with a snappy easing; the previous 200ms +
     `transition: all` made the menu feel sluggish (a noticeable
     "beat" between click and reveal). 130ms is right at the
     human reaction-time floor — clicks feel instant.
   • Heavy paint properties (shadow, blur, border) stay static;
     they only repaint once when the dropdown is rasterised on
     first open. */
.topbar-dropdown {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  width: 270px;
  background: rgba(10,18,31,0.98);
  border: 1px solid rgba(186,224,255,0.10);
  border-radius: 18px;
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.985);
  transform-origin: top right;
  transition:
    opacity   0.13s ease-out,
    transform 0.13s cubic-bezier(0.2, 0.7, 0.3, 1),
    visibility 0s linear 0.13s;
  z-index: 1000;
  box-shadow:
    0 24px 64px rgba(0,0,0,0.55),
    0 0 0 1px rgba(186,224,255,0.04);
}

.topbar-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  /* On open, swap visibility immediately so the panel is hit-
     testable while the transition runs. */
  transition:
    opacity   0.13s ease-out,
    transform 0.13s cubic-bezier(0.2, 0.7, 0.3, 1),
    visibility 0s;
}

.topbar-dropdown-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
}

.topbar-dropdown-header .topbar-user-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.topbar-dropdown-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}

.topbar-dropdown-username {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}

.topbar-dropdown-divider {
  height: 1px;
  background: rgba(186,224,255,0.08);
  margin: 4px 0;
}

.topbar-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  /* keep compositor-only — used to be `all 0.2s` */
  transition: background 0.12s ease, color 0.12s ease;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  text-decoration: none;
}

.topbar-dropdown-item i,
.topbar-dropdown-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  text-align: center;
  font-size: 13px;
  color: rgba(255,255,255,0.35);
  transition: color 0.12s ease;
  flex-shrink: 0;
}
.topbar-dropdown-icon svg { width: 100%; height: 100%; }

.topbar-dropdown-item:hover {
  background: rgba(186,224,255,0.08);
  color: #fff;
}

.topbar-dropdown-item:hover i,
.topbar-dropdown-item:hover .topbar-dropdown-icon { color: var(--accent); }

.topbar-dropdown-logout { color: rgba(248,113,113,0.85); }
.topbar-dropdown-logout:hover { background: rgba(248,113,113,0.1); color: #f87171; }
.topbar-dropdown-logout:hover i,
.topbar-dropdown-logout:hover .topbar-dropdown-icon { color: #f87171; }

/* Small "opens in new tab" hint next to View profile.
   Pushed all the way right with margin-left: auto so it sits
   in the empty space without crowding the label. */
.topbar-dropdown-meta {
  margin-left: auto;
  font-size: 11px;
  color: rgba(255,255,255,0.30);
  font-family: var(--font-mono, ui-monospace, monospace);
  letter-spacing: 0.3px;
  transition: color 0.12s ease, transform 0.12s ease;
}
.topbar-dropdown-item:hover .topbar-dropdown-meta {
  color: var(--accent);
  transform: translate(1px, -1px);
}

@media (max-width: 768px) {
  .topbar { width: calc(100% - 20px); top: 10px; }
  .topbar-inner { height: 54px; padding: 0 6px 0 14px; }
  .topbar-center { display: none; }
  .topbar-login { display: none; }
  .topbar-lang { display: none; }
  .topbar-brand-name { font-size: 17px; }
  .topbar-brand-domain { display: none; }
  .topbar-brand-mark { width: 30px; height: 30px; font-size: 15px; border-radius: 9px; }
  .topbar-user-name { display: none; }
  .topbar-user-btn { padding: 4px; }
  .topbar-user-chevron { display: none; }
  .topbar-dropdown { width: 240px; right: -8px; }
}
