/* ============================================================
   Responsive Breakpoints
   Sts. Cyril and Methody Cathedral
   ============================================================ */

/* ============================================================
   TABLET: max-width 1024px
   ============================================================ */
@media (max-width: 1024px) {
  /* Header */
  .cathedral-name    { font-size: 1.75rem; }
  .cathedral-subtitle { font-size: 0.95rem; }
  .header-icon, .icon-placeholder { width: 150px; height: 150px; }

  /* Hero */
  .hero-title   { font-size: 2.4rem; }
  .hero-tagline { font-size: 1.1rem; }

  /* Page hero */
  .page-hero-title { font-size: 2rem; }

  /* Hall features */
  .hall-features { grid-template-columns: repeat(2, 1fr); }

  /* Section title */
  .section-title { font-size: 1.85rem; }

  /* Cards grid */
  .cards-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}

/* ============================================================
   MOBILE: max-width 768px
   ============================================================ */
/* ============================================================
   MOBILE NAV OVERLAY (shared — activates at 768px)
   ============================================================ */
.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 999;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
  /* ── Hamburger: show ── */
  .hamburger {
    display: flex !important;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
    padding: 8px;
    background: none;
    border: none;
    z-index: 1002;
    position: relative;
  }

  /* ── Nav drawer: slide in from left ── */
  .nav-menu {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    width: min(80vw, 300px);
    height: 100vh;
    background: #fff;
    z-index: 1001;
    padding: 64px 0 32px;
    overflow-y: auto;
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(-100%);
    gap: 0;
    justify-content: flex-start;
    border-right: 3px solid #c9a84c;
  }

  .nav-menu li {
    width: 100%;
  }

  .nav-menu li a {
    display: block;
    padding: 14px 28px;
    font-size: 0.85rem;
    border-bottom: 1px solid #f0e8d5;
    border-left: 3px solid transparent;
    white-space: normal;
  }

  .nav-menu li a:hover,
  .nav-menu li a.active {
    border-bottom-color: #f0e8d5;
    border-left-color: #c9a84c;
    background: #fdf8ee;
  }

  /* ── Open state ── */
  body.nav-mobile-open .nav-menu {
    transform: translateX(0);
  }

  body.nav-mobile-open .nav-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  /* ── Open state: pin the X to the drawer's top-right corner ── */
  body.nav-mobile-open .hamburger {
    position: fixed;
    top: 12px;
    left: calc(min(80vw, 300px) - 52px);
    z-index: 1003;
  }

  /* ── Larger tap target for submenu carets ── */
  .nav-toggle-btn {
    position: absolute;
    right: 8px;
    top: 0;
    width: 48px;
    height: 48px;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
  }
  .nav-menu > li { position: relative; }
  .nav-toggle-btn.rotated { transform: rotate(180deg); }

  /* ── Hamburger → X animation ── */
  .hamburger.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .hamburger.open span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }
  .hamburger.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  .hamburger span {
    transition: transform 0.25s ease, opacity 0.25s ease;
  }

  /* ── Nav inner: hamburger left, lang-toggle right ── */
  .nav-inner {
    justify-content: space-between;
    padding: 0 12px;
  }

  /* ── Lang toggle stays in nav-inner on mobile ── */
  .lang-toggle {
    margin-left: auto;
    margin-right: 0;
    order: 2;
  }

  .hamburger {
    order: 1;
  }

  /* ── Header — vertical stack ── */
  .header-inner {
    flex-direction: column;
    gap: 16px;
    padding: 20px 16px;
  }
  .header-icon-wrapper { flex-direction: row; align-items: center; gap: 12px; }
  .header-icon, .icon-placeholder { width: 100px; height: 100px; }
  .icon-placeholder { font-size: 2.5rem; }
  .icon-label { display: none; }
  .cathedral-name    { font-size: 1.4rem; letter-spacing: 0.06em; }
  .cathedral-subtitle { font-size: 0.875rem; }
  .header-est { font-size: 0.75rem; }

  /* Hero */
  .hero { height: 42vh; min-height: 242px; }
  .hero-title   { font-size: 1.75rem; letter-spacing: 0.04em; }
  .hero-tagline { font-size: 0.95rem; }

  /* Page hero */
  /* .page-hero padding stays at mobile-first base (44px 16px) — no override needed */
  .page-hero-title { font-size: 1.75rem; }
  .page-hero-subtitle { font-size: 0.95rem; }

  /* Sections */
  .section { padding: 52px 16px; }
  .section-title { font-size: 1.6rem; }

  /* Services grid */
  .services-grid { grid-template-columns: 1fr; }

  /* Cards */
  .cards-grid { grid-template-columns: 1fr; }

  /* Hall features */
  .hall-features { grid-template-columns: 1fr; }

  /* Hall 3-col layout → 1 col */
  .hall-layout-3col {
    grid-template-columns: 1fr !important;
  }
  .hall-layout-3col .hall-photos-left,
  .hall-layout-3col .hall-photos-right {
    display: none !important;
  }

  /* Gallery */
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }

  /* Person cards grid */
  .persons-grid { grid-template-columns: 1fr !important; }

  /* Staff grid */
  .staff-grid { grid-template-columns: 1fr !important; }

  /* Footer */
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }

  /* Timeline */
  .timeline { padding-left: 28px; }
  .timeline::before { left: 8px; }
  .timeline-dot { left: -24px; width: 14px; height: 14px; }

  /* Accordion header */
  .accordion-header { padding: 14px 16px; }
  .accordion-title { font-size: 0.95rem; }
  .accordion.open .accordion-body { padding: 0 16px 16px; }

  /* Quick actions */
  .quick-actions { flex-direction: column; align-items: center; }

  /* Contact two-col → one col */
  .contact-two-col { grid-template-columns: 1fr !important; }

  /* Scroll top */
  .scroll-top { bottom: 16px; right: 16px; width: 40px; height: 40px; font-size: 1rem; }

  /* Info table horizontal scroll */
  .info-table-wrap { overflow-x: auto; }

  /* Bulletin card */
  .bulletin-download { display: none; }

  /* Sunday school grid */
  .sunday-school-grid { grid-template-columns: 1fr !important; }

  /* Leadership grid */
  .leadership-grid { grid-template-columns: 1fr !important; }
}

