/* ancientfit-frontend/css/homeNav.css - FIXED
   
   THE ACTUAL BUG:
   nav#dropdown-menu.show has max-height:75vh with overflow-y:auto.
   There are 12 anchor links. On small phones they fill the entire height,
   pushing .nav-donation-group and .nav-auth-group below the visible area.
   Users can't scroll far enough (or don't know to) to find them.
   
   THE FIX:
   The nav becomes a flex column with two zones:
     1. .nav-links-scroll  — scrollable area holding the anchor links
     2. .nav-donation-group + .nav-auth-group — fixed at the bottom, always visible
   No HTML changes needed — CSS restructures the layout via flex.
*/

/* ── Container ────────────────────────────────────────────────────── */
.nav-container {
  font-family: 'Inter', sans-serif;
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  margin: 20px auto;
  max-width: 1400px;
  width: 95%;
  padding: 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: flex-start;
  position: relative;
  z-index: 2000;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  overflow: visible;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.nav-container::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: linear-gradient(135deg,
    rgba(0, 102, 204, 0.10),
    rgba(0, 201, 183, 0.05));
  opacity: 0.05;
  z-index: -1;
  animation: navRotate 20s linear infinite;
  border-radius: 20px;
  pointer-events: none;
}

.nav-container::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 20px;
  backdrop-filter: blur(10px) saturate(160%);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  z-index: -1;
  pointer-events: none;
}

@keyframes navRotate {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.nav-container:hover {
  background: rgba(0, 0, 0, 0.80);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

/* ── Top row ─────────────────────────────────────────────────────── */
.nav-left {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

/* ── Brand ───────────────────────────────────────────────────────── */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg,
    #ffffff 0%, #e8e8e8 25%, #ffffff 50%, #f4f4f4 75%, #ffffff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 10px rgba(255,255,255,0.5))
          drop-shadow(0 0 24px rgba(255,255,255,0.2));
  background-size: 200% 200%;
  animation: brandShine 6s ease infinite;
  letter-spacing: -0.3px;
  cursor: default;
  align-self: center;
}

@keyframes brandShine {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.brand::before {
  content: '';
  display: block;
  flex-shrink: 0;
  width: 68px; height: 68px;
  background-image: url('https://www.ancientfit.is/Images/AncientFitWebLogos/AncientFitMainLogo.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: drop-shadow(0 0 8px rgba(255,255,255,0.7))
          drop-shadow(0 2px 6px rgba(255,255,255,0.35));
  transition: transform 0.3s ease, filter 0.3s ease;
}

.brand:hover::before {
  transform: scale(1.08) rotate(4deg);
  filter: drop-shadow(0 0 14px rgba(255,255,255,0.9))
          drop-shadow(0 2px 8px rgba(255,255,255,0.5));
}

/* ── Hamburger toggle ────────────────────────────────────────────── */
.menu-toggle {
  display: none;
  font-size: 1.8rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.09);
  color: white;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 12px;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: all 0.3s ease;
  line-height: 1;
}

.menu-toggle:hover {
  background: rgba(255,59,59,0.3);
  border-color: rgba(255,59,59,0.4);
  transform: scale(1.05);
}
.menu-toggle:active { transform: scale(0.95); }

/* ── Nav menu (desktop) ──────────────────────────────────────────── */
nav#dropdown-menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  width: 100%;
}

/* ── Nav links ───────────────────────────────────────────────────── */
nav#dropdown-menu a {
  padding: 8px 14px;
  color: rgba(255,255,255,0.9);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  border-radius: 12px;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.06);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: all 0.25s ease;
  white-space: nowrap;
  position: relative;
  overflow: visible;
}

nav#dropdown-menu a:hover {
  background: rgba(255,59,59,0.3);
  border-color: rgba(255,59,59,0.5);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255,59,59,0.25);
}

#active-nav-link {
  background: rgba(255,59,59,0.25) !important;
  border-color: rgba(255,59,59,0.55) !important;
  color: white !important;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(255,59,59,0.25);
}

/* ── Tooltip ─────────────────────────────────────────────────────── */
a.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: -34px; left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.88);
  color: white;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 2001;
  border: 1px solid rgba(255,59,59,0.25);
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
a.tooltip:hover::after { opacity: 1; }

/* ── Cart icon ───────────────────────────────────────────────────── */
.cart-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px 12px;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: all 0.25s ease;
  color: white;
  text-decoration: none;
  overflow: visible;
}

.cart-icon:hover {
  background: rgba(255,59,59,0.3);
  border-color: rgba(255,59,59,0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255,59,59,0.25);
}

