/* ============================================================
   BHF MOBILE RESPONSIVE — css/mobile.css
   Full mobile-first responsive fixes for all pages & components
   Breakpoints: 1200px | 1024px | 768px | 480px | 360px
   ============================================================ */

/* ============================================================
   BASE MOBILE SAFETY NET
   ============================================================ */
* {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

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

/* Prevent any element from causing horizontal overflow */
.container,
section,
article,
aside,
header,
footer,
main,
div {
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ============================================================
   BACK TO TOP BUTTON
   ============================================================ */
#back-to-top {
  position: fixed;
  bottom: 28px;
  right: 24px;
  z-index: 9990;
  width: 52px;
  height: 52px;
  background: var(--bhf-black);
  border: 2px solid var(--bhf-teal);
  color: var(--bhf-teal);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
  clip-path: polygon(10px 0%, 100% 0%, calc(100% - 10px) 100%, 0% 100%);
  box-shadow: 0 0 16px rgba(0, 229, 200, 0.25), inset 0 0 0 0 var(--bhf-teal);
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition: opacity 0.35s ease, visibility 0.35s ease,
              transform 0.35s ease, box-shadow 0.25s ease,
              background 0.25s ease, color 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}

#back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

#back-to-top:hover,
#back-to-top:focus-visible {
  background: var(--bhf-teal);
  color: var(--bhf-black);
  box-shadow: 0 0 24px rgba(0, 229, 200, 0.5), 0 0 60px rgba(0, 229, 200, 0.2);
  outline: none;
}

#back-to-top:active {
  transform: translateY(2px);
}

/* Nudge left on mobile so it doesn't overlap scroll bar */
@media (max-width: 480px) {
  #back-to-top {
    bottom: 20px;
    right: 16px;
    width: 46px;
    height: 46px;
    font-size: 1.2rem;
  }
}

/* ============================================================
   CONTAINER — tighter padding on small screens
   ============================================================ */
