/* Typing tutor */

.typing { max-width: 1080px; gap: 20px; }
.typing__intro { max-width: 560px; }
.typing__lead { font-size: 15px; line-height: 1.5; color: var(--text-body); }

.typing__levels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: 8px;
}
.typing__level {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.typing__level:hover { border-color: var(--ink); color: var(--ink); text-decoration: none; }
.typing__level[aria-current="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.typing__level-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--sand);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}
.typing__level.is-complete .typing__level-num { background: var(--green); color: var(--paper); }
.typing__level[aria-current="true"] .typing__level-num { background: var(--peach); color: var(--ink); }
.typing__level-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.typing__level-label { font-size: 15px; font-weight: 700; }
.typing__level-sub { font-size: 12px; opacity: .85; }

.typing__level-desc { font-size: 14px; color: var(--text-body); max-width: 520px; }
.typing__lesson { padding: 7px 14px; font-size: 13px; }

.typing__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: 10px;
}
.typing__stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.typing__stat-value { font-size: 34px; line-height: 1; }
.typing__stat-label { font-size: 13px; color: var(--text-body); }

.typing__pad {
  position: relative;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 30px clamp(20px, 4vw, 44px);
  outline: none;
  cursor: text;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
}
.typing__pad.is-focused { border-color: var(--ink); }
.typing__pad-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--text-muted);
}
.typing__pad-title { font-weight: 600; color: var(--ink); }
.typing__text {
  font-family: "Noto Naskh Arabic", var(--font-arabic);
  font-size: clamp(28px, 4vw, 38px);
  line-height: 2.1;
  text-align: right;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.typing__done { color: var(--green); }
.typing__current { background: var(--sand); box-shadow: inset 0 -3px 0 var(--ink); border-radius: 4px; }
.typing__current.is-wrong { background: var(--clay-soft); box-shadow: inset 0 -3px 0 var(--clay); }
.typing__rest { color: var(--text-faint); }

.typing__finish {
  background: var(--green);
  color: var(--paper);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.typing__finish-title { font-size: 26px; }
.typing__result { font-size: 14px; color: var(--green-soft); }

.typing__overlay {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.typing__overlay-label {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-pill);
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
}

.typing__keyboard {
  background: var(--ink);
  border-radius: 20px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-x: auto;
  position: relative; /* offsetParent for keeping the next key in view */
}
.typing__row { display: flex; gap: 6px; min-width: 680px; }
.typing__key {
  flex: var(--w, 1);
  min-width: 0;
  height: 54px;
  border-radius: 9px;
  background: var(--ink-raised);
  color: var(--paper);
  border-bottom: 3px solid color-mix(in srgb, var(--ink) 70%, black);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px 8px;
}
.typing__key.is-spacer { visibility: hidden; }
.typing__key.is-home { border-bottom-color: var(--peach); }
.typing__key.is-wrong { background: var(--clay-soft); color: var(--ink); }
.typing__key.is-target { background: var(--clay); color: var(--paper); border-bottom-color: var(--clay-deep); }
.typing__key-en { font-size: 11px; opacity: .75; text-align: left; white-space: nowrap; }
.typing__key-ar { font-family: "Noto Naskh Arabic", var(--font-arabic); font-size: 20px; text-align: right; line-height: 1; }

.typing__footnote { font-size: 13px; color: var(--text-muted); }

@media (max-width: 600px) {
  .typing__key { height: 46px; padding: 4px 6px; }
  .typing__key-ar { font-size: 17px; }
}
.typing__pad .progress { flex: none; }
.typing__check { margin-right: 4px; }
