/* TTS Reader for DataLife Engine. Colours can be changed on the site through these variables:
   :root { --tts-accent: #686de0; --tts-bg: rgba(104,109,224,.1); --tts-mark: rgba(104,109,224,.14); } */
:root {
  --tts-accent: #4f6bed;
  --tts-bg: rgba(79, 107, 237, .1);
  --tts-mark: rgba(79, 107, 237, .14);
}
.tts-reader {
  display: none;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
  line-height: 1;
}
html.tts-supported .tts-reader { display: inline-flex; }
html.tts-supported .tts-reader.tts-novoice { display: none; }

.tts-reader .tts-btn,
.tts-reader button.tts-btn,
.tts-size button.tts-btn {
  /* !important: site themes often style every button; the reader keeps its own look */
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: auto !important;
  height: 32px !important;
  min-width: 32px;
  margin: 0 !important;
  padding: 0 12px !important;
  border: 0 !important;
  border-radius: 16px !important;
  background: var(--tts-bg) !important;
  color: var(--tts-accent) !important;
  font-family: inherit;
  font-size: 13px !important;
  font-weight: 600 !important;
  line-height: 1 !important;
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: none !important;
  text-shadow: none !important;
  text-transform: none !important;
  transition: background .2s, color .2s;
}
/* Hover only on devices with a mouse: on phones a tapped button would stay filled */
@media (hover: hover) {
  .tts-reader .tts-btn:hover, .tts-size .tts-btn:not(:disabled):hover { background: var(--tts-accent) !important; color: var(--tts-on-accent, #fff) !important; }
}
.tts-reader .tts-btn:focus-visible, .tts-size .tts-btn:focus-visible { background: var(--tts-accent) !important; color: var(--tts-on-accent, #fff) !important; outline: none; }
.tts-reader .tts-btn[hidden] { display: none !important; }
.tts-reader .tts-stop { padding: 0 !important; }
.tts-reader .tts-speed { padding: 0 10px !important; font-variant-numeric: tabular-nums; }

/* Icons are drawn with CSS so the module needs no icon font */
.tts-reader .tts-ic { position: relative; display: inline-block; width: 12px; height: 12px; flex: 0 0 12px; }
.tts-reader .tts-main .tts-ic::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0;
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent currentColor;
}
.tts-reader[data-state="playing"] .tts-main .tts-ic::before,
.tts-reader[data-state="playing"] .tts-main .tts-ic::after {
  content: "";
  left: 2px;
  width: 3px;
  height: 12px;
  border: 0;
  background: currentColor;
  border-radius: 1px;
}
.tts-reader[data-state="playing"] .tts-main .tts-ic::after { position: absolute; top: 0; left: 7px; }
.tts-reader .tts-stop .tts-ic::before {
  content: "";
  position: absolute;
  inset: 1px;
  background: currentColor;
  border-radius: 2px;
}

/* The block being read */
.tts-current {
  background: var(--tts-mark, rgba(79, 107, 237, .14));
  border-radius: 6px;
  box-shadow: 0 0 0 4px var(--tts-mark, rgba(79, 107, 237, .14));
  transition: background .3s, box-shadow .3s;
}
tr.tts-current { box-shadow: none; }

@media (prefers-reduced-motion: reduce) {
  .tts-reader .tts-btn, .tts-current { transition: none; }
}

/* Reading time ("Читать 4 минуты") */
.tts-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
  white-space: nowrap;
  font-size: inherit;
  opacity: .8;
}
.tts-time .tts-clock {
  position: relative;
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  box-sizing: border-box;
}
.tts-time .tts-clock::before,
.tts-time .tts-clock::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 50%;
  width: 1.5px;
  margin-left: -.75px;
  background: currentColor;
  transform-origin: 50% 100%;
}
.tts-time .tts-clock::before { height: 3.5px; }
.tts-time .tts-clock::after { height: 2.5px; transform: rotate(90deg); }
.tts-time + .tts-reader { margin-left: 10px; }

/* Voice choice: a person icon and a menu of the device's voices */
.tts-reader { position: relative; }
.tts-reader .tts-voice { padding: 0 !important; }
.tts-reader .tts-voice .tts-ic::before {
  content: "";
  position: absolute;
  left: 3.5px;
  top: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.tts-reader .tts-voice .tts-ic::after {
  content: "";
  position: absolute;
  left: 1px;
  bottom: 0;
  width: 10px;
  height: 5.5px;
  border-radius: 5px 5px 1px 1px;
  background: currentColor;
}
.tts-menu {
  position: absolute;
  top: calc(100% + 6px);
  z-index: 1000;
  min-width: 220px;
  max-width: min(320px, 90vw);
  max-height: 300px;
  overflow-y: auto;
  padding: 6px;
  border-radius: 12px;
  background: var(--tts-menu-bg, #fff);
  color: var(--tts-menu-fg, #222);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  line-height: 1.3;
}
.tts-menu .tts-vopt {
  display: flex !important;
  align-items: baseline;
  gap: 8px;
  width: 100% !important;
  height: auto !important;
  margin: 0 !important;
  padding: 9px 12px 9px 30px !important;
  position: relative;
  border: 0 !important;
  border-radius: 8px !important;
  background: none !important;
  color: inherit !important;
  font: inherit;
  font-size: 14px !important;
  font-weight: 400 !important;
  text-align: left !important;
  text-transform: none !important;
  box-shadow: none !important;
  cursor: pointer;
}
.tts-menu .tts-vopt small { opacity: .6; font-size: 12px; }
.tts-menu .tts-vopt:focus-visible { background: var(--tts-bg) !important; outline: none; }
.tts-menu .tts-vopt[aria-checked="true"] { color: var(--tts-accent) !important; font-weight: 600 !important; }
.tts-menu .tts-vopt[aria-checked="true"]::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 5px;
  height: 9px;
  margin-top: -6px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
@media (hover: hover) {
  .tts-menu .tts-vopt:hover { background: var(--tts-bg) !important; }
}

/* Text size buttons: shown only when the script runs */
.tts-size { display: none; align-items: center; gap: 6px; vertical-align: middle; line-height: 1; }
html.tts-js .tts-size { display: inline-flex; }
.tts-reader + .tts-size, .tts-time + .tts-size { margin-left: 10px; }
.tts-size .tts-btn { padding: 0 !important; width: 36px !important; font-size: 14px !important; letter-spacing: -.5px; }
.tts-size .tts-smaller { font-size: 12px !important; }
.tts-size .tts-btn:disabled { opacity: .4; cursor: default; }

/* ---------- Looks, chosen in the admin panel ---------- */
/* solid: filled with the accent colour */
:is(.tts-reader, .tts-size).tts-st-solid .tts-btn { background: var(--tts-accent) !important; color: var(--tts-on-accent, #fff) !important; }
:is(.tts-reader, .tts-size).tts-st-solid .tts-btn:focus-visible { filter: brightness(1.1); }
/* outline: a thin frame, transparent inside */
:is(.tts-reader, .tts-size).tts-st-outline .tts-btn { background: transparent !important; box-shadow: inset 0 0 0 1.5px var(--tts-accent) !important; }
/* minimal: just coloured text, like a link */
:is(.tts-reader, .tts-size).tts-st-minimal .tts-btn { background: transparent !important; padding-left: 6px !important; padding-right: 6px !important; }
:is(.tts-reader, .tts-size).tts-st-minimal .tts-btn:focus-visible { text-decoration: underline; }
/* dark: dark buttons for light sites */
:is(.tts-reader, .tts-size).tts-st-dark .tts-btn { background: #23262f !important; color: #fff !important; }
@media (hover: hover) {
  :is(.tts-reader, .tts-size).tts-st-solid .tts-btn:not(:disabled):hover { filter: brightness(1.1); }
  :is(.tts-reader, .tts-size).tts-st-outline .tts-btn:not(:disabled):hover,
  :is(.tts-reader, .tts-size).tts-st-dark .tts-btn:not(:disabled):hover { background: var(--tts-accent) !important; color: var(--tts-on-accent, #fff) !important; }
  :is(.tts-reader, .tts-size).tts-st-minimal .tts-btn:not(:disabled):hover { background: var(--tts-bg) !important; color: var(--tts-accent) !important; }
}

/* Shapes */
:is(.tts-reader, .tts-size).tts-sh-rounded .tts-btn { border-radius: 8px !important; }
:is(.tts-reader, .tts-size).tts-sh-square .tts-btn { border-radius: 2px !important; }

/* Sizes */
:is(.tts-reader, .tts-size).tts-sz-small .tts-btn { height: 26px !important; min-width: 26px; font-size: 12px !important; }
:is(.tts-reader, .tts-size).tts-sz-small .tts-btn.tts-stop,
:is(.tts-reader, .tts-size).tts-sz-small .tts-btn.tts-voice { width: 26px !important; }
.tts-size.tts-sz-small .tts-btn { width: 30px !important; }
:is(.tts-reader, .tts-size).tts-sz-large .tts-btn { height: 40px !important; min-width: 40px; font-size: 15px !important; }
.tts-reader.tts-sz-large .tts-btn:not(.tts-main) { width: 40px !important; }
.tts-size.tts-sz-large .tts-btn { width: 44px !important; }

/* Icons only: the "Listen" button keeps just the play/pause icon */
.tts-reader.tts-icons .tts-main { padding: 0 !important; width: 32px !important; }
.tts-reader.tts-icons.tts-sz-small .tts-main { width: 26px !important; }
.tts-reader.tts-icons.tts-sz-large .tts-main { width: 40px !important; }
.tts-reader.tts-icons .tts-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tts-reader .tts-stop, .tts-reader .tts-voice { width: 32px !important; }

/* Text colour from the settings (normal state; on hover the text follows --tts-on-accent) */
:is(.tts-reader, .tts-size).tts-fg .tts-btn:not(:hover):not(:focus-visible) { color: var(--tts-fg) !important; }
@media (hover: none) {
  :is(.tts-reader, .tts-size).tts-fg .tts-btn { color: var(--tts-fg) !important; }
}
