/* word-pronunciation.css — the Pronunciation Popover (GLOSSARY.md). */

.pron-passage .pron-word {
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.pron-passage .pron-word:hover {
  background: var(--control-hover-soft);
}

/* The word the open card points at, kept marked while arrow keys walk. */
.pron-passage .pron-word--active {
  background: var(--control-hover-soft);
  box-shadow: 0 0 0 2px var(--control-hover-soft);
}

/* Words the voice still owes: stepped past faster than speech, marked with
   a soft dotted trail that clears as the audio catches up. */
.pron-passage .pron-word--queued {
  text-decoration: underline dotted var(--ink-muted);
  text-underline-offset: 3px;
}

/* Inert while a recording is in progress: no hand, no hover, no hint. */
.pron-passage--disabled .pron-word {
  cursor: inherit;
}

.pron-passage--disabled .pron-word:hover {
  background: none;
}

/* Our own display rule beats the UA's [hidden] { display: none }, so the
   attribute needs an explicit author-side answer — without this, close()
   "worked" in every test yet the card never left the screen. */
.pron-popover[hidden] {
  display: none;
}

/* The Stress Picture owns the upper region. Playback and Try it share the
   footer below it; the × remains quiet corner chrome. */
.pron-popover {
  /* How tall the footer stands. Named here because two rules answer to it:
     the footer's own floor, and the room left above it for the Word Emblem,
     which must stop clear of the play rail. */
  --pron-footer-height: 52px;
  /* How the prompt side's Stress Picture stands, width to height: its
     266 by 88 drawing laid 126 per cent wide (`stress-picture.css`, the prompt
     crop), so 266 by 88 x 1.26. Named because a word with no saying lays its
     absence in the picture's room at this same shape, and the card must be
     the same height either way. Move it with the picture's viewBox or crop. */
  --pron-picture-aspect: 266 / 110.88;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: absolute;
  z-index: 1000;
  box-sizing: border-box;
  width: min(272px, calc(100vw - 16px));
  padding: 4px 8px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  /* Floats above the passage, raised rather than outlined. */
  box-shadow: var(--shadow-float);
}

/* The speech-bubble tail: a rotated square whose two outward edges carry the
   border, aimed at the clicked word via --pron-arrow-x (set from JS). Its
   inward half paints over the card's own border line, so the notch is open. */
.pron-popover::after {
  content: "";
  position: absolute;
  bottom: -7px;
  left: calc(var(--pron-arrow-x, 24px) - 6px);
  width: 12px;
  height: 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transform: rotate(45deg);
}

.pron-popover--below::after {
  bottom: auto;
  top: -7px;
  border-right: 0;
  border-bottom: 0;
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
}

/* Dismissal stays ghost chrome but is large enough to read at a glance. It
   hugs the card's top-right corner, above the protected picture ink. */
.pron-popover__close {
  position: absolute;
  top: 0;
  right: 0;
  width: 29px;
  height: 29px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--ink-placeholder);
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.pron-popover__close:hover {
  color: var(--ink-slate);
  background: var(--control-hover-soft);
}

/* The rail's three direct actions share one control shape; their SVG and
   interaction state provide the distinction. */
.pron-popover__playback,
.pron-popover__try {
  position: relative;
  z-index: 1;
  width: var(--pron-action-width);
  height: var(--pron-action-size);
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--ink-secondary);
  background: transparent;
  border: 0;
  border-radius: var(--pill);
  cursor: pointer;
  transition: color 0.15s ease, transform 0.15s ease;
}

.pron-popover__playback:hover {
  color: color-mix(in srgb, var(--good) 84%, black);
  transform: scale(1.06);
}

.pron-popover__playback svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.pron-popover__playback[data-action="normal"] svg {
  transform: translateX(1px);
}

/* The footer is one physical surface split into left and right word-navigation
   halves. The action rail bridges their seam on a raised platform. */
.pron-popover__bottom {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  gap: 4px;
  min-height: var(--pron-footer-height);
  margin: 0 -8px -8px;
  padding: 8px 4px;
  background: color-mix(in srgb, var(--good) 13%, var(--surface));
  border-radius: 0 0 var(--radius) var(--radius);
}

.pron-popover__actions {
  /* One square cell at every viewport (DECISIONS: the island reads the same
     everywhere), so the lens that sits in it is the same circle on a phone
     and on a desktop rather than an oval on one of them. */
  --pron-action-width: 44px;
  --pron-action-size: 44px;
  /* The lens is round, so it takes the smaller of the cell's two sides. */
  --pron-lens-size: min(var(--pron-action-width), var(--pron-action-size));
  position: relative;
  z-index: 2;
  isolation: isolate;
  display: flex;
  width: max-content;
  min-width: 0;
  justify-self: center;
  align-items: center;
  padding: 4px;
  overflow: hidden;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--control-border) 72%, transparent);
  border-radius: var(--pill);
  box-shadow:
    0 5px 12px color-mix(in srgb, var(--ink) 14%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--surface) 88%, transparent),
    var(--shadow-sm);
  transform: translateY(-2px);
  backdrop-filter: blur(14px) saturate(135%);
  touch-action: pan-y;
  cursor: grab;
}

