/* Four risograph themes: one by day (Mint), three after dark.
 * They share the print structure: Bricolage Grotesque, thick ink outlines,
 * hard offset shadows that press in on click. Each swaps paper and inks and
 * carries one print detail of its own:
 *
 *   riso-mint      mint paper, purple ink, sunflower; faint halftone grain
 *   riso-fern      Mint after dark: forest paper, mint lines, sunflower over
 *                  purple shadows; dashed stencil outlines, tighter corners
 *   riso-plum      Mint inverted: purple paper, mint lines and shadows,
 *                  sunflower buttons; grain, headings double-printed in mint
 *   riso-midnight  navy-black paper, lavender lines, yellow buttons over pink
 *                  shadows, pink highlights
 *
 * The <head> script sets data-theme on <html> before first paint. Theme
 * swatches in the footer carry data-theme too, so each previews itself.
 */

/* Shared structure for every variant; the last four are per-theme details. */
:root,
[data-theme^="riso"] {
  --font-ui: "Bricolage Grotesque", system-ui, sans-serif;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-reading: "Bricolage Grotesque", system-ui, sans-serif;
  --heading-weight: 800;
  --heading-tracking: -0.025em;
  --reading-size: 1.0625rem;
  --reading-leading: 1.7;

  --radius-sm: 6px;
  --radius: 12px;
  --radius-lg: 18px;
  --border-width: 2px;
  --shadow: 5px 5px 0 var(--shadow-ink);
  --shadow-btn: 3px 3px 0 var(--shadow-ink);
  --mark-line: transparent;

  --paper-texture: none;
  --radius-btn: var(--radius);
  --card-border-style: solid;
  --heading-shadow: none;
}

/* <html> always carries a data-theme (riso-mint in the markup), so no theme
   is attached to :root: anything it set would leak into themes that do not
   override it, as the halftone grain once did. */
[data-theme="riso-mint"] {
  color-scheme: light;

  --bg: #e0f2e8;
  --surface: #f6fcf8;
  --surface-raised: #ffffff;
  --border: #4b2a8c;
  --shadow-ink: #4b2a8c;
  --text: #2e1a5e;
  --text-muted: #5d4a8a;
  --accent: #ffc21a;
  --accent-hover: #ffb300;
  --on-accent: #2e1a5e;
  --accent-subtle: rgba(75, 42, 140, 0.08);
  --success: #1d7a4d;
  --danger: #c4314b;
  --mark: rgba(255, 194, 26, 0.5);
  --mark-hover: rgba(255, 194, 26, 0.75);
  --paper-texture: radial-gradient(rgba(75, 42, 140, 0.08) 1px, transparent 1.3px) 0 0 / 7px 7px;
}

[data-theme="riso-fern"] {
  color-scheme: dark;

  --bg: #10221b;
  --surface: #163029;
  --surface-raised: #1d3a31;
  --border: #6fc49a;
  --shadow-ink: #8a63e8;
  --text: #e3f5ea;
  --text-muted: #a6c7b5;
  --accent: #ffc21a;
  --accent-hover: #ffd04d;
  --on-accent: #10221b;
  --accent-subtle: rgba(138, 99, 232, 0.16);
  --success: #7fe0aa;
  --danger: #ff8a7a;
  --mark: rgba(138, 99, 232, 0.42);
  --mark-hover: rgba(138, 99, 232, 0.6);
  --paper-texture: radial-gradient(rgba(227, 245, 234, 0.06) 1px, transparent 1.3px) 0 0 / 7px 7px;
  --radius-sm: 3px;
  --radius: 6px;
  --radius-lg: 10px;
  --card-border-style: dashed;
}

[data-theme="riso-plum"] {
  color-scheme: dark;

  --bg: #231540;
  --surface: #2c1c4f;
  --surface-raised: #36245e;
  --border: #8fe0b6;
  --shadow-ink: #8fe0b6;
  --text: #f3ecff;
  --text-muted: #c3b4e6;
  --accent: #ffc21a;
  --accent-hover: #ffd04d;
  --on-accent: #231540;
  --accent-subtle: rgba(143, 224, 182, 0.14);
  --success: #8fe0b6;
  --danger: #ff8a8a;
  --mark: rgba(143, 224, 182, 0.45);
  --mark-hover: rgba(143, 224, 182, 0.62);
  --paper-texture: radial-gradient(rgba(143, 224, 182, 0.07) 1px, transparent 1.3px) 0 0 / 7px 7px;
  --heading-shadow: 2px 2px 0 rgba(143, 224, 182, 0.4);
}

