/*
 * Yazıyı Sese Çevirme page (page-text-to-speech.php): the two cards.
 *
 * Loaded after style.css and dark.css. The cards themselves (.panel, .tts-card,
 * .tcard-head, .tcard-body, .btn-listen, .tool-btn) are styled there, in both
 * themes. This file lays the two cards out and styles what is new: the voice
 * pictures, the Listen row and the Clear button. Colours come from the
 * variables of style.css, which dark.css redefines.
 */
.ttsv-panels {
  display: grid;
  /* Same width, columns and gap as the cards of the translation pages (.panels in style.css). */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
  margin: 0 auto;
}
/* Both heads are as tall as the head of a translation card. */
.ttsv-panel .tcard-head {
  min-height: 90px;
  padding: 18px 16px;
}
/* Computers: a card is at least as tall as a translation card (526px). It grows
   when a language has more voices than fit. */
@media (min-width: 1025px) {
  .ttsv-panel {
    min-height: 526px;
  }
}
@media (max-width: 1400px) {
  .ttsv-panel .tcard-head {
    min-height: 84px;
  }
}
.ttsv-panel .tcard-label {
  cursor: default;
}
/* style.css hides the card label on small screens; the text card has nothing else in its head. */
.ttsv-panel--text .tcard-label {
  visibility: visible;
}
/* Step labels in the card heads: "1 Metni yazın", "2 Sesi seçin". Fixed colours,
   because the heads keep their gradient in the dark theme. */
.ttsv-step {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 0 20px 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: default;
}
.ttsv-step-num {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #fff;
  color: #27408f;
  font-size: 0.95rem;
  font-weight: 800;
}
.ttsv-legacy[hidden] {
  display: none !important;
}

/* ---- Left card: the text ---- */
.ttsv-panel--text .tcard-body {
  display: flex;
  flex-direction: column;
}
.ttsv-panel--text .input-group {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}
.ttsv-page #source-textarea {
  min-height: 250px;
}
.ttsv-text-footer {
  flex-wrap: nowrap;
}
.ttsv-clear {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  margin-left: auto;
  padding: 8px 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--input-bg);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: var(--soft-shadow);
  cursor: pointer;
  transition: transform 0.16s ease, color 0.16s ease;
}
.ttsv-clear svg {
  width: 20px;
  height: 20px;
}
.ttsv-clear:hover {
  color: var(--blue);
  transform: translateY(-2px);
}

/* ---- Right card: language, voices, listen ---- */
.ttsv-panel--voice .tcard-head .ttsv-lang-select {
  flex: 1 1 auto;
  max-width: none;
  margin-left: 0;
}
.ttsv-panel--voice .tcard-head .ttsv-lang-select select,
.ttsv-panel--voice .tcard-head .cld-trigger {
  width: 100%;
}
.ttsv-panel--voice .tcard-head .cld-dropdown {
  left: 0;
  width: 100%;
  max-width: none;
}
.ttsv-panel--voice .tcard-body {
  display: flex;
  flex-direction: column;
}
.ttsv-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 2px 0 14px;
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 800;
}
.ttsv-heading svg {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  color: var(--blue);
}
.ttsv-voices {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 8px;
}
.ttsv-voice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 10px 6px 9px;
  border: 2px solid transparent;
  border-radius: 18px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}
.ttsv-voice:hover {
  background: var(--blue-soft);
  transform: translateY(-2px);
}
.ttsv-voice:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}
.ttsv-avatar {
  display: block;
  width: 54px;
  height: 54px;
  padding: 3px;
  border-radius: 50%;
  background: var(--input-bg);
  box-shadow: 0 0 0 2px var(--line);
}
.ttsv-avatar svg {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
.ttsv-name {
  max-width: 100%;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
}
.ttsv-voice.is-on {
  border-color: var(--blue);
  background: var(--blue-soft);
}
.ttsv-voice.is-on .ttsv-avatar {
  box-shadow: 0 0 0 3px var(--blue);
}
.ttsv-voice.is-on .ttsv-name {
  color: var(--blue);
}

.ttsv-speed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
}
.ttsv-speed[hidden] {
  display: none;
}
.ttsv-speed-label {
  margin-right: 4px;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 800;
}
.ttsv-speed-btn {
  min-height: 40px;
  padding: 6px 16px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--input-bg);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.ttsv-speed-btn:hover {
  border-color: var(--blue);
}
.ttsv-speed-btn.is-on {
  border-color: var(--blue);
  background: var(--blue-soft);
  color: var(--blue);
}

.ttsv-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: auto;
  padding-top: 24px;
}
.ttsv-actions .ttsv-listen {
  order: 0;
  flex: 0 1 300px;
  min-height: 62px;
  margin-left: 0;
  font-size: 1.3rem;
  cursor: pointer;
}
.ttsv-listen svg {
  width: 28px;
  height: 28px;
}
.ttsv-listen .ttsv-ico-stop,
.ttsv-listen .ttsv-spinner {
  display: none;
}
.ttsv-listen.is-playing .ttsv-ico-play,
.ttsv-listen.is-loading .ttsv-ico-play {
  display: none;
}
.ttsv-listen.is-playing .ttsv-ico-stop {
  display: block;
}
.ttsv-listen.is-loading .ttsv-spinner {
  display: block;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ttsv-spin 0.8s linear infinite;
}
@keyframes ttsv-spin {
  to {
    transform: rotate(360deg);
  }
}
.ttsv-download {
  width: 58px;
  height: 58px;
  cursor: pointer;
}
.ttsv-download:disabled,
.ttsv-download.is-loading {
  opacity: 0.55;
  cursor: progress;
}
.ttsv-state {
  min-height: 1.5em;
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
}
.ttsv-state.is-bad {
  color: #b42318;
}

@media (max-width: 1024.98px) {
  .ttsv-panels {
    grid-template-columns: minmax(0, 1fr);
  }
  .ttsv-panel .tcard-head {
    min-height: 68px;
    padding: 12px 10px;
  }
  .ttsv-step {
    min-height: 44px;
    font-size: 1rem;
  }
  .ttsv-page #source-textarea {
    min-height: 190px;
  }
  .ttsv-actions {
    margin-top: 0;
  }
}
@media (max-width: 480px) {
  .ttsv-step {
    gap: 8px;
    min-height: 42px;
    padding: 0 14px 0 6px;
    font-size: 0.95rem;
  }
  .ttsv-step-num {
    width: 28px;
    height: 28px;
  }
  .ttsv-voices {
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 6px;
  }
  .ttsv-avatar {
    width: 48px;
    height: 48px;
  }
  .ttsv-actions .ttsv-listen {
    flex: 1 1 auto;
  }
  .ttsv-panel--voice .tcard-head .tcard-label {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .ttsv-listen.is-loading .ttsv-spinner {
    animation-duration: 2.4s;
  }
  .ttsv-voice:hover,
  .ttsv-clear:hover {
    transform: none;
  }
}

/* ---- Dark theme: the fixed colour above ---- */
html[data-theme="dark"] .ttsv-state.is-bad {
  color: #ff9aa5;
}
