/* The talk card and the live talk: the mic button, the voice wave, the timer,
   the status line, the time limit, the microphone help and the wrap-up. */

.actions {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.practice {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
}

.practice .page-title {
  justify-content: center;
  text-align: center;
}

.talk-stage {
  display: grid;
  justify-items: center;
  gap: 20px;
  margin: 20px 0 0;
  text-align: center;
}

.talk-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  box-shadow: 0 10px 24px #2563eb40;
}

.talk-button:focus {
  outline: none;
}

.talk-button:focus-visible {
  outline: 2px solid CanvasText;
  outline-offset: 6px;
}

.talk-button:hover:not(:disabled) {
  filter: brightness(1.06);
}

.talk-button svg {
  width: 34px;
  height: 34px;
}

.talk-icon.live {
  display: none;
}

.talk-pulse {
  display: none;
  position: absolute;
  inset: -8px;
  z-index: 0;
  border: 2px solid #e11d48;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.talk-icon {
  position: relative;
  z-index: 1;
  display: grid;
}

.talk-wave {
  width: min(100%, 280px);
  height: 72px;
  margin-top: 4px;
  color: #60a5fa;
}

.talk-wave path {
  fill: currentColor;
  fill-opacity: 0.2;
  stroke: currentColor;
  stroke-width: 2.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
  transition:
    opacity 0.2s ease,
    fill-opacity 0.2s ease;
}

.talk-stage[data-state="connecting"] .talk-wave,
.talk-stage[data-state="ending"] .talk-wave {
  animation: wave-wait 1.2s ease-in-out infinite;
}

.talk-stage[data-state="live"] .talk-wave path {
  opacity: 0.92;
  fill-opacity: 0.26;
}

.talk-stage[data-speaking="true"] .talk-wave {
  color: #93c5fd;
}

.talk-stage[data-speaking="true"] .talk-wave path {
  opacity: 1;
  fill-opacity: 0.34;
}

.talk-timer {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  opacity: 0.82;
}

.talk-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  min-height: 1.5em;
  opacity: 0.78;
}

.talk-live-dot {
  display: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e11d48;
}

.talk-stage[data-state="connecting"] .talk-button,
.talk-stage[data-state="ending"] .talk-button {
  opacity: 0.7;
}

.talk-stage[data-state="live"] .talk-button {
  background: #e11d48;
  box-shadow: 0 10px 24px #e11d4840;
}

.talk-stage[data-state="live"] .talk-icon.idle {
  display: none;
}

.talk-stage[data-state="live"] .talk-icon.live {
  display: grid;
}

.talk-stage[data-state="live"] .talk-pulse {
  display: block;
  animation: talk-pulse 1.6s ease-out infinite;
}

.talk-stage[data-state="live"] .talk-live-dot {
  display: block;
  animation: talk-dot 1.2s ease-in-out infinite;
}

@keyframes talk-pulse {
  from {
    transform: scale(0.92);
    opacity: 0.5;
  }

  to {
    transform: scale(1.12);
    opacity: 0;
  }
}

@keyframes talk-dot {
  50% {
    opacity: 0.35;
  }
}