/* The lens reads as the same shape at every viewport: a circle centred in its
   cell, so a cell that is wider than it is tall gains side room rather than
   stretching into an oval. Sliding still steps by one cell width. */
.pron-popover__actions::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: calc(4px + (var(--pron-action-size) - var(--pron-lens-size)) / 2);
  left: calc(4px + (var(--pron-action-width) - var(--pron-lens-size)) / 2);
  width: var(--pron-lens-size);
  height: var(--pron-lens-size);
  background: color-mix(in srgb, var(--good) 15%, var(--surface));
  border: 1px solid color-mix(
    in srgb,
    var(--skill-color, var(--skill-speaking)) 42%,
    var(--surface)
  );
  border-radius: var(--pill);
  box-shadow:
    0 0 0 2px color-mix(
      in srgb,
      var(--skill-color, var(--skill-speaking)) 14%,
      transparent
    ),
    0 3px 10px color-mix(in srgb, var(--ink) 12%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--surface) 92%, transparent);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.18s ease;
}

.pron-popover__actions[data-engaged][data-active="slow"]::before,
.pron-popover__actions[data-engaged][data-active="normal"]::before {
  background: color-mix(in srgb, var(--good) 15%, var(--surface));
}

.pron-popover__actions[data-active="normal"]::before {
  transform: translateX(var(--pron-action-width));
}

.pron-popover__actions[data-engaged][data-active="try"]::before {
  transform: translateX(calc(var(--pron-action-width) * 2));
  background: color-mix(in srgb, var(--skill-color, var(--skill-speaking)) 13%, var(--surface));
}

.pron-popover__actions--dragging {
  cursor: grabbing;
}

.pron-popover__actions.pron-popover__actions--dragging::before,
.pron-popover__actions[data-engaged].pron-popover__actions--dragging::before {
  transform: translateX(var(--pron-drag-x));
  transition: none;
}

/* The room the picture is given: the card's own gutters are opened up for
   it, and what overflows them is hidden. The picture styles itself. */
.pron-popover__stress {
  /* Positioned so the curve paints over the Word Emblem's layer below it,
     which is absolutely placed and would otherwise cover it. */
  position: relative;
  margin: 0 -8px;
  padding: 8px 0 0;
  overflow: hidden;
}

/* The room the Word Emblem is fitted into (ADR-0126): behind the card's
   middle, clear of the footer's play rail. The small padding is the margin
   the emblem is scaled to fit inside — the drawing is centred in what is
   left, whole and never cropped, and never touches the card's edges. */
.pron-popover__emblem {
  position: absolute;
  inset: 4px 8px var(--pron-footer-height);
  padding: 4px;
  overflow: hidden;
  pointer-events: none;
}

.pron-popover__verdict {
  grid-column: 1 / -1;
}

.pron-popover__stress:empty {
  display: none;
}

/* A word the bank has no saying for (`paintAbsent`): the picture's room at
   the picture's shape, so the card is never a bare play rail, holding a ghost
   of the picture. The dashed line is the Sample's floor, 73 per cent of the
   way down, where a painted picture's unstressed syllables lie; the words sit
   above it, where the respelling would, in the label face. Both are quiet
   ink: this is a note about the lexicon, not an error. */
.pron-popover__absent {
  position: relative;
  aspect-ratio: var(--pron-picture-aspect);
}

.pron-popover__absent svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.pron-popover__absent line {
  fill: none;
  stroke: var(--ink-placeholder);
  stroke-width: 1.5;
  stroke-dasharray: 4 6;
  stroke-linecap: round;
  /* The drawing is stretched to the room, so the stroke is kept to screen
     pixels: the dashes stay round and even at any card width. */
  vector-effect: non-scaling-stroke;
}

.pron-popover__absent-words {
  position: absolute;
  right: 0;
  bottom: calc(27% + 12px);
  left: 0;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.14em;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink-tertiary);
}

.pron-popover__key {
  position: absolute;
  z-index: 1;
  top: 8px;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--ink-secondary);
  background: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  border-radius: 50%;
  transform: none;
  cursor: pointer;
  transition:
    color 0.15s ease,
    background 0.15s ease,
    box-shadow 0.12s ease,
    transform 0.08s ease;
}

.pron-popover__key--prev {
  left: 4px;
}

