/* ============================================================
   Lesson 01 — Next-token prediction
   ============================================================ */

.module {
  max-width: 62rem;
  margin: 0 auto;
  padding: 1.6rem 1.4rem 0;
}

html[data-mode="presenter"] .module {
  max-width: 76rem;
  padding-top: 0.15rem;
}

/* ---- head ---- */

.eyebrow {
  font-family: var(--font-body);
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--press);
  margin-bottom: 0.4rem;
}

.lesson-name {
  font-family: var(--font-display);
  font-weight: var(--w-title);
  font-size: 2rem;
  line-height: 1.12;
  letter-spacing: -0.015em;
  max-width: 40ch;
}

html[data-mode="presenter"] .lesson-name { font-size: 1.3rem; }
html[data-mode="presenter"] .hook { font-size: 0.88rem; }
html[data-mode="presenter"] .eyebrow { font-size: 0.65rem; margin-bottom: 0.15rem; }

.intro {
  margin-top: 0.7rem;
  max-width: 58ch;
  color: var(--mute);
  font-size: 1.05rem;
}

/* ---- sentence strip ----
   Each generated token is a discrete "sort": mono text carrying its
   own leading space (white-space: pre), plus a small stamp of the
   probability it was chosen at. At the terminal state the seams
   collapse — gaps, borders and stamps go — and the raw concatenation
   reads as prose for the first time. */

.strip {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.5rem 0.3rem;
  margin-top: 1.4rem;
  padding: 0.9rem 1rem;
  min-height: 5.6rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: background 0.5s ease, border-color 0.5s ease;
}

.chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 1.5px 0 var(--rule);
  padding: 0.22rem 0.45rem 0.14rem;
  transition: background 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease,
              padding 0.5s ease, border-radius 0.5s ease;
}

.chip .t {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  line-height: 1.3;
  white-space: pre;   /* the token's own leading space stays visible */
}

.chip .stamp {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--mute);
  max-height: 1.2em;
  opacity: 1;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  overflow: hidden;
}

.chip.seed { background: var(--paper); border-style: dashed; }
.chip.seed .stamp { color: var(--press); letter-spacing: 0.08em; text-transform: uppercase; }

.chip.fly { box-shadow: 0 6px 18px rgba(23, 26, 33, 0.25); }

/* terminal state: machinery dissolves into writing */
.strip.as-prose { gap: 0; background: transparent; border-color: transparent; }
.strip.as-prose .chip {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  padding: 0;
  border-radius: 0;
}
.strip.as-prose .chip .t { font-family: var(--font-body); font-size: 1.35rem; line-height: 1.5; }
.strip.as-prose .chip .stamp { max-height: 0; opacity: 0; }

html[data-mode="presenter"] .strip.as-prose .chip .t { font-size: 1.6rem; }

.instruction {
  margin-top: 1.1rem;
  color: var(--mute);
  font-size: 0.95rem;
}

/* ---- candidate rack ----
   The probability bar is the hero: a ruled gauge with ticks every
   10%, filled with solid press-blue ink. */

.rack {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.7rem;
}

.cand {
  display: grid;
  grid-template-columns: 2.1rem minmax(7.5rem, 11rem) 1fr 3.6rem;
  align-items: center;
  gap: 0.8rem;
  padding: 0.5rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

button.cand:hover { border-color: var(--press); }
button.cand:active { background: #fff; }

.cand .key {
  justify-self: center;
  font-size: 0.85rem;
}

.cand .tok {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  white-space: pre;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 5px;
  padding: 0.14rem 0.4rem;
  justify-self: start;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meter {
  position: relative;
  height: 1.5rem;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
}

/* ruler ticks every 10% — makes 94% vs 19% measurable from the back row */
.meter::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent calc(10% - 1px),
    rgba(23, 26, 33, 0.16) calc(10% - 1px),
    rgba(23, 26, 33, 0.16) 10%
  );
  pointer-events: none;
}

.fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 0;
  background: var(--press);
  transition: width 0.22s ease;
}

.fill.hatch {
  background: repeating-linear-gradient(
    -45deg,
    var(--mute) 0,
    var(--mute) 3px,
    transparent 3px,
    transparent 8px
  );
  opacity: 0.55;
}

.cand .pct {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.05rem;
  text-align: right;
}

/* model-pick flash */
.cand.picked {
  border-color: var(--press);
  background: #e6eafc;
  box-shadow: inset 0 0 0 2px var(--press);
}

/* the always-present sixth row: the rest of the vocabulary */
.cand.remainder {
  cursor: default;
  background: transparent;
  border-style: dashed;
  color: var(--mute);
}
.cand.remainder .tok {
  background: transparent;
  border: 0;
  padding-left: 0;
  font-size: 0.9rem;
  white-space: normal;
  line-height: 1.2;
}
.cand.remainder .pct { font-weight: 400; }
.cand.remainder .key { visibility: hidden; }

/* ---- completion panel ---- */

.finish {
  margin-top: 0.9rem;
  padding: 1.1rem 1.2rem;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}

.odds { font-size: 1.15rem; }
.odds strong {
  font-family: var(--font-mono);
  color: var(--press);
  font-size: 1.25em;
  white-space: nowrap;
}

.odds-note { color: var(--mute); font-size: 0.9rem; margin-top: 0.3rem; }

.finish-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.9rem; }

