/* views/activities.css — Study cards, Recall, Quiz, Spell, Match and the results screen.
   They share one rhythm: header with progress → one main card → answers → action bar. */

.activity-wide { max-width: 860px; }

/* ── Study: flip card ──────────────────────────────────────────── */
.flash {
  position: relative; display: grid;
  min-height: clamp(300px, 46vh, 400px);
  perspective: 1400px; cursor: pointer; border-radius: var(--r-lg);
}
.flash-face {
  grid-area: 1 / 1; min-width: 0;
  display: grid; align-content: center; justify-items: center; gap: var(--s-3);
  padding: var(--s-6) var(--s-5); text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  transition: transform 520ms var(--ease);
}
.flash-back { transform: rotateY(180deg); }
.flash.is-flipped .flash-front { transform: rotateY(-180deg); }
.flash.is-flipped .flash-back { transform: rotateY(0); }
.flash-badges { justify-content: center; }
.flash-word {
  font-family: var(--font-word); font-weight: 700; letter-spacing: .005em;
  font-size: clamp(2.1rem, 1.4rem + 3.4vw, 3.3rem); line-height: 1.15;
  overflow-wrap: anywhere;
}
.flash-sense { color: var(--ink-3); font-size: var(--text-lg); margin-top: calc(var(--s-2) * -1); }
.flash-sound { justify-content: center; }
.flash-sound .ipa { font-size: 1.15rem; }
.flash-tip { display: flex; align-items: center; gap: 6px; margin-top: var(--s-4); color: var(--ink-3); font-size: var(--text-sm); }
.flash-ar { font-size: clamp(1.6rem, 1.2rem + 2vw, 2.3rem); font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
.flash-def { font-size: var(--text-lg); max-width: 42ch; overflow-wrap: anywhere; }
.flash-example {
  display: flex; align-items: center; gap: var(--s-3); text-align: start;
  max-width: 52ch; padding: var(--s-3) var(--s-4);
  background: var(--surface-2); border-radius: var(--r-md); color: var(--ink-2);
}
.flash-example p { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.flash-word-small { color: var(--ink-3); font-size: var(--text-sm); }

/* ── Recall ────────────────────────────────────────────────────── */
.recall { display: grid; min-width: 0; gap: var(--s-3); padding: clamp(20px, 4vw, 36px); }
.recall-badges { gap: var(--s-2); }
.recall-from { margin-inline-start: auto; overflow-wrap: anywhere; }
.recall-ar { font-size: clamp(1.6rem, 1.2rem + 2vw, 2.3rem); font-weight: 600; line-height: 1.5; margin-top: var(--s-2); overflow-wrap: anywhere; }
.recall-gap { font-size: var(--text-xl); font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.recall-ar-sm { font-size: 1.25rem; color: var(--ink-2); margin-top: 0; }
.recall-def { font-size: var(--text-lg); color: var(--ink-2); overflow-wrap: anywhere; }
.recall-form { margin-top: var(--s-3); }
.recall-form .field input { font-size: 1.1rem; }
.recall-answer {
  display: grid; gap: var(--s-2); margin-top: var(--s-3); padding-top: var(--s-4);
  border-top: 1px dashed var(--line-strong);
}
.recall-word { font-family: var(--font-word); font-size: clamp(1.9rem, 1.4rem + 2.4vw, 2.8rem); font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.recall-example { color: var(--ink-2); font-style: italic; overflow-wrap: anywhere; }
.verdict { font-weight: 600; font-size: var(--text-sm); }
.verdict.is-right { color: var(--good); }
.verdict.is-wrong { color: var(--bad); }

/* ── Quiz ──────────────────────────────────────────────────────── */
.question { padding: clamp(20px, 4vw, 32px); display: grid; gap: var(--s-3); }
.q-label { color: var(--ink-3); font-size: var(--text-sm); font-weight: 500; }
.q-def, .q-sentence { font-size: var(--text-xl); font-weight: 500; line-height: 1.4; overflow-wrap: anywhere; }
.q-ar { font-size: clamp(1.6rem, 1.2rem + 2vw, 2.2rem); font-weight: 600; overflow-wrap: anywhere; }
.q-word { font-family: var(--font-word); font-size: var(--text-2xl); font-weight: 700; overflow-wrap: anywhere; }
.q-word-row { gap: var(--s-3); }
.gap {
  display: inline-block; min-width: 4ch; height: 1.1em; vertical-align: -.18em; padding: 0 .2em;
  border-bottom: 3px solid var(--brand);
}

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: var(--s-2); }
.option {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center;
  gap: var(--s-3); text-align: start;
  min-height: 62px; padding: 11px var(--s-4);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md);
  font-size: 1.02rem; font-weight: 500;
  transition: border-color var(--fast), background var(--fast), transform var(--fast);
}
.option:hover:not(:disabled) { border-color: var(--brand); transform: translateY(-1px); }
.option .opt-label { min-width: 0; overflow-wrap: anywhere; }
.option small { color: var(--ink-3); font-weight: 400; }
.option kbd.opt-key {
  display: grid; place-items: center; flex: none; width: 27px; height: 27px; border-radius: 7px;
  background: var(--surface-2); color: var(--ink-2);
  font: 700 .78rem/1 var(--font-body); letter-spacing: 0;
}
.opt-letter { display: none; }
.option:disabled { cursor: default; }
.option:disabled:not(.is-right):not(.is-wrong) { opacity: .55; }
.option.is-right { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.option.is-wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); animation: shake 300ms; }
.option.is-right kbd, .option.is-wrong kbd { background: transparent; color: inherit; }

.feedback {
  display: grid; gap: var(--s-2); margin-top: var(--s-4);
  padding: var(--s-4) var(--s-5); border-radius: var(--r-lg);
  /* Right / wrong is the whole panel's colour, not a stripe down one side. */
  border: 1px solid color-mix(in srgb, var(--good) 35%, var(--line));
  background: color-mix(in srgb, var(--good-soft) 55%, var(--surface));
  animation: view-in var(--slow) var(--ease);
}
.feedback.is-wrong { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); background: color-mix(in srgb, var(--bad-soft) 55%, var(--surface)); }
.feedback-title { font-weight: 700; }
.feedback.is-right .feedback-title { color: var(--good); }
.feedback.is-wrong .feedback-title { color: var(--bad); }
.feedback-word { font-family: var(--font-word); font-size: var(--text-lg); font-weight: 700; overflow-wrap: anywhere; }
.feedback-ar { font-size: 1.15rem; }
.feedback-example { color: var(--ink-2); font-style: italic; }

