/* Top Header */
#topBar {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: max(50%, 600px);
  border-radius: 12px;
  padding: 12px 24px;
  min-height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  z-index: 200;
  transition: max-width 0.3s ease;
}

body.top-bar-small #topBar {
  width: 33.333%;
  max-width: 33.333%;
}
body.top-bar-standard #topBar {
  width: 50%;
  max-width: 50%;
}
body.top-bar-wide #topBar {
  width: 75%;
  max-width: 75%;
}
body.top-bar-full #topBar {
  width: 100%;
  max-width: calc(100vw - 40px);
}
body.top-bar-fixed #topBar {
  width: 100%;
  max-width: none;
  top: 0;
  inset-inline-start: 0;
  inset-inline-end: 0;
  transform: none;
  border-radius: 0;
}

.title-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  padding: 10px 16px;
  margin-inline-start: -16px;
  border-radius: 10px;
  transition: background 0.2s ease;
  min-width: 0;
  flex: 1 1 auto;
}
.title-dropdown-trigger:hover {
  background: var(--hover-bg-overlay, rgba(255, 255, 255, 0.25));
}

.title-dropdown-trigger.open .dropdown-chevron {
  transform: rotate(180deg);
}

.dropdown-chevron {
  flex-shrink: 0;
}

.glass-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 250px;
  width: max-content;
  max-width: 450px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--primary-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  padding: 8px 0;
  margin: 0;
  list-style: none;
  z-index: 100;
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
}
.glass-dropdown.hidden {
  display: none;
  opacity: 0;
  transform: translateY(-10px);
}

/* Center elements on Full and Fixed layouts */
body.top-bar-fixed .title-dropdown-trigger,
body.top-bar-fixed #topBar > h1.sceneName,
body.top-bar-full .title-dropdown-trigger,
body.top-bar-full #topBar > h1.sceneName {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  min-width: unset;
  max-width: calc(100% - 120px); /* Leave room for buttons */
  justify-content: space-between;
}

body.top-bar-fixed .glass-dropdown,
body.top-bar-full .glass-dropdown {
  left: 50%;
  transform: translateX(-50%);
  min-width: unset;
}
/* the room list is capped; the mega gallery is as wide as its thumbnails per row say (.columns-N below). The cap outranked those, so
   under a full-width or fixed bar the gallery stayed 450px wide, three medium thumbnails, whatever was chosen (Ben, 2026-10-30) */
body.top-bar-fixed .glass-dropdown:not(.title-gallery),
body.top-bar-full .glass-dropdown:not(.title-gallery) {
  width: max-content;
  max-width: 450px;
}
body.top-bar-fixed .glass-dropdown.hidden,
body.top-bar-full .glass-dropdown.hidden {
  transform: translateX(-50%) translateY(-10px);
}

.title-gallery {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-start: 20px;
  margin-top: 8px;
  min-width: 250px;
  width: max-content;
  max-width: calc(100vw - 40px); /* gracefully shrinks on mobile */
  padding: 15px;
  /* as tall as the room under the top bar allows (it starts about 110px down, more under a Multi Menu; a phone's bottom bar takes
     its own), leaving 20px at the foot: a tour with many rooms shows them all without scrolling where they fit (Ben, 2026-10-30). It
     was 70% of the screen. A short gallery is only as tall as its thumbnails */
  --title-gallery-h: calc(100vh - 110px - var(--menu-bar-h, 0px) - var(--mobile-bottom-nav-height, 0px));
  max-height: var(--title-gallery-h);
  overflow: hidden; /* Hide the ugly inherited dropdown scrollbar */
}

.title-gallery-list {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start; /* ensures left alignment on wrapping rows */
  align-content: flex-start;
  overflow-y: auto;
  gap: 12px; /* matched to main gallery */
  max-height: calc(var(--title-gallery-h) - 30px); /* Tightly bounds to parent minus padding */
  padding: 10px; /* prevent hover transform clipping */
}
/* custom scrollbar for mega-menu */
.title-gallery-list {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.95) transparent;
}
.title-gallery-list:hover {
  scrollbar-color: var(--accent-dark, rgba(0, 0, 0, 0.5)) transparent;
}
.title-gallery-list::-webkit-scrollbar {
  width: 8px;
}
.title-gallery-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}
.title-gallery-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 4px;
}
.title-gallery-list::-webkit-scrollbar-thumb:hover {
  background: var(--accent-dark, rgba(0, 0, 0, 0.5));
}

