/* Aviveil Circular Walkie-Talkie Floating Controller (Part A)
 * 68px Circular Floating Button, Pastel Status Rings, Companion Pill,
 * 7s Hint Bubble, 3s Undo Toast, and Safe Area Insets.
 */

#radio {
  position: fixed;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
  transition: bottom 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#radio.hi {
  bottom: calc(150px + env(safe-area-inset-bottom, 0px));
}

.radio-floating-dock {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

/* 68px Circular Walkie-Talkie Button */
.radio-round-btn {
  width: 68px;
  height: 68px;
  min-width: 68px;
  min-height: 68px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  background: var(--p);
  color: var(--tx);
  border: 2.5px solid var(--ln);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  -webkit-touch-callout: none;
  outline: none;
  transition: transform 0.12s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
}

.radio-round-btn:active {
  transform: scale(0.94);
}

.radio-round-btn:focus-visible {
  outline: 2px solid var(--v);
  outline-offset: 3px;
}

/* 3-letter channel code */
.radio-btn-code {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  text-transform: uppercase;
  pointer-events: none;
  line-height: 1;
}

.radio-btn-code.is-off-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--mu);
  text-transform: none;
}

.radio-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: var(--mu, #9ca3af);
  transition: color 0.15s ease, transform 0.15s ease;
}

.radio-round-btn:hover .radio-btn-icon {
  color: #ebecee;
  transform: scale(1.06);
}

/* Status Rings (Pastel) */
.radio-round-btn.st-off {
  border-color: var(--ln);
  background: var(--p);
  color: var(--mu);
}

.radio-round-btn.st-idle {
  border-color: var(--g);
  background: var(--p);
  color: var(--tx);
}

.radio-round-btn.st-req {
  border-color: var(--y);
  background: var(--p);
  color: var(--y);
}

/* TX: Pink fill with slow pulse (I am talking) */
.radio-round-btn.st-tx {
  background: var(--r);
  border-color: var(--r);
  color: #2a1a1f;
  animation: radio-pulse-pink 2s ease-in-out infinite;
}

@keyframes radio-pulse-pink {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 143, 163, 0.55);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(255, 143, 163, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 143, 163, 0);
  }
}

/* RX: Green pulsing halo (someone else talking) */
.radio-round-btn.st-rx {
  border-color: var(--g);
  background: var(--p);
  animation: radio-halo-green 1.5s ease-out infinite;
}

@keyframes radio-halo-green {
  0% {
    box-shadow: 0 0 0 0 rgba(133, 224, 163, 0.7);
  }
  70% {
    box-shadow: 0 0 0 14px rgba(133, 224, 163, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(133, 224, 163, 0);
  }
}

/* Muted state: diagonal pink slash across button & dimmed text */
.radio-round-btn.is-muted .radio-btn-code {
  opacity: 0.5;
}

.radio-round-btn.is-muted::after {
  content: '';
  position: absolute;
  width: 48px;
  height: 2.5px;
  background: var(--r);
  transform: rotate(-45deg);
  border-radius: 2px;
  pointer-events: none;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
}

/* Companion Pill (floats to the left of button) */
.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--p);
  border: 1px solid var(--ln);
  border-radius: 9999px;
  padding: 8px 14px;
  font-size: 12px;
  color: var(--tx);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  max-width: 260px;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.radio-pill:hover {
  background: var(--p2);
}

.radio-pill-dot {
  width: 7px;
  height: 7px;
  min-width: 7px;
  border-radius: 50%;
  background: var(--g);
}

.radio-pill-dot.st-tx {
  background: var(--r);
}

.radio-pill-dot.st-req {
  background: var(--y);
}

.radio-pill-dot.st-off {
  background: var(--mu);
}

.radio-pill-dot.is-muted {
  background: var(--r);
}

.radio-pill-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* 7-Second Hint Bubble */
.radio-hint-bubble {
  pointer-events: auto;
  position: absolute;
  bottom: 82px;
  right: 0;
  width: 280px;
  max-width: calc(100vw - 32px);
  background: var(--p);
  border: 1px solid var(--ln);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 12px;
  line-height: 1.45;
  color: var(--tx);
  cursor: pointer;
  animation: radio-fade-in 0.2s ease-out;
  margin-bottom: 6px;
}

.radio-hint-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 28px;
  width: 10px;
  height: 10px;
  background: var(--p);
  border-right: 1px solid var(--ln);
  border-bottom: 1px solid var(--ln);
  transform: rotate(45deg);
}

.radio-hint-text {
  color: var(--tx);
  opacity: 0.95;
}

@keyframes radio-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 3-Second Accidental Swipe-Down Undo Toast */
.radio-undo-toast {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--p);
  border: 1px solid var(--ln);
  border-radius: 9999px;
  padding: 7px 14px;
  font-size: 12px;
  color: var(--tx);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
  animation: radio-fade-in 0.15s ease-out;
}

.radio-undo-btn {
  background: var(--v);
  color: #fff;
  border: none;
  border-radius: 9999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.radio-undo-btn:hover {
  opacity: 0.9;
}

/* Accessible Popup Menu for Keyboard / Screen Reader */
.radio-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 94px 16px 94px 16px;
  pointer-events: auto;
}

.radio-menu-card {
  background: var(--p);
  border: 1px solid var(--ln);
  border-radius: 14px;
  width: 290px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
  padding: 14px;
  animation: radio-fade-in 0.18s ease-out;
}

.radio-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.radio-menu-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--f);
}

.radio-menu-close {
  background: transparent;
  border: none;
  color: var(--mu);
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
}

.radio-menu-label {
  font-size: 11px;
  color: var(--mu);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  display: block;
}

.radio-channel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.radio-channel-chip {
  background: var(--p2);
  border: 1px solid var(--ln);
  color: var(--tx);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}

.radio-channel-chip.selected {
  background: var(--v);
  border-color: var(--v);
  color: #fff;
}

.radio-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--ln);
  padding-top: 12px;
}

.radio-action-btn {
  background: var(--p2);
  border: 1px solid var(--ln);
  color: var(--tx);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.radio-action-btn:hover {
  background: var(--p);
}

.radio-action-btn.danger {
  color: var(--r);
}

@media (max-width: 480px) {
  #radio {
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .radio-pill {
    max-width: 170px;
    padding: 6px 10px;
    font-size: 11px;
  }
  .radio-hint-bubble {
    width: 250px;
    font-size: 11px;
  }
}

/* On touch devices with bottom navigation bar, lift radio button to 70px + safe-area (Check-in keeps 150px) */
@media (hover: none) and (pointer: coarse) and (max-width: 1024px) {
  #radio {
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }
  #radio.hi {
    bottom: calc(150px + env(safe-area-inset-bottom, 0px));
  }
}
