/* ===============================
   SAMYAK GYAN - A+ NAVIGATION SYSTEM
   Production-Grade Global Navigation
   =============================== */

/* ===============================
   DESIGN TOKENS
   =============================== */
:root {
  --brand: #fc7306;
  --brand-soft: rgba(252,115,6,0.12);
  --brand-soft-strong: rgba(252,115,6,0.18);
  --brand-border: rgba(252,115,6,0.08);
  --nav-text-dark: #1f1f1f;
}

/* ===============================
   NAV BAR WITH SHARP TRICOLOR
   =============================== */
.global-nav {
  width: 100%;
  background: var(--bg-primary, white);
  border-bottom: 1px solid var(--brand-border);
  position: relative;
  overflow: visible;
  z-index: 1000;
}

/* When status strip is inside the header, stack nav-inner and strip vertically */
body.has-status-strip .global-nav {
  display: flex;
  flex-direction: column;
}

/* Left 40% sharper, tilted tricolor fade with white center */
.global-nav::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    160deg,
    rgba(252,115,6,0.15) 0%,
    rgba(252,115,6,0.15) 30%,
    rgba(255,255,255,0.6) 50%,
    rgba(147,212,155,0.25) 70%,
    rgba(147,212,155,0.25) 100%
  );
  mask-image: linear-gradient(to right, black 80%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, black 80%, transparent 100%);
  pointer-events: none;
}


.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.2rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 2;
  min-height: 90px;
}

/* ===============================
   LOGOS WITH HOVER FEEDBACK
   =============================== */
.nav-logo {
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: opacity 0.2s ease;
  height: 100%;
  padding: 0.15rem 0;
  margin-right: 2rem; /* Shift logo slightly to the left */
}

.nav-logo:hover { opacity: 0.85; }

.logo-desktop-nav {
  height: 100%;
  max-height: 85px;
  width: auto;
  display: block;
  object-fit: contain;
}

.logo-mobile-nav {
  display: none;
  height: 100%;
  max-height: 60px;
  width: auto;
  object-fit: contain;
}

/* ===============================
   ICON LINKS (Home & Profile)
   =============================== */
.nav-icon-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border-radius: 999px; /* Full pill shape for icons */
  color: var(--brand);
  cursor: pointer;
  background: rgba(0, 0, 0, 0.03); /* Very faint charcoal - subtle differentiator */
  transition: background 0.2s ease, border 0.2s ease;
  text-decoration: none;
  border: 2px solid transparent; /* Invisible border for smooth transition */
}

.nav-icon-link:hover {
  background: rgba(252, 115, 6, 0.12); /* Orange tint on hover */
  border: 2px solid var(--brand); /* Orange border on hover */
}

.nav-icon-link svg {
  display: block;
}

/* ===============================
   DESKTOP LINKS
   =============================== */
.nav-links {
  display: flex;
  gap: 1rem; /* Tighter gap to fit lang toggle */
  align-items: center;
  margin-left: 2rem; /* Slightly reduced to give more room */
}

.nav-link {
  text-decoration: none;
  font-size: 15px; /* IMPROVED: Was 0.95rem (~15.2px), now explicit 15px */
  font-weight: 600;
  color: var(--text-primary, #008ECC);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  transition: background 0.2s ease, color 0.2s ease;
  cursor: pointer;
  line-height: 1.5; /* IMPROVED: Better readability */
}

/* Single-Line Navigation Links - Simplified */
.nav-link-two-line {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
  padding: 0.5rem 0.8rem; /* Tighter padding to fit with lang toggle */
  font-size: 0.85rem !important; /* Slightly smaller nav text */
  font-weight: 700 !important; /* Override base .nav-link font weight */
  background: rgba(0, 0, 0, 0.03); /* Very faint charcoal - subtle differentiator */
  border-radius: 20px; /* Rounded pill shape */
  border: 2px solid transparent; /* Invisible border for smooth transition */
  transition: background 0.2s ease, border 0.2s ease;
  white-space: nowrap; /* CRITICAL: Prevent text from wrapping to 2 lines */
}

.nav-line-1 {
  display: block;
  font-size: inherit; /* Inherit from parent .nav-link-two-line */
  font-weight: inherit; /* Inherit from parent .nav-link-two-line */
}

/* Unicode Arrow Styling (➜) - Exact same size as surrounding text */
.nav-arrow {
  font-size: inherit; /* Inherit exact font size from parent */
  color: var(--brand);
  display: inline-block;
  margin: 0 0.25rem;
  font-weight: inherit; /* Inherit exact font weight from parent */
  vertical-align: baseline; /* Align to text baseline */
}

/* Hover - Applies to all nav links including .nav-link-two-line */
.nav-link:hover {
  background: rgba(252, 115, 6, 0.12); /* Orange tint on hover */
  color: var(--brand);
}

/* Specific hover for pill-shaped nav items */
.nav-link-two-line:hover {
  background: rgba(252, 115, 6, 0.12); /* Orange tint on hover */
  border: 2px solid var(--brand); /* Orange border on hover */
  color: var(--brand);
}

/* Active State – High Contrast */
.nav-link.active {
  background: var(--brand);
  color: white;
  box-shadow: 0 2px 4px rgba(252,115,6,0.25);
}

/* ===============================
   DROPDOWN NAVIGATION
   =============================== */
.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-trigger {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 200px;
  padding: 0.5rem 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  z-index: 9999;
  max-height: 400px;
  overflow-y: auto;
}

/* Right-aligned dropdown for profile */
.nav-dropdown-menu-right {
  left: auto;
  right: 0;
}

.nav-dropdown:hover .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.nav-dropdown-menu a {
  display: block;
  padding: 0.7rem 1.2rem;
  color: var(--text-primary, #222);
  text-decoration: none;
  font-size: 14px; /* IMPROVED: Was 0.9rem (~14.4px), now explicit 14px */
  font-weight: 500;
  transition: background 0.2s ease;
  line-height: 1.5; /* IMPROVED: Better readability */
}

.nav-dropdown-menu a:hover {
  background: var(--brand-soft);
  color: var(--brand);
}

.nav-dropdown-divider {
  height: 1px;
  background: var(--brand-border, #e5e5e5);
  margin: 0.4rem 0;
}

/* ===============================
   MOBILE TOGGLE (A11Y)
   =============================== */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.8rem;
  cursor: pointer;
  color: var(--brand);
}

/* ===============================
   MOBILE DRAWER
   =============================== */
.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  z-index: 900;
}

.mobile-nav-overlay.show { display: block; }

.mobile-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100%;
  background: var(--bg-primary, white);
  padding: 1.2rem;
  box-shadow: 4px 0 14px rgba(0,0,0,0.25);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 1000;
}

.mobile-nav.open { transform: translateX(0); }

/* Mobile Header – Strong */
.mobile-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mobile-nav-header strong {
  font-size: 18px; /* IMPROVED: Was 1.1rem (~17.6px), now clear 18px */
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.4; /* IMPROVED: Better readability */
}

.mobile-close {
  font-size: 1.6rem;
  background: none;
  border: none;
  cursor: pointer;
}

/* Mobile Links */
.mobile-link {
  display: block;
  padding: 0.9rem;
  margin-top: 0.6rem;
  border-radius: 10px;
  text-decoration: none;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  width: 100%;
  text-align: left;
  border: none;
  font-size: 16px; /* OK: Was 1rem (~16px), now explicit 16px */
  cursor: pointer;
  line-height: 1.5; /* IMPROVED: Better readability */
}

/* Mobile Active State */
.mobile-link.active {
  background: var(--brand);
  color: white;
}

/* ===============================
   MOBILE EXPANDABLE SECTIONS
   =============================== */
.mobile-expandable {
  margin-top: 0.6rem;
}