@media (max-width: 768px) {
  .container {
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media (max-width: 480px) {
  .container {
    padding-left: 14px;
    padding-right: 14px;
  }
}

/* ============================================================
   TYPOGRAPHY SCALING
   ============================================================ */
@media (max-width: 768px) {
  h1 { font-size: clamp(2rem, 9vw, 3.5rem); }
  h2 { font-size: clamp(1.6rem, 7vw, 2.8rem); }
  h3 { font-size: clamp(1.2rem, 5vw, 2rem); }

  .section-title { font-size: clamp(1.6rem, 7vw, 2.5rem); }
  .section-subtitle { font-size: 0.95rem; }
}

@media (max-width: 480px) {
  h1 { font-size: clamp(1.8rem, 10vw, 2.8rem); }
  h2 { font-size: clamp(1.4rem, 8vw, 2.2rem); }
}

/* ============================================================
   BUTTONS — full width on tiny screens
   ============================================================ */
@media (max-width: 380px) {
  .btn {
    width: 100%;
    text-align: center;
    clip-path: none;
  }

  .hero-ctas,
  .zombie-walk-hero .hero-ctas {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-ctas .btn {
    width: 100%;
    text-align: center;
  }
}

/* ============================================================
   HEADER & NAVIGATION
   ============================================================ */
@media (max-width: 1024px) {
  .header-inner {
    padding: 14px 20px;
  }
  /* Hide some nav items to prevent overflow before hamburger kicks in */
  .nav-menu > li:nth-child(n+8) {
    display: none;
  }
}

@media (max-width: 768px) {
  .header-inner {
    padding: 12px 18px;
  }

  /* ── Site header must sit above the nav overlay ── */
  #site-header {
    z-index: 1100;
    /* Always show background on mobile so it's readable over the nav */
    background: rgba(5, 5, 5, 0.97) !important;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 229, 200, 0.15);
  }

  /* ── Hamburger: highest z-index, always on top ── */
  .menu-toggle {
    display: flex;
    position: relative;
    z-index: 1200;  /* above header AND nav overlay */
    flex-shrink: 0;
  }

  /* ── Mobile nav: true full-screen fixed overlay ─────────────
     top: 0 + bottom: 0 = covers entire viewport regardless of
     scroll position. Content is padded down by --nav-top-pad
     so it clears the header bar.
  ─────────────────────────────────────────────────────────── */
  #main-navigation {
    /* Layout & position */
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;

    /* Stack below hamburger, above everything else */
    z-index: 1099;

    /* Clear the header (62px header approx + breathing room) */
    padding-top: 80px;
    padding-left: 24px;
    padding-right: 24px;
    padding-bottom: env(safe-area-inset-bottom, 32px);

    /* Background */
    background: rgba(5, 5, 5, 0.97);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    /* Scroll */
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;

    /* Flex layout */
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;

    /* Slide-in from top animation */
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
  }

  #main-navigation.open {
    display: flex;
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  /* Decorative top accent line when open */
  #main-navigation.open::before {
    content: '';
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--bhf-red), var(--bhf-teal), var(--bhf-orange));
    z-index: 1;
  }

  /* ── Nav menu list ── */
  .nav-menu {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0;
    margin-top: 0.5rem;
  }

  /* Un-hide items hidden at 1024px */
  .nav-menu > li {
    display: block !important;
  }

  .nav-menu > li > a {
    display: block;
    font-size: 1.3rem;
    padding: 15px 0;
    border-bottom: 1px solid rgba(0, 229, 200, 0.08);
    letter-spacing: 0.1em;
    color: var(--bhf-cream);
    transition: color 0.15s ease, padding-left 0.2s ease;
  }

  .nav-menu > li > a:hover,
  .nav-menu > li > a:focus {
    color: var(--bhf-teal);
    padding-left: 6px;
  }

  /* Remove underline pseudo-element on mobile */
  .nav-menu > li > a::after { display: none; }

  .nav-menu > li:last-child > a {
    border-bottom: none;
  }

  /* ── Dropdowns: static, indented ── */
  .nav-menu .sub-menu {
    position: static !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    border: none !important;
    background: rgba(0, 229, 200, 0.04) !important;
    padding-left: 1rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
  }

  .nav-menu .sub-menu a {
    font-size: 1rem;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--bhf-cream-dark);
  }

  /* ── CTA button in nav ── */
  .nav-cta {
    display: block !important;
    margin-top: 1.5rem !important;
    clip-path: none !important;
    text-align: center !important;
    padding: 16px 24px !important;
    font-size: 1rem !important;
    background: var(--bhf-red) !important;
    color: var(--bhf-white) !important;
    border: none !important;
  }

  /* Logo sizing on mobile */
  .logo-main  { font-size: 1.05rem; }
  .logo-sub   { font-size: 0.52rem; }
  .logo-skull { font-size: 1.9rem; }
}

/* ── Extra small screens ── */
@media (max-width: 380px) {
  #main-navigation {
    padding-left: 18px;
    padding-right: 18px;
    padding-top: 74px;
  }

  .nav-menu > li > a {
    font-size: 1.15rem;
    padding: 13px 0;
  }
}

/* ============================================================
   HERO SECTION
   ============================================================ */
@media (max-width: 1024px) {
  .hero-skull-art { font-size: 12rem; }
}

@media (max-width: 768px) {
  #hero {
    min-height: 100svh; /* small viewport height aware */
    align-items: flex-start;
    padding-top: 0;
  }

  .hero-content {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 100px 18px 60px;
    gap: 1.5rem;
  }

  .hero-visual { display: none; }
  .hero-eyebrow { justify-content: center; }
  .hero-description { margin: 1.25rem auto 2rem; max-width: 100%; }

  .hero-title {
    font-size: clamp(2.8rem, 14vw, 5rem);
  }

  .hero-title-line2 {
    font-size: clamp(1.1rem, 5vw, 2rem);
    letter-spacing: 0.15em;
  }

  .hero-ctas {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .hero-ctas .btn {
    flex: 1 1 160px;
    text-align: center;
    font-size: 0.85rem;
    padding: 13px 20px;
  }

  .scroll-indicator { display: none; }
}

