/* ============================================================================
   SITE NAVIGATION
   Reusable navigation component - shadcn-inspired minimal aesthetic
   ============================================================================ */

/* Body padding offset when nav is present */
body.has-site-nav {
  padding-top: 64px;
}

@media (max-width: 768px) {
  body.has-site-nav {
    padding-top: 56px;
  }
}

/* ============================================================================
   NAV HEADER
   ============================================================================ */

.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: hsl(var(--background, 0 0% 100%) / 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid hsl(var(--border, 240 5.9% 90%));
}

.site-nav__container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 24px;
}

@media (max-width: 768px) {
  .site-nav__container {
    height: 56px;
    padding: 0 16px;
  }
}

/* ============================================================================
   BRAND (Issue #7: separator for intentional font pairing)
   ============================================================================ */

.site-nav__brand {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 24px;
  font-weight: 400;
  color: hsl(var(--foreground, 240 10% 3.9%));
  text-decoration: none;
  letter-spacing: -0.01em;
  transition: opacity 0.15s;
  padding-right: 20px;
  border-right: 1px solid hsl(var(--border, 240 5.9% 90%));
  margin-right: 12px;
  flex-shrink: 0;
}

.site-nav__logo {
  height: 28px;
  width: auto;
}

.site-nav__brand:hover {
  opacity: 0.8;
}

@media (max-width: 768px) {
  .site-nav__brand {
    border-right: none;
    padding-right: 0;
    margin-right: 0;
  }
}

/* ============================================================================
   DESKTOP LINKS (Issue #8: better spacing)
   ============================================================================ */

.site-nav__links {
  display: flex;
  align-items: center;
  gap: 6px;
}

.site-nav__links-inner {
  display: contents;
}

.site-nav__link {
  position: relative;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--muted-foreground, 240 3.8% 46.1%));
  text-decoration: none;
  border-radius: var(--radius-md, 0.5rem);
  transition: color 0.15s, background-color 0.15s;
  border: none;
  background: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.site-nav__link:hover {
  color: hsl(var(--foreground, 240 10% 3.9%));
  background: hsl(var(--muted, 240 4.8% 95.9%));
}

/* Active indicator — italic-serif asterisk prefix mark.
   Replaces the generic underline pattern with an editorial footnote-style typographic mark. */
.site-nav__link--active {
  color: hsl(var(--foreground, 240 10% 3.9%));
  gap: 0;
}

.site-nav__link--active::before {
  content: '*';
  display: inline-flex;
  align-items: flex-start;
  margin-right: 5px;
  margin-left: -2px;
  color: hsl(var(--brand-orange, 16 82% 52%));
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 22px;
  line-height: 0.9;
  letter-spacing: -0.02em;
  transform: translateY(2px);
  pointer-events: none;
}

/* Suppress the legacy underline if anything still references ::after. */
.site-nav__link--active::after {
  display: none;
}

/* Dropdown arrow */
.site-nav__dropdown-arrow {
  transition: transform 0.2s ease;
}

.site-nav__dropdown-trigger[aria-expanded="true"] .site-nav__dropdown-arrow,
.site-nav__dropdown-toggle[aria-expanded="true"] .site-nav__dropdown-arrow {
  transform: rotate(180deg);
}

/* Split-button dropdown: clickable label + arrow toggle */
.site-nav__dropdown-trigger-wrap {
  gap: 0;
}

.site-nav__dropdown-label {
  text-decoration: none;
  color: inherit;
  font: inherit;
}

.site-nav__dropdown-toggle {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  border-radius: var(--radius-md, 0.5rem);
}

.site-nav__dropdown-toggle:hover {
  background: hsl(var(--muted, 240 4.8% 95.9%));
}

/* ============================================================================
   DESKTOP DROPDOWNS (Issue #6: animated transitions)
   ============================================================================ */

.site-nav__dropdown {
  position: relative;
}

.site-nav__dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 200px;
  background: hsl(var(--background, 0 0% 100%));
  border: 1px solid hsl(var(--border, 240 5.9% 90%));
  border-radius: var(--radius-lg, 0.75rem);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  padding: 4px;
  z-index: 1001;
  /* Transition system */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.site-nav__dropdown-menu--open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Invisible bridge to prevent hover gap between trigger and menu */
