/* FixMyPhoneSpeaker tool — light theme, mobile-first, no external requests. */

.psc-tool {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #0f172a;
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.psc-tool *,
.psc-tool *::before,
.psc-tool *::after {
  box-sizing: border-box;
}

/* ---- Guidance checklist ---- */
.psc-checklist {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 14px 16px;
  margin: 0 0 16px;
}

.psc-checklist-title {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: 1rem;
  color: #1d4ed8;
}

.psc-checklist-list {
  margin: 0;
  padding-left: 20px;
}

.psc-checklist-list li {
  margin: 4px 0;
  font-size: 0.95rem;
}

/* ---- Card ---- */
.psc-card {
  position: relative; /* anchor for the droplet overlay */
  overflow: hidden;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.08);
  padding: 20px 16px;
  text-align: center;
}

/* ---- Mode tabs ---- */
.psc-tabs {
  display: flex;
  gap: 6px;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
}

.psc-tab {
  flex: 1;
  border: 0;
  background: transparent;
  color: #475569;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 10px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.psc-tab:hover {
  color: #1d4ed8;
}

.psc-tab.is-active {
  background: #ffffff;
  color: #2563eb;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.psc-tab:focus-visible {
  outline: 3px solid #14b8a6;
  outline-offset: 2px;
}

/* ---- Panels ---- */
.psc-panels {
  min-height: 3.2em;
  margin-bottom: 8px;
}

.psc-desc {
  margin: 0;
  font-size: 0.95rem;
  color: #334155;
}

.psc-field {
  display: block;
  text-align: left;
  margin: 10px 0;
}

.psc-field-label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: #0f172a;
}

.psc-range {
  width: 100%;
  accent-color: #2563eb;
  height: 32px;
  cursor: pointer;
}

.psc-select {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  color: #0f172a;
  cursor: pointer;
}

.psc-select:focus-visible,
.psc-range:focus-visible {
  outline: 3px solid #14b8a6;
  outline-offset: 2px;
}

/* ---- Play / Stop button ---- */
.psc-play {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 124px;
  height: 124px;
  margin: 12px auto 4px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #14b8a6 100%);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.psc-play:hover {
  transform: scale(1.04);
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.45);
}

.psc-play:active {
  transform: scale(0.97);
}

.psc-play:focus-visible {
  outline: 4px solid #14b8a6;
  outline-offset: 4px;
}

.psc-icon-stop {
  display: none;
}

.is-playing .psc-icon-play {
  display: none;
}

.is-playing .psc-icon-stop {
  display: block;
}

/* ---- Animated wave bars (CSS only) ---- */
.psc-waves {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 36px;
  margin: 10px 0 4px;
}

.psc-waves span {
  width: 5px;
  height: 8px;
  border-radius: 3px;
  background: linear-gradient(180deg, #2563eb, #14b8a6);
  opacity: 0.25;
  animation: psc-wave 0.9s ease-in-out infinite;
  animation-play-state: paused;
}

.psc-waves span:nth-child(1)  { animation-delay: 0s; }
.psc-waves span:nth-child(2)  { animation-delay: 0.08s; }
.psc-waves span:nth-child(3)  { animation-delay: 0.16s; }
.psc-waves span:nth-child(4)  { animation-delay: 0.24s; }
.psc-waves span:nth-child(5)  { animation-delay: 0.32s; }
.psc-waves span:nth-child(6)  { animation-delay: 0.4s; }
.psc-waves span:nth-child(7)  { animation-delay: 0.48s; }
.psc-waves span:nth-child(8)  { animation-delay: 0.56s; }
.psc-waves span:nth-child(9)  { animation-delay: 0.64s; }
.psc-waves span:nth-child(10) { animation-delay: 0.72s; }
.psc-waves span:nth-child(11) { animation-delay: 0.8s; }
.psc-waves span:nth-child(12) { animation-delay: 0.88s; }

.is-playing .psc-waves span {
  animation-play-state: running;
  opacity: 1;
}

@keyframes psc-wave {
  0%, 100% { transform: scaleY(0.4); }
  50%      { transform: scaleY(2.6); }
}

/* ---- Progress ---- */
.psc-progress {
  height: 10px;
  background: #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
  margin: 8px 0 6px;
}

.psc-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #14b8a6);
  border-radius: 6px;
  transition: width 0.2s linear;
}

.psc-time {
  margin: 0;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  color: #334155;
}

.psc-cycle-ind {
  margin: 4px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #0f766e;
}

/* ---- Cycle selector ---- */
.psc-cycles {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 14px 0 4px;
}

.psc-cycles-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  margin-right: 4px;
}

.psc-cycle {
  width: 44px;
  height: 44px;
  border: 1px solid #cbd5e1;
  border-radius: 50%;
  background: #ffffff;
  color: #334155;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.psc-cycle:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.psc-cycle[aria-pressed="true"] {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.psc-cycle:focus-visible {
  outline: 3px solid #14b8a6;
  outline-offset: 2px;
}

/* ---- Status + safety ---- */
.psc-status {
  margin: 10px 0 0;
  min-height: 1.5em;
  font-size: 0.95rem;
  color: #0f766e;
  font-weight: 600;
}