@media (max-width: 480px) {
  .hero-content {
    padding: 90px 14px 48px;
  }

  .hero-title {
    font-size: clamp(2.4rem, 15vw, 4rem);
  }

  .hero-ctas .btn {
    flex: 1 1 140px;
    font-size: 0.8rem;
    padding: 12px 16px;
  }
}

/* ============================================================
   COUNTDOWN
   ============================================================ */
@media (max-width: 768px) {
  .countdown-section { padding: 28px 0; }

  .countdown-grid {
    gap: 0.5rem;
    justify-content: center;
  }

  .countdown-unit {
    min-width: 64px;
  }

  .countdown-number {
    font-size: clamp(2.2rem, 11vw, 4rem);
  }

  .countdown-sep {
    font-size: 2rem;
    padding-top: 0.3em;
  }
}

@media (max-width: 480px) {
  .countdown-sep { display: none; }
  .countdown-grid { gap: 0.75rem; }
  .countdown-unit { min-width: 72px; }
  .countdown-number { font-size: clamp(2.5rem, 13vw, 3.5rem); }
  .countdown-label { font-size: 0.65rem; letter-spacing: 0.2em; padding: 0 10px; }
}

/* ============================================================
   SECTION SPACING
   ============================================================ */
@media (max-width: 768px) {
  :root { --section-pad: 48px; }
  .section { padding: var(--section-pad) 0; }
  .section-header { margin-bottom: 2rem; }
}

@media (max-width: 480px) {
  :root { --section-pad: 36px; }
}

/* ============================================================
   ABOUT HOME (2-column → 1-column)
   ============================================================ */
