/* =====================================================
   /learn/tetris/step-XX/ — shared layout for every step page.
   Builds on /style.css tokens and /learn/tetris/course.css.
   ===================================================== */

.step-hero {
  padding-top: 140px;
  padding-bottom: 40px;
}
.step-hero__inner {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.step-hero__no {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.step-hero__title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(36px, 5.5vw, 64px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 8px 0 24px;
  font-variation-settings: "opsz" 96;
}
.step-hero__goal {
  max-width: 60ch;
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--fg);
  margin: 0;
}
.step-hero__goal strong {
  font-weight: 500;
  background: linear-gradient(transparent 68%, rgba(255, 90, 31, 0.22) 68%);
  padding: 0 2px;
}

/* ---------- Playground (editor + canvas + controls) ---------- */
.playground {
  padding-bottom: clamp(80px, 8vw, 120px);
}
.playground__inner {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}
@media (min-width: 900px) {
  .playground__inner {
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 40px;
    align-items: start;
  }
}

.playground__code {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #FDFCFA;
  overflow: hidden;
  min-width: 0;
}
.playground__code-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: #F4F2EC;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.playground__code-filename {
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
}
.playground__code-readonly {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 99px;
  color: var(--muted);
  background: var(--bg);
  letter-spacing: 0.04em;
}
.playground__code textarea {
  display: block;
  width: 100%;
  border: 0;
  resize: none;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--fg);
  padding: 20px 24px;
  outline: none;
  overflow: auto;
  min-height: 360px;
  tab-size: 4;
}
.playground__code textarea[readonly] {
  cursor: default;
  color: var(--fg);
}

/* ---------- Right column: canvas + controls ---------- */
.playground__stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.playground__canvas-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #1A1A1A;
  border-radius: 6px;
  border: 1px solid var(--border);
  aspect-ratio: 1 / 2;
  max-width: 320px;
  margin-inline: auto;
  width: 100%;
}
.playground__canvas {
  display: block;
  background: #0D0D0D;
  image-rendering: pixelated;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: auto;
}

.playground__controls {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.playground__run {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--bg);
  background: var(--fg);
  border: 1px solid var(--fg);
  border-radius: 4px;
  padding: 12px 18px;
  cursor: pointer;
  transition: background 180ms var(--ease), color 180ms var(--ease);
}
.playground__run:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
}
.playground__run:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.playground__run-icon {
  display: inline-block;
  font-size: 10px;
}

.playground__status {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.playground__status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #C4C0B8;
  flex-shrink: 0;
}
.playground__status[data-mode="loading"]::before { background: #D7BA5A; animation: pulse 1.2s ease-in-out infinite; }
.playground__status[data-mode="running"]::before { background: #7FAE6A; }
.playground__status[data-mode="error"]::before   { background: var(--accent); }
.playground__status[data-mode="ready"]::before   { background: var(--muted); }

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.playground__console {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  background: #F4F2EC;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
  max-height: 120px;
  overflow-y: auto;
  min-height: 44px;
}
.playground__console:empty::before {
  content: "console output";
  color: #B8B4AC;
  font-style: italic;
}

/* ---------- Explanation + navigation sections ---------- */
.step-body {
  padding-block: clamp(56px, 7vw, 96px);
  border-top: 1px solid var(--border);
}
.step-body__inner {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
.step-body__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
}
@media (min-width: 800px) {
  .step-body__grid {
    grid-template-columns: 200px 1fr;
    gap: 64px;
  }
}
.step-body__eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
  padding-top: 6px;
}
.step-body__section {
  margin-bottom: 48px;
}
.step-body__section:last-child { margin-bottom: 0; }
.step-body__section h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.6rem;
  margin: 0 0 16px;
  font-variation-settings: "opsz" 48;
}
.step-body__section p {
  font-size: 1rem;
  line-height: 1.85;
  color: var(--fg);
  margin: 0 0 16px;
  max-width: 60ch;
}
.step-body__section p:last-child { margin-bottom: 0; }
.step-body__section code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: #F1EFEA;
  padding: 2px 6px;
  border-radius: 3px;
}
.step-body__section ul {
  margin: 0 0 16px;
  padding-left: 1.5em;
  list-style: disc;
  font-size: 1rem;
  line-height: 1.85;
}
.step-body__section li { margin-bottom: 4px; }

.step-nav {
  border-top: 1px solid var(--border);
  padding-block: clamp(40px, 5vw, 72px);
}
.step-nav__inner {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.step-nav a, .step-nav span {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  transition: color 180ms var(--ease);
}
.step-nav a:hover { color: var(--accent); }
.step-nav .step-nav__disabled {
  color: var(--muted);
  pointer-events: none;
}
.step-nav__arrow {
  font-size: 12px;
}

/* ---------- First-time CheerpJ loading overlay ---------- */
.playground__loading {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  background: rgba(26, 26, 26, 0.88);
  color: #F4F2EC;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 24px;
  text-align: center;
  border-radius: 6px;
}
.playground__loading[data-visible="true"] { display: flex; }
.playground__loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #444;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.playground__loading small {
  color: #9A968E;
  max-width: 220px;
  line-height: 1.6;
}
