/* =========================================================
   Reset-3-2-1 — Train page
   Quick brain workouts: games + prompt challenges.
   Depends on reset-3-2-1.css for tokens, header, footer,
   buttons and the safety note.
   ========================================================= */

/* ---------- Hero ---------- */

.train-hero {
  padding-top: 48px;
}

.train-hero__kicker {
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.train-hero h1 {
  margin-top: 12px;
  font-size: 44px;
  line-height: 1.05;
}

.train-hero__intro {
  max-width: 640px;
  margin-top: 16px;
  color: rgba(12, 43, 25, 0.8);
  line-height: 1.6;
}

/* ---------- Filter bar ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 32px;
}

.filter-btn {
  height: 34px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background-color: var(--card);
  color: var(--foreground);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.filter-btn:hover {
  background-color: var(--secondary);
}

.filter-btn[aria-pressed="true"] {
  border-color: var(--primary);
  background-color: var(--primary);
  color: var(--primary-foreground);
}

.filter-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring-shadow);
}

/* ---------- Workout cards ---------- */

.workout-grid {
  display: grid;
  gap: 16px;
  margin: 32px 0 0;
  padding: 0;
  list-style: none;
}

.workout-grid > li {
  display: flex;
}

.workout-grid > li[hidden] {
  display: none;
}

.workout-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background-color: var(--card);
  color: var(--foreground);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.workout-card:hover {
  border-color: rgba(67, 148, 88, 0.45);
  box-shadow: var(--shadow-card);
}

.workout-card:focus-visible {
  outline: none;
  box-shadow: var(--ring-shadow);
}

.workout-card__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted-foreground);
  font-size: 14px;
}

.workout-card__kind,
.workout-card__time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.workout-card__kind svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.workout-card__time svg {
  width: 14px;
  height: 14px;
}

.workout-card h2 {
  font-size: 24px;
  line-height: 1.25;
}

.workout-card p {
  color: var(--muted-foreground);
  font-size: 14px;
  line-height: 1.5;
}

.workout-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background-color: var(--secondary);
  color: var(--secondary-foreground);
  font-size: 12px;
  font-weight: 500;
}

.workout-card__start {
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
}

/* ---------- Train safety note ---------- */

.train-safety {
  margin-top: 48px;
}

/* ---------- Dialog ---------- */

.workout-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background-color: var(--card);
  color: var(--foreground);
  box-shadow: 0 24px 60px rgba(12, 43, 25, 0.25);
  overflow: auto;
}

.workout-dialog::backdrop {
  background-color: rgba(12, 43, 25, 0.45);
}

.workout-dialog__inner {
  padding: 24px;
}

.workout-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.workout-dialog__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted-foreground);
  font-size: 13px;
}

.workout-dialog__meta svg {
  width: 14px;
  height: 14px;
}

.workout-dialog h2 {
  margin-top: 12px;
  font-size: 28px;
  line-height: 1.15;
}

.workout-dialog__desc {
  margin-top: 8px;
  color: var(--muted-foreground);
  font-size: 14px;
  line-height: 1.5;
}

.workout-dialog__close {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background-color: var(--muted);
  color: var(--foreground);
  cursor: pointer;
}

.workout-dialog__close:hover {
  background-color: var(--secondary);
}

.workout-dialog__close:focus-visible {
  outline: none;
  box-shadow: var(--ring-shadow);
}

.workout-dialog__close svg {
  width: 18px;
  height: 18px;
}

.workout-dialog__body {
  margin-top: 16px;
}

/* ---------- Shared game UI ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  background-color: var(--primary);
  color: var(--primary-foreground);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background-color: var(--primary-hover);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring-shadow);
}

.btn--outline {
  border-color: var(--border);
  background-color: var(--card);
  color: var(--foreground);
}

.btn--outline:hover {
  background-color: var(--secondary);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.game-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  text-align: center;
}

.game-intro p {
  max-width: 360px;
  color: var(--muted-foreground);
  font-size: 14px;
  line-height: 1.55;
}

.game-intro .btn {
  height: 44px;
  padding: 0 28px;
  font-size: 15px;
}

.game-shell {
  display: grid;
  gap: 16px;
  padding: 4px 0;
}

.game-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted-foreground);
  font-size: 14px;
}

.game-feedback {
  margin-left: 12px;
  font-weight: 500;
}

.game-feedback--right {
  color: var(--primary);
}

.game-feedback--wrong {
  color: #a33a25;
}

.game-display {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 104px;
  padding: 16px;
  border-radius: 16px;
  background-color: var(--secondary);
  font-family: var(--font-display);
  font-size: 40px;
  letter-spacing: 0.25em;
  text-align: center;
  overflow-wrap: anywhere;
}

.game-display--empty {
  color: var(--muted-foreground);
  letter-spacing: normal;
}

.game-question {
  padding: 12px 0;
  font-family: var(--font-display);
  font-size: 44px;
  line-height: 1.1;
  text-align: center;
}

.game-form {
  display: flex;
  gap: 8px;
}

.game-form input {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background-color: var(--card);
  color: var(--foreground);
  font-family: inherit;
  font-size: 17px;
}

.game-form input:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 1px;
}

.meter {
  height: 6px;
  border-radius: 999px;
  background-color: var(--muted);
  overflow: hidden;
}

.meter__fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background-color: var(--primary);
  transition: width 0.25s linear;
}

.word-display {
  padding: 16px 0;
  font-family: var(--font-display);
  font-size: 56px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.choice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background-color: var(--card);
  color: var(--foreground);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.choice-btn:hover {
  background-color: var(--secondary);
}

.choice-btn:focus-visible {
  outline: none;
  box-shadow: var(--ring-shadow);
}

.choice-dot {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  border-radius: 50%;
}

.symbol-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.symbol-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border: 0;
  border-radius: 10px;
  background-color: var(--secondary);
  color: var(--secondary-foreground);
  font-family: inherit;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.symbol-cell:hover {
  background-color: var(--accent);
}

.symbol-cell:focus-visible {
  outline: none;
  box-shadow: var(--ring-shadow);
}

.game-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
  text-align: center;
}

.game-result svg {
  width: 32px;
  height: 32px;
  color: var(--terracotta);
}

.game-result__title {
  font-family: var(--font-display);
  font-size: 24px;
}

.game-result p {
  max-width: 380px;
  color: var(--muted-foreground);
  font-size: 14px;
  line-height: 1.55;
}

/* ---------- Prompt challenges ---------- */

.prompt-steps {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.prompt-steps label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background-color: var(--card);
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
}

.prompt-steps input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.prompt-steps input:checked + span {
  color: var(--muted-foreground);
  text-decoration: line-through;
}

.prompt-done {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
}

.prompt-done svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---------- Responsive ---------- */

@media (min-width: 640px) {
  .train-hero {
    padding-top: 64px;
  }

  .train-hero h1 {
    font-size: 56px;
  }

  .workout-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .train-hero h1 {
    font-size: 64px;
  }

  .workout-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 479px) {
  .workout-dialog__inner {
    padding: 20px;
  }

  .workout-dialog h2 {
    font-size: 24px;
  }

  .game-display {
    font-size: 32px;
  }

  .word-display {
    font-size: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .workout-card,
  .meter__fill {
    transition: none;
  }
}
