/* Production Visuals drawer: Real controls, rewards and preview logic
   come from Calphii's existing Visuals code; this file does not replace them. */
body.calphii-tray-active #visualsFloatingMenu {
  box-sizing: border-box;
  width: calc(100vw - 20px) !important;
  max-width: calc(100vw - 20px) !important;
  height: var(--visuals-drawer-lift-height);
  max-height: var(--visuals-drawer-lift-height);
  min-height: 0;
  left: 50% !important;
  right: auto !important;
  top: auto !important;
  bottom: max(75px, env(safe-area-inset-bottom)) !important;
  transform: translateX(-50%);
  padding: 0;
  overflow: hidden;
  gap: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
/* The home and detail views share the same compact height. */
#visualsFloatingMenu .visuals-drawer-preserved { display: none !important; }
#visualsFloatingMenu .visuals-drawer-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-width: 0;
  overflow: hidden;
}
#visualsFloatingMenu .visuals-drawer-back[hidden] { display: none !important; }
#visualsFloatingMenu .visuals-drawer-back {
  flex: 0 0 auto;
  align-self: center;
}
#visualsFloatingMenu .visuals-drawer-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
#visualsFloatingMenu .visuals-drawer-page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(16px, 0, 0);
  transition: transform 220ms ease, opacity 220ms ease, visibility 0s linear 220ms;
}
#visualsFloatingMenu .visuals-drawer-page.is-current {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, 0, 0);
  transition: transform 220ms ease, opacity 220ms ease, visibility 0s;
}
#visualsFloatingMenu .visuals-drawer-shell.is-detail .visuals-drawer-home {
  transform: translate3d(-16px, 0, 0);
}
/* Hidden category controls must not intersect the viewport: preserve their
   existing IntersectionObserver lazy-loading until the user opens that view. */
#visualsFloatingMenu .visuals-drawer-detail:not(.is-current) .visuals-drawer-detail-body {
  display: none;
}
#visualsFloatingMenu .visuals-drawer-home { padding: 10px 12px; }
#visualsFloatingMenu .visuals-drawer-category-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
#visualsFloatingMenu .visuals-drawer-category {
  appearance: none;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 0;
  gap: 10px;
  padding: 12px 14px;
  text-align: left;
  color: var(--color-text-primary);
  background-color: rgba(241, 255, 250, .03);
  border: 1px solid rgba(241, 255, 250, .18);
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}
#visualsFloatingMenu .visuals-drawer-category:hover,
#visualsFloatingMenu .visuals-drawer-category:focus-visible {
  background-color: rgba(241, 255, 250, .1);
  border-color: rgba(241, 255, 250, .34);
}
#visualsFloatingMenu .visuals-drawer-category-icon {
  display: block;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  object-fit: contain;
}
#visualsFloatingMenu .visuals-drawer-category[data-visual-category="pixel-pet"] .visuals-drawer-category-icon {
  image-rendering: pixelated;
}
#visualsFloatingMenu .visuals-drawer-category-copy {
  display: flex;
  align-items: center;
  min-width: 0;
}
#visualsFloatingMenu .visuals-drawer-category-name {
  font-family: var(--font-primary);
  font-size: 12px;
  font-weight: 500;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
#visualsFloatingMenu .visuals-drawer-category-arrow {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 18px;
  opacity: .6;
}
#visualsFloatingMenu .visuals-drawer-detail { padding: 10px 12px; }
#visualsFloatingMenu .visuals-drawer-detail-heading {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  min-height: 29px;
  margin-bottom: 10px;
  min-width: 0;
}
#visualsFloatingMenu .visuals-drawer-detail-title {
  flex: 0 0 auto;
  margin: 0;
  font-size: 13px;
  white-space: nowrap;
}
#visualsFloatingMenu .visuals-drawer-detail-copy {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 11px;
  line-height: 1.5;
  opacity: .7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#visualsFloatingMenu .visuals-drawer-detail-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
  padding: 0 2px 0 0;
}
#visualsFloatingMenu .visuals-drawer-pane:not([hidden]) {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
  min-height: 100%;
  min-width: 0;
}
#visualsFloatingMenu .visuals-drawer-pane > .visuals-option-section:not(.hidden) {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
  min-height: 0;
  min-width: 0;
}
#visualsFloatingMenu .visuals-drawer-pane[hidden] { display: none !important; }
#visualsFloatingMenu .visuals-drawer-pane .preference-highlight,
#visualsFloatingMenu .visuals-drawer-pane .visuals-widgets-section > .tools-floating-menu-header {
  display: none;
}
#visualsFloatingMenu .visuals-drawer-availability {
  font-size: 11px;
  line-height: 1.5;
  opacity: .7;
  padding: 10px 0;
}
#visualsFloatingMenu .visuals-drawer-pane .visuals-option-section {
  padding: 0;
}
#visualsFloatingMenu .visuals-drawer-pane .ambience-player-presets,
#visualsFloatingMenu .visuals-drawer-pane .visuals-widgets-section > .tools-floating-grid {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 0;
  flex: 1 1 auto;
}
/* Every inner picker uses one row. Cards divide the available width instead
   of wrapping; CSS never changes the options or their saved state. */
