/* knotis-readaloud.css — Read Aloud inline header controls */

/* ── Container ──────────────────────────────────────────────────────────── */

.knotis-readaloud-trigger {
  align-items: center;
  display: inline-flex;
  gap: 0;
  position: relative;
}

/* ── Headphones button ──────────────────────────────────────────────────── */

.knotis-readaloud-hp {
  align-items: center;
  background: transparent;
  border: none;
  color: var(--md-default-fg-color);
  cursor: pointer;
  display: flex;
  padding: 0.4rem;
  flex-shrink: 0;
}

.knotis-readaloud-hp:hover {
  color: var(--knotis-accent-color);
}

.knotis-readaloud--expanded .knotis-readaloud-hp {
  color: var(--knotis-accent-color);
}

/* ── Panel (hidden by default, shown on expand) ──────────────────────────── */

.knotis-readaloud-panel {
  align-items: center;
  display: inline-flex;
  gap: 0.2rem;
  margin-right: 0;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateX(8px);
  transition: max-width 0.22s ease, opacity 0.18s ease, transform 0.22s ease,
    margin-right 0.22s ease;
}

.knotis-readaloud-panel[hidden] {
  display: none !important;
}

.knotis-readaloud--expanded .knotis-readaloud-panel {
  max-width: 48rem;
  opacity: 1;
  margin-right: 0.15rem;
  pointer-events: auto;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .knotis-readaloud-panel {
    transition: none;
  }
}

/* On narrow screens the inline panel would overflow the header; float it
   below the headphones button as an anchored popover instead. */
@media screen and (max-width: 768px) {
  .knotis-readaloud--expanded .knotis-readaloud-panel {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.3rem;
    margin-right: 0;
    max-width: calc(100vw - 1.5rem);
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.4rem 0.5rem;
    padding: 0.5rem 0.6rem;
    background: var(--md-default-bg-color);
    border: 1px solid var(--md-default-fg-color--lightest, rgba(0, 0, 0, 0.12));
    border-radius: 0.4rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    z-index: 10;
  }
}

/* ── Buttons in panel ───────────────────────────────────────────────────── */

.knotis-readaloud-btn {
  align-items: center;
  background: transparent;
  border: none;
  color: var(--md-default-fg-color);
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  padding: 0.35rem 0.25rem;
  border-radius: 0.25rem;
  flex-shrink: 0;
}

.knotis-readaloud-btn:hover {
  background: var(--md-default-fg-color--lightest, rgba(0,0,0,0.07));
  color: var(--knotis-accent-color);
}

/* Play button gets a subtle fill */
.knotis-readaloud-play {
  background: var(--knotis-accent-fill-color);
  border-radius: 50%;
  color: var(--knotis-accent-on-color);
  height: 32px;
  width: 32px;
  padding: 0;
}

.knotis-readaloud-play:hover {
  background: var(--knotis-accent-fill-color);
  color: var(--knotis-accent-on-color);
  opacity: 0.85;
}

.knotis-readaloud-play-icon {
  align-items: center;
  display: flex;
  justify-content: center;
}

/* ── Settings (speed / voice) ───────────────────────────────────────────── */

.knotis-readaloud-setting {
  align-items: center;
  display: flex;
  gap: 0.25rem;
}

.knotis-readaloud-setting__select {
  background: var(--md-default-bg-color);
  border: 1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,0.15));
  border-radius: 0.2rem;
  color: var(--md-default-fg-color);
  cursor: pointer;
  font-size: 0.72rem;
  padding: 0.15rem 0.3rem;
  max-width: 11rem;
}

.knotis-readaloud-setting__select:focus {
  border-color: var(--knotis-accent-color);
  outline: none;
}

[data-md-color-scheme="slate"] .knotis-readaloud-setting__select {
  border-color: rgba(255,255,255,0.12);
}

[data-md-color-scheme="slate"] .knotis-readaloud-btn:hover {
  background: rgba(255,255,255,0.07);
}

/* ── No-voices warning ──────────────────────────────────────────────────── */

.knotis-readaloud-no-voices {
  color: var(--md-default-fg-color--light);
  font-size: 0.65rem;
  line-height: 1.2;
  max-width: 8rem;
  white-space: normal;
}

.knotis-readaloud-play:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* ── Click-to-read affordance (panel open) ──────────────────────────────── */

.knotis-readaloud--armed article.md-content__inner :is(p, li, h1, h2, h3, h4, h5, h6, blockquote) {
  cursor: pointer;
}

.knotis-readaloud--armed article.md-content__inner :is(p, h1, h2, h3, h4, h5, h6, blockquote):hover,
.knotis-readaloud--armed article.md-content__inner li:hover {
  background-color: var(--knotis-block-hover-background, rgba(245, 196, 114, 0.12));
  border-radius: 3px;
  transition: background-color 0.15s ease;
}

/* ── Active block while reading ─────────────────────────────────────────── */

.knotis-readaloud--active {
  background-color: var(--knotis-block-highlight-background, rgba(245, 196, 114, 0.35));
  border-radius: 3px;
  outline: 2px solid var(--knotis-block-highlight-outline, #f5c472);
  outline-offset: 3px;
  scroll-margin-top: 5rem;
  scroll-margin-bottom: 2rem;
  transition: background-color 0.2s ease, outline-color 0.2s ease;
}
