/* Lektionen: övningarna, sidfoten med återkoppling och resultatsidan. */
/* ---------- Lektion ---------- */
.lesson { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.lesson-top { display: flex; flex: none; align-items: center; gap: 14px; width: 100%; max-width: 1000px; margin: 0 auto; padding: 18px 16px 8px; }
.lesson-close { display: grid; flex: none; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 12px; background: none; color: var(--faint); }
@media (hover: hover) { .lesson-close:hover { background: var(--soft); color: var(--muted); } }
.lesson-close .icon { width: 26px; height: 26px; }
.progress { position: relative; flex: 1; height: 16px; overflow: hidden; border-radius: 99px; background: var(--line); }
.progress > span { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--green); transition: width 450ms cubic-bezier(0.3, 1.3, 0.5, 1); }
.progress > span::after { position: absolute; top: 4px; right: 8px; left: 8px; height: 4px; border-radius: 99px; background: rgba(255, 255, 255, 0.3); content: ""; }
.combo { display: inline-flex; flex: none; align-items: center; gap: 2px; color: var(--hue-orange); font-size: 17px; font-weight: 900; font-variant-numeric: tabular-nums; animation: pop 350ms; }
.combo .icon { width: 24px; height: 24px; color: var(--orange); }
.lesson-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.lesson-inner { width: 100%; max-width: 660px; margin: 0 auto; padding: 18px 16px 40px; }
.lesson-inner:focus { outline: none; }

.ex-kicker-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.ex-kicker { font-size: 14px; font-weight: 900; letter-spacing: 0.08em; text-transform: uppercase; }
.hue-blue { color: var(--hue-blue); }
.hue-purple { color: var(--hue-purple); }
.hue-teal { color: var(--hue-teal); }
.hue-orange { color: var(--hue-orange); }
.hue-pink { color: var(--hue-pink); }
.hue-green { color: var(--hue-green); }
.hue-indigo { color: var(--hue-indigo); }
.ex-tag { color: var(--muted); font-size: 14px; font-weight: 700; }
.pill { padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; }
.pill--gold { background: var(--gold-soft); color: var(--gold-ink); }
.pill--red { background: var(--red-soft); color: var(--red-ink); }
.ex-prompt { margin-bottom: 20px; color: var(--ink-strong); font-size: clamp(23px, 4.8vw, 30px); font-weight: 900; line-height: 1.22; letter-spacing: -0.01em; }
.ex-prompt.is-long { font-size: clamp(19px, 3.6vw, 23px); line-height: 1.32; }
.ex-sub { margin: -12px 0 16px; color: var(--muted); font-size: 15px; font-weight: 700; }

.bubble { margin: 0 0 22px; padding: 16px 18px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); font-size: 17px; font-weight: 700; line-height: 1.5; }
.bubble-tag { display: inline-block; margin-bottom: 6px; padding: 2px 10px; border-radius: 99px; background: var(--soft); color: var(--muted); font-size: 12px; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; }
.bubble p { white-space: pre-line; }

.ex-visual { margin: 0 0 20px; padding: 16px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--soft); }