@media (max-width: 768px) {
  .about-home {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .about-home-visual {
    aspect-ratio: 3/2;
    font-size: 6rem;
  }

  .about-stats {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .stat-number { font-size: 2.2rem; }
  .stat-label  { font-size: 0.6rem; }
}

/* ============================================================
   EVENTS GRID
   ============================================================ */
@media (max-width: 768px) {
  .events-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

@media (max-width: 480px) {
  .event-card-body { padding: 1rem; }
  .event-card-title { font-size: 1.2rem; }
}

/* ============================================================
   ZOMBIE WALK HERO
   ============================================================ */
@media (max-width: 768px) {
  .zombie-walk-hero {
    min-height: 60vh;
    padding-top: 0;
  }

  .zombie-walk-hero .container {
    padding-top: 100px;
    padding-bottom: 40px;
  }

  .zombie-walk-hero-title {
    font-size: clamp(3rem, 16vw, 6rem);
  }

  .zombie-walk-sub {
    font-size: clamp(1rem, 5vw, 1.8rem);
    letter-spacing: 0.2em;
  }

  .event-since { font-size: 0.7rem; }

  /* CTA buttons under hero */
  .zombie-walk-hero + * .hero-ctas,
  .zombie-walk-hero [style*="display:flex"] {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
}

@media (max-width: 480px) {
  .zombie-walk-hero-title {
    font-size: clamp(2.8rem, 18vw, 5rem);
  }
}

/* ============================================================
   ZOMBIE WALK PAGE — EVENT DETAILS GRID
   ============================================================ */
@media (max-width: 768px) {
  /* 3-col detail cards → 1-col */
  [id="event-details"] .container > div[style*="grid-template-columns: repeat(3"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  /* zombie walk highlights grid */
  [id="zombie-walk-highlight"] [style*="grid-template-columns: 1fr 1fr"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  /* hide the big zombie emoji on small screens */
  [id="zombie-walk-highlight"] [style*="font-size: 15rem"] {
    font-size: 8rem !important;
  }
}

@media (max-width: 640px) {
  /* Zombie walk registration 2-col → 1-col outer grid */
  .registration-section .container > div[style*="grid-template-columns:1fr 1.5fr"],
  .registration-section .container > div[style*="grid-template-columns: 1fr 1.5fr"] {
    display: block !important;
  }

  .registration-section .container > div > div:first-child {
    margin-bottom: 2rem;
  }
}

/* ============================================================
   REGISTRATION FORM
   ============================================================ */
@media (max-width: 768px) {
  .bhf-form .form-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .waiver-group { flex-direction: column; gap: 0.75rem; }
  .waiver-group input[type="checkbox"] { width: 22px; height: 22px; }

  fieldset { padding: 1rem; }
}

/* ============================================================
   GUIDELINE CARDS (3→2→1)
   ============================================================ */
@media (max-width: 900px) {
  .guideline-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
}

@media (max-width: 540px) {
  .guideline-cards {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   FAQ
   ============================================================ */
@media (max-width: 480px) {
  .faq-question {
    font-size: 0.9rem;
    padding: 1rem 0;
  }

  .faq-answer-inner {
    font-size: 0.9rem;
  }
}

/* ============================================================
   GALLERY
   ============================================================ */
@media (max-width: 900px) {
  .gallery-masonry { columns: 3; column-gap: 0.75rem; }
}

@media (max-width: 640px) {
  .gallery-masonry { columns: 2; column-gap: 0.5rem; }
  .gallery-item { margin-bottom: 0.5rem; }
}

@media (max-width: 360px) {
  .gallery-masonry { columns: 1; }
}

.gallery-filter-bar {
  gap: 0.4rem;
  padding: 0.75rem;
}

@media (max-width: 640px) {
  .gallery-filter-bar {
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.75rem 0;
  }

  .gallery-filter-bar::-webkit-scrollbar { display: none; }

  .filter-btn {
    flex-shrink: 0;
    font-size: 0.65rem;
    padding: 7px 14px;
    white-space: nowrap;
  }
}

/* Gallery strip */
@media (max-width: 768px) {
  .gallery-strip { grid-template-columns: repeat(3, 1fr); gap: 2px; }
}

@media (max-width: 480px) {
  .gallery-strip { grid-template-columns: repeat(2, 1fr); }
}

/* Year archive grid */
@media (max-width: 900px) {
  .year-archive-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 600px) {
  .year-archive-grid { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .year-number { font-size: 2rem; }
}

@media (max-width: 360px) {
  .year-archive-grid { grid-template-columns: 1fr; }
}

/* Lightbox */
@media (max-width: 768px) {
  .lightbox-img {
    max-width: 95vw;
    max-height: 75vh;
  }

  .lightbox-close {
    top: -36px;
    font-size: 1.8rem;
  }
}

/* ============================================================
   HORROR FILM FESTIVAL — COMING SOON
   ============================================================ */
@media (max-width: 768px) {
  .coming-soon-title {
    font-size: clamp(3rem, 18vw, 7rem);
    line-height: 0.85;
  }

  .film-teaser-text {
    font-size: 0.95rem;
    padding: 0 8px;
  }

  .coming-soon-hero {
    min-height: 70vh;
    padding-top: 0;
  }

  .coming-soon-hero .container {
    padding-top: 110px;
    padding-bottom: 50px;
  }
}

/* Film festival 2-col sections → 1-col */
@media (max-width: 768px) {
  [id="hff-about-heading"] ~ div,
  .coming-soon-hero ~ section [style*="grid-template-columns:1fr 1fr"],
  .coming-soon-hero ~ section [style*="grid-template-columns: 1fr 1fr"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  [id="categories-heading"] ~ div {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }
}

@media (max-width: 640px) {
  [id="categories-heading"] ~ div {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   TESTIMONIALS
   ============================================================ */
@media (max-width: 900px) {
  .testimonials-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
}

@media (max-width: 600px) {
  .testimonials-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   TIMELINE
   ============================================================ */
@media (max-width: 768px) {
  .timeline { padding-left: 20px; }

  .timeline::before {
    left: 20px;
    width: 2px;
  }

  .timeline-item {
    grid-template-columns: 44px 1fr;
    gap: 0.75rem;
    margin-bottom: 2rem;
  }

  .timeline-year {
    width: 44px;
    height: 44px;
    font-size: 0.7rem;
    flex-shrink: 0;
  }

  .timeline-content {
    padding: 1rem;
    text-align: left !important;
    order: 2 !important;
  }

  .timeline-empty { display: none; }
}

/* ============================================================
   ABOUT PAGE — CULTURE CARDS (3→2→1)
   ============================================================ */
@media (max-width: 900px) {
  [id="culture-heading"] ~ div {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
  }
}

@media (max-width: 540px) {
  [id="culture-heading"] ~ div {
    grid-template-columns: 1fr !important;
  }

  [id="team-heading"] ~ div {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1.25rem !important;
  }
}

@media (max-width: 360px) {
  [id="team-heading"] ~ div {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   SPONSORS & PARTNERS
   ============================================================ */
@media (max-width: 768px) {
  .sponsors-logo-wall {
    gap: 0.75rem;
    justify-content: center;
  }

  .sponsor-logo-item {
    padding: 1rem 1.5rem;
    max-width: 130px !important;
  }

  .sponsor-logo-item img {
    max-width: 110px;
    max-height: 50px;
  }
}

@media (max-width: 480px) {
  .sponsor-logo-item {
    padding: 0.75rem 1rem;
    max-width: 110px !important;
  }
}

/* Sponsorship packages grid: 2→1 */
@media (max-width: 768px) {
  [id="packages"] .container > div[style*="grid-template-columns: repeat(2,1fr)"],
  [id="packages"] .container > div[style*="grid-template-columns:repeat(2,1fr)"] {
    grid-template-columns: 1fr !important;
  }

  .sponsor-package { padding: 1.5rem; }
  .package-price { font-size: 2rem; }
}

/* ============================================================
   CONTACT PAGE
   ============================================================ */
@media (max-width: 900px) {
  .contact-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }
}

@media (max-width: 768px) {
  .social-links { gap: 0.5rem; }
  .social-link { padding: 9px 14px; font-size: 0.65rem; }

  .contact-info-item { gap: 0.75rem; }
  .contact-icon { font-size: 1.2rem; width: 30px; }
}

/* ============================================================
   FOOTER
   ============================================================ */
@media (max-width: 1024px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }
}

@media (max-width: 640px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
    font-size: 0.6rem;
  }

  #site-footer { padding: 40px 0 0; }

  .footer-brand-desc { font-size: 0.85rem; }
  .footer-col-title  { font-size: 0.8rem; }
  .footer-links a    { font-size: 0.85rem; }

  .footer-social { gap: 0.5rem; }
  .footer-social-btn { width: 32px; height: 32px; font-size: 0.9rem; }
}

/* ============================================================
   PAGE HERO BANNER
   ============================================================ */
@media (max-width: 768px) {
  .page-hero {
    padding: 100px 0 40px;
  }

  .page-hero-title {
    font-size: clamp(2.2rem, 11vw, 4rem);
  }

  .page-hero-breadcrumb {
    font-size: 0.65rem;
    margin-top: 0.75rem;
  }
}

@media (max-width: 480px) {
  .page-hero {
    padding: 90px 0 32px;
  }
}

/* ============================================================
   ARCHIVE / BLOG
   ============================================================ */
@media (max-width: 900px) {
  .archive-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  #sidebar { order: -1; } /* sidebar on top on mobile */
}

@media (max-width: 768px) {
  .post-card-thumb { height: 180px; }
  .post-card-title { font-size: 1.2rem; }
  .post-card-body  { padding: 1rem; }
}

/* ============================================================
   INLINE GRIDS IN FRONT-PAGE.PHP (non-class style grids)
   These target inline grid styles used in front-page.php
   ============================================================ */

/* About preview section: 2→1 */
@media (max-width: 768px) {
  #about-preview .about-home {
    grid-template-columns: 1fr !important;
  }

  /* Zombie walk highlight: 2→1 */
  #zombie-walk-highlight > .container > div[style] {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }

  /* Zombie walk highlight: hide big emoji on mobile */
  #zombie-walk-highlight > .container > div > div:last-child > [style*="font-size:15rem"] {
    font-size: 6rem !important;
  }

  /* Film festival teaser CTA buttons */
  #film-festival-teaser .container > div[style*="display:flex"] {
    flex-direction: column !important;
    align-items: center !important;
    gap: 0.75rem !important;
  }

  /* 4-highlight boxes for zombie walk: 2→1 */
  #zombie-walk-highlight [style*="grid-template-columns:1fr 1fr"] {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.75rem !important;
  }
}

@media (max-width: 540px) {
  /* zombie walk 2-col boxes → 1 col */
  #zombie-walk-highlight [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* about stats */
  .about-stats {
    grid-template-columns: 1fr 1fr;
  }
}

/* ============================================================
   FINAL CTA SECTIONS
   ============================================================ */
@media (max-width: 640px) {
  /* Any flex CTA row with multiple buttons */
  section [style*="display:flex"][style*="gap:1rem"],
  section [style*="display: flex"][style*="gap: 1rem"] {
    flex-wrap: wrap !important;
    justify-content: center !important;
  }
}

@media (max-width: 480px) {
  section [style*="display:flex"][style*="justify-content:center"] .btn {
    flex: 1 1 140px;
    text-align: center;
  }
}

/* ============================================================
   COUNTDOWN URGENCY STATE
   ============================================================ */
#countdown.urgent .countdown-number {
  animation: flicker-urgent 1.5s ease-in-out infinite;
}

@keyframes flicker-urgent {
  0%, 90%, 100% { opacity: 1; }
  91% { opacity: 0.5; }
  92% { opacity: 1; }
  94% { opacity: 0.3; }
  96% { opacity: 1; }
}

/* ============================================================
   NEWSLETTER FORM
   ============================================================ */
@media (max-width: 640px) {
  .newsletter-form {
    flex-direction: column;
    gap: 0;
    max-width: 100%;
  }

  .newsletter-form input {
    border-right: 1px solid rgba(0, 229, 200, 0.2);
    border-bottom: none;
  }

  .newsletter-form .btn {
    clip-path: none;
    border-radius: 0;
    width: 100%;
  }
}

/* ============================================================
   ROUTE MAP
   ============================================================ */
@media (max-width: 768px) {
  .route-map-container {
    height: 300px;
  }

  /* Route stops: wrap nicely */
  [id="route"] .container > div[style*="display:flex"] {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.5rem !important;
  }
}

/* ============================================================
   SIDEBAR WIDGETS
   ============================================================ */
@media (max-width: 900px) {
  .sidebar-widget { margin-bottom: 1rem; }
}

/* ============================================================
   HORIZONTAL OVERFLOW GUARDRAIL
   Catches any edge cases that still overflow
   ============================================================ */
@media (max-width: 768px) {
  body { overflow-x: hidden; }

  /* Force inline styles that use px grid widths to collapse */
  [style*="grid-template-columns: 1fr 1fr;"],
  [style*="grid-template-columns:1fr 1fr;"] {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-template-columns: repeat(3,1fr)"],
  [style*="grid-template-columns:repeat(3,1fr)"] {
    grid-template-columns: 1fr !important;
  }

  [style*="grid-template-columns: repeat(4,1fr)"],
  [style*="grid-template-columns:repeat(4,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 480px) {
  [style*="grid-template-columns: repeat(2,1fr)"],
  [style*="grid-template-columns:repeat(2,1fr)"],
  [style*="grid-template-columns: repeat(4,1fr)"],
  [style*="grid-template-columns:repeat(4,1fr)"] {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
   TOUCH DEVICE SPECIFIC
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
  /* Make all hover states into always-visible states on touch */
  .event-card:hover { transform: none; }
  .btn:hover::before { display: none; }
  .gallery-item-overlay { opacity: 0; } /* keep lightbox tap-only */

  /* Bigger tap targets */
  .nav-menu a      { padding: 18px 0; }
  .filter-btn      { padding: 10px 18px; }
  .faq-question    { padding: 18px 0; }
  .footer-links a  { padding: 6px 0; display: block; }
}

/* ============================================================
   SAFE AREA (iPhone notch / home bar)
   ============================================================ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  #site-footer {
    padding-bottom: calc(0px + env(safe-area-inset-bottom));
  }

  #back-to-top {
    bottom: calc(28px + env(safe-area-inset-bottom));
  }

  @media (max-width: 480px) {
    #back-to-top {
      bottom: calc(16px + env(safe-area-inset-bottom));
    }
  }
}
