/* Shironeko — "Listen" text-to-speech + "Share" row on single posts.
   Adapted from the Made Good Designs widgets, restyled for the dark theme. */

/* ===========================
   LISTEN (web narration)
   =========================== */
.mgd-listen-wrap {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 4px;
}

.mgd-listen,
.mgd-listen__speed,
.mgd-listen__voice {
  font-family: var(--font-body);
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

.mgd-listen {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 12px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  color: var(--color-heading);
}

.mgd-listen__speed {
  padding: 7px 12px;
  min-width: 44px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
}

.mgd-listen__voice {
  max-width: 190px;
  padding: 7px 28px 7px 12px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'><path fill='%23c5c5c5' d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  text-overflow: ellipsis;
}
.mgd-listen__voice option { color: var(--color-text); background: var(--color-surface); }

.mgd-listen:hover,
.mgd-listen__speed:hover,
.mgd-listen__voice:hover {
  background-color: var(--color-surface-hover);
  border-color: var(--color-accent);
}

.mgd-listen:focus-visible,
.mgd-listen__speed:focus-visible,
.mgd-listen__voice:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

.mgd-listen__icon { display: inline-flex; align-items: center; color: var(--color-accent-hover); }
.mgd-listen__label { white-space: nowrap; }

/* Play/pause icon swap driven by .is-playing on the button. */
.mgd-listen .mgd-i-pause { display: none; }
.mgd-listen.is-playing .mgd-i-play { display: none; }
.mgd-listen.is-playing .mgd-i-pause { display: inline; }

.mgd-listen.is-playing {
  color: #fff;
  background-color: var(--color-accent);
  border-color: var(--color-accent);
}
.mgd-listen.is-playing .mgd-listen__icon { color: #fff; }

/* Word currently being spoken. */
.mgd-w--on {
  color: var(--color-heading);
  background: rgba(197, 97, 79, 0.35);
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(197, 97, 79, 0.25);
}

/* ===========================
   SHARE ROW
   =========================== */
.mgd-share {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 4px;
}

.mgd-share__label {
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.mgd-share__btns {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mgd-share__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  cursor: pointer;
  text-decoration: none;
  -webkit-appearance: none;
  appearance: none;
  transition: color .15s ease, background .15s ease, border-color .15s ease, transform .1s ease;
}

.mgd-share__btn:hover { transform: translateY(-1px); }
.mgd-share__btn:focus-visible { outline: 2px solid var(--color-gold); outline-offset: 2px; }

/* Brand-tinted hover per network (icons stay monochrome until hover). */
.mgd-share__btn--x:hover    { color: #000; background: #fff; border-color: #fff; }
.mgd-share__btn--fb:hover   { color: #fff; background: #1877f2; border-color: #1877f2; }
.mgd-share__btn--wa:hover   { color: #fff; background: #25d366; border-color: #25d366; }
.mgd-share__btn--em:hover   { color: #fff; background: #5a6b7b; border-color: #5a6b7b; }
.mgd-share__btn--copy:hover { color: #fff; background: var(--color-accent); border-color: var(--color-accent); }

/* Copy-link confirmation toast. */
.mgd-share__toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  z-index: 99999;
  padding: 10px 18px;
  font: 600 14px/1.2 var(--font-body);
  color: #fff;
  background: var(--color-accent);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.mgd-share__toast.is-on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* The single-post header is centred. */
.article-header .mgd-listen-wrap,
.article-header .mgd-share { justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  .mgd-listen, .mgd-listen__speed, .mgd-listen__voice,
  .mgd-share__btn, .mgd-share__toast { transition: none; }
}
