/* Mini-course "Шахматы с нуля" — page /learn.html */

.learn-page .learn-main {
  width: min(100% - 40px, var(--max));
  margin: 0 auto;
  padding: 8px 0 80px;
}

/* ---------- hero ---------- */
.learn-hero {
  max-width: 46rem;
  margin: 22px auto 26px;
  text-align: center;
  animation: rise 0.7s var(--ease) both;
}

.learn-hero h1 {
  margin: 0 0 14px;
  font-family: var(--display);
  font-size: clamp(2.1rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.12;
}

.learn-hero .help-lede {
  margin-bottom: 22px;
}

.learn-hero-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.learn-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: min(340px, 100%);
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--phone-shadow-sm);
}

.learn-ring {
  position: relative;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.learn-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.learn-ring circle {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
}

.learn-ring .track {
  stroke: var(--surface-2);
}

.learn-ring .fill {
  stroke: var(--gold);
  transition: stroke-dashoffset 0.45s var(--ease);
}

.learn-ring-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.learn-progress-text {
  text-align: left;
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--muted);
}

.learn-progress-text b {
  display: block;
  color: var(--text);
  font-size: 0.95rem;
}

/* ---------- sticky chapter chips ---------- */
.learn-toc {
  position: sticky;
  top: 62px;
  z-index: 9;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 12px;
  margin-bottom: 18px;
  scrollbar-width: none;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
}

.learn-toc::-webkit-scrollbar {
  display: none;
}

.learn-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.learn-chip:hover,
.learn-chip.is-current {
  border-color: var(--gold);
  color: var(--text);
}

.learn-chip.is-done {
  color: var(--text);
}

.learn-chip.is-done::after {
  content: '✓';
  color: var(--accent-2);
  font-weight: 700;
}

.learn-chip-num {
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  font-weight: 700;
}

/* ---------- chapters ---------- */
.learn-chapters {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.learn-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--phone-shadow-sm);
  padding: 22px clamp(16px, 3vw, 26px) 20px;
  scroll-margin-top: 120px;
}

.learn-card.is-done {
  border-color: color-mix(in srgb, var(--accent-2) 55%, var(--line));
}

.learn-card-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
}

.learn-num {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.learn-card h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 700;
}

.learn-lead {
  margin: 6px 0 16px;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
}

.learn-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 320px);
  gap: clamp(16px, 3vw, 30px);
  align-items: start;
}

.learn-copy p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.97rem;
  line-height: 1.62;
}

.learn-copy p:last-child {
  margin-bottom: 0;
}

.learn-copy b {
  color: var(--text);
  font-weight: 600;
}

.learn-tip {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--gold);
  border-radius: 0 10px 10px 0;
  background: var(--gold-wash);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ---------- board ---------- */
.lb {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lb-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06) inset,
    0 10px 24px rgba(0, 0, 0, 0.28);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.lb-sq {
  position: relative;
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
  min-height: 0;
  background: #e9edcc;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.lb-sq.is-dark {
  background: #769656;
}

.lb-sq:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
  z-index: 2;
}

.lb-sq.is-static {
  cursor: default;
}

.lb-sq img {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* Cburnett art keeps ~13% margins inside its 45×45 viewBox; 1.18 makes it
     fill the square like on lichess, while the widest piece (queen, 38.5u)
     still fits without clipping. */
  transform: scale(1.18);
  transform-origin: center;
}

.lb-sq.is-sel::before {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 3px var(--gold);
  border-radius: 2px;
}

.lb-sq.is-ok::before {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 3px #2f7d1f;
}

.lb-sq.is-bad::before {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 3px #b3352a;
}

.lb-sq .lb-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26%;
  height: 26%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(20, 30, 10, 0.32);
  z-index: 0;
}

.lb-sq.is-ok .lb-dot {
  background: rgba(47, 125, 31, 0.55);
}

.lb-sq.is-bad .lb-dot {
  background: rgba(179, 53, 42, 0.55);
}

.lb-coord {
  position: absolute;
  z-index: 2;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  color: rgba(20, 30, 10, 0.55);
  pointer-events: none;
}

.lb-sq.is-dark .lb-coord {
  color: rgba(240, 245, 230, 0.72);
}

.lb-coord-file {
  right: 3px;
  bottom: 2px;
}

.lb-coord-rank {
  left: 3px;
  top: 2px;
}

/* ---------- task ---------- */
.lb-task {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lb-prompt {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text);
}

