/* language.css · P42's page: the sample, the loss, the induction test, the
   letter by letter sentence, the embeddings and heads, the features, writing
   and the history. Every colour, size of type and radius is a token of the
   design system; the controls are its parts. The plots are canvases the page
   paints with the same tokens (readColors in app.js). */

.lm { flex: 1; min-height: 0; overflow: auto; background: var(--paper); }
.lm-wrap { display: flex; flex-direction: column; max-width: 1240px; margin: 0 auto; padding: 28px 32px 80px; box-sizing: border-box; color: var(--ink); font-size: var(--fs-13); line-height: var(--lh-13); }
.lm .num { font-variant-numeric: tabular-nums; }
.lm .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lm h1 { margin: 0 0 6px; font-size: var(--fs-16); line-height: var(--lh-16); font-weight: var(--fw-550); }
.lm h2 { margin: 0; font-size: var(--fs-16); line-height: var(--lh-16); font-weight: var(--fw-550); }
.lm h3 { margin: 0 0 4px; font-size: var(--fs-14); line-height: var(--lh-14); font-weight: var(--fw-550); }
.lm p { margin: 0; }
.lm a { color: inherit; text-decoration-color: var(--line-4); text-underline-offset: 3px; }
.lm a:hover { color: var(--accent-ink); text-decoration-color: currentColor; }
.lm .card { background: var(--raised); box-shadow: 0 0 0 var(--px) var(--line-3); border-radius: var(--r-contain); }
.lm .sub { margin: 0 0 16px; color: var(--ink-2); max-width: 40em; text-wrap: pretty; }

/* the bar's facts */
.lm-barfact { color: var(--ink-3); font-size: var(--fs-12); line-height: var(--lh-12); white-space: nowrap; }
.lm-barfact b { color: var(--ink); font-weight: var(--fw-500); }

/* the hero: what it is and its controls, and the sample as it writes */
.lm .hero { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 48px; align-items: start; padding-bottom: 40px; }
.lm .lead { color: var(--ink-2); max-width: 36em; text-wrap: pretty; margin-bottom: 20px; }
.lm .lead b { color: var(--ink); font-weight: var(--fw-500); }
.lm .controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lm .controls kbd { margin-left: 6px; }
.lm-slider { display: grid; grid-template-columns: 96px minmax(0, 260px); gap: 12px; align-items: center; margin-top: 16px; }
.lm-k { color: var(--ink-2); }
.lm-slider output { color: var(--ink); font-variant-numeric: tabular-nums; min-width: 2.6em; text-align: right; }
.lm .own { display: none; margin-top: 16px; }
.lm .own[data-open] { display: block; }
.lm .own .row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 8px; color: var(--ink-2); }
.lm-area { width: 100%; }
.lm-area textarea { min-height: 120px; resize: vertical; }
.lm-write textarea { min-height: 160px; font-size: var(--fs-16); line-height: var(--lh-16); }
.lm .sample-wrap { padding: 20px 24px; background: var(--raised); box-shadow: 0 0 0 var(--px) var(--line-3); border-radius: var(--r-contain); }
.lm .sample { font-size: var(--fs-18); line-height: 1.6; min-height: 9.6em; white-space: pre-wrap; overflow-wrap: anywhere; }
.lm .sample .c { transition: color 500ms var(--ease-quad); }
.lm .prompt { color: var(--accent-ink); font-weight: var(--fw-550); }
.lm .caption { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 14px; color: var(--ink-3); font-size: var(--fs-12); line-height: var(--lh-12); }
.lm .ramp { display: inline-flex; align-items: center; gap: 8px; }
.lm .ramp i { display: inline-block; width: 72px; height: 6px; border-radius: var(--r-mark); background: linear-gradient(to right, color-mix(in oklab, var(--ink) 18%, var(--raised)), var(--ink)); }

/* sections */
.lm .s { padding: 40px 0; box-shadow: inset 0 var(--px) 0 var(--line-2); }
.lm .s-head { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 48px; margin-bottom: 24px; align-items: start; }
.lm .s-head p { color: var(--ink-2); max-width: 42em; text-wrap: pretty; }

