/* =============================================================
   Shared Navigation — Road to D2D Mastery
   Include via <link rel="stylesheet" href="/components/nav.css">
   Pages provide their own :root vars; these are safe fallbacks.
   ============================================================= */

:root {
  --black:        #0A0A0A;
  --green:        #00E676;
  --green-dark:   #00c853;
  --white:        #F0F0F0;
  --gray:         #888;
  --gray-light:   #AAA;
  --border:       #242424;
  --border-light: #2E2E2E;
  --surface:      #151515;
  --yellow:       #F5C518;
  --font:         'Inter', sans-serif;
}

/* ===== NAV SHELL ===== */

nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: rgba(10, 10, 10, 0.9);
  border-bottom: 1px solid var(--border);
}

nav::before {
  content: '';
  position: absolute;
  inset: 0;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  z-index: -1;
  pointer-events: none;
}

/* ===== NAV INNER ===== */

.nav-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

/* ===== LOGO ===== */

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-icon { width: auto; height: 36px; }

.logo-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.01em;
}

.logo-text .accent { color: var(--green); }

/* ===== NAV LINKS ===== */

.nav-links {
  display: flex;
  gap: 18px;
  align-items: center;
}

.nav-links a {
  color: var(--gray);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: color 0.2s;
}

.nav-links a:hover { color: var(--white); }

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

/* ===== DROPDOWNS ===== */

.nav-dropdown { position: relative; }

.nav-dropdown-btn {
  background: none;
  border: none;
  color: var(--gray);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  transition: color 0.2s;
}

.nav-dropdown-btn:hover { color: var(--white); }

.nav-dropdown-arrow {
  font-size: 0.65rem;
  transition: transform 0.2s;
}

.nav-dropdown.open .nav-dropdown-arrow { transform: rotate(180deg); }

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 14px);
  left: 50%;
  transform: translateX(-50%);
  background: #111;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 8px;
  min-width: 160px;
  z-index: 1001;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

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

.nav-dropdown-menu a {
  display: block;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--gray-light);
  font-size: 0.82rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.nav-dropdown-menu a:hover {
  background: rgba(255,255,255,0.06);
  color: var(--white);
}

/* ===== GRIND LINK (yellow highlight) ===== */

.nav-grind-link {
  background: rgba(245,197,24,0.12) !important;
  color: var(--yellow) !important;
  border: 1px solid rgba(245,197,24,0.3);
  border-radius: 6px;
  padding: 5px 12px !important;
  font-weight: 700 !important;
  transition: background 0.2s, border-color 0.2s;
}

.nav-grind-link:hover {
  background: rgba(245,197,24,0.22) !important;
  border-color: rgba(245,197,24,0.5);
  color: var(--yellow) !important;
}

/* ===== AUTH SECTION ===== */

.nav-auth {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 8px;
}

.nav-home {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
  color: var(--gray-light);
  font-size: 1.2rem;
  text-decoration: none;
  transition: 0.2s;
  border: 1px solid transparent;
}

.nav-home:hover {
  background: rgba(255,255,255,0.1);
  color: var(--white);
  border-color: var(--border-light);
}

#btn-signin {
  background: none;
  border: 1px solid var(--border-light);
  color: var(--gray-light);
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 10px 18px;
  min-height: 44px;
  border-radius: 6px;
  cursor: pointer;
  transition: 0.2s;
  letter-spacing: 0.02em;
}

#btn-signin:hover {
  border-color: var(--green);
  color: var(--green);
}

#user-chip {
  display: none;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 4px 12px 4px 4px;
  cursor: pointer;
  transition: 0.2s;
}

#user-chip:hover {
  border-color: var(--border-light);
  background: #222;
}

#user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green) 0%, #00a854 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #000;
  overflow: hidden;
  flex-shrink: 0;
}

#user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#user-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--white);
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Mobile-only Sign In link — hidden on desktop, shown in hamburger menu */
.nav-mobile-signin { display: none; }

/* ===== HAMBURGER ===== */

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.menu-toggle span {
  display: block;
  width: 20px;
  height: 1.5px;
  background: var(--white);
  margin: 5px 0;
  transition: all 0.25s ease;
}

/* ===== BACK LINK BAR ===== */

.nav-back-link {
  max-width: 1120px;
  margin: 0 auto;
  padding: 6px 24px;
  font-size: 0.8rem;
}

.nav-back-link a {
  color: var(--gray);
  text-decoration: none;
  transition: color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-back-link a:hover { color: var(--white); }

/* =============================================================
   MOBILE (max-width: 768px)
   ============================================================= */

@media (max-width: 768px) {

  .nav-links { display: none; }
  .menu-toggle { display: block; }

  /* Hide Sign In button and home icon from top bar — they move into the menu */
  #btn-signin { display: none !important; }
  .nav-home   { display: none !important; }

  .nav-links.active {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 64px; left: 0; right: 0;
    bottom: 0;
    background: var(--black);
    padding: 20px 24px calc(40px + env(safe-area-inset-bottom, 0px));
    gap: 4px;
    border-top: 1px solid var(--border);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 1100;
    overscroll-behavior: contain;
  }

  .nav-links.active a {
    font-size: 1.1rem;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    color: var(--gray-light);
  }

  .nav-links.active a:last-child { border-bottom: none; }

  /* Dropdown buttons fill width, arrow hidden, menus always open */
  .nav-dropdown-btn {
    font-size: 1.1rem;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    color: var(--gray-light);
    width: 100%;
    justify-content: space-between;
  }

  .nav-dropdown-arrow { display: none; }

  .nav-dropdown-menu {
    display: block;
    position: static;
    transform: none;
    background: none;
    border: none;
    padding: 0 0 0 12px;
    box-shadow: none;
    min-width: unset;
    border-radius: 0;
  }

  .nav-dropdown-menu a {
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    padding: 10px 0;
  }

  .nav-dropdown-menu a:hover { background: none; }

  .nav-links.active .nav-grind-link {
    margin-top: 12px;
    padding: 14px 20px !important;
    text-align: center;
    border-bottom: none;
  }

  /* Sign In link inside hamburger menu */
  .nav-mobile-signin {
    display: block;
    margin-top: 16px;
    padding: 14px 20px !important;
    text-align: center;
    background: rgba(255,255,255,0.06) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: 8px !important;
    color: var(--white) !important;
    font-weight: 600 !important;
    font-size: 1rem !important;
    border-bottom: none !important;
  }

  /* Hamburger → X animation */
  .menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(4px, 4px);
  }
  .menu-toggle.active span:nth-child(2) { opacity: 0; }
  .menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
  }
}
