/* ================================================================
   MODULAR WIDGET STYLES (New UX with conditional features)
   ================================================================ */

/* Widget wraps content - position controls at top-left */
.supernal-tts-widget {
  position: relative;
  display: block;
}

/* Modular Widget Container - position at top-left */
.supernal-tts-modular-widget {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
}

/* Controls Row - horizontal layout for play button, voice, speed */
.supernal-tts-controls-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  background: transparent; /* Transparent background */
  position: relative; /* Enable z-index positioning */
  z-index: 10; /* Place above progress bar */
}

/* Add padding to widget content to make room for controls */
.supernal-tts-widget-modular {
  padding-top: 45px; /* Base space for controls - reduced from 60px for tighter spacing */
}

/* Progress bar is now absolutely positioned, no extra padding needed */

/* Hide additional controls by default, show on hover */
.supernal-tts-voice-control,
.supernal-tts-speed-control {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.supernal-tts-widget:not(.supernal-tts-widget-modular):hover .supernal-tts-voice-control,
.supernal-tts-widget:not(.supernal-tts-widget-modular):hover .supernal-tts-speed-control,
.supernal-tts-widget:not(.supernal-tts-widget-modular):focus-within .supernal-tts-voice-control,
.supernal-tts-widget:not(.supernal-tts-widget-modular):focus-within .supernal-tts-speed-control {
  opacity: 1;
  visibility: visible;
}

/* Mobile/Touch: Always show controls (no hover) - only for non-modular widgets */
@media (hover: none) and (pointer: coarse) {
  .supernal-tts-widget:not(.supernal-tts-widget-modular) .supernal-tts-voice-control,
  .supernal-tts-widget:not(.supernal-tts-widget-modular) .supernal-tts-speed-control {
    opacity: 1;
    visibility: visible;
  }
}

/* Voice Control - Person Icon */
.supernal-tts-voice-control {
  position: relative;
  display: inline-flex;
  align-items: center; /* Ensure vertical alignment */
}

.supernal-tts-voice-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: rgba(255, 255, 255, 0.75); /* Liquid glass background */
  backdrop-filter: blur(10px) saturate(180%);
  -webkit-backdrop-filter: blur(10px) saturate(180%);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%; /* Circular shape */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12),
              0 1px 3px rgba(0, 0, 0, 0.08),
              inset 0 1px 1px rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 350ms cubic-bezier(0.4, 0.0, 0.2, 1);
  flex-shrink: 0;
  color: #000000; /* Black icon color */
  font-size: 16px;
}

.supernal-tts-voice-toggle:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0, 0, 0, 0.15);
  transform: scale(1.08) translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16),
              0 2px 6px rgba(0, 0, 0, 0.12),
              inset 0 1px 1px rgba(255, 255, 255, 0.6);
}

.supernal-tts-voice-toggle:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16),
              0 2px 6px rgba(0, 0, 0, 0.12),
              inset 0 1px 1px rgba(255, 255, 255, 0.6);
}

.supernal-tts-voice-icon {
  transition: transform 0.2s ease;
}

.supernal-tts-voice-toggle[aria-expanded="true"] .supernal-tts-voice-icon {
  transform: scale(1.1);
}

/* Voice Dropdown Menu - Liquid Glass Style (matches circle buttons) */
.supernal-tts-voice-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 160px;

  /* Liquid glass effect - EXACT match to circle buttons */
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px) saturate(180%);
  -webkit-backdrop-filter: blur(10px) saturate(180%);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;

  /* Shadow matching circle buttons */
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.12),
    0 1px 3px rgba(0, 0, 0, 0.08),
    inset 0 1px 1px rgba(255, 255, 255, 0.5);

  z-index: 1000;
  overflow: hidden;
  transition: opacity 0.2s ease, transform 0.2s ease;
  transform-origin: top center;
  padding: 6px;
}

.supernal-tts-voice-dropdown.hidden {
  display: none;
}

.supernal-tts-voice-option {
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  border-radius: 8px;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #1f2937;
  margin: 2px 0;
}

