/* Web Speech API — voice search & read aloud */

/* —— Voice search mic button —— */
.rp-speech-mic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  cursor: pointer;
  color: #667eea;
  background: #f0f3ff;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.search-input-wrapper .rp-speech-mic {
  position: absolute;
  right: 44px;
  top: 0;
  border-left: 1px solid rgba(102, 126, 234, 0.25);
  border-radius: 0;
}

.rp-speech-mic:hover {
  background: #e4e9ff;
  color: #5568d3;
}

.rp-speech-mic:focus-visible {
  outline: 3px solid rgba(102, 126, 234, 0.35);
  outline-offset: -3px;
  z-index: 1;
}

.rp-speech-mic.is-listening {
  color: #fff;
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  animation: rp-speech-pulse 1.2s ease-in-out infinite;
}

.rp-speech-mic--compact {
  width: auto;
  height: auto;
  min-width: 44px;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border-radius: var(--rp-radius-sm, 8px);
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.rp-hero__search .rp-speech-mic--compact:hover {
  background: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.rp-hero__search .rp-speech-mic--compact.is-listening {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  border-color: transparent;
}

.rp-speech-mic-status {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: calc(100% + 4px);
  font-size: 0.75rem;
  white-space: nowrap;
  color: #667eea;
  background: #fff;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 10;
}

.rp-hero__search .rp-speech-mic-status {
  color: #764ba2;
}

@keyframes rp-speech-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(231, 76, 60, 0); }
}

/* —— Read aloud toolbar —— */
.rp-speech-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 1rem;
  margin-bottom: 1rem;
  padding: 0.65rem 0.85rem;
  background: linear-gradient(135deg, #f8f9ff 0%, #f0f3ff 100%);
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: 10px;
}

.rp-speech-bar__group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.rp-speech-bar__controls {
  margin-left: auto;
}

.rp-speech-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  color: #4a5568;
  background: #fff;
  border: 1px solid #dde1ea;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.rp-speech-btn:hover:not(:disabled) {
  background: #f8f9fa;
  border-color: #667eea;
  color: #667eea;
}

.rp-speech-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.rp-speech-btn--primary {
  color: #fff;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: transparent;
}

.rp-speech-btn--primary:hover:not(:disabled) {
  color: #fff;
  filter: brightness(1.06);
}

.rp-speech-bar.is-playing .rp-speech-btn--primary {
  opacity: 0.7;
}

.rp-speech-slider {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  margin: 0;
}

.rp-speech-slider input[type="range"] {
  width: 72px;
  height: 4px;
  accent-color: #667eea;
  cursor: pointer;
}

/* FAQ listen button */
.accordion-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.faq-question-text {
  flex: 1;
  text-align: left;
}

.rp-speech-faq-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  margin-left: 0.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(102, 126, 234, 0.12);
  color: #667eea;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.15s, color 0.15s;
}

.accordion-button .rp-speech-faq-btn {
  margin-left: auto;
}

.rp-speech-faq-btn:hover {
  background: rgba(102, 126, 234, 0.22);
}

.rp-speech-faq-btn.is-speaking {
  color: #fff;
  background: #667eea;
  animation: rp-speech-pulse 1.2s ease-in-out infinite;
}

/* Selected text bubble */
.rp-speech-selection {
  position: absolute;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(102, 126, 234, 0.4);
  cursor: pointer;
  animation: rp-speech-fade-in 0.15s ease;
}

.rp-speech-selection:hover {
  filter: brightness(1.06);
}

@keyframes rp-speech-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 576px) {
  .rp-speech-bar__controls {
    margin-left: 0;
    width: 100%;
  }

  .rp-speech-btn__short {
    display: none;
  }

  .rp-speech-slider input[type="range"] {
    width: 56px;
  }
}

/* Sticky read-aloud dock (job/blog detail) */
.rp-speech-sticky {
  position: fixed;
  left: max(1rem, env(safe-area-inset-left, 0px));
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  z-index: 10040;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  pointer-events: none;
}

.rp-speech-sticky > * {
  pointer-events: auto;
}

.rp-speech-sticky__prompt {
  position: relative;
  max-width: min(14rem, calc(100vw - 6rem));
  padding: 0.5rem 1.85rem 0.5rem 0.7rem;
  border-radius: 10px;
  background: #fff;
  color: #1e293b;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
  border: 1px solid rgba(102, 126, 234, 0.2);
  animation: rp-speech-sticky-in 0.3s ease-out;
}

