/* practice.css â€” the practice page (SPEC Â§6.2 keyboard-aware layout, Â§6.3â€“6.5, Â§8.4 miss view, S4 summary) and the
   student pages (S1 home, S2 pick, S5 review, S6 explorer, S7 settings) + the parent progress page (PA3).
   Phones / tablets in portrait / whenever the on-screen keyboard is open: a full-height flex column sized to the
   visual viewport (--vvh, set by student-practice.js), the dock (band + input + buttons) pinned right above the
   keyboard. Chromebooks/desktops â‰¥ 900 px with no keyboard open: a roomier centered column. No inline styles (CSP). */

/* ---------- Practice page frame ---------- */
body.practice-page { min-height: 0; }
main.practice { height: var(--vvh, 100dvh); display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.p-loading { margin: auto; }
.p-fail { padding-block: 32px; }

.p-head { flex: none; height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 var(--gutter);
  background: var(--cream); border-bottom: 1px solid var(--line); }
.p-exit { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 12px; border: 2px solid var(--line-strong);
  border-radius: 10px; background: var(--card); color: var(--pine); font: inherit; font-size: .95rem; font-weight: 800; cursor: pointer; }
.p-mode { font-family: var(--display); font-weight: 800; font-size: 1.05rem; color: var(--pine); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-count { margin-left: auto; font-weight: 800; font-size: .95rem; color: var(--muted); white-space: nowrap; }
.p-head-speaker { display: inline-flex; color: var(--forest-2); }
.practice.speaking .wave { animation: wave .9s ease-in-out infinite; }
.practice.speaking .wave-2 { animation-delay: .15s; }
@keyframes wave { 50% { opacity: .25; } }

.p-main { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px var(--gutter) 10px; -webkit-overflow-scrolling: touch; }
.p-stage { max-width: 720px; margin: 0 auto; }

/* ---------- Dock: hint band + THE input + one row of buttons ---------- */
.p-dock { flex: none; position: relative; padding: 6px var(--gutter) calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--cream); border-top: 1px solid var(--line); }
.p-dock > * { max-width: 720px; margin-inline: auto; }
.p-label { display: block; margin: 0 auto 4px; font-size: .92rem; }
.p-inputwrap { position: relative; }
.p-input, input.p-input[type="text"] { width: 100%; min-height: 58px; padding: 8px 14px; border: 2px solid var(--line-strong);
  border-radius: var(--r-sm); background: var(--card); color: var(--ink); font-family: var(--text); font-weight: 800;
  font-size: 1.75rem; line-height: 1.2; letter-spacing: .04em; }
.p-input:focus { border-color: var(--forest); outline: 3px solid var(--ring); outline-offset: 0; }
.p-input.gated { background: var(--cream-2); }
.p-input::placeholder { color: var(--muted); font-weight: 700; font-size: 1.15rem; letter-spacing: 0; }

/* The band overlays the bottom of the clue area, 6 px above the input; its left edge = the input's. */
.p-band-wrap { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); height: 54px; pointer-events: none; border-radius: var(--r-sm); }
.p-band-wrap.cue { outline: 3px solid var(--sun); animation: cue .45s ease-in-out 2; }
@keyframes cue { 50% { outline-color: var(--sun-deep); } }
.p-band { display: block; width: 100%; height: 100%; border-radius: var(--r-sm); }
.flash-canvas { opacity: 0; will-change: opacity; }
.flash-canvas.flash-on { opacity: 1; }

