/* =========================================
   PREHISTORY CLUB OF KENYA
   Modern Mobile Navigation + Overall Polish
   2024/2025 – Stylish, touch-friendly, premium
========================================= */

/* ---------- Base improvements ---------- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  overflow-x: hidden;
}

body.menu-open {
  overflow: hidden;
}

img, video, iframe {
  max-width: 100%;
  height: auto;
}

/* Better touch targets */
a, button, .btn, .nav-link, .dropdown-item {
  min-height: 44px;
  touch-action: manipulation;
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
  .navbar .container,
  footer .container {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
}

/* ---------- Animated Hamburger ---------- */
.mobile-nav-toggle {
  border: none !important;
  background: transparent !important;
  padding: 8px !important;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: none !important;
  position: relative;
  z-index: 1060;
}

.mobile-nav-toggle:focus {
  box-shadow: none !important;
  outline: none;
}

.hamburger-box {
  width: 24px;
  height: 18px;
  display: inline-block;
  position: relative;
}

.hamburger-inner,
.hamburger-inner::before,
.hamburger-inner::after {
  width: 24px;
  height: 2.5px;
  background-color: #fff;
  border-radius: 3px;
  position: absolute;
  transition: transform 0.25s ease, opacity 0.2s ease, top 0.2s ease;
}

.hamburger-inner {
  top: 50%;
  margin-top: -1.25px;
}

.hamburger-inner::before,
.hamburger-inner::after {
  content: "";
  display: block;
}

.hamburger-inner::before {
  top: -7px;
}

.hamburger-inner::after {
  bottom: -7px;
}

/* Hamburger → X when menu open */
.navbar-toggler[aria-expanded="true"] .hamburger-inner {
  background-color: transparent;
}

.navbar-toggler[aria-expanded="true"] .hamburger-inner::before {
  top: 0;
  transform: rotate(45deg);
}

.navbar-toggler[aria-expanded="true"] .hamburger-inner::after {
  bottom: 0;
  transform: rotate(-45deg);
}

/* Brand refinements */
.navbar-brand .brand-text h5 {
  font-size: 1.15rem;
  line-height: 1.2;
  font-weight: 700;
}

.navbar-brand .brand-text small {
  font-size: 0.75rem;
  opacity: 0.9;
}

/* ---------- TABLET & BELOW (≤ 991.98px) ---------- */
@media (max-width: 991.98px) {

  /* Navbar bar */
  .navbar {
    padding: 8px 0 !important;
  }

  .navbar-brand .brand-logo {
    height: 40px !important;
    width: 40px !important;
  }

  .navbar-brand .brand-text h5 {
    font-size: 1rem !important;
  }

  .navbar-brand .brand-text small {
    font-size: 0.68rem !important;
  }

  /* Full-screen style mobile menu */
  .navbar-collapse {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: linear-gradient(165deg, #8B3A1A 0%, #5E2525 55%, #3d1810 100%);
    margin: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    z-index: 1055;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex !important;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-12px);
    transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s;
  }

  .navbar-collapse.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  /* Mobile menu header */
  .mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
  }

  .mobile-menu-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #E5A624;
    letter-spacing: 0.5px;
  }

  .mobile-menu-close {
    width: 42px;
    height: 42px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    transition: background 0.2s;
  }

  .mobile-menu-close:hover,
  .mobile-menu-close:active {
    background: rgba(229, 166, 36, 0.35);
  }

  /* Nav links */
  .navbar-nav {
    flex: 1;
    padding: 16px 16px 8px;
    gap: 4px;
  }

  .nav-item {
    width: 100%;
  }

  .nav-link {
    padding: 14px 16px !important;
    border-radius: 12px;
    font-size: 1.05rem !important;
    font-weight: 500;
    color: #fff !important;
    display: flex;
    align-items: center;
    transition: background 0.2s, color 0.2s;
  }

  .nav-link .nav-icon {
    width: 22px;
    text-align: center;
    opacity: 0.9;
    color: #E5A624;
  }

  .nav-link:hover,
  .nav-link:focus,
  .nav-link.active {
    background: rgba(229, 166, 36, 0.18) !important;
    color: #E5A624 !important;
  }

  /* Dropdown inside mobile menu */
  .dropdown-menu {
    border: none !important;
    background: rgba(0, 0, 0, 0.2) !important;
    box-shadow: none !important;
    padding: 6px 0 6px 12px !important;
    margin: 0 0 4px !important;
    border-radius: 10px !important;
    position: static !important;
    float: none !important;
    width: 100% !important;
    transform: none !important;
  }

  .dropdown-item {
    color: rgba(255, 255, 255, 0.9) !important;
    border-radius: 8px;
    padding: 11px 16px !important;
    font-size: 0.95rem;
  }

  .dropdown-item:hover,
  .dropdown-item:focus {
    background: rgba(229, 166, 36, 0.2) !important;
    color: #E5A624 !important;
  }

  /* Actions (theme + join + login) */
  .nav-actions {
    padding: 16px 20px 28px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
    flex-shrink: 0;
  }

  .nav-actions .theme-toggle {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px !important;
    border-color: rgba(255, 255, 255, 0.35);
  }

  .nav-actions .join-btn {
    width: 100%;
    text-align: center;
    padding: 13px 20px !important;
    font-size: 1.05rem;
    font-weight: 600;
  }

  .nav-actions .admin-login-link {
    text-align: center;
    opacity: 0.85;
    font-size: 0.95rem;
    padding: 10px !important;
  }

  /* Sections & typography */
  section {
    padding-top: 48px !important;
    padding-bottom: 48px !important;
  }

  .section-title {
    font-size: 1.65rem !important;
    line-height: 1.25 !important;
  }

  .section-text {
    font-size: 0.95rem !important;
  }

  .section-tag {
    font-size: 11px !important;
    padding: 5px 14px !important;
  }

  /* Cards */
  .news-card,
  .event-card,
  .gallery-card,
  .mission-card {
    margin-bottom: 16px;
  }

  .card-title,
  .news-card h5,
  .event-card h5 {
    font-size: 1.05rem !important;
  }

  /* Forms – prevent iOS zoom */
  .form-control,
  .form-select,
  .form-control-lg,
  .form-select-lg {
    font-size: 16px !important;
    padding: 0.7rem 0.95rem !important;
  }

  .btn-lg {
    font-size: 1rem !important;
    padding: 0.75rem 1.4rem !important;
  }

  /* Hero */
  .hero,
  .hero img,
  .carousel-item img {
    height: 78vh !important;
    min-height: 420px;
  }

  .carousel-caption {
    left: 5% !important;
    right: 5% !important;
    bottom: 12% !important;
    width: auto !important;
    max-width: none !important;
    text-align: left !important;
    padding: 0 !important;
  }

  .carousel-caption h1 {
    font-size: 1.85rem !important;
    line-height: 1.2 !important;
    margin-bottom: 10px !important;
  }

  .carousel-caption p,
  .carousel-caption .lead {
    font-size: 0.95rem !important;
    margin-bottom: 16px !important;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .hero-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .hero-buttons .btn {
    width: 100%;
    max-width: 280px;
    text-align: center;
    padding: 12px 20px !important;
  }

  /* Counter */
  .counter {
    font-size: 2.2rem !important;
  }

  /* Hide floating quick links on mobile */
  .quick-float {
    display: none !important;
  }

  /* Fossil map */
  .fossil-map-container {
    height: 320px !important;
    border-radius: 16px !important;
  }

  .fossil-sites-list {
    max-height: none !important;
    margin-top: 20px;
  }

  /* Footer */
  footer {
    padding-top: 40px !important;
    padding-bottom: 30px !important;
  }

  footer .col-lg-4,
  footer .col-lg-3,
  footer .col-lg-2,
  footer [class*="col-"] {
    margin-bottom: 28px;
  }
}

