/* @ML-MARK v0.9.1-stage6 circles-css FIXED
 * Runa Chat — Circles (video & voice circle messages)
 *
 * FIXES v2:
 * - Removed dangerous max-width:none
 * - Video circle properly contained within bubble
 * - No overflow issues
 */

/* ============== Recording overlay (fullscreen) ====================== */
.ml-circle-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.ml-circle-overlay.is-active { display: flex; }

/* ============== Preview circle during recording ====================== */
.ml-circle-preview {
  position: relative;
  width: min(72vw, 320px);
  height: min(72vw, 320px);
  border-radius: 50%;
  overflow: hidden;
  background: #111;
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.08),
    0 16px 48px rgba(0, 0, 0, 0.6);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.ml-circle-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}
.ml-circle-preview[data-facing="environment"] video {
  transform: none;
}

/* Cancel state */
.ml-circle-preview.is-cancelling {
  transform: scale(0.85);
  box-shadow:
    0 0 0 4px rgba(255, 60, 60, 0.4),
    0 16px 48px rgba(0, 0, 0, 0.6);
}

/* Pulsing red REC dot */
.ml-circle-preview::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ff3b30;
  box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.6);
  animation: ml-rec-pulse 1.4s ease-out infinite;
  z-index: 2;
}
@keyframes ml-rec-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.6); }
  70%  { box-shadow: 0 0 0 14px rgba(255, 59, 48, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}

/* Timer */
.ml-circle-timer {
  margin-top: 18px;
  font-variant-numeric: tabular-nums;
  font-size: 18px;
  color: #fff;
  letter-spacing: 0.5px;
}

/* Hint text */
.ml-circle-hint {
  margin-top: 6px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  max-width: 80vw;
  line-height: 1.35;
}

/* Camera switch button */
.ml-circle-switch {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  border: none;
  cursor: pointer;
  z-index: 3;
}

/* Video messages */
.msg .msg-bubble--circle {
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.ml-msg-circle {
  position: relative;
  width: min(62vw, 238px);
  max-width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #14181d;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .16);
}

.ml-msg-circle video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.ml-msg-circle button {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
}

.ml-msg-circle button:focus-visible { outline: 2px solid #fff; outline-offset: -3px; }

.ml-msg-circle__play {
  inset: 0;
  background: rgba(0, 0, 0, .14);
  font-size: 28px;
}

.ml-msg-circle__play svg {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 1px 3px #000);
}

.ml-msg-circle.is-playing .ml-msg-circle__play { background: transparent; }
.ml-msg-circle.is-playing .ml-msg-circle__play > * { opacity: 0; }

.ml-msg-circle__progress {
  --circle-progress: 0turn;
  position: absolute;
  inset: 6%;
  display: none;
  border-radius: 50%;
  pointer-events: none;
}

.ml-msg-circle.has-progress .ml-msg-circle__progress { display: block; }

.ml-msg-circle__progress::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: conic-gradient(#fff var(--circle-progress), rgba(255, 255, 255, .36) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3px));
}

.ml-msg-circle__progress::after {
  content: "";
  position: absolute;
  inset: -6px;
  transform: rotate(var(--circle-progress));
  background: radial-gradient(circle at 50% 8px, #fff 0 5px, transparent 6px);
}

.ml-msg-circle__mute {
  width: 32px;
  height: 32px;
  background: rgba(0, 0, 0, .58);
}

.ml-msg-circle__mute { top: 5px; left: 50%; transform: translateX(-50%); }
.ml-msg-circle__mute svg { width: 19px; height: 19px; }
.ml-msg-circle__mute span { display: grid; place-items: center; }
.ml-msg-circle__mute[aria-pressed="false"] .ml-msg-circle__sound-off,
.ml-msg-circle__mute[aria-pressed="true"] .ml-msg-circle__sound-on { display: none; }

.ml-msg-circle__time {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, .58);
  color: #fff;
  font-size: 12px;
  line-height: 16px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.msg .msg-bubble--circle .msg-reactions {
  position: static;
  margin: 4px 0 0;
  flex-wrap: wrap;
}

/* ============== Toggle mic ↔ camera in composer ====================== */
.ml-composer-rec-toggle {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--ml-icon, #6b7280);
  font-size: 20px;
  cursor: pointer;
  transition: color 0.15s, transform 0.15s;
}
.ml-composer-rec-toggle:active { transform: scale(0.92); }
.ml-composer-rec-toggle[data-mode="video"] { color: var(--ml-accent, #2563eb); }

/* Mode indicator dot */
.ml-composer-rec-toggle::after {
  content: '';
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ml-icon, #6b7280);
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
}
.ml-composer-rec-toggle[data-rec-mode="video"]::after {
  opacity: 1;
  background: var(--accent-cyan, #00d4ff);
}

@media (prefers-reduced-motion: reduce) {
  .ml-circle-preview::before { animation: none; }
  .ml-circle-preview { transition: none; }
}

/* Shared speed control for voice messages and voice circles */
.msg button.msg-voice-speed {
  flex: none;
  min-width: 36px;
  min-height: 24px;
  padding: 2px 5px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, currentColor 6%, transparent);
  color: var(--text-secondary, var(--text, #263c50));
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.msg button.msg-voice-speed:hover,
.msg button.msg-voice-speed:focus-visible {
  background: color-mix(in srgb, currentColor 13%, transparent);
}
