/* ==========================================================================
   Header & Navigation
   ========================================================================== */

header {
  background-color: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 999;
  height: 64px;
}

[data-theme="dark"] header {
  background-color: rgba(7, 7, 8, 0.9);
}

header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--page-gutter-desktop);
  height: 100%;
}

.logo h1 {
  font-family: var(--font-family-display);
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--color-text);
  line-height: 1;
  margin: 0;
  transition: opacity var(--transition-fast);
  display: flex;
  align-items: baseline;
}

.logo h1:hover {
  opacity: 1; /* Override generic opacity hover */
}

.phonetic-hint {
  font-family: var(--font-family-sans);
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 400;
  opacity: 0;
  transform: translateX(-8px);
  transition: all var(--transition-default);
  margin-left: 0.5rem;
  letter-spacing: 0;
  pointer-events: none; /* Let clicks pass through to the link */
}

.logo:hover .phonetic-hint {
  opacity: 1;
  transform: translateX(0);
}

/* Ensure the brand link hover doesn't conflict visually */
.brand-link:hover h1 {
    opacity: 1;
}
.brand-link:hover h1 > span:first-child {
     /* Main text */
     opacity: 0.8;
}

nav ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 100%;
  margin: 0;
  padding: 0;
}

nav ul li {
  position: relative;
}

nav a {
  color: var(--color-text);
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  transition: background-color var(--transition-fast),
    color var(--transition-fast);
}

nav a:hover {
  background-color: var(--color-surface);
}

nav a.button {
  background-color: var(--color-primary);
  color: var(--color-primary-button-text);
}

nav a.button.secondary {
  background-color: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

nav a.button.secondary:hover {
  background-color: var(--color-surface);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

nav a.button:hover {
  background-color: var(--color-primary-dark);
}

nav a.button.secondary:hover {
  background-color: var(--color-surface); /* Re-declare to override the generic button hover if specificity is issue */
}

/* Dropdown Menu */
.dropdown-content {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background-color: var(--color-background);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  min-width: 200px;
  z-index: 1000;
}

.dropdown-content a {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--color-text);
  transition: background-color var(--transition-fast),
    color var(--transition-fast);
}

.dropdown-content a:hover {
  background-color: var(--color-surface);
}

nav li.dropdown:hover .dropdown-content {
  display: block;
}

header nav ul li {
  margin-bottom: 0; /* Remove bottom margin */
  display: inline-block; /* Ensure items are inline */
  vertical-align: middle; /* Align items vertically */
}

/* Add this after the existing dropdown styles (around line 94) */
.dropdown-divider {
  height: 1px;
  background-color: var(--color-border);
  margin: 0.5rem 0;
}

.dropdown-subheader {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--color-text-light);
  font-weight: 500;
}

.theme-selector {
  padding: 0.75rem 1rem;
}

.theme-selector label {
  display: block;
  font-size: 0.875rem;
  color: var(--color-text-light);
  margin-bottom: 0.25rem;
}

.theme-selector select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  background-color: var(--color-surface);
  color: var(--color-text);
}

/* Upgrade Link Styling */
.upgrade-link {
  background: linear-gradient(
      145deg,
      var(--color-primary),
      var(--color-primary-dark)
    )
    !important;
  color: var(--color-primary-button-text) !important;
  border-radius: var(--border-radius-pill);
  font-weight: 600;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-fast);
}

.upgrade-link:hover {
  background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary)) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.upgrade-link i {
  color: #fbbf24;
  margin-right: 0.5rem;
  text-shadow: 0 0 8px rgba(251, 191, 36, 0.4);
}

/* Dropdown Upgrade Link */
.upgrade-dropdown-link {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light)) !important;
  color: var(--color-primary-button-text) !important;
  font-weight: 600;
  border-radius: var(--border-radius-sm);
  margin: 0.25rem;
  padding: 0.75rem 1rem !important;
}

.upgrade-dropdown-link:hover {
  background: linear-gradient(135deg, var(--color-primary-dark), var(--color-primary)) !important;
  transform: translateX(2px);
}

.upgrade-dropdown-link i {
  color: #fbbf24;
  margin-right: 0.5rem;
}

/* Mobile header adjustments */
@media (max-width: 600px) {
  header .container {
    padding: 0 var(--page-gutter-mobile);
  }

  nav ul {
    gap: 0.25rem;
  }

  nav a {
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
  }

  .upgrade-link {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .upgrade-link i {
    margin-right: 0.25rem;
  }

  /* Hide "Upgrade Plan" text on very small screens, show just icon */
  .upgrade-link .upgrade-text {
    display: none;
  }
}

@media (max-width: 420px) {
  .logo h1 {
    font-size: 1rem;
  }

  nav a {
    padding: 0.35rem 0.4rem;
    font-size: 0.8rem;
  }

  .upgrade-link {
    padding: 0.35rem 0.5rem !important;
  }
}

/* ==========================================================================
     Footer
     ========================================================================== */

footer {
  background-color: var(--color-background);
  border-top: 1px solid var(--color-border);
  padding: 1.5rem 0;
}

footer .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--page-gutter-desktop);
}

footer p {
  color: var(--color-text-light);
  font-size: 0.9rem;
  margin: 0;
}

footer .footer-links {
  display: flex;
  gap: 1.5rem;
}

footer .footer-links a {
  color: var(--color-text-light);
  font-size: 0.9rem;
  transition: color var(--transition-fast);
}

footer .footer-links a:hover {
  color: var(--color-text);
}

@media (max-width: 768px) {
  footer .container {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
    padding: 0 var(--page-gutter-mobile);
  }

  footer .footer-links {
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
  }
}

/* ==========================================================================
     Main Content
     ========================================================================== */

main {
  padding: var(--layout-main-top) 0 var(--space-6);
}