@media (max-width: 1023px) {
  .activity-stage { padding-bottom: var(--s-5); }
}
/* ── Spell ─────────────────────────────────────────────────────── */
.spell { display: grid; gap: var(--s-3); padding: clamp(20px, 4vw, 36px); justify-items: center; text-align: center; }
.spell-listen { display: flex; align-items: center; gap: var(--s-3); }
.speak-xl { width: 76px; height: 76px; }
.spell-ar { font-size: clamp(1.5rem, 1.2rem + 1.6vw, 2rem); font-weight: 600; overflow-wrap: anywhere; }
.spell-hint b { font-family: var(--font-word); letter-spacing: .12em; }
.spell form { width: 100%; max-width: 440px; }
.field-xl input { height: 60px; font-size: 1.5rem; text-align: center; letter-spacing: .06em; font-family: var(--font-word); }
.field.is-right { border-color: var(--good); background: var(--good-soft); }
.field.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.spell .feedback { width: 100%; text-align: start; }
.spell-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: var(--s-2) var(--s-3); }
.spell-line .hint { min-width: 72px; }
.spell-diff { font-family: var(--font-word); font-size: 1.4rem; letter-spacing: .08em; }
.spell-typed { font-family: var(--font-word); font-size: 1.15rem; color: var(--ink-2); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 60%, transparent); overflow-wrap: anywhere; }
/* One span per letter has no break opportunity between the spans: a 22-letter
   word would push the whole card past the screen. Let it break when needed. */
.spell-diff { font-size: 1.6rem; font-weight: 700; letter-spacing: .06em; overflow-wrap: anywhere; }
.ch-ok { color: var(--good); }
.ch-bad { color: var(--bad); text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 6px; }
.ch-space { display: inline-block; width: .45em; }
.spell-legend .ch-ok, .spell-legend .ch-bad { font-weight: 700; text-decoration-thickness: 2px; text-underline-offset: 3px; }