[data-theme="riso-midnight"] {
  color-scheme: dark;

  --bg: #161a33;
  --surface: #1e2342;
  --surface-raised: #262c52;
  --border: #7d74c4;
  --shadow-ink: #ff4fa3;
  --text: #f1ebff;
  --text-muted: #bdb5dc;
  --accent: #ffd23f;
  --accent-hover: #ffde6e;
  --on-accent: #161a33;
  --accent-subtle: rgba(255, 79, 163, 0.16);
  --success: #5fd6a4;
  --danger: #ff7a6b;
  --mark: rgba(255, 79, 163, 0.34);
  --mark-hover: rgba(255, 79, 163, 0.52);
}

/* Shared tokens, independent of theme. */
:root {
  --space-xs: 0.375rem;
  --space-sm: 0.625rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.5rem;
  --font-size: 1rem;
  --line-height: 1.5;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper-texture), var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--font-size);
  line-height: var(--line-height);
  transition:
    background 200ms ease,
    color 200ms ease;
}

.layout {
  display: flex;
  flex-direction: column;
  width: min(100%, 44rem);
  min-height: 100vh;
  margin: 0 auto;
  padding: var(--space-md) var(--space-md) var(--space-lg);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- header and footer ---------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-lg);
  padding: var(--space-sm) 0 var(--space-md);
  border-bottom: var(--border-width) solid var(--border);
}

.site-logo {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: var(--heading-weight);
  letter-spacing: var(--heading-tracking);
  text-decoration: none;
}

.site-logo:hover {
  color: var(--accent);
}

.site-main {
  display: grid;
  flex: 1;
  align-content: start;
  gap: var(--space-md);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: var(--border-width) solid var(--border);
}

.theme-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* Each swatch carries its own data-theme, so the tokens above make it a
   miniature of the theme it selects. */
.theme-swatch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.3rem 0.75rem 0.3rem 0.35rem;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.875rem;
  cursor: pointer;
  box-shadow: var(--shadow-btn);
}

.theme-swatch__sample {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  background: var(--mark);
  box-shadow: inset 0 -2px 0 var(--mark-line);
  font-family: var(--font-display);
  font-weight: var(--heading-weight);
}

.theme-swatch[aria-checked="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.875rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.link-button:hover {
  color: var(--accent);
}

/* ---------- type ---------- */

h1,
h2,
h3 {
  margin: 0 0 var(--space-sm);
  font-family: var(--font-display);
  font-weight: var(--heading-weight);
  letter-spacing: var(--heading-tracking);
  line-height: 1.2;
  text-shadow: var(--heading-shadow);
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.2rem;
}

p {
  margin: 0 0 var(--space-sm);
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

/* Fluorescent pink is too light to read as text on Riso's paper, so links
   stay ink-blue with a pink underline, the way a second ink would print. */
[data-theme^="riso"] a:not(.btn) {
  color: var(--text);
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

[data-theme^="riso"] .steps__item::before {
  background: var(--accent);
  color: var(--on-accent);
}

.lead {
  margin: 0;
  max-width: 60ch;
  color: var(--text-muted);
  font-size: 1.0625rem;
}

.muted,
.help-text {
  color: var(--text-muted);
}

.hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* ---------- messages ---------- */

.messages {
  display: grid;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.message {
  margin: 0;
  padding: var(--space-sm) var(--space-md);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.message--error,
.message--danger {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
}

.message--success {
  border-color: color-mix(in srgb, var(--success) 55%, var(--border));
  background: color-mix(in srgb, var(--success) 12%, var(--surface));
}

/* ---------- surfaces and layout helpers ---------- */

.card {
  padding: var(--space-lg);
  background: var(--surface);
  border: var(--border-width) var(--card-border-style) var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card--compact {
  padding: var(--space-md);
  box-shadow: none;
}

.stack {
  display: grid;
  gap: var(--space-md);
}

.stack--sm {
  gap: var(--space-sm);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.page-head h1 {
  margin: 0;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: 2.5rem;
  padding: 0 var(--space-md);
  border: var(--border-width) solid transparent;
  border-radius: var(--radius-btn);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    color 120ms ease,
    transform 80ms ease,
    box-shadow 80ms ease;
}

.btn:hover {
  text-decoration: none;
}

/* `display` above outranks the UA `[hidden]` rule; restate it. */
.btn[hidden] {
  display: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-btn);
}

.btn--primary:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
}

.btn--secondary {
  border-color: var(--border);
  background: var(--surface-raised);
  box-shadow: var(--shadow-btn);
}

.btn--secondary:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: var(--accent-subtle);
  color: var(--text);
}

[data-theme^="riso"] .btn--primary,
[data-theme^="riso"] .btn--secondary {
  border-color: var(--border);
}

/* Riso buttons press into the page, like a stamp. */
[data-theme^="riso"] .btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--border);
}

.btn--sm {
  min-height: 2rem;
  padding: 0 0.7rem;
  font-size: 0.875rem;
}

/* ---------- forms ---------- */

.field {
  display: grid;
  gap: var(--space-xs);
}

.field label {
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 700;
}

.input,
.textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text);
  font: inherit;
}