.rp-speech-sticky__prompt[hidden] {
  display: none !important;
}

.rp-speech-sticky__prompt-text {
  margin: 0;
}

.rp-speech-sticky__prompt-close {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 1.25rem;
  height: 1.25rem;
  border: none;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #64748b;
  cursor: pointer;
}

.rp-speech-sticky__prompt-close:hover {
  background: #f1f5f9;
}

.rp-speech-sticky__dock {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
}

.rp-speech-sticky__panel {
  width: min(15.5rem, calc(100vw - 5.5rem));
  max-height: min(42vh, 16rem);
  overflow: auto;
  padding: 0.55rem 0.65rem 0.65rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(102, 126, 234, 0.18);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  animation: rp-speech-sticky-in 0.25s ease-out;
}

.rp-speech-sticky__panel[hidden] {
  display: none !important;
}

.rp-speech-sticky__panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #eef2f7;
}

.rp-speech-sticky__panel-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #475569;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.rp-speech-sticky__panel-close {
  width: 1.5rem;
  height: 1.5rem;
  border: none;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  color: #64748b;
  cursor: pointer;
}

.rp-speech-sticky__panel-close:hover {
  background: #e2e8f0;
  color: #334155;
}

.rp-speech-sticky__transport {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}

.rp-speech-sticky__ctrl {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  min-height: 2.1rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: #fff;
  color: #475569;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.rp-speech-sticky__ctrl:hover:not(:disabled) {
  border-color: #667eea;
  color: #667eea;
}

.rp-speech-sticky__ctrl:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.rp-speech-sticky__ctrl--primary {
  color: #fff;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-color: transparent;
}

.rp-speech-sticky__ctrl--primary:hover:not(:disabled) {
  color: #fff;
  filter: brightness(1.05);
}

.rp-speech-sticky__sliders {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.rp-speech-sticky__slider {
  display: grid;
  grid-template-columns: 3.1rem 1fr 2.2rem;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
  margin: 0;
}

.rp-speech-sticky__slider input[type="range"] {
  width: 100%;
  height: 4px;
  accent-color: #667eea;
  cursor: pointer;
}

.rp-speech-sticky__slider output {
  font-size: 0.68rem;
  font-weight: 700;
  color: #667eea;
  text-align: right;
}

.rp-speech-sticky__bar {
  display: inline-flex;
  align-items: stretch;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.rp-speech-sticky__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 0.95rem;
  border: none;
  cursor: pointer;
  color: #fff;
  font-size: 0.84rem;
  font-weight: 700;
  font-family: inherit;
  background: transparent;
  transition: filter 0.2s ease;
}

.rp-speech-sticky__btn:hover {
  filter: brightness(1.06);
}

.rp-speech-sticky__btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: -2px;
}

.rp-speech-sticky__toggle {
  width: 2.65rem;
  border: none;
  border-left: 1px solid rgba(255, 255, 255, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.2s ease;
}

.rp-speech-sticky__toggle:hover {
  background: rgba(255, 255, 255, 0.18);
}

.rp-speech-sticky.is-open .rp-speech-sticky__toggle {
  background: rgba(255, 255, 255, 0.22);
}

.rp-speech-sticky.has-prompt .rp-speech-sticky__bar {
  animation: rp-speech-sticky-pulse 1.4s ease-in-out infinite;
}

.rp-speech-sticky.is-playing .rp-speech-sticky__bar {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
  box-shadow: 0 6px 20px rgba(231, 76, 60, 0.38);
  animation: none;
}

@keyframes rp-speech-sticky-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes rp-speech-sticky-pulse {
  0%, 100% { box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4); }
  50% { box-shadow: 0 6px 26px rgba(102, 126, 234, 0.55), 0 0 0 5px rgba(102, 126, 234, 0.12); }
}

@media (max-width: 768px) {
  .rp-speech-sticky__panel {
    width: min(14.5rem, calc(100vw - 5rem));
  }

  .rp-speech-sticky__ctrl-text {
    display: none;
  }

  .rp-speech-sticky__btn {
    padding: 0.6rem 0.8rem;
    font-size: 0.8rem;
  }

  .rp-speech-sticky__label {
    display: none;
  }

  .rp-speech-sticky__btn svg {
    width: 20px;
    height: 20px;
  }
}
