/* explain.css: layout for the animated explanations. Builds on /style.css (colours, type). */
[hidden] { display: none !important; }

body.explain header,
body.explain footer { max-width: 74rem; }
body.explain header { padding-top: 2rem; }

.crumbs {
  font: .88rem/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--muted);
  margin: 0 0 1rem;
}
.crumbs a { color: var(--muted); }

.intro { max-width: 44rem; }
.intro .limits { margin-top: .4rem; }

.explain-layout {
  max-width: 74rem;
  margin: 0 auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.25fr);
  gap: 2.2rem;
  align-items: start;
}
.stage-col { grid-column: 2; grid-row: 1; position: sticky; top: .8rem; }
.steps-col { grid-column: 1; grid-row: 1; max-width: none; margin: 0; padding: 0; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #0b0f15;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.stage canvas { display: block; width: 100%; height: 100%; }
.no-webgl .stage { display: none; }
.no-webgl .stage-bar { display: none; }
.no-webgl .stage-caption { display: none; }
.no-webgl .show3d { display: none; }

.stage-bar {
  display: flex;
  gap: .4rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: .5rem;
  font: .9rem/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.step-label { flex: 1 1 12rem; color: var(--muted); }
.stage-caption { color: var(--muted); font-size: .88rem; margin: .45rem 0 0; min-height: 2.6em; }
.stage-controls { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-top: .45rem; }
.stage-controls:empty { display: none; }
.ctl-row { display: flex; flex-wrap: wrap; gap: .3rem; }
.stage-legend {
  margin: 0;
  font: .9rem/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--fg);
  border-left: 2px solid var(--accent);
  padding-left: .6rem;
}
.ctl-slider {
  display: flex; align-items: center; gap: .6rem; flex: 1 1 16rem;
  font: .88rem/1.3 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--muted);
}
.ctl-slider input { flex: 1 1 auto; accent-color: var(--accent); min-height: 2rem; }

button.ctl,
.ctl-row button {
  font: .88rem/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: .45rem .75rem;
  min-height: 2.2rem;
  cursor: pointer;
}
button.ctl:hover, .ctl-row button:hover { border-color: var(--accent); }
button.ctl:focus-visible, .ctl-row button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.ctl[disabled] { opacity: .45; cursor: default; }
.ctl-row button[aria-pressed="true"], button.ctl[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.nogl { border-left: 3px solid var(--accent); padding: .6rem 0 .6rem 1rem; background: var(--card); }

section.step {
  padding: 1.2rem 0 2.4rem;
  min-height: 62vh;
  border-top: 1px solid var(--line);
}
section.step:first-child { border-top: 0; }
section.step h2 {
  margin-top: .4rem;
  text-transform: none;
  letter-spacing: 0;
  font-size: 1.2rem;
  color: var(--fg);
}
section.step.active h2 { color: var(--accent); }
section.step .num { color: var(--muted); font-weight: 400; margin-right: .35rem; }
.scene-note { color: var(--muted); font-size: .9rem; border-left: 2px solid var(--line); padding-left: .75rem; }
.scene-note strong { font-weight: 600; }
.show3d { margin-top: .2rem; }
.steps-col .end { min-height: 30vh; }
section.reading { padding: 1.2rem 0 1.6rem; border-top: 1px solid var(--line); }
section.reading h2 { margin-top: .4rem; text-transform: none; letter-spacing: 0; font-size: 1.05rem; color: var(--fg); }
section.reading li, section.reading p { font-size: .92rem; }
.fine { font-size: .88rem; color: var(--muted); }

/* overview page cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1.2rem; margin: 1.4rem 0; }
.card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem 1.1rem 1.1rem;
  text-decoration: none;
  color: var(--fg);
}
.card:hover, .card:focus-visible { border-color: var(--accent); }
.card img { width: 100%; height: auto; display: block; border-radius: 4px; margin-bottom: .8rem; background: #0b0f15; }
.card h3 { margin: 0 0 .4rem; font: 600 1.1rem/1.3 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--accent); }
.card p { margin: 0; font-size: .95rem; }

@media (max-width: 860px) {
  .explain-layout { display: block; padding: 0; }
  .stage-col {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--bg);
    padding: .5rem 16px .4rem;
    border-bottom: 1px solid var(--line);
  }
  .stage { aspect-ratio: auto; height: 36vh; min-height: 13rem; }
  .stage-caption { display: none; }
  .stage-legend { font-size: .8rem; line-height: 1.35; }
  .steps-col { padding: 0 16px; }
  section.step { min-height: 52vh; scroll-margin-top: calc(36vh + 5.5rem); }
  .no-webgl .stage-col { position: static; border-bottom: 0; }
}
