/**
 * Slide-in sidebar nav and collapsible footer.
 * Mobile-responsive: safe areas, touch targets, viewport height.
 * Sidebar overlays the page only; page must not scroll horizontally.
 */

/* Lock viewport: page stays normal size, sidebar slides over it (no horizontal scroll) */
html { overflow-x: hidden; width: 100%; }
body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  /* Prevent touch from scrolling page horizontally on mobile */
  touch-action: pan-y;
}

/* ----- Sidebar ----- */
.nav-sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1040;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  cursor: pointer;
  pointer-events: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.nav-sidebar-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.nav-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 280px;
  max-width: 85vw;
  height: 100vh;
  height: 100dvh;
  min-height: -webkit-fill-available;
  background: #fff;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
  z-index: 1050;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
  padding-right: env(safe-area-inset-right, 0);
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-sidebar.is-open {
  transform: translateX(0);
}

.nav-sidebar-header {
  padding: 1rem 1.25rem;
  padding-left: max(1.25rem, env(safe-area-inset-left));
  border-bottom: 1px solid #eee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.nav-sidebar-header .site-logo { font-size: 1.25rem; margin: 0; }
.nav-sidebar-close {
  width: 40px;
  height: 40px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: #f0f0f0;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #333;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.nav-sidebar-close:hover { background: #e0e0e0; }

.nav-sidebar-body {
  padding: 1rem 0;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
}
.nav-sidebar-section { padding: 0 1rem 0.75rem; padding-left: max(1rem, env(safe-area-inset-left)); }
.nav-sidebar-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6c757d;
  margin-bottom: 0.5rem;
  padding: 0 0.25rem;
}
.nav-sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  min-height: 44px;
  box-sizing: border-box;
  color: #212529;
  text-decoration: none;
  border-radius: 8px;
  margin-bottom: 2px;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.nav-sidebar-link:hover { background: #f0f0f0; color: #212529; }
.nav-sidebar-link.active { background: rgba(255, 107, 107, 0.15); color: #c44569; font-weight: 600; }
.nav-sidebar-link i { width: 1.25em; text-align: center; flex-shrink: 0; }
.nav-sidebar-divider { height: 1px; background: #eee; margin: 0.5rem 1rem; }

.btn-nav-menu {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.95);
  color: #333;
  cursor: pointer;
  font-size: 1.25rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: background 0.2s, transform 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.btn-nav-menu:hover { background: #fff; transform: scale(1.02); }
.btn-nav-menu:focus { outline: 2px solid var(--primary-color, #ff6b6b); outline-offset: 2px; }

/* Prevent body scroll when sidebar open */
body.nav-sidebar-open {
  overflow: hidden;
  touch-action: none;
}

/* ----- Mobile: sidebar full-width and safe areas ----- */
@media (max-width: 575.98px) {
  .nav-sidebar {
    width: 100%;
    max-width: 100%;
    padding-right: 0;
    right: 0;
  }
  .nav-sidebar-header,
  .nav-sidebar-section {
    padding-left: max(1rem, env(safe-area-inset-left));
  }
}

/* ----- Footer collapsible ----- */
.site-footer .footer-collapsible {
  overflow: hidden;
  transition: max-height 0.35s ease, opacity 0.3s ease;
}
.site-footer.footer-collapsed .footer-collapsible {
  max-height: 0 !important;
  opacity: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  pointer-events: none;
}
.site-footer:not(.footer-collapsed) .footer-collapsible {
  max-height: 420px;
  opacity: 1;
}

.footer-toggle-wrap { margin-top: 0.5rem; margin-bottom: 0.5rem; }
.btn-footer-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-footer-toggle:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.btn-footer-toggle i { transition: transform 0.25s; }
.site-footer.footer-collapsed .btn-footer-toggle i.fa-chevron-down { transform: rotate(-90deg); }

/* Footer links grid - uniform size */
.footer-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
  justify-content: center;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}
.footer-links-grid .footer-link {
  min-width: 0;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  text-align: center;
}

.social-links { margin-top: 0.75rem; }