.supernal-tts-voice-option:hover {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.supernal-tts-voice-option.active {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  color: #3b82f6;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

.supernal-tts-voice-option:focus {
  outline: none;
  background: rgba(0, 0, 0, 0.05);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Speed Control - Hover Dropdown */
.supernal-tts-speed-control {
  position: relative;
  display: inline-flex;
  align-items: center; /* Ensure vertical alignment */
}

.supernal-tts-speed-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: rgba(255, 255, 255, 0.75); /* Liquid glass background */
  backdrop-filter: blur(10px) saturate(180%);
  -webkit-backdrop-filter: blur(10px) saturate(180%);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%; /* Circular shape */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12),
              0 1px 3px rgba(0, 0, 0, 0.08),
              inset 0 1px 1px rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 350ms cubic-bezier(0.4, 0.0, 0.2, 1);
  flex-shrink: 0;
  color: #000000; /* Black icon color */
  font-size: 16px;
}

.supernal-tts-speed-toggle:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0, 0, 0, 0.15);
  transform: scale(1.08) translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16),
              0 2px 6px rgba(0, 0, 0, 0.12),
              inset 0 1px 1px rgba(255, 255, 255, 0.6);
}

.supernal-tts-speed-icon {
  color: inherit;
}

/* Speed Dropdown Menu (shown on hover) - Liquid Glass Style (matches circle buttons) */
.supernal-tts-speed-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 100px;

  /* Liquid glass effect - EXACT match to circle buttons */
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px) saturate(180%);
  -webkit-backdrop-filter: blur(10px) saturate(180%);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;

  /* Shadow matching circle buttons */
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.12),
    0 1px 3px rgba(0, 0, 0, 0.08),
    inset 0 1px 1px rgba(255, 255, 255, 0.5);

  z-index: 1000;
  overflow: hidden;
  transition: opacity 0.2s ease;
  padding: 6px;
}

.supernal-tts-speed-dropdown.hidden {
  display: none;
  opacity: 0;
}

.supernal-tts-speed-control:hover .supernal-tts-speed-dropdown.hidden {
  display: block;
  opacity: 1;
}

.supernal-tts-speed-option {
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  color: #1f2937;
  margin: 2px 0;
}

.supernal-tts-speed-option:hover {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.supernal-tts-speed-option.active {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  color: #3b82f6;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

.supernal-tts-speed-option:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

/* Progress Bar Container - horizontal compact layout, max 4 icons width */
.supernal-tts-progress-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: auto;
  max-width: 180px; /* ~4 icons + padding */

  /* Subtle liquid glass background */
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(8px) saturate(150%);
  -webkit-backdrop-filter: blur(8px) saturate(150%);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 20px;
  padding: 6px 10px;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.08),
    inset 0 1px 1px rgba(255, 255, 255, 0.4);

  /* Position absolutely ABOVE the circles */
  position: absolute;
  bottom: 48px; /* Above the 44px unified circle + 4px gap */
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;

  /* Hide by default - no max-height animation to prevent layout shift */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Show on hover or when playing */
.supernal-tts-modular-widget:hover .supernal-tts-progress-container,
.supernal-tts-progress-container.playing {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Mobile/Touch: Show progress when playing */
@media (hover: none) and (pointer: coarse) {
  .supernal-tts-progress-container.playing {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

/* Progress Slider - compact horizontal layout */
.supernal-tts-progress-container .supernal-tts-progress-slider {
  flex: 1;
  min-width: 60px;
  height: 3px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.12);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  padding: 0;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.08);
}

.supernal-tts-progress-container .supernal-tts-progress-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid #3b82f6;
  cursor: pointer;
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.15),
    inset 0 0.5px 1px rgba(255, 255, 255, 0.6);
  transition: all 0.2s ease;
}

.supernal-tts-progress-container .supernal-tts-progress-slider::-webkit-slider-thumb:hover {
  background: rgba(255, 255, 255, 1);
  border-color: #2563eb;
  transform: scale(1.2);
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.2),
    inset 0 1px 1px rgba(255, 255, 255, 0.7);
}

.supernal-tts-progress-container .supernal-tts-progress-slider::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid #3b82f6;
  cursor: pointer;
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.15),
    inset 0 0.5px 1px rgba(255, 255, 255, 0.6);
  transition: all 0.2s ease;
}

