/* ========================================
   NAVIGATION.CSS - Header Navigation Styles
   ======================================== */

.header {
  position: sticky;
  top: 0;
  background-color: rgba(24, 24, 27, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: var(--border-width) solid var(--color-border);
  box-shadow: var(--shadow-md);
  z-index: var(--z-index-sticky);
  display: flex;
  flex-direction: column;
}

/* ===== NAVBAR ===== */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: var(--spacing-md) var(--container-padding) 0;
  max-width: var(--container-max-width);
  margin: 0 auto;
  width: 100%;
  flex-wrap: wrap;
}

/* ===== BRAND / LOGO ===== */
.navbar-brand {
  flex-shrink: 0;
  order: 1;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  color: var(--color-text);
  text-decoration: none;
  font-family: var(--font-family-display);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  transition: color var(--transition-fast);
}

.logo:hover {
  color: var(--color-primary);
}

.logo-img {
  height: 40px;
  width: auto;
}

.logo-text {
  font-size: var(--font-size-xl);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== NAVBAR MENU (TABS) ===== */
.navbar-menu {
  display: flex;
  align-items: stretch;
  gap: 3px;
  list-style: none;
  width: auto;
  order: 2;
  margin: 0;
  padding: 0;
  margin-left: auto;
  align-self: flex-end;
}

.navbar-item {
  position: relative;
  flex: 0 1 auto;
  display: flex;
  align-items: stretch;
}

/* Tab Button Styling - "Connected" state */
.navbar-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md) var(--spacing-lg);
  height: 48px;
  color: var(--color-text);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  background-color: var(--color-bg-card);
  border: 2px solid var(--color-border);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
}

/* Triangular arrow notch at bottom - part of border (only for dropdowns) */
.navbar-item.dropdown .navbar-link::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--color-border);
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
  filter: drop-shadow(0 0 0 transparent);
}

/* Inner triangle (background fill) */
.navbar-item.dropdown .navbar-link::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--color-bg-card);
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1), border-top-color 0.4s;
  z-index: 2;
}

/* Angled border segments on sides of arrow */
.navbar-item.dropdown .navbar-link {
  overflow: visible;
}

.navbar-item.dropdown::before {
  content: '';
  position: absolute;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid var(--color-border);
  border-right: 10px solid var(--color-border);
  border-bottom: 8px solid transparent;
  z-index: 0;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar-item.dropdown:hover::before {
  opacity: 0;
}

/* Tab "Disconnect" animation on hover */
.navbar-link:hover,
.navbar-item:hover .navbar-link {
  transform: translateY(-8px);
  border-radius: var(--radius-lg);
  background-color: var(--color-bg-elevated);
  color: var(--color-primary);
  box-shadow: var(--shadow-lg);
  z-index: 10;
}

/* Hide arrow triangles on hover */
.navbar-item.dropdown:hover .navbar-link::before,
.navbar-item.dropdown:hover .navbar-link::after {
  opacity: 0;
}

/* Update inner triangle color on hover */
.navbar-item.dropdown .navbar-link:hover::after {
  border-top-color: var(--color-bg-elevated);
}

.navbar-link:focus {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* Ensure dropdown button inherits all tab styles */
.navbar-link.dropdown-toggle {
  width: 100%;
  text-align: left;
  font-family: inherit;
}

/* ===== MOBILE TOGGLE (Hamburger) ===== */
.navbar-toggle {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 30px;
  height: 24px;
  background-color: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  order: 3;
  margin-left: auto;
}

.hamburger-line {
  display: block;
  width: 100%;
  height: 3px;
  background-color: var(--color-text);
  border-radius: var(--radius-sm);
  transition: transform var(--transition-normal), opacity var(--transition-normal);
}

/* Hamburger Animation (when active) */
.navbar-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
  transform: translateY(10.5px) rotate(45deg);
}

.navbar-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) {
  opacity: 0;
}

