/* A study text's tab (study-text.js, docs/study-texts.md): its title, where
   it came from, then the whole text, each paragraph in a box of its own. */
#study-text-view { flex: 1; min-height: 0; display: flex; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font); }
#study-text-view[hidden] { display: none; }
.study-column { max-width: 46em; margin: 0 auto; padding: 20px 16px 40vh; display: flex; flex-direction: column; gap: 12px; }
.study-title { margin: 0; font-size: 1.3em; line-height: 1.3; font-weight: 700; }
.study-meta { margin: 0 0 4px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.study-meta a { color: inherit; }
/* A paragraph's box: its words, and under them a button to read it aloud,
   big enough for a thumb. The box is lit while it's read, and its button
   dims while the speech is being made. */
.study-para { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); font-size: var(--text); line-height: var(--text-line); }
.study-words { min-width: 0; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.study-read { min-height: 44px; min-width: 140px; padding: 0 16px; border: 1px solid var(--border); border-radius: 22px; background: none; color: inherit; font: inherit; font-size: 14px; line-height: 1; cursor: pointer; }
.study-read:hover, .study-read[aria-pressed="true"] { background: var(--hover); }
.study-para.making .study-read { animation: study-making .9s ease-in-out infinite alternate; }
@keyframes study-making { from { opacity: 1; } to { opacity: .3; } }
.study-para.reading { border-color: var(--accent); }
/* The player: while a paragraph is read, a bar stuck to the bottom of the
   tab with pause or play, which paragraph, a scrubber, the time, and close. */
.study-player { position: sticky; bottom: 0; z-index: 2; display: flex; align-items: center; gap: 10px; max-width: 46em; margin: 0 auto; padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); border: 1px solid var(--border); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--card); box-shadow: 0 -4px 16px rgba(0, 0, 0, .25); font-size: 13px; }
.study-player[hidden] { display: none; }
/* Pick up where studying was left off: a big button stuck to the bottom of
   the text, shown when nothing is being read or talked about. */
