@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("./fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("./fonts/atkinson-hyperlegible-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("./fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Fraunces;
  src: url("./fonts/fraunces-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: Fraunces;
  src: url("./fonts/fraunces-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --paper: #fbf3e6;
  --paper-2: #f4e6cf;
  --ink: #1c140c;
  --ink-soft: #3f2f22;
  --ember: #8b3a0f;
  --ember-hot: #c45c12;
  --gold: #e0a020;
  --teal: #084740;
  --teal-hot: #0b5f55;
  --rose: #8f2d2d;
  --line: rgba(28, 20, 12, 0.16);
  --line-strong: rgba(28, 20, 12, 0.34);
  --card: rgba(255, 250, 242, 0.88);
  --focus: #0b5f55;
  --radius: 1.25rem;
  --font: "Atkinson Hyperlegible", "Segoe UI", sans-serif;
  --display: Fraunces, Georgia, serif;
  --step: 1.125rem;
  --passage: 1.28rem;
  --space: 1;
  --shadow: 0 18px 40px rgba(80, 40, 10, 0.12);
  --header: 4.6rem;
  --header-h: 4.6rem;
  color-scheme: light;
}

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

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--step);
  line-height: 1.65;
}

body {
  letter-spacing: calc((var(--space) - 1) * 0.02em);
  word-spacing: calc((var(--space) - 1) * 0.08em);
}

img,
svg {
  max-width: 100%;
}

button,
input,
textarea,
a {
  font: inherit;
}

h1,
h2,
h3,
p,
li,
button,
label,
a,
td,
th,
span,
div {
  overflow: visible;
  text-shadow: none;
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 700;
  line-height: 1.22;
  margin: 0 0 0.6rem;
  text-wrap: balance;
}

p {
  margin: 0 0 1rem;
}

#backdrop {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 20;
  background: var(--ink);
  color: var(--paper);
  padding: 0.6rem 0.9rem;
  border-radius: 0.6rem;
}

.skip:focus {
  top: 0.8rem;
}

.top {
  position: sticky;
  top: 0;
  z-index: 8;
  background: rgba(251, 243, 230, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.top-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.7rem 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.8rem 1rem;
  flex-wrap: wrap;
  min-height: var(--header);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
  min-height: 44px;
}

.brand-mark {
  color: var(--ink);
  display: grid;
  place-items: center;
}

.brand-type {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.55rem;
}

.brand-tag {
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.pill {
  margin: 0;
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--teal);
  background: rgba(8, 71, 64, 0.08);
}

.pill[data-state="checking"],
.pill[data-state="online"] {
  color: var(--ink-soft);
  background: rgba(28, 20, 12, 0.05);
}

.tools {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tool,
.btn,
.file-btn {
  min-height: 44px;
  min-width: 44px;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.tool[aria-pressed="true"] {
  background: #1c140c;
  color: #fbf3e6;
  border-color: #1c140c;
}

.btn.primary {
  /* Deep ember keeps white label text above the WCAG AAA 7:1 ratio. */
  background: var(--ember);
  border-color: #6a2a08;
  color: #fffaf3;
  font-weight: 700;
}

.btn.ghost {
  background: rgba(255, 250, 242, 0.7);
}

.btn:hover,
.tool:hover,
.file-btn:hover {
  transform: translateY(-1px);
}

.tool:focus-visible,
.btn:focus-visible,
.file-btn:focus-visible,
a:focus-visible,
.scoop:focus-visible,
.choice:focus-visible,
.word-link:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

main {
  position: relative;
  z-index: 1;
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.4rem 1.2rem 6rem;
}

.view[hidden],
.panel[hidden],
.word-panel[hidden],
.plain-line[hidden],
.paste-preview[hidden],
.dialog[hidden] {
  display: none !important;
}

.view.is-on,
.panel.is-on {
  display: block;
}

.hero {
  max-width: 46rem;
  padding: 0.6rem 0 0.2rem;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--ember);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

#hero-title {
  font-size: clamp(2.1rem, 5vw, 3.6rem);
  margin-bottom: 1rem;
}

.lead {
  font-size: 1.12em;
  color: var(--ink-soft);
  max-width: 46rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin: 1rem 0 1.15rem;
}

.steps {
  list-style: none;
  padding: 0;
  margin: 0.9rem 0 1.4rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.steps li,
.lesson-card,
.paste-cta,
.paper,
.word-panel,
.practice-card,
.trail-panel,
.paste-view,
.about,
.dialog-card,
.paste-preview {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.2rem 1.25rem;
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  background: #fff3d8;
  color: var(--ember);
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.section-head {
  margin-bottom: 1rem;
  max-width: 40rem;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.lesson-card {
  text-align: left;
  width: 100%;
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 0;
}

.lesson-card h3 {
  font-size: 1.5rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.7rem;
}

.chip {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.5);
}

.paste-cta {
  margin-top: 1.5rem;
}

body.in-lesson {
  overflow: hidden;
}

body.in-lesson .foot {
  display: none;
}

body.in-lesson main {
  padding-top: 0.55rem;
  padding-bottom: 0.2rem;
}

#view-lesson.is-on {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - var(--header-h) - 0.75rem);
  max-height: calc(100dvh - var(--header-h) - 0.75rem);
  overflow: hidden;
  min-height: 0;
}

#panel-read.is-on,
#panel-practice.is-on,
#panel-trail.is-on {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#panel-read.is-on {
  display: grid !important;
  grid-template-rows: minmax(7.5rem, 1fr) auto auto auto;
  min-height: 0;
}

#panel-practice.is-on,
#panel-trail.is-on {
  overflow: auto;
  overscroll-behavior: contain;
}

.lesson-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.8rem 1rem;
  align-items: center;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
}

