/* === LAYOUT STYLES — NAV, FOOTER, GRID === */

/* ===== NAVIGATION ===== */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 14px 24px;
  transition: background var(--duration-slow) ease, box-shadow var(--duration-base) ease, border-color var(--duration-base) ease;
}

.site-header.scrolled {
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 30px rgba(0,0,0,0.06);
}

.nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0;
  padding: 6px 6px 6px 20px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(0,0,0,0.08);
  box-shadow: 0 2px 16px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  transition: all var(--duration-base) ease;
  max-width: 1200px;
  margin: 0 auto;
  min-width: 0;
}

[data-theme="dark"] .nav-wrap {
  background: rgba(22,27,34,0.92);
  border-color: rgba(255,255,255,0.08);
}

.site-header.scrolled .nav-wrap {
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  border-color: rgba(0,0,0,0.06);
}

[data-theme="dark"] .site-header.scrolled .nav-wrap {
  background: rgba(22,27,34,0.95);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  text-decoration: none;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-base);
  transition: opacity var(--duration-fast) ease;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 0;
}

.nav-brand:hover {
  opacity: 0.85;
  color: var(--text-primary);
}

.nav-brand img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-full);
  text-decoration: none;
  position: relative;
  white-space: nowrap;
  transition: color var(--duration-fast) ease,
              background var(--duration-fast) ease;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--color-primary);
  border-radius: 1px;
  transition: width var(--duration-fast) ease, left var(--duration-fast) ease;
}

.nav-links a:hover {
  color: var(--color-primary);
  background: rgba(37, 99, 235, 0.06);
}

.nav-links a:hover::after {
  width: 60%;
  left: 20%;
}

.nav-links a.active {
  color: var(--color-primary);
  font-weight: 600;
}

.nav-links a.active::after {
  width: 60%;
  left: 20%;
}

.nav-icon {
  width: 0.9rem;
  height: 0.9rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Theme Toggle */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.06);
  background: rgba(0,0,0,0.03);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration-fast) ease,
              color var(--duration-fast) ease,
              transform var(--duration-fast) var(--ease-spring);
  position: relative;
  flex-shrink: 0;
}

[data-theme="dark"] .theme-toggle {
  border-color: rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.05);
}

.theme-toggle:hover {
  color: var(--color-primary);
  background: rgba(37, 99, 235, 0.08);
  transform: scale(1.1);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--duration-base) var(--ease-spring);
}

.theme-toggle .sun-icon {
  display: none;
}

.theme-toggle .moon-icon {
  display: block;
}

[data-theme="dark"] .theme-toggle .sun-icon {
  display: block;
}

[data-theme="dark"] .theme-toggle .moon-icon {
  display: none;
}

/* Nav Toggle (Mobile) */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 10px;
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast) ease;
}

.nav-toggle:hover {
  background: var(--bg-elevated);
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: transform var(--duration-base) var(--ease-spring),
              opacity var(--duration-fast) ease;
}

.nav-toggle.active span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.nav-toggle.active span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ===== FOOTER ===== */
.site-footer {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: var(--space-2xl) 0 var(--space-lg);
  margin-top: var(--space-2xl);
}

[data-theme="dark"] .site-footer {
  background: var(--bg-surface-dark);
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.5fr);
  gap: var(--space-xl);
}

.footer-grid > * {
  min-width: 0;
}

.footer-brand-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  text-decoration: none;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-base);
  min-width: 0;
  overflow-wrap: anywhere;
}

.footer-brand img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.footer-tagline {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.6;
  max-width: 300px;
}

.footer-social {
  display: flex;
  gap: var(--space-md);
}

.footer-social a {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--duration-fast) ease,
              color var(--duration-fast) ease,
              transform var(--duration-fast) ease;
}

.footer-social a:hover {
  background: var(--color-primary);
  color: white;
  transform: translateY(-2px);
}

.footer-social svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.footer-heading {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-primary);
  margin-bottom: var(--space-md);
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.footer-links a {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: color var(--duration-fast) ease;
  line-height: 1.5;
}

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

.footer-contact {
  list-style: none;
  padding: 0;
  margin: 0 0 var(--space-lg) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.footer-contact li {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.footer-contact span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.footer-contact svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  margin-top: 1px;
}

.footer-newsletter {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

.footer-newsletter form {
  display: flex;
  gap: var(--space-xs);
}

.footer-newsletter input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.85rem;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-primary);
}

.footer-newsletter input:focus {
  outline: none;
  border-color: var(--color-primary);
}

.footer-newsletter button {
  padding: 0.6rem 1rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-sm);
  border: none;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: white;
  cursor: pointer;
  transition: background var(--duration-fast) ease;
  white-space: nowrap;
}

.footer-newsletter button:hover {
  background: var(--color-secondary);
}

