/**
 * Mobile & tablet responsive enhancements.
 * Loaded after site.css; complements Bootstrap 3 breakpoints.
 */

/* ─── Base: prevent horizontal scroll ─── */
html {
  -webkit-text-size-adjust: 100%;
}

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

/* ─── Body offset for fixed nav + bottom bar (CSS-first; JS adds isMobile/isDesktop) ─── */
@media (max-width: 991px) {
  body {
    padding-top: 170px;
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  }

  .navbar-fixed-bottom.footer-mobile {
    display: block;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: var(--bg-header);
  }

  .footer-mobile .nav-tabs > li > a {
    min-height: 48px;
    line-height: 1.3;
    padding: 12px 8px;
    font-size: 0.75rem;
  }

  /* Compact footer: keep newsletter visible on mobile */
  .isMobile .footer-inner,
  body:not(.isDesktop) .footer-inner {
    display: block;
    padding: 1.25rem 1rem 0.5rem;
    font-size: 0.85rem;
  }

  .footer-inner p {
    margin-bottom: 0.75rem;
  }

  .footer-social {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
  }

  footer {
    padding-bottom: 0;
  }
}

@media (min-width: 992px) {
  .navbar-fixed-bottom.footer-mobile {
    display: none !important;
  }

  body {
    padding-bottom: 0;
  }
}

/* ─── Top bar & nav ─── */
@media (max-width: 991px) {
  body {
    padding-top: 170px;
  }

  .top-bar--banner {
    --banner-h: min(calc(100vw * 287 / 1600), 96px);
    --header-band-height: calc(var(--banner-h) + 4.5rem);
    --banner-bg-offset: calc(-0.2rem);
    background-position: 0 0;
  }

  .top-bar-banner-media {
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem 0.5rem;
    padding: 0.2rem 0.5rem 0.3rem;
    font-size: calc(var(--banner-h) / 9);
  }

  .top-bar-banner-frame {
    order: -1;
    flex: 0 0 100%;
    width: 100%;
    display: flex;
    justify-content: center;
    align-self: auto;
  }

  .top-bar-banner-img {
    width: min(100%, calc(var(--banner-h) * 1600 / 287));
    max-height: var(--banner-h);
  }

  .top-bar-banner-side--left {
    flex: 1 1 calc(50% - 0.25rem);
    text-align: left;
  }

  .top-bar-banner-side--right {
    flex: 1 1 calc(50% - 0.25rem);
    text-align: right;
  }

  .top-bar-hours-line,
  .top-bar-phone,
  .top-bar-email {
    white-space: normal;
  }

  .header-logo {
    font-size: 0.75rem;
    line-height: 1.3;
  }

  .navbar-inverse .navbar-nav > li > a {
    padding: 12px 15px;
    font-size: calc(0.85rem + 1px);
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .navbar-inverse .navbar-nav .open .dropdown-menu {
    position: static;
    float: none;
    width: 100%;
    box-shadow: none;
    border-radius: 0;
  }

  .navbar-inverse .navbar-nav .dropdown-menu > li > a {
    padding: 10px 20px 10px 30px;
    min-height: 44px;
  }

  .navbar-toggle {
    margin-top: 8px;
    margin-bottom: 8px;
    padding: 12px 10px;
  }

  .navbar-brand.visible-xs {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    max-width: calc(100% - 60px);
  }

  .navbar-brand.visible-xs span {
    font-size: 0.7rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 600px) {
  .top-bar {
    font-size: 0.6rem;
  }

  .navbar-inverse .navbar-brand img {
    max-width: 36px;
    height: auto;
  }
}

/* ─── Home hero ─── */
@media (max-width: 991px) {
  .isDesktop header.home,
  header.home {
    min-height: auto;
    height: auto;
  }

  #hero-video {
    background: var(--bg-header) center/cover no-repeat;
    background-image: var(--hero-poster, none);
  }

  #hero-video .hero-content {
    padding: 1.5rem 1rem 2rem;
    width: 100%;
  }

  .hero-title {
    font-size: clamp(1.35rem, 6vw, 2rem);
  }

  .hero-sub {
    font-size: 0.95rem;
  }

  .hero-cta {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
    width: 100%;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
  }

  .hero-cta .btn {
    width: 100%;
    min-height: 44px;
    white-space: normal;
  }

  .hero-ornament::before,
  .hero-ornament::after {
    width: 20vw;
    min-width: 40px;
  }

  #home-hero.hero {
    min-height: 4rem;
    height: auto;
    padding: 1rem 0;
  }
}

