/* Talk it through — the practice conversation screen of a mini lesson
   (src/js/talk.js). Linked by academy.html and the course previews. */

/* ── The screen ─────────────────────────────────────────────────────────
   Phone: one card (the talk's title over the scenario and aim), then the chat.
   iPad and up: the chat on the left, the card on the right. The chat is a
   window of fixed height that scrolls inside itself, so the page stays still. */
.microlearning-container-wrapper .microlesson-stage.is-talk { max-width: 1080px; }

.talk-screen {
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.talk-side {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}
.talk-side .microlesson-scenario { margin: 0; }

/* The situation and the aim, under the talk's title. On a phone they are read
   first, alone, with Continue under them; Continue folds the card into its
   title line, which opens it again on a tap, and the chat takes the screen.
   Beside the chat the card stays open, and the title line is only a heading. */
.talk-brief { min-width: 0; }
.talk-brief-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.talk-brief > summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 12px;
    background: #f3f1ea;
    color: #18211f;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    -webkit-tap-highlight-color: transparent;
}
.talk-brief > summary::-webkit-details-marker { display: none; }
.talk-brief-title { min-width: 0; line-height: 1.35; }
.talk-brief:not([open]) .talk-brief-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.talk-brief > summary i { font-size: .85rem; color: #6b7370; transition: transform .2s ease; }
.talk-brief[open] > summary i { transform: rotate(90deg); }
.talk-brief[open] > summary { margin-bottom: 12px; }
.talk-brief > summary:focus-visible { outline: 2px solid #4f6f5d; outline-offset: 2px; }
.dark .talk-brief > summary { background: #1f2026; color: #f1f5f9; }
.dark .talk-brief > summary i { color: #94a3b8; }
.talk-screen .talk-side .talk-begin[hidden] { display: none; }
/* Before Continue: the title line is a heading, not a toggle, and no chat. */
.talk-screen.is-brief .talk-brief > summary { cursor: default; }
.talk-screen.is-brief .talk-brief > summary i,
.talk-screen.is-brief .talk { display: none; }

@media (min-width: 768px) {
    .talk-screen {
        display: grid;
        grid-template-columns: minmax(0, 1.12fr) minmax(260px, .88fr);
        grid-template-areas: "talk side";
        gap: 16px 28px;
        align-items: start;
    }
    .talk-side { grid-area: side; }
    .talk { grid-area: talk; }
    .talk-brief > summary { cursor: default; }
    .talk-brief > summary i, .talk-screen .talk-side .talk-begin { display: none; }
}

.talk-aim {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 0;
    padding: 0 4px;
    font-size: .95rem;
    line-height: 1.55;
    color: #4a5450;
}
.talk-aim i { flex: none; margin-top: 3px; font-size: 1.05rem; color: #b88746; }
.talk-aim strong { color: #18211f; }
.dark .talk-aim { color: #cbd5e1; }
.dark .talk-aim strong { color: #f1f5f9; }
.dark .talk-aim i { color: #e0bb85; }

/* ── The thread ─────────────────────────────────────────────────────────
   It looks like Messages on a phone: the person at the top, grey bubbles for
   them and blue ones for the learner, with a tail on the last bubble of each
   run and "Delivered", then "Read", under the learner's latest. The learner
   cannot type, so there is no message box: the replies wait in a tray under
   the thread, each with its own send arrow. */
.talk {
    --talk-bg: #ffffff;
    --talk-them: #e9e9eb;
    --talk-you: #0b84fe;
    --talk-top: calc(var(--site-header-offset, 69px) + var(--module-bar-clear, 72px) + 24px);
    display: flex;
    flex-direction: column;
    height: clamp(440px, calc(100vh - var(--talk-top)), 780px);
    height: clamp(440px, calc(100dvh - var(--talk-top)), 780px);
    border-radius: 22px;
    overflow: hidden;
    background: var(--talk-bg);
    box-shadow: 0 1px 3px rgba(24, 33, 31, .08), 0 0 0 1px rgba(24, 33, 31, .08);
}
.dark .talk {
    --talk-bg: #0c0d10;
    --talk-them: #26252a;
    box-shadow: 0 0 0 1px #2c2c2e;
}

.talk-head {
    flex: none;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    padding: 12px 14px 10px;
    background: #f6f6f8;
    border-bottom: 1px solid rgba(0, 0, 0, .08);
}
.dark .talk-head { background: #1c1c1e; border-bottom-color: #2c2c2e; }

.talk-who {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    line-height: 1.25;
    text-align: center;
}
.talk-avatar {
    width: 44px;
    height: 44px;
    margin-bottom: 4px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #a6abb7, #858a96);
    color: #ffffff;
    font-weight: 600;
    font-size: 1.2rem;
}
.talk-who strong { font-size: .86rem; font-weight: 600; color: #000000; }
.talk-status { font-size: .74rem; color: #8e8e93; white-space: nowrap; }
.talk-status.is-typing { font-style: italic; }
.dark .talk-who strong { color: #ffffff; }

/* How the person is taking it: a word and a dot, from upset (0) to open (4). */
.talk-mood {
    grid-column: 3;
    justify-self: end;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 8px;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .02em;
    background: var(--talk-mood-bg);
    color: var(--talk-mood-ink);
    transition: background .4s ease, color .4s ease;
}
.talk-mood-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}
.talk-mood.is-m0 { --talk-mood-bg: rgba(157, 81, 69, .13); --talk-mood-ink: #8a4438; }
.talk-mood.is-m1 { --talk-mood-bg: rgba(184, 135, 70, .16); --talk-mood-ink: #8a6326; }
.talk-mood.is-m2 { --talk-mood-bg: rgba(101, 112, 107, .12); --talk-mood-ink: #4a5450; }
.talk-mood.is-m3 { --talk-mood-bg: rgba(79, 111, 93, .13); --talk-mood-ink: #3d5a49; }
.talk-mood.is-m4 { --talk-mood-bg: rgba(79, 111, 93, .2); --talk-mood-ink: #2f4a3b; }
.dark .talk-mood.is-m0 { --talk-mood-bg: rgba(217, 138, 124, .16); --talk-mood-ink: #e6a99d; }
.dark .talk-mood.is-m1 { --talk-mood-bg: rgba(215, 171, 109, .16); --talk-mood-ink: #e0bb85; }
.dark .talk-mood.is-m2 { --talk-mood-bg: rgba(160, 174, 192, .14); --talk-mood-ink: #cbd5e1; }
.dark .talk-mood.is-m3 { --talk-mood-bg: rgba(111, 158, 131, .16); --talk-mood-ink: #9ecfb2; }
.dark .talk-mood.is-m4 { --talk-mood-bg: rgba(111, 158, 131, .26); --talk-mood-ink: #b8e3c9; }
.talk-mood.is-changing { animation: talkMood .6s cubic-bezier(.16, 1, .3, 1); }
@keyframes talkMood {
    0% { transform: scale(1); }
    35% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

.talk-log {
    position: relative;               /* bubbles measure their place from here */
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px 14px;
}
.talk-day {
    align-self: center;
    margin: 0 0 10px;
    font-size: .72rem;
    color: #8e8e93;
}
.talk-day strong { font-weight: 600; }

.talk-msg {
    display: flex;
    padding: 0 6px;
    animation: talkIn .3s cubic-bezier(.16, 1, .3, 1);
}
.talk-msg.is-first { margin-top: 10px; }
.talk-day + .talk-msg.is-first { margin-top: 0; }
.talk-msg p {
    position: relative;
    margin: 0;
    max-width: 78%;
    padding: 8px 13px;
    font-size: .98rem;
    line-height: 1.38;
    border-radius: 18px;
    overflow-wrap: anywhere;
}
.talk-msg.is-them p { background: var(--talk-them); color: #000000; }
.talk-msg.is-you { justify-content: flex-end; }
.talk-msg.is-you p { background: var(--talk-you); color: #ffffff; }
.dark .talk-msg.is-them p { color: #ffffff; }
/* The last bubble of a run has the curled tail at its foot. */
.talk-msg.is-last p::before,
.talk-msg.is-last p::after {
    content: '';
    position: absolute;
    bottom: 0;
    height: 17px;
}
.talk-msg.is-you.is-last p::before { right: -7px; width: 20px; background: var(--talk-you); border-bottom-left-radius: 16px 14px; }
.talk-msg.is-you.is-last p::after { right: -26px; width: 26px; background: var(--talk-bg); border-bottom-left-radius: 10px; }
.talk-msg.is-them.is-last p::before { left: -7px; width: 20px; background: var(--talk-them); border-bottom-right-radius: 16px 14px; }
.talk-msg.is-them.is-last p::after { left: -26px; width: 26px; background: var(--talk-bg); border-bottom-right-radius: 10px; }

.talk-receipt {
    align-self: flex-end;
    margin: 3px 8px 0;
    font-size: .72rem;
    color: #8e8e93;
}
.talk-receipt strong { font-weight: 600; }

.talk-typing {
    align-self: flex-start;
    display: inline-flex;
    gap: 5px;
    margin: 10px 0 0 6px;
    padding: 12px 15px;
    border-radius: 18px;
    background: var(--talk-them);
    animation: talkIn .25s ease;
}
.talk-msg.is-them + .talk-typing { margin-top: 2px; }
.talk-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #8e8e93;
    animation: talkDot 1.1s infinite ease-in-out;
}
.talk-typing span:nth-child(2) { animation-delay: .15s; }
.talk-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes talkDot {
    0%, 70%, 100% { transform: translateY(0); opacity: .45; }
    35% { transform: translateY(-4px); opacity: 1; }
}
@keyframes talkIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* The coach's note on the reply just made, set apart from the bubbles: what
   the reply did, and why it landed the way it did. Its tone shows in the
   heading's icon and colour only. */
.talk-note {
    align-self: center;
    width: min(100%, 470px);
    margin: 12px 0 4px;
    padding: 11px 14px 12px;
    border-radius: 14px;
    background: #f2f2f7;
    animation: talkIn .32s cubic-bezier(.16, 1, .3, 1);
}
.talk-note p { margin: 0; font-size: .89rem; line-height: 1.55; color: #3a3a3c; }
.talk-note .talk-note-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--talk-note-ink);
}
.talk-note-head i { flex: none; font-size: .95rem; }
.talk-note.is-up { --talk-note-ink: #3d5a49; }
.talk-note.is-flat { --talk-note-ink: #8a6326; }
.talk-note.is-down { --talk-note-ink: #8a4438; }
.dark .talk-note { background: #1c1c1e; }
.dark .talk-note p { color: #d1d1d6; }
.dark .talk-note.is-up { --talk-note-ink: #9ecfb2; }
.dark .talk-note.is-flat { --talk-note-ink: #e0bb85; }
.dark .talk-note.is-down { --talk-note-ink: #e6a99d; }

/* ── The replies to choose from ───────────────────────────────────────────── */
.talk-replies {
    flex: none;
    max-height: 62%;
    overflow-y: auto;
    padding: 12px 12px 14px;
    background: #f2f2f7;
    border-top: 1px solid rgba(0, 0, 0, .07);
}
.dark .talk-replies { background: #1c1c1e; border-top-color: #2c2c2e; }
.talk-replies.is-in .talk-reply { animation: talkIn .3s cubic-bezier(.16, 1, .3, 1) both; }
.talk-replies.is-in .talk-reply:nth-of-type(2) { animation-delay: .05s; }
.talk-replies.is-in .talk-reply:nth-of-type(3) { animation-delay: .1s; }
.talk-replies.is-in .talk-reply:nth-of-type(4) { animation-delay: .15s; }
.talk-replies-label {
    margin: 0 4px 8px;
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #8e8e93;
}

.talk-reply {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 0 0 8px;
    padding: 10px 10px 10px 15px;
    border: 0;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
    font: inherit;
    font-size: .96rem;
    line-height: 1.38;
    text-align: left;
    color: #000000;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease;
}
.talk-reply:last-child { margin-bottom: 0; }
.talk-reply:hover { background: #fafafa; }
.talk-reply:active { transform: scale(.985); }
.talk-reply:focus-visible { outline: 2px solid var(--talk-you, #0b84fe); outline-offset: 2px; }
.talk-reply-text { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.talk-reply > i { flex: none; font-size: 1.75rem; color: #0b84fe; }
.dark .talk-reply { background: #2c2c2e; color: #ffffff; box-shadow: none; }
.dark .talk-reply:hover { background: #3a3a3c; }
.talk-tried {
    font-size: .72rem;
    font-weight: 600;
    color: #8e8e93;
}

/* Next, after a coach note: the tray holds only this until it is tapped. */
.talk-replies.is-pause { padding-top: 10px; padding-bottom: 12px; }
.talk-next {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    padding: 10px 16px;
    border: 0;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: #0a6fd6;
    cursor: pointer;
    animation: talkIn .3s cubic-bezier(.16, 1, .3, 1) both;
    transition: background .15s ease, transform .15s ease;
}
.talk-next:hover { background: #fafafa; }
.talk-next:active { transform: scale(.985); }
.talk-next:focus-visible { outline: 2px solid #0b84fe; outline-offset: 2px; }
.talk-next i { font-size: 1.05rem; }
.dark .talk-next { background: #2c2c2e; color: #4aa3ff; box-shadow: none; }
.dark .talk-next:hover { background: #3a3a3c; }

/* ── How it ended ───────────────────────────────────────────────────────── */
.talk-end, .talk-end-in {
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: talkIn .4s cubic-bezier(.16, 1, .3, 1);
}
.talk-end-in { margin-top: 10px; }

/* Continue and Try it another way, where the replies were. */
.microlearning-container-wrapper .microlesson-actions.talk-actions {
    flex: none;
    margin: 0;
    padding: 12px;
    background: #f2f2f7;
    border-top: 1px solid rgba(0, 0, 0, .07);
}
.dark .microlearning-container-wrapper .microlesson-actions.talk-actions { background: #1c1c1e; border-top-color: #2c2c2e; }

.talk-ending {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    margin-top: 12px;
    padding: 16px 18px;
    border-radius: 18px;
    animation: talkIn .4s cubic-bezier(.16, 1, .3, 1);
}
.talk-ending h4 { margin: 2px 0 6px; font-size: 1.12rem; line-height: 1.35; }
.talk-ending p { margin: 0; font-size: .95rem; line-height: 1.6; }
.talk-ending .talk-ending-label {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    opacity: .8;
}
.talk-ending-icon {
    flex: none;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}
.talk-ending.is-good { background: rgba(79, 111, 93, .1); }
.talk-ending.is-good .talk-ending-icon { background: rgba(79, 111, 93, .16); color: #3d5a49; }
.talk-ending.is-good h4, .talk-ending.is-good .talk-ending-label { color: #3d5a49; }
.talk-ending.is-mixed { background: rgba(184, 135, 70, .1); }
.talk-ending.is-mixed .talk-ending-icon { background: rgba(184, 135, 70, .16); color: #8a6326; }
.talk-ending.is-mixed h4, .talk-ending.is-mixed .talk-ending-label { color: #7a5720; }
.talk-ending.is-poor { background: rgba(157, 81, 69, .08); }
.talk-ending.is-poor .talk-ending-icon { background: rgba(157, 81, 69, .13); color: #8a4438; }
.talk-ending.is-poor h4, .talk-ending.is-poor .talk-ending-label { color: #8a4438; }
.dark .talk-ending.is-good { background: rgba(111, 158, 131, .14); }
.dark .talk-ending.is-good .talk-ending-icon { background: rgba(111, 158, 131, .2); color: #9ecfb2; }
.dark .talk-ending.is-good h4, .dark .talk-ending.is-good .talk-ending-label { color: #9ecfb2; }
.dark .talk-ending.is-mixed { background: rgba(215, 171, 109, .12); }
.dark .talk-ending.is-mixed .talk-ending-icon { background: rgba(215, 171, 109, .18); color: #e0bb85; }
.dark .talk-ending.is-mixed h4, .dark .talk-ending.is-mixed .talk-ending-label { color: #e0bb85; }
.dark .talk-ending.is-poor { background: rgba(217, 138, 124, .12); }
.dark .talk-ending.is-poor .talk-ending-icon { background: rgba(217, 138, 124, .18); color: #e6a99d; }
.dark .talk-ending.is-poor h4, .dark .talk-ending.is-poor .talk-ending-label { color: #e6a99d; }

.talk-recap {
    padding: 14px 18px;
    border-radius: 16px;
    background: #f2f2f7;
}
.dark .talk-recap { background: #1c1c1e; }
.talk-recap-head, .talk-takeaway-head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 8px;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #69736e;
}
.dark .talk-recap-head { color: #9ca3af; }
.talk-recap ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; counter-reset: talk; }
.talk-recap li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .95rem;
    line-height: 1.4;
}
.talk-recap li::before {
    counter-increment: talk;
    content: counter(talk);
    flex: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .74rem;
    font-weight: 700;
    background: rgba(24, 33, 31, .07);
    color: #4a5450;
}
.dark .talk-recap li::before { background: rgba(249, 250, 251, .08); color: #cbd5e1; }
.talk-recap li i { flex: none; font-size: 1rem; }
.talk-recap li.is-up i { color: #4f6f5d; }
.talk-recap li.is-flat i { color: #b88746; }
.talk-recap li.is-down i { color: #9d5145; }
.dark .talk-recap li.is-up i { color: #9ecfb2; }
.dark .talk-recap li.is-flat i { color: #e0bb85; }
.dark .talk-recap li.is-down i { color: #e6a99d; }

.talk-takeaway {
    padding: 16px 20px;
    border-radius: 16px;
    background: color-mix(in srgb, var(--module-accent, #4f6f5d) 9%, transparent);
}
.talk-takeaway-head { color: var(--module-accent, #4f6f5d); }
.talk-takeaway-head i { color: #b88746; font-size: 1rem; }
.dark .talk-takeaway-head { color: #8cc0a3; }
.talk-takeaway p:last-child { margin: 0; font-size: .95rem; line-height: 1.65; }

.microlearning-container-wrapper .talk-actions button.microlesson-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* The screen's parts wait hidden until their moment; the lesson's own rules
   would otherwise show them (the actions row is display: flex). */
.talk-replies[hidden], .talk-end[hidden], .talk-end:empty,
.microlearning-container-wrapper .microlesson-actions.talk-actions[hidden] { display: none; }

.talk-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 480px) {
    .talk-head { padding: 8px 10px 7px; }
    .talk-avatar { width: 34px; height: 34px; font-size: .95rem; margin-bottom: 2px; }
    .talk-log { padding: 10px 8px 12px; }
    .talk-msg p { max-width: 84%; }
    .talk-replies { padding: 10px 8px 12px; }
    .talk-ending { padding: 16px; gap: 12px; }
    .talk-ending-icon { width: 38px; height: 38px; font-size: 1.3rem; border-radius: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .talk-msg, .talk-typing, .talk-note, .talk-end, .talk-next, .talk-replies.is-in .talk-reply, .talk-mood.is-changing { animation: none; }
    .talk-mood, .talk-brief > summary i { transition: none; }
}