.input:focus,
.textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.textarea {
  min-height: 10rem;
  resize: vertical;
  font-family: var(--font-reading);
}

.field--checkbox label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  font-weight: 500;
  color: var(--text);
}

.field--checkbox input[type="checkbox"] {
  margin-top: 0.25rem;
  accent-color: var(--accent);
}

/* ---------- library ---------- */

.language-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.language-picker label {
  color: var(--text-muted);
  font-weight: 700;
}

.language-picker__select {
  width: auto;
  min-width: 10rem;
  padding-block: 0.4rem;
}

.language-picker__other {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

.language-picker__other[hidden] {
  display: none;
}

.language-picker__other .input {
  width: 4.5rem;
  padding-block: 0.4rem;
  text-transform: lowercase;
}

.text-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.text-list__item h2 {
  margin-bottom: var(--space-xs);
  font-size: 1.0625rem;
}

.text-list__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.text-list__header h2 {
  flex: 1;
  margin-bottom: 0;
}

.text-list__header h2 a {
  color: inherit;
  text-decoration: none;
}

.text-list__header h2 a:hover {
  color: var(--accent);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius);
  background: var(--accent-subtle);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 700;
}

.empty {
  display: grid;
  gap: var(--space-sm);
  justify-items: start;
  padding: var(--space-lg);
  border: var(--border-width) dashed var(--border);
  border-radius: var(--radius-lg);
}

/* ---------- reading session ---------- */

.article-body {
  max-width: 65ch;
  font-family: var(--font-reading);
  font-size: var(--reading-size);
  line-height: var(--reading-leading);
  white-space: pre-wrap;
}

.highlight {
  padding: 0.05em 0.1em;
  border-radius: var(--radius-sm);
  background: var(--mark);
  box-shadow: inset 0 -2px 0 var(--mark-line);
  color: inherit;
  cursor: pointer;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.highlight:hover {
  background: var(--mark-hover);
}

/* ---------- explanation modal ---------- */

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--space-md);
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 70%, rgba(0, 0, 0, 0.5));
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: min(100%, 34rem);
  max-height: min(88vh, 34rem);
  overflow: auto;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.modal__header h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal__selection {
  margin: 0;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius);
  background: var(--mark);
  box-shadow: inset 0 -2px 0 var(--mark-line);
  font-family: var(--font-reading);
  font-size: 1.0625rem;
  font-weight: 600;
}

.modal__transcript {
  display: grid;
  gap: var(--space-md);
}

.modal__message {
  margin: 0;
}

/* Model replies arrive as rendered markdown: keep its blocks compact. */
.modal__message > :first-child {
  margin-top: 0;
}

.modal__message > :last-child {
  margin-bottom: 0;
}

.modal__message p,
.modal__message ul,
.modal__message ol {
  margin: 0 0 var(--space-sm);
}

.modal__message ul,
.modal__message ol {
  padding-left: 1.25em;
}

.modal__message--assistant {
  color: var(--text);
}