.site-nav__dropdown-menu::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 8px;
}

/* Align dropdown to right edge for last item to prevent clipping */
.site-nav__dropdown:last-child .site-nav__dropdown-menu {
  left: auto;
  right: 0;
}

/* Dropdown items — editorial layout with reserved gutters for typographic marks.
   Left gutter holds the active-state asterisk; right gutter holds a hover chevron. */
.site-nav__dropdown-item {
  position: relative;
  display: block;
  padding: 8px 26px 8px 26px;
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--muted-foreground, 240 3.8% 46.1%));
  text-decoration: none;
  border-radius: var(--radius-md, 0.5rem);
  transition: color 0.15s, background-color 0.15s;
}

/* Hover: subtle muted bg + a serif right-chevron sliding in from the right gutter. */
.site-nav__dropdown-item::after {
  content: '›';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translate(-3px, -55%);
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-size: 16px;
  line-height: 1;
  color: hsl(var(--muted-foreground, 240 3.8% 46.1%));
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.2s ease;
  pointer-events: none;
}

.site-nav__dropdown-item:hover {
  color: hsl(var(--foreground, 240 10% 3.9%));
  background: hsl(var(--muted, 240 4.8% 95.9%));
}

.site-nav__dropdown-item:hover::after {
  opacity: 1;
  transform: translate(0, -55%);
}

/* Active: orange italic-serif asterisk in the left gutter. No bg, no border. */
.site-nav__dropdown-item--active {
  color: hsl(var(--foreground, 240 10% 3.9%));
  background: transparent;
  font-weight: 600;
}

.site-nav__dropdown-item--active::before {
  content: '*';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-30%);
  color: hsl(var(--brand-orange, 16 82% 52%));
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 18px;
  line-height: 1;
  letter-spacing: -0.02em;
  pointer-events: none;
}

/* Active row hides the hover chevron — the asterisk is the marker. */
.site-nav__dropdown-item--active::after {
  display: none;
}

.site-nav__dropdown-empty {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  color: hsl(var(--muted-foreground, 240 3.8% 46.1%));
  font-style: italic;
}

/* Section headers inside a dropdown — editorial italic serif with a hairline
   rule extending to the right edge of the menu (magazine TOC vibe).
   Uses the same 26px left gutter as items so labels visually align. */
.site-nav__dropdown-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 6px 26px;
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.005em;
  text-transform: none;
  color: hsl(var(--foreground, 240 10% 3.9%));
  pointer-events: none;
}

.site-nav__dropdown-section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: hsl(var(--border, 240 5.9% 90%));
}

.site-nav__dropdown-section-header:first-child {
  padding-top: 6px;
}

/* ============================================================================
   NAV GROUP SEPARATORS (Issue #11)
   ============================================================================ */

.site-nav__separator {
  width: 1px;
  height: 20px;
  background: hsl(var(--border, 240 5.9% 90%));
  margin: 0 4px;
  flex-shrink: 0;
}

/* ============================================================================
   ORG LABEL (Issue #10)
   ============================================================================ */

.site-nav__org-label {
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--muted-foreground, 240 3.8% 46.1%));
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: none;
}

.site-nav--authenticated .site-nav__org-label:not(:empty) {
  display: inline-block;
}

/* ============================================================================
   SIGN IN CTA (Issue #12)
   ============================================================================ */

.site-nav__cta {
  display: none;
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  background: hsl(var(--brand-orange, 16 82% 52%));
  border: none;
  border-radius: var(--radius-md, 0.5rem);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s, transform 0.15s;
}

.site-nav__cta:hover {
  background: hsl(var(--brand-orange-hover, 16 82% 45%));
  transform: translateY(-1px);
}

/* Only show CTA when Clerk confirms not signed in */
.site-nav--public .site-nav__cta {
  display: inline-flex;
}

/* ============================================================================
   CLERK USER BUTTON
   ============================================================================ */

.site-nav__user-button {
  margin-left: 8px;
  display: none;
  align-items: center;
}

.site-nav--authenticated .site-nav__user-button {
  display: inline-flex;
}

/* "What's New" bell — only shown to signed-in visitors (the feed is gated).
   Mirrors the user-button reveal pattern. */
