/* Small interactive demos inside the stories */
.demo { margin: 0.5rem 0 1.5rem; font-family: var(--sans); }
.demo[hidden] { display: none; }
.demo-intro { font-family: var(--serif); }
.demo-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0 0 1rem; }
.demo-choice {
  font: 600 0.9rem/1 var(--sans);
  color: var(--accent); background: transparent;
  border: 0; box-shadow: inset 0 0 0 2px var(--accent); border-radius: 999px;
  padding: 0.55rem 0.9rem; cursor: pointer;
}
.demo-choice:hover { background: rgba(168, 50, 45, 0.08); }
.demo-choice[aria-pressed="true"] { background: var(--accent); color: #fff; }
.demo-choice:focus-visible, .demo .button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.demo .button { border: 0; cursor: pointer; font-size: 1rem; }
.demo .button[hidden] { display: none; }
.demo-result { margin: 1rem 0 0; min-height: 1.7em; }
.demo-result .is-current { font-weight: 700; color: var(--accent); }
.demo-note { font-size: 0.85rem; color: var(--muted); margin: 0.5rem 0 0; }

/* Wiffle ball: same hit, different fence */
.yard {
  position: relative;
  display: grid; grid-template-columns: 45fr 30fr 25fr;
  height: 8rem;
  border-radius: 0.5rem; overflow: hidden;
  box-shadow: 0 0.5rem 1.5rem rgba(31, 35, 40, 0.12);
}
.yard-zone {
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 0.6rem 0.7rem;
  color: #fff; font-size: 0.8rem; line-height: 1.3;
}
.yard-zone--ours { background: #5f8a4d; }
.yard-zone--neighbors { background: #77a05f; border-left: 4px dashed #f5f1ea; }
.yard-zone--past { background: #9bb886; }
.yard-zone__name { font-weight: 600; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.yard-zone__call {
  align-self: flex-start;
  padding: 0.1rem 0.45rem; border-radius: 999px;
  font-family: var(--mono); font-size: 0.75rem;
  background: rgba(31, 35, 40, 0.35);
}
.yard-zone__call.is-hr { background: #d9a03f; color: #1f2328; }
.yard-zone__call.is-out { background: var(--accent); color: #fff; }
.yard[data-batter="sibling"] .for-me,
.yard[data-batter="me"] .for-sibling { display: none; }

.yard-ball {
  position: absolute; bottom: 2.6rem;
  left: calc(var(--x, 2%) - 0.45rem);
  width: 0.9rem; height: 0.9rem; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: left 0.9s ease-out;
}
.yard-ball.is-flying { animation: yard-arc 0.9s ease-out; }
@keyframes yard-arc {
  0% { transform: translateY(0); }
  45% { transform: translateY(-3.5rem); }
  100% { transform: translateY(0); }
}

/* Same street, different eyes: shapes drawn over a real photo */
.street-photo {
  position: relative;
  border-radius: 0.5rem; overflow: hidden;
  box-shadow: 0 0.5rem 1.5rem rgba(31, 35, 40, 0.15);
}
.street-photo img { display: block; width: 100%; height: auto; }
.street-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.street-layer { opacity: 0; transition: opacity 0.5s ease; }
.street-photo[data-mode="tetris"] .street-layer--tetris,
.street-photo[data-mode="chess"] .street-layer--chess { opacity: 1; }

/* Tetris: the lamp drops in as an L, the intersection settles in as a T */
.street-piece--l { transform: translateY(-140px); transition: transform 0.6s cubic-bezier(0.3, 1.35, 0.6, 1); }
.street-photo[data-mode="tetris"] .street-piece--l { transform: translateY(0); }
.street-piece--t {
  transform-box: fill-box; transform-origin: 50% 0;
  transform: scaleY(0.6);
  transition: transform 0.6s ease 0.15s;
}
.street-photo[data-mode="tetris"] .street-piece--t { transform: scaleY(1); }
.street-block { fill: #b8644a; fill-opacity: 0.88; stroke: #fff; stroke-width: 4; }
.street-t { fill: #3f6e8f; fill-opacity: 0.55; stroke: #fff; stroke-width: 4; stroke-linejoin: round; }
.street-t-line { stroke: #fff; stroke-width: 4; }

/* Chess: a knight's move laid out as three squares on the road */
.knight-square {
  fill: #f3ebe1; fill-opacity: 0.72;
  stroke: #fff; stroke-width: 4; stroke-linejoin: round;
  opacity: 0; transition: opacity 0.35s ease;
}
.knight-square--dark { fill: #6e1f1b; fill-opacity: 0.68; }
.knight-square--land { fill: #d9a03f; fill-opacity: 0.88; }
.street-photo[data-mode="chess"] .knight-square { opacity: 1; }
.street-photo[data-mode="chess"] .knight-square--1 { transition-delay: 0.15s; }
.street-photo[data-mode="chess"] .knight-square--2 { transition-delay: 0.4s; }
.street-photo[data-mode="chess"] .knight-square--3 { transition-delay: 0.65s; }
.knight-ghost {
  font-size: 44px; fill: #1f2328; fill-opacity: 0;
  transition: fill-opacity 0.35s ease;
}
.street-photo[data-mode="chess"] .knight-ghost { fill-opacity: 0.6; transition-delay: 0.85s; }
.knight-start { fill: #1f2328; stroke: #fff; stroke-width: 5; }
.knight-glyph { font-size: 62px; fill: #fff; }

@media (prefers-reduced-motion: reduce) {
  .yard-ball { transition: none; }
  .yard-ball.is-flying { animation: none; }
  .street-layer, .street-piece--l, .street-piece--t,
  .knight-square, .knight-ghost { transition: none !important; }
}
@media (max-width: 40rem) {
  .yard { height: 9rem; }
  .yard-zone { font-size: 0.72rem; padding: 0.5rem; }
}