/* Learn — the hub, the Reader, the deck, practice.
   Same tokens as nia.css. Practice never uses red: a wrong pick is simply set aside. */

.make-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px;
}
.make-label { font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; margin: 0; }
.chip-radio { position: absolute; opacity: 0; pointer-events: none; }
label.chip { cursor: pointer; margin: 0; font-weight: 500; min-height: 34px; }
.chip-radio:checked + label.chip { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); font-weight: 700; }
.chip-radio:focus-visible + label.chip { outline: 3px solid var(--accent); outline-offset: 2px; }

.maker-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.maker-row form { display: contents; }
.maker {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 76px; padding: 10px 6px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  font: inherit; font-size: .84rem; font-weight: 700; cursor: pointer; text-align: center;
}
.maker:hover { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); }
.maker .ico { color: var(--accent); }

.mat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mat-card {
  display: flex; flex-direction: column; gap: 4px; padding: 14px; min-height: 128px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
.mat-card:hover { box-shadow: var(--shadow-lift); border-color: var(--line-2); }
.mat-ico {
  width: 38px; height: 38px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 4px;
}
.mat-guide .mat-ico, .mat-reading .mat-ico, .mat-document .mat-ico, .mat-rubric .mat-ico { background: var(--second-soft); color: var(--ink-2); }
.mat-flashcards .mat-ico, .mat-quiz .mat-ico { background: var(--ok-soft); color: var(--ok); }
.mat-kind { font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
.mat-title { font-weight: 700; line-height: 1.3; font-size: .98rem; }
.mat-course { font-size: .78rem; color: var(--ink-3); margin-top: auto; }

.course-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.course-tile {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 14px 12px; min-height: 80px;
  border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; color: var(--ink); border-top: 4px solid var(--accent);
}
.course-tile:nth-child(3n+2) { border-top-color: var(--second); }
.course-tile:nth-child(3n+3) { border-top-color: var(--ok); }
.course-name { font-family: var(--font-display); font-weight: 800; font-size: 1.02rem; letter-spacing: -.01em; }

.snap-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  min-height: 170px; border: 2px dashed var(--line-2); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--accent); cursor: pointer; font-weight: 700;
}
.snap-drop:hover { background: var(--accent-soft); border-color: var(--accent-line); }

.making { text-align: center; padding: 40px 12px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.making-dots { display: flex; gap: 8px; margin-bottom: 8px; }
.making-dots i { width: 12px; height: 12px; border-radius: 999px; background: var(--accent); opacity: .3; animation: nia-pulse 1.2s infinite ease-in-out; }
.making-dots i:nth-child(2) { animation-delay: .15s; }
.making-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes nia-pulse { 0%, 100% { opacity: .25; transform: scale(.85); } 50% { opacity: 1; transform: scale(1); } }

.figure { margin: 0; }
.figure img { width: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; }
.figure figcaption { font-size: .92rem; color: var(--ink-2); margin-top: 8px; }
.player { width: 100%; }

/* flashcards */
.deck { display: flex; flex-direction: column; gap: 12px; }
.flip {
  min-height: 250px; width: 100%; padding: 28px 22px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lift);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  font: inherit; color: var(--ink); cursor: pointer; text-align: center;
}
.flip-face { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; line-height: 1.3; letter-spacing: -.01em; }
.flip.is-back { background: var(--accent-soft); border-color: var(--accent-line); }
.flip.is-back .flip-face { font-family: var(--font-body); font-weight: 500; font-size: 1.1rem; }
.flip.is-back .flip-hint { visibility: hidden; }
.deck-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* practice */
.practice { display: flex; flex-direction: column; gap: 12px; }
.q-text { font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; line-height: 1.3; margin: 0; }
.q-options { display: flex; flex-direction: column; gap: 8px; }
.q-opt {
  text-align: left; min-height: var(--tap); padding: 12px 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line-2); font: inherit; color: var(--ink); cursor: pointer;
}
.q-opt:hover { border-color: var(--accent-line); }
.q-opt.is-right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); font-weight: 700; }
.q-opt.is-picked { opacity: .55; text-decoration: line-through; }
.q-why { background: var(--surface-2); border-radius: 12px; padding: 12px 14px; }

.vocab .icon-btn { width: 40px; height: 40px; }
.plan { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 12px; }
.plan li::marker { font-family: var(--font-display); font-weight: 800; color: var(--accent); }

/* ---------- the Reader ---------- */
.reader {
  --r-size: 1;
  font-size: calc(1.06rem * var(--r-size));
  line-height: 1.75; letter-spacing: .012em;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 20px 18px 26px;
}
.reader[data-spacing="wide"] { line-height: 2.05; letter-spacing: .05em; word-spacing: .16em; }
.reader[data-page="paper"] { background: #FBF3E3; color: #1E1A14; }
.reader[data-page="sky"] { background: #EAF2FB; color: #13202E; }
.reader[data-page="mint"] { background: #E9F6F0; color: #12241C; }
.reader h3 { font-family: var(--font-display); font-weight: 800; font-size: 1.15em; margin: 1.1em 0 .4em; }
.reader p, .reader li { margin: 0 0 .75em; max-width: 64ch; }
.reader ul, .reader ol { padding-left: 1.2em; margin: 0 0 .8em; }
.reader .rb { border-radius: 8px; transition: background .15s, opacity .15s; }
.reader .rb.is-current {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  box-shadow: -8px 0 0 color-mix(in srgb, var(--accent) 7%, transparent), 8px 0 0 color-mix(in srgb, var(--accent) 7%, transparent);
}
.reader[data-focus="on"] .rb:not(.is-current) { opacity: .28; }
.reader .w { cursor: pointer; border-radius: 4px; }
.reader .w:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.reader .w.speaking { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 2px var(--accent); }

body.has-reader { padding-bottom: calc(var(--bar) + 76px + env(safe-area-inset-bottom, 0px)); }
.reader-bar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 25;
  bottom: calc(var(--bar) + 10px + env(safe-area-inset-bottom, 0px));
  display: flex; align-items: center; gap: 4px; padding: 6px;
  background: var(--ink); color: var(--bg); border-radius: 999px; box-shadow: var(--shadow-lift);
}
.rb-play {
  width: 52px; height: 52px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center;
}
.rb-play .i-pause, .reader-bar.is-playing .i-play { display: none; }
.reader-bar.is-playing .i-pause { display: inline; }
.rb-btn {
  min-width: 46px; height: 46px; padding: 0 10px; border-radius: 999px; border: 0; cursor: pointer;
  background: transparent; color: inherit; font: inherit; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.rb-btn:hover { background: color-mix(in srgb, var(--bg) 14%, transparent); }
.rb-aa { font-family: var(--font-display); font-size: 1.05rem; }

.sheet {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 26; width: min(420px, calc(100vw - 24px));
  bottom: calc(var(--bar) + 78px + env(safe-area-inset-bottom, 0px));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift); padding: 8px 14px;
}
.sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.sheet-row:last-child { border-bottom: 0; }
.sheet-row > span { font-weight: 700; font-size: .92rem; }
.seg-mini { display: flex; gap: 4px; }
.seg-mini button {
  min-width: 52px; height: 38px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font: inherit; font-size: .88rem; cursor: pointer;
}
.seg-mini button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.seg-mini .pg { min-width: 38px; width: 38px; border-radius: 999px; }
.seg-mini .pg-plain { background: var(--surface); }
.seg-mini .pg-paper { background: #FBF3E3; }
.seg-mini .pg-sky { background: #EAF2FB; }
.seg-mini .pg-mint { background: #E9F6F0; }
.seg-mini .pg[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

.word-pop {
  position: absolute; z-index: 30; width: 280px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lift);
}
.wp-word { font-family: var(--font-display); font-weight: 800; font-size: 1.2rem; margin: 0 0 4px; }
.wp-meaning { margin: 0 0 10px; }
.wp-meaning:empty { display: none; }

/* Page tints stay tints in dark mode, dimmed so they don't glare. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .reader[data-page="paper"] { background: #2A241A; color: #F3E9D6; }
  :root:not([data-theme="light"]) .reader[data-page="sky"] { background: #17222E; color: #DCE8F5; }
  :root:not([data-theme="light"]) .reader[data-page="mint"] { background: #15241D; color: #D8EFE4; }
  :root:not([data-theme="light"]) .seg-mini .pg-paper { background: #2A241A; }
  :root:not([data-theme="light"]) .seg-mini .pg-sky { background: #17222E; }
  :root:not([data-theme="light"]) .seg-mini .pg-mint { background: #15241D; }
}
:root[data-theme="dark"] .reader[data-page="paper"] { background: #2A241A; color: #F3E9D6; }
:root[data-theme="dark"] .reader[data-page="sky"] { background: #17222E; color: #DCE8F5; }
:root[data-theme="dark"] .reader[data-page="mint"] { background: #15241D; color: #D8EFE4; }
:root[data-theme="dark"] .seg-mini .pg-paper { background: #2A241A; }
:root[data-theme="dark"] .seg-mini .pg-sky { background: #17222E; }
:root[data-theme="dark"] .seg-mini .pg-mint { background: #15241D; }

@media (min-width: 560px) {
  .maker-row { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .mat-grid, .course-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media print {
  .reader-bar, .sheet, .word-pop, .maker-row { display: none !important; }
}

/* The Reader's one status line: "Getting the voice ready…" while the first clip renders. */
.rb-status {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 25;
  bottom: calc(var(--bar) + 76px + env(safe-area-inset-bottom, 0px));
  margin: 0; padding: 6px 14px; border-radius: 999px; font-size: .86rem; font-weight: 700;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); box-shadow: var(--shadow);
}
[data-hear].is-busy { opacity: .6; }
[data-hear].is-busy .ico, [data-hear].is-busy svg { animation: nia-pulse 1.2s infinite ease-in-out; }
[data-hear].is-playing { color: var(--accent); border-color: var(--accent); }

/* Voice picker in Me */
.voice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.voice-opt { position: relative; display: flex; align-items: center; gap: 6px; }
.voice-opt input { position: absolute; opacity: 0; pointer-events: none; }
.voice-opt label {
  flex: 1 1 auto; margin: 0; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--line-2);
  background: var(--surface); cursor: pointer; font-weight: 500; min-height: 60px;
}
.voice-opt label b { display: block; font-size: 1rem; }
.voice-opt label .small { display: block; line-height: 1.3; }
.voice-opt input:checked + label { border-color: var(--accent); background: var(--accent-soft); }
.voice-opt input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }
.voice-opt .icon-btn { width: 42px; height: 42px; }
