/* The lesson player (STORY-03.11): one step per screen, Back and Next in thumb reach, and the kinds
   of the teach family. Phone first; colours, spacing and type from tokens.css. */

.lp { display: flex; flex-direction: column; gap: var(--s5); max-width: 760px; }
.lp-head { display: grid; gap: var(--s2); }
.lp-head h1 { font-size: var(--fs-3xl); line-height: 1.1; }
.lp-where { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lp-where:focus { outline: none; }
.lp-step { display: grid; align-content: start; gap: var(--s4); min-width: 0; flex: 1 0 auto; }
.lp-step__title { font-size: var(--fs-2xl); line-height: 1.25; }
/* STORY-04.23: the header line keeps each part whole and breaks only at a dot; a title's emphasis is slanted; the
   bookmark sits at the right of the title. */
.lp-seg { white-space: nowrap; }
.lp-step__title em { font-style: italic; }
.lp-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.lp-title-row .rl { flex: none; margin: -6px -6px -6px 0; }
/* No big gap under a step's title (the owner's principle 3): its content's first heading sits at the step's own spacing. */
.lp-kind > .lp-blocks > :first-child { margin-top: 0; }
.lp-sample-line { padding: var(--s3) var(--s4); border-radius: var(--r-s); background: var(--paper-2); font-size: var(--fs-m); }
.lp-unshown, .lp-coming { display: flex; align-items: flex-start; gap: var(--s2); padding: var(--s3) var(--s4); border-radius: var(--r-s); background: var(--sun-tint); color: var(--ink); }
.lp-unshown > .i, .lp-coming > .i { flex: none; margin-top: 3px; }
.lp-failed p { font-size: var(--fs-l); }
.lp-end__title { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-2xl); }
.lp-end__title > .i { color: var(--teal); }
.lp-end__title:focus { outline: none; }
/* The end screen's buttons wrap when their words are long ("Next lesson: Lesson 2 of 3: Where the answer hides"), so on a phone
   a button never runs past its card (the 8A+8B close). A short label is one line, as before. */
.lp-end .btn { max-width: 100%; white-space: normal; padding-block: var(--s2); }

/* Back and Next: on screen with the page scrolled, above the tab bar on a phone. */
.lp-nav {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; justify-content: space-between; gap: var(--s3);
  margin-inline: calc(-1 * var(--s4)); padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom));
  background: var(--paper); border-top: 1px solid var(--line);
}
.lp-nav .btn { flex: 1 1 0; max-width: 220px; }
.lp-nav .btn:last-child { margin-inline-start: auto; }
/* When a field is scrolled to (the try's box as it is typed in), the page keeps clear the height of Back and Next and a
   line under the field, so the try's box and its word count end above the bar (STORY-04.13). */
html:has(.lp) { scroll-padding-bottom: calc(144px + env(safe-area-inset-bottom)); }

/* Content */
/* One column that may shrink below its content's width, so a wide table scrolls inside its own box, never the page. */
.lp-kind { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); min-width: 0; }
.lp-blocks { max-width: none; }
.lp-steps-list { counter-reset: lp-step; }
.lp-steps-list > li { position: relative; padding-inline-start: var(--s6); counter-increment: lp-step; }
.lp-steps-list > li::before { content: counter(lp-step); position: absolute; inset-inline-start: 0; font-weight: 700; color: var(--teal); }
.lp-source, .lp-script { display: grid; gap: var(--s2); padding: var(--s4); border-radius: var(--r-s); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.lp-script p, .lp-source p { padding: 2px var(--s2); border-radius: 6px; }
.lp-script[hidden] { display: none; }
.lp-audio { display: grid; gap: var(--s3); }
.is-answer { background: var(--teal-tint); box-shadow: inset 4px 0 0 var(--teal); }
.is-trap { box-shadow: inset 0 -2px 0 var(--line-strong); }
.lp-instructions { font-weight: 700; }
.lp-level { justify-self: start; padding: 2px var(--s3); border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink-2); font-size: var(--fs-s); font-weight: 700; }
.lp-blank { display: inline-block; min-width: 3.5em; padding: 0 var(--s1); border-bottom: 2px solid var(--ink); font-weight: 700; text-align: center; }
.lp-gap { padding: 0 var(--s1); border-radius: 4px; background: var(--sun-tint); color: var(--sun-ink); font-weight: 700; }
.lp-change { padding: 0 2px; border-radius: 4px; background: var(--sun-tint); color: var(--ink); box-shadow: inset 0 -2px 0 var(--sun-deep); }
.lp-tag {
  display: inline-grid; place-items: center; flex: none; min-width: 28px; height: 28px; padding: 0 var(--s2);
  border-radius: 14px; background: var(--teal); color: var(--surface); font-weight: 700; font-size: var(--fs-s);
}