/* ─── Page hero (inner pages) ─── */
@media (max-width: 768px) {
  .hero {
    height: auto;
    min-height: 10rem;
    padding-bottom: 1rem;
  }

  .hero-content {
    padding: 1rem;
  }

  .ssn-story .hero-bg {
    background-position: center center;
  }
}

/* ─── Main content ─── */
@media (max-width: 768px) {
  .main {
    padding: 1.5rem 1rem 2.5rem;
  }

  section .container {
    padding-left: 15px;
    padding-right: 15px;
  }

  .card {
    padding: 1.25rem;
  }

  .section-title {
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    word-wrap: break-word;
  }

  .btn,
  .btn-fe-primary,
  .btn-lg {
    min-height: 44px;
    padding: 0.65rem 1rem;
  }

  .fe-days-grid {
    grid-template-columns: 1fr;
  }

  .fe-cta-row {
    flex-direction: column;
    align-items: stretch;
    padding: 1rem 1.25rem;
  }

  .fe-cta-btns {
    flex-direction: column;
    width: 100%;
  }

  .fe-cta-btns .btn {
    width: 100%;
    text-align: center;
  }

  .fe-body {
    padding: 1.25rem;
  }

  .stats-bar {
    flex-direction: column;
    gap: 1rem;
  }

  .filter-row {
    gap: 0.4rem;
  }

  .filter-pill {
    min-height: 40px;
    padding: 0.5rem 0.75rem;
  }

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

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

  .container-fluid.grid {
    flex-direction: column;
    margin: 0 10px;
  }
}

/* ─── Tables & calendars ─── */
@media (max-width: 768px) {
  .table-scroll,
  .table-2col-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #temple-calendar {
    overflow-x: auto;
  }

  .fc-toolbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .fc-toolbar-title {
    font-size: 1rem !important;
  }
}

/* ─── Embeds (PDF, Constant Contact, panchang) ─── */
.embed-responsive {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.embed-responsive iframe {
  display: block;
  width: 100%;
  border: 0;
}

.embed-responsive-16by9 {
  aspect-ratio: 4 / 3;
  min-height: 280px;
}

@media (max-width: 768px) {
  .embed-responsive-16by9 {
    aspect-ratio: auto;
    min-height: 70vh;
  }

  .embed-responsive-16by9 iframe {
    min-height: 70vh;
    height: 70vh;
  }
}

@media (max-width: 991px) {
  #panchangFrame {
    width: min(calc(100vw - 2rem), 300px);
    max-width: calc(100vw - 2rem);
    height: min(70vh, 420px);
    right: 1rem;
    left: auto;
    top: auto;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    margin: 0;
    transform: translateX(120%);
  }

  #panchangFrame.isopen {
    transform: translateX(0);
  }

  #social_side_links {
    top: auto;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    transform: none;
    right: 0;
    height: auto;
    max-height: 50vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.15);
  }

  #social_side_links li a img {
    width: 44px;
    padding: 6px;
  }

  #social_side_links li a:hover img,
  #social_side_links li a:hover img:hover {
    padding-left: 6px;
    width: 44px;
  }
}

/* ─── Gallery lightbox ─── */
@media (max-width: 700px) {
  .gallery-grid {
    columns: 1 100% !important;
  }

  .lightbox-content,
  #lb-img {
    max-width: 100vw;
    max-height: 60vh;
  }
}

/* ─── Testimonials / quick links on home ─── */
@media (max-width: 576px) {
  .col-xs-6.col-sm-4.col-md-2 {
    width: 50%;
  }
}

/* ─── Touch: reduce hover-only effects ─── */
@media (hover: none) and (pointer: coarse) {
  #social_side_links li a:hover {
    transform: none;
  }
}