#visualsFloatingMenu .visuals-drawer-pane :is(
  #widgetWrapOptions, #visualsVibePicker,
  #visualsFontPicker, #visualsPixelPetPicker
) {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  min-width: 0;
  flex: 1 1 auto;
  overflow-x: hidden;
}
/* Styling only: preserve original option buttons, their contents and handlers.
   In particular, fonts keep their own preview-family variable and lazy loader. */
#visualsFloatingMenu .visuals-drawer-pane :is(
  #widgetWrapOptions, #visualsVibePicker,
  #visualsFontPicker, #visualsPixelPetPicker,
  #visualsNostalgiaOptions .ambience-player-presets
) > button {
  box-sizing: border-box;
  width: 0;
  min-width: 0;
  min-height: 68px;
  height: auto;
  flex: 1 1 0%;
  margin: 0;
  padding: 9px 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
  background-color: rgba(241, 255, 250, .03);
  border: 1px solid rgba(241, 255, 250, .18);
  border-radius: var(--radius-md);
  box-shadow: none;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}
#visualsFloatingMenu .visuals-drawer-pane :is(
  #widgetWrapOptions, #visualsVibePicker,
  #visualsFontPicker, #visualsPixelPetPicker,
  #visualsNostalgiaOptions .ambience-player-presets
) > button:hover:not(:disabled) {
  border-color: rgba(241, 255, 250, .34);
  background-color: rgba(241, 255, 250, .1);
}
#visualsFloatingMenu .visuals-drawer-pane :is(
  #widgetWrapOptions, #visualsVibePicker,
  #visualsFontPicker, #visualsPixelPetPicker,
  #visualsNostalgiaOptions .ambience-player-presets
) > button.active {
  border-color: rgba(241, 255, 250, .42);
  background-color: rgba(241, 255, 250, .17);
}
#visualsFloatingMenu .visuals-drawer-pane :is(
  #widgetWrapOptions, #visualsVibePicker,
  #visualsFontPicker, #visualsPixelPetPicker,
  #visualsNostalgiaOptions .ambience-player-presets
) > button[hidden],
#visualsFloatingMenu .visuals-drawer-pane :is(
  #widgetWrapOptions, #visualsVibePicker,
  #visualsFontPicker, #visualsPixelPetPicker,
  #visualsNostalgiaOptions .ambience-player-presets
) > button.hidden {
  display: none !important;
}
/* Keep existing edge-to-edge artwork and the selected frosted stroke. */
#visualsFloatingMenu .visuals-drawer-pane #widgetWrapOptions > button.widget-wrap-preview-loaded {
  border-color: transparent;
  box-shadow: inset 0 0 0 1px rgba(241, 255, 250, .18);
}
#visualsFloatingMenu .visuals-drawer-pane #widgetWrapOptions > button.widget-wrap-preview-loaded.active {
  border-color: transparent;
  box-shadow: inset 0 0 0 1px rgba(241, 255, 250, .42);
}
#visualsFloatingMenu .visuals-drawer-pane #widgetWrapOptions > button {
  min-height: 68px;
}
#visualsFloatingMenu .visuals-drawer-pane #visualsPixelPetPicker {
  align-items: stretch;
}
#visualsFloatingMenu .visuals-drawer-pane #visualsPixelPetPicker > button.pixel-pet-preview-option {
  min-height: 68px;
  flex: 1 1 0%;
  width: 0;
  opacity: .75;
}
#visualsFloatingMenu .visuals-drawer-pane #visualsPixelPetPicker .pixel-pet-portrait {
  max-width: 100%;
  max-height: 46px;
}
#visualsFloatingMenu .visuals-drawer-pane #visualsPixelPetPicker > button.pixel-pet-preview-option:is(.active, :hover) {
  opacity: 1;
}
#visualsFloatingMenu .visuals-drawer-pane #visualsPixelPetPicker > button.pixel-pet-preview-option:disabled {
  opacity: .35;
  cursor: not-allowed;
}
#visualsFloatingMenu .visuals-drawer-pane .visuals-nostalgia-options > .ambience-player-presets > button {
  min-height: 58px;
}
#visualsFloatingMenu .visuals-drawer-pane .visuals-nostalgia-caption { padding-top: 8px; }
#visualsFloatingMenu .visuals-drawer-pane .visuals-widgets-section > .tools-floating-grid {
  display: flex;
  flex-flow: row nowrap;
}
#visualsFloatingMenu .visuals-drawer-pane .widget-tile {
  min-height: 68px;
  flex: 1 1 0%;
  width: 0;
  align-items: center;
  padding: 7px;
}
#visualsFloatingMenu .visuals-drawer-pane .widget-tile-copy,
#visualsFloatingMenu .visuals-drawer-pane .widget-tile-title-row {
  min-width: 0;
}
#visualsFloatingMenu .visuals-drawer-pane .widget-tile-title-row h4 {
  overflow-wrap: anywhere;
}
@media (max-width: 740px) {
  #visualsFloatingMenu .visuals-drawer-category { padding: 8px; }
  #visualsFloatingMenu .visuals-drawer-category-arrow { display: none; }
  #visualsFloatingMenu .visuals-drawer-category-icon {
    width: 22px;
    height: 22px;
    flex-basis: 22px;
  }
  #visualsFloatingMenu .visuals-drawer-category-name { font-size: 10px; }
}
@media (max-width: 500px) {
  #visualsFloatingMenu .visuals-drawer-home { padding: 8px; }
  #visualsFloatingMenu .visuals-drawer-detail { padding: 10px; }
  #visualsFloatingMenu .visuals-drawer-category { padding: 5px; gap: 5px; }
  #visualsFloatingMenu .visuals-drawer-category-icon {
    width: 17px;
    height: 17px;
    flex-basis: 17px;
  }
  #visualsFloatingMenu .visuals-drawer-category-name { font-size: 9px; }
  #visualsFloatingMenu .visuals-drawer-category-grid { gap: 5px; }
  #visualsFloatingMenu .visuals-drawer-pane :is(#widgetWrapOptions, #visualsVibePicker, #visualsFontPicker) > button {
    padding-inline: 3px;
    font-size: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  body.calphii-tray-active #visualsFloatingMenu,
  #visualsFloatingMenu .visuals-drawer-page { transition: none; }
}