.lesson-meta h1,
.lesson-meta h2 {
  margin: 0;
  font-size: clamp(1.2rem, 2.6vw, 1.85rem);
}

.progress {
  margin: 0;
  font-weight: 700;
  color: var(--teal);
}

.tabs {
  display: flex;
  gap: 0.4rem;
  margin: 0 0 0.7rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.tabs button {
  min-height: 44px;
  padding: 0.4rem 1rem;
  border: 1.5px solid var(--line-strong);
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink);
}

.tabs button[aria-selected="true"] {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.reader {
  display: flex;
  gap: 1rem;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.paper {
  padding: 1.15rem 1.3rem 1.2rem;
  flex: 1;
  max-height: none;
  overflow: auto;
  overscroll-behavior: contain;
  min-height: 0;
  height: 100%;
}

.scoop-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  padding-bottom: 0.4rem;
}

.scoop {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0.15rem 0.1rem 0.85rem;
  margin: 0;
  font: inherit;
  font-size: var(--passage);
  line-height: calc(1.7 * var(--space));
  color: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
  border-radius: 0.4rem;
  max-width: 100%;
}

.scoop-mark {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.1rem;
  height: 0.7rem;
  width: 100%;
  color: rgba(196, 92, 18, 0.35);
  pointer-events: none;
}

.scoop.is-current {
  background: rgba(232, 163, 23, 0.16);
  color: var(--ink);
}

.scoop.is-current .scoop-mark {
  color: var(--ember-hot);
}

.scoop.is-hard .scoop-mark {
  color: var(--rose);
}

.scoop.is-heard:not(.is-current) .scoop-mark {
  color: var(--teal-hot);
}

.word-link {
  color: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.18em;
  cursor: pointer;
  color: var(--teal);
}

.plain-line {
  margin: 0.45rem 0 0;
  padding: 0.55rem 1rem 0.6rem;
  border-left: 6px solid var(--gold);
  font-size: var(--passage);
  color: var(--ink);
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.plain-line strong {
  display: block;
  font-family: var(--display);
  margin-bottom: 0.35rem;
  font-size: 1rem;
}

.dock {
  position: relative;
  bottom: auto;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.65rem;
  margin-top: 0.65rem;
  background: #fbf3e6;
  border: 1px solid var(--line-strong);
  border-radius: 1.2rem;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.keys-hint {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 0.55rem 0 0;
  flex-shrink: 0;
}

.word-panel {
  position: relative;
  top: auto;
  overflow: auto;
  flex: 0 0 18rem;
  width: 18rem;
  max-width: 100%;
  max-height: none;
  min-height: 0;
}

.word-panel {
  padding: 0.8rem 0.9rem 0.85rem;
}
.word-panel h2 {
  font-size: 1.25rem;
  margin-bottom: 0.2rem;
}
.word-panel p {
  margin: 0 0 0.45rem;
}
.word-panel .hero-actions {
  margin: 0.45rem 0 0;
}
.word-panel .btn {
  min-height: 40px;
  padding: 0.3rem 0.7rem;
}


.syllables {
  color: var(--ember);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.practice-panel,
.trail-panel,
.paste-view,
.about {
  max-width: 52rem;
}

.passage-strip {
  display: block;
  max-height: 26vh;
  overflow: auto;
  overscroll-behavior: contain;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem 0.7rem;
  background: #fffaf3;
  border: 1px solid var(--line);
  border-radius: 1rem;
  line-height: 1.75;
}

.passage-strip .scoop-list,
.passage-strip.scoop-list {
  display: block;
  padding-bottom: 0.2rem;
}

.passage-strip li {
  display: inline;
  list-style: none;
}

.passage-strip .scoop {
  display: inline;
  font-size: 1.05rem;
  padding: 0.05rem 0.12rem 0.15rem;
  margin-right: 0.2rem;
  line-height: 1.75;
}

.passage-strip .scoop-mark {
  display: none;
}

.practice-card {
  padding-bottom: 1rem;
}

#trail-note {
  margin: 0.6rem 0 0.8rem;
  padding: 0.8rem 0.9rem;
  background: #fffaf3;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  white-space: pre-wrap;
  font-family: var(--font);
  font-size: 0.98rem;
  line-height: 1.5;
}

textarea {
  min-height: 7rem;
}


.choices,
.bank,
.order {
  display: grid;
  gap: 0.55rem;
  margin: 0.8rem 0 1rem;
}

.choice,
.order-card {
  text-align: left;
  border: 1.5px solid var(--line-strong);
  background: #fffaf3;
  border-radius: 0.9rem;
  padding: 0.75rem 0.9rem;
  cursor: pointer;
  min-height: 44px;
}

.choice.is-on,
.order-card.is-on {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 2px var(--teal);
}

.choice.is-correct {
  border-color: var(--teal);
  background: #e7f4f1;
}

.choice.is-wrong {
  border-color: var(--rose);
  background: #fdecec;
}

.feedback {
  border-radius: 0.9rem;
  padding: 0.85rem 1rem;
  margin: 0.4rem 0 1rem;
  background: #e7f4f1;
  border: 1px solid rgba(8, 71, 64, 0.25);
}

.feedback.is-retry {
  background: #fff4e8;
  border-color: rgba(139, 58, 15, 0.3);
}

.order {
  list-style: none;
  padding: 0;
}

textarea {
  width: 100%;
  min-height: 7rem;
  border-radius: 1rem;
  border: 1.5px solid var(--line-strong);
  background: #fffaf3;
  color: var(--ink);
  padding: 0.9rem 1rem;
  line-height: 1.6;
  resize: vertical;
}

.file-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.file-btn {
  position: relative;
}

.paste-meta {
  color: var(--ink-soft);
}

.foot {
  position: relative;
  z-index: 1;
  max-width: 72rem;
  margin: 0 auto;
  padding: 0 1.2rem 2.4rem;
  color: var(--ink-soft);
}

.foot a {
  color: var(--teal);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.dialog {
  position: fixed;
  inset: 0;
  z-index: 16;
  background: rgba(28, 20, 12, 0.45);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.dialog-card {
  max-width: 32rem;
  width: min(32rem, 100%);
}

kbd {
  font-family: var(--font);
  border: 1px solid var(--line-strong);
  border-radius: 0.35rem;
  padding: 0.05rem 0.35rem;
  background: #fff;
}

.dots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin: 0.4rem 0 0;
}

.dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: rgba(28, 20, 12, 0.18);
}

.dot.is-heard {
  background: var(--teal-hot);
}

.dot.is-current {
  background: var(--ember-hot);
  transform: scale(1.15);
}

body.font-lg {
  --step: 1.25rem;
  --passage: 1.5rem;
}

body.font-xl {
  --step: 1.4rem;
  --passage: 1.75rem;
}

body.spacing-roomy {
  --space: 1.22;
  line-height: 1.8;
}

body.contrast-high {
  --paper: #ffffff;
  --paper-2: #ffffff;
  --card: #ffffff;
  --ink: #000000;
  --ink-soft: #141414;
  --ember: #7a2a00;
  --ember-hot: #7a2a00;
  --gold: #7a2a00;
  --teal: #00332f;
  --teal-hot: #00332f;
  --line: #000000;
  --line-strong: #000000;
  --shadow: none;
  background: #fff;
  color: #000;
}

body.contrast-high .top,
body.contrast-high .dock {
  background: #fff;
}

body.contrast-high .btn.primary,
body.contrast-high .tabs button[aria-selected="true"],
body.contrast-high .tool[aria-pressed="true"] {
  background: #000;
  color: #fff;
  border-color: #000;
}

body.contrast-high .word-link,
body.contrast-high .eyebrow,
body.contrast-high .progress,
body.contrast-high .foot a {
  color: #00332f;
}

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation: none !important;
  transition: none !important;
}


.wide-label { display: inline; }
.narrow-label { display: none; }
@media (max-width: 980px) {
  .steps,
  .lesson-grid {
    grid-template-columns: 1fr;
  }

  .paper {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .wide-label { display: none; }
  .narrow-label { display: inline; }
  .top-inner,
  main,
  .foot {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .top-inner {
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
    gap: 0.4rem;
    min-height: 0;
  }

  .brand-name {
    font-size: 1.3rem;
  }

  .tools {
    width: 100%;
    margin-left: 0;
    gap: 0.3rem;
    display: flex;
    flex-wrap: wrap;
  }

  .tool {
    min-height: 40px;
    padding: 0.28rem 0.62rem;
    font-size: 0.88rem;
    width: auto;
  }

  .pill {
    font-size: 0.75rem;
    padding: 0.18rem 0.5rem;
  }

  .dock {
    bottom: auto;
  }

  .keys-hint {
    display: none;
  }

  .lesson-bar {
    grid-template-columns: 1fr auto;
    gap: 0.3rem 0.6rem;
    justify-items: start;
  }

  .lesson-bar #back-home {
    justify-self: start;
    align-self: start;
    width: auto;
    min-height: 40px;
    height: 40px;
    padding: 0.3rem 0.75rem;
  }

  .lesson-meta {
    grid-column: 1 / -1;
  }

  .progress {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }

  #hero-title {
    font-size: 2.05rem;
  }

  .passage-strip {
    max-height: 22vh;
  }

  body.in-lesson .brand-tag,
  body.in-lesson #offline-pill {
    display: none;
  }

  .paper {
    min-height: 0;
  }

  .plain-line {
    padding: 0.7rem 0.85rem;
    font-size: 1.05rem;
  }

  .dock {
    gap: 0.35rem;
    padding: 0.5rem;
  }

.narrow-label {
    display: inline;
  }

  .reader {
    flex-direction: column;
  }

  .word-panel {
    flex: 0 1 auto;
    width: auto;
    max-height: 36%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-height: 800px) {
  .keys-hint {
    display: none;
  }
}

#paste-view-title,
#about-title {
  font-size: 1.5em;
}

/* Sub-panel titles are h2 for a clean outline under each view's h1, sized like h3. */
.as-h3 {
  font-size: 1.17em;
}
