/* ========================================
   MOBILE-FIRST RESPONSIVE STYLESHEET
   Version 3.0 — Aligned with style.css v3.0
   Works with Tailwind CDN
   ======================================== */

/* ========================================
   BASE MOBILE (320px - 640px)
   ======================================== */

html, body {
  overflow-x: hidden !important;
  max-width: 100vw;
}

*, *::before, *::after {
  box-sizing: border-box;
}

img, video, iframe, table, pre, code {
  max-width: 100% !important;
}

section, main, article, div, footer, header, nav {
  max-width: 100vw;
}

/* ========================================
   RESPONSIVE TYPOGRAPHY
   ======================================== */

h1, .hero-title {
  line-height: 1.4 !important;
}

h2, h3 {
  line-height: 1.35 !important;
}

p, body {
  line-height: 1.6;
}

label {
  font-size: 0.875rem;
  letter-spacing: 0.05em;
}

@media (min-width: 641px) {
  label {
    font-size: 0.75rem;
    letter-spacing: 0.075em;
  }
}

/* Form Field Improvements */
.form-field {
  padding: 10px 12px;
}

@media (min-width: 641px) {
  .form-field {
    padding: 12px 16px;
  }
}

/* Hero Card Padding Responsive */
.hero-card {
  padding: clamp(1rem, 4vw, 2rem) !important;
}

/* Improve Card Overlay Visibility */
.hero-card::before,
.hero-card > div:first-child {
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.7) 30%, transparent 100%) !important;
}

/* ========================================
   MOBILE MENU — z-index: 9999 (aligned with style.css)
   ======================================== */

/* Mobile menu - default hidden state */
#mobileMenu.hidden {
  display: none !important;
}

/* Show on mobile/tablet when NOT hidden */
@media (max-width: 1023px) {
  #mobileMenu:not(.hidden) {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999 !important;
  }
}

/* Ensure hidden on desktop regardless */
@media (min-width: 1024px) {
  #mobileMenu {
    display: none !important;
  }
}

/* Ensure menu toggle button is always visible on mobile */
@media (max-width: 1023px) {
  #menuToggle {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 10000 !important;
  }

  #langToggleMobile {
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
}

/* Hide button controls on desktop */
@media (min-width: 1024px) {
  #menuToggle {
    display: none !important;
  }

  #langToggleMobile {
    display: none !important;
  }
}

/* ========================================
   HERO CARDS GRID
   ======================================== */

#hero-cards {
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 641px) {
  #hero-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.75rem;
  }
}

@media (min-width: 1024px) {
  #hero-cards {
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
  }
}

/* ========================================
   FOOTER LINKS GRID — always 2-column
   ======================================== */

.footer-links-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1.5rem;
}

/* ========================================
   SECTION WIDTH — 100% fluid on mobile
   ======================================== */