.lb-prompt b {
  color: var(--gold);
}

.lb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lb-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background 0.2s var(--ease);
}

.lb-btn:hover {
  border-color: var(--gold);
}

.lb-btn.is-primary {
  border-color: transparent;
  background: var(--accent-2);
  color: var(--on-accent);
}

.lb-btn.is-primary:hover {
  background: var(--accent);
}

.lb-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.lb-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lb-opt {
  text-align: left;
  padding: 10px 13px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  line-height: 1.35;
  cursor: pointer;
  transition: border-color 0.2s var(--ease);
}

.lb-opt:hover {
  border-color: var(--gold);
}

.lb-opt.is-sel {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px var(--gold);
}

.lb-opt.is-ok {
  border-color: #2f7d1f;
  background: color-mix(in srgb, #2f7d1f 18%, var(--surface-2));
}

.lb-opt.is-bad {
  border-color: #b3352a;
  background: color-mix(in srgb, #b3352a 16%, var(--surface-2));
}

.lb-opt:disabled {
  cursor: default;
}

.lb-feedback {
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.88rem;
  line-height: 1.5;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.lb-feedback.is-ok {
  border-color: color-mix(in srgb, #2f7d1f 55%, var(--line));
  background: color-mix(in srgb, #2f7d1f 12%, var(--surface-2));
}

.lb-feedback.is-bad {
  border-color: color-mix(in srgb, #b3352a 55%, var(--line));
  background: color-mix(in srgb, #b3352a 10%, var(--surface-2));
}

.lb-feedback.is-hint {
  border-color: color-mix(in srgb, var(--gold) 45%, var(--line));
  background: var(--gold-wash);
}

.lb-feedback[hidden] {
  display: none;
}

.lb-feedback b {
  color: var(--text);
}

/* ---------- final test ---------- */
.learn-test {
  margin-top: 32px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--phone-shadow-sm);
  padding: 24px clamp(16px, 3vw, 28px);
}

.learn-test h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: clamp(1.5rem, 3vw, 2rem);
}

.learn-test-lead {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.55;
}

.quiz-q {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.quiz-q:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.quiz-q-title {
  margin: 0 0 10px;
  font-weight: 600;
  font-size: 0.97rem;
  line-height: 1.45;
}

.quiz-q-title span {
  color: var(--gold);
  margin-right: 6px;
}

.quiz-result {
  margin-top: 18px;
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.quiz-result.is-ok {
  border-color: color-mix(in srgb, #2f7d1f 55%, var(--line));
  background: color-mix(in srgb, #2f7d1f 12%, var(--surface-2));
}

.quiz-result h3 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-size: 1.3rem;
}

.quiz-result p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.5;
}

.quiz-q.is-missing {
  animation: quiz-miss 1.6s ease;
}

@keyframes quiz-miss {
  0%,
  100% {
    background: transparent;
  }
  30% {
    background: color-mix(in srgb, var(--gold) 16%, transparent);
  }
}

.quiz-wrong {
  margin: 0 0 14px;
  padding-left: 18px;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.45;
}

.quiz-wrong li + li {
  margin-top: 6px;
}

/* ---------- next / roadmap ---------- */
.learn-soon {
  margin-top: 28px;
  border-radius: 22px;
  border: 1px dashed color-mix(in srgb, var(--gold) 55%, var(--line));
  background: linear-gradient(
    120deg,
    var(--gold-wash),
    color-mix(in srgb, var(--surface) 88%, var(--gold-wash))
  );
  padding: 22px clamp(16px, 3vw, 26px);
}

.learn-soon h2 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: clamp(1.3rem, 2.6vw, 1.6rem);
}

.learn-soon p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.6;
}

.learn-soon ul {
  margin: 0 0 16px;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
}

.learn-soon b {
  color: var(--text);
}

.learn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.learn-hero-row .learn-actions {
  justify-content: center;
}

.learn-reset {
  margin-top: 18px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
}

.learn-credit {
  margin-top: 22px;
  color: var(--muted);
  font-size: 0.76rem;
  text-align: center;
}

@media (max-width: 780px) {
  .learn-grid {
    grid-template-columns: 1fr;
  }

  .lb {
    max-width: 360px;
    margin: 0 auto;
    width: 100%;
  }

  .learn-toc {
    top: 58px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .learn-hero,
  .learn-ring .fill {
    animation: none;
    transition: none;
  }
}