@keyframes wave-wait {
  50% {
    opacity: 0.55;
    transform: scaleX(1.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  .talk-stage[data-state="live"] .talk-pulse,
  .talk-stage[data-state="live"] .talk-live-dot,
  .talk-stage[data-state="connecting"] .talk-wave,
  .talk-stage[data-state="ending"] .talk-wave {
    animation: none;
  }
}

.talk-audio {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

#status {
  min-height: 1.5em;
}

.practice {
  min-height: 430px;
  align-content: center;
  padding: 42px 28px 34px;
  border: 1.5px solid var(--line);
  border-radius: 23px 17px 21px 15px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.practice-kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.talk-stage {
  gap: 14px;
  margin-top: 30px;
}

.talk-button {
  width: 112px;
  height: 112px;
  border: 1.5px solid var(--line);
  background: var(--brand);
  box-shadow: 3px 4px 0 rgb(66 60 54 / 18%);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    filter 0.2s ease;
}

.talk-button:hover:not(:disabled) {
  filter: none;
  background: var(--brand-strong);
  transform: translate(-1px, -2px);
  box-shadow: 4px 6px 0 rgb(66 60 54 / 18%);
}

.talk-button:active:not(:disabled) {
  transform: translate(1px, 1px);
  box-shadow: 1px 2px 0 rgb(66 60 54 / 16%);
}

.talk-stage[data-state="live"] .talk-button {
  background: var(--live-button, #97ad9f);
  box-shadow: none;
}

.talk-stage[data-state="live"] .talk-pulse {
  border-color: var(--live-accent, #4b6a57);
}

.talk-live-dot {
  background: var(--live-accent, #4b6a57);
}

.talk-wave {
  height: 58px;
  color: var(--brand-strong);
}

.talk-status {
  min-height: 1.5em;
  color: var(--text);
  font-weight: 700;
}

.talk-hint {
  max-width: 360px;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

@media (max-width: 760px) {
  .practice {
    min-height: 390px;
    padding: 34px 20px 28px;
    border-radius: 22px;
  }
}

.feedback-notice {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.feedback-notice[hidden] {
  display: none;
}

/* After a failed check of a talk: run it again. It steps aside in practice
   mode, like the result of the talk. */
.analysis-retry {
  display: inline-flex;
  align-items: center;
  justify-self: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1.5px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  transition:
    background-color 0.18s ease,
    color 0.18s ease;
}

.analysis-retry svg {
  width: 16px;
  height: 16px;
}

.analysis-retry:hover {
  background: var(--accent);
  color: #fff;
}

.analysis-retry:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

.analysis-retry[hidden],
.practice[data-mode="practice"] .analysis-retry {
  display: none;
}

/* On a phone the button would reach the buddy, so it sits above its head. */
@media (max-width: 620px) {
  .practice[data-mode="free"]:has(.analysis-retry:not([hidden])) {
    padding-bottom: 64px;
  }
}

/* The switch sits pinned to the top of the card, so it never moves between modes. */
.practice {
  min-height: 0;
  align-content: start;
  padding-top: 88px;
}

/* While idle, the flat wave and the "ready" status only take space. */
.talk-stage[data-state="idle"] .talk-wave,
.talk-stage[data-state="idle"][data-status-ready] .talk-status {
  display: none;
}

/* How to allow the microphone, when the browser refused it: a few short
   steps under the line that says so. */
.mic-help {
  display: grid;
  gap: 6px;
  max-width: 36ch;
  margin: 0 auto;
  padding-inline-start: 1.5em;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
  text-align: start;
}

.mic-help[hidden] {
  display: none;
}

/* A live talk that hears nothing at all: one soft line under the status. */
.mic-silent {
  max-width: 36ch;
  margin: 0 auto;
  padding: 6px 14px;
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.mic-silent[hidden] {
  display: none;
}

/* The line is the lowest thing on the card, so it leaves room for the
   buddy's head at the card's corner. */
.practice:has(.mic-silent:not([hidden])) {
  padding-bottom: 76px;
}

/* Wrap-up between the end of a talk and its result. */
.talk-stage[data-wrapup]
  :is(
    .talk-timer,
    .talk-status,
    .talk-wave,
    .feedback-notice,
    .practice-target
  ) {
  display: none;
}

.talk-wrapup {
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
  animation: wrapup-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.talk-wrapup[hidden] {
  display: none;
}

.wrapup-duration {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 750;
}

.wrapup-working {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 0;
  color: var(--muted);
}

.wrapup-dots {
  display: inline-flex;
  gap: 3px;
}

.wrapup-dots i,
.buddy-thought i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: wrapup-dot 1.2s ease-in-out infinite;
}

.wrapup-dots i:nth-child(2),
.buddy-thought i:nth-child(2) {
  animation-delay: 0.15s;
}

.wrapup-dots i:nth-child(3),
.buddy-thought i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes wrapup-dot {
  0%,
  60%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@keyframes wrapup-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .wrapup-dots i,
  .buddy-thought i,
  .talk-wrapup {
    animation: none;
  }
}

/* Conversation length, under the mic in free conversation (in the mode's color). */
.talk-limit {
  --accent: var(--brand);
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.talk-limit[hidden] {
  display: none;
}

.talk-limit svg {
  width: 20px;
  height: 20px;
}