section {
  width: 100%;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* Hero sections */
.hero-remembrance,
.hero-section {
  min-height: 280px;
  padding: 2rem 1rem;
}

.hero-remembrance h1,
.hero-section h1,
.serif-font {
  font-size: clamp(1.75rem, 5vw, 3.5rem);
  line-height: 1.2;
}

.hero-remembrance p,
.hero-section p {
  font-size: clamp(0.875rem, 2vw, 1.125rem);
}

/* Responsive grids - MOBILE DEFAULT (1 column) */
.obituary-grid {
  grid-template-columns: 1fr;
  gap: 1rem;
}

.places-grid {
  grid-template-columns: 1fr;
  gap: 1rem;
}

.footer-grid {
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

/* Cards on mobile */
.obituary-card,
.hero-card {
  height: auto;
  padding: 1rem;
}

/* Form fields */
input[type="text"],
input[type="email"],
input[type="date"],
input[type="url"],
textarea,
.form-field {
  width: 100%;
  font-size: 16px;
  padding: 12px 16px;
}

/* Modal on mobile */
.modal {
  padding: 1rem;
}

.modal > div {
  max-width: 95vw;
  padding: 1.5rem;
}

.modal .grid {
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* Button sizing — mobile only (preserve desktop nav buttons) */
@media (max-width: 1023px) {
  button:not(#menuToggle):not(#langToggle):not(#langToggleMobile) {
    min-height: 44px;
    padding: 12px 16px;
  }
}

/* Images */
img {
  max-width: 100%;
  height: auto;
}

/* ========================================
   PAGE-SPECIFIC MOBILE FIXES
   ======================================== */

/* NEWS PAGE */
@media (max-width: 640px) {
  .news-item {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center;
    padding: 1.5rem !important;
    gap: 1rem !important;
  }

  .news-item img {
    width: 120px !important;
    height: 120px !important;
    margin-bottom: 0.5rem;
  }

  .news-item h3 {
    font-size: 1.25rem !important;
    text-align: center;
  }

  .news-item p {
    font-size: 0.95rem;
    text-align: center;
  }

  .bg-green-900.rounded-3xl {
    padding: 1.5rem !important;
  }

  .bg-green-900 h3 {
    font-size: 1.75rem !important;
  }

  .bg-amber-50.flex {
    flex-direction: column !important;
    gap: 1rem !important;
    padding: 1.5rem !important;
    align-items: flex-start !important;
  }

  .bg-amber-50.flex .w-16.h-16 {
    align-self: flex-start;
    margin-bottom: 0.5rem;
  }

  .bg-amber-50 h3 {
    font-size: 1.25rem !important;
  }

  .bg-amber-50 p {
    font-size: 0.95rem;
  }
}

/* MEMBER PAGE */
@media (max-width: 640px) {
  .member-sidebar {
    padding: 1.5rem !important;
  }

  .member-content {
    padding: 1.5rem !important;
  }

  .member-sidebar .w-48,
  .member-sidebar .w-48.h-48 {
    width: 120px !important;
    height: 120px !important;
  }

  .member-sidebar h2 {
    font-size: 1.5rem !important;
  }

  .member-sidebar p {
    font-size: 0.95rem;
  }

  .member-content h1 {
    font-size: 1.75rem !important;
  }

  .member-content h3 {
    font-size: 1.25rem !important;
  }

  .grid.grid-cols-1 {
    grid-template-columns: 1fr !important;
  }
}

/* ========================================
   TABLET (641px - 1023px)
   ======================================== */
@media (min-width: 641px) {
  .obituary-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }

  .hero-remembrance,
  .hero-section {
    min-height: 380px;
    padding: 3rem 2rem;
  }

  .modal > div {
    max-width: 90vw;
  }

  .modal .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
  }

  section {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

@media (min-width: 641px) and (max-width: 1023px) {
  .member-sidebar {
    padding: 2rem;
  }

  .member-content {
    padding: 2rem;
  }

  .member-sidebar .w-48,
  .member-sidebar .w-48.h-48 {
    width: 160px;
    height: 160px;
  }

  .news-item img {
    width: 140px;
    height: 140px;
  }
}

/* Hide search input on mobile */
input[placeholder*="Search"] {
  max-width: 100%;
  width: 100%;
}

/* ========================================
   DESKTOP (1024px+)
   ======================================== */
@media (min-width: 1024px) {
  .obituary-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem;
  }

  .footer-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
  }

  .places-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }

  .hero-remembrance,
  .hero-section {
    min-height: 450px;
    padding: 4rem 2rem;
  }

  .hero-remembrance h1,
  .hero-section h1 {
    font-size: 3.5rem;
  }

  .modal > div {
    max-width: 56rem;
    padding: 2rem;
  }

  .modal .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 3rem;
  }

  section {
    padding-left: 2rem;
    padding-right: 2rem;
  }

  input[placeholder*="Search"] {
    width: 256px;
  }
}

/* ========================================
   EXTRA LARGE (1400px+)
   ======================================== */
@media (min-width: 1400px) {
  section {
    padding-left: 3rem;
    padding-right: 3rem;
  }

  .hero-remembrance,
  .hero-section {
    min-height: 500px;
  }
}

/* ========================================
   LANDSCAPE MODE
   ======================================== */
@media (max-height: 500px) and (orientation: landscape) {
  .hero-remembrance,
  .hero-section {
    min-height: 200px;
    padding: 1rem !important;
  }

  .hero-remembrance h1,
  .hero-section h1 {
    font-size: 1.5rem !important;
  }

  nav {
    padding: 0.5rem !important;
  }
}