.tiles { display: grid; gap: 12px; }
.tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 58px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 2px 0 var(--line);
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  text-align: left;
  transition: background 100ms, border-color 100ms, transform 60ms;
}
@media (hover: hover) { .tile:not(.is-selected):hover:not(:disabled) { background: var(--soft); } }
.tile:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.tile:disabled { cursor: default; }
.tile-key { display: grid; flex: none; place-items: center; width: 30px; height: 30px; border: 2px solid var(--line); border-radius: 9px; color: var(--faint); font-size: 14px; font-weight: 800; }
.tile-key .icon { width: 18px; height: 18px; }
.tile-text { min-width: 0; overflow-wrap: anywhere; }
.tile-detail { display: block; margin-top: 2px; font-size: 14px; font-weight: 800; opacity: 0.9; }
.tile.is-selected { border-color: var(--blue-line); background: var(--blue-soft); box-shadow: 0 2px 0 var(--blue-line); color: var(--blue-ink); }
.tile.is-selected .tile-key { border-color: var(--blue-line); color: var(--blue-ink); }
.tile.is-correct { border-color: var(--green-line); background: var(--green-soft); box-shadow: 0 2px 0 var(--green-line); color: var(--green-ink); }
.tile.is-correct .tile-key { border-color: var(--green-line); color: var(--green-ink); }
.tile.is-wrong { border-color: var(--red-line); background: var(--red-soft); box-shadow: 0 2px 0 var(--red-line); color: var(--red-ink); }
.tile.is-wrong .tile-key { border-color: var(--red-line); color: var(--red-ink); }
.tile.is-missed { border-style: dashed; border-color: var(--green-line); color: var(--green-ink); }
.tile.is-dim { opacity: 0.55; }
.tile.is-matched { border-color: var(--line); background: var(--panel); box-shadow: none; color: var(--faint); }
.tile.is-matched .tile-key { color: transparent; }
.tile.is-used { border-style: dashed; background: var(--soft); box-shadow: none; color: transparent; }
.tile.is-used .tile-key { opacity: 0; }
.tile.is-tapped { animation: tap 200ms ease-out; }
.tile.is-correct.is-tapped { animation: tap-good 320ms cubic-bezier(0.3, 1.5, 0.5, 1); }
.tile.shake { animation: shake 380ms; }
.tiles--long .tile { font-size: 16px; }

.match { display: grid; gap: 12px; }
.match .tile { justify-content: flex-start; min-height: 64px; font-size: 16px; }
.match .tile--left { font-weight: 800; }

.order-slots { display: grid; gap: 10px; margin: 0 0 12px; padding: 0; list-style: none; counter-reset: slot; }
.order-slot { display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: center; gap: 10px; }
.order-num { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--soft); color: var(--muted); font-size: 14px; font-weight: 900; }
.order-empty { display: block; height: 58px; border: 2px dashed var(--line); border-radius: var(--radius); }
.order-hint { min-height: 1.4em; margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.order-bank { display: grid; gap: 10px; padding-top: 16px; border-top: 2px solid var(--line); }
.tile--compact { min-height: 54px; padding: 10px 14px; font-size: 16px; }

.type-input {
  width: 100%;
  min-height: 60px;
  padding: 12px 18px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--ink-strong);
  font-size: 20px;
  font-weight: 800;
}
.type-input:focus { border-color: var(--blue-line); outline: none; background: var(--panel); }
.type-input.is-correct { border-color: var(--green-line); background: var(--green-soft); color: var(--green-ink); }
.type-input.is-wrong { border-color: var(--red-line); background: var(--red-soft); color: var(--red-ink); text-decoration: line-through; }
.type-hint { margin-top: 10px; color: var(--muted); font-size: 14px; }

.essay-task { margin: 0 0 16px; font-size: 17px; font-weight: 700; line-height: 1.55; }
.essay-input {
  display: block;
  width: 100%;
  min-height: 240px;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--ink-strong);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.55;
  resize: vertical;
}
.essay-input:focus { border-color: var(--blue-line); outline: none; background: var(--panel); }
.essay-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; color: var(--muted); font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rubric { margin-top: 22px; padding: 18px; border: 2px solid var(--blue-line); border-radius: var(--radius); background: var(--blue-soft); }
.rubric h2 { color: var(--ink-strong); font-size: 19px; font-weight: 900; }
.rubric-lead { margin: 4px 0 14px; color: var(--muted); font-size: 15px; }
.rubric-list { display: grid; gap: 10px; }
.rubric-item { display: grid; grid-template-columns: 26px minmax(0, 1fr); align-items: start; gap: 10px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--panel); font-size: 16px; font-weight: 700; line-height: 1.4; cursor: pointer; }
.rubric-item input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--primary); }
.rubric-item.is-checked { border-color: var(--green-line); background: var(--green-soft); color: var(--green-ink); }
.rubric-outline { margin-top: 14px; }
.rubric-outline summary { display: inline-flex; align-items: center; gap: 10px; color: var(--blue-ink); font-weight: 900; cursor: pointer; list-style: none; }
.rubric-outline p { margin-top: 10px; font-size: 16px; line-height: 1.55; }
.rubric-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 16px; }
.copy-status { color: var(--muted); font-size: 14px; }