/* Exercises */
.lp-exercise { display: grid; gap: var(--s5); }
.lp-item { display: grid; gap: var(--s3); min-width: 0; }
.lp-item__prompt { font-weight: 700; font-size: var(--fs-l); line-height: 1.4; margin-bottom: var(--s1); }
.lp-item .choice:has(input:disabled) { cursor: default; }
.lp-result { display: grid; gap: var(--s2); padding: var(--s3) var(--s4); border-radius: var(--r-s); background: var(--paper-2); }
.lp-result[hidden] { display: none; }
.lp-result:focus { outline: none; }
.lp-result:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.is-right > .lp-result, .lp-result.is-right { background: var(--teal-tint); }
.is-wrong > .lp-result, .lp-result.is-wrong { background: var(--coral-tint); }
.lp-verdict { display: flex; align-items: center; gap: var(--s2); }
.is-right .lp-verdict .i, .lp-result.is-right .lp-verdict .i { color: var(--teal); }
.is-wrong .lp-verdict .i, .lp-result.is-wrong .lp-verdict .i { color: var(--coral-deep); }
.lp-line blockquote { margin: var(--s1) 0 0; padding-inline-start: var(--s3); border-inline-start: 3px solid var(--teal); font-style: italic; }
.lp-check { display: flex; flex-wrap: wrap; gap: var(--s3); }
.lp-check .btn[hidden] { display: none; }
.lp-fill { display: flex; align-items: center; gap: var(--s2); margin-top: calc(-1 * var(--s3)); font-weight: 700; color: var(--coral-ink); }
.lp-trap { display: inline-block; padding: 0 var(--s2); border-radius: 10px; box-shadow: inset 0 0 0 1px var(--line-strong); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 700; text-transform: none; }
.lp-reasons { display: grid; gap: var(--s1); }

/* pattern */
.lp-parts { display: grid; gap: var(--s2); }
.lp-part { border-radius: var(--r-m); background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); }
.lp-part__btn {
  display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 52px; padding: var(--s2) var(--s4);
  border: 0; border-radius: var(--r-m); background: none; color: var(--ink); text-align: start;
  font-family: var(--display); font-size: var(--fs-l); font-weight: 700; cursor: pointer;
}
.lp-part__btn > span:nth-child(2) { flex: 1; }
.lp-part__btn[aria-expanded="true"] > .i { transform: rotate(180deg); }
.lp-part__btn:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.lp-part__panel { display: grid; gap: var(--s2); padding: 0 var(--s4) var(--s4); }
.lp-part__panel[hidden] { display: none; }
.lp-part__panel h3 { font-size: var(--fs-base); margin-top: var(--s2); }
.lp-serves { font-weight: 700; color: var(--teal-deep); }
.lp-starts { display: grid; gap: var(--s2); }
.lp-starts li { padding: var(--s2) var(--s3); border-radius: var(--r-s); background: var(--paper-2); }

