/* Learner pages only. Shared fonts and colour tokens live in theme.css; the admin workspace has admin.css. */

.public-page {
  background: var(--bg);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.public-page .page-shell {
  width: min(1120px, calc(100% - 64px));
  padding: 48px 0 40px;
}

.public-page :is(h1, h2, h3, .completion-title, .selection-translation-word) {
  font-family: inherit;
  font-weight: 650;
  overflow-wrap: anywhere;
}

/* Ukrainian prose and titles use the reading face; controls stay in the system UI font. */
.public-page :is(h1, .continue-card h2, .story-note, .text-title, .selection-translation-word) {
  font-family: var(--font-reading);
}
.public-page :is(h1, .continue-card h2, .text-title) { font-weight: 600; }

.public-page :is(a, button, input, select, [tabindex]):focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.public-page .skip-link {
  position: fixed;
  top: 12px;
  left: 16px;
  z-index: 60;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  transform: translateY(-160%);
}

.public-page .skip-link:focus { transform: none; }

.public-page .hero {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.public-page :is(.eyebrow, .continue-kicker, .story-level) {
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
}

.public-page .eyebrow { margin-bottom: 10px; font-size: 0.875rem; }
.public-page :is(.eyebrow, .continue-kicker, .story-level, .word-count-note) { color: var(--muted); }
.public-page .brand { display: flex; align-items: center; gap: 16px; }
.public-page .brand-mark { flex: none; width: 56px; height: 56px; }
.public-page .brand .eyebrow { margin-bottom: 4px; }
.public-page h1 { font-size: clamp(1.9rem, 3.5vw, 2.65rem); line-height: 1.2; letter-spacing: -0.035em; }
.public-page .hero-copy { margin-top: 10px; font-size: 1rem; line-height: 1.5; }

.public-page :is(.continue-card, .library-state) {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: none;
}

.public-page .continue-card {
  gap: 20px;
  padding: 18px 22px;
}

.public-page .continue-card > div { min-width: 0; }
.public-page .continue-kicker { margin-bottom: 4px; font-size: 0.8125rem; }
.public-page .continue-card h2 { font-size: 1.125rem; line-height: 1.4; }
.public-page .continue-meta { margin-top: 4px; font-size: 0.875rem; }

.public-page :is(.continue-link, .next-story-link, .completion-back-link) {
  border-radius: 10px;
  font-weight: 600;
}

.public-page .continue-link { flex-shrink: 0; }
.public-page :is(.continue-link, .next-story-link):hover { background: var(--accent-strong); }

.public-page .library-tools {
  margin-top: 32px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.public-page .library-tools-heading { align-items: center; gap: 12px; }
.public-page .library-tools h2 { font-size: 1.25rem; line-height: 1.4; }
/* Library filters use the reader's controls: a tinted search field, the same
   segmented control for status, and chips for topics. Selected = white, raised. */
.public-page .library-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; margin-top: 12px; }
.public-page .library-field { display: block; min-width: 0; }
.public-page .library-search-field input { width: 100%; min-width: 0; min-height: 42px; padding: 0 14px; border: 1px solid transparent; border-radius: 10px; background: var(--surface-muted); color: var(--ink); font: inherit; font-size: 1rem; font-weight: 400; }
.public-page .library-search-field input:hover { background: var(--surface-muted-hover); }
.public-page .library-search-field input:focus { border-color: var(--control-line); background: var(--paper); }
.public-page .library-field input::placeholder { color: var(--muted); opacity: 1; }
.public-page .status-filter .segment { letter-spacing: 0; }
.public-page .topic-chips { display: flex; flex-wrap: wrap; grid-column: 1 / -1; gap: 8px; }
.public-page .chip { flex: none; min-height: 36px; padding: 0 14px; border: 0; border-radius: 8px; background: var(--surface-muted); color: var(--muted); font: inherit; font-size: 0.8125rem; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease; }
.public-page .chip:hover { background: var(--surface-muted-hover); color: var(--ink); }
.public-page .chip[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: var(--shadow-raised); }
.public-page .library-summary { margin-top: 12px; font-size: 0.8125rem; font-weight: 400; }

.public-page :is(.clear-filters-button, .level-toggle-button, .retry-button, .review-mistakes-button, .restart-button) {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--ink);
  font-weight: 500;
}

.public-page .clear-filters-button { font-size: 0.8125rem; }
.public-page :is(.clear-filters-button, .level-toggle-button, .retry-button, .review-mistakes-button, .restart-button):enabled:hover { transform: none; background: var(--surface-muted-hover); box-shadow: none; }

.public-page .levels { margin-top: 24px; gap: 28px; }
.public-page .level-card { overflow: visible; border: 0; border-radius: 0; background: none; box-shadow: none; }
.public-page .level-header { padding: 0 0 14px; align-items: center; border-bottom: 1px solid var(--line); background: none; }
.public-page .level-header h2 { margin-bottom: 4px; font-size: 1.375rem; line-height: 1.25; letter-spacing: -0.02em; }
.public-page .level-header p { font-size: 0.875rem; }
.public-page .level-count { padding: 0; background: none; font-weight: 400; }
.public-page .level-toggle-button { font-size: 0.875rem; }
.public-page .texts-grid { padding: 16px 0 0; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.public-page .text-card { min-width: 0; }

.public-page .text-button {
  position: relative;
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  column-gap: 12px;
  align-content: start;
  min-height: 112px;
  height: 100%;
  padding: 18px 16px 22px 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  transition: border-color 0.15s ease;
}

.public-page .text-button:hover { transform: none; border-color: var(--control-line); box-shadow: none; }
.public-page .text-button:focus-visible { transform: none; box-shadow: none; }
.public-page .text-number { grid-row: span 2; color: var(--faint); font-size: 1.375rem; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; }
.public-page .text-button.is-done .text-number { color: var(--ink); }
.public-page .text-title { display: -webkit-box; min-height: 2.8em; margin: 0 34px 0 0; overflow: hidden; font-size: 1rem; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.public-page .text-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; color: var(--muted); font-size: 0.8125rem; line-height: 1.4; }
.public-page .text-topic { display: block; min-width: 0; margin: 0; padding: 0; overflow: hidden; border-radius: 0; background: none; color: inherit; font-size: inherit; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.public-page .text-status { flex: none; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.public-page .text-progress { position: absolute; right: 0; bottom: 0; left: 0; height: 4px; background: var(--track); }
.public-page .text-progress::after { content: ""; display: block; width: calc(var(--progress, 0) * 100%); height: 100%; background: var(--accent); }
.public-page .text-bookmark-button { top: 10px; right: 10px; width: 34px; height: 34px; border: 0; border-radius: 8px; background: var(--surface-muted); color: var(--muted); font-size: 1rem; }
.public-page .text-bookmark-button.is-active { background: var(--accent-soft); color: var(--accent); }
.public-page :is(.text-bookmark-button, .bookmark-button):hover { transform: none; background: var(--accent-soft); color: var(--accent); }
.public-page .bookmark-button.is-active { background: var(--accent-soft); color: var(--accent); }

.public-page.reader-page .page-shell { max-width: 1120px; padding-top: 24px; }
/* Product rule: questions occupy the right column on tablets and desktops, and
   follow the story text on phones (see the 640px breakpoint below). */
.public-page .story-layout {
  grid-template-columns: minmax(300px, 1.55fr) minmax(300px, 1fr);
  gap: 24px;
  overflow-x: auto;
  padding: 4px;
}
.public-page .story-card { grid-column: 1; }
.public-page .questions-card { grid-column: 2; }
.public-page .back-link { min-height: 44px; padding: 8px 0; border: 0; border-radius: 0; background: none; color: var(--accent); box-shadow: none; font-size: 0.9375rem; }
.public-page .back-link:hover { text-decoration: underline; }
.public-page :is(.story-card, .questions-card) { min-width: 0; padding: 32px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: none; }
.public-page .story-heading { display: flex; flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 16px; }
.public-page .story-heading > div { min-width: 0; }
.public-page .story-heading .bookmark-button { flex: none; }
.public-page .story-level { margin-bottom: 10px; font-size: 0.875rem; }
.public-page .story-title { margin-bottom: 24px; font-size: clamp(1.75rem, 3.3vw, 2.25rem); line-height: 1.25; }
.public-page .reader-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.public-page .story-heading-actions { align-items: center; justify-content: flex-start; flex-wrap: wrap; gap: 8px; max-width: 100%; min-width: 0; order: initial; }
.public-page .story-heading-actions > * { flex: none; }
/* Reader controls: a language segmented control and a stress switch, both on a
   soft tinted surface so they read as one set of settings, not form fields. */
.public-page .language-switch { display: flex; align-items: center; gap: 10px; }
.public-page .reader-control-label { color: var(--muted); font-size: 0.8125rem; font-weight: 500; }
.public-page .segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-muted); }
.public-page .segment { min-width: 44px; min-height: 36px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font: inherit; font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.04em; cursor: pointer; transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease; }
.public-page .segment:hover { color: var(--ink); }
.public-page .segment[aria-pressed="true"] { background: var(--paper); color: var(--ink); box-shadow: var(--shadow-raised); }
.public-page .stress-toggle { display: inline-flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 10px 0 14px; border: 0; border-radius: 10px; background: var(--surface-muted); color: var(--ink); font: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer; }
.public-page .stress-toggle:hover { background: var(--surface-muted-hover); }
.public-page .switch { position: relative; flex: none; width: 32px; height: 18px; border-radius: 9px; background: var(--switch-off); transition: background-color 0.18s ease; }
.public-page .switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--paper); box-shadow: 0 1px 2px #1f232840; transition: transform 0.18s ease; }
.public-page .stress-toggle[aria-checked="true"] .switch { background: var(--accent); }
.public-page .stress-toggle[aria-checked="true"] .switch::after { transform: translateX(14px); }
/* Set in story.html's <head> until story.js applies the saved choice. */
:root[data-stress="off"] .public-page .stress-toggle .switch { background: var(--switch-off); }
:root[data-stress="off"] .public-page .stress-toggle .switch::after { transform: none; }
/* Voice menu: a tinted button like the stress switch that opens a paper listbox,
   so the choice looks like the rest of the reader rather than a native select. */
.public-page .voice-picker { display: flex; align-items: center; gap: 10px; }
.public-page .voice-picker[hidden] { display: none; }
.public-page .voice-menu { position: relative; }
.public-page .voice-menu-button { display: inline-flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 12px 0 14px; border: 0; border-radius: 10px; background: var(--surface-muted); color: var(--ink); font: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer; }
.public-page .voice-menu-button:hover, .public-page .voice-picker.is-open .voice-menu-button { background: var(--surface-muted-hover); }
.public-page .voice-menu-chevron { flex: none; color: var(--muted); transition: transform 0.15s ease; }
.public-page .voice-picker.is-open .voice-menu-chevron { transform: rotate(180deg); }
.public-page .voice-menu-list { position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; width: max-content; min-width: 220px; max-width: min(340px, calc(100vw - 32px)); max-height: min(320px, 60vh); margin: 0; padding: 4px; overflow-y: auto; list-style: none; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: 0 6px 24px #1f232826; }
.public-page .voice-menu-list:focus { outline: none; }
.public-page .voice-menu-list:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.public-page .voice-option { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; min-height: 40px; padding: 9px 12px 9px 30px; border-radius: 8px; color: var(--ink); font-size: 0.875rem; cursor: pointer; position: relative; }
.public-page .voice-option:hover, .public-page .voice-option.is-active { background: var(--surface-muted); }
.public-page .voice-option[aria-selected="true"] { font-weight: 600; }
.public-page .voice-option[aria-selected="true"]::before { content: ""; position: absolute; left: 11px; top: 50%; width: 8px; height: 4px; border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent); transform: translateY(-70%) rotate(-45deg); }
.public-page .voice-option-meta { flex: none; color: var(--muted); font-size: 0.8125rem; font-weight: 400; }
@media (prefers-reduced-motion: reduce) {
  .public-page :is(.segment, .switch, .switch::after) { transition: none; }
}
.public-page .bookmark-button { width: 42px; height: 42px; border: 0; border-radius: 10px; background: var(--surface-muted); color: var(--muted); }
.public-page .story-speech-hint { margin: 12px 0 24px; padding: 0; border: 0; border-radius: 0; background: none; color: var(--muted); font-size: 0.8125rem; font-weight: 400; line-height: 1.6; }
.public-page .story-content { margin-top: 24px; gap: 24px; }
.public-page .story-text { gap: 20px; max-width: 65ch; }
.public-page .story-note { color: var(--ink); font-size: 1.25rem; line-height: 1.75; overflow-wrap: anywhere; }
.public-page .story-word { border-radius: 4px; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: background-color 0.12s ease; }
@media (hover: hover) {
  .public-page .story-word:hover { background: var(--highlight-soft); box-shadow: 0 0 0 2px var(--highlight-soft); }
}
.public-page .story-word.is-tapped,
.public-page .story-word.is-tapped:hover { background: var(--highlight); box-shadow: 0 0 0 2px var(--highlight); }
.public-page .word-count-note { margin: 0; color: var(--muted); font-size: 0.8125rem; font-weight: 400; }
.public-page .selection-speech-popover { border-radius: 12px; box-shadow: 0 6px 24px #1f232826; }
.public-page .selection-translation-word { font-weight: 600; }
/* First-visit tip: a dark bubble like the word popover, pointing up at a word
   that pulses in the tapped-word yellow until the learner taps a word. */
.public-page .story-content { position: relative; }
.public-page .word-tip { position: absolute; z-index: 15; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; width: max-content; max-width: min(300px, 100%); padding: 12px 14px; border-radius: 12px; background: var(--ink); color: var(--paper); box-shadow: 0 6px 24px #1f232826; }
.public-page .word-tip[hidden] { display: none; }
.public-page .word-tip:not([hidden]) { animation: word-tip-fade-in 0.5s ease-out; }
@keyframes word-tip-fade-in {
  from { opacity: 0; transform: translateY(4px); }
}
@media (prefers-reduced-motion: reduce) {
  .public-page .word-tip:not([hidden]) { animation-name: word-tip-fade-only; }
  .public-page .story-word.is-tip-target { animation: none; }
}
@keyframes word-tip-fade-only {
  from { opacity: 0; }
}
.public-page .word-tip::before { content: ""; position: absolute; top: -6px; left: calc(var(--tip-arrow-left, 24px) - 6px); width: 12px; height: 12px; border-radius: 2px; background: var(--ink); transform: rotate(45deg); }
.public-page .word-tip-message { margin: 0; font-size: 0.875rem; line-height: 1.45; }
.public-page .word-tip-close { min-height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: #ffffff26; color: var(--paper); font: inherit; font-size: 0.8125rem; font-weight: 600; cursor: pointer; }
.public-page .word-tip-close:hover { background: #ffffff40; }
.public-page .word-tip-close:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }
.public-page .story-word.is-tip-target { background: var(--highlight-soft); box-shadow: 0 0 0 2px var(--highlight-soft); animation: word-tip-pulse 1.6s ease-in-out infinite; }
@keyframes word-tip-pulse {
  50% { background: var(--highlight); box-shadow: 0 0 0 4px var(--highlight); }
}
.public-page .selection-word-actions :is(button) { font-weight: 600; }
.public-page .selection-speech-popover :is(button, a):focus-visible { outline-color: #a9bbd3; outline-offset: -4px; }

.public-page .questions-card { position: static; }
.public-page .questions-title { margin-bottom: 16px; font-size: 1.125rem; line-height: 1.4; scroll-margin-top: 24px; }
.public-page .question-item { gap: 10px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.public-page .question-item:first-of-type { padding-top: 0; }
.public-page .question-number { width: 26px; height: 26px; border-radius: 8px; background: var(--surface-muted); color: var(--ink); font-size: 0.75rem; font-weight: 600; }
/* A fieldset pins its legend to the top border, above the padding; floating it
   makes it an ordinary grid item so the question sits inside the spacing. */
.public-page .question-legend { float: left; grid-template-columns: 26px minmax(0, 1fr); gap: 8px; }
.public-page .question-prompt { font-size: 0.875rem; font-weight: 600; }
.public-page .question-options { grid-template-columns: 1fr; gap: 6px; }
.public-page .answer-option { min-height: 38px; align-items: center; gap: 7px; padding: 7px 10px; border-color: var(--control-line); border-radius: 8px; }
.public-page .answer-option input { width: 15px; height: 15px; margin: 0; }
.public-page .answer-option span:last-child { font-size: 0.8125rem; }
.public-page .answer-marker { width: 18px; height: 18px; font-size: 0.625rem; }
.public-page .answer-feedback { font-size: 0.8125rem; }
.public-page .answer-feedback:empty { display: none; }
.public-page .answer-option:not(.is-locked):hover { transform: none; box-shadow: none; background: #faf8f3; }
.public-page .answer-option:not(.is-locked):active { transform: none; }
.public-page .answer-option:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 3px; }
.public-page .answer-option.is-correct { background: var(--success-soft); border-color: var(--success); }
.public-page .answer-option.is-wrong { background: var(--danger-soft); border-color: var(--danger); }
.public-page .answer-marker { background: var(--surface-muted); color: var(--muted); font-weight: 500; }
.public-page .answer-feedback { font-weight: 500; }
.public-page .completion-actions { border-color: var(--line); border-radius: 12px; background: var(--surface-muted); }
/* styles.css still carries the old green for the admin workspace; these are the
   reader states it would otherwise leak into. Correct answers keep a success
   green on purpose: it means "right", not the brand. */
.public-page .answer-option:not(.is-locked):hover { border-color: var(--control-line); }
.public-page .answer-option:focus-within { box-shadow: 0 0 0 3px #2c4f7c2e; }
.public-page .answer-option.is-correct-answer { border-color: var(--success); box-shadow: inset 0 0 0 1px #1f7a4d4d; }
.public-page .answer-feedback.is-correct { color: var(--success); }
.public-page .restart-button:focus-visible { background: var(--surface-muted-hover); }
.public-page .completion-back-link:hover { border-color: var(--accent); background: var(--accent-soft); }
.public-page :is(.selection-speech-popover, .selection-translate-button, .selection-speech-button[aria-pressed="true"]) { background: var(--ink); }
.public-page .selection-speech-button:hover { background: #343a42; }
.public-page .completion-title { font-size: 1.125rem; }
.public-page .site-version { margin-top: 32px; font-size: 0.75rem; }
.public-page .site-version-link { display: inline-flex; align-items: center; min-height: 44px; }

@media (max-width: 900px) {
  .public-page .page-shell { width: calc(100% - 40px); padding-top: 32px; }
  .public-page .texts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .public-page .library-controls { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .public-page .page-shell { width: calc(100% - 32px); padding-top: 28px; }
  .public-page .brand { gap: 12px; }
  .public-page .brand-mark { width: 44px; height: 44px; }
  .public-page .continue-card { align-items: stretch; flex-direction: column; gap: 14px; padding: 16px; }
  .public-page .continue-link { align-self: flex-start; }
  .public-page .library-tools { margin-top: 28px; }
  .public-page .library-tools-heading { align-items: center; flex-direction: row; flex-wrap: wrap; }
  .public-page .library-tools h2 { font-size: 1.125rem; }
  .public-page .status-filter { display: flex; }
  .public-page .status-filter .segment { flex: 1 1 auto; min-width: 0; padding: 0 8px; }
  /* Topics scroll sideways on phones instead of stacking several rows high. */
  .public-page .topic-chips { flex-wrap: nowrap; margin: 0 -16px; padding: 0 16px 2px; overflow-x: auto; scrollbar-width: none; }
  .public-page .topic-chips::-webkit-scrollbar { display: none; }
  .public-page .level-header { gap: 12px; padding: 0 0 12px; }
  .public-page .level-header-actions { justify-content: space-between; }
  .public-page .texts-grid { grid-template-columns: minmax(0, 1fr); padding: 12px 0 0; }
  .public-page .text-button { min-height: 0; }
  .public-page .text-title { min-height: 0; }
  .public-page :is(.story-card, .questions-card) { padding: 20px; }
  /* Phones read top to bottom: the questions come after the story. */
  .public-page .story-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; overflow-x: visible; }
  .public-page .questions-card { grid-column: 1; }
  .public-page .reader-toolbar { gap: 4px; }
  .public-page .story-heading-actions { flex-wrap: wrap; }
  /* Keeps the language and stress controls on one row in the narrow reader card;
     the label still names the select for assistive technology. */
  .public-page .reader-control-label { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .public-page .story-note { font-size: 1.125rem; }
  .public-page .story-speech-hint { margin-bottom: 20px; }
  .public-page .story-title { margin-bottom: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .public-page *, .public-page *::before, .public-page *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
