/* ─────────────────────────────────────────
   VOCAB//CYBER app.css — layout + components
   ───────────────────────────────────────── */

* {
  box-sizing: border-box;
}

/* The UA stylesheet's [hidden] rule is `display: none` at the lowest possible
   specificity, so ANY class that sets `display` (.chip, .card, .row, .panel …)
   silently defeats it — an element with hidden=true stays on screen. Screens
   toggle visibility exclusively via the `hidden` attribute, so it has to win. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, 'Noto Sans Thai', system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

/* Headings / buttons / data / hint elements use the mono stack, uppercase,
   letter-spaced — but ONLY on Latin-only content; Thai text is never
   uppercased (text-transform is a no-op on Thai script but the rule is
   still scoped narrowly so intent stays clear at the call sites). */
.h1,
.h2,
.mono,
.btn {
  font-family: 'JetBrains Mono', 'Noto Sans Thai', ui-monospace, monospace;
}

.h1 {
  font-size: 2rem;
  margin: 0 0 0.25em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.h2 {
  font-size: 1.25rem;
  margin: 1.5em 0 0.5em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.muted {
  color: var(--muted);
}

.tiny {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── Layout ──────────────────────────────────────────────────────────── */

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.screen {
  min-height: 100vh;
}

.panel {
  background: var(--panel-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--divider);
  border-radius: 10px;
  padding: 1.25rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.spacer {
  flex: 1 1 auto;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */

.btn {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid var(--divider);
  background: transparent;
  color: var(--text);
  padding: 0.6em 1.1em;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out, color 0.15s ease-out;
}

.btn:hover {
  border-color: var(--neon-cyan);
}

.btn-primary {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.45);
}

.btn-ghost {
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--divider);
}

.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  box-shadow: 0 0 10px rgba(255, 42, 109, 0.35);
}

.btn-icon {
  padding: 0.5em 0.65em;
  font-size: 1rem;
  line-height: 1;
}

.btn-sm {
  padding: 0.4em 0.8em;
  font-size: 0.75rem;
}

.btn.is-active {
  border-color: var(--neon-magenta);
  color: var(--neon-magenta);
  box-shadow: 0 0 8px rgba(255, 0, 255, 0.3);
}

/* ── Cards ───────────────────────────────────────────────────────────── */

.card {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: var(--panel-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--divider);
  border-radius: 10px;
  padding: 1rem;
  color: var(--text);
  font: inherit;
  position: relative;
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
}

.card:hover {
  border-color: var(--neon-cyan);
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.2);
}

.card-title {
  font-family: 'JetBrains Mono', 'Noto Sans Thai', ui-monospace, monospace;
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: var(--text);
}

.card-sub {
  font-size: 0.85rem;
  color: var(--muted);
}

.card-meta {
  font-size: 0.75rem;
  color: var(--muted-dim);
}

.badge {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--neon-magenta);
  border: 1px solid var(--neon-magenta);
  border-radius: 999px;
  padding: 0.15em 0.6em;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.3em 0.8em;
  font-size: 0.8rem;
  font-family: 'JetBrains Mono', 'Noto Sans Thai', ui-monospace, monospace;
  border: 1px solid var(--divider);
  color: var(--muted);
}

.chip-magenta {
  border-color: var(--neon-magenta);
  color: var(--neon-magenta);
}

/* ── Mastery bar ─────────────────────────────────────────────────────── */

.mastery {
  display: block;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: rgba(0, 255, 255, 0.08);
  overflow: hidden;
}

.mastery i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-magenta));
  font-style: normal;
}

/* ── Drill screen ────────────────────────────────────────────────────── */

.drill-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.prompt-th {
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0;
}

.hint-line {
  font-family: 'JetBrains Mono', 'Noto Sans Thai', ui-monospace, monospace;
  letter-spacing: 0.25em;
  color: var(--neon-magenta);
  font-size: 1.1rem;
  margin: 0;
}

.feedback {
  min-height: 1.4em;
  font-weight: 600;
}

.feedback.is-correct {
  color: var(--neon-cyan);
}

.feedback.is-wrong {
  color: var(--danger);
}

.feedback.is-near {
  color: var(--neon-magenta);
}

.feedback.is-info {
  color: var(--muted);
}

.progressbar {
  flex: 1 1 auto;
  height: 6px;
  border-radius: 999px;
  background: rgba(0, 255, 255, 0.08);
  overflow: hidden;
}

.progressbar i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-magenta));
  font-style: normal;
  transition: width 0.2s ease-out;
}

.reveal-panel {
  border-top: 1px dashed var(--divider);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}

.reveal-panel mark {
  background: transparent;
  color: var(--neon-magenta);
  text-shadow: 0 0 6px rgba(255, 0, 255, 0.6);
  font-weight: 700;
}

.answer-input {
  width: 100%;
  background: rgba(5, 5, 10, 0.6);
  border: 1px solid var(--divider);
  border-radius: 6px;
  color: var(--text);
  font-family: 'JetBrains Mono', 'Noto Sans Thai', ui-monospace, monospace;
  font-size: 1.1rem;
  padding: 0.6em 0.8em;
}

.answer-input:focus {
  border-color: var(--neon-cyan);
}

.answer-input:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}

/* ── Result screen ───────────────────────────────────────────────────── */

.big-percent {
  font-size: 3rem;
  color: var(--neon-cyan);
  text-shadow: 0 0 12px rgba(0, 255, 255, 0.5);
  margin: 0.5rem 0;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.stat {
  background: var(--panel-glass);
  border: 1px solid var(--divider);
  border-radius: 8px;
  padding: 0.75rem;
  text-align: center;
}

.stat-k {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-v {
  display: block;
  font-family: 'JetBrains Mono', 'Noto Sans Thai', ui-monospace, monospace;
  font-size: 1.4rem;
  color: var(--text);
}

.wrong-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  list-style: none;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--divider);
}

.wrong-word {
  font-family: 'JetBrains Mono', 'Noto Sans Thai', ui-monospace, monospace;
  color: var(--neon-magenta);
  min-width: 8ch;
}

.wrong-th {
  flex: 1 1 auto;
  color: var(--muted);
}

/* ── History screen ──────────────────────────────────────────────────── */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table th,
.table td {
  text-align: left;
  padding: 0.5em 0.6em;
  border-bottom: 1px solid var(--divider);
}

.table th {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.7rem;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 2rem 0;
}

/* ── Banner (storage failure notice) ────────────────────────────────── */

.banner {
  background: rgba(255, 42, 109, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
  font-size: 0.85rem;
}