.pron-popover__key--next {
  right: 4px;
}

.pron-popover__key:hover {
  color: var(--skill-color, var(--brand-blue));
}

.pron-popover__key:active,
.pron-popover__key--keyboard-active {
  color: var(--skill-color, var(--brand-blue));
  background: color-mix(in srgb, var(--good) 15%, transparent);
  border-color: color-mix(
    in srgb,
    var(--skill-color, var(--skill-speaking)) 62%,
    var(--surface)
  );
  box-shadow:
    0 0 0 1px color-mix(
      in srgb,
      var(--skill-color, var(--skill-speaking)) 28%,
      transparent
    ),
    inset 0 3px 5px color-mix(in srgb, var(--ink) 20%, transparent);
  transform: translateY(2px);
  transition-duration: 0.05s;
}

.pron-popover__key:hover svg {
  transform: translateY(-1px) scale(1.06);
}

.pron-popover__key svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.12s cubic-bezier(0.2, 0.9, 0.3, 1.35);
}

/* The close control carries an invisible halo that grows its touch target to
   the 44px the style guide asks of phone portrait. */
.pron-popover__close::before {
  content: "";
  position: absolute;
  inset: -10px;
}

.pron-popover__try:hover {
  color: color-mix(in srgb, var(--skill-color, var(--skill-speaking)) 84%, black);
  transform: scale(1.06);
}

.pron-popover__actions[data-engaged][data-active="slow"] [data-action="slow"],
.pron-popover__actions[data-engaged][data-active="normal"] [data-action="normal"] {
  color: var(--good);
}

.pron-popover__actions[data-engaged][data-active="try"] [data-action="try"] {
  color: var(--skill-color, var(--skill-speaking));
}

/* Engaged actions retain their own hue on hover; these selectors deliberately
   outrank the selected-action colour above rather than switching hue. */
.pron-popover__actions[data-engaged][data-active] .pron-popover__playback:hover {
  color: color-mix(in srgb, var(--good) 84%, black);
}

.pron-popover__actions[data-engaged][data-active] .pron-popover__try:hover {
  color: color-mix(in srgb, var(--skill-color, var(--skill-speaking)) 84%, black);
}

.pron-popover__try-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pron-popover__try svg {
  width: 20px;
  height: 20px;
  transform: translateY(-1px);
}

/* A live take deepens the purple tint and breathes a ring around the
   microphone: recording state without adding text to the compact control. */
.pron-popover--trying .pron-popover__actions[data-active="try"]::before {
  background: color-mix(in srgb, var(--skill-color, var(--skill-speaking)) 22%, var(--surface));
}

.pron-popover--trying .pron-popover__try {
  transform: scale(1.04);
  cursor: default;
}

.pron-popover--trying .pron-popover__try-icon::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid currentColor;
  animation: pron-orb-ring 1.2s ease-out infinite;
}

@keyframes pron-orb-ring {
  to {
    transform: scale(1.6);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pron-popover--trying .pron-popover__try-icon::after {
    animation: none;
    inset: -4px;
    opacity: 0.6;
  }
}

/* The settled take, in the Issue Popover's language (speaking-feedback-card
   .sfc-pop[data-verdict]): one verdict colour per kind, spent as a 4% flood
   over the card's own surface with a short swell as it lands. */
.pron-popover[data-verdict="pass"] { --pron-verdict: var(--good); }
.pron-popover[data-verdict="miss"] { --pron-verdict: var(--rubric); }
.pron-popover[data-verdict="error"] { --pron-verdict: var(--score-grammar); }

.pron-popover[data-verdict] {
  background: color-mix(in srgb, var(--pron-verdict) 4%, var(--surface));
  animation: pron-pop-flood 0.9s ease-out;
}

/* The tail is a second box painting the same surface, so it floods with the
   card — otherwise the notch stays white against a tinted card. */
.pron-popover[data-verdict]::after {
  background: color-mix(in srgb, var(--pron-verdict) 4%, var(--surface));
}

@keyframes pron-pop-flood {
  45% {
    border-color: color-mix(in srgb, var(--pron-verdict) 42%, var(--border));
    background: color-mix(in srgb, var(--pron-verdict) 8%, var(--surface));
    box-shadow: var(--shadow-float), 0 0 0 5px color-mix(in srgb, var(--pron-verdict) 7%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pron-popover[data-verdict] {
    animation: none;
  }
}

/* The verdict: the mark leads, large and in the verdict's colour, the words
   beside it in supporting text. One centred line under the pill. */
.pron-popover__verdict {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.4;
  text-align: center;
  color: var(--pron-verdict, var(--ink-secondary));
}

.pron-popover__mark {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.pron-popover__mark[hidden],
.pron-popover__verdict[hidden] {
  display: none;
}