.title-scene-thumb {
  width: 120px;
  height: 70px;
  margin: 0; /* flex handles layout */
  flex-shrink: 0; /* ensure they don't squish */
}
.title-scene-thumb .thumb-background {
  filter: brightness(1) !important;
}
.title-scene-thumb:hover .thumb-background {
  filter: brightness(0.7) !important;
}

.dropdown-item {
  padding: 10px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95em;
  font-weight: 500;
  color: var(--text-main, #ffffff); /* Maximum whiteness for best contrast against glass */
  transition: all 0.2s ease;
  border-inline-start: 3px solid transparent;
  width: 100%;
}
.scene-menu-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
}
.dropdown-thumb-img {
  width: 64px;
  height: 32px;
  min-width: 64px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.dropdown-item:hover {
  background: rgba(0, 0, 0, 0.35); /* Darkened hover state for maximum contrast */
  color: var(--text-main);
}
.dropdown-item.current {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.2); /* Slightly darkened active state */
  border-inline-start: 3px solid var(--accent);
}

.header-controls {
  display: flex;
  gap: 16px;
}

body:not(.top-bar-small) .header-controls {
  width: 100%;
  justify-content: flex-end;
}

.control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  transition: all var(--transition-speed);
  text-decoration: none;
}
.control-btn:hover {
  background: var(--hover-bg-overlay, rgba(255, 255, 255, 0.25));
  box-shadow: 0 0 12px var(--accent-glow);
  /* the glow in the tour's icon colour (it was cyan on every tour: a theme sets no --accent-glow) */
  box-shadow: 0 0 12px color-mix(in srgb, var(--icon-color, #00e5ff) 40%, transparent);
}
.control-btn img {
  width: 20px;
  height: 20px;
  filter: brightness(0) invert(1);
}

.control-btn.enabled .off {
  display: none;
}
.control-btn.enabled .on {
  display: block;
}
.control-btn:not(.enabled) .off {
  display: block;
}
.control-btn:not(.enabled) .on {
  display: none;
}

#standaloneControls {
  position: absolute;
  top: 15px;
  inset-inline-end: 20px;
  display: flex;
  gap: 12px;
  z-index: 20;
}
#standaloneControls .control-btn.glass-panel {
  border-radius: 50%;
  width: 44px;
  height: 44px;
  /* the tour's own panel colour, as the bars and the folded floor plan wear it: the 5% white of a button inside the title bar left
     these two all but see-through, and pale on a bright ceiling (Ben, 2026-10-11) */
  background: var(--primary-bg, rgba(20, 20, 20, 0.75));
}
/* the bar's own icons, drawn in the tour's icon colour (a page made before 2026-10-11 has two pictures here instead) */
#standaloneControls .control-btn.glass-panel {
  color: var(--icon-color, #fff);
  cursor: pointer;
}
#standaloneControls .control-btn.glass-panel svg {
  width: 22px;
  height: 22px;
}
#standaloneControls .control-btn.glass-panel:hover {
  background: var(--primary-bg, rgba(20, 20, 20, 0.75));
  filter: brightness(1.25);
}

/* MEGA GALLERY OVERRIDE USER SETTINGS */

/* Define CSS Variables for Thumb sizes */
.title-gallery.thumb-size-small {
  --thumb-width: 80px;
}
.title-gallery.thumb-size-medium {
  --thumb-width: 120px;
}
.title-gallery.thumb-size-large {
  --thumb-width: 160px;
}

/* Apply Thumb sizes */
.title-gallery.thumb-size-small .title-scene-thumb {
  width: var(--thumb-width);
  height: 50px;
}
.title-gallery.thumb-size-small .scene-label {
  font-size: 0.65em;
  padding: 4px;
}
.title-gallery.thumb-size-medium .title-scene-thumb {
  width: var(--thumb-width);
  height: 70px;
}
.title-gallery.thumb-size-large .title-scene-thumb {
  width: var(--thumb-width);
  height: 100px;
  font-size: 1em;
}

/* Enforce physical Width Caps for Auto */
.title-gallery.columns-auto.gallery-width-standard {
  width: 600px;
  max-width: calc(100vw - 40px);
}
.title-gallery.columns-auto.gallery-width-wide {
  width: 900px;
  max-width: calc(100vw - 40px);
}

