/**
 * Responsive fixes for the Bali Spa Guide front end.
 *
 * Loaded after style.css and the custom module styles. Breakpoints follow
 * Bootstrap 5: sm 576px, md 768px, lg 992px, xl 1200px.
 */

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

/* ------------------------------------------------------------------
 * Header / mobile navigation
 *
 * The navbar collapses below lg (992px), but the old hamburger styles only
 * applied up to 768px, so between 769-991px the toggle was invisible.
 * ---------------------------------------------------------------- */
@media (max-width: 991.98px) {
  header nav.navbar {
    padding-top: .5rem;
    padding-bottom: .5rem;
  }
  header nav.navbar > .container {
    padding-left: 12px !important;
    padding-right: 12px !important;
    align-items: center;
  }
  #block-sitebranding-2 p {
    margin: 0;
  }
  #block-sitebranding-2 img {
    width: 100px;
    height: auto;
  }

  /* Hamburger, turning into an X while the menu is open. */
  header .navbar-toggler {
    border: 0;
    padding: 10px 8px;
    border-radius: 4px;
  }
  header .navbar-toggler:focus {
    box-shadow: none;
  }
  header .navbar-toggler:focus-visible {
    box-shadow: 0 0 0 2px #71CBD3;
  }
  header .hamburger {
    width: 26px;
    height: 3px;
    border-radius: 2px;
    background-color: #fff;
    transition: transform .25s ease, opacity .2s ease;
  }
  header .hamburger:not(:last-child) {
    margin-bottom: 5px;
  }
  header .navbar-toggler:not(.collapsed) .hamburger:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }
  header .navbar-toggler:not(.collapsed) .hamburger:nth-child(2) {
    opacity: 0;
  }
  header .navbar-toggler:not(.collapsed) .hamburger:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }

  /* Opened menu overlays the page instead of pushing sections down.
     nav.navbar is position: relative, so this spans the full header width. */
  header .navbar-collapse {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    background-color: #444;
    border-top: 1px solid #5D5D5D;
    box-shadow: 0 8px 16px rgba(0, 0, 0, .35);
    max-height: calc(100vh - 96px);
    max-height: calc(100dvh - 96px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  header .navbar-collapse > div,
  header #block-b5subtheme-main-navigation,
  header .navbar-nav {
    width: 100%;
  }
  header .navbar-nav > li.nav-item {
    border-bottom: 1px solid #5D5D5D;
  }
  header nav.navbar .navbar-nav > li > a.nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 20px;
    line-height: 1.2;
    padding: 14px 16px !important;
    border: 0;
  }
  header .navbar-nav > li > a.dropdown-toggle::after {
    position: static;
    margin-left: auto;
    transition: transform .2s ease;
  }
  header .navbar-nav > li > a.dropdown-toggle.show::after {
    transform: rotate(180deg);
  }

  /* Submenus: inline, two columns so long lists stay short. */
  header nav.navbar .dropdown-menu {
    position: static !important;
    transform: none !important;
    float: none;
    border: 0;
    margin: 0;
    padding: 4px 0 12px;
    background-color: #3a3a3a;
    column-count: 2;
    column-gap: 0;
  }
  header nav.navbar .dropdown-menu > li {
    break-inside: avoid;
  }
  header nav.navbar .dropdown-menu .dropdown-item {
    color: #fff;
    font-size: 14px;
    padding: 9px 16px;
    white-space: normal;
  }
  header nav.navbar .dropdown-menu .dropdown-item:hover,
  header nav.navbar .dropdown-menu .dropdown-item:focus {
    background-color: #555;
    color: #71CBD3;
  }
}

/* ------------------------------------------------------------------
 * Hero slider (owl_slider)
 * ---------------------------------------------------------------- */
#owl .slider-image-wrapper img {
  width: 100%;
}

#owl .slider-text-wrapper {
  max-width: 85%;
  z-index: 2;
}

/* owl-slider.css gives the arrows z-index 9999, which put them above the
   opened mobile menu. They only need to sit above the slide. */
#owl-slider.owl-nav button {
  z-index: 5;
}

@media (max-width: 767.98px) {
  #owl .slider-image-wrapper img {
    height: 260px;
  }
  #owl .slider-body-text {
    margin-bottom: .75rem !important;
  }
  #owl .slider-title {
    font-size: 1.75rem !important;
    margin-bottom: .25rem;
  }
  #owl .slider-subtitle {
    font-size: 1rem !important;
    margin-bottom: 0;
  }
  #owl .slider-button-wrapper .button-link {
    font-size: 1.1rem;
    padding: 8px 14px;
  }
  #owl-slider.owl-nav button.owl-prev {
    right: 52px;
  }
  #owl-slider.owl-nav button.owl-next {
    right: 12px;
  }
  #owl-slider.owl-nav button > a {
    height: 32px;
    width: 32px;
  }
}

@media (min-width: 768px) and (max-width: 1199.98px) {
  #owl .slider-image-wrapper img {
    height: 380px;
  }
}

/* ------------------------------------------------------------------
 * Homepage "LOCATIONS" grid (block_locations)
 * ---------------------------------------------------------------- */
