/* The public example: a cork board you can move around, and any screen walks its own flow.
   Read only. No sidebars, no editing, nothing saved: reloading puts every frame back.
   The rules the app follows apply here too: the page never scrolls, nothing under 12px, targets
   at least 44px, and it works at any browser zoom and on a phone. */
.demo-body {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
}
.demo-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right));
  border-bottom: 1px solid var(--line);
  background: #f8f8f1;
}
.demo-header .brand {
  font-size: 19px;
}
.demo-header .brand img {
  width: 26px;
  height: 26px;
}
.demo-intro {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
  font-size: 13px;
  color: var(--muted);
}
.demo-intro strong {
  color: var(--ink);
  font-size: 14px;
}
.demo-play {
  flex-shrink: 0;
  gap: 8px;
}
.button.primary {
  background: var(--green);
  color: #fbfdf8;
}

/* The board */
.demo-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background-color: var(--cork);
  background-image:
    radial-gradient(#00000012 1px, transparent 1.4px),
    radial-gradient(#ffffff12 1px, transparent 1.4px);
  background-size:
    13px 13px,
    17px 17px;
  background-position:
    0 0,
    6px 8px;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.demo-stage.panning {
  cursor: grabbing;
}
.demo-world {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.demo-yarn {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 2;
}
.demo-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 500 15px var(--sans);
  color: #6a5a3c;
}

/* A frame: paper, a tack, tape with its name, the drawing, and what it is. */
.card {
  position: absolute;
  z-index: 3;
  cursor: grab;
}
.card.dragging {
  z-index: 6;
  cursor: grabbing;
}
.card-paper {
  position: relative;
  background: #fffef5;
  padding: 30px 12px 0;
  border-radius: 1px;
  box-shadow:
    1px 3px 4px #52432a2a,
    2px 9px 15px #69543622;
}
.card:hover .card-paper {
  box-shadow:
    1px 4px 7px #52432a30,
    3px 11px 20px #6954362a;
}
.card-tack {
  position: absolute;
  top: 8px;
  left: calc(50% - 8px);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 24%, #d98c7d, #b55547 40%, #8c3b30 70%, #c06a5c 71%);
  box-shadow: 0 2px 3px #4c3a2540;
}
.card-tape {
  position: absolute;
  left: 0;
  top: -35px;
  max-width: 100%;
  min-height: 30px;
  padding: 3px 13px 5px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--hand);
  font-size: clamp(22px, calc(13px / var(--board-zoom, 1)), 46px);
  font-weight: 600;
  line-height: 1.1;
  color: #686748;
  background: #f5edcf;
  box-shadow: 0 3px 4px #64513128;
  transform: rotate(var(--tilt));
  clip-path: polygon(0.6% 2%, 99% 0, 100% 97%, 0 100%);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-home {
  font-size: 0.7em;
  color: #9b986f;
}
.card-shot {
  position: relative;
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
}
.card-shot img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  background: #fdfbf4;
}
.card-shot::after {
  content: 'Walk it →';
  position: absolute;
  inset: auto 0 0 0;
  padding: 26px 10px 10px;
  font: 600 clamp(13px, calc(13px / var(--board-zoom, 1)), 30px) var(--sans);
  color: #fffdf4;
  text-align: right;
  background: linear-gradient(to top, #24322a9e, transparent);
  opacity: 0;
  transition: opacity 0.15s;
}
.card-shot:hover::after,
.card-shot:focus-visible::after {
  opacity: 1;
}
.card-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 4px;
  font-size: clamp(12px, calc(12px / var(--board-zoom, 1)), 30px);
  letter-spacing: 1.4px;
  color: #9b9b87;
}
.card-code {
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #6f7e62;
  background: #eef1e6;
  border-radius: 4px;
  padding: 2px 6px;
}
.pin {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 23px;
  height: 23px;
  border-radius: 50%;
  border: 2px solid #fff7e7;
  background: radial-gradient(circle at 35% 25%, #d88573, #ae4d41 70%);
  color: #fff8e9;
  font: 700 12px var(--sans);
  display: grid;
  place-items: center;
  box-shadow: 1px 3px 5px #553d2855;
  z-index: 5;
  pointer-events: none;
}
.yarn-label {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 4;
  padding: 7px 12px;
  border-radius: 999px;
  background: #f7f1dd;
  border: 1px solid #d9cba3;
  color: #6b5a40;
  font: 600 max(12px, calc(12px / var(--board-zoom, 1))) var(--sans);
  white-space: nowrap;
  max-width: calc(240px / var(--board-zoom, 1));
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 4px #4a3c2430;
  pointer-events: none;
}
.history-tag {
  position: absolute;
  z-index: 4;
  padding: 6px 11px;
  border-radius: 999px;
  background: #eef1e6;
  border: 1px dashed #b3bfa4;
  color: #5f6e55;
  font: 600 max(12px, calc(12px / var(--board-zoom, 1))) var(--sans);
  white-space: nowrap;
  pointer-events: none;
}
.demo-world.far .pin,
.demo-world.far .yarn-label,
.demo-world.far .history-tag {
  opacity: 0;
}
.demo-world.far .card-foot {
  visibility: hidden;
}

/* Legend, controls, hint */
.demo-legend {
  position: absolute;
  left: 16px;
  top: 14px;
  z-index: 8;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  padding: 9px 13px;
  border-radius: 10px;
  background: #fffef5d9;
  backdrop-filter: blur(3px);
  box-shadow: 0 2px 8px #4a3c2426;
  font-size: 12px;
  color: #5d6455;
  max-width: calc(100% - 32px);
}
.demo-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.demo-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.demo-controls {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: #fffef5e8;
  box-shadow: 0 3px 12px #4a3c2433;
}
.demo-controls .icon-button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: none;
  font-size: 19px;
  line-height: 1;
  color: #4c5648;
  cursor: pointer;
}
.demo-controls .icon-button:hover {
  background: #e9ecdf;
}
.demo-zoom {
  min-width: 52px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #5d6455;
}
.demo-hint {
  position: absolute;
  right: 16px;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 8;
  font-size: 12px;
  color: #6b5a3c;
  background: #fffef5b3;
  padding: 6px 10px;
  border-radius: 8px;
  max-width: 45%;
  text-align: right;
}
.only-narrow {
  display: none;
}

/* Walking the flow */
.player {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: #2b2a24f2;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  gap: 10px;
}
.player[hidden] {
  display: none;
}
.player-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fffef5;
}
.player-where {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  min-width: 0;
}
.player-where span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-where b {
  font-size: 12px;
  color: #6f7e62;
  background: #eef1e6;
  border-radius: 4px;
  padding: 3px 7px;
}
.player-kind {
  font-size: 12px;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 4px;
  background: #e7e3d0;
  color: #6b5f3d;
}
.player-steps {
  margin-left: auto;
  font-size: 13px;
  color: var(--muted);
}
.player-close {
  background: var(--green);
  color: #fbfdf8;
  border-color: var(--green);
}
.player-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
}
.player-frame {
  position: relative;
  max-width: 100%;
  background: #fffef5;
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 14px 40px #00000059;
  line-height: 0;
}
.player-frame img {
  display: block;
  width: 100%;
  height: auto;
}
.player-frame img[hidden] {
  display: none;
}
.player-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  border-radius: 50%;
  border: 2px solid #fff7e7;
  background: radial-gradient(circle at 35% 25%, #d88573, #ae4d41 70%);
  color: #fff8e9;
  font: 700 14px var(--sans);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 1px 3px 6px #00000066;
  animation: pulse 2.4s ease-in-out infinite;
}
.player-pin:hover,
.player-pin:focus-visible {
  outline: 6px solid #bc615a4d;
}
@keyframes pulse {
  0%,
  100% {
    box-shadow:
      1px 3px 6px #00000066,
      0 0 0 0 #d8857399;
  }
  50% {
    box-shadow:
      1px 3px 6px #00000066,
      0 0 0 10px #d8857300;
  }
}
.player-note {
  flex-shrink: 0;
  text-align: center;
  font-size: 13px;
  color: #efeadb;
}
.player-choice {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #1c1b1899;
  padding: 16px;
}
.player-choice[hidden] {
  display: none;
}
.player-choice-card {
  width: min(460px, 100%);
  max-height: 80dvh;
  overflow: auto;
  background: #fffef5;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.player-choice-card .eyebrow {
  font-size: 12px;
  letter-spacing: 1.4px;
  color: #96a086;
}
.player-choice-card h2 {
  font: 400 24px/1.2 var(--serif);
}
.player-choice-card > p {
  font-size: 14px;
  color: var(--muted);
}
.branch {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcf6;
  cursor: pointer;
  font: inherit;
}
.branch:hover {
  border-color: var(--green);
  background: #f1f3e9;
}
.branch strong {
  font-size: 14px;
}
.branch small {
  font-size: 12px;
  color: var(--muted);
}
.branch em {
  font-size: 12px;
  font-style: normal;
  color: #7d8872;
}