.supernal-tts-progress-container .supernal-tts-progress-slider::-moz-range-thumb:hover {
  background: rgba(255, 255, 255, 1);
  border-color: #2563eb;
  transform: scale(1.2);
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.2),
    inset 0 1px 1px rgba(255, 255, 255, 0.7);
}

/* Time Display - compact, right-aligned */
.supernal-tts-time-display {
  font-size: 9px;
  color: rgba(0, 0, 0, 0.5);
  text-align: right;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', 'Droid Sans Mono', 'Source Code Pro', monospace;
  background: transparent;
  padding: 0;
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 50px; /* Accommodate "0:00 / 0:00" */
  letter-spacing: -0.3px; /* Tighter spacing for compact display */
}

.supernal-tts-time-display .current {
  font-weight: 600;
  color: #3b82f6;
}

/* Dark mode support for modular widget */
@media (prefers-color-scheme: dark) {
  /* Voice and speed toggles use same liquid glass styling in dark mode */
  .supernal-tts-voice-toggle,
  .supernal-tts-speed-toggle {
    background: rgba(255, 255, 255, 0.75);
    border-color: rgba(0, 0, 0, 0.12);
    color: #000000;
  }

  .supernal-tts-voice-toggle:hover,
  .supernal-tts-speed-toggle:hover {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.15);
  }
  
  .supernal-tts-voice-dropdown,
  .supernal-tts-speed-dropdown {
    /* Keep same light frosted glass as circles - don't change for dark mode */
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow:
      0 4px 12px rgba(0, 0, 0, 0.12),
      0 1px 3px rgba(0, 0, 0, 0.08),
      inset 0 1px 1px rgba(255, 255, 255, 0.5);
  }

  .supernal-tts-voice-option,
  .supernal-tts-speed-option {
    color: #1f2937; /* Dark text on light frosted background */
  }

  .supernal-tts-voice-option:hover,
  .supernal-tts-speed-option:hover {
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  }

  .supernal-tts-voice-option.active,
  .supernal-tts-speed-option.active {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    color: #3b82f6;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
  }
}

/* Mobile responsiveness for modular widget */
@media (max-width: 768px) {
  .supernal-tts-controls-row {
    flex-wrap: wrap;
  }
  
  .supernal-tts-progress-container {
    min-width: 100%;
  }
  
  .supernal-tts-voice-dropdown {
    left: auto;
    right: 0;
  }
}

/* Progressive loading indicator */
.supernal-tts-progress-container.loading .current {
  color: #f59e0b;
  font-weight: 500;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* ================================================================
   UNIFIED CIRCLE INTERFACE
   Default: ONE circle with ~+
   Hover: Splits into THREE circles: (~) (▶) (+)
   The play button (▶) stays in center, ~ moves left, + moves right
   ================================================================ */

/* Modular widget container positioning */
.supernal-tts-modular-widget {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 52px; /* Accommodate circle size */
}

/* Alignment options - left-aligned widgets need offset for expansion */
.supernal-tts-modular-widget.supernal-tts-align-left {
  margin-left: 30px; /* Offset to the right to account for expansion going left */
}

.supernal-tts-modular-widget.supernal-tts-align-center {
  display: flex; /* Use flex instead of inline-flex for true centering */
  margin: 0 auto; /* Center horizontally */
}

/* Add extra space when progress bar is enabled to prevent layout shift */
.supernal-tts-modular-widget.has-progress {
  min-height: 52px; /* Just circles, progress bar is absolute */
  padding-bottom: 0; /* Remove old padding */
}

/* ===== UNIFIED CIRCLE (Default State) ===== */
.supernal-tts-unified-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: #000000;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px) saturate(180%);
  -webkit-backdrop-filter: blur(10px) saturate(180%);
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12),
              0 1px 3px rgba(0, 0, 0, 0.08),
              inset 0 1px 1px rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: all 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
  position: relative;
  z-index: 2;
}

.supernal-tts-unified-circle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16),
              0 2px 6px rgba(0, 0, 0, 0.12),
              inset 0 1px 1px rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0, 0, 0, 0.15);
}