.psc-status:empty {
  display: none;
}

.psc-safety {
  margin: 14px 0 0;
  padding: 10px 14px;
  font-size: 0.88rem;
  color: #475569;
  background: #f0fdfa;
  border-left: 4px solid #14b8a6;
  border-radius: 0 10px 10px 0;
}

/* ---- Larger screens ---- */
@media (min-width: 480px) {
  .psc-card {
    padding: 28px 32px;
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .psc-waves span {
    animation: none;
    opacity: 0.4;
    transform: scaleY(1);
  }

  .psc-play,
  .psc-tab,
  .psc-cycle,
  .psc-progress-fill {
    transition: none;
  }

  .psc-play:hover {
    transform: none;
  }
}

/* ---- Intent quick-start cards ---- */
.psc-intents {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.psc-intent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  border: 2px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.3;
  color: #0f172a;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.psc-intent:hover {
  border-color: #2563eb;
  transform: translateY(-1px);
}

.psc-intent.is-active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.18);
}

.psc-intent-emoji {
  font-size: 1.8rem;
  line-height: 1;
}

.psc-intent:focus-visible {
  outline: 3px solid #14b8a6;
  outline-offset: 2px;
}

/* ---- Live visualizer (real spectrum, shown while playing) ---- */
.psc-viz {
  display: none;
  width: 100%;
  height: 84px;
  margin: 8px 0 0;
  border-radius: 10px;
  background: #0f172a;
}

.is-playing .psc-viz {
  display: block;
}

/* ---- Droplet particles (water mode, absolute overlay) ---- */
.psc-drops {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

/* ---- Pulsing invitation ring on the play button ---- */
.psc-play {
  position: relative;
}

.psc-play::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid rgba(37, 99, 235, 0.45);
  pointer-events: none;
  animation: psc-ping 1.8s ease-out infinite;
}

.is-playing .psc-play::after {
  animation: none;
  opacity: 0;
}

@keyframes psc-ping {
  0%   { transform: scale(0.92); opacity: 0.9; }
  70%  { transform: scale(1.12); opacity: 0; }
  100% { transform: scale(1.12); opacity: 0; }
}

/* ---- Smooth tab panel transitions ---- */
.psc-panel:not([hidden]) {
  animation: psc-panel-in 0.25s ease;
}

@keyframes psc-panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---- Completion panel ---- */
.psc-done {
  margin-top: 16px;
  padding: 20px 16px 16px;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  background: #f0fdfa;
  animation: psc-panel-in 0.3s ease;
}

.psc-done-check svg {
  display: block;
  margin: 0 auto;
}

.psc-done-circle {
  stroke-dasharray: 157; /* 2πr ≈ 157 for r=25 */
  stroke-dashoffset: 157;
}

.psc-done-tick {
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
}

.psc-done.is-done .psc-done-circle {
  animation: psc-draw 0.5s ease forwards;
}

.psc-done.is-done .psc-done-tick {
  animation: psc-draw 0.35s ease 0.45s forwards;
}

@keyframes psc-draw {
  to { stroke-dashoffset: 0; }
}

.psc-done-title {
  margin: 10px 0 12px;
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
}

.psc-chime {
  display: inline-block;
  padding: 12px 22px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb 0%, #14b8a6 100%);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.psc-chime:hover {
  transform: scale(1.04);
}

.psc-chime:active {
  transform: scale(0.97);
}

.psc-chime:focus-visible {
  outline: 3px solid #14b8a6;
  outline-offset: 2px;
}

.psc-feedback-q {
  margin: 16px 0 8px;
  font-weight: 700;
  color: #0f172a;
}

.psc-feedback-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.psc-feedback-btn {
  padding: 10px 20px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  color: #334155;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.psc-feedback-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.psc-feedback-btn.is-active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.psc-feedback-btn:focus-visible {
  outline: 3px solid #14b8a6;
  outline-offset: 2px;
}

.psc-feedback-msg {
  margin: 10px 0 0;
  min-height: 1.5em;
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f766e;
}

.psc-feedback-msg:empty {
  display: none;
}

.psc-troubleshoot {
  margin: 12px 0 0;
  padding-left: 22px;
  text-align: left;
  font-size: 0.92rem;
  color: #334155;
}

.psc-troubleshoot li {
  margin: 8px 0;
}

.psc-troubleshoot a {
  color: #1d4ed8;
  font-weight: 600;
}

/* ---- Larger screens ---- */
@media (min-width: 480px) {
  .psc-intents {
    gap: 12px;
  }
}

/* ---- Reduced motion: new components only
   (base waves/buttons rules live in the earlier reduced-motion block) ---- */
@media (prefers-reduced-motion: reduce) {
  .psc-intent,
  .psc-chime,
  .psc-feedback-btn {
    transition: none;
  }

  .psc-intent:hover,
  .psc-chime:hover {
    transform: none;
  }

  .psc-play::after {
    animation: none;
    display: none;
  }

  .psc-panel:not([hidden]),
  .psc-done {
    animation: none;
  }

  .psc-done.is-done .psc-done-circle,
  .psc-done.is-done .psc-done-tick {
    animation: none;
    stroke-dashoffset: 0;
  }
}