.footer-bottom {
  grid-column: 1 / -1;
  border-top: 1px solid var(--border);
  padding-top: var(--space-lg);
  margin-top: var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.footer-bottom a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-bottom a:hover {
  color: var(--color-primary);
}

.footer-bottom-links {
  display: flex;
  gap: var(--space-md);
}

/* ===== SIDEBAR NAV (Mobile — Full-Screen Right Panel) ===== */
.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1099;
  background: rgba(8, 13, 23, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

.nav-sidebar-close {
  display: none;
}

.nav-sidebar-header {
  display: none;
}

.nav-sidebar-brand {
  display: none;
}

.mobile-nav-cta {
  display: none;
}

body.nav-open {
  overflow: hidden;
}

body.nav-open .site-header {
  z-index: 1200;
}

@media (max-width: 1024px) {
  .nav-toggle {
    display: flex;
  }

  /* Sidebar header row: brand left, close right */
  .nav-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    margin-bottom: var(--space-xl);
    opacity: 1;
    transform: none;
    transition: none;
  }

  .nav-links.open .nav-sidebar-header {
    opacity: 1;
    transform: none;
  }

  .nav-sidebar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text-primary);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--text-base);
  }

  .nav-sidebar-brand img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(37, 99, 235, 0.2);
  }

  .nav-sidebar-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    transition: all 0.25s var(--ease-spring);
    flex-shrink: 0;
  }

  .nav-sidebar-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #DC2626;
    border-color: rgba(239, 68, 68, 0.25);
    transform: rotate(90deg);
  }

  /* Full-screen right panel */
  .nav-links {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    z-index: 1100;
    background: var(--bg-surface);
    border-left: none;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 0;
    padding: var(--space-xl) var(--space-lg) var(--space-2xl);
    transform: translateX(100%);
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.1, 1);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: -12px 0 48px rgba(0,0,0,0.18);
    opacity: 1;
    pointer-events: none;
    -webkit-overflow-scrolling: touch;
  }

  [data-theme="dark"] .nav-links {
    box-shadow: -12px 0 48px rgba(0,0,0,0.5);
  }

  .nav-links.open {
    transform: translateX(0);
    pointer-events: auto;
  }

  .nav-links li {
    opacity: 1;
    transform: none;
    transition: none;
    border-radius: var(--radius-md);
  }

  .nav-links.open li {
    opacity: 1;
    transform: none;
  }

  /* Divider line below header */
  .nav-sidebar-header + li {
    border-top: 1px solid var(--border);
    margin-top: var(--space-xs);
    padding-top: var(--space-xs);
  }

  .nav-links a {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-size: var(--text-xl);
    font-weight: 500;
    padding: var(--space-lg) var(--space-lg);
    border-radius: var(--radius-lg);
    width: 100%;
    color: var(--text-secondary);
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
  }

  .nav-links a:active {
    transform: scale(0.97);
  }

  .nav-links a::after {
    display: none;
  }

  .nav-links a:hover {
    background: var(--gradient-card);
    color: var(--color-primary);
  }

  .nav-links a.active {
    color: var(--color-primary);
    font-weight: 600;
    background: rgba(37, 99, 235, 0.06);
  }

  .nav-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
  }

  /* Hide the donate CTA button inside the sidebar — it stays in the header */
  .nav-links .btn-donate-glow {
    display: none;
  }

  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-lg);
  }

  .footer-brand-section {
    grid-column: 1 / -1;
  }

  .footer-bottom {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .footer-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .footer-newsletter form {
    flex-direction: column;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
  }

  .nav-brand span {
    display: none;
  }

  .btn-donate-glow {
    font-size: var(--text-xs);
    padding: 0.6rem 1rem;
  }
}

/* Refined mobile navigation drawer */
@media (max-width: 1024px) {
  .site-header {
    padding: 10px 14px;
  }

  .nav-wrap {
    gap: var(--space-xs);
    padding: 6px 8px 6px 14px;
  }

  .nav-actions {
    gap: 6px;
  }

  .theme-toggle {
    order: 1;
  }

  .nav-actions .btn-donate-glow {
    order: 2;
  }

  .nav-toggle {
    order: 3;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--bg-surface);
  }

  .nav-sidebar-header {
    padding: 0 0 var(--space-lg);
    margin-bottom: 0;
  }

  .nav-sidebar-brand {
    max-width: calc(100% - 58px);
  }

  .nav-sidebar-brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .nav-sidebar-close {
    border-radius: var(--radius-md);
    font-size: 1.35rem;
  }

  .nav-sidebar-close:hover {
    transform: none;
  }

  .nav-links {
    top: 10px;
    right: 10px;
    bottom: 10px;
    width: min(390px, calc(100vw - 20px));
    height: calc(100vh - 40px);
    height: calc(100dvh - 40px);
    gap: 6px;
    padding: var(--space-lg);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: -12px 18px 54px rgba(15, 23, 42, 0.2);
    transform: translateX(calc(100% + 24px));
    transition: transform 0.36s var(--ease-smooth), box-shadow var(--duration-base) ease;
  }

  [data-theme="dark"] .nav-links {
    box-shadow: -12px 18px 54px rgba(0,0,0,0.52);
  }

  .nav-links li {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .nav-sidebar-header + li {
    margin-top: 0;
    padding-top: var(--space-sm);
  }

  .nav-links a {
    gap: 0.85rem;
    min-height: 54px;
    padding: 0.85rem 0.95rem;
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: 650;
    line-height: 1.2;
  }

  .nav-links a:hover,
  .nav-links a:focus-visible {
    background: var(--bg-elevated);
    color: var(--color-primary);
  }

  .nav-icon {
    width: 1.1rem;
    height: 1.1rem;
  }

  .mobile-nav-cta {
    display: block;
    margin-top: auto;
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
  }

  .mobile-nav-cta a {
    justify-content: center;
    min-height: 52px;
    color: white;
    background: var(--gradient-cta);
    box-shadow: var(--shadow-glow-accent);
  }

  .mobile-nav-cta a:hover,
  .mobile-nav-cta a:focus-visible {
    color: white;
    background: var(--gradient-cta-alt);
  }
}

@media (max-width: 640px) {
  .site-header {
    padding-inline: 10px;
  }

  .nav-wrap {
    padding-left: 10px;
  }

  .nav-actions .btn-donate-glow {
    display: none;
  }

  .nav-links {
    inset: 8px;
    width: auto;
    height: calc(100vh - 38px);
    height: calc(100dvh - 38px);
    border-radius: 20px;
    padding: var(--space-lg) var(--space-md);
  }
}