.mobile-expandable-trigger {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mobile-expandable-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.mobile-expandable-content.open {
  max-height: 800px;
}

.mobile-sublink {
  display: block;
  padding: 0.7rem 0.9rem 0.7rem 1.8rem;
  margin-top: 0.3rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px; /* IMPROVED: Was 0.9rem (~14.4px), now explicit 14px */
  color: var(--brand);
  background: rgba(252,115,6,0.08);
  line-height: 1.5; /* IMPROVED: Better readability */
}

/* ===============================
   TABLET PORTRAIT MODE - Dedicated Implementation
   Complete separate system from mobile
   =============================== */
@media (orientation: portrait) and (min-width: 481px) and (max-width: 1024px) {
  /* Tablet Portrait Header Layout - with Language Toggle */
  .global-nav .nav-inner {
    display: grid;
    grid-template-columns: 44px 1fr auto 44px; /* Hamburger | Logo | Language | Profile */
    align-items: center;
    padding: 0.75rem 0.8rem;
    min-height: 75px;
    gap: 0.5rem;
  }

  /* Show hamburger for tablet portrait */
  .mobile-hamburger {
    grid-column: 1;
    display: flex !important;
    align-items: center;
    justify-content: flex-start;
  }

  .nav-logo {
    grid-column: 2;
    justify-self: center !important;
    margin: 0 !important;
  }

  .nav-links {
    grid-column: 3 / 5; /* Spans columns 3 and 4 for lang toggle + profile */
    display: flex !important;
    justify-content: flex-end;
    margin: 0 !important;
    gap: 0.5rem !important; /* Small gap between language and profile */
  }

  /* Hide all nav-links children EXCEPT language toggle and profile dropdown */
  .nav-links > *:not(.lang-toggle):not(.nav-dropdown-profile) {
    display: none !important;
  }

  /* Show language toggle with compact styling */
  .lang-toggle {
    display: flex !important;
    font-size: 0.75rem !important;
    padding: 0.35rem 0.6rem !important;
    gap: 0.3rem !important;
  }

  .lang-option {
    font-size: 0.75rem !important;
    padding: 0.25rem 0.4rem !important;
  }

  /* Show profile icon + timer stacked */
  .nav-dropdown-profile {
    display: inline-flex !important;
    flex-direction: column !important;
    align-items: center !important;
    margin: 0 !important;
  }

  .logo-desktop-nav { display: none !important; }
  .logo-mobile-nav {
    display: block !important;
    max-height: 65px;
  }

  /* Show mobile menu for tablet portrait */
  .mobile-menu-overlay { display: block; }
  .mobile-menu { display: block; }
}

/* ===============================
   MOBILE PHONE MODE (Portrait) - NO PROFILE ICON
   =============================== */
@media (max-width: 480px) {
  .global-nav .nav-inner {
    display: grid;
    grid-template-columns: 44px 1fr; /* Only Hamburger | Logo */
    align-items: center;
    padding: 0.75rem 0.8rem;
    min-height: 75px;
    gap: 0.5rem;
  }

  .mobile-hamburger {
    grid-column: 1;
    display: flex !important;
  }

  .nav-logo {
    grid-column: 2;
    justify-self: center !important;
  }

  /* Hide ALL nav-links on mobile phone (including profile) */
  .nav-links {
    display: none !important;
  }

  .logo-desktop-nav { display: none; }
  .logo-mobile-nav { display: block; }
}

/* ===============================
   HAMBURGER ICON
   =============================== */
.mobile-hamburger {
  display: none; /* Hidden on desktop */
  width: 44px;
  height: 44px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  background: none;
  border: none;
  padding: 8px;
  -webkit-tap-highlight-color: transparent;
}

.mobile-hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--nav-text-dark, #1f1f1f);
  margin: 3px 0;
  transition: all 0.3s ease;
  border-radius: 2px;
}

.mobile-hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-hamburger.active span:nth-child(2) {
  opacity: 0;
}

.mobile-hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

/* Hamburger display is now handled in the tablet/mobile sections above */

/* ===============================
   MOBILE MENU OVERLAY
   =============================== */
.mobile-menu-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-menu-overlay.active {
  display: block;
  opacity: 1;
}

/* ===============================
   MOBILE MENU PANEL
   =============================== */
.mobile-menu {
  display: none;
  position: fixed;
  top: 0;
  left: -100%;
  width: 65%;
  max-width: 240px;
  height: 100%;
  background: #ffffff;
  z-index: 9999;
  overflow-y: auto;
  transition: left 0.3s ease;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
}

.mobile-menu.active {
  display: block;
  left: 0;
}

