/* Math Pyramid — game styles scoped to .mp-* / #math-pyramid-app.
   Lessonfield tokens (--ink, --paper2, --moss, --sage, --rust, --muted, --line) are inherited. */

#math-pyramid-app {
  --mp-block: clamp(40px, 13vw, 72px);
  --mp-gap: clamp(4px, 1.5vw, 10px);
  --mp-font: clamp(1rem, 3.2vw, 1.5rem);
  --mp-radius: 10px;
}

.mp-game {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 640px;
  margin: 0 auto;
}

.mp-heading-sub {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  text-align: center;
}

.mp-grades {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.mp-grade {
  appearance: none;
  min-width: 48px;
  min-height: 48px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper2);
  color: var(--ink);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}

.mp-grade:hover { background: var(--sage); }

.mp-grade--on {
  background: var(--moss);
  border-color: var(--moss);
  color: var(--paper2);
}

.mp-progress {
  margin: 0;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--muted);
}

.mp-pyramid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--mp-gap);
  padding: clamp(12px, 3vw, 24px) 8px;
  background: var(--paper2);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 22px rgba(24, 32, 28, 0.05);
  overflow-x: auto;
}

.mp-row {
  display: flex;
  gap: var(--mp-gap);
}

.mp-block {
  width: var(--mp-block);
  height: var(--mp-block);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--mp-radius);
  font-family: var(--serif);
  font-weight: 600;
  font-size: var(--mp-font);
  color: var(--ink);
  background: var(--paper);
  border: 2px solid var(--line);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
}

.mp-block--given {
  background: var(--moss);
  border-color: var(--moss);
  color: var(--paper2);
}

button.mp-block--empty {
  appearance: none;
  cursor: pointer;
  border-style: dashed;
  border-color: var(--muted);
  color: var(--muted);
  font-family: var(--sans);
}

button.mp-block--empty:hover {
  border-color: var(--moss);
  color: var(--moss);
}

button.mp-block--empty:focus-visible,
.mp-grade:focus-visible,
.mp-key:focus-visible,
.mp-btn:focus-visible {
  outline: 3px solid var(--rust);
  outline-offset: 3px;
}

.mp-block--active {
  border: 2px solid var(--rust);
  border-style: solid;
  color: var(--ink);
  background: var(--paper2);
  box-shadow: 0 0 0 4px rgba(166, 83, 61, 0.22);
  transform: scale(1.06);
}

.mp-block--solved {
  background: var(--sage);
  border-color: var(--moss);
  border-style: solid;
  color: var(--moss);
  animation: mp-solve 0.25s ease;
}

@keyframes mp-solve {
  40% { transform: scale(1.12); }
}

.mp-block--error {
  border-color: #b03a2e;
  color: #b03a2e;
  background: #f7e4e0;
  animation: mp-shake 0.3s ease;
}

@keyframes mp-shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.mp-block--hint {
  border-color: var(--rust);
  background: #f6e8d9;
  color: var(--rust);
}

.mp-feedback {
  margin: 0;
  min-height: 2em;
  text-align: center;
  font-weight: 650;
  color: var(--moss);
}

.mp-feedback[data-kind='win'] {
  color: var(--rust);
  font-size: 1.15rem;
}

.mp-keypad {
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  margin: 0 auto;
}

.mp-keys {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mp-key {
  appearance: none;
  min-height: 52px;
  padding: 8px 0;
  border: 1px solid var(--line);
  border-radius: var(--mp-radius);
  background: var(--paper2);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.mp-key:active { transform: scale(0.95); background: var(--sage); }

.mp-key--enter {
  min-height: 52px;
  border: 0;
  border-radius: var(--mp-radius);
  background: var(--moss);
  color: var(--paper2);
  font-family: var(--sans);
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}

.mp-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.mp-btn {
  appearance: none;
  border: 1px solid var(--moss);
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 16px;
  min-height: 44px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  touch-action: manipulation;
}

.mp-btn:active { transform: scale(0.97); }

.mp-hide { display: none; }

@media (prefers-reduced-motion: reduce) {
  .mp-block,
  .mp-key,
  .mp-btn,
  .mp-grade {
    animation: none !important;
    transition: none !important;
  }
}

/* page-level (no inline styles) */
.mp-hero { display: block; padding: 64px 0 8px; }
.mp-hero h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); margin: 0.15em 0 0.3em; }
.mp-hero-pad { padding: 52px 0 30px; }
.mp-game-section { background: var(--oat); }
.mp-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 24px;
}
.mp-cards article {
  padding: 18px;
  background: var(--paper2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.mp-cards h3 { margin: 0 0 6px; }
.mp-cards p { margin: 0; color: var(--muted); font-size: 0.95rem; }
