/* ============================================================
 * 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: 48px;
  --btn-icon: 30px;
  --btn-gap: 6px;
  --btn-radius: 14px;
  --btn-bar-radius: 20px;
  --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.7);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--btn-bar-radius);
  box-shadow:
    0 8px 32px rgba(0,0,0,0.4),
    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;
  left: 0px !important;
  top: 0px !important;
  position: relative !important;
}

#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 */
@media (max-width: 380px) {
  #hex-menu.collapsed .hex-cluster { width: 44px !important; height: 44px !important; }
}
@media (min-width: 381px) and (max-width: 599px) {
  #hex-menu.collapsed .hex-cluster { width: 48px !important; height: 48px !important; }
}
@media (min-width: 600px) {
  #hex-menu.collapsed .hex-cluster { width: 52px !important; height: 52px !important; }
}

/* ── 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.1);
  transform: scale(1.08);
}

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

/* ── 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;
}

/* Legacy div.hex-icon fallback (if any remain) */
.hex-btn .hex-icon {
  width: var(--btn-icon);
  height: var(--btn-icon);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  filter: brightness(0) invert(1);
  opacity: 0.85;
  pointer-events: none;
  transition: opacity 0.2s, filter 0.3s;
}

.hex-btn:hover .hex-icon { opacity: 1; }

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

.hex-toggle .hex-svg {
  color: rgba(0,255,255,0.8);
  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.1);
  box-shadow: 0 0 14px rgba(0,255,255,0.18);
}

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

.hex-btn.is-on .hex-icon {
  filter: brightness(0) invert(1)
          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.15);
  box-shadow: 0 0 14px rgba(255,69,58,0.22);
}

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

.hex-btn.is-off .hex-icon {
  opacity: 0.9;
  filter: brightness(0) invert(1) sepia(1) saturate(4) hue-rotate(330deg)
          drop-shadow(0 0 2px rgba(255,69,58,0.5));
}

/* ── End Call — Red ───────────────────────────────────────── */
.hex-end-call {
  background: rgba(255,69,58,0.15);
}
.hex-end-call .hex-svg {
  color: #ff453a;
}
.hex-end-call:hover {
  background: rgba(255,69,58,0.25);
  box-shadow: 0 0 16px rgba(255,69,58,0.25);
}
.hex-end-call:hover .hex-svg {
  color: #ff6b60;
  filter: drop-shadow(0 0 4px rgba(255,69,58,0.4));
}

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

/* 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: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  pointer-events: none;
  z-index: 3;
}

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

.hex-btn:hover .hex-chevron::after {
  border-color: cyan;
}

/* ── Honeycomb Positioning (JS sets left/top) ─────────────── */
.hex-cluster .hex-btn {
  position: relative;
  left: auto !important;
  top: auto !important;
}

/* ── Device Dropdown ──────────────────────────────────────── */
.hex-device-dropdown {
  position: fixed;
  z-index: calc(var(--hex-menu-z) + 10);
  background: rgba(15,18,22,0.92);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 6px 0;
  min-width: 220px;
  max-width: 300px;
  max-height: 50vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  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: 10px;
  color: rgba(0,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 14px 4px;
  font-weight: 600;
}

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

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

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

.hex-device-dropdown .dd-option.active::before {
  content: '\2713';
  font-size: 13px;
  color: #00e5ff;
}

.hex-device-dropdown .dd-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 3px 10px;
}

/* ── Responsive ───────────────────────────────────────────── */

/* Extra-small (iPhone SE, 375px) */
@media (max-width: 380px) {
  :root {
    --btn-size: 44px;
    --btn-icon: 28px;
    --btn-gap: 4px;
    --btn-radius: 12px;
    --btn-bar-radius: 16px;
  }
  .hex-toggle .hex-icon { width: 28px; height: 28px; }
}

/* Standard phones (381-599px) */
@media (min-width: 381px) and (max-width: 599px) {
  :root {
    --btn-size: 48px;
    --btn-icon: 30px;
    --btn-gap: 5px;
  }
  .hex-toggle .hex-icon { width: 30px; height: 30px; }
}

/* Tablet+ (600px+) */
@media (min-width: 600px) {
  :root {
    --btn-size: 52px;
    --btn-icon: 32px;
    --btn-gap: 6px;
  }
  .hex-toggle .hex-icon { width: 32px; height: 32px; }
}

/* Large desktop */
@media (min-width: 1200px) {
  :root {
    --btn-size: 56px;
    --btn-icon: 34px;
  }
  .hex-toggle .hex-icon { width: 34px; height: 34px; }
}

/* 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;
    border-radius: var(--btn-bar-radius);
  }
  .hex-label {
    right: auto;
    top: auto;
    bottom: calc(100% + 8px);
    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)); }
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .hex-btn { transition-duration: 0.05s !important; }
}

/* Fallback */
@supports not (backdrop-filter: blur(1px)) {
  .hex-btn { background: rgba(25,28,35,0.85); }
  .hex-cluster { background: rgba(10,12,16,0.9); }
  .hex-device-dropdown { background: rgba(15,18,22,0.95); }
}