/* ---- controls ---- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.1rem 1.8rem;
  margin-top: 1.2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--rule);
}

.ctl label, .seed-label {
  display: block;
  font-family: var(--font-body);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 0.35rem;
}

.temp-ctl { min-width: 15rem; flex: 1 1 15rem; max-width: 22rem; }

.temp-val { color: var(--press); margin-left: 0.4em; }

input[type="range"] {
  width: 100%;
  accent-color: var(--press);
  height: 1.4rem;
  cursor: pointer;
}

.detents {
  display: flex;
  justify-content: space-between;
  margin-top: 0.15rem;
}

.detents button {
  background: none;
  border: 0;
  padding: 0.1rem 0.2rem;
  font-size: 0.78rem;
  color: var(--mute);
  cursor: pointer;
}
.detents button span { font-family: var(--font-mono); }
.detents button:hover { color: var(--press); }
.detents button[aria-pressed="true"] { color: var(--press); font-weight: 700; }

.action-ctl { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; padding-top: 1.3rem; }

.big-btn {
  border: 1px solid var(--press);
  background: var(--press);
  color: #fff;
  border-radius: 7px;
  padding: 0.5rem 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.big-btn kbd { background: rgba(255, 255, 255, 0.16); border-color: rgba(255, 255, 255, 0.35); color: #fff; }
.big-btn:hover { filter: brightness(1.12); }

.big-btn.ghost { background: var(--card); color: var(--ink); border-color: var(--rule); }
.big-btn.ghost kbd { background: var(--card); border-color: var(--rule); color: var(--mute); }
.big-btn.ghost:hover { border-color: var(--press); color: var(--press); filter: none; }

.big-btn[disabled] { opacity: 0.4; cursor: default; pointer-events: none; }

.seed-ctl { display: flex; flex-direction: column; align-items: flex-start; }
.seed-btns { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.seed-btn {
  border: 1px solid var(--rule);
  background: var(--card);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.88rem;
  color: var(--mute);
  cursor: pointer;
}
.seed-btn:hover { border-color: var(--press); color: var(--press); }
.seed-btn[aria-pressed="true"] {
  border-color: var(--press);
  color: var(--press);
  font-weight: 700;
  background: #e6eafc;
}

/* ---- takeaway + forward link ---- */

.takeaway {
  margin-top: 2rem;
  padding: 1.2rem 1.4rem;
  background: var(--card);
  border-left: 4px solid var(--press);
  border-radius: 0 var(--radius) var(--radius) 0;
  max-width: 62ch;
}
.takeaway h2 {
  font-family: var(--font-display);
  font-weight: var(--w-head);
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  margin-bottom: 0.5rem;
}
.takeaway p { margin-bottom: 0.7rem; color: var(--ink); }
.takeaway p:last-child { margin-bottom: 0; }

.mod-foot { margin-top: 1.6rem; }
.forward { display: inline-block; font-size: 1rem; }

/* ---- presenter scale-ups beyond the root font switch ---- */

html[data-mode="presenter"] .strip { min-height: 3rem; margin-top: 0.4rem; padding: 0.4rem 0.7rem; }
html[data-mode="presenter"] .chip .t { line-height: 1.2; }
html[data-mode="presenter"] .chip .stamp { font-size: 0.9rem; }
html[data-mode="presenter"] .rack { margin-top: 0.3rem; gap: 0.2rem; }
html[data-mode="presenter"] .cand { padding: 0.2rem 0.9rem; gap: 1rem; }
html[data-mode="presenter"] .meter { height: 1.5rem; }
html[data-mode="presenter"] .cand .tok { font-size: 1.05rem; line-height: 1.2; padding: 0.1rem 0.35rem; }
html[data-mode="presenter"] .cand .pct { font-size: 1.15rem; }
html[data-mode="presenter"] .cand .key { font-size: 0.95rem; }
html[data-mode="presenter"] .cand.remainder .tok { font-size: 0.95rem; }

/* presenter controls: one slim band — the presenter mostly drives by
   keyboard; these stay visible as a reference, not the main event */
html[data-mode="presenter"] .controls {
  flex-wrap: nowrap;
  align-items: flex-start;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  gap: 1.2rem;
}
html[data-mode="presenter"] .temp-ctl { flex: 0 1 14rem; min-width: 12.5rem; }
html[data-mode="presenter"] .ctl label,
html[data-mode="presenter"] .seed-label { font-size: 0.6rem; margin-bottom: 0.1rem; }
html[data-mode="presenter"] .detents button { font-size: 0.6rem; }
html[data-mode="presenter"] input[type="range"] { height: 1.1rem; }
html[data-mode="presenter"] .action-ctl { padding-top: 0.4rem; flex-wrap: nowrap; }
html[data-mode="presenter"] .big-btn { font-size: 0.7rem; padding: 0.3rem 0.55rem; white-space: nowrap; }
html[data-mode="presenter"] .seed-label { display: none; }
html[data-mode="presenter"] .seed-btns { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
html[data-mode="presenter"] .seed-btn { font-size: 0.6rem; line-height: 1.1; padding: 0.12rem 0.45rem; white-space: nowrap; }
html[data-mode="presenter"] .detents button { padding: 0; }
html[data-mode="presenter"] .detents { margin-top: 0; }

/* ---- small screens ---- */

@media (max-width: 680px) {
  .module { padding-inline: 1rem; }
  .lesson-name { font-size: 1.5rem; }
  .cand {
    grid-template-columns: 1.5rem minmax(5.5rem, 7.5rem) 1fr 3.1rem;
    gap: 0.5rem;
    padding: 0.45rem 0.55rem;
  }
  .cand .tok { font-size: 0.95rem; }
  .cand .pct { font-size: 0.95rem; }
  .action-ctl { padding-top: 0.2rem; }
}

/* ---- touch targets ----
   This lesson has its own control classes (.seed-btn, its own range height),
   and this file loads after site.css, so the shared touch rules need
   restating here to win. */
@media (hover: none) and (pointer: coarse) {
  .seed-btn { min-height: 44px; padding-block: 0.55rem; }
  input[type="range"] { height: 44px; }
  .detents button { min-height: 44px; }
  .big-btn { min-height: 44px; }
}
