/* chess — bàn cờ, quân SVG, khu chơi, màn chọn môn. */

/* ----- màn chọn môn ----- */
.home-body { padding: 32px 20px 56px; max-width: 860px; margin: 0 auto; width: 100%; }
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}
.subject-card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.subject-card:hover { transform: translateY(-5px); box-shadow: 0 14px 32px rgba(31,42,68,0.18); }
.subject-card__icon { font-size: 3.4rem; line-height: 1; }
.subject-card__title { margin: 12px 0 6px; font-size: 1.35rem; }
.subject-card__desc { color: var(--c-ink-soft); font-size: 0.95rem; }
.subject-card__progress {
  margin-top: 14px; display: inline-block;
  background: var(--c-bg); border-radius: 999px;
  padding: 4px 14px; font-weight: 700; font-size: 0.85rem;
}

/* ----- khu chơi cờ ----- */
.chess-area {
  flex: 1;
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: center;
  padding: 12px 20px 40px;
  flex-wrap: wrap;
}
.chess-side {
  width: 230px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chess-actions { display: flex; flex-direction: column; gap: 8px; }
.move-list {
  background: var(--c-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
  min-height: 48px;
}
.move-list__item {
  background: var(--c-bg);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: ui-monospace, monospace;
}

/* ----- bàn cờ ----- */
.chessboard {
  --sq: min(11vw, 66px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 8px 26px rgba(31,42,68,0.22);
  border: 4px solid #6b4f3a;
}
.chessboard:focus-visible { outline: 3px solid var(--c-primary); outline-offset: 4px; }
.chessboard--waiting { opacity: 0.75; pointer-events: none; }
.chessboard__row { display: flex; }

.square {
  width: var(--sq);
  height: var(--sq);
  position: relative;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.12s ease;
}
.square--light { background: #f0d9b5; }
.square--dark  { background: #b58863; }

/* nhãn toạ độ ở mép bàn */
.square__rank, .square__file {
  position: absolute;
  font-size: 0.62rem;
  font-weight: 800;
  opacity: 0.55;
  pointer-events: none;
}
.square__rank { top: 2px; left: 3px; }
.square__file { bottom: 1px; right: 4px; }

/* quân cờ */
.piece-wrap { width: 88%; height: 88%; display: block; pointer-events: none; }
.piece { width: 100%; height: 100%; display: block; }
.piece__body {
  stroke: #111;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.piece--white .piece__body { fill: #fff; }
.piece--black .piece__body { fill: #2b2b2b; }
.piece--black .piece__body { stroke: #000; }
.piece__body .piece-line { fill: none; }
.piece--white .piece__body .piece-line { stroke: #111; }
.piece--black .piece__body .piece-line { stroke: #f0f0f0; }
.piece__body .piece-dot { fill: #111; stroke: none; }
.piece--black .piece__body .piece-dot { fill: #f0f0f0; }

/* trạng thái ô */
.square--selected { background: #f6f36b !important; }
.square--last     { box-shadow: inset 0 0 0 100px rgba(255, 235, 120, 0.32); }

/* ô đi được: chấm tròn giữa ô */
.square--move::after {
  content: '';
  position: absolute;
  width: 30%; height: 30%;
  border-radius: 50%;
  background: rgba(20, 90, 50, 0.45);
  pointer-events: none;
}
/* ô ăn được: viền vòng tròn */
.square--capture::after {
  content: '';
  position: absolute;
  inset: 6%;
  border-radius: 50%;
  border: 5px solid rgba(200, 40, 40, 0.6);
  pointer-events: none;
}
/* ô đích của bài học */
.square--target {
  box-shadow: inset 0 0 0 4px var(--c-accent);
  animation: targetPulse 1.4s ease-in-out infinite;
}
@keyframes targetPulse {
  0%, 100% { box-shadow: inset 0 0 0 4px rgba(255,209,102,0.9); }
  50%      { box-shadow: inset 0 0 0 7px rgba(255,209,102,1); }
}
.square--cursor { outline: 3px solid var(--c-primary); outline-offset: -3px; z-index: 2; }
.square--nope { background: #e88 !important; }

.reward__message { color: var(--c-ink-soft); margin-top: 6px; }

body.a11y-reduce .square--target { animation: none; }
body.a11y-contrast .square--light { background: #fff; }
body.a11y-contrast .square--dark  { background: #555; }
body.a11y-contrast .piece--white .piece__body { fill: #fff; stroke: #000; stroke-width: 2; }
body.a11y-contrast .piece--black .piece__body { fill: #000; stroke: #fff; stroke-width: 2; }

@media (max-width: 780px) {
  .chess-area { flex-direction: column; align-items: center; }
  .chess-side { width: min(100%, 420px); }
  .chessboard { --sq: min(11.5vw, 56px); }
  .move-list { max-height: 110px; }
}

/* ---------- Journey: bảng phụ khi đánh ván thật ---------- */

.coach {
  min-height: 1.4em;
  color: var(--c-wrong);
  font-weight: 600;
  font-size: 0.92rem;
}

.captured {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 1.6em;
}
.captured__pieces {
  font-size: 1.3rem;
  line-height: 1.2;
  letter-spacing: 1px;
}
.captured__diff {
  font-size: 0.85rem;
  color: var(--c-ink-soft);
  font-weight: 600;
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.checklist__item {
  font-size: 0.9rem;
  color: var(--c-ink-soft);
}
.checklist__item.is-done {
  color: var(--c-correct);
  font-weight: 600;
}

.move-list__num {
  color: var(--c-ink-soft);
  font-size: 0.85rem;
  margin-left: 6px;
}

/* Hộp chọn quân khi phong cấp */
.promo-row {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.promo-btn {
  font-size: 2.4rem;
  line-height: 1;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 2px solid #dbe3f0;
  background: var(--c-surface);
  cursor: pointer;
}
.promo-btn:hover { border-color: var(--c-primary); }
