/* Listen to a mini lesson (src/js/lesson-audio.js): the headphones button in
   the lesson bar, the player docked at the foot of the screen, and the light
   on the sentence being read. Same green as the lesson runner. */

.la-toggle {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(79, 111, 93, 0.35);
    background: transparent;
    color: #4f6f5d;
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.la-toggle i { font-size: 1.05rem; }
.la-toggle:hover { background: rgba(79, 111, 93, 0.08); }
.la-toggle.is-on { background: #4f6f5d; border-color: #4f6f5d; color: #ffffff; }
.la-toggle:focus-visible { outline: 2px solid #4f6f5d; outline-offset: 2px; }
.dark .la-toggle { color: #8cc0a3; border-color: rgba(140, 192, 163, 0.4); }
.dark .la-toggle:hover { background: rgba(140, 192, 163, 0.1); }
.dark .la-toggle.is-on { background: #8cc0a3; border-color: #8cc0a3; color: #13201a; }
@media (max-width: 560px) {
    .la-toggle { width: 34px; padding: 0; justify-content: center; }
    .la-toggle-label { display: none; }
}

/* The dock. It sits over the foot of the lesson, so the stage gets room
   below its buttons while it is up. */
.microlearning-container-wrapper.la-docked .microlesson-stage { padding-bottom: 120px; }

.la-dock {
    position: fixed;
    left: 50%;
    bottom: max(16px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 1000;
    width: min(560px, calc(100% - 24px));
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px 10px 10px;
    border-radius: 20px;
    background: #ffffff;
    border: 1px solid rgba(24, 33, 31, 0.1);
    box-shadow: 0 12px 32px rgba(24, 33, 31, 0.16), 0 2px 6px rgba(24, 33, 31, 0.06);
    color: #18211f;
    animation: laDockIn .3s cubic-bezier(.16, 1, .3, 1);
}
.la-dock[hidden] { display: none; }
@keyframes laDockIn { from { opacity: 0; transform: translate(-50%, 12px); } }
@media (prefers-reduced-motion: reduce) { .la-dock { animation: none; } }
.dark .la-dock {
    background: #222b3a;
    border-color: #334155;
    color: #e2e8f0;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.la-play {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 0;
    background: #4f6f5d;
    color: #ffffff;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background-color .2s ease, transform .15s ease;
}
.la-play:hover { background: #405a4b; }
.la-play:active { transform: scale(.94); }
.la-play:disabled { opacity: .4; cursor: default; }
.la-dock.is-loading .la-play i { animation: laPulse 1s ease-in-out infinite; }
@keyframes laPulse { 50% { opacity: .45; } }
.dark .la-play { background: #8cc0a3; color: #13201a; }
.dark .la-play:hover { background: #a3cfb6; }

.la-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.la-line { display: flex; align-items: baseline; gap: 10px; min-width: 0; }

.la-voice {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: .92rem;
    font-weight: 700;
    cursor: pointer;
}
.la-voice i { font-size: .75rem; opacity: .6; }
.la-voice:hover { color: #4f6f5d; }
.dark .la-voice:hover { color: #8cc0a3; }
.la-status {
    font-size: .78rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dark .la-status { color: #9ca3af; }

.la-progress { height: 4px; border-radius: 999px; background: rgba(24, 33, 31, 0.08); overflow: hidden; }
.dark .la-progress { background: #334155; }
.la-progress-fill { height: 100%; width: 0; border-radius: 999px; background: #4f6f5d; }
.dark .la-progress-fill { background: #8cc0a3; }

.la-rate, .la-close {
    flex: none;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: rgba(24, 33, 31, 0.06);
    color: inherit;
    font: inherit;
    cursor: pointer;
}
.la-rate { min-width: 48px; padding: 0 8px; font-size: .82rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.la-close { width: 34px; display: grid; place-items: center; background: transparent; opacity: .65; }
.la-rate:hover, .la-close:hover { background: rgba(24, 33, 31, 0.1); opacity: 1; }
.dark .la-rate { background: rgba(255, 255, 255, 0.07); }
.dark .la-rate:hover, .dark .la-close:hover { background: rgba(255, 255, 255, 0.12); }
.la-dock button:focus-visible { outline: 2px solid #4f6f5d; outline-offset: 2px; }
.dark .la-dock button:focus-visible { outline-color: #8cc0a3; }

/* The voice menu opens upwards from the dock. */
.la-menu {
    position: absolute;
    left: 56px;
    bottom: calc(100% + 8px);
    width: min(280px, calc(100vw - 80px));
    padding: 6px;
    border-radius: 16px;
    background: #ffffff;
    border: 1px solid rgba(24, 33, 31, 0.1);
    box-shadow: 0 12px 32px rgba(24, 33, 31, 0.18);
}
.la-menu[hidden] { display: none; }
.dark .la-menu { background: #222b3a; border-color: #334155; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5); }
.la-menu-head {
    margin: 6px 10px 6px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #6b7280;
}
.dark .la-menu-head { color: #9ca3af; }
.la-menu-item {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas: "name tick" "note tick";
    align-items: center;
    column-gap: 10px;
    padding: 9px 10px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.la-menu-item:hover, .la-menu-item:focus-visible { background: rgba(79, 111, 93, 0.08); outline: none; }
.la-menu-item.is-on { background: rgba(79, 111, 93, 0.12); }
.dark .la-menu-item:hover, .dark .la-menu-item:focus-visible { background: rgba(140, 192, 163, 0.1); }
.dark .la-menu-item.is-on { background: rgba(140, 192, 163, 0.16); }
.la-menu-name { grid-area: name; font-weight: 700; font-size: .92rem; }
.la-menu-note { grid-area: note; font-size: .78rem; color: #6b7280; }
.dark .la-menu-note { color: #9ca3af; }
.la-menu-item i { grid-area: tick; color: #4f6f5d; }
.dark .la-menu-item i { color: #8cc0a3; }

/* The sentence being read. A soft wash rather than a colour change, so the
   text stays as legible as it was, and it follows the line when it wraps. */
.la-s {
    border-radius: 4px;
    transition: background-color .25s ease, box-shadow .25s ease;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}
.la-s.la-now {
    background: rgba(184, 135, 70, 0.2);
    box-shadow: 0 0 0 2px rgba(184, 135, 70, 0.2);
}
.dark .la-s.la-now {
    background: rgba(226, 178, 108, 0.2);
    box-shadow: 0 0 0 2px rgba(226, 178, 108, 0.2);
}
.option-button.la-reading { box-shadow: 0 0 0 3px rgba(184, 135, 70, 0.45); }
.dark .option-button.la-reading { box-shadow: 0 0 0 3px rgba(226, 178, 108, 0.45); }
.option-button.la-reading .la-s.la-now { background: none; box-shadow: none; }

/* Hands-free. The badge says it is on; the settings menu sets the wait. */
.la-auto-badge {
    margin-left: 4px;
    padding: 1px 7px;
    border-radius: 999px;
    background: rgba(79, 111, 93, 0.12);
    color: #4f6f5d;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
}
.la-auto-badge[hidden] { display: none; }
.la-auto-badge:not([hidden]) { display: inline-flex; align-items: center; gap: 4px; }
.la-line { overflow: hidden; }
@media (max-width: 420px) {
    /* Room is short beside the speed button: the badge keeps its icon only. */
    .la-auto-badge span, .la-voice > .ph-caret-up, .la-status { display: none; }
}
.dark .la-auto-badge { background: rgba(140, 192, 163, 0.16); color: #8cc0a3; }
.la-menu-sep { height: 1px; margin: 6px 4px; background: rgba(24, 33, 31, 0.08); }
.dark .la-menu-sep { background: #334155; }
.la-menu-help { margin: -2px 10px 8px; font-size: .78rem; color: #6b7280; }
.dark .la-menu-help { color: #9ca3af; }
.la-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0 4px 4px; }
.la-seg-item {
    padding: 8px 4px;
    border: 1px solid rgba(24, 33, 31, 0.12);
    border-radius: 10px;
    background: none;
    color: inherit;
    font: inherit;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.la-seg-item:hover { background: rgba(79, 111, 93, 0.08); }
.la-seg-item.is-on { background: #4f6f5d; border-color: #4f6f5d; color: #ffffff; }
.dark .la-seg-item { border-color: #334155; }
.dark .la-seg-item:hover { background: rgba(140, 192, 163, 0.1); }
.dark .la-seg-item.is-on { background: #8cc0a3; border-color: #8cc0a3; color: #13201a; }

/* The countdown: the button fills from the left over the wait, then presses
   itself. Cancel sits beside it. */
#microlesson-primary.la-counting { position: relative; overflow: hidden; isolation: isolate; }
#microlesson-primary.la-counting::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: rgba(255, 255, 255, 0.24);
    transform-origin: left center;
    transform: scaleX(0);
    animation: laFill var(--la-wait, 5s) linear forwards;
}
.dark #microlesson-primary.la-counting::before { background: rgba(0, 0, 0, 0.22); }
@keyframes laFill { to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) {
    /* No sweep: the dock's line says how long is left. */
    #microlesson-primary.la-counting::before { animation: none; transform: scaleX(1); opacity: .5; }
}
.microlearning-container-wrapper .microlesson-actions.la-has-cancel { flex-direction: row; }
.microlearning-container-wrapper .microlesson-actions.la-has-cancel #microlesson-primary { flex: 1; width: auto; }
.microlearning-container-wrapper .microlesson-actions button.la-cancel {
    flex: none;
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding-left: 20px;
    padding-right: 20px;
    background: #ffffff;
    border-color: rgba(24, 33, 31, 0.22);
    color: #18211f;
}
.microlearning-container-wrapper .microlesson-actions button.la-cancel:hover { background: #f4f4f2; }
.microlearning-container-wrapper .microlesson-actions button.la-cancel:focus-visible { outline: 2px solid #4f6f5d; outline-offset: 2px; }
.dark .microlearning-container-wrapper .microlesson-actions button.la-cancel { background: transparent; border-color: #4a5568; color: #e2e8f0; }
.dark .microlearning-container-wrapper .microlesson-actions button.la-cancel:hover { background: rgba(255, 255, 255, 0.06); }

/* While listening, a sentence can be tapped to read from there. */
.la-docked .la-s:not(button .la-s) { cursor: pointer; }
@media (hover: hover) {
    .la-docked .la-s:not(button .la-s):not(.la-now):hover { background: rgba(79, 111, 93, 0.1); }
    .dark .la-docked .la-s:not(button .la-s):not(.la-now):hover { background: rgba(140, 192, 163, 0.12); }
}