/* ── Match ─────────────────────────────────────────────────────── */
.match-bar {
  display: flex; justify-content: space-between; align-items: center; gap: var(--s-3);
  margin-bottom: var(--s-4); font-variant-numeric: tabular-nums;
}
.match-bar > span:first-child { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-lg); }
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.match-col { display: grid; gap: var(--s-3); align-content: start; }
.tile {
  min-height: 64px; padding: var(--s-3) var(--s-4);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-md);
  font-weight: 500; font-size: 1.02rem; line-height: 1.35; overflow-wrap: anywhere;
  transition: border-color var(--fast), background var(--fast), transform var(--fast), opacity var(--slow);
}
.tile:hover:not(:disabled) { border-color: var(--brand); }
.tile.is-on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.tile.is-wrong { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); animation: shake 300ms; }
.tile.is-done { border-color: transparent; background: var(--good-soft); color: var(--good); opacity: .55; cursor: default; }
.tile .sense { font-size: var(--text-sm); }

/* ── Results ───────────────────────────────────────────────────── */
.summary { display: grid; gap: var(--s-4); text-align: center; justify-items: center; padding-top: var(--s-5); }
.summary h1 { font-size: var(--text-3xl); }
.summary-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: var(--s-3); margin-block: var(--s-3); }
.summary-stat {
  display: grid; min-width: 120px; padding: var(--s-4); border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line);
}
.summary-stat b { font-family: var(--font-display); font-size: var(--text-2xl); font-variant-numeric: tabular-nums; white-space: nowrap; }
.summary-stat span { color: var(--ink-3); font-size: var(--text-sm); }
.summary-stat.is-good b { color: var(--good); }
.summary-stat.is-bad b { color: var(--bad); }
.summary-stat.is-mark b { color: var(--on-mark); background: var(--mark); border-radius: 6px; padding: 0 .2em; justify-self: center; }
.summary-sub { font-size: var(--text-lg); margin-top: var(--s-4); justify-self: start; }
.summary .word-list { width: 100%; text-align: start; }
.summary-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-3); margin-top: var(--s-3); }

/* ── Phones ────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .options { grid-template-columns: 1fr; gap: 8px; }
  .option { min-height: 56px; padding: 10px 12px; gap: 10px; font-size: 1rem; border-width: 1px; }
  .option kbd.opt-key { width: 30px; height: 30px; border-radius: 8px; background: var(--paper); }
  .opt-num { display: none; }
  .opt-letter { display: inline; }
  /* Once answered, the two rows that carry meaning (your pick, the right
     answer) are enough; the explanation follows right below them. */
  .options.is-resolved .option:not(.is-right):not(.is-wrong) { display: none; }
  .q-def, .q-sentence { font-size: var(--text-lg); }
  .flash { min-height: 54vh; }
  .match-grid { gap: var(--s-2); }
  .match-col { gap: var(--s-2); }
  .tile { min-height: 58px; padding: var(--s-2) var(--s-3); font-size: .95rem; }
  .summary { padding-top: var(--s-4); gap: var(--s-3); }
  .summary h1 { font-size: var(--text-2xl); }
  .summary-stats { gap: 8px; margin-block: var(--s-1); }
  .summary-stat { min-width: 0; flex: 1; padding: 12px 8px; }
  .summary-stat b { font-size: 1.35rem; }
  .summary-stat span { font-size: var(--text-2xs); }
  .summary-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .summary-actions > .btn:first-child { grid-column: 1 / -1; }
  .summary-actions > .btn:last-child:nth-child(2),
  .summary-actions > .btn:last-child:nth-child(4) { grid-column: 1 / -1; }
  .summary-actions > .btn { min-width: 0; padding-inline: var(--s-3); text-wrap: balance; }
  .action-bar kbd { display: none; }
}