/* ========================================
   MOBILE-SPECIFIC FIXES (320px - 480px)
   Critical responsive fixes for small phones
   ======================================== */
@media (max-width: 480px) {

  /* --- NAV --- */
  #mainNav {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }
  #mainNav > div {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  #mainNav .text-2xl,
  #mainNav #logoText {
    font-size: 1.1rem !important;
  }
  #mainNav .w-12 {
    width: 36px !important;
    height: 36px !important;
  }

  /* --- HERO SECTIONS --- */
  header[id="home"] {
    padding-top: 60px !important;
  }
  .hero-remembrance,
  .hero-section,
  .hero-banner,
  .hero-education,
  .hero-infrastructure,
  .hero-medical {
    min-height: 250px !important;
    padding: 70px 1rem 2rem !important;
  }
  .hero-remembrance h1,
  .hero-section h1,
  .hero-banner h1,
  .hero-education h1,
  .hero-infrastructure h1,
  .hero-medical h1,
  [class*="hero"] h1 {
    font-size: clamp(1.25rem, 7vw, 2rem) !important;
    line-height: 1.3 !important;
  }
  [class*="hero"] p {
    font-size: 0.85rem !important;
  }

  /* --- HERO CARDS / QUICK ACTIONS --- */
  #hero-cards {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
    margin-top: -3rem !important;
    padding: 0 1rem !important;
  }
  .hero-card {
    height: 200px !important;
    border-radius: 16px !important;
    padding: 1rem !important;
  }

  /* --- INFRASTRUCTURE PAGE GRIDS --- */
  .infra-status-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
  }
  .infra-projects-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }
  .infra-future-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }
  .infra-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
  }

  /* --- DONATE PAGE --- */
  .donate-impact-grid,
  .donate-causes-grid,
  .donate-trust-grid {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }
  /* Marquee testimonial items */
  .marquee-item,
  [style*="min-width:320px"],
  [style*="min-width: 320px"] {
    min-width: 260px !important;
    max-width: 90vw !important;
  }

  /* --- ABOUT PAGE --- */
  .place-image {
    height: clamp(160px, 50vw, 240px) !important;
  }

  /* --- MEMBER PAGE SIDEBAR --- */
  .member-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  /* --- CONTACT PAGE --- */
  .contact-main-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }
  .contact-card {
    padding: 1.25rem !important;
  }

  /* --- FOOTER --- */
  footer .grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }
  footer .footer-links-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1rem;
  }
  footer .border-t {
    flex-direction: column !important;
    text-align: center !important;
    gap: 1rem !important;
  }

  /* --- GENERAL MOBILE FIXES --- */
  .max-w-7xl,
  .max-w-5xl,
  .max-w-6xl {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
  section {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* CTA buttons - stack vertically */
  .flex.flex-wrap.justify-center.gap-4 {
    flex-direction: column !important;
    align-items: center !important;
  }
  .flex.flex-wrap.justify-center.gap-4 > a {
    width: 100% !important;
    max-width: 280px !important;
    text-align: center !important;
    padding: 14px 24px !important;
    font-size: 0.9rem !important;
  }

  /* Fix w-64 input on contact/search */
  .w-64 {
    width: 100% !important;
  }

  /* Prevent horizontal overflow */
  .overflow-x-auto,
  .overflow-hidden {
    max-width: 100vw !important;
  }
  pre, code, table {
    max-width: 100% !important;
    overflow-x: auto !important;
    font-size: 0.8rem !important;
  }
}

/* ========================================
   SMALL-MEDIUM MOBILE (481px - 640px)
   ======================================== */
@media (min-width: 481px) and (max-width: 640px) {
  .infra-status-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .infra-projects-grid {
    grid-template-columns: 1fr !important;
  }
  .infra-future-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .donate-impact-grid,
  .donate-causes-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .donate-trust-grid {
    grid-template-columns: 1fr !important;
  }
  .member-grid {
    grid-template-columns: 1fr !important;
  }
  footer .grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }
}

/* ========================================
   TABLET FIX (641px - 768px)
   ======================================== */
@media (min-width: 641px) and (max-width: 768px) {
  .infra-projects-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .donate-causes-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  footer .grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  nav,
  footer,
  button {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }
}
