/* ================================================================
   RESPONSIVE OVERRIDES
   Loads AFTER styles.css — adds breakpoints, hamburger menu,
   touch targets, fluid typography, layout stability, and print.
   ================================================================ */

/* === GLOBAL RESPONSIVE FOUNDATIONS === */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

/* Safe-area insets for notched devices (iPhone X+, Dynamic Island) */
.header {
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.footer {
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Touch interaction — eliminate 300ms tap delay */
a, button, [role="button"], input, select, textarea, summary {
  touch-action: manipulation;
}

/* Text wrapping safety — prevent overflow on narrow screens */
p, li, td, th, h1, h2, h3, h4, h5, h6, label, .card-content {
  overflow-wrap: break-word;
}

/* Selection styling — uses theme CSS vars for all 5 designs */
::selection {
  background-color: var(--accent-gold);
  color: var(--dark-brown);
}

/* Active/pressed states for touch feedback */
.btn:active,
.donate-btn:active,
.hero-cta:active,
.card-btn:active {
  opacity: 0.85;
  transform: scale(0.98);
}


/* === FLUID TYPOGRAPHY === */

/* Default (Classic Glen): desktop 3.5rem → mobile 2.5rem */
.hero-content h1 { font-size: clamp(2.5rem, 5vw + 0.5rem, 3.5rem); }
.hero-tagline { font-size: clamp(1.3rem, 2.5vw + 0.3rem, 1.8rem); }

/* Franciscan Modern: desktop 3.8rem → mobile 2.4rem */
body.design-franciscan .hero-content h1 { font-size: clamp(2.4rem, 5vw + 0.4rem, 3.8rem); }
body.design-franciscan .hero-tagline { font-size: clamp(1.1rem, 2vw + 0.3rem, 1.4rem); }

/* Glen Fusion: desktop 4rem → mobile 2.8rem */
body.design-fusion .hero-content h1 { font-size: clamp(2.8rem, 5vw + 0.5rem, 4rem); }
body.design-fusion .hero-tagline { font-size: clamp(1.1rem, 2vw + 0.3rem, 1.5rem); }

/* Blessed Sanctuary: desktop 4.2rem → mobile 2.6rem */
body.design-blessed .hero-content h1 { font-size: clamp(2.6rem, 5.5vw + 0.4rem, 4.2rem); }
body.design-blessed .hero-tagline { font-size: clamp(1.05rem, 2vw + 0.2rem, 1.3rem); }

/* Artisan Prairie: desktop 3.8rem → mobile 2.4rem */
body.design-prairie .hero-content h1 { font-size: clamp(2.4rem, 5vw + 0.4rem, 3.8rem); }
body.design-prairie .hero-tagline { font-size: clamp(0.95rem, 1.8vw + 0.2rem, 1.15rem); }

/* Base headings */
h1 { font-size: clamp(1.75rem, 4vw + 0.5rem, 2.5rem); }
h2 { font-size: clamp(1.5rem, 3vw + 0.4rem, 2rem); }
h3 { font-size: clamp(1.2rem, 2vw + 0.3rem, 1.5rem); }


/* === HERO SVH FALLBACK (safer on mobile browsers with dynamic toolbars) === */

.hero { height: 70vh; height: 70svh; }
body.design-franciscan .hero { height: 75vh; height: 75svh; }
body.design-fusion .hero { height: 80vh; height: 80svh; }
body.design-blessed .hero { height: 85vh; height: 85svh; }
body.design-prairie .hero { height: 75vh; height: 75svh; }


/* === LAYOUT STABILITY (prevent CLS from lazy images) === */

.card-image {
  aspect-ratio: 16 / 9;
}

.gallery-item {
  aspect-ratio: 1 / 1;
}


/* === HAMBURGER MENU — hidden on desktop === */

.nav-toggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 12px;
  flex-direction: column;
  gap: 5px;
  z-index: 1001;
}

.nav-toggle-bar {
  display: block;
  width: 28px;
  height: 3px;
  background-color: var(--white);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Animated X when open */
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}


/* === SMALL DESKTOP (≤1024px) === */

@media (max-width: 1024px) {
  .nav-list {
    gap: 15px;
  }

  .nav-item a {
    font-size: 0.8rem;
    padding: 5px 6px;
  }

  .card-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }

  .section {
    padding: 60px 0;
  }
}


/* === TABLET / MOBILE (≤768px) — supplements existing 768px rules === */

