/* ============================================================
 * style_hex_buttons.css — Y Liquid Glass Floating Control Bar
 * ============================================================
 * Clean pill-shaped buttons with:
 *   - Frosted glass bar background
 *   - Clear SVG icons at readable sizes
 *   - Text labels always visible
 *   - RED glow for muted/off states
 *   - Cyan glow for active/on states
 *   - Collapse to single toggle button
 *   - Drag to reposition
 *   - Responsive across all devices
 * ============================================================ */

:root {
  --btn-size: 37px;
  --btn-icon: 24px;
  --btn-gap: 5px;
  --btn-radius: 11px;
  --btn-bar-radius: 16px;
  --hex-menu-z: 950;
  --hex-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Floating Menu Container ──────────────────────────────── */
#hex-menu {
  position: fixed;
  z-index: var(--hex-menu-z);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  top: 50%;
  right: 12px;
  left: auto;
  transform: translateY(-50%);
  transition: none;
}

#hex-menu.is-dragging { cursor: grabbing; }

/* ── Button Bar (cluster) ─────────────────────────────────── */
.hex-cluster {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--btn-gap);
  padding: 8px;
  background: rgba(10, 12, 16, 0.85);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--btn-bar-radius);
  box-shadow:
    0 8px 32px rgba(0,0,0,0.5),
    inset 0 1px 0 rgba(255,255,255,0.06);
  position: relative;
  width: auto;
  height: auto;
}

/* ── Collapsed State ──────────────────────────────────────── */
#hex-menu.collapsed .hex-cluster {
  padding: 0;
  background: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: none;
  box-shadow: none;
  pointer-events: none;
  width: auto !important;
  height: auto !important;
  overflow: visible;
}

#hex-menu.collapsed .hex-toggle {
  pointer-events: auto;
  position: relative;
}

#hex-menu.collapsed .hex-btn:not(.hex-toggle) {
  width: 0;
  height: 0;
  padding: 0;
  margin: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

#hex-menu.collapsed .hex-label { display: none; }

/* Collapsed cluster sizing per breakpoint - reduced */
@media (max-width: 599px) {
  #hex-menu.collapsed .hex-cluster { width: 28px; height: 28px; }
}
@media (min-width: 600px) {
  #hex-menu.collapsed .hex-cluster { width: 43px; height: 43px; }
}

/* ── Expanded State ───────────────────────────────────────── */
#hex-menu.expanded .hex-cluster { pointer-events: auto; }
#hex-menu.expanded .hex-btn {
  opacity: 1;
  pointer-events: auto;
}

/* ── Individual Button — Pill Shape ───────────────────────── */
.hex-btn {
  position: relative;
  width: var(--btn-size);
  height: var(--btn-size);
  border-radius: var(--btn-radius);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  padding: 0;
  transition:
    background var(--hex-transition),
    box-shadow var(--hex-transition),
    transform var(--hex-transition),
    opacity var(--hex-transition);
  flex-shrink: 0;
}

/* No pseudo-elements */
.hex-btn::before,
.hex-btn::after { display: none; }

.hex-btn:hover {
  background: rgba(255,255,255,0.15);
  transform: scale(1.1);
}

.hex-btn:active {
  transform: scale(0.95);
  background: rgba(255,255,255,0.08);
}

/* ── Icon (inline SVG) ─────────────────────────────────────── */
.hex-btn .hex-svg {
  width: var(--btn-icon);
  height: var(--btn-icon);
  color: rgba(255,255,255,0.88);
  pointer-events: none;
  transition: color 0.2s, filter 0.2s, transform 0.2s;
  flex-shrink: 0;
}

.hex-btn:hover .hex-svg {
  color: #fff;
}

/* ── Toggle Button ────────────────────────────────────────── */
.hex-toggle {
  background: rgba(0,255,255,0.12);
}

.hex-toggle .hex-svg {
  color: rgba(0,255,255,0.9);
  transition: transform 0.3s ease, color 0.2s;
}

.hex-toggle:hover .hex-svg {
  color: cyan;
}

#hex-menu.expanded .hex-toggle .hex-svg {
  transform: rotate(45deg);
}