/* ============================================================
   SMALL MOBILE: max-width 480px
   ============================================================ */
@media (max-width: 480px) {
  /* Header icons smaller */
  .header-icon, .icon-placeholder { width: 72px; height: 72px; }
  .icon-placeholder { font-size: 1.75rem; }
  .cathedral-name { font-size: 1.05rem; letter-spacing: 0.03em; }
  .cathedral-subtitle { font-size: 0.8rem; }
  .header-est { font-size: 0.68rem; gap: 8px; }

  /* Hero */
  .hero { height: 37vh; min-height: 210px; }
  .hero-title { font-size: 1.4rem; }
  .hero-tagline { font-size: 0.875rem; }

  /* Gallery 1 col */
  .gallery-grid { grid-template-columns: 1fr; }

  /* Buttons stack */
  .quick-actions .btn { width: 100%; max-width: 280px; text-align: center; }

  /* Font sizes */
  .section-title { font-size: 1.35rem; }
  .page-hero-title { font-size: 1.4rem; }

  /* Person photo smaller */
  .person-photo-placeholder,
  .person-photo { width: 90px; height: 90px; }

  /* Filter bar wrap nicely */
  .filter-bar { gap: 8px; }
  .filter-btn { padding: 6px 14px; font-size: 0.72rem; }

  /* Bulletin card compact */
  .bulletin-card { padding: 14px 14px; gap: 10px; }
  .bulletin-icon { font-size: 1.75rem; }
  .bulletin-title { font-size: 0.875rem; }

  /* Staff info */
  .staff-card-header { padding: 24px 16px; }
  .staff-card-body { padding: 20px 16px; }

  /* Contact card compact */
  .contact-card { padding: 16px; }

  /* Hall features 1 col */
  .hall-features { grid-template-columns: 1fr; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .site-nav, .hamburger, .scroll-top, .lightbox { display: none !important; }
  .site-header { border: none; }
  .hero { height: auto; }
  .hero-overlay { position: relative; background: none; color: #000; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.75em; }
}

/* ============================================================
   HERO SLIDESHOW — RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .hero-title   { font-size: 1.6rem; }
  .hero-tagline { font-size: 0.9rem; max-width: 90vw; }
}

/* ============================================================
   PAGE LOADER — RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
  .loader-title    { font-size: 1rem; }
  .loader-subtitle { font-size: 0.72rem; }
  .loader-cross-wrap svg { width: 42px; height: 56px; }
  .loader-bar { width: 70vw; }
}

/* ============================================================
   LIGHTBOX — MOBILE TOUCH IMPROVEMENTS
   ============================================================ */
@media (max-width: 768px) {
  .lightbox-close  { top: 12px; right: 14px; width: 40px; height: 40px; font-size: 1.6rem; }
  .lightbox-prev   { left: 6px;  padding: 10px 14px; font-size: 2rem; border-radius: 4px; }
  .lightbox-next   { right: 6px; padding: 10px 14px; font-size: 2rem; border-radius: 4px; }
  .lightbox-img    { max-width: 96vw; max-height: 82vh; }
  .lightbox-counter { font-size: 0.72rem; bottom: 10px; }
  #lightbox-content { min-height: 50vh; }
}
@media (max-width: 480px) {
  .lightbox-prev, .lightbox-next { padding: 8px 10px; font-size: 1.7rem; }
}

/* ============================================================
   NAVIGATION — ENSURE CLEAN MOBILE LAYOUT
   ============================================================ */
@media (max-width: 768px) {
  .nav-inner { padding: 0 16px; }
  .lang-toggle { margin-left: auto; }
  .lang-btn { font-size: 0.72rem; padding: 4px 8px; }
}

/* ============================================================
   INLINE GRID OVERRIDES — EVENTS / ACTIVITIES / HALLS
   (pages use inline style grids with fixed minmax values)
   ============================================================ */
@media (max-width: 600px) {
  /* Override inline grids with fixed column widths */
  [style*="minmax(180px"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  [style*="minmax(240px"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  [style*="minmax(200px"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  [style*="minmax(260px"] {
    grid-template-columns: 1fr !important;
  }
  [style*="minmax(280px"] {
    grid-template-columns: 1fr !important;
  }
  [style*="minmax(300px"] {
    grid-template-columns: 1fr !important;
  }
  [style*="minmax(320px"] {
    grid-template-columns: 1fr !important;
  }
  [style*="minmax(380px"] {
    grid-template-columns: 1fr !important;
  }
  [style*="minmax(400px"] {
    grid-template-columns: 1fr !important;
  }
  /* Two-column inline layouts */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns:1fr 2fr 1fr"],
  [style*="grid-template-columns: 1fr 2fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns:repeat(3"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  [style*="grid-template-columns:repeat(2"] {
    grid-template-columns: 1fr !important;
  }
}
@media (max-width: 380px) {
  [style*="minmax(180px"],
  [style*="minmax(200px"],
  [style*="minmax(240px"] {
    grid-template-columns: 1fr !important;
  }
  [style*="grid-template-columns:repeat(3"] {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   STAFF GRID — inline minmax(380px) fix
   ============================================================ */
@media (max-width: 820px) {
  .staff-grid { grid-template-columns: 1fr !important; }
}

/* ============================================================
   BULLETIN CARDS — FULL MOBILE
   ============================================================ */
@media (max-width: 600px) {
  .bulletin-card {
    flex-wrap: wrap;
    gap: 10px;
  }
  .bulletin-card .btn {
    width: 100%;
    text-align: center;
    flex-shrink: 0;
  }
  /* Year filter row stacks */
  #year-filter, #lang-filter, #bulletin-search {
    font-size: 0.875rem;
  }
}

/* ============================================================
   GALLERY FILTER BAR — MOBILE SCROLL
   ============================================================ */
@media (max-width: 768px) {
  .filter-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filter-bar::-webkit-scrollbar { display: none; }
  .filter-btn { flex-shrink: 0; }
}

/* ============================================================
   PERSON CARDS / CLERGY GRID — MOBILE
   ============================================================ */
@media (max-width: 600px) {
  .leadership-grid { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 400px) {
  .leadership-grid { grid-template-columns: 1fr !important; }
}

/* ============================================================
   FOOTER — SMALL MOBILE
   ============================================================ */
@media (max-width: 480px) {
  .footer-bottom p { font-size: 0.72rem; }
  .footer-section h3 { font-size: 0.95rem; }
  .footer-section p, .footer-section a { font-size: 0.82rem; }
}

/* ============================================================
   CONTACT PAGE FORM / INFO — MOBILE
   ============================================================ */
@media (max-width: 768px) {
  .contact-two-col { gap: 28px !important; }
  iframe { height: 220px !important; }
}

/* ============================================================
   HALLS PAGE — MOBILE
   ============================================================ */
@media (max-width: 768px) {
  [style*="grid-template-columns:1fr 2fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  .hall-features { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .hall-features { grid-template-columns: 1fr; }
}

/* ============================================================
   MEMBERSHIP PAGE — MOBILE
   ============================================================ */
@media (max-width: 600px) {
  [style*="minmax(260px,1fr)"] { grid-template-columns: 1fr !important; }
}

/* ============================================================
   TABLES — HORIZONTAL SCROLL ON MOBILE
   ============================================================ */
@media (max-width: 600px) {
  table { font-size: 0.875rem; }
  th, td { padding: 8px 10px; }
}

/* ============================================================
   HISTORY TIMELINE — SMALL MOBILE
   ============================================================ */
@media (max-width: 480px) {
  .timeline-content { padding: 16px; }
  .timeline-date { font-size: 0.75rem; }
}

/* ============================================================
   BUTTONS — PREVENT OVERFLOW ON SMALL SCREENS
   ============================================================ */
@media (max-width: 480px) {
  .btn { padding: 11px 18px; font-size: 0.82rem; word-break: break-word; }
  .page-hero .btn { font-size: 0.8rem; }
}

/* ============================================================
   PRINT — HIDE LOADER
   ============================================================ */
@media print {
  #page-loader, .hero-slides { display: none !important; }
}

/* ============================================================
   GLOBAL OVERFLOW / WIGGLE PREVENTION
   Ensures no element creates a horizontal scrollbar on any
   phone or tablet — applied outside breakpoints so it's always
   active as a safety net.
   ============================================================ */

/* Tables — wrap in scrollable container on narrow viewports */
@media (max-width: 768px) {
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  /* Prevent any fixed-width inline block from overflowing */
  img, video, iframe, canvas {
    max-width: 100% !important;
    height: auto;
  }
  /* Long words in headings / paragraphs */
  h1, h2, h3, h4, h5, p, li, td, th, label, figcaption {
    overflow-wrap: break-word;
    word-break: break-word;
  }
  /* Scripture banners with large blockquote text */
  .scripture-banner blockquote {
    font-size: 1rem;
  }
  /* Newsletter inline form on small screens */
  .newsletter-form-inline {
    flex-direction: column;
    width: 100%;
  }
}

/* School.html — 3-column photo grid collapses on tablet */
@media (max-width: 768px) {
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 480px) {
  [style*="grid-template-columns:repeat(3,1fr)"],
  [style*="grid-template-columns: repeat(3, 1fr)"] {
    grid-template-columns: 1fr !important;
  }
}

/* School enrolment form — 2-col inputs stack on mobile */
@media (max-width: 600px) {
  [style*="grid-template-columns:1fr 1fr"][style*="gap:14px"],
  [style*="grid-template-columns: 1fr 1fr"][style*="gap: 14px"] {
    grid-template-columns: 1fr !important;
  }
}

/* Events layout — fixed 340px calendar column can overflow on iPad */
@media (max-width: 860px) {
  .events-layout {
    grid-template-columns: 1fr !important;
  }
  .mini-calendar {
    position: static !important;
    max-width: 380px;
    margin: 0 auto;
  }
}

/* Donation layout — two-col layout breaks on tablet */
@media (max-width: 900px) {
  .donation-layout {
    grid-template-columns: 1fr !important;
    gap: 32px !important;
  }
}

/* Action cards — force 2-col on phones smaller than 400px */
@media (max-width: 400px) {
  .action-cards-grid {
    grid-template-columns: 1fr !important;
  }
}

/* Page hero — scale down title on very small screens */
@media (max-width: 360px) {
  .page-hero-title { font-size: 1.25rem; }
  .page-hero-subtitle { font-size: 0.85rem; }
  .page-hero { padding: 32px 12px; }
}

/* Prevent the fixed nav dropdown from peeking on tablet */
@media (max-width: 1024px) {
  .nav-dropdown {
    left: 0 !important;
    transform: translateX(0) translateY(-8px) !important;
  }
  .nav-has-dropdown:hover .nav-dropdown,
  .nav-has-dropdown:focus-within .nav-dropdown {
    transform: translateX(0) translateY(0) !important;
  }
}

/* FAB tooltips hidden on touch devices (no hover) */
@media (hover: none) {
  .fab-btn[title]::before { display: none !important; }
}

/* Lightbox image never overflows viewport */
.lightbox img {
  max-width: 92vw !important;
  max-height: 80vh !important;
  width: auto !important;
  height: auto !important;
}

/* Section padding tighter on tablet to prevent text cramping */
@media (max-width: 1024px) {
  .section { padding: 60px 20px; }
  .action-cards-section { padding: 48px 16px; }
  .events-section { padding: 60px 16px; }
}

/* ============================================================
   HERO BUTTONS — MOBILE COMPACT
   ============================================================ */
.hero-btns {
  display: flex;
  gap: 14px;
  margin-top: 28px;
  flex-wrap: wrap;
  justify-content: center;
}
@media (max-width: 768px) {
  .hero-btns {
    margin-top: 18px;
    gap: 10px;
  }
}
@media (max-width: 480px) {
  .hero-btns {
    margin-top: 12px;
    gap: 8px;
  }
  .hero-btns .btn {
    padding: 10px 16px;
    font-size: 0.8rem;
  }
}