/* Öppna övningar ur boken: eget svar, förslag och punkter att kryssa. */
.explain-input {
  display: block;
  width: 100%;
  min-height: 120px;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  color: var(--ink-strong);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.55;
  resize: vertical;
}
.explain-input:focus { border-color: var(--blue-line); outline: none; background: var(--panel); }
.explain-answer { margin-top: 18px; }
.explain-model { margin: 8px 0 14px; color: var(--ink); font-size: 16px; font-weight: 600; line-height: 1.6; }
.explain-source { margin-top: 12px; color: var(--muted); font-size: 13px; font-weight: 700; }
.copy-status.is-ok { color: var(--green-ink); }
.copy-status.is-error { color: var(--red-ink); }

/* Skrivövningar i Monkeytype-stil: otypad text är dämpad, rätt tecken lyser upp och fel blir röda. */
.typing { position: relative; }
.typing-board {
  padding: 18px 20px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--type-pending);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: clamp(18px, 3.2vw, 22px);
  font-weight: 500;
  line-height: 1.8;
  cursor: text;
}
.typing-board.is-focused { border-color: var(--blue-line); }
.tw { white-space: nowrap; }
.tc { position: relative; }
.tc.ok { color: var(--ink-strong); }
.tc.bad { border-radius: 3px; background: var(--red-soft); color: var(--red-ink); }
.tc.sp.bad { background: var(--red-line); }
.tc.caret::before { position: absolute; top: 0.25em; bottom: 0.2em; left: -1px; width: 2px; border-radius: 2px; background: var(--blue); content: ""; animation: caret-blink 1s step-end infinite; }
.typing-board:not(.is-focused) .tc.caret::before { opacity: 0.35; animation: none; }
.typing-input { position: absolute; top: 0; left: 0; width: 1px; height: 1px; margin: 0; padding: 0; border: 0; opacity: 0; font-size: 16px; resize: none; pointer-events: none; }
.typing-stats { margin-top: 12px; color: var(--muted); font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.complete-typing { max-width: 460px; padding: 10px 16px; border-radius: 14px; background: var(--soft); color: var(--ink); font-size: 15px; line-height: 1.6; }
.complete-typing .icon { width: 20px; height: 20px; margin-right: 8px; color: var(--hue-green); vertical-align: -5px; }
.complete-typing strong { display: inline-block; margin-left: 4px; padding: 0 10px; border-radius: 99px; background: var(--gold-soft); color: var(--gold-ink); font-size: 12px; font-weight: 900; letter-spacing: 0.05em; text-transform: uppercase; }
.complete-words { max-width: 460px; color: var(--muted); font-size: 15px; }
.complete-words strong { color: var(--ink-strong); }
@keyframes caret-blink { 50% { opacity: 0; } }

.lesson-foot { flex: none; border-top: 2px solid var(--line); background: var(--bg); }
.lesson-foot.is-correct { border-top-color: transparent; background: var(--green-soft); }
.lesson-foot.is-wrong { border-top-color: transparent; background: var(--red-soft); }
.lesson-foot.is-neutral { border-top-color: transparent; background: var(--blue-soft); }
.foot-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1000px;
  max-height: 55vh;
  max-height: 55dvh;
  margin: 0 auto;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
/* Fortsätt ska alltid synas, så det är återkopplingen som skrollar när den är lång. */
.foot-inner.is-feedback { align-items: flex-end; overflow: hidden; animation: rise 180ms ease-out; }
.foot-hint { color: var(--muted); font-size: 15px; font-weight: 700; }
.foot-actions { display: flex; flex: none; align-items: center; gap: 12px; }
.foot-actions--split { flex: 1; justify-content: space-between; }
.foot-actions .btn, .foot-main { min-width: 170px; }
.verdict { display: flex; gap: 16px; min-width: 0; min-height: 0; max-height: calc(55dvh - 40px); overflow-y: auto; }
.verdict-icon { display: grid; flex: none; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--panel); }
.verdict-icon .icon { width: 34px; height: 34px; }
.is-correct .verdict-icon { color: var(--green); }
.is-wrong .verdict-icon { color: var(--red-face); }
.is-neutral .verdict-icon { color: var(--blue-face); }
.is-neutral .verdict-answer { color: var(--blue-ink); }
.verdict-copy { display: grid; gap: 6px; min-width: 0; }
.verdict h2 { font-size: 23px; font-weight: 900; line-height: 1.2; }
.is-correct .verdict h2 { color: var(--green-ink); }
.is-wrong .verdict h2 { color: var(--red-ink); }
.is-neutral .verdict h2 { color: var(--blue-ink); }
.verdict-answer { color: var(--red-ink); font-size: 17px; font-weight: 800; }
.is-correct .verdict-answer { color: var(--green-ink); }
.verdict-answer ul, .verdict-answer ol { margin: 4px 0 0; padding-left: 20px; }
.verdict-text { color: var(--ink); font-size: 15px; line-height: 1.45; }
.verdict-why { color: var(--ink); font-size: 15px; }
.verdict-source { color: var(--muted); font-size: 13px; font-weight: 700; }
.guess-btn { color: var(--green-ink); }