/* loss and induction: a plot with its facts beside it */
.lm .loss, .lm .ind { display: grid; grid-template-columns: minmax(0, 1fr) 240px; }
.lm .plot { position: relative; padding: 16px 8px 12px 16px; }
.lm .plot canvas { display: block; width: 100%; height: 300px; }
.lm .side { box-shadow: inset var(--px) 0 0 var(--line-2); padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.lm .fact-k { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; color: var(--ink-3); font-size: var(--fs-12); line-height: var(--lh-12); }
.lm .fact-v { font-size: var(--fs-20); line-height: var(--lh-20); font-weight: var(--fw-500); }
.lm .fact-v small { margin-left: 4px; font-size: var(--fs-12); color: var(--ink-3); font-weight: var(--fw-400); }
.lm .sw { width: 10px; height: 10px; border-radius: var(--r-mark); display: inline-block; }
.lm .tip { position: absolute; z-index: 2; pointer-events: none; padding: 6px 10px; border-radius: var(--r-row); background: var(--raised); box-shadow: 0 0 0 var(--px) var(--line-3), 0 6px 20px color-mix(in oklab, var(--ink) 10%, transparent); font-size: var(--fs-12); line-height: var(--lh-12); white-space: nowrap; opacity: 0; transition: opacity 120ms var(--ease-quad); }
.lm .tip[data-on] { opacity: 1; }
.lm .tip b { font-weight: var(--fw-550); }
.lm .ok { color: var(--chart-3); }

/* switching heads off */
.lm .iheads-k { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 48px; margin-top: 28px; align-items: start; }
.lm .iheads-k p { color: var(--ink-2); max-width: 42em; }
.lm .iheads { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.lm .ih { appearance: none; font: inherit; color: inherit; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 0; border-radius: var(--r-contain); background: var(--raised); box-shadow: 0 0 0 var(--px) var(--line-3); cursor: default; transition: background 150ms var(--ease-quad); }
.lm .ih:hover { background: var(--plane-hover); }
.lm .ih:focus-visible { outline: none; box-shadow: var(--ring-in); }
.lm .ih b { font-weight: var(--fw-550); }
.lm .ih span { color: var(--ink-2); font-size: var(--fs-12); line-height: var(--lh-12); }
.lm .ih i { font-style: normal; color: var(--ink); font-weight: var(--fw-500); }
.lm .ih[aria-pressed="true"] { background: var(--well); box-shadow: inset 0 0 0 var(--px) var(--line-4); }
.lm .ih[aria-pressed="true"] b { text-decoration: line-through; color: var(--ink-3); }
.lm .ablnote { min-height: 20px; margin-top: 12px; color: var(--accent-ink); }
.lm .probe { display: grid; gap: 4px; margin-top: 24px; }
.lm .probe-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 24px; align-items: baseline; }
.lm .pl { color: var(--ink-3); }
.lm .pr { font-family: var(--font-mono); font-size: var(--fs-18); line-height: 1.5; letter-spacing: 0.04em; overflow-wrap: anywhere; }
.lm .pr span { transition: color 600ms var(--ease-quad); }
.lm .rep { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 48px; margin-top: 24px; padding-top: 20px; box-shadow: inset 0 var(--px) 0 var(--line-2); align-items: start; }
.lm .rep-k { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; color: var(--ink-2); }
.lm .rep p { color: var(--ink-2); max-width: 42em; text-wrap: pretty; }
.lm .indkey { margin-top: 18px; color: var(--ink-3); font-size: var(--fs-12); line-height: var(--lh-12); max-width: 64em; }

/* the sentence, letter by letter */
.lm .lens-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 40px; align-items: start; }
.lm .passage { display: flex; flex-wrap: wrap; padding: 8px 4px; border-radius: var(--r-contain); font-size: var(--fs-24); line-height: 1.9; outline: none; }
.lm .passage:focus-visible { box-shadow: var(--ring-in); }
.lm .lw { display: inline-flex; white-space: nowrap; }
.lm .lc { position: relative; display: inline-block; min-width: 0.32em; padding: 0 1px; text-align: center; border-radius: var(--r-key); transition: color 500ms var(--ease-quad), background 120ms var(--ease-quad); }
.lm .lc::after { content: ""; position: absolute; left: 12%; right: 12%; bottom: 0.16em; height: 3px; border-radius: 2px; background: var(--accent-ink); opacity: var(--a, 0); transition: opacity 120ms var(--ease-quad); }
.lm .lc:hover { background: var(--accent-tint); }
.lm .lc[data-sel] { background: var(--accent-tint); box-shadow: inset 0 0 0 var(--px) var(--accent-line); }
.lm .lc[data-sp] { color: transparent !important; }
.lm .lc[data-sp]::before { content: ""; position: absolute; left: 50%; top: 58%; width: 3px; height: 3px; margin: -1.5px 0 0 -1.5px; border-radius: 50%; background: var(--sp, var(--ink-3)); }
.lm .headnote { margin-top: 12px; color: var(--ink-3); }
.lm .guess { padding: 20px; }
.lm .bars { display: grid; gap: 4px; }
.lm .bar { display: grid; grid-template-columns: 64px minmax(0, 1fr) 44px; gap: 10px; align-items: center; padding: 2px 4px; border-radius: var(--r-row); }
.lm .bar:hover { background: var(--plane-hover); }
.lm .bar .ch { font-weight: var(--fw-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lm .bar .tr { height: 8px; border-radius: var(--r-mark); background: var(--well); overflow: hidden; }
.lm .bar .tr i { display: block; height: 100%; border-radius: var(--r-mark); background: color-mix(in oklab, var(--accent-ink) 55%, var(--raised)); transition: width 250ms var(--ease-quad); }
.lm .bar[data-hit] .tr i { background: var(--accent-ink); }
.lm .bar[data-hit] .ch { color: var(--accent-ink); }
.lm .bar .pc { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.lm .mean { margin-top: 16px; padding-top: 14px; box-shadow: inset 0 var(--px) 0 var(--line-2); color: var(--ink-2); }
.lm .mean b { display: block; color: var(--ink); font-size: var(--fs-20); line-height: var(--lh-20); font-weight: var(--fw-500); }

/* embeddings and heads */
.lm .two { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; }
.lm .two .card { display: flex; flex-direction: column; padding: 20px; }
.lm .map-c { display: block; width: 100%; height: 340px; }
.lm .legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; color: var(--ink-2); font-size: var(--fs-12); line-height: var(--lh-12); }
.lm .legend span { display: inline-flex; align-items: center; gap: 6px; }
.lm .heads { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.lm .head { appearance: none; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 6px; padding: 8px 8px 6px; border: 0; border-radius: var(--r-contain); background: var(--paper); box-shadow: 0 0 0 var(--px) var(--line-3); cursor: default; transition: background 150ms var(--ease-quad); }
.lm .head:hover { background: var(--plane-hover); }
.lm .head:focus-visible { outline: none; box-shadow: var(--ring-in); }
.lm .head[aria-pressed="true"] { box-shadow: 0 0 0 1.25px var(--accent); }
.lm .head canvas { display: block; width: 100%; aspect-ratio: 1; image-rendering: pixelated; border-radius: var(--r-key); }
.lm .head span { color: var(--ink-2); font-size: var(--fs-11); line-height: var(--lh-11); text-align: left; }
.lm .headkey { margin-top: auto; padding-top: 16px; color: var(--ink-3); }

/* features and steering */
.lm .feat-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-bottom: 20px; color: var(--ink-2); }
.lm .feats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.lm .feat { padding: 16px 18px; border-radius: var(--r-contain); background: var(--raised); box-shadow: 0 0 0 var(--px) var(--line-3); }
.lm .feat[data-on] { box-shadow: 0 0 0 1.25px var(--accent); }
.lm .feat-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.lm .feat-h > div { display: flex; flex-direction: column; gap: 2px; }
.lm .feat-h b { font-weight: var(--fw-550); }
.lm .feat-h span { color: var(--ink-2); font-size: var(--fs-12); line-height: var(--lh-12); }
.lm .feat-h [data-r="button"] { flex: none; }
.lm .feat-x { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 0.55fr); font-family: var(--font-mono); font-size: var(--fs-13); line-height: 1.75; white-space: pre; color: var(--ink-2); }
.lm .feat-x .l { display: flex; justify-content: flex-end; overflow: hidden; }
.lm .feat-x .r { display: flex; overflow: hidden; }
.lm .feat-x span { border-radius: 3px; }
.lm .feat-x .at { color: var(--ink); font-weight: var(--fw-550); box-shadow: inset 0 -2px 0 var(--accent-ink); }
.lm .steer { margin-top: 16px; padding: 20px; }
.lm .steer-k { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.lm .steer-k b { font-size: var(--fs-14); font-weight: var(--fw-550); }
.lm .steer-k .lm-slider { margin-top: 0; grid-template-columns: auto minmax(160px, 220px); }
.lm .steer-note { margin: 10px 0 16px; color: var(--ink-3); max-width: 64em; }
.lm .steer-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
.lm .steer-tx { margin-top: 6px; font-size: var(--fs-15); line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }

/* writing */
.lm .write { display: grid; grid-template-columns: minmax(0, 1fr) 320px; }
.lm .write .in { padding: 20px; }
.lm .write .acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; color: var(--ink-2); }
.lm .write .acts .hint { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.lm .write .out { padding: 20px; box-shadow: inset var(--px) 0 0 var(--line-2); }
.lm .write .out h3 { margin-bottom: 12px; }
.lm .skip { min-height: 18px; margin-top: 8px; color: var(--chart-4); font-size: var(--fs-12); line-height: var(--lh-12); }

/* history */
.lm .hist { list-style: none; margin: 0; padding: 0; }
.lm .hist li { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 24px; padding: 12px; border-radius: var(--r-row); box-shadow: inset 0 calc(-1 * var(--px)) 0 var(--line-2); transition: background 150ms var(--ease-quad); }
.lm .hist li:hover { background: var(--plane-hover); }
.lm .hist .st { color: var(--ink-3); padding-top: 2px; }
.lm .hist .st b { display: block; color: var(--ink); font-weight: var(--fw-550); }
.lm .hist .tx { font-size: var(--fs-15); line-height: 1.55; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lm .hist li[data-new] { animation: lm-arrive 600ms var(--ease-quad); }
@keyframes lm-arrive { from { background: var(--accent-tint); } to { background: transparent; } }
.lm .hist .empty { color: var(--ink-3); }

/* how it is built */
.lm .trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px; }
.lm .trio p { color: var(--ink-2); text-wrap: pretty; }
.lm .receipts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 32px; }
.lm .receipts > div { padding: 18px 20px; box-shadow: inset var(--px) 0 0 var(--line-2); }
.lm .receipts > div:first-child { box-shadow: none; }
.lm .receipts p { margin-top: 6px; color: var(--ink-2); font-size: var(--fs-12); line-height: var(--lh-12); }
.lm-foot { padding-top: 24px; box-shadow: inset 0 var(--px) 0 var(--line-2); color: var(--ink-3); font-size: var(--fs-12); line-height: var(--lh-12); }

@media (max-width: 1080px) {
  .lm .hero, .lm .s-head, .lm .lens-grid, .lm .two, .lm .rep, .lm .iheads-k { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .lm .hero { gap: 28px; }
  .lm .receipts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lm .receipts > div:nth-child(3) { box-shadow: none; }
}
@media (max-width: 900px) { .lm .feats { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) {
  .lm-wrap { padding: 20px 16px 64px; }
  .lm-wide { display: none; }
  .lm .loss, .lm .ind, .lm .write { grid-template-columns: minmax(0, 1fr); }
  .lm .side { box-shadow: inset 0 var(--px) 0 var(--line-2); display: grid; grid-template-columns: 1fr 1fr; }
  .lm .write .out { box-shadow: inset 0 var(--px) 0 var(--line-2); }
  .lm .plot canvas { height: 240px; }
  .lm .passage { font-size: var(--fs-20); }
  .lm .pr { font-size: var(--fs-15); }
  .lm .probe-row, .lm .hist li { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .lm .iheads { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lm .steer-two, .lm .trio, .lm .receipts { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .lm .receipts > div { box-shadow: inset 0 var(--px) 0 var(--line-2); }
  .lm .write .acts .hint { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) { .lm *, .lm *::before, .lm *::after { transition: none !important; animation: none !important; } }