/* ---------- PHONES (≤ 767.98px) ---------- */
@media (max-width: 767.98px) {

  .hero,
  .hero img,
  .carousel-item img {
    height: 70vh !important;
    min-height: 380px;
  }

  .carousel-caption h1 {
    font-size: 1.6rem !important;
  }

  .carousel-caption p,
  .carousel-caption .lead {
    font-size: 0.9rem !important;
    -webkit-line-clamp: 2;
  }

  .section-title {
    font-size: 1.5rem !important;
  }

  .row > [class*="col-"] {
    margin-bottom: 12px;
  }

  .mission-card {
    flex-direction: column;
    text-align: center;
    align-items: center;
    gap: 12px;
    padding: 18px 16px !important;
  }

  .mission-icon {
    width: 56px !important;
    height: 56px !important;
    font-size: 22px !important;
  }

  .timeline-card {
    margin-left: 0 !important;
  }

  .program-card,
  .gallery-card {
    margin-bottom: 18px;
  }

  .hero-buttons .btn,
  .cta-section .btn,
  .newsletter .btn {
    width: 100%;
    max-width: 100%;
  }

  .news-card:hover,
  .event-card:hover,
  .gallery-card:hover {
    transform: none;
  }
}

/* ---------- SMALL PHONES (≤ 575.98px) ---------- */
@media (max-width: 575.98px) {

  .navbar-brand .brand-text h5 {
    font-size: 0.92rem !important;
  }

  .hero,
  .hero img,
  .carousel-item img {
    height: 65vh !important;
    min-height: 340px;
  }

  .carousel-caption {
    bottom: 10% !important;
  }

  .carousel-caption h1 {
    font-size: 1.4rem !important;
    margin-bottom: 8px !important;
  }

  .carousel-caption p {
    display: none;
  }

  .carousel-caption .lead {
    font-size: 0.85rem !important;
    -webkit-line-clamp: 2;
    margin-bottom: 12px !important;
  }

  .section-title {
    font-size: 1.35rem !important;
  }

  .section-tag {
    font-size: 10px !important;
    padding: 4px 12px !important;
  }

  .container,
  .container-fluid {
    padding-left: 14px;
    padding-right: 14px;
  }

  section {
    padding-top: 40px !important;
    padding-bottom: 40px !important;
  }

  .form-label {
    font-size: 0.9rem;
  }

  footer h5,
  footer h6 {
    font-size: 1rem !important;
  }

  footer p,
  footer li,
  footer a {
    font-size: 0.88rem !important;
  }
}