.site-nav__whatsnew {
  position: relative;
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: hsl(var(--muted-foreground, 20 12% 42%));
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.site-nav--authenticated .site-nav__whatsnew {
  display: inline-flex;
}

.site-nav__whatsnew:hover {
  color: hsl(var(--brand-orange, 16 82% 52%));
  background: hsl(var(--brand-orange, 16 82% 52%) / 0.08);
}

.site-nav__whatsnew svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-nav__whatsnew-dot {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: hsl(var(--brand-orange, 16 82% 52%));
  box-shadow: 0 0 0 2px hsl(var(--background, 0 0% 100%));
}

.site-nav__whatsnew-dot[hidden] {
  display: none;
}

/* Hide desktop links on mobile */
@media (max-width: 768px) {
  .site-nav__links {
    display: none;
  }
}

/* Responsive squeeze for narrow desktops (Issue #8) */
@media (min-width: 769px) and (max-width: 1100px) {
  .site-nav__links {
    gap: 2px;
  }
  .site-nav__link {
    padding: 8px 10px;
    font-size: 13px;
  }
}

/* ============================================================================
   MOBILE TOGGLE (HAMBURGER)
   ============================================================================ */

.site-nav__mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-md, 0.5rem);
  transition: background-color 0.15s;
}

.site-nav__mobile-toggle:hover {
  background: hsl(var(--muted, 240 4.8% 95.9%));
}

.site-nav__mobile-toggle:focus-visible {
  outline: 2px solid hsl(var(--ring, 240 10% 3.9%));
  outline-offset: 2px;
}

/* Show on mobile */
@media (max-width: 768px) {
  .site-nav__mobile-toggle {
    display: flex;
  }
}

/* Hamburger icon */
.site-nav__hamburger {
  position: relative;
  width: 20px;
  height: 14px;
}