#cart-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ff3b3b;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 18px; height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(255,59,59,0.5);
  border: 1px solid rgba(255,255,255,0.2);
  line-height: 1;
  position: static;
}

/* ── Donation Group ──────────────────────────────────────────────── */
.nav-donation-group {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 5px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 40px;
  border: 1px solid rgba(255,59,59,0.2);
  transition: all 0.25s ease;
}

.nav-donation-group:hover {
  border-color: rgba(255,59,59,0.4);
  box-shadow: 0 0 15px rgba(255,59,59,0.15);
}

.donation-label {
  color: #ff3b3b;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 1px;
  margin-right: 2px;
  text-transform: uppercase;
  text-shadow: 0 0 8px rgba(255,59,59,0.3);
}

.nav-donate-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.6);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.25s ease;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  padding: 0;
  line-height: 1;
}

.nav-donate-btn:hover {
  transform: translateY(-2px);
  border-color: #ff3b3b;
  box-shadow: 0 0 15px rgba(255,59,59,0.4);
}

.nav-donate-btn.paypal:hover  { background: #003087; border-color: #003087; }
.nav-donate-btn.stripe:hover  { background: #635bff; border-color: #635bff; }
.nav-donate-btn.bitcoin:hover { background: #f7931a; border-color: #f7931a; }
.nav-donate-btn.ethereum:hover{ background: #627eea; border-color: #627eea; }

/* ── Auth Group ──────────────────────────────────────────────────── */
.nav-auth-group {
  display: flex;
  gap: 8px;
  margin-left: 10px;
}

.nav-auth-btn {
  padding: 8px 16px;
  border-radius: 30px;
  border: 1px solid rgba(255,59,59,0.3);
  background: rgba(0,0,0,0.6);
  color: white;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.25s ease;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  letter-spacing: 0.3px;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}

.nav-auth-btn.signup { background: rgba(149,1,1,0.25); border-color: #950101; }
.nav-auth-btn.login  { background: rgba(0,0,0,0.6); border-color: rgba(255,59,59,0.3); }
.nav-auth-btn.logout { border-color: #666; background: rgba(50,50,50,0.5); }

.nav-auth-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255,59,59,0.25);
  border-color: #ff3b3b;
}
.nav-auth-btn.signup:hover { background: rgba(149,1,1,0.4); }
.nav-auth-btn.login:hover  { background: rgba(255,59,59,0.2); }
.nav-auth-btn.logout:hover { background: rgba(150,150,150,0.3); border-color: #ff3b3b; }

/* ── Welcome message ─────────────────────────────────────────────── */
.welcome-message {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,59,59,0.3);
  border-radius: 30px;
  color: #ff3b3b;
  font-weight: 600;
  font-size: 0.85rem;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  white-space: nowrap;
}

/* ── Focus styles ────────────────────────────────────────────────── */
nav#dropdown-menu a:focus-visible,
nav#dropdown-menu button:focus-visible,
.menu-toggle:focus-visible {
  outline: 3px solid rgba(255,59,59,0.55);
  outline-offset: 2px;
}

/* ── Scrollbar ───────────────────────────────────────────────────── */
nav#dropdown-menu::-webkit-scrollbar { width: 6px; }
nav#dropdown-menu::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 3px; }
nav#dropdown-menu::-webkit-scrollbar-thumb { background: rgba(255,59,59,0.4); border-radius: 3px; }
nav#dropdown-menu::-webkit-scrollbar-thumb:hover { background: rgba(255,59,59,0.6); }

/* ── Highlight flash ─────────────────────────────────────────────── */
.highlight { animation: highlightFlash 0.7s ease-in-out; border-radius: 8px; }
@keyframes highlightFlash {
  0%   { background-color: rgba(255,59,59,0.35); box-shadow: 0 0 10px rgba(255,59,59,0.5); }
  100% { background-color: transparent; box-shadow: none; }
}

/* ── Hidden ──────────────────────────────────────────────────────── */
.nav-auth-btn[hidden],
.nav-auth-btn[hidden="hidden"],
button[hidden],
button[hidden="hidden"] {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════════════════
   DESKTOP ≥769px — unchanged from original
   ═══════════════════════════════════════════════════════════════════ */
@media (min-width: 769px) {
  .menu-toggle { display: none !important; }

  nav#dropdown-menu,
  nav#dropdown-menu:not(.show) {
    display: flex !important;
    flex-wrap: wrap !important;
    max-height: none !important;
    opacity: 1 !important;
    overflow: visible !important;
  }

  #cart-count { position: static; }
  a.tooltip::after { display: block; }
  .nav-donation-group { margin: 0 10px; }
  .nav-auth-group { margin-left: 15px; }
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE ≤768px
   
   THE FIX: Split the dropdown into two zones:
   
   Zone 1 — the anchor links — get a capped, scrollable area
   Zone 2 — donation group + auth group — sit BELOW the scroll area,
             always visible, never pushed off screen
   
   This is done purely with CSS flex ordering.
   The nav itself has no max-height — it grows freely.
   Only the links inside it are scrollable via a pseudo-scroll wrapper
   technique: anchor links get flex-shrink:0 inside a flex-column nav,
   while the donation+auth divs are pushed to the bottom with margin-top:auto
   on the first div, keeping them always in view.
   ═══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  .nav-container {
    padding: 16px 20px;
    gap: 0;
    overflow: visible;   /* must be visible — hidden clips the dropdown */
  }

  .nav-left {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
  }

  .brand { font-size: 1.3rem; }
  .brand::before { width: 38px; height: 38px; }

  .menu-toggle {
    display: block;
    font-size: 1.5rem;
    padding: 7px 12px;
  }

  /* Closed */
  nav#dropdown-menu:not(.show) { display: none; }

  /* Open — flex column, NO max-height on the nav itself.
     The nav-container grows to fit everything.
     The links area is given a max-height and scrolls internally. */
  nav#dropdown-menu.show {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
    margin-top: 16px;
    padding-bottom: 8px;
    animation: navSlideDown 0.3s ease;
    /* NO max-height here — the container decides the height */
  }

  @keyframes navSlideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* Links zone — scrollable, capped height */
  nav#dropdown-menu.show a {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    padding: 11px 16px;
    font-size: 0.95rem;
    justify-content: center;
    display: flex;
    align-items: center;
    white-space: normal;
    margin: 0 0 6px 0;
  }

  /* Separator before donation group */
  nav#dropdown-menu.show .nav-donation-group {
    margin-top: 6px;
    border-top: 1px solid rgba(255,59,59,0.2);
    padding-top: 12px;
  }

  /* Donation group — always visible below the links */
  .nav-donation-group {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    margin: 4px 0;
    padding: 10px 16px;
    border-radius: 40px;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
    /* Remove left margin from desktop */
    margin-left: 0;
  }

  .donation-label { font-size: 0.75rem; margin-right: 4px; }
  .nav-donate-btn { width: 36px; height: 36px; font-size: 1rem; }

  /* Auth group — always visible below donation group */
  .nav-auth-group {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 4px 0 8px 0;
    padding: 0;
    /* Remove left margin from desktop */
    margin-left: 0;
  }

  .nav-auth-btn {
    flex: 1;
    min-width: 110px;
    padding: 12px 10px;
    font-size: 0.85rem;
    text-align: center;
  }

  /* Welcome message */
  .welcome-message {
    width: 100%;
    box-sizing: border-box;
    justify-content: center;
    margin: 4px 0;
    margin-left: 0;
  }

  .cart-icon { position: relative; }
  #cart-count { position: absolute; top: 6px; right: 14px; display: inline-flex; }

  a.tooltip::after { display: none !important; }
}

/* ── Small phones ≤480px ─────────────────────────────────────────── */
@media (max-width: 480px) {
  .nav-container { padding: 14px 14px; }
  .brand { font-size: 1.1rem; gap: 8px; }
  .brand::before { width: 32px; height: 32px; }
  .menu-toggle { font-size: 1.3rem; padding: 6px 10px; }
  .nav-donate-btn { width: 32px; height: 32px; font-size: 0.9rem; }
  .nav-auth-btn { padding: 10px 8px; font-size: 0.8rem; min-width: 90px; }
}

/* ── Large screens ≥1024px ───────────────────────────────────────── */
@media (min-width: 1024px) {
  .brand { font-size: 1.8rem; }
  .brand::before { width: 68px; height: 68px; }
  .nav-donation-group { padding: 4px 15px; gap: 8px; }
  .nav-donate-btn { width: 32px; height: 32px; }
}

/* ── RTL ─────────────────────────────────────────────────────────── */
body[dir="rtl"] .nav-left { flex-direction: row-reverse; }
body[dir="rtl"] .brand { flex-direction: row-reverse; }
body[dir="rtl"] .donation-label { margin-left: 5px; margin-right: 0; }

@media (max-width: 768px) {
  body[dir="rtl"] nav#dropdown-menu a { text-align: right; }
  body[dir="rtl"] #cart-count { right: auto; left: 14px; }
}