.p-buttons { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; margin-top: 10px; }
.p-btn { min-height: 52px; padding: .45em .35em; font-size: 1rem; }
.p-btn.btn-line { background: var(--card); }
.lbl-long { display: none; }
@media (min-width: 600px) { .lbl-long { display: inline; } .lbl-short { display: none; } }
.p-tap { display: flex; width: 100%; margin-bottom: 8px; animation: tap-pulse 1.4s ease-in-out infinite; }
@keyframes tap-pulse { 50% { box-shadow: 0 4px 0 var(--sun-deep), 0 0 0 6px var(--sun-soft); } }
.p-msg { margin-bottom: 8px; padding: 8px 12px; border-radius: var(--r-sm); border: 1px solid var(--sun-line); background: var(--sun-soft);
  color: var(--sun-ink); font-weight: 700; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.p-msg.error { border-color: var(--berry-line); background: var(--berry-soft); color: var(--berry-ink); }
.p-msg.ok { border-color: var(--mint-line); background: var(--mint); color: var(--pine); }
.shake { animation: shake .35s ease-in-out; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- Clues (Learning mode) ---------- */
.practice .clues { gap: 12px; font-size: 1.15rem; }
.clue-label { font-weight: 800; color: var(--forest-2); }
.clue-na { color: var(--muted); font-style: italic; font-weight: 600; }
.clue-listen { margin-left: 8px; min-height: 32px; padding: 0 10px; border: 2px solid var(--line-strong); border-radius: 999px;
  background: var(--card); color: var(--pine); font: inherit; font-size: .85rem; font-weight: 800; cursor: pointer; vertical-align: middle; }
mark.clue-word { background: var(--sun-soft); color: var(--pine); font-weight: 800; padding: 0 .15em; border-radius: 4px; }
/* No "?" tip while a word flashes (Imprinting, Study mode's flash, a Hint from its yellow outline to the end of its flash):
   nothing asks for the eyes, and no tip sheet can cover the flash. */
#practice[data-phase="imprinting"] .tip-q, #practice[data-phase="study_flashing"] .tip-q, #practice[data-phase="reflash_wait"] .tip-q,
#practice.hint-cue .tip-q { visibility: hidden; }
.p-speaker-big { display: none; }

/* ---------- Audio flashcards ---------- */
.p-listen { display: grid; justify-items: center; gap: 10px; padding: 10px 0; text-align: center; }
.p-speaker-hero { display: grid; place-items: center; width: 136px; height: 136px; border-radius: 50%; background: var(--sage);
  color: var(--forest-2); border: 2px solid var(--sage-line); }
.practice.speaking .p-speaker-hero { box-shadow: 0 0 0 10px var(--sun-soft); }
html.kb-open .p-speaker-hero { width: 72px; height: 72px; }
html.kb-open .p-speaker-hero svg { width: 48px; height: 48px; }

/* ---------- Imprinting card ---------- */
.flip-card { max-width: 560px; height: clamp(140px, 30vh, 240px); margin: 4px auto; perspective: 1200px; }
.flip-inner { position: relative; width: 100%; height: 100%; transition: transform .4s ease; transform-style: preserve-3d; }
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-card.instant .flip-inner { transition: none; }
.face { position: absolute; inset: 0; display: grid; place-items: center; border: 2px solid var(--line); border-radius: var(--r-lg);
  background: var(--card); box-shadow: var(--tile-shadow); backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.face.back { transform: rotateY(180deg); background: var(--sage); border-color: var(--sage-line); }
.card-canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: var(--r-lg); }
.card-ready, .card-back { margin: 0; font-family: var(--display); font-weight: 800; font-size: 1.5rem; color: var(--forest-2); }

/* ---------- Result (Correct! / miss view) ---------- */
.p-result { max-width: 720px; margin: 12px auto 0; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card); }
.p-result.ok { background: var(--mint); border-color: var(--mint-line); }
.p-result.miss { background: var(--card); border-color: var(--sun-line); }
.p-verdict { margin: 0 0 4px; font-family: var(--display); font-weight: 800; font-size: 1.3rem; color: var(--pine); }
.p-word { margin: 0; font-family: var(--text); font-weight: 800; font-size: 2.25rem; line-height: 1.25; letter-spacing: .04em; color: var(--pine); overflow-wrap: anywhere; }
.p-letters .l { display: inline-block; padding: 0 1px; }
.p-letters .l.fix { background: var(--sun); color: var(--on-sun); border-radius: 4px; box-shadow: inset 0 -5px 0 var(--on-sun); }
.p-typed { margin: 8px 0 0; }
.small-letters { font-weight: 800; font-size: 1.3rem; letter-spacing: .04em; }
.small-letters .l.off { text-decoration: underline dotted var(--berry-ink); text-decoration-thickness: 3px; text-underline-offset: 5px; }
.p-copy-note { margin: 8px 0 0; font-weight: 700; }
.p-skip { margin-top: 8px; }

/* ---------- Intro, device checks, summary ---------- */
.p-intro { padding-top: 6px; }
.p-intro-title { margin: 0; }
.p-intro .lede { margin: 0; }
.p-intro-count { font-weight: 800; color: var(--pine); margin: 0; }
.btn-big { min-height: 60px; padding: .8em 2.4em; font-size: 1.2rem; }
.device-checks { border: 1px dashed var(--line-strong); border-radius: var(--r); padding: 12px 14px; background: var(--card); }
.device-checks summary { cursor: pointer; font-weight: 800; color: var(--pine); }
.device-checks .stack { margin-top: 10px; }
.device-check h3 { margin-bottom: .2em; }
.device-check p { margin: 0 0 .5em; }
.kb-input { max-width: 280px; font-weight: 800; letter-spacing: .04em; }
.check-result p { margin: 8px 0 0; }
.p-summary { padding-top: 8px; }
.p-summary h1:focus { outline: none; } /* focused only so screen readers start here */
.p-note { margin: 0; padding: 10px 14px; border-left: 4px solid var(--sun); border-radius: var(--r-sm); background: var(--cream); font-weight: 700; }
/* Parent pop quiz (/parent/quiz): numbered word cards a parent reads aloud; prints one card per block */
.quiz-list { margin: 0; padding: 0; list-style: none; }
.quiz-word { padding: 14px 16px; }
.quiz-word p { margin: 0; }
.quiz-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.quiz-n { min-width: 1.5em; font-weight: 800; color: var(--muted); }
.quiz-spelling { flex: 1 1 auto; font-size: 1.5rem; font-weight: 800; letter-spacing: .02em; color: var(--pine); }
.quiz-marks { display: flex; gap: 14px; }
.level-chips { display: flex; flex-wrap: wrap; gap: 6px; }
@media print {
  .no-print { display: none !important; }
  .quiz-word { break-inside: avoid; border: 1px solid #000; box-shadow: none; background: #fff; color: #000; }
  .quiz-spelling { color: #000; }
}
/* Two-tone list bars: mastered (dark) inside learned (light) */
.bar.two { position: relative; }
.bar.two > span { position: absolute; inset: 0 auto 0 0; }
.bar.two > .learned { background: #a9cdb7; background: color-mix(in srgb, var(--forest-2) 40%, var(--cream-2)); }
.bar.two > .mastered { background: var(--forest-2); }
.bar-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; font-size: .85rem; color: var(--muted); }
.bar-legend i { display: inline-block; width: 12px; height: 12px; margin-right: 5px; border-radius: 3px; vertical-align: -1px; }
.bar-legend .k-mastered { background: var(--forest-2); }
.bar-legend .k-learned { background: #a9cdb7; background: color-mix(in srgb, var(--forest-2) 40%, var(--cream-2)); }
/* Study mode: the step label over the card / speaker, and the summary's "Keep studying" list */
.p-step { margin: 0 0 8px; }
.keep-list { padding: 14px 16px; border: 2px solid var(--sun); border-radius: var(--r); background: var(--cream); }
.keep-list h2 { margin: 0; }
.keep-words { display: grid; gap: 6px 18px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr)); margin: 0; padding: 0;
  list-style: none; font-weight: 800; font-size: 1.25rem; letter-spacing: .02em; color: var(--pine); }
.honeycomb { display: flex; flex-wrap: wrap; gap: 4px; color: var(--forest); }
.hex { flex: none; }
.hex-no, .hex-skip { color: var(--line-strong); }
.p-exit-dialog .actions { margin-top: 12px; }

/* ---------- Little room (an on-screen keyboard is open on a phone): keep the clues visible ---------- */
@media (max-height: 480px) {
  .p-main { padding-top: 8px; padding-bottom: 6px; }
  .p-dock { padding-top: 4px; padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
  .p-label { margin-bottom: 2px; font-size: .85rem; }
  .p-input, input.p-input[type="text"] { min-height: 50px; padding-block: 4px; }
  .p-buttons { margin-top: 6px; }
  .p-btn { min-height: 48px; }
  .p-tap { min-height: 40px; margin-bottom: 4px; padding-block: .3em; }
  .p-msg { margin-bottom: 4px; padding: 4px 10px; }
  .practice .clues { gap: 6px; }
  .p-result { margin-top: 6px; padding: 8px 12px; }
  .p-verdict { font-size: 1.1rem; }
  .flip-card { height: 120px; }
}

/* ---------- Roomy layout: Chromebooks / desktops with a physical keyboard ---------- */
@media (min-width: 900px) and (min-height: 560px) {
  html:not(.kb-open) main.practice { height: auto; min-height: 100vh; overflow: visible; }
  html:not(.kb-open) .p-head { height: 56px; }
  html:not(.kb-open) .p-main { flex: none; overflow: visible; padding-top: 28px; }
  html:not(.kb-open) .p-dock { border-top: 0; background: transparent; padding-top: 12px; }
  html:not(.kb-open) .p-speaker-big { display: flex; justify-content: center; margin-bottom: 10px; color: var(--forest-2); }
  html:not(.kb-open) .practice .clues { font-size: 1.25rem; }
}

/* ---------- Student pages (S1, S2, S5â€“S7) ---------- */
.kid-top { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; }
.kid-tiles { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.mode-tile { display: flex; flex-direction: column; gap: 6px; padding: 22px; border: 1px solid var(--sage-line); border-radius: var(--r-lg);
  background: var(--sage); color: var(--ink); text-decoration: none; box-shadow: var(--tile-shadow); transition: transform .15s, border-color .15s; }
.mode-tile:hover { transform: translateY(-2px); border-color: var(--forest); color: var(--ink); }
.mode-tile h2, .mode-tile h3 { margin: 0; }
.mode-tile p { margin: 0; }
.mode-tile .tile-go { margin-top: auto; padding-top: 8px; font-weight: 800; color: var(--forest); }
.keep-going { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.keep-going p { margin: 0; }
.mastery { display: grid; gap: 14px; }
.mastery-row p { margin: 0 0 4px; }
.bar { height: 14px; border: 1px solid var(--line); border-radius: 7px; background: var(--cream-2); overflow: hidden; }
.bar > span { display: block; height: 100%; width: 0; background: var(--forest-2); border-radius: 7px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 40px)); gap: 4px; }
.cal-head { font-size: .75rem; font-weight: 800; color: var(--muted); text-align: center; }
.cal-day { display: grid; place-items: center; aspect-ratio: 1; font-size: .8rem; font-weight: 700; color: var(--muted); position: relative; }
.cal-day .hex { position: absolute; inset: 0; margin: auto; width: 34px; height: 36px; }
.cal-day.on { color: var(--on-forest); }
.cal-day.on .hex { color: var(--forest-2); }
.cal-day span { position: relative; }
.cal-day.today { outline: 2px solid var(--sun); border-radius: 8px; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 14px; border: 2px solid var(--line-strong);
  border-radius: 999px; background: var(--card); color: var(--pine); font: inherit; font-weight: 800; cursor: pointer; }
.chip-btn:hover { border-color: var(--forest); }
.chip-btn .n { font-weight: 700; color: var(--muted); }
.pick-options { display: grid; gap: 16px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 14px; border: 2px solid var(--line-strong);
  border-radius: var(--r-sm); background: var(--card); font-weight: 800; cursor: pointer; }
.seg input { accent-color: var(--forest); width: 18px; height: 18px; }
.more { border: 1px solid var(--line); border-radius: var(--r); background: var(--card); padding: 12px 16px; }
.more summary { cursor: pointer; font-weight: 800; color: var(--pine); min-height: 32px; }
.more[open] summary { margin-bottom: 12px; }
.list-choices { display: grid; gap: 8px; }
.list-choice { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--cream); }
.list-choice p { margin: 0; }
.review-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.review-card .word { margin: 0; font-family: var(--text); font-weight: 800; font-size: 1.7rem; letter-spacing: .03em; color: var(--pine); }
.dots { display: inline-flex; gap: 4px; font-size: 1.1rem; color: var(--forest-2); letter-spacing: 2px; }
.word-row { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--card); }
.word-row summary { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; cursor: pointer; font-weight: 800; font-size: 1.15rem; color: var(--pine); }
.word-row summary .meta { font-weight: 600; font-size: .9rem; color: var(--muted); }
.word-row .body { padding: 0 14px 14px; }
.explore-list { display: grid; gap: 8px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; }
.voice-list { display: grid; gap: 8px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ---------- Parent progress (PA3) ---------- */
.tiles-4 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.chart { display: grid; grid-template-columns: repeat(var(--n, 14), minmax(0, 1fr)); gap: 6px; align-items: end; height: 170px; padding-top: 8px; }
.chart-col { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 1px; }
.chart-col .seg-clean { background: var(--forest-2); }
.chart-col .seg-assisted { background: var(--sun); }
.chart-col .seg-missed { background: var(--berry); }
.chart-col span { display: block; border-radius: 3px; min-height: 0; }
.chart-labels { display: grid; grid-template-columns: repeat(var(--n, 14), minmax(0, 1fr)); gap: 6px; font-size: .7rem; color: var(--muted); text-align: center; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .88rem; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .k-clean { background: var(--forest-2); } .legend .k-assisted { background: var(--sun); } .legend .k-missed { background: var(--berry); }
.reason-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.flag { font-size: .85rem; color: var(--sun-ink); }

/* ---------- Bigger text (student setting) ---------- */
body.big-text { font-size: 1.3rem; }
body.big-text .practice .clues { font-size: 1.35rem; }
body.big-text .p-input { font-size: 2rem; }

@media (prefers-reduced-motion: reduce) {
  .flip-inner, .p-tap, .p-band-wrap.cue, .shake, .practice.speaking .wave { transition: none !important; animation: none !important; }
  .shake .p-input { border-color: var(--sun-deep); }
}
@media (forced-colors: active) {
  .p-input, .p-exit, .face, .chip-btn, .seg label, .mode-tile, .p-result { border: 2px solid ButtonText; }
  .p-letters .l.fix { outline: 2px solid Highlight; }
  .bar > span, .chart-col span { background: Highlight; }
}
