/* Interactive animation pages: built on top of course.css (same variables and look as index.html) */

:root {
  --ink: var(--text-primary);
  --muted: var(--text-secondary);
  --accent: var(--accent-code);
  --accent2: var(--accent-compile);
  --line: rgba(27, 128, 207, 0.12);
  --warm: #fff0cf;
  --good: #e2f5ed;
}

.anim-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.anim-hero {
  padding: 74px 0 0.5rem;
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.2rem 1.5rem;
}

.eyebrow {
  flex-basis: 100%;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.anim-hero h1 {
  font-size: clamp(1.5rem, 2.6vw, 2.1rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--accent-syntax) 0%, var(--accent-code) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.lede {
  flex: 1 1 380px;
  margin: 0 !important;
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.anim-main h2 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.4rem;
}

.anim-main p {
  margin: 0.25rem 0 0.5rem;
}

.muted,
.hint {
  color: var(--muted);
}

.panel {
  background: var(--bg-secondary);
  border: 2px solid rgba(27, 128, 207, 0.1);
  border-radius: 16px;
  padding: 0.85rem 1.15rem;
  box-shadow: 0 4px 20px var(--shadow-code);
  margin-bottom: 1rem;
}

.controls-row {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1rem;
}

.controls-row .panel {
  margin-bottom: 1rem;
}

.setup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.25rem;
  align-items: end;
}

.field label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.field input,
.field select {
  width: 100%;
  min-height: 45px;
  padding: 0.6rem 0.8rem;
  border: 1px solid #b8c5d3;
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

.examples {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid #b5c5d5;
  padding: 0.55rem 1rem;
  color: var(--ink);
  background: #fff;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

button:hover:not(:disabled) {
  border-color: var(--accent);
  background: #eef6fd;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.primary:hover:not(:disabled) {
  background: var(--accent-syntax);
  border-color: var(--accent-syntax);
  color: #fff;
}

.playback {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.playback .spacer {
  flex: 1;
}

.speed {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.speed select {
  width: auto;
  min-height: 41px;
  padding: 0.4rem 0.6rem;
  border: 1px solid #b8c5d3;
  border-radius: 10px;
  font: inherit;
}

.scrubber {
  margin-top: 0.6rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
}

.scrubber input {
  width: 100%;
  accent-color: var(--accent);
}

.stage-grid {
  display: grid;
  grid-template-columns: 1.5fr 0.8fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.stage-grid .panel {
  margin: 0;
}

.tokens {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-height: 54px;
  align-items: center;
}

.token {
  display: inline-flex;
  min-width: 40px;
  min-height: 43px;
  justify-content: center;
  align-items: center;
  padding: 4px 12px;
  background: #eef2f8;
  border: 2px solid transparent;
  border-radius: 10px;
  font: 700 1.1rem ui-monospace, SFMono-Regular, Consolas, monospace;
}

.token.processed {
  background: #edf1f4;
  color: #778498;
}

.token.current {
  border-color: #cc8610;
  background: var(--warm);
  color: #6b4300;
}

.token.pending {
  background: #edf3fa;
}

.stack {
  min-height: 170px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.35rem;
  max-width: 300px;
  margin: 0 auto;
}

.stack-cell {
  text-align: center;
  border: 1px solid #87b0cd;
  background: #e8f5fd;
  border-radius: 8px;
  padding: 0.45rem;
  font: 700 1.15rem ui-monospace, monospace;
}

.stack-cell.top {
  background: #d0edf1;
  border-color: #4aa4ae;
}

.stack-cell {
  position: relative;
}

.stack-cell.top::before {
  content: '▲ sommet';
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  font: 600 0.7rem -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--muted);
}

/* Elements that arrive after a flight: hidden until the flying copy lands, then flash */
.stack-cell.pushed {
  animation: land-green 0.7s ease-out 0.3s backwards;
}

.output .token.arrived,
.calculation-history li.arrived {
  animation: land-blue 0.7s ease-out 0.3s backwards;
}

.fly {
  position: fixed;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  pointer-events: none;
  border: 2px solid var(--accent);
  border-radius: 10px;
  background: var(--warm);
  box-shadow: 0 6px 18px var(--shadow-code);
  font: 700 1.1rem ui-monospace, monospace;
}

@keyframes land-green {
  from {
    opacity: 0;
    background: #b5e6c9;
  }

  40% {
    opacity: 1;
    background: #b5e6c9;
  }
}

@keyframes land-blue {
  from {
    opacity: 0;
    background: #bfe0f7;
  }

  40% {
    opacity: 1;
    background: #bfe0f7;
  }
}

.stack-base {
  text-align: center;
  border-top: 3px solid var(--ink);
  font-size: 0.82rem;
  color: var(--muted);
  margin: 10px auto 0;
  max-width: 330px;
}

.output {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-height: 65px;
  align-content: start;
}

.output .token {
  background: var(--good);
  border-color: #9bcdbb;
}

.message {
  font-size: 1.02rem;
  margin: 0;
}

.note {
  margin-top: 0.5rem;
  border-left: 4px solid var(--accent2);
  padding: 0.4rem 0.8rem;
  background: #f0faf9;
  border-radius: 0 8px 8px 0;
}

.step-number {
  font-weight: 800;
  color: var(--accent);
  font-size: 0.9rem;
}

.error {
  color: #982a36;
  background: #fff1f1;
  border: 1px solid #f0c0c4;
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  margin-top: 0.8rem;
}

.hidden {
  display: none;
}

.result {
  font-size: 1.35rem;
  font-weight: 800;
  color: #086b54;
}

.algorithm {
  padding-left: 1.5rem;
}

.algorithm li {
  margin: 0.45rem 0;
}

.code {
  font-family: ui-monospace, monospace;
  background: #eef2f7;
  border-radius: 5px;
  padding: 2px 5px;
}

/* Reason for the current step */
.detail-note {
  border-left-color: var(--accent);
  background: #f2f8fd;
}

.detail-note .slot {
  display: inline-block;
  padding: 0 0.5rem;
  border-radius: 6px;
  background: var(--warm);
  font-family: ui-monospace, monospace;
}

.detail-note .op {
  font: 800 1.2rem ui-monospace, monospace;
}

.detail-note code {
  font-weight: 700;
  background: #e3eef8;
  border-radius: 5px;
  padding: 0 4px;
}

/* Operator priorities (infix page) */
.prio-line {
  margin: 0.5rem 0 0 !important;
  font-size: 0.9rem;
  color: var(--muted);
}

.prio-line span {
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
}

.prio-line span.active {
  background: var(--warm);
  color: var(--ink);
  font-weight: 700;
}

.button-link {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}

.button-link:hover {
  background: var(--accent-syntax);
}

/* Predict mode */
.predict {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-weight: 600;
}

.quiz {
  margin-top: 0.75rem;
  padding: 1rem 1.25rem;
  border: 2px solid var(--accent);
  border-radius: 14px;
  background: #f2f8fd;
}

.quiz-question {
  font-weight: 700;
  margin: 0 0 0.6rem;
}

.quiz-choices {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

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

  .stage-grid > .panel:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .anim-hero {
    padding-top: 90px;
  }

  .controls-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .setup,
  .stage-grid {
    grid-template-columns: 1fr;
  }

  .stage-grid > .panel:first-child {
    grid-column: auto;
  }

  .anim-main {
    padding: 0 1rem;
  }

  .panel {
    padding: 1.25rem;
  }

  .playback .spacer {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Evolving history of the postfix evaluation */
.output-evaluation {
  display: block;
  min-height: 120px;
}

.calculation-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--good);
  border: 1px solid #9bcdbb;
}

.calculation-summary .result {
  font: 800 1.8rem ui-monospace, Consolas, monospace;
}

.calculation-history {
  margin: 0;
  padding-left: 27px;
  display: grid;
  gap: 8px;
}

.calculation-history li {
  padding: 7px 9px;
  border-radius: 7px;
  font-family: ui-monospace, Consolas, monospace;
}

.calculation-history li.latest {
  background: var(--warm);
  font-weight: 700;
}

.calc-expression {
  white-space: pre-wrap;
}

/* Compact desktop layout */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.help {
  margin-top: 0.4rem;
  font-size: 0.9rem;
}

.help summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}

.controls-row .panel button,
.stage-grid .button-link {
  padding: 0.4rem 0.75rem;
  font-size: 0.95rem;
}

.controls-row .field input {
  min-height: 40px;
}

.examples {
  margin-top: 0.5rem;
  gap: 0.4rem;
}

.examples button {
  padding: 0.3rem 0.6rem;
}

.speed select {
  min-height: 36px;
}

.stack {
  min-height: 120px;
}

.stack-base {
  margin-top: 6px;
}

@media (max-width: 768px) {
  .anim-hero {
    padding-top: 200px;
  }
}
