/*========================================
 General
========================================*/


/* -----------------------------------
 Audio Reader - Notes
 -----------------------------------
 Injected by the course-audio-controls script, which appends its markup to
 document.body. Two deliberate departures from the coding standards, both
 forced by that:


 1. @media is used instead of @container. Container queries require an
    ancestor with container-type set. Both elements are position: fixed and
    live on document.body, outside .course-content, so there is no
    container to query and their size relationship genuinely is to the
    viewport rather than to a container.
 2. The markup sits outside .course-content. A viewport-fixed overlay
    cannot be nested inside the page body container.


 Only three !important declarations remain, each noted where it appears.
----------------------------------- */




/* -----------------------------------
 Audio Reader - Toggle Button
----------------------------------- */
#reader-toggle {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 99999;
  padding: 0.9375rem;
  border: 0.0625rem solid var(--ms-neutral-500, #848687);
  border-radius: 3.125rem;

  /* Off: light circle, dark icon. 14.99:1. */
  background-color: var(--ms-neutral-100, #fafafa);
  color: var(--ms-neutral-900, #0d0d0d);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 0.25rem 0.375rem rgba(0, 0, 0, 0.2);

  &:hover {
    background-color: var(--ms-neutral-200, #f2f2f2);
  }

  svg {
    width: 1.375rem;
    height: 1.375rem;
    display: block;
  }

  &:focus-visible {
    outline: 0.125rem solid var(--ms-neutral-900, #0d0d0d);
    outline-offset: 0.125rem;
  }

  /* On: dark circle, light icon. Same 14.99:1, inverted. */
  &[aria-expanded="true"] {
    background-color: var(--ms-navy-900, #1e2448);
    color: #fff;
    border-color: var(--ms-navy-900, #1e2448);

    &:hover {
      background-color: var(--ms-navy-800, #242c56);
    }

    &:focus-visible {
      outline-color: #fff;
    }
  }
}

/* -----------------------------------
 Audio Reader - Toolbar
----------------------------------- */
#reader-toolbar {
  position: fixed;
  top: 1rem;
  /* Centered with left/right + auto margins rather than left: 50% and a
     transform. With left: 50%, the browser only allows the toolbar half the
     screen width, so the controls wrapped onto a second row. */
  left: 0;
  right: 0;
  margin-inline: auto;
  z-index: 99999;
  width: fit-content;
  /* Stops a long system voice name pushing the close button off screen. */
  max-width: calc(100vw - 2rem);
  box-sizing: border-box;
  padding: 0.625rem 1.25rem;
  border-radius: 1.875rem;
  background-color: var(--ms-neutral-800, #2a2a2b);
  color: #fff;
  box-shadow: 0 0.25rem 0.375rem rgba(0, 0, 0, 0.1);


  /* Control row layout. Moved out of the script's inline style attribute so
     base design lives in the CSS panel rather than inline. */
  .reader-toolbar__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    white-space: nowrap;
  }


  /* Shared sizing for every control in the row. */
  button,
  select {
    height: 2.125rem;
    box-sizing: border-box;
    margin: 0;
    padding: 0 0.75rem;
    border: 0.0625rem solid transparent;
    border-radius: 0.25rem;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;


    &:focus-visible {
      outline: 0.125rem solid var(--ms-yellow-600, #fecc80);
      outline-offset: 0.125rem;
    }
  }


  /* Icon buttons. The SVG needs explicit sizing for the reason above. */
  button {
    display: inline-flex;
    align-items: center;
    justify-content: center;


    svg {
      width: 1.125rem;
      height: 1.125rem;
      display: block;
    }
  }


  select {
    background-color: var(--ms-neutral-700, #4b4c4e);
    color: #fff;
    border-color: var(--ms-neutral-600, #5f6062);
  }


  /* Any disabled control in the toolbar. Play is disabled while playing,
     Pause while not playing, Restart until there is something to restart. */
  button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
  }


  /* Play */
  #play-btn {
    background-color: var(--clr-green-900, #1d8636);
    color: #fff;
  }


  /* Pause */
  #pause-btn {
    background-color: var(--ms-neutral-700, #4b4c4e);
    color: #fff;
  }


  /* Start from a word */
  #start-here-btn {
    background-color: var(--ms-neutral-700, #4b4c4e);
    color: #fff;
  }


  /* Pick mode is on. Yellow matches the word highlight it is about to
     place, so the connection is visible. */
  #start-here-btn[aria-pressed="true"] {
    background-color: var(--ms-yellow-600, #fecc80);
    color: var(--ms-neutral-900, #0d0d0d);
  }


  /* Playback speed */
  #rate-select {
    width: 4.5rem;
    padding: 0 0.25rem;
  }


  /* Voice picker */
  #voice-select {
    max-width: 12rem;
  }


  /* Start over. The greyed-out look is tied to the real disabled attribute,
     which the script toggles. */
  #restart-btn {
    background-color: var(--clr-red-600, #d91c1c);
    color: #fff;
  }


  /* Hide controls */
  #hide-controls-btn {
    background-color: var(--ms-neutral-600, #5f6062);
    color: #fff;
  }


  /* Status messages. Announced by screen readers through role="status", and
     hidden visually so the toolbar keeps its height. */
  #reader-status {
    position: absolute;
    width: 0.0625rem;
    height: 0.0625rem;
    padding: 0;
    margin: -0.0625rem;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
}


/* -----------------------------------
 Audio Reader - Picking a Starting Word
 -----------------------------------
 While pick mode is on, the crosshair cursor covers the lesson text and the
 word under the keyboard cursor is outlined.
----------------------------------- */
body.reader-picking .course-header,
body.reader-picking .course-content,
body.reader-picking .course-html-page-body {
  cursor: crosshair;
}

body.reader-picking .reader-word:hover {
  background-color: var(--ms-yellow-200, #ffefd7);
  border-radius: 0.1875rem;
}

.reader-word:focus {
  outline: 0.125rem solid var(--ms-neutral-900, #0d0d0d);
  outline-offset: 0.0625rem;
  border-radius: 0.1875rem;
}


/* -----------------------------------
 Audio Reader - Spoken Word Highlight
----------------------------------- */
.reader-word-active {
  /* These two !important declarations are required. They have to beat any
     colour or background set inline on the course text being read. */
  background-color: var(--ms-yellow-600, #fecc80) !important;
  color: var(--ms-neutral-900, #0d0d0d) !important;
  border-radius: 0.1875rem;
  box-shadow: 0 0 0 0.125rem var(--ms-yellow-600, #fecc80);
  text-decoration: underline;
  text-decoration-thickness: 0.125rem;
  text-underline-offset: 0.125rem;
}


/* -----------------------------------
 Audio Reader - Small Screens
 -----------------------------------
 The reader is deliberately not offered below 48rem. Mobile learners are
 better served by the read-aloud built into their own device. @media rather
 than @container for the reason given in the notes at the top.
----------------------------------- */
@media (max-width: 48rem) {
  #reader-toggle,
  #reader-toolbar {
    display: none !important;
  }
}