/* rater */
.lp-points { display: grid; gap: var(--s3); }
.lp-point { display: grid; gap: var(--s2); padding: var(--s4); border-radius: var(--r-m); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.lp-point h3 { font-size: var(--fs-l); }
.lp-point__parts { display: flex; flex-wrap: wrap; gap: var(--s2); }
.lp-chip { display: inline-flex; align-items: center; gap: var(--s2); padding: 2px var(--s3) 2px 2px; border-radius: 16px; background: var(--paper-2); font-size: var(--fs-m); }

/* build */
.lp-build { display: grid; gap: var(--s3); }
.lp-build__part { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s3); padding: var(--s4); border-radius: var(--r-m); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.lp-build__part:focus { outline: none; }
.lp-build__body { display: grid; gap: var(--s2); min-width: 0; }
.lp-build__text { font-size: var(--fs-l); }
.lp-build__does { color: var(--ink-2); }
.lp-build__body h4 { font-size: var(--fs-base); }
.lp-changes { display: grid; gap: var(--s1); }
.lp-kind > .btn[hidden] { display: none; }
.lp-kind > .btn { justify-self: start; }

/* order */
.lp-tiles { display: grid; gap: var(--s2); }
.lp-tile { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s2) var(--s2) var(--s4); border-radius: var(--r-m); background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); }
.lp-tile__text { flex: 1; min-width: 0; font-weight: 700; }
.lp-tile__moves { display: flex; gap: var(--s2); flex: none; }

/* Basics (STORY-03.19): the correct, rewrite and mixed-check kinds, and the Basics page. */
.bx-sentence { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); padding: var(--s4); border-radius: var(--r-s); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.bx-word, .bx-gap {
  min-width: 44px; min-height: 44px; padding: 0 var(--s3); border: 0; border-radius: var(--r-s);
  background: var(--paper-2); color: var(--ink); font: inherit; font-size: var(--fs-l); cursor: pointer;
}
.bx-gap { min-width: 44px; padding: 0; background: none; box-shadow: inset 0 0 0 2px var(--line); color: var(--ink-2); font-weight: 700; }
.bx-word[aria-pressed="true"], .bx-gap[aria-pressed="true"] { background: var(--pick); color: var(--pick-ink); box-shadow: none; }
.bx-word:disabled, .bx-gap:disabled { cursor: default; }
.bx-word.is-answer, .bx-gap.is-answer { box-shadow: inset 0 -4px 0 var(--sun-deep); }
.bx-word:focus-visible, .bx-gap:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.bx-fixes, .bx-results { display: grid; gap: var(--s4); }
.bx-fixes:empty, .bx-results:empty { display: none; }
.bx-chosen { font-weight: 700; }
.bx-original { margin: 0; font-size: var(--fs-l); }
.lp-item textarea { width: 100%; }
.bx-compare { display: grid; gap: var(--s1); padding-inline-start: var(--s5); }
.bx-mixed { font-size: var(--fs-xl); }

.bx-head h1 { font-size: var(--fs-3xl); line-height: 1.1; }
.bx-optional { color: var(--ink-2); font-weight: 400; }
.bx-rule { margin-top: var(--s2); font-weight: 700; }
.bx-stage__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s2) var(--s4); margin-bottom: var(--s3); }
.bx-stage__head h2:focus { outline: none; }
.bx-stage__head p { color: var(--ink-2); font-size: var(--fs-m); }
.bx-stage__names { margin-bottom: var(--s3); color: var(--ink-2); }
.bx-units { display: grid; gap: var(--s2); }
.bx-unit {
  display: grid; gap: var(--s1); min-height: 44px; padding: var(--s3) var(--s4); border-radius: var(--r-m);
  background: var(--paper); box-shadow: inset 0 0 0 2px var(--line); color: var(--ink); text-decoration: none;
}
.bx-unit:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.bx-unit__n { font-size: var(--fs-s); font-weight: 700; color: var(--ink-2); }
.bx-unit__title { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); font-weight: 700; font-size: var(--fs-l); }
.bx-unit__why { font-size: var(--fs-m); color: var(--ink-2); }
.bx-unit__end { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); margin-top: var(--s1); }
.bx-unit__points { font-weight: 700; color: var(--teal-deep); }
.bx-coming { display: flex; align-items: flex-start; gap: var(--s2); margin-top: var(--s3); color: var(--ink-2); }
.bx-coming > .i { flex: none; margin-top: 3px; }
.bx-earned { font-size: var(--fs-xl); font-weight: 700; color: var(--teal-deep); }