.navbar-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) {
  transform: translateY(-10.5px) rotate(-45deg);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 767px) {
  .navbar {
    flex-wrap: wrap;
    align-items: center;
    padding-top: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    position: relative;
    z-index: 1002;
    background-color: var(--color-bg-card);
  }

  .navbar-brand {
    display: flex;
    align-items: center;
    position: relative;
    z-index: 1002;
  }

  .navbar-toggle {
    display: flex;
    order: 3;
    margin-top: 0;
    position: relative;
    z-index: 1002;
  }

  .navbar-menu {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--color-bg-card);
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 0;
    padding-top: 80px;
    z-index: 1000;
    overflow-y: auto;
  }

  .navbar-menu--active {
    display: flex;
  }

  .navbar-item {
    width: 100%;
    border-bottom: 2px solid var(--color-border);
    flex-direction: column;
    display: flex;
    align-items: stretch;
  }

  .navbar-link {
    width: 100%;
    padding: var(--spacing-xl);
    font-size: var(--font-size-lg);
    text-align: left;
    background-color: var(--color-bg-card);
    border: none;
    border-radius: 0;
    margin: 0;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  /* Arrow indicator for dropdowns */
  .navbar-item.dropdown .navbar-link::after {
    content: '▼';
    font-size: var(--font-size-md);
    color: var(--color-text);
    transition: transform var(--transition-normal);
    opacity: 1 !important;
    position: static !important;
    transform: none !important;
    width: auto !important;
    height: auto !important;
    border: none !important;
    margin-left: auto;
  }

  /* Arrow points up when dropdown is open */
  .navbar-item.dropdown .navbar-link[aria-expanded="true"]::after {
    transform: rotate(180deg) !important;
  }

  .navbar-item.dropdown .navbar-link::before {
    display: none;
  }

  /* Remove tab-style "disconnect" animation on mobile */
  .navbar-link:hover,
  .navbar-item:hover .navbar-link {
    transform: none;
    background-color: transparent;
    border-radius: 0;
  }

  /* Left border indicator for active dropdown items */
  .navbar-item.dropdown .navbar-link[aria-expanded="true"] {
    border-left: 4px solid var(--color-primary);
    padding-left: calc(var(--spacing-xl) - 4px);
    background-color: transparent;
    position: relative;
  }

  /* Dropdown menus in mobile - accordion style */
  .dropdown-menu {
    position: static;
    width: 100%;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background-color: var(--color-bg-elevated);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .dropdown-menu--active {
    max-height: 500px;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Cascade animation keyframes */
  @keyframes cascadeIn {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .dropdown-item {
    padding: var(--spacing-lg) var(--spacing-xl);
    padding-left: calc(var(--spacing-xl) * 2);
    background-color: var(--color-bg-elevated);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
  }

  .dropdown-item-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  /* Apply cascade animation when dropdown is active */
  .dropdown-menu--active .dropdown-item {
    animation: cascadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  }

  /* Staggered delays for waterfall effect */
  .dropdown-menu--active .dropdown-item:nth-child(1) {
    animation-delay: 0.05s;
  }

  .dropdown-menu--active .dropdown-item:nth-child(2) {
    animation-delay: 0.1s;
  }

  .dropdown-menu--active .dropdown-item:nth-child(3) {
    animation-delay: 0.15s;
  }

  .dropdown-menu--active .dropdown-item:nth-child(4) {
    animation-delay: 0.2s;
  }

  .dropdown-menu--active .dropdown-item:nth-child(5) {
    animation-delay: 0.25s;
  }

  .dropdown-menu--active .dropdown-item:nth-child(6) {
    animation-delay: 0.3s;
  }

  .dropdown-item:hover {
    background-color: var(--color-bg-card-hover);
  }

  .logo-text {
    display: none;
  }

  .logo-img {
    height: 32px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .navbar-menu {
    gap: var(--spacing-xs);
  }

  .navbar-link {
    padding: var(--spacing-sm);
    font-size: var(--font-size-sm);
  }

  /* Match Watch Stream height on tablet */
  #nav-watch-stream .navbar-link {
    padding: var(--spacing-sm);
    font-size: var(--font-size-sm);
  }
}

/* ===== WATCH STREAM NAV ITEM (Special Styling) ===== */
#nav-watch-stream .navbar-link {
  background: linear-gradient(135deg, var(--color-primary) 0%, #a970ff 100%);
  color: #fff;
  font-weight: 700;
  border-color: var(--color-primary);
  position: relative;
  overflow: hidden;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-md) var(--spacing-lg);
}

/* Holographic flash overlay */
#nav-watch-stream .navbar-link::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 100%
  );
  transition: left 0.6s ease;
  z-index: 1;
  pointer-events: none;
}

/* Trigger holographic flash on hover */
#nav-watch-stream .navbar-link:hover::before {
  left: 100%;
}

/* Enhanced hover state for Watch Stream */
#nav-watch-stream .navbar-link:hover {
  background: linear-gradient(135deg, #a970ff 0%, #bf94ff 100%);
  box-shadow: 0 8px 32px rgba(74, 198, 255, 0.6);
  transform: translateY(-10px) scale(1.02);
  border-color: #a970ff;
}

/* Inner triangle for Watch Stream (if dropdown, override) */
#nav-watch-stream.dropdown .navbar-link::after {
  border-top-color: var(--color-primary);
}

/* Hide normal triangle indicator, show holographic overlay */
#nav-watch-stream.dropdown .navbar-link::before {
  /* Override triangle, use for holographic effect */
  border: none;
  opacity: 1;
  width: 100%;
  height: 100%;
  bottom: auto;
  top: 0;
  left: -100%;
  transform: none;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.3) 50%,
    transparent 100%
  );
}

/* Mobile styling for Watch Stream */
@media (max-width: 767px) {
  #nav-watch-stream .navbar-link {
    background: linear-gradient(135deg, var(--color-primary) 0%, #a970ff 100%);
    color: #fff;
    border: none;
    border-radius: 0;
    font-weight: 700;
    position: relative;
    overflow: hidden;
  }

  /* Holographic flash on mobile */
  #nav-watch-stream .navbar-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
      90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.3) 50%,
      transparent 100%
    );
    transition: left 0.6s ease;
    z-index: 1;
  }

  #nav-watch-stream .navbar-link:hover::before,
  #nav-watch-stream .navbar-link:active::before {
    left: 100%;
  }

  /* Enhanced mobile hover/active */
  #nav-watch-stream .navbar-link:hover,
  #nav-watch-stream .navbar-link:active {
    background: linear-gradient(135deg, #a970ff 0%, #bf94ff 100%);
  }

  /* Text should be white and visible */
  #nav-watch-stream .navbar-link {
    color: #fff !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  }
}
