/* SpellMaster styles */

:root {
  --bg: #f6f5ff;
  --surface: #ffffff;
  --text: #1e1b3a;
  --muted: #6b6889;
  --border: #e3e1f3;
  --primary: #4f46e5;
  --primary-soft: #eceafe;
  --accent: #f97316;
  --accent-text: #ffffff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --warn-soft: #fef3c7;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(30 27 58 / 6%), 0 8px 24px rgb(30 27 58 / 6%);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14122a;
    --surface: #1f1c3d;
    --text: #f1f0ff;
    --muted: #a6a3c8;
    --border: #34305c;
    --primary: #8b85ff;
    --primary-soft: #2b2760;
    --accent: #fb923c;
    --accent-text: #1a1206;
    --ok: #4ade80;
    --ok-soft: #14361f;
    --bad: #f87171;
    --bad-soft: #3d1717;
    --warn-soft: #3a2f10;
    --shadow: none;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); }
h1, h2 { line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
h2 { font-size: 1.3rem; }
code { background: var(--primary-soft); padding: 0 .3em; border-radius: 4px; }
[hidden] { display: none !important; }

.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 24px; padding-bottom: 64px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; justify-content: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header__inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.logo__mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--primary); color: #fff; font-size: .95rem; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 600; }
.nav a.is-active, .nav a:hover { background: var(--primary-soft); color: var(--primary); }

/* Buttons */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 18px; border: 2px solid transparent; border-radius: 999px;
  background: var(--primary); color: #fff; font: inherit; font-weight: 700;
  text-decoration: none; cursor: pointer; transition: transform .08s ease, filter .15s ease;
}
.button:hover { filter: brightness(1.08); }
.button:active { transform: scale(.97); }
.button--accent { background: var(--accent); color: var(--accent-text); }
.button--ghost { background: var(--surface); color: var(--primary); border-color: var(--border); }
.button--danger { background: var(--surface); color: var(--bad); border-color: var(--bad-soft); }
.button--small { min-height: 36px; padding: 4px 12px; font-size: .9rem; }
.button--big { font-size: 1.2rem; padding: 12px 28px; min-height: 56px; }
.button:focus-visible, .speak:focus-visible, .flashcard:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0; }
.actions form { margin: 0; }

.speak { border: 0; background: var(--primary-soft); border-radius: 999px; width: 34px; height: 34px; cursor: pointer; font-size: 1rem; flex: none; }