.modal__message--user {
  justify-self: end;
  max-width: 85%;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius);
  background: var(--accent-subtle);
  color: var(--text-muted);
}

.modal__followup {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

/* A class-level `display` outranks the UA stylesheet's `[hidden]` rule, so the
   hidden state has to be restated — same reason `.modal[hidden]` exists. */
.modal__followup[hidden] {
  display: none;
}

.modal__followup .input {
  flex: 1;
  min-width: 0;
}

.modal__followup .input:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* Visible to screen readers only — the field is labelled by its placeholder
   visually, but a placeholder is not an accessible name. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.modal__scratchpad {
  display: grid;
  gap: var(--space-sm);
  padding-top: var(--space-md);
  border-top: var(--border-width) solid var(--border);
}

.modal__scratchpad[hidden] {
  display: none;
}

.modal__scratchpad-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

.modal__saved {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* The spec asks for an overlay, not an inline message: it covers the modal so
   the reader has to acknowledge it before carrying on. It sits over the whole
   modal rather than inside .modal__panel, which scrolls — an absolutely
   positioned child there anchors to the scrolled content, not the visible box,
   so it could open off-screen. */
.modal__overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  gap: var(--space-sm);
  justify-items: center;
  padding: var(--space-md);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  text-align: center;
}

.modal__overlay[hidden] {
  display: none;
}

.modal__overlay-message {
  margin: 0;
  max-width: 28ch;
}

/* ---------- glossary ---------- */

.glossary {
  display: grid;
  gap: var(--space-sm);
  margin: 0;
  padding: 0;
  list-style: none;
}

.glossary__entry {
  display: grid;
  grid-template-columns: minmax(6rem, 12rem) 1fr;
  gap: var(--space-sm);
  align-items: baseline;
  padding-bottom: var(--space-sm);
  border-bottom: var(--border-width) solid var(--border);
}

.glossary__item {
  font-family: var(--font-reading);
  font-weight: 700;
}

.glossary__entry--selectable {
  grid-template-columns: auto minmax(6rem, 12rem) 1fr;
}

.glossary__check {
  margin: 0;
  align-self: center;
  accent-color: var(--accent);
}

.glossary__definition {
  color: var(--text-muted);
}

@media (max-width: 30rem) {
  .glossary__entry {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .glossary__entry--selectable {
    grid-template-columns: auto 1fr;
    column-gap: var(--space-sm);
  }

  .glossary__entry--selectable .glossary__definition {
    grid-column: 2;
  }
}

/* Practice status next to each word, and what an article would do with it. */
.status,
.glossary__role {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.45rem;
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-btn);
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.5;
  vertical-align: 0.1em;
}

.status--new {
  background: var(--accent-subtle);
}

.status--learning {
  background: var(--mark);
}

.status--known {
  background: var(--accent);
  color: var(--on-accent);
}

.glossary__role {
  border-style: dashed;
  color: var(--text-muted);
}

.glossary__role[hidden] {
  display: none;
}

.glossary__entry--later .glossary__item,
.glossary__entry--later .glossary__definition {
  opacity: 0.55;
}

.quiz-callout {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-md);
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  background: var(--surface);
  border: var(--border-width) var(--card-border-style) var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.quiz-callout p {
  margin: 0;
  flex: 1 1 18rem;
}

/* ---------- quiz ---------- */

.quiz {
  max-width: 36rem;
  margin-inline: auto;
}

.quiz__count,
.quiz__keys {
  margin: 0;
  text-align: center;
}

.quiz__card {
  display: grid;
  gap: var(--space-md);
  justify-items: center;
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  background: var(--surface);
  border: var(--border-width) var(--card-border-style) var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.quiz__item {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: var(--heading-weight);
  letter-spacing: var(--heading-tracking);
  line-height: 1.1;
  text-shadow: var(--heading-shadow);
  overflow-wrap: anywhere;
}

.quiz__context {
  margin: 0;
  max-width: 32ch;
  font-family: var(--font-reading);
  color: var(--text-muted);
}

.quiz__context mark {
  background: var(--mark);
  color: var(--text);
  border-radius: 3px;
  padding: 0 0.1em;
}

.quiz__back {
  display: grid;
  gap: var(--space-sm);
  justify-items: center;
  width: 100%;
  padding-top: var(--space-md);
  border-top: var(--border-width) dashed var(--border);
}

.quiz__back[hidden] {
  display: none;
}

.quiz__definition {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.quiz__ratings {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
  width: 100%;
}

@media (max-width: 30rem) {
  .quiz__ratings {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- tutorial tips ---------- */

.tip {
  position: fixed;
  z-index: 200;
  width: min(20rem, calc(100vw - 24px));
  padding: var(--space-md);
  border: var(--border-width) solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--text);
  box-shadow: var(--shadow);
  animation: tip-in 160ms ease-out;
}

.tip[hidden] {
  display: none;
}

/* The pointer: a rotated square on the edge facing the feature. */
.tip::before {
  content: "";
  position: absolute;
  top: -7px;
  left: calc(var(--arrow-x, 24px) - 6px);
  width: 12px;
  height: 12px;
  border-top: var(--border-width) solid var(--accent);
  border-left: var(--border-width) solid var(--accent);
  background: var(--surface-raised);
  transform: rotate(45deg);
}

.tip[data-spot="above"]::before {
  top: auto;
  bottom: -7px;
  transform: rotate(225deg);
}

/* Beside the column the pointer faces left, at the anchor's first line. */
.tip[data-spot="beside"]::before {
  top: 14px;
  left: -7px;
  transform: rotate(-45deg);
}

/* Docked at the bottom of a narrow screen there is nothing to point at. */
.tip[data-spot="docked"]::before {
  display: none;
}

.tip__title {
  margin: 0 0 var(--space-xs);
  font-family: var(--font-display);
  font-weight: var(--heading-weight);
  font-size: 1.0625rem;
}

.tip__body {
  margin: 0 0 var(--space-md);
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.tip__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

@keyframes tip-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

/* ---------- splash page ---------- */

.hero {
  display: grid;
  gap: var(--space-lg);
  padding: var(--space-lg) 0 var(--space-md);
}

.hero__title {
  margin: 0;
  max-width: 18ch;
  font-size: clamp(2.1rem, 7vw, 3.1rem);
  line-height: 1.08;
}

.hero__lead {
  margin: 0;
  max-width: 52ch;
  color: var(--text-muted);
  font-size: 1.125rem;
}

/* The demo is the real interaction in miniature: a sentence you can click,
   and the explanation card the app would show. */
.demo {
  display: grid;
  gap: var(--space-md);
  padding: var(--space-lg);
  border: var(--border-width) var(--card-border-style) var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.demo__label {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.demo__sentence {
  margin: 0;
  font-family: var(--font-reading);
  font-size: clamp(1.2rem, 4vw, 1.45rem);
  line-height: 1.6;
}

.demo__word {
  padding: 0.05em 0.1em;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-decoration: underline dotted color-mix(in srgb, var(--text-muted) 70%, transparent);
  text-underline-offset: 0.25em;
}

.demo__word:hover {
  background: var(--accent-subtle);
}

.demo__word--on {
  background: var(--mark);
  box-shadow: inset 0 -2px 0 var(--mark-line);
  text-decoration: none;
}

.demo__word--on:hover {
  background: var(--mark-hover);
}

.demo__card {
  display: grid;
  gap: var(--space-xs);
  padding: var(--space-md);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
}

.demo__term {
  margin: 0;
  font-family: var(--font-reading);
  font-weight: 700;
  font-size: 1.125rem;
}

.demo__explain {
  margin: 0;
}

.demo__parts {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.steps {
  display: grid;
  gap: var(--space-lg);
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps__item {
  display: grid;
  grid-template-columns: 2.5rem 1fr;
  gap: var(--space-md);
  counter-increment: step;
}

.steps__item::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border: var(--border-width) solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  font-family: var(--font-display);
  font-weight: var(--heading-weight);
  font-size: 1.125rem;
}

.steps__item h3 {
  margin: 0.35rem 0 var(--space-xs);
  font-size: 1.125rem;
}

.steps__item p {
  margin: 0;
  color: var(--text-muted);
}

.section-title {
  margin: var(--space-lg) 0 0;
  font-size: 1.375rem;
}

.cta {
  display: grid;
  gap: var(--space-md);
  justify-items: start;
  margin-top: var(--space-lg);
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  background: var(--accent-subtle);
}

.cta p {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