@media (max-width: 768px) {

  /* -- Hamburger visible -- */
  .nav-toggle {
    display: flex;
    margin: 0 auto;
  }

  .nav-list {
    display: none;
    width: 100%;
    gap: 0;
  }

  .nav-list.nav-open {
    display: flex;
    flex-direction: column;
  }

  /* -- Mobile dropdowns: static positioning -- */
  .nav-item.dropdown {
    position: static;
  }

  .dropdown-menu {
    position: static;
    box-shadow: none;
    border-radius: 0;
    min-width: 100%;
    background-color: rgba(0, 0, 0, 0.1);
  }

  /* Override hover-show: use ARIA-driven display from accessible-nav.js */
  .dropdown:hover .dropdown-menu {
    display: none;
  }

  .dropdown[aria-expanded="true"] .dropdown-menu,
  .dropdown.mobile-open .dropdown-menu {
    display: block;
  }

  .dropdown-menu a {
    color: var(--white);
    border-bottom-color: rgba(255, 255, 255, 0.08);
    padding-left: 30px;
  }

  .dropdown-menu a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--accent-gold);
  }

  /* -- Touch-friendly tap targets (44px minimum) -- */
  .nav-item a {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    width: 100%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .dropdown-menu a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 12px 20px;
  }

  .btn,
  .donate-btn,
  .hero-cta {
    min-height: 44px;
    padding: 12px 24px;
  }

  .social-links a {
    width: 44px;
    height: 44px;
  }

  /* -- Prairie design: remove border separators at mobile -- */
  body.design-prairie .nav-item a {
    border-right: none;
    border-left: none;
  }

  /* -- Collapse inline 2-column grids at tablet/mobile -- */
  [style*="grid-template-columns: 1fr 1fr"],
  [style*="grid-template-columns: 300px 1fr"] {
    grid-template-columns: 1fr !important;
  }
}


/* === SMALL PHONE (≤480px) === */

@media (max-width: 480px) {
  .container {
    padding: 0 12px;
  }

  .hero {
    height: 50vh;
  }

  .section {
    padding: 50px 0;
  }

  .section-title {
    margin-bottom: 30px;
  }

  /* Single-column grids */
  .card-grid {
    grid-template-columns: 1fr;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .donation-tiers {
    grid-template-columns: 1fr;
  }

  .board-grid {
    grid-template-columns: 1fr;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  /* Stack header elements */
  .header-top {
    flex-direction: column;
    gap: 8px;
    text-align: center;
    padding-bottom: 8px;
  }

  /* Tighter event items */
  .event-item {
    padding: 20px;
    gap: 15px;
  }

  /* Reduced info-box padding */
  .info-box {
    padding: 25px;
  }

  /* Collapse 3-column form rows and payment grids */
  [style*="grid-template-columns: 2fr 1fr 1fr"],
  [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
  }

  /* SVH override for small phones */
  .hero {
    height: 50vh;
    height: 50svh;
  }
}


/* === LANDSCAPE ORIENTATION on small screens === */

@media (orientation: landscape) and (max-height: 500px) {
  .hero {
    height: auto;
    min-height: 50vw;
    padding: 40px 0;
  }

  .hero-content h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
  }

  .header {
    padding: 8px 0;
  }
}


/* === BREADCRUMB === */

.breadcrumb {
  padding: 10px 20px;
  font-size: 0.85rem;
  max-width: 1200px;
  margin: 0 auto;
}

.breadcrumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0;
  padding: 0;
}

.breadcrumb li:not(:last-child)::after {
  content: "/";
  margin-left: 4px;
  color: var(--text-light);
}

.breadcrumb a {
  color: var(--secondary-green);
}

.breadcrumb [aria-current="page"] {
  color: var(--text-light);
  font-weight: normal;
  border-bottom: none;
}


/* === PRINT === */

@media print {
  .header,
  .nav,
  .nav-toggle,
  .hero-cta,
  .social-links,
  .donate-btn,
  .footer,
  #theme-switcher,
  #theme-toggle-btn {
    display: none !important;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
    color: #000;
    background: #fff;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #555;
  }

  .hero {
    height: auto;
    background: none;
    color: #000;
    padding: 20px 0;
  }

  .hero-content h1 {
    color: #000;
    text-shadow: none;
  }

  .section {
    padding: 20px 0;
    page-break-inside: avoid;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }
}