/* Hide unified circle when widget is hovered or permanently expanded */
.supernal-tts-modular-widget:hover .supernal-tts-unified-circle,
.supernal-tts-modular-widget.permanently-expanded .supernal-tts-unified-circle {
  opacity: 0;
  transform: scale(0.85);
  pointer-events: none;
}

/* ===== SPLIT CIRCLES (Hover State) ===== */
.supernal-tts-split-circles {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
  /* Container just for positioning, children use absolute positioning */
  width: 350px; /* Wide enough for expanded state */
  height: 44px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.supernal-tts-modular-widget:hover .supernal-tts-split-circles,
.supernal-tts-modular-widget.permanently-expanded .supernal-tts-split-circles {
  opacity: 1;
  pointer-events: auto;
}

/* Base circle styling - LIQUID GLASS */
.supernal-tts-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Mono', monospace;
  font-size: 18px;
  font-weight: 600;
  color: #000000;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(10px) saturate(180%);
  -webkit-backdrop-filter: blur(10px) saturate(180%);
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12),
              0 1px 3px rgba(0, 0, 0, 0.08),
              inset 0 1px 1px rgba(255, 255, 255, 0.5);
  transition: all 350ms cubic-bezier(0.4, 0.0, 0.2, 1);
  cursor: pointer;
  text-decoration: none;
}

.supernal-tts-circle:hover {
  transform: scale(1.08) translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16),
              0 2px 6px rgba(0, 0, 0, 0.12),
              inset 0 1px 1px rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(0, 0, 0, 0.15);
}

.supernal-tts-circle:active {
  transform: scale(1.02);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1),
              inset 0 1px 1px rgba(255, 255, 255, 0.4);
}

/* Left circle: Tilde (~) - Positioned LEFT of center */
.supernal-tts-tilde-circle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 32px;
  height: 32px;
  font-size: 14px;
  transform: translate(-50%, -50%) scale(0.8);
  opacity: 0;
  transition: all 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.supernal-tts-modular-widget:hover .supernal-tts-tilde-circle,
.supernal-tts-modular-widget.permanently-expanded .supernal-tts-tilde-circle {
  transform: translate(calc(-50% - 45px), -50%) scale(1);
  opacity: 1;
  transition-delay: 0ms;
}

/* Center: Play button (▶) - ABSOLUTELY CENTERED, exactly where unified circle was */
.supernal-tts-play-circle {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  opacity: 0;
  transition: all 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.supernal-tts-modular-widget:hover .supernal-tts-play-circle,
.supernal-tts-modular-widget.permanently-expanded .supernal-tts-play-circle {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  transition-delay: 30ms;
}

/* Right circle: Plus (+) - Positioned RIGHT of center */
.supernal-tts-plus-circle {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  opacity: 0;
  transition: all 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
}

.supernal-tts-modular-widget:hover .supernal-tts-plus-circle,
.supernal-tts-modular-widget.permanently-expanded .supernal-tts-plus-circle {
  transform: translate(calc(-50% + 45px), -50%) scale(1);
  opacity: 1;
  transition-delay: 60ms;
}

/* Plus circle with glow when controls are available */
.supernal-tts-plus-circle.has-controls {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12),
              0 1px 3px rgba(0, 0, 0, 0.08),
              inset 0 1px 1px rgba(255, 255, 255, 0.5),
              0 0 16px rgba(255, 215, 0, 0.5);
}

.supernal-tts-modular-widget:hover .supernal-tts-plus-circle.has-controls,
.supernal-tts-modular-widget.permanently-expanded .supernal-tts-plus-circle.has-controls {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16),
              0 2px 6px rgba(0, 0, 0, 0.12),
              inset 0 1px 1px rgba(255, 255, 255, 0.6),
              0 0 20px rgba(255, 215, 0, 0.6);
}

/* When controls are revealed via JS, plus moves to the end */
/* Position varies based on which controls are present */

/* Voice only: 87px (42px after voice at 45px) */
.supernal-tts-plus-circle.controls-revealed.voice-only {
  transform: translate(calc(-50% + 87px), -50%) scale(1) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12),
              0 1px 3px rgba(0, 0, 0, 0.08),
              inset 0 1px 1px rgba(255, 255, 255, 0.5) !important;
}