@media (max-width: 720px) {
  .demo-intro {
    display: none;
  }
  .demo-header {
    justify-content: space-between;
  }
  /* The hint sits above the controls instead of beside them, so neither is covered. */
  .demo-hint {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 60px);
    max-width: calc(100% - 24px);
    text-align: center;
    white-space: nowrap;
  }
  .only-wide {
    display: none;
  }
  .only-narrow {
    display: inline;
  }
  .demo-legend {
    left: 10px;
    top: 10px;
    padding: 7px 10px;
    gap: 4px 10px;
  }
  .player-steps {
    display: none;
  }
  /* The title takes its own row so the three buttons share the next one evenly. */
  .player-where {
    flex-basis: 100%;
  }
  .player-bar .button {
    flex: 1;
    justify-content: center;
    white-space: nowrap;
    padding-left: 10px;
    padding-right: 10px;
  }
  .player-frame {
    padding: 6px;
    width: 100%;
  }
  .player-frame img {
    width: 100%;
  }
}
@media (max-height: 520px) {
  .demo-header {
    padding-top: 6px;
    padding-bottom: 6px;
  }
  .demo-intro strong {
    display: none;
  }
  .player-note {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .player-pin {
    animation: none;
  }
}

/* A frame that is planned but not drawn yet: on the board, and while walking it. The app shows
   the same thing, because a board in progress is most of what a board ever is. */
.card-shot.planned {
  aspect-ratio: 2 / 1;
  display: grid;
  place-items: center;
  padding: 8px;
  background: repeating-linear-gradient(0deg, transparent 0 23px, #efebdc 23px 24px);
  border: 2px dashed #cfc8a9;
  border-radius: 6px;
  overflow: hidden;
}
.card-waiting {
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: center;
  color: #6f7767;
  min-width: 0;
}
.card-waiting em {
  font-style: normal;
  letter-spacing: 1.1px;
  color: #a08c5a;
  font-size: clamp(12px, calc(12px / var(--board-zoom, 1)), 26px);
}
.card-waiting b {
  font: 400 clamp(15px, calc(15px / var(--board-zoom, 1)), 36px) var(--serif, Georgia, serif);
  color: #4c5648;
}
.demo-world.far .card-waiting > * {
  visibility: hidden;
}
.card-shot.planned::after {
  padding-top: 14px;
}
.player-frame.planned {
  width: min(680px, 100%);
  padding: 22px;
}
.player-waiting {
  display: flex;
  flex-direction: column;
  gap: 10px;
  line-height: 1.55;
  text-align: left;
}
.player-waiting strong {
  font: 400 24px/1.2 var(--serif, Georgia, serif);
}
.player-waiting p {
  font-size: 14px;
  color: var(--muted);
}
.player-waiting span {
  font-size: 12px;
  letter-spacing: 1.2px;
  color: #a08c5a;
}
.player-waiting ul {
  margin: 0;
  padding-left: 20px;
  font-family: var(--hand, cursive);
  font-size: 20px;
  line-height: 1.35;
  color: #4c5648;
}
.player-waiting li.more {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--muted);
  list-style: none;
  margin-left: -20px;
}