@media (max-width: 860px) {
  .lp-head h1 { font-size: 1.75rem; }
  /* The tab bar is fixed at the bottom (shell.css): Back and Next sit just above it. */
  /* The step fills the screen, so Back and Next sit low, in thumb reach, on a short step too. */
  .lp { min-height: calc(100dvh - 210px - env(safe-area-inset-bottom)); }
  .lp-nav { bottom: calc(65px + env(safe-area-inset-bottom)); padding-bottom: var(--s3); }
  .lp-nav .btn { max-width: none; }
  /* A gap being typed in is scrolled clear of Back, Next and the tab bar, with room for its Check. */
  html:has(.lp) { scroll-padding-bottom: calc(200px + env(safe-area-inset-bottom)); }
  /* A gap already in view when it takes the focus is brought up too, so its Check clears the tab bar (STORY-04.49: the page's
     foot moved with the footer, and a gap could sit in view with its Check under the bar). */
  .lp-item input[type="text"] { scroll-margin-bottom: 140px; }
}
/* With the on-screen keyboard open the screen is short: Back and Next stay in the page, never over a gap or its Check. */
@media (max-width: 860px) and (max-height: 560px) {
  .lp-nav { position: static; }
}

/* STORY-04.45: the reader (views/journey-lesson.js), opened in the pop-up since STORY-04.48 (css/work-pop.css): its bar, then
   the lesson: its title (an h2) with "About n min" at the right, the where line, one segment per step, the step, and Back and
   Next at the foot. */
.jl { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); min-width: 0; }
.jl__body { min-width: 0; }
.lp.lp--embedded { max-width: none; min-height: 0; gap: var(--s4); scroll-margin-top: var(--s4); }
.lp-head__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.lp-title { font-size: var(--fs-2xl); line-height: 1.25; min-width: 0; }
.lp-title:focus { outline: none; }
.lp-about { flex: none; color: var(--ink-2); font-size: var(--fs-m); white-space: nowrap; }
.lp--embedded .lp-where, .lesson--embedded .lp-where { font-weight: 400; font-size: var(--fs-m); }
.lp-segs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--s1); margin-top: var(--s1); }
.lp-segs__bar { height: 5px; border-radius: 3px; background: var(--line-2); }
.lp-segs__bar.is-done { background: var(--c5); }
.lp-segs__bar.is-current { background: var(--teal); }
/* Back and Next at the foot of the detail area, one rule across it, each as wide as its words (the prototype's 03b). */
.lp--embedded .lp-nav { margin-inline: 0; padding-inline: 0; }
.lp--embedded .lp-nav .btn { flex: 0 0 auto; }
.lesson.lesson--embedded { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); min-width: 0; max-width: none; margin-inline: 0; }
.lesson--embedded .actions { margin-top: var(--s2); }

/* "Words for this part": a table of word, meaning and example with Review later on each row; a list at a phone's width. */
.jl-words { display: grid; gap: var(--s5); min-width: 0; }
.wd { display: grid; gap: var(--s3); min-width: 0; }
.wd-about { color: var(--ink-2); font-size: var(--fs-m); }
.wd-table { table-layout: fixed; }
.wd-table thead th:first-child { width: 24%; }
.wd-table thead th:last-child { width: 52px; }
.wd-table .wd-word { padding: var(--s2) var(--s3) var(--s2) 0; border-top: 1px solid var(--line); vertical-align: middle; font-family: var(--display); font-size: var(--fs-l); color: var(--ink); }
.wd-table td { padding-block: var(--s2); }
.wd-example { color: var(--ink-2); }
.wd-act .rl { margin: 0; }
@media (max-width: 860px) {
  .wd-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .wd-table, .wd-table tbody { display: block; }
  .wd-row { display: grid; grid-template-columns: minmax(0, 1fr) 44px; grid-template-areas: "word act" "meaning meaning" "example example"; column-gap: var(--s3); row-gap: var(--s1); padding: var(--s2) 0 var(--s3); border-top: 1px solid var(--line); }
  .wd-table .wd-word, .wd-table td { display: block; padding: 0; border: 0; text-align: start; }
  .wd-word { grid-area: word; align-self: center; }
  .wd-meaning { grid-area: meaning; }
  .wd-example { grid-area: example; font-size: var(--fs-m); }
  .wd-act { grid-area: act; justify-self: end; }
}
