/**
 * Auth Button — always visible in header bar, outside hamburger menu.
 * Shows "Login" when unauthenticated, user initials + logout dropdown when authenticated.
 * On both desktop and mobile: initials chip in header bar with click-to-dropdown logout.
 * Desktop: chip at far right of nav (inside nav-right as last child).
 * Mobile: chip pinned to top-right of nav bar, always visible.
 */

/* ── Mobile auth container (wraps button + dropdown) ── */
.mobile-auth-wrap {
  display: none; /* hidden by default */
  position: relative;
  align-items: center;
}

/* Desktop (≥769px): chip is inside nav-right, pushed to far right with margin-left auto.
   Initials + click-to-dropdown. */
@media (min-width: 769px) {
  .mobile-auth-wrap {
    display: flex !important;
    position: relative;
    align-items: center;
    margin-left: auto;
    margin-right: 0.5rem;
    flex-shrink: 0;
  }

  .mobile-auth-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
    min-width: 160px;
  }
}

/* Mobile (≤768px): chip is pinned to top-right of nav bar, ALWAYS visible
   (even when hamburger menu is closed). */
@media (max-width: 768px) {
  .mobile-auth-wrap {
    display: flex !important;
    position: absolute;
    top: 50%;
    right: 4.5rem; /* left of hamburger */
    transform: translateY(-50%);
    align-items: center;
    margin-right: 0;
    z-index: 260;
  }

  /* When hamburger menu IS open (nav-right.visible), show chip at top of dropdown */
  .nav-right.open .mobile-auth-wrap {
    position: static;
    transform: none;
    order: -1;
    margin-left: 0;
    justify-content: flex-end;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(0,255,136,0.14);
    margin-bottom: 0.5rem;
  }
}

/* Pages without hamburger that always show the login button */
.mobile-auth-wrap.always-visible {
  display: flex;
}

/* ── Medium desktop (769px–1400px): compress nav to prevent overflow of Subscribe button ── */
@media (min-width: 769px) and (max-width: 1400px) {
  /* Tighten gap across the whole nav-right */
  .nav-right { gap: 0.6rem !important; }
  /* Reduce font size slightly for all nav links */
  .nav-right a[style*="0.65rem"],
  .nav-right a[style*="0.63rem"] { font-size: 0.58rem !important; }
  /* Tighten subscribe button padding */
  .btn-subscribe { padding: 0.35rem 0.7rem !important; font-size: 0.58rem !important; }
}

/* ── Narrow desktop (769px–1100px): hide breadcrumb and live indicator ── */
@media (min-width: 769px) and (max-width: 1100px) {
  .nav-breadcrumb { display: none !important; }
  .live-indicator { display: none !important; }
}

/* ── Login button (unauthenticated state) ── */
#navLoginBtn {
  font-family: 'Space Mono', monospace;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.35rem 0.7rem;
  color: #e8edf2;
  background: none;
  border: 1px solid rgba(0, 255, 136, 0.3);
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#navLoginBtn:hover {
  background: rgba(0, 255, 136, 0.08);
  border-color: rgba(0, 255, 136, 0.5);
}

/* ── Dropdown (authenticated state) ── */
.mobile-auth-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: rgba(8, 11, 15, 0.97);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 255, 136, 0.14);
  padding: 0.6rem 0.8rem;
  z-index: 10001;
  min-width: 140px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.mobile-auth-dropdown.open {
  display: block;
}

.mobile-auth-dropdown-email {
  font-family: 'Space Mono', monospace;
  font-size: 0.55rem;
  color: #8a97a8;
  margin-bottom: 0.5rem;
  word-break: break-all;
  line-height: 1.4;
}

.mobile-auth-dropdown-logout {
  font-family: 'Space Mono', monospace;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #ff4455;
  background: none;
  border: 1px solid rgba(255, 68, 85, 0.25);
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  width: 100%;
  transition: all 0.15s;
}

.mobile-auth-dropdown-logout:hover {
  background: rgba(255, 68, 85, 0.08);
  border-color: rgba(255, 68, 85, 0.5);
}

/* ── Dropdown nav items (Settings, Alerts) ── */
.mobile-auth-dropdown-menu {
  list-style: none;
  margin: 0 0 0.4rem 0;
  padding: 0;
}

.mobile-auth-dropdown-item {
  display: block;
  font-family: 'Space Mono', monospace;
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #e8edf2;
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  transition: color 0.15s, background 0.15s;
  border-radius: 2px;
}

.mobile-auth-dropdown-item:hover {
  color: #00ff88;
  background: rgba(0, 255, 136, 0.07);
}

/* ── Nav-chip dropdown (desktop pages without .mobile-auth-wrap) ── */
.nav-chip-btn {
  font-family: 'Space Mono', monospace;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #000;
  background: #00ff88;
  border: none;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.nav-chip-btn:hover {
  opacity: 0.85;
}

.nav-chip-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: rgba(8, 11, 15, 0.97);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 255, 136, 0.14);
  padding: 0.6rem 0.8rem;
  z-index: 10001;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: navChipFadeIn 0.15s ease;
}

.nav-chip-dropdown.open {
  display: block;
}

@keyframes navChipFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.nav-chip-email {
  font-family: 'Space Mono', monospace;
  font-size: 0.55rem;
  color: #8a97a8;
  margin-bottom: 0.5rem;
  word-break: break-all;
  line-height: 1.4;
}

/* Fade-in for mobile dropdown too when it opens */
.mobile-auth-dropdown.open {
  animation: navChipFadeIn 0.15s ease;
}

/* ── iOS input zoom prevention ──────────────────────────────────────────────
   iOS Safari zooms the viewport when any input/textarea/select has font-size
   below 16px. Force 16px minimum on all form controls on mobile viewports.
   Visual sizing (padding, line-height) is separate from the font-size fix.
   ─────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  input, textarea, select {
    font-size: 16px !important;
  }
}