/* ── ON State — Cyan Glow ─────────────────────────────────── */
.hex-btn.is-on {
  background: rgba(0,255,255,0.15);
  box-shadow: 0 0 10px rgba(0,255,255,0.2);
}

.hex-btn.is-on .hex-svg {
  color: #00e5ff;
  filter: drop-shadow(0 0 3px rgba(0,255,255,0.5));
}

/* ── OFF/Muted State — RED Warning ────────────────────────── */
.hex-btn.is-off {
  background: rgba(255,60,50,0.2);
  box-shadow: 0 0 10px rgba(255,69,58,0.25);
}

.hex-btn.is-off .hex-svg {
  color: #ff453a;
  filter: drop-shadow(0 0 3px rgba(255,69,58,0.5));
}

/* ── End Call — Red ───────────────────────────────────────── */
.hex-end-call {
  background: rgba(255,69,58,0.2);
}
.hex-end-call .hex-svg {
  color: #ff453a;
}
.hex-end-call:hover {
  background: rgba(255,69,58,0.3);
  box-shadow: 0 0 12px rgba(255,69,58,0.3);
}

/* ── Labels — Tooltip floating left of the button ────────── */
.hex-label {
  position: absolute;
  right: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  font-size: 8px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
  letter-spacing: 0.5px;
  pointer-events: none;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.2s ease;
  background: rgba(10,12,16,0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.05);
}

/* Desktop: show on hover */
.hex-btn:hover .hex-label {
  opacity: 1;
}

/* Mobile: shown via JS class on double-tap */
.hex-label.is-visible {
  opacity: 1;
}

/* ── Device Source Chevron ─────────────────────────────────── */
.hex-chevron {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 5px;
  height: 6px;
  pointer-events: none;
  z-index: 3;
}

.hex-chevron::after {
  content: '';
  display: block;
  width: 3px;
  height: 3px;
  border-right: 1px solid rgba(255,255,255,0.6);
  border-bottom: 1px solid rgba(255,255,255,0.6);
  transform: rotate(45deg);
}

/* ── Device Dropdown ──────────────────────────────────────── */
.hex-device-dropdown {
  position: fixed;
  z-index: calc(var(--hex-menu-z) + 10);
  background: rgba(15,18,22,0.95);
  backdrop-filter: blur(32px) saturate(1.4);
  -webkit-backdrop-filter: blur(32px) saturate(1.4);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 4px 0;
  min-width: 180px;
  max-width: 260px;
  max-height: 50vh;
  overflow-y: auto;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  display: none;
  animation: dd-in 0.2s ease;
}

@keyframes dd-in {
  from { opacity: 0; transform: translateY(6px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.hex-device-dropdown .dd-title {
  font-size: 8px;
  color: rgba(0,255,255,0.6);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 6px 12px 2px;
  font-weight: 700;
}

.hex-device-dropdown .dd-option {
  padding: 10px 12px;
  color: rgba(255,255,255,0.9);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
  margin: 0 4px;
  border-radius: 6px;
}

.hex-device-dropdown .dd-option:hover {
  background: rgba(255,255,255,0.08);
}

.hex-device-dropdown .dd-option.active {
  color: #00e5ff;
}

/* ── Responsive — reduced scaling ─────────────────────────── */

/* Phones (+33%) */
@media (max-width: 599px) {
  :root {
    --btn-size: 28px;
    --btn-icon: 19px;
    --btn-gap: 4px;
  }
}

/* Tablet/Desktop (+33%) */
@media (min-width: 600px) {
  :root {
    --btn-size: 43px;
    --btn-icon: 27px;
    --btn-gap: 7px;
  }
}

/* Landscape phones — move to bottom-right */
@media (max-width: 900px) and (orientation: landscape) {
  #hex-menu {
    top: auto;
    bottom: 12px;
    right: 12px;
    transform: none;
  }
  .hex-cluster {
    flex-direction: row;
  }
  .hex-label {
    right: auto;
    top: auto;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
  }
}

/* Safe areas */
@supports (padding-right: env(safe-area-inset-right)) {
  #hex-menu { right: calc(12px + env(safe-area-inset-right)); }
}
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (orientation: landscape) {
    #hex-menu { bottom: calc(12px + env(safe-area-inset-bottom)); }
  }
}