/* ── Speak: say the word, the app listens ─────────────────────── */
.speak { display: grid; justify-items: center; gap: var(--s-3); padding: clamp(24px, 5vw, 44px) var(--s-5); text-align: center; }
.speak-ar { font-size: 1.35rem; font-weight: 600; color: var(--ink-2); }
.speak-word { font-family: var(--font-word); font-weight: 700; font-size: clamp(2.1rem, 1.4rem + 3.4vw, 3.3rem); line-height: 1.15; overflow-wrap: anywhere; }
.speak-word .mark { animation: mark-draw 560ms var(--ease) 120ms both; background-repeat: no-repeat; }
.speak-sound { justify-content: center; }
.speak-sound .ipa { font-size: 1.15rem; }
.speak .traps { padding: var(--s-2) var(--s-3); border-radius: var(--r-md); background: var(--surface-2); }
.mic {
  display: grid; place-items: center; width: 84px; height: 84px; margin-top: var(--s-3); border-radius: 50%;
  background: var(--brand); color: var(--on-brand); box-shadow: var(--shadow-2);
  transition: transform var(--fast), background var(--fast);
}
.mic:hover { background: var(--brand-hover); }
.mic:active { transform: scale(.96); }
.mic:disabled { background: var(--good); opacity: 1; }
.mic.is-listening { background: var(--bad); animation: mic-pulse 1.1s var(--ease) infinite; }
.speak-status { display: flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 1.6em; font-weight: 500; color: var(--ink-2); }
.speak-note { text-align: center; margin: var(--s-3) auto 0; }

/* ── Recall: hints, "almost", the suggested grade, undo ───────────── */
.recall-hint { display: grid; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--mark-soft); }
.recall-hint-letters { font-family: var(--font-word); font-size: 1.5rem; letter-spacing: .14em; color: var(--on-mark); }
.recall-hint-letters b { font-weight: 700; }
.hint-blank { color: color-mix(in srgb, var(--on-mark) 45%, transparent); margin-inline: .08em; }
.hint-space { display: inline-block; width: .6em; }
.recall-hint .similar { color: var(--on-mark); }
.verdict { display: grid; gap: var(--s-1); }
.verdict.is-almost { color: var(--on-mark); }
.verdict-diff { font-size: 1.35rem; }
.action-bar .btn.is-suggested { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px currentColor; }
.btn-undo { margin-inline-start: auto; min-height: var(--tap); min-width: var(--tap); padding: 0 var(--s-3); font-size: var(--text-sm); color: var(--ink-2); }
.btn-undo + .count { margin-inline-start: var(--s-2); }
@media (max-width: 420px) {
  .btn-undo span { display: none; }
}

/* Quiz: what the wrong pick means */
.feedback-picked { display: flex; gap: var(--s-2); align-items: baseline; margin-top: var(--s-2); padding-top: var(--s-3);
  border-top: 1px solid color-mix(in srgb, var(--bad) 25%, transparent); font-size: var(--text-sm); color: var(--ink-2); }
.feedback-picked .icon { flex: none; color: var(--bad); transform: translateY(2px); }
.feedback-picked [lang="ar"] { font-family: var(--font-arabic); font-size: calc(var(--text-sm) * var(--arabic-scale)); color: var(--ink); }

/* Cards, quiz and recall: the extra teaching stays compact */
.flash-met, .flash-usage { justify-self: stretch; }
.feedback-usage { margin-top: var(--s-2); }

/* ── Use it: write your own sentence ───────────────────────────── */
.write { display: grid; min-width: 0; gap: var(--s-4); padding: clamp(20px, 4vw, 32px); }
.write-word { display: grid; min-width: 0; gap: var(--s-2); }
.write-headword { font-family: var(--font-word); font-size: clamp(1.9rem, 1.4rem + 2.4vw, 2.6rem); font-weight: 700; line-height: 1.15; overflow-wrap: anywhere; }
.write-ar { font-size: 1.3rem; font-weight: 600; overflow-wrap: anywhere; }
.write-def { color: var(--ink-2); }
.write-example summary { cursor: pointer; font-weight: 600; color: var(--brand); min-height: var(--tap); display: flex; align-items: center; }
.write-example[open] { display: grid; gap: var(--s-2); }
.write-form textarea { font-size: var(--text-lg); line-height: 1.5; min-height: 96px; }
.write-form .form-field > span { font-size: var(--text-md); color: var(--ink); }
.write-check { padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: color-mix(in srgb, var(--bad-soft) 60%, var(--surface)); }
.write-check-title { font-weight: 700; color: var(--bad); margin-bottom: var(--s-2); }
.write-check ul { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s-3); }
.write-check li { display: grid; gap: 2px; color: var(--ink); }
.write-saved { font-size: var(--text-lg); line-height: 1.5; }
.write-ok .feedback-title { display: flex; align-items: center; gap: var(--s-1); }
.write-check .usage-wrong small { margin-inline-start: auto; font-size: var(--text-xs); color: var(--ink-3); text-decoration: none; }
.write-privacy { font-size: var(--text-xs); margin-top: calc(var(--s-2) * -1); }
