/* Practice page only */
.practice-page {
  --background: #000;
  --panel: #151515;
  --foreground: #fff;
  --muted: #9a9a9a;

  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: "Inter", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color-scheme: dark;
}

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

.practice-page [hidden] {
  display: none !important;
}

.practice-page :where(button, input) {
  font: inherit;
}

.practice-page button {
  cursor: pointer;
}

.practice-page :where(button, a, summary):focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

/* One chapter-focused setup page. Exercise choices stay behind Filters. */
.practice-page:has(#setup-screen:not([hidden])) {
  background: var(--panel);
}

.practice-layout {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 28px;
  width: 100%;
  max-width: 1200px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(100px, 18vh, 200px) 40px 64px;
}

.practice-eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.chapter-lead {
  margin: 0;
  font-size: clamp(1.25rem, 2.5vw, 2rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  text-wrap: balance;
}

.practice-load-state:not(:has(> :not([hidden]):not(noscript))) {
  display: none;
}

.practice-filters {
  border-block: 1px solid #414141;
}

.practice-filters summary {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 58px;
  padding: 14px 0;
  list-style: none;
  cursor: pointer;
}

.practice-filters summary::-webkit-details-marker {
  display: none;
}

.filter-label {
  font-size: 0.875rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.filter-summary {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.filter-chevron {
  width: 9px;
  height: 9px;
  margin: -4px 4px 0 auto;
  flex-shrink: 0;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
}

.practice-filters[open] .filter-chevron {
  margin-top: 4px;
  transform: rotate(225deg);
}

.practice-filter-content {
  padding: 4px 0 24px;
}

/* The group's name on the left, as the vocabulary filters label theirs,
   and Select all / Clear all on the right of the same line. */
.mode-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.mode-legend {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#select-all-modes {
  min-height: 36px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.practice-footer {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 28px;
}

.chapter-footer {
  flex: 1;
  min-width: 0;
}

.practice-start {
  flex-shrink: 0;
  max-width: 100%;
}

.selection-summary {
  margin: 0;
  font-size: clamp(0.8rem, 1.1vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.practice-actions {
  display: flex;
  gap: 28px;
  margin-top: 14px;
}

.text-button {
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: clamp(0.8rem, 1.1vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.2s ease;
}

.text-button:hover {
  color: var(--foreground);
}

.page-status,
.practice-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.practice-note {
  margin-top: 20px;
}

/* Chapters */

/* Five in a row keeps nine chapters to two rows, with the start button close
   by. Smaller screens get an even three by three. */
.chapter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.chapter-tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #1a1a1a;
  color: var(--foreground);
  text-align: left;
}

/* Unselected reads as black and white; selecting brings the colour back. */
.chapter-media {
  position: absolute;
  inset: 0;
  filter: grayscale(1) contrast(1.05) brightness(0.55);
  transition: filter 0.35s ease, transform 0.35s ease;
}

.chapter-tile[aria-pressed="true"] .chapter-media {
  filter: none;
}

.chapter-tile:hover .chapter-media {
  transform: scale(1.04);
}

.chapter-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* A soft fade at the foot of the tile so the title reads over any artwork. */
.chapter-tile::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  z-index: 1;
  height: 30%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
  pointer-events: none;
}

.chapter-number {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 14px;
  font-size: clamp(1.4rem, 2.6vw, 2.25rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
}

.chapter-label {
  position: absolute;
  z-index: 2;
  right: 14px;
  bottom: 12px;
  left: 14px;
}

.chapter-title {
  margin: 0;
  font-size: clamp(0.72rem, 1.15vw, 1rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
}

.chapter-count {
  display: block;
  margin-top: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.75;
}

/* A quiet ring marks the chosen chapters without adding rules to the page. */
.chapter-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 3px solid transparent;
  transition: border-color 0.25s ease;
  pointer-events: none;
}

.chapter-tile[aria-pressed="true"]::after {
  border-color: #fff;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Starting a session */
.practice-start .start-button {
  margin-top: 0;
}

.start-button {
  align-self: start;
  margin-top: 26px;
  padding: 16px 28px;
  border: 0;
  background: #fff;
  color: #000;
  font-size: clamp(0.85rem, 1.15vw, 1rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: opacity 0.2s ease;
}

.start-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.start-button:not(:disabled):hover {
  opacity: 0.85;
}

/* A bordered, square button, matching the answer choices and mode toggles. */
.boxy-button {
  min-height: 46px;
  padding: 12px 22px;
  border: 2px solid #4a4a4a;
  border-radius: 0;
  background: transparent;
  color: var(--foreground);
  font-size: clamp(0.75rem, 1vw, 0.875rem);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.boxy-button:hover {
  border-color: #fff;
  background: #fff;
  color: #000;
}

/* All exercise choices live inside the expandable filter panel. */
.mode-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

/* Each mode is one box: a square that fills in when the mode is on, and a
   body carrying the name and its question count. */
.mode-toggle {
  display: grid;
  grid-template-columns: 46px 1fr;
  align-items: stretch;
  width: 100%;
  height: 46px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--foreground);
  text-align: left;
}

.mode-filter {
  position: relative;
  border: 2px solid #4a4a4a;
  background: transparent;
  transition: background 0.2s ease, border-color 0.2s ease;
}

/* The tick is drawn rather than typed, so it never depends on a font. */
.mode-filter::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 8px;
  border-left: 3px solid #000;
  border-bottom: 3px solid #000;
  opacity: 0;
  transform: translate(-50%, -65%) rotate(-45deg);
  transition: opacity 0.2s ease;
}

.mode-body {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border: 2px solid #4a4a4a;
  border-left: 0;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.mode-name {
  font-size: clamp(0.75rem, 1vw, 0.9rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* On: the filter fills and the body turns white, like a lit cigarette. */
.mode-toggle[aria-pressed="true"] .mode-filter {
  border-color: #fff;
  background: #fff;
}

.mode-toggle[aria-pressed="true"] .mode-filter::after {
  opacity: 1;
}

.mode-toggle[aria-pressed="true"] .mode-body {
  border-color: #fff;
  background: #fff;
  color: #000;
}

.mode-toggle:not(:disabled):hover .mode-filter,
.mode-toggle:not(:disabled):hover .mode-body {
  border-color: #fff;
}

.mode-toggle:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.mode-toggle:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

/* A session takes over the page: one question, nothing else competing */
.session-screen,
.results-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 32px 40px 56px;
}

.session-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 24px;
  padding-right: clamp(140px, 26vw, 420px);
}

.session-progress {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* The score sits beside the panel and level with it, counted from the
   answers actually given. */
.session-score {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 22px;
  border: 2px solid #2e2e2e;
}

.score-figure {
  font-size: clamp(1.9rem, 3vw, 2.5rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.score-label {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.session-card {
  display: grid;
  /* The score's column is held open from the start, so the panel does not
     change width when the first answer arrives. */
  grid-template-columns: minmax(0, 1fr) 11rem;
  align-content: center;
  align-items: start;
  gap: 20px;
  flex: 1;
  width: 100%;
  max-width: 52rem;
  margin: 0 auto;
  padding: 24px 0 64px;
}

/* One panel holds the question, so nothing shifts about as the answer and
   the feedback take their turns inside it. */
.session-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 32rem;
  padding: 36px;
  border: 2px solid #2e2e2e;
}

/* What to do, said in the interface voice at the top of every card. */
.question-task {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.question-note {
  margin: 0 0 16px;
  max-width: 46ch;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.3vw, 1.1rem);
  font-weight: 600;
}

/* The prompt and its listen button share a line. */
.question-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin: 0 0 32px;
}

/* Vocabulary keeps its own capitalisation; only the interface shouts. */
.question-prompt {
  min-width: 0;
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.85rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
}

/* Square and bordered like the letter keys, filling white on hover. The
   speaker is drawn, so it never depends on an icon font. */
.listen-button {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid #3a3a3a;
  border-radius: 0;
  background: transparent;
  color: var(--foreground);
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.listen-button:hover {
  border-color: #fff;
  background: #fff;
  color: #000;
}

.listen-button svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Whichever of these is showing sits at the foot of the panel, so the
   question stays put and nothing jumps between steps. */
.answer-choices,
.answer-form,
.feedback {
  margin-top: auto;
}

.answer-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.answer-choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 14px 24px 14px 18px;
  border: 2px solid #4a4a4a;
  background: transparent;
  color: var(--foreground);
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  font-weight: 800;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.answer-choice:hover {
  border-color: #fff;
}

/* English glosses: one per line, at a size that suits a phrase. */
.answer-choices.is-stacked {
  flex-direction: column;
  align-items: stretch;
}

.answer-choices.is-stacked .answer-choice {
  min-height: 56px;
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  text-align: left;
}

.answer-key {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.answer-choice:hover .answer-key {
  color: var(--foreground);
}

.answer-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.answer-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

/* Letters a keyboard may not have. Answers are marked with ae for ä anyway,
   so these are a convenience rather than the only way in. */
.umlaut-keys {
  display: flex;
  gap: 8px;
}

.umlaut-key {
  min-width: 48px;
  min-height: 44px;
  padding: 8px 12px;
  border: 2px solid #3a3a3a;
  border-radius: 0;
  background: transparent;
  color: var(--foreground);
  font-size: 1.05rem;
  font-weight: 800;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.umlaut-key:hover {
  border-color: #fff;
  background: #fff;
  color: #000;
}

/* The clock stands in for the question text */
.question-clock {
  margin: 0 0 28px;
  color: var(--foreground);
}

.question-clock svg {
  display: block;
  width: clamp(160px, 26vw, 220px);
  height: auto;
}

#answer-input {
  flex: 1;
  min-width: min(100%, 16rem);
  height: 64px;
  padding: 14px 18px;
  border: 2px solid #4a4a4a;
  border-radius: 0;
  background: transparent;
  color: var(--foreground);
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  font-weight: 700;
}

#answer-input::placeholder {
  color: #6a6a6a;
  font-weight: 400;
}

#answer-input:focus {
  border-color: #fff;
  outline: none;
}

.answer-row .start-button {
  align-self: stretch;
  margin-top: 0;
  min-height: 64px;
}

/* Feedback */
.feedback-verdict {
  margin: 0 0 14px;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.feedback-verdict[data-correct="true"] {
  color: #6ee7a8;
}

.feedback-verdict[data-correct="false"] {
  color: #ff9d8a;
}

.feedback-given {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.3vw, 1.1rem);
}

.feedback-given:empty {
  display: none;
}

/* The right answer, with a button to hear it beside it. */
.feedback-answer-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 12px;
}

.feedback-answer-row:has(.feedback-answer:empty) {
  display: none;
}

.feedback-answer {
  min-width: 0;
  margin: 0;
  font-size: clamp(1.25rem, 2.6vw, 2rem);
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.feedback-answer:empty {
  display: none;
}

.feedback-explanation {
  max-width: 46ch;
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.3vw, 1.1rem);
}

.feedback-explanation:empty {
  display: none;
}

/* Results */
.results-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 24px 0 64px;
}

.results-heading {
  margin: 0 0 18px;
  font-size: clamp(2.5rem, 7vw, 5rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.045em;
  text-transform: uppercase;
}

.results-score {
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  text-transform: uppercase;
}

.results-breakdown {
  margin-top: 8px;
}

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

.results-mode {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  max-width: 26rem;
  padding: 12px 0;
}

.results-mode + .results-mode {
  border-top: 1px solid #262626;
}

.results-mode-name {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.results-mode-score {
  font-size: 1.05rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Said plainly, because the numbers only cover the session just played. */
.results-note {
  max-width: 44ch;
  margin: 36px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.results-subheading {
  margin: 40px 0 16px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

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

.results-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 0;
}

.results-item + .results-item {
  border-top: 1px solid #262626;
}

.results-answer {
  font-size: 1.15rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.results-explanation {
  max-width: 52ch;
  color: var(--muted);
  font-size: 0.95rem;
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 28px;
  margin-top: 44px;
}

.results-actions .start-button {
  margin-top: 0;
}

@media (max-width: 760px) {
  .practice-layout {
    padding: 100px 24px 40px;
    gap: 24px;
  }

  .chapter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .practice-footer {
    flex-direction: column;
    gap: 24px;
  }

  .practice-start,
  .practice-start .start-button {
    width: 100%;
  }

  .mode-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .session-screen,
  .results-screen {
    padding: 84px 24px 48px;
  }

  .session-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .session-main {
    min-height: 0;
    padding: 24px;
  }

  /* On a narrow screen the score goes above the question rather than
     out of sight below it. */
  .session-aside {
    order: -1;
  }

  .session-score {
    flex-direction: row;
    align-items: baseline;
    gap: 12px;
    padding: 14px 18px;
  }

  .score-figure {
    font-size: 1.6rem;
  }

  .answer-choice,
  #answer-input,
  .answer-row .start-button {
    min-height: 58px;
  }

  .answer-row .start-button {
    width: 100%;
  }

  .question-clock svg {
    width: 150px;
  }
}

@media (max-width: 599px) {
  .chapter-grid {
    gap: 8px;
  }

  /* The label takes up more of a small tile, so its fade has to as well. */
  .chapter-tile::before {
    height: 46%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0));
  }

  .chapter-number {
    top: 7px;
    left: 8px;
  }

  .chapter-label {
    right: 6px;
    bottom: 7px;
    left: 8px;
  }

  .chapter-title {
    font-size: clamp(0.56rem, 2.8vw, 0.85rem);
    letter-spacing: 0;
  }

  .chapter-count {
    margin-top: 2px;
    font-size: clamp(0.5rem, 2.2vw, 0.7rem);
    letter-spacing: 0.04em;
  }
}

@media (max-width: 480px) {
  .mode-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chapter-media {
    transition: none;
  }

  .chapter-tile:hover .chapter-media {
    transform: none;
  }
}
