/* =============================================================================
 *  tts-highlight.css
 *
 *  Load this AFTER your own style.css so it layers on top:
 *      <link rel="stylesheet" href="style.css">
 *      <link rel="stylesheet" href="tts-highlight.css">
 *
 *  It styles four word states and nothing else. It deliberately does not touch
 *  your layout, your fonts, your colours, or the hover you already have on
 *  .reader-word.
 *
 *  Written against your actual stylesheet, which is dark: black page, white
 *  text, red accents. That matters more than it sounds, and the reason is in
 *  the note on the sentence tint below.
 * ========================================================================== */

:root{
  /* The word being spoken. Opaque and high contrast on purpose, so it reads
     the same on a black page or a white one. */
  --tts-current-bg:   #ffd85e;
  --tts-current-ink:  #1a1206;

  /* The sentence around it. TRANSLUCENT, not a solid colour.

     A solid pale tint is the obvious choice and it is wrong here. Your page
     sets .content { color: white }, so a solid cream background under white
     text makes the entire current sentence unreadable, which is the opposite
     of helpful. A translucent wash tints whatever is behind it and leaves your
     text colour alone, so the same value works on your dark theme and on a
     light one without either having to know about the other. */
  --tts-sentence-bg:  rgba(255, 216, 94, .28);

  /* How far already read text drops back. */
  --tts-spoken-fade:  .55;
}

/* Every word is a click target for seeking, so it needs a cursor and a small
   rounded box for the highlight to sit in.

   Only the fade out is animated. The spoken word itself must snap on with no
   transition at all: at a normal reading pace a word lasts about 300ms, so
   even a 120ms fade leaves the highlight permanently half drawn and the whole
   effect reads as blurry rather than crisp. */
.reader-word{
  cursor: pointer;
  border-radius: 4px;
  transition: opacity .3s linear;
}

/* The sentence being read, so the eye has context for where it is. */
.reader-word.is-sentence{
  background-color: var(--tts-sentence-bg);
}

/* The current word. Background colour change, as you asked for. */
.reader-word.is-speaking{
  background-color: var(--tts-current-bg);
  color: var(--tts-current-ink);
  box-shadow: 0 0 0 3px var(--tts-current-bg);
  transition: none;
}

/* Everything already read on this page. */
.reader-word.was-spoken{
  opacity: var(--tts-spoken-fade);
}

/* There is deliberately no :hover rule in this file.

   Your style.css already gives .reader-word a red hover, and this file loads
   after yours, so any hover defined here would silently replace your design
   without you asking for it. Yours is left exactly as you wrote it. */

/* French typography puts a space before ; : ! ? and the guillemets, so those
   land as tokens of their own. Nothing is ever spoken for them, so they must
   not look or behave like a clickable word. */
.reader-word.is-punct{
  cursor: default;
  background-color: transparent;
}

/* Respect a reader who has asked the system to reduce motion. */
@media (prefers-reduced-motion: reduce){
  .reader-word{ transition: none; }
  html{ scroll-behavior: auto; }
}