/* Speed only: 87px (42px after speed would be at 45px) */
.supernal-tts-plus-circle.controls-revealed.speed-only {
  transform: translate(calc(-50% + 87px), -50%) scale(1) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12),
              0 1px 3px rgba(0, 0, 0, 0.08),
              inset 0 1px 1px rgba(255, 255, 255, 0.5) !important;
}

/* Both voice and speed: 128px (41px after speed at 87px) */
.supernal-tts-plus-circle.controls-revealed.both-controls {
  transform: translate(calc(-50% + 128px), -50%) scale(1) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12),
              0 1px 3px rgba(0, 0, 0, 0.08),
              inset 0 1px 1px rgba(255, 255, 255, 0.5) !important;
}

/* Fallback for controls-revealed without specific class (shouldn't happen but safe default) */
.supernal-tts-plus-circle.controls-revealed {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12),
              0 1px 3px rgba(0, 0, 0, 0.08),
              inset 0 1px 1px rgba(255, 255, 255, 0.5) !important;
}

/* Plus circle changes to arrow on hover - handled by JavaScript changing text content */

/* ===== VOICE/SPEED CONTROLS IN SPLIT CIRCLES ===== */
/* Position controls absolutely between play and plus */
.supernal-tts-split-circles .supernal-tts-voice-control {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(calc(-50% + 45px), -50%);
  opacity: 0 !important; /* Override general widget hover rules */
  visibility: hidden !important;
  transition: all 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
  pointer-events: none;
}

.supernal-tts-split-circles .supernal-tts-speed-control {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(calc(-50% + 87px), -50%);
  opacity: 0 !important; /* Override general widget hover rules */
  visibility: hidden !important;
  transition: all 400ms cubic-bezier(0.4, 0.0, 0.2, 1);
  pointer-events: none;
}

/* Speed control when there's no voice control (speed only) */
.supernal-tts-split-circles:not(:has(.supernal-tts-voice-control)) .supernal-tts-speed-control {
  transform: translate(calc(-50% + 45px), -50%);
}

/* Show controls ONLY when they have the controls-visible class (set by JS on + hover) */
.supernal-tts-split-circles .supernal-tts-voice-control.controls-visible,
.supernal-tts-split-circles .supernal-tts-speed-control.controls-visible {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* Play icon styling */
.supernal-tts-play-icon-circle {
  font-size: 16px;
  color: #000000;
  margin-left: 1px; /* Optical alignment for play triangle */
}

/* ===== PLAY BUTTON STATES ===== */

/* Playing state - Slightly more opaque with pulse */
.supernal-tts-play-circle.supernal-tts-playing {
  background: rgba(255, 255, 255, 0.4);
  animation: play-pulse 1.5s ease-in-out infinite;
}

@keyframes play-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.85;
  }
}

/* Loading state - Spinner */
.supernal-tts-play-circle.supernal-tts-loading {
  background: rgba(255, 255, 255, 0.35);
}

.supernal-tts-play-circle.supernal-tts-loading .supernal-tts-play-icon-circle {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Error state - Same glass effect */
.supernal-tts-play-circle.supernal-tts-error {
  background: rgba(255, 255, 255, 0.3);
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
  .supernal-tts-unified-circle,
  .supernal-tts-circle {
    background: rgba(255, 255, 255, 0.75);
    border-color: rgba(0, 0, 0, 0.12);
    color: #000000;
  }

  .supernal-tts-unified-circle:hover,
  .supernal-tts-circle:hover {
    background: rgba(255, 255, 255, 0.85);
    border-color: rgba(0, 0, 0, 0.15);
  }

  .supernal-tts-play-icon-circle {
    color: #000000;
  }
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  /* On mobile, always show split circles (no hover needed) */
  .supernal-tts-unified-circle {
    display: none;
  }

  .supernal-tts-split-circles {
    position: relative;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    gap: 10px;
  }

  .supernal-tts-tilde-circle,
  .supernal-tts-play-circle,
  .supernal-tts-plus-circle {
    opacity: 1;
    transform: translateX(0) scale(1.0);
    transition-delay: 0ms;
  }

  .supernal-tts-circle {
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
}