/* Enforce math-based column layouts using Flex wrap physical boundary constraints */
/* Container width = (thumb_width * columns) + (12px_gap * (columns - 1)) + 30px_parent_padding + 20px_list_padding + 10px_scrollbar */
.title-gallery.columns-3 {
  width: calc((var(--thumb-width) * 3) + 24px + 60px);
  max-width: calc(100vw - 40px);
}
.title-gallery.columns-4 {
  width: calc((var(--thumb-width) * 4) + 36px + 60px);
  max-width: calc(100vw - 40px);
}
.title-gallery.columns-5 {
  width: calc((var(--thumb-width) * 5) + 48px + 60px);
  max-width: calc(100vw - 40px);
}
.title-gallery.columns-6 {
  width: calc((var(--thumb-width) * 6) + 60px + 60px);
  max-width: calc(100vw - 40px);
}
.title-gallery.columns-7 {
  width: calc((var(--thumb-width) * 7) + 72px + 60px);
  max-width: calc(100vw - 40px);
}
.title-gallery.columns-8 {
  width: calc((var(--thumb-width) * 8) + 84px + 60px);
  max-width: calc(100vw - 40px);
}

/* Expand Top Bar Dropdowns to 90% width on Mobile */
@media (max-width: 768px) {
  .glass-dropdown,
  body.top-bar-fixed .glass-dropdown,
  body.top-bar-full .glass-dropdown {
    min-width: unset !important;
    width: 90vw !important;
    max-width: 90vw !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
  }
  body.top-bar-fixed .glass-dropdown.hidden,
  body.top-bar-full .glass-dropdown.hidden,
  .glass-dropdown.hidden {
    transform: translateX(-50%) translateY(-10px) !important;
  }
  
  /* Make Top Bar Title wider and left-aligned on mobile */
  body.top-bar-fixed .title-dropdown-trigger,
  body.top-bar-fixed #topBar > h1.sceneName,
  body.top-bar-full .title-dropdown-trigger,
  body.top-bar-full #topBar > h1.sceneName {
    position: static;
    inset-inline-start: auto;
    transform: none;
    max-width: calc(100% - 80px); /* Leave just enough room for the right-side icons */
    justify-content: flex-start;
  }

  /* The room's name runs the width of the bar on a phone, as far as the first icon (Ben, 2026-10-12: "can the dropdown menu
     go all the way across the top? if an icon is on a side it can go as far as the icon, it's too small here"). The rule above
     always kept 80px back for icons, with one icon or none, so a 300px bar showed "Islamic Center - E…". Once the script has
     put the name in the row of icons, the row shares the room out: the icons keep their size and the name has the rest. */
  body #topBar .header-controls .title-dropdown-trigger {
    flex: 1 1 0;
    /* it may be narrower than its words (a wide bar's rule for a computer undoes that), so a long name ends in dots */
    min-width: 0;
    max-width: none;
  }
  body #topBar .header-controls .control-btn,
  body #topBar .header-controls #tbBtnLangWrapper {
    flex-shrink: 0;
  }

  /* Hide direct child dropdown trigger on mobile unless moved into controls by JS */
  body.has-mobile-nav #topBar > .title-dropdown-trigger {
    display: none;
  }

  body.mobile-no-dropdown #topBar .title-dropdown-trigger {
    display: none !important;
  }
  body.mobile-bottom-no-dropdown #mobileBottomNav .title-dropdown-trigger {
    display: none !important;
  }
}

body.desktop-no-dropdown:not(.has-mobile-nav) .title-dropdown-trigger {
  display: none !important;
}

/* Mobile Bottom Navigation */
#mobileBottomNav {
  display: none;
}