/* ---------- Landscape phones ---------- */
@media (max-width: 991.98px) and (orientation: landscape) {
  .hero,
  .hero img,
  .carousel-item img {
    height: 100vh !important;
    min-height: 280px;
  }

  .carousel-caption {
    bottom: 8% !important;
  }

  .carousel-caption h1 {
    font-size: 1.5rem !important;
  }

  .navbar-collapse {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ---------- Prefer reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .navbar-collapse {
    transition: none !important;
  }
}

/* ---------- Dark mode mobile menu ---------- */
@media (max-width: 991.98px) {
  [data-theme="dark"] .navbar-collapse {
    background: linear-gradient(165deg, #1a1410 0%, #14110f 50%, #0d0b09 100%);
  }

  [data-theme="dark"] .mobile-menu-header {
    border-bottom-color: rgba(229, 166, 36, 0.15);
  }

  [data-theme="dark"] .dropdown-menu {
    background: rgba(255, 255, 255, 0.06) !important;
  }
}

/* ---------- Print ---------- */
@media print {
  .navbar,
  .quick-float,
  .theme-toggle,
  .carousel-control-prev,
  .carousel-control-next {
    display: none !important;
  }
}

/* Override Bootstrap collapse height animation for full-screen mobile menu */
@media (max-width: 991.98px) {
  .navbar-collapse.collapsing {
    height: 100vh !important;
    height: 100dvh !important;
    transition: opacity 0.28s ease, transform 0.28s ease !important;
    opacity: 0.5;
    transform: translateY(-8px);
  }
}