.site-nav__hamburger span {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: hsl(var(--foreground, 240 10% 3.9%));
  border-radius: 1px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.site-nav__hamburger span:nth-child(1) {
  top: 0;
}

.site-nav__hamburger span:nth-child(2) {
  top: 6px;
}

.site-nav__hamburger span:nth-child(3) {
  top: 12px;
}

/* Hamburger to X animation */
.site-nav--menu-open .site-nav__hamburger span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.site-nav--menu-open .site-nav__hamburger span:nth-child(2) {
  opacity: 0;
}

.site-nav--menu-open .site-nav__hamburger span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ============================================================================
   MOBILE MENU (Issue #5: scroll containment, Issue #6: class-based toggle)
   ============================================================================ */

.site-nav__mobile-menu {
  display: none;
  flex-direction: column;
  padding: 8px 16px 16px;
  background: hsl(var(--background, 0 0% 100%));
  border-bottom: 1px solid hsl(var(--border, 240 5.9% 90%));
}

.site-nav__mobile-menu--open {
  display: flex;
  max-height: calc(100dvh - 56px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.site-nav__mobile-links-inner {
  display: contents;
}

.site-nav__mobile-link {
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 500;
  color: hsl(var(--muted-foreground, 240 3.8% 46.1%));
  text-decoration: none;
  border-radius: var(--radius-md, 0.5rem);
  transition: color 0.15s, background-color 0.15s;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  text-align: left;
}

.site-nav__mobile-link:hover {
  color: hsl(var(--foreground, 240 10% 3.9%));
  background: hsl(var(--muted, 240 4.8% 95.9%));
}

.site-nav__mobile-link--active {
  color: hsl(var(--foreground, 240 10% 3.9%));
  background: transparent;
  position: relative;
  gap: 6px;
}

/* Active indicator — italic-serif asterisk prefix mark (matches desktop). */
.site-nav__mobile-link--active::before {
  content: '*';
  display: inline-flex;
  align-items: flex-start;
  margin-right: 4px;
  margin-left: -4px;
  color: hsl(var(--brand-orange, 16 82% 52%));
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 24px;
  line-height: 0.9;
  letter-spacing: -0.02em;
  transform: translateY(2px);
}

/* ============================================================================
   MOBILE DROPDOWNS (Issue #6: accordion transitions)
   ============================================================================ */

.site-nav__mobile-dropdown {
  display: flex;
  flex-direction: column;
}

.site-nav__mobile-dropdown-trigger {
  justify-content: space-between;
}

.site-nav__mobile-dropdown-trigger--open .site-nav__dropdown-arrow {
  transform: rotate(180deg);
}

/* Mobile split dropdown: label link + arrow toggle */
.site-nav__mobile-dropdown-split {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-nav__mobile-dropdown-label {
  flex: 1;
  text-decoration: none;
  color: inherit;
  font: inherit;
}

.site-nav__mobile-dropdown-trigger--arrow-only {
  padding: 8px 12px;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

.site-nav__mobile-dropdown-menu {
  display: flex;
  flex-direction: column;
  padding-left: 16px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease, margin-top 0.2s ease;
  margin-top: 0;
}

.site-nav__mobile-dropdown-menu--open {
  max-height: 300px;
  margin-top: 4px;
}

/* Mobile dropdown items — same editorial mark system as desktop. */
.site-nav__mobile-dropdown-item {
  position: relative;
  display: block;
  padding: 10px 16px 10px 30px;
  font-size: 14px;
  font-weight: 500;
  color: hsl(var(--muted-foreground, 240 3.8% 46.1%));
  text-decoration: none;
  border-radius: var(--radius-md, 0.5rem);
  transition: color 0.15s, background-color 0.15s;
}

.site-nav__mobile-dropdown-item:hover {
  color: hsl(var(--foreground, 240 10% 3.9%));
  background: hsl(var(--muted, 240 4.8% 95.9%));
}

.site-nav__mobile-dropdown-item--active {
  color: hsl(var(--foreground, 240 10% 3.9%));
  background: transparent;
  font-weight: 600;
}

.site-nav__mobile-dropdown-item--active::before {
  content: '*';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-30%);
  color: hsl(var(--brand-orange, 16 82% 52%));
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 20px;
  line-height: 1;
  letter-spacing: -0.02em;
  pointer-events: none;
}

.site-nav__mobile-dropdown-empty {
  padding: 10px 16px;
  font-size: 13px;
  color: hsl(var(--muted-foreground, 240 3.8% 46.1%));
  font-style: italic;
}

/* Mobile section header — italic serif + hairline rule (matches desktop). */
.site-nav__mobile-dropdown-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 6px 30px;
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.005em;
  text-transform: none;
  color: hsl(var(--foreground, 240 10% 3.9%));
  pointer-events: none;
}

.site-nav__mobile-dropdown-section-header::after {
  content: '';
  flex: 1;
  height: 1px;
  background: hsl(var(--border, 240 5.9% 90%));
}

.site-nav__mobile-dropdown-section-header:first-child {
  padding-top: 8px;
}

/* ============================================================================
   MOBILE SEPARATORS (Issue #11)
   ============================================================================ */

.site-nav__mobile-separator {
  height: 1px;
  background: hsl(var(--border, 240 5.9% 90%));
  margin: 4px 16px;
}

/* ============================================================================
   MOBILE FOOTER (CTA + User Button)
   ============================================================================ */

.site-nav__mobile-footer {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid hsl(var(--border, 240 5.9% 90%));
}

.site-nav__mobile-cta {
  display: none;
  width: 100%;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  color: white;
  background: hsl(var(--brand-orange, 16 82% 52%));
  border: none;
  border-radius: var(--radius-md, 0.5rem);
  cursor: pointer;
  transition: background-color 0.15s;
}

.site-nav__mobile-cta:hover {
  background: hsl(var(--brand-orange-hover, 16 82% 45%));
}

/* Only show mobile CTA when Clerk confirms not signed in */
.site-nav--public .site-nav__mobile-cta {
  display: block;
}

.site-nav__mobile-user-button {
  margin-top: 8px;
  padding: 4px 0;
  display: none;
}

.site-nav--authenticated .site-nav__mobile-user-button {
  display: block;
}

/* Only show mobile menu on mobile */
@media (min-width: 769px) {
  .site-nav__mobile-menu {
    display: none !important;
  }
}

/* ============================================================================
   REDUCED MOTION
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  .site-nav__dropdown-menu,
  .site-nav__mobile-dropdown-menu,
  .site-nav__dropdown-arrow,
  .site-nav__hamburger span,
  .site-nav__cta {
    transition: none;
  }
}