.study-resume { position: sticky; bottom: 0; z-index: 1; display: flex; max-width: 46em; margin: 0 auto; padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); }
.study-resume[hidden] { display: none; }
.study-resume-btn { flex: 1; min-height: 52px; padding: 0 16px; border: 1px solid var(--accent); border-radius: 12px; background: var(--card); color: inherit; font: inherit; font-size: 16px; font-weight: 600; cursor: pointer; box-shadow: 0 -4px 16px rgba(0, 0, 0, .25); }
.study-resume-btn:hover { background: var(--hover); }
.study-play, .study-close { flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 22px; background: none; color: inherit; font: inherit; font-size: 18px; line-height: 1; cursor: pointer; }
.study-play { background: var(--hover); }
.study-play:disabled { opacity: .4; cursor: default; }
.study-close { font-size: 14px; color: var(--muted); }
.study-close:hover { background: var(--hover); }
.study-where { flex: none; color: var(--muted); }
.study-scrub { flex: 1; min-width: 0; height: 44px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.study-time { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 480px) { .study-where { display: none; } }
.study-trouble { margin: 0; font-size: 12px; color: #f14c4c; }
.study-note { margin: 0; padding: 12px 16px; font-size: 12px; color: var(--muted); }
/* Talking about a paragraph: its button beside Read aloud, and while a talk
   is on, a bar under the chat: what it's doing, mute, and end. */
.study-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.study-para.talking { border-color: #3fb950; }
/* The tab's two sides: the text, which scrolls by itself, and the chat.
   On a narrow screen the chat goes under the text. */
.study-left { flex: 1 1 0; min-width: 0; min-height: 0; overflow: auto; }
.study-chat { flex: 0 0 min(42%, 520px); min-width: 0; min-height: 0; display: flex; flex-direction: column; border-left: 1px solid var(--border); }
.study-chat[hidden] { display: none; }
.study-chat-log { container: study-chat / inline-size; flex: 1; min-height: 0; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; font-size: var(--text); line-height: var(--text-line); }
.study-chat-log:empty::before { content: "Press 💬 Talk on a paragraph to talk about it. It waits until you say \201Cover\201D. What you say and what it says back show here."; margin: auto; max-width: 22em; text-align: center; font-size: 12px; color: var(--muted); }
.study-line { max-width: 92%; }
.study-line-who { margin-bottom: 2px; font-size: 11px; color: var(--muted); }
.study-line-words { white-space: pre-wrap; overflow-wrap: anywhere; }
.study-line.me { align-self: flex-end; }
.study-line.me .study-line-who { text-align: right; }
.study-line.me .study-line-words { padding: 8px 12px; border-radius: 12px; background: var(--hover); }
.study-line-words:empty { display: none; }
/* A line with sidebar questions: the message on the left, and its questions
   branching off to its right, each with its answer under it. */
.study-line.sided { max-width: 100%; align-self: stretch; }
.study-line.sided .study-line-who { text-align: left; }
.study-line.sided .study-line-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: start; }
.study-sides { display: flex; flex-direction: column; gap: 8px; }
.study-side { position: relative; margin-left: 28px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.study-side::before { content: ""; position: absolute; left: -29px; top: 17px; width: 28px; border-top: 1px solid var(--muted); }
.study-side:not(:first-child)::before { left: -15px; width: 14px; }
.study-side::after { content: ""; position: absolute; left: -15px; border-left: 1px solid var(--muted); }
.study-side:not(:last-child)::after { top: 17px; bottom: -10px; }
.study-side:not(:first-child)::after { top: -10px; height: 28px; }
.study-side:not(:first-child):not(:last-child)::after { top: -10px; bottom: -10px; height: auto; }
.study-side-q { display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; font-weight: 600; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; cursor: pointer; }
.study-side-q::before { content: "▾ ❓ "; color: var(--muted); }
.study-side.folded .study-side-q::before { content: "▸ ❓ "; }
.study-side-a { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.study-side-a:empty, .study-side.folded .study-side-a { display: none; }
.study-side.asking .study-side-a, .study-side.failed .study-side-a { color: var(--muted); }
.study-side.asking .study-side-a { animation: study-side-wait 1.2s ease-in-out infinite alternate; }
@keyframes study-side-wait { to { opacity: .4; } }
/* In a narrow chat the questions go under the message instead. */
@container study-chat (max-width: 460px) {
  .study-line.sided .study-line-body { grid-template-columns: minmax(0, 1fr); row-gap: 8px; }
  .study-side { margin-left: 14px; }
  .study-side::before, .study-side:not(:first-child)::before { left: -15px; width: 14px; }
  .study-side:first-child::after { top: -8px; height: 26px; }
  .study-side:first-child:not(:last-child)::after { top: -8px; bottom: -10px; height: auto; }
}
.study-chat-mark { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); }
.study-chat-mark::before, .study-chat-mark::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
/* A talk's recording: "▶ Your voice" on its line, then the browser's player under it. */
.study-voice-b { flex: none; min-height: 24px; padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px; background: none; color: inherit; font: inherit; cursor: pointer; }
.study-voice-b:hover:not(:disabled) { background: var(--card); }
.study-voice-b:disabled { cursor: default; opacity: .7; }
.study-voice { flex: none; display: block; width: 100%; height: 36px; color-scheme: dark; }
.study-devices { flex: none; display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 6px 12px; border-top: 1px solid var(--border); font-size: 12px; }
.study-device { flex: 1 1 140px; min-width: 0; display: flex; align-items: center; gap: 6px; }
.study-device[hidden] { display: none; }
.study-device select { flex: 1; min-width: 0; min-height: 30px; padding: 2px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: inherit; font: inherit; text-overflow: ellipsis; }
.study-talkbar { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); background: var(--card); font-size: 13px; }
.study-talkbar[hidden] { display: none; }
/* With no talk on, the talk bar's hidden and the device lists are the bottom
   row, so they keep clear of the phone's navigation bar instead. */
.study-devices:has(+ .study-talkbar[hidden]) { padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 760px) {
  #study-text-view { flex-direction: column; }
  .study-chat { flex: 0 0 42%; border-left: 0; border-top: 1px solid var(--border); }
}
/* On a phone, Pick up is the chat's bottom row (placeResume in study-text.js). */
.study-chat > .study-resume { position: static; flex: none; max-width: none; margin: 0; border-top: 1px solid var(--border); }
.study-chat:has(> .study-resume:not([hidden])) .study-devices { padding-bottom: 6px; }
.study-mute, .study-end { flex: none; min-height: 44px; padding: 0 16px; border: 1px solid var(--border); border-radius: 22px; background: none; color: inherit; font: inherit; font-size: 14px; cursor: pointer; }
.study-mute:hover, .study-end:hover { background: var(--hover); }
.study-mute:disabled { opacity: .4; cursor: default; }
/* Whether the mic's being heard: a row of its own, green while it is. */
.study-talkbar { flex-wrap: wrap; justify-content: flex-end; }
.study-talk-state { flex: 1 1 100%; min-width: 0; padding: 10px 14px; border-radius: 10px; background: #3d444d; color: #d1d7e0; font-size: 17px; font-weight: 600; text-align: center; transition: background .15s; }
.study-talkbar.listening .study-talk-state { background: #1a7f37; color: #fff; }
.study-talkbar.listening .study-talk-state::before { content: "●"; display: inline-block; margin-right: 8px; color: #aff5b4; animation: study-listening 1.2s ease-in-out infinite; }
@keyframes study-listening { 50% { opacity: .25; } }
.study-chat-log > * { flex: none; }
@media (max-width: 760px) {
  .study-talkbar { gap: 8px; }
  .study-talkbar .study-mute, .study-talkbar .study-end { flex: 1 1 0; padding: 0 8px; white-space: nowrap; }
}