/* VISUALS UNDER-DESK DRAWER
   Lift one foreground surface; scene imagery, video and atmospheric effects
   remain fixed in their original page container behind the workspace. */
body.calphii-tray-active {
  --visuals-drawer-lift-height: min(150px, calc(100dvh - 115px));
  --visuals-drawer-motion: 620ms cubic-bezier(.22, .78, .22, 1);
  background-color: var(--color-bg-dark);
}
body.calphii-tray-active .calphii-workspace-foreground {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  transition: transform var(--visuals-drawer-motion);
}
body.calphii-tray-active.calphii-tray-open .calphii-workspace-foreground {
  transform: translate3d(0, calc(-1 * var(--visuals-drawer-lift-height)), 0);
  box-shadow: 0 12px 25px rgba(0, 0, 0, .24);
}
body.calphii-tray-active #visualsFloatingMenu {
  position: fixed;
  z-index: 1;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  top: auto !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: var(--visuals-drawer-lift-height) !important;
  max-height: var(--visuals-drawer-lift-height) !important;
  /* At rest, the drawer is entirely below the viewport. */
  transform: translate3d(0, 100%, 0) !important;
  transition: transform var(--visuals-drawer-motion);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border-bottom: 0;
  box-sizing: border-box;
}
body.calphii-tray-active.calphii-tray-open #visualsFloatingMenu {
  transform: translate3d(0, 0, 0) !important;
}
body.calphii-tray-active #visualsFloatingMenu.calphii-tray-retreating {
  pointer-events: none;
}
@media (max-width: 500px) {
  body.calphii-tray-active {
    --visuals-drawer-lift-height: min(150px, calc(100dvh - 110px));
  }
}
@media (prefers-reduced-motion: reduce) {
  body.calphii-tray-active {
    --visuals-drawer-motion: 0ms linear;
  }
}

/* Carry Calphii's sampled frosted surface into the space below the lifted
   workspace. One cached scene texture provides depth for the real glass blur. */
body.calphii-tray-active .visuals-drawer-frost-underlay {
  position: fixed;
  z-index: 0;
  inset: auto 0 0;
  height: var(--visuals-drawer-lift-height);
  display: none;
  pointer-events: none;
  background-color: var(--color-bg-dark);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  filter: blur(14px) saturate(.9);
}
body.calphii-tray-active .visuals-drawer-frost-underlay.is-visible {
  display: block;
}
body.calphii-tray-active #visualsFloatingMenu {
  /* The inline background tint still comes from updateMenuTint(). */
  background-color: var(--surface-glass-90);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Focus Together's avatars already share a single overlay. Move its surface
   with the workspace instead of updating each portrait's stored coordinates. */
body.calphii-tray-active.focus-together-floating .focus-together-floating-avatars {
  transform: translate3d(0, 0, 0);
  transition: transform var(--visuals-drawer-motion);
}
body.calphii-tray-active.calphii-tray-open.focus-together-floating .focus-together-floating-avatars {
  transform: translate3d(0, calc(-1 * var(--visuals-drawer-lift-height)), 0);
}