.complete { display: grid; justify-items: center; gap: 14px; padding: 24px 0 8px; text-align: center; }
.complete-badge { position: relative; display: grid; place-items: center; width: 128px; height: 128px; margin-bottom: 6px; }
.complete-medal { display: grid; place-items: center; width: 112px; height: 112px; border-radius: 50%; background: var(--gold); box-shadow: 0 8px 0 var(--gold-shadow); color: #ffffff; animation: pop 500ms cubic-bezier(0.3, 1.6, 0.5, 1); }
.complete-medal .icon { width: 58px; height: 58px; }
.burst { position: absolute; inset: 0; pointer-events: none; }
.burst span { position: absolute; top: 50%; left: 50%; width: 10px; height: 10px; border-radius: 3px; background: var(--c); opacity: 0; animation: burst 900ms ease-out forwards; animation-delay: var(--d); }
.complete h1 { color: var(--gold-ink); font-size: 32px; font-weight: 900; }
.complete-sub { max-width: 460px; color: var(--muted); font-size: 17px; }
.complete-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; width: 100%; max-width: 460px; margin-top: 8px; }
.stat-tile { overflow: hidden; border: 2px solid var(--c); border-radius: var(--radius); background: var(--c); }
.stat-tile dt { padding: 4px 6px; color: #ffffff; font-size: 12px; font-weight: 900; letter-spacing: 0.07em; text-transform: uppercase; }
.stat-tile dd { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px 6px; border-radius: 13px; background: var(--panel); color: var(--c); font-size: 21px; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat-tile dd .icon { width: 22px; height: 22px; }
.stat-tile--gold { --c: var(--gold-shadow); }
.stat-tile--gold dt { color: #4a3700; }
.stat-tile--gold dd { color: var(--gold-ink); }
.stat-tile--green { --c: var(--primary); }
.stat-tile--blue { --c: var(--blue-face); }
.complete-streak { display: inline-flex; align-items: center; gap: 8px; color: var(--hue-orange); font-size: 18px; font-weight: 900; }
.complete-streak .icon { width: 26px; height: 26px; color: var(--orange); }
.final-verdict { width: 100%; max-width: 460px; padding: 14px 16px; border-radius: var(--radius); background: var(--soft); font-size: 16px; text-align: left; }
.final-verdict strong { display: block; color: var(--ink-strong); font-size: 18px; font-weight: 900; }
.mistakes { width: 100%; max-width: 460px; margin-top: 6px; text-align: left; }
.mistakes summary { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; padding: 0 16px; border: 2px solid var(--line); border-radius: var(--radius); color: var(--blue-ink); font-weight: 900; cursor: pointer; list-style: none; }
@media (hover: hover) { .mistakes summary:hover { background: var(--soft); } }
.mistakes[open] summary { margin-bottom: 10px; }
.mistakes ul { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.mistakes summary::-webkit-details-marker, .rubric-outline summary::-webkit-details-marker { display: none; }
.mistakes summary::after, .rubric-outline summary::after { width: 7px; height: 7px; margin-top: -4px; border-right: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; content: ""; transform: rotate(45deg); transition: transform 150ms; }
.mistakes[open] summary::after, .rubric-outline[open] summary::after { margin-top: 4px; transform: rotate(-135deg); }
.mistakes li { display: grid; gap: 4px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; font-size: 15px; }
.mistakes li strong { color: var(--ink-strong); font-weight: 800; }
.mistakes li span { color: var(--green-ink); font-weight: 800; }