/* Login Button (Top of Menu for Guests) */
.mobile-menu .login-btn {
  display: block;
  margin: 1rem;
  padding: 0.875rem 1.5rem;
  background: linear-gradient(135deg, var(--brand) 0%, #ea580c 100%);
  color: white;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  border-radius: 12px;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(252, 115, 6, 0.25);
  transition: transform 0.2s ease;
}

.mobile-menu .login-btn:hover {
  transform: translateY(-2px);
}

/* Menu List */
.mobile-menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.mobile-menu > ul {
  padding: 1rem 0;
}

.mobile-menu li {
  border-bottom: 2px solid #e5e7eb;
}

.mobile-menu li.mobile-menu-divider {
  border-bottom: none;
  height: 1px;
  background: #d1d5db;
  margin: 0.5rem 1rem;
}

.mobile-menu a {
  display: flex;
  align-items: center;
  padding: 0.875rem 1.25rem;
  color: var(--nav-text-dark, #1f1f1f);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: background 0.2s ease;
  min-height: 44px;
  line-height: 1.5;
}

.mobile-menu a:hover,
.mobile-menu a:active {
  background: var(--brand-soft);
  color: var(--brand);
}

/* Caption for "Latest" */
.mobile-menu .caption {
  padding: 0 1.25rem 0.5rem 1.25rem;
  font-size: 13px;
  color: #6b7280;
  font-style: italic;
  margin-top: -0.5rem;
  line-height: 1.5;
}

/* Daily Feed Label (Not a Link) */
.mobile-menu .label {
  padding: 0.875rem 1.25rem;
  font-weight: 700;
  color: #374151;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f9fafb;
  line-height: 1.5;
}

/* Date List (Nested Under Daily Feed) */
.mobile-menu .date-list {
  background: #fafafa;
  padding-left: 0;
}

.mobile-menu .date-list li {
  border-bottom: 2px solid #e5e7eb;
}

.mobile-menu .date-list a {
  padding-left: 2rem;
  font-size: 14px;
  color: #4b5563;
  line-height: 1.5;
}

/* Topics Parent (Expandable) */
.mobile-menu .topics-parent {
  position: relative;
  cursor: pointer;
  user-select: none;
  min-height: 44px;
}

.mobile-menu .topics-parent > .topics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.25rem;
  font-weight: 600;
  color: var(--nav-text-dark, #1f1f1f);
  min-height: 44px;
  width: 100%;
}

.mobile-menu .expand-arrow {
  margin-left: auto;
  font-size: 14px;
  color: var(--brand);
  transition: transform 0.3s ease;
  display: inline-block;
  font-weight: 700;
}

.mobile-menu .topics-parent.expanded .expand-arrow {
  transform: rotate(180deg);
}

/* Topics List (Initially Hidden) */
.mobile-menu .topics-list {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
  background: #f9fafb;
  padding-left: 0;
}

.mobile-menu .topics-parent.expanded .topics-list {
  max-height: 1000px;
}

.mobile-menu .topics-list li {
  border-bottom: 2px solid #e5e7eb;
}

.mobile-menu .topics-list a {
  padding-left: 2rem;
  font-size: 14px;
  color: #4b5563;
  line-height: 1.5;
}

/* Hide Mobile Menu on Desktop Landscape (not tablet portrait) */
@media (min-width: 1025px), (orientation: landscape) and (min-width: 769px) {
  .mobile-hamburger,
  .mobile-menu,
  .mobile-menu-overlay {
    display: none !important;
  }
}

/* ===============================
   LANGUAGE TOGGLE - DESKTOP (iOS Style)
   =============================== */
.lang-toggle {
  margin-left: auto !important;
  display: flex;
  align-items: center;
  background: #e8e8e8;
  border: none;
  border-radius: 6px;
  padding: 2px;
  cursor: pointer;
  font-family: inherit;
  position: relative;
}

.nav-profile-right {
  margin-left: 12px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}

/* ===============================
   READING TIMER (below profile icon)
   =============================== */
.reading-timer {
  font-family: 'SF Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  line-height: 1;
  transition: color 0.8s ease;
  cursor: default;
  user-select: none;
}

.reading-timer.timer-red {
  color: #b91c1c;
}

.reading-timer.timer-green {
  color: #15803d;
}

/* Dark mode timer colors */
body.dark-mode .reading-timer.timer-red {
  color: #f87171;
}

body.dark-mode .reading-timer.timer-green {
  color: #4ade80;
}

/* Mobile menu timer strip */
.reading-timer-mobile {
  padding: 0.6rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid #e5e7eb;
  background: #fafafa;
}

.reading-timer-mobile .reading-timer {
  font-size: 0.95rem;
}

body.dark-mode .reading-timer-mobile {
  background: #1e293b;
  border-bottom-color: #334155;
}

.lang-option {
  font-size: 0.75rem;
  font-weight: 600;
  color: #666;
  padding: 4px 10px;
  border-radius: 5px;
  transition: all 0.25s ease;
  position: relative;
  z-index: 1;
  user-select: none;
}

.lang-option.active {
  color: #fff;
  background: var(--brand);
  box-shadow: 0 2px 6px rgba(252, 115, 6, 0.3);
}

.lang-option:not(.active):hover {
  color: #333;
}

/* Hide desktop toggle on mobile */
@media (max-width: 768px) {
  .lang-toggle {
    display: none !important;
  }
}

/* ===============================
   LANGUAGE FAB - MOBILE
   =============================== */
.lang-fab {
  display: none; /* Hidden by default, shown only on mobile */
  position: fixed;
  bottom: 24px;
  left: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand, #fc7306);
  color: white;
  border: none;
  box-shadow: 0 4px 14px rgba(252, 115, 6, 0.4);
  cursor: pointer;
  z-index: 999;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}

.lang-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(252, 115, 6, 0.5);
}

.lang-fab:active {
  transform: scale(0.95);
}

.fab-text {
  font-size: 0.8rem;
  font-weight: 700;
}

/* Show FAB only on mobile */
@media (max-width: 768px) {
  .lang-fab {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