#locations .grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#locations .grid-item a,
#locations .content-wrapper,
#locations .image-wrapper {
  display: block;
  height: 100%;
}

#locations .count-wrapper p {
  white-space: nowrap;
  margin: 0;
}

@media (max-width: 575.98px) {
  #locations {
    padding: 10px 6px 6px !important;
  }
  #locations .section-title h2 {
    font-size: 1.75rem !important;
  }
  #locations .grid-container {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  #locations .grid-item.primary {
    grid-column: 1 / -1;
    grid-row: auto;
  }
  #locations .grid-item.primary .count-wrapper {
    bottom: 28px;
  }
  #locations .count-wrapper p {
    font-size: 1.1rem;
  }
}

@media (min-width: 576px) and (max-width: 991.98px) {
  #locations .grid-container {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  #locations .grid-item.primary {
    grid-column: 1 / 3;
    grid-row: 1 / 3;
  }
  #locations .count-wrapper p {
    font-size: 1.25rem;
  }
}

/* ------------------------------------------------------------------
 * Homepage "TREATMENTS" carousel (block_treatments)
 * ---------------------------------------------------------------- */
@media (max-width: 575.98px) {
  #treatment .section-title h2 {
    font-size: 1.75rem !important;
  }
  #treatment .owl-nav button {
    top: 14px;
  }
}

/* ------------------------------------------------------------------
 * Views image grids ("Treatments and Classes", "Locations")
 *
 * Views Grid prints fixed inline widths (14.28% / 25%) and empty cells
 * for terms without an image. Re-flow them as a CSS grid instead.
 * ---------------------------------------------------------------- */
.views-view-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.views-view-grid.cols-7 {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.views-view-grid > .views-row {
  display: contents;
}

/* .clearfix::after would otherwise become an empty grid cell. */
.views-view-grid::before,
.views-view-grid::after,
.views-view-grid > .views-row::before,
.views-view-grid > .views-row::after {
  display: none;
}

.views-view-grid .views-col {
  width: auto !important;
  float: none;
}

.views-view-grid .views-col:not(:has(img)) {
  display: none;
}

.views-view-grid .views-col img {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 991.98px) {
  .views-view-grid.cols-7 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 767.98px) {
  .views-view-grid,
  .views-view-grid.cols-7 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .views-view-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ------------------------------------------------------------------
 * Single spa page (single_spa)
 * ---------------------------------------------------------------- */
.spa-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.spa-tabs::-webkit-scrollbar {
  display: none;
}

.spa-tabs .nav-link,
.spa-tabs .nav-item {
  white-space: nowrap;
}

@media (max-width: 991.98px) {
  /* Lead with the spa name and photos; sidebar (booking, map, hours) follows. */
  .spa-detail-content .row > .sidebar {
    order: 2;
    margin-top: 2rem;
  }
  .spa-detail-content .row > .col-lg-9 {
    order: 1;
    padding-top: 1rem !important;
  }
  .spa-detail-content .logo-image-wrapper {
    max-width: 220px;
    margin: 0 auto 1rem;
  }
  .spa-detail-content .map-wrapper #map {
    height: 300px !important;
  }
}

@media (max-width: 575.98px) {
  .spa-header {
    margin-bottom: 1.5rem !important;
  }
  .spa-header > .spa-title-wrapper,
  .spa-header > .spa-rating-budget-wrapper {
    flex: 0 0 100%;
    max-width: 100%;
    text-align: left !important;
  }
  .spa-header .spa-rating-budget-wrapper {
    margin-top: .5rem;
  }
  .spa-header .spa-title {
    font-size: 2.25rem;
  }
  .spa-header .spa-subtitle {
    font-size: 1.4rem;
  }
  .spa-header .spa-rating i {
    font-size: 22px !important;
  }
  #spa-tabContent {
    padding: 1.5rem 1rem !important;
  }
}

/* ------------------------------------------------------------------
 * Spa listings (term pages, spafinder, search)
 * ---------------------------------------------------------------- */
.spa-wrapper .spa-rating,
.spa-wrapper .spa-budget {
  white-space: nowrap;
}
@media (max-width: 991.98px) {
  #map.map {
    height: 300px !important;
  }
}

@media (max-width: 575.98px) {
  .filter .filter-sort select {
    max-width: 100%;
  }
}

/* ------------------------------------------------------------------
 * Footer: Bootstrap5 gives <footer> 2rem vertical padding, which shows as
 * white bands above the first and below the last coloured section.
 * ---------------------------------------------------------------- */
footer {
  padding: 0;
}

/* ------------------------------------------------------------------
 * Footer link lists (locations, treatments): flow into columns instead
 * of one long single column.
 * ---------------------------------------------------------------- */
footer :is(.footer_second, .footer_third) div:has(> div > a) {
  column-count: 2;
  column-gap: 1.5rem;
}

footer :is(.footer_second, .footer_third) div:has(> div > a) > div {
  break-inside: avoid;
  padding: 2px 0;
}

@media (min-width: 576px) {
  footer :is(.footer_second, .footer_third) div:has(> div > a) {
    column-count: 3;
  }
}

@media (min-width: 992px) {
  footer :is(.footer_second, .footer_third) div:has(> div > a) {
    column-count: 4;
  }
}