@media (max-width: 768px) {
  body.has-mobile-nav #mobileBottomNav {
    display: flex;
    position: fixed;
    bottom: 0;
    inset-inline-start: 0;
    inset-inline-end: 0;
    width: 100%;
    z-index: 1000;
    justify-content: center;
    border-radius: 0;
    border-top: 1px solid var(--mobile-nav-line, rgba(255, 255, 255, 0.1));
    /* The theme's panel colour, as the top bar has on a phone, until Design > Mobile Navigation gives the bar a colour or an
       opacity of its own (TourTemplateService::mobileNavStyles). It was black at 40% whatever the theme (Ben, 2026-10-12:
       "still dark bottom tab, should be green like the header"). At 0% the blur and the line along the top go too. */
    background: var(--mobile-nav-bg, var(--primary-bg, rgba(0, 0, 0, 0.4)));
    backdrop-filter: var(--mobile-nav-blur, blur(15px));
    -webkit-backdrop-filter: var(--mobile-nav-blur, blur(15px));
  }
  
  /* nothing ticked for it (only a top feature makes the phone's own navigation): no empty strip along the foot */
  body.mobile-bottom-empty #mobileBottomNav {
    display: none;
  }

  #mobileBottomNav .header-controls {
    justify-content: space-evenly;
    width: 100%;
    gap: 8px;
    padding: 0.5rem;
  }

  /* Buttons a finger can press: 46 px round with a larger icon (they were 36 px: Ben, 2026-10-11) */
  #mobileBottomNav .control-btn {
    width: 46px;
    height: 46px;
  }
  #mobileBottomNav .control-btn svg {
    width: 24px;
    height: 24px;
  }
  #mobileBottomNav .control-btn img {
    width: 24px;
    height: 24px;
  }
  /* Every icon in the Icon colour (Global aesthetics): Gallery, List Rooms and Menu are drawn in currentColor, so they stayed white
     beside a coloured Play and Floor plan (Ben, 2026-10-29, Harrison Kenyon's MC6 Astro Turf tour). Here, not in the markup, so a page made before has it. */
  #mobileBottomNav .control-btn > svg {
    color: var(--icon-color, currentColor);
  }
  
  body.mobile-bottom-no-autorotate #mbBtnAutorotate,
  body.mobile-bottom-no-fullscreen #mbBtnFullscreen,
  body.mobile-bottom-no-vr #mbBtnVR,
  body.mobile-bottom-no-gallery #mbBtnGallery,
  body.mobile-bottom-no-floorplan #mbBtnFloorplan,
  body.mobile-bottom-no-map #mbBtnMap {
    display: none !important;
  }
}

/* Desktop/Mobile Sidebar Toggle Button Logic */
#tbBtnSidebar {
  display: none !important;
}

@media (max-width: 768px) {
  body.has-mobile-nav #sidebarToggleWrapper {
    display: none !important;
  }
  
  body.has-mobile-nav:not(.mobile-no-sidebar) #tbBtnSidebar {
    display: flex !important;
  }
  
  body.mobile-bottom-no-sidebar #mbBtnSidebar {
    display: none !important;
  }
}

/* Look Around (top-bar.js): a Mobile Navigation icon, so in the top bar on a phone only, never in a computer's title bar */
#tbBtnLookAround {
  display: none !important;
}
@media (max-width: 768px) {
  body.has-mobile-nav #tbBtnLookAround {
    display: flex !important;
  }
}
/* ...and while it is on, its button is lit as a pressed toggle */
.look-around-btn.active {
  background: color-mix(in srgb, var(--icon-color, #ffffff) 28%, transparent);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--icon-color, #ffffff) 70%, transparent);
}

.header-controls .title-dropdown-trigger { margin-inline-end: auto; }
#mobileBottomNav .header-controls .title-dropdown-trigger { 
  margin-inline-start: 0;
  padding-inline-start: 8px;
}

@media (max-width: 768px) {
  .glass-dropdown.dropdown-up {
    position: fixed !important;
    top: auto !important;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 70px) !important;
    z-index: 1010 !important;
  }
  body.top-bar-fixed .glass-dropdown.dropdown-up.hidden,
  body.top-bar-full .glass-dropdown.dropdown-up.hidden,
  .glass-dropdown.dropdown-up.hidden {
    transform: translateX(-50%) translateY(10px) !important;
  }
}

/* A top bar that only a phone has (App\Support\PhoneTopBar): the Multi Menu is the computer's bar and is left off phones, so
   Mobile Navigation's Top Bar Features make the phone's own. It is never drawn on a wider screen (top-bar.js takes it off the
   page there as well, so everything that asks whether the page has a top bar is answered as on a tour without one), and not on
   a phone either where nothing is ticked for it. */
@media (min-width: 769px) {
  body.top-bar-phones-only #topBar {
    display: none !important;
  }
}
@media (max-width: 768px) {
  /* a phone's header: the whole width at the very top, whatever kind of title bar the tour's computer bar would be (a floating
     one is 15px down, centred and round-cornered, and beside the side menu's button it was pushed half off the screen) */
  body.top-bar-phones-only #topBar {
    top: 0 !important;
    inset-inline-end: 0 !important;
    inset-inline-start: 0 !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    transform: none !important;
  }

  body.top-bar-phones-empty #topBar {
    display: none !important;
  }

  /* The side menu opens under that header, not behind it: its close button and its first line were under the bar (Ben,
     2026-10-12: "make sure there is some room above the side nav menu text on mobile. it's too close to the topbar here") */
  body.top-bar-phones-only:not(.top-bar-phones-empty) .glass-sidebar {
    top: 64px !important;
    height: calc(100% - 64px) !important;
  }
}