/* Flash + misc */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; background: var(--ok-soft); }
.flash--alert { background: var(--bad-soft); }
.empty { text-align: center; padding: 48px 16px; background: var(--surface); border-radius: var(--radius); }
.card { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.badge--warn { background: var(--warn-soft); color: inherit; }
.dots { letter-spacing: 2px; color: var(--muted); font-size: .85rem; white-space: nowrap; }
.dots--done { color: var(--ok); }
.pos { font-style: italic; color: var(--muted); font-size: .9rem; }

/* Page heading */
.hero { margin-bottom: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.crumbs { margin: 0 0 4px; font-size: .9rem; color: var(--muted); }
.pager { display: flex; gap: 8px; }

/* Batch grid */
.batch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.batch-card {
  display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: var(--radius);
  background: var(--surface); color: var(--text); text-decoration: none; box-shadow: var(--shadow);
  border: 2px solid transparent; transition: border-color .15s ease, transform .1s ease;
}
.batch-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.batch-card__title { font-weight: 800; font-size: 1.15rem; display: flex; justify-content: space-between; }
.batch-card__meta { color: var(--muted); font-size: .9rem; }
.batch-card__preview { font-size: .9rem; color: var(--muted); }
.batch-card--trouble { background: var(--warn-soft); }
.batch-card--done .check { color: var(--ok); }
.progress { display: block; height: 8px; border-radius: 999px; background: var(--primary-soft); overflow: hidden; flex: 1; }
.progress__bar { display: block; height: 100%; background: var(--ok); border-radius: 999px; transition: width .3s ease; }

/* Word list in a batch */
.word-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.word-item { background: var(--surface); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.word-item__head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.word-item__text { font-size: 1.35rem; font-weight: 800; }
.word-item .dots { margin-left: auto; }
.definition { margin: 6px 0 0; }
.example { margin: 4px 0 0; color: var(--muted); font-style: italic; }
.note { margin: 4px 0 0; color: var(--muted); font-size: .9rem; }

/* Flashcards */
.flashcards { max-width: 560px; margin: 0 auto; }
.flashcards__counter { text-align: center; color: var(--muted); margin: 0 0 8px; }
.flashcard { perspective: 1200px; cursor: pointer; height: 300px; -webkit-tap-highlight-color: transparent; }
.flashcard__inner { position: relative; width: 100%; height: 100%; transition: transform .45s ease; transform-style: preserve-3d; }
.flashcard.is-flipped .flashcard__inner { transform: rotateY(180deg); }
.flashcard.no-anim .flashcard__inner { transition: none; }
.flashcard__face {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px; border-radius: 24px; background: var(--surface); box-shadow: var(--shadow);
  border: 2px solid var(--border); text-align: center; overflow: auto;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.flashcard__back { transform: rotateY(180deg); background: var(--primary-soft); }
.flashcard__word { font-size: clamp(2rem, 8vw, 3rem); font-weight: 800; word-break: break-word; }
.flashcard__note { color: var(--muted); }
.flashcard__hint { position: absolute; bottom: 14px; font-size: .8rem; color: var(--muted); }
.flashcard__definition { font-size: 1.2rem; margin: 0; }
.flashcards__controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 16px 0 8px; }

/* Quiz */
.quiz { max-width: 620px; margin: 0 auto; }
.quiz__panel { background: var(--surface); border-radius: 24px; padding: 24px; box-shadow: var(--shadow); text-align: center; }
.quiz__top { display: flex; align-items: center; gap: 12px; color: var(--muted); margin-bottom: 18px; white-space: nowrap; }
.quiz__clues { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.quiz__clue { min-height: 1.5em; margin: 14px 0; font-size: 1.05rem; }
.quiz__form { display: flex; gap: 8px; }
.quiz__input {
  flex: 1; min-width: 0; font: inherit; font-size: 1.5rem; padding: 10px 16px;
  border: 2px solid var(--border); border-radius: 14px; background: var(--bg); color: var(--text);
}
.quiz__input:disabled { opacity: .7; }
.quiz__feedback { min-height: 1.5em; margin: 14px 0 0; padding: 0; border-radius: 12px; font-size: 1.1rem; }
.quiz__feedback--ok { background: var(--ok-soft); color: var(--ok); padding: 10px 14px; }
.quiz__feedback--bad { background: var(--bad-soft); color: var(--bad); padding: 10px 14px; animation: shake .3s ease; }
.quiz__score { font-size: 1.3rem; font-weight: 700; }
.missed { list-style: none; padding: 0; display: grid; gap: 4px; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) {
  .flashcard__inner, .progress__bar, .batch-card { transition: none; }
  .quiz__feedback--bad { animation: none; }
}

/* Word table */
.list-batch { margin-bottom: 28px; }
.list-batch h2 a { color: inherit; text-decoration: none; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table__word { font-weight: 700; width: 30%; }
.table__word a { color: var(--text); }
.table__stats { text-align: right; width: 1%; }
@media (max-width: 600px) {
  .table__def { display: none; }
  .table__word { width: auto; }
}

/* Forms */
.form { display: grid; gap: 6px; }
.form label { font-weight: 700; margin-top: 10px; }
.form input[type="text"], .form textarea {
  width: 100%; font: inherit; padding: 10px 12px; border-radius: 12px;
  border: 2px solid var(--border); background: var(--bg); color: var(--text);
}
.form__row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .form__row { grid-template-columns: 1fr; } }
.help { color: var(--muted); font-size: .9rem; padding-left: 20px; }
.help-inline { color: var(--muted); font-size: .85rem; margin: 0; }
