/* foldedline.com/play: the web trial. Loaded only on /play, on top of site.css (same tokens). */

/* The board is the hero: its size follows the viewport height so the board AND the tools fit in the first screen
   (compact header 60 + top 12 + stage bar 58 + message 44 + tools 56 + breathing 20 = 250 px of chrome). */
.play { --board-size: min(100%, 600px, max(320px, calc(100svh - 250px))); padding-block: 12px var(--section); }
.play-layout {
  display: grid; gap: 14px clamp(40px, 5vw, 72px);
  grid-template-areas: "intro" "stage" "modes" "panel" "note";
  align-items: start;
}
.play-intro { grid-area: intro; display: grid; gap: 2px; }
.play-intro h1 { font-size: clamp(1.5rem, 1.25rem + .9vw, 1.875rem); font-weight: 900; line-height: 1.1; letter-spacing: -.02em; text-wrap: balance; }
.play-intro p { font-size: var(--step--1); font-weight: 700; }
.modes { grid-area: modes; margin-top: 18px; }
.stage { grid-area: stage; width: var(--board-size); justify-self: center; scroll-margin-top: 8px; }
.chapter-panel { grid-area: panel; }
.storage-note { grid-area: note; max-width: 56ch; }

@media (min-width: 1000px) {
  .play-layout {
    --board-size: min(600px, calc(100vw - 21.5rem - 2 * var(--gutter) - 56px), max(360px, calc(100svh - 250px)));
    grid-template-columns: 21.5rem var(--board-size); justify-content: center;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas: "intro stage" "modes stage" "panel stage" "note stage";
  }
  .play-intro { padding-top: 6px; }
  .modes { margin-top: 4px; }
}

/* Compact header on /play: the puzzle gets the height. */
.site-header--compact .wrap { min-height: 60px; }
.site-header--compact .brand { font-size: 1.125rem; }
.site-header--compact .brand .mark { width: 32px; height: 32px; }
.site-header--compact .nav a { padding-block: 8px; }
.site-header--compact .icon-btn { width: 42px; min-height: 42px; }

/* ---------- Mode switch: two paper tiles on a tray ---------- */
.modes { display: inline-flex; gap: 4px; padding: 4px; border-radius: 20px; background: var(--band); justify-self: start; max-width: 100%; }
.mode {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 16px;
  color: var(--muted); font-weight: 800; text-decoration: none; white-space: nowrap;
}
.mode:hover { color: var(--ink); }
.mode[aria-current] { background: var(--tile); color: var(--ink); box-shadow: 0 3px 0 var(--tile-lip); }
:root[data-play-mode="tutorial"] .mode { color: var(--muted); }

/* ---------- Stage ---------- */
.stage-bar { display: flex; align-items: center; gap: 12px; min-height: 48px; margin-bottom: 10px; }
.stage-heading { flex: 1; min-width: 0; }
.stage-title { font-size: var(--step-2); font-weight: 900; letter-spacing: -.012em; line-height: 1.15; text-wrap: balance; }
.stage-heading .small { margin-top: 2px; }
.beat-tag { flex: none; padding: 4px 12px; border-radius: 99px; border: 2px solid color-mix(in srgb, var(--line) 60%, transparent); color: var(--link); font-size: var(--step--1); font-weight: 850; }
.btn--small { min-height: 44px; padding: 0 16px; font-size: .9375rem; border-radius: 14px; box-shadow: 0 3px 0 var(--lip); }

.board-wrap { position: relative; border-radius: calc(3400% / (var(--n, 6) * 100 + 32)); box-shadow: 0 18px 36px -16px rgba(60, 38, 16, .38); }
:root[data-theme="dark"] .board-wrap { box-shadow: 0 24px 44px -18px rgba(0, 0, 0, .7); }
.play-board {
  display: block; width: 100%; height: auto; aspect-ratio: 1; border-radius: calc(3400% / (var(--n, 6) * 100 + 32));
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.play-board:focus-visible { outline: 3px solid var(--line); outline-offset: 5px; }
.noscript { padding: 24px; text-align: center; }

/* Board pieces (base classes come from site.css: .b-frame .b-cell .b-lip .b-line .pip) */
.play-board .b-cell { transition: fill .18s ease; }
.play-board .b-cell.is-on { fill: color-mix(in srgb, var(--tile) 86%, var(--line)); }
.play-board .b-cell.is-hover { fill: color-mix(in srgb, var(--tile) 84%, var(--line)); }
.play-board .b-cell.is-flash { fill: color-mix(in srgb, var(--tile) 62%, var(--glow)); }
.play-board .b-cell.is-pulse { animation: cell-pulse 1.4s ease-in-out infinite; }
@keyframes cell-pulse { 0%, 100% { fill: var(--tile); } 50% { fill: color-mix(in srgb, var(--tile) 70%, var(--copper)); } }
.play-board .b-glow { filter: url(#ember-play); opacity: 0; transition: opacity .9s ease .1s; }
.play-board.is-won .b-glow { opacity: var(--glow-max); }
.play-board .b-reach { stroke: var(--line); stroke-width: 34; stroke-linecap: round; opacity: .38; }
.play-board .b-cursor { fill: var(--line); opacity: .2; }
.play-board.is-drawing .b-cursor { opacity: .3; }
.play-board .pip .pip-ring { opacity: 0; transition: opacity .2s ease; }
.play-board .pip.is-next .pip-ring { opacity: 1; }
/* Solved: like the app's Daily, the line turns amber and glows; the discs stay as they are. */
.play-board .b-line { transition: stroke .6s ease; }
.play-board.is-won .b-line { stroke: var(--line-lit); }
.play-board.is-won .pip .pip-ring { opacity: 0; }
.play-board .pip text { pointer-events: none; }

.msg { min-height: 1.6em; margin: 10px 0 8px; text-align: center; font-weight: 750; color: var(--muted); text-wrap: balance; }

/* ---------- Tools ---------- */
.tray { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.tool { min-height: 50px; padding: 0 14px; gap: 7px; font-size: 1rem; }
.tool .t-icon { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
.tool .snd-off { display: none; }
.tool.is-off .snd-on { display: none; }
.tool.is-off .snd-off { display: block; }
.tool.is-off { color: var(--muted); }
.tool:disabled { opacity: .42; cursor: default; box-shadow: 0 4px 0 var(--lip); transform: none; filter: none; }
.tool.is-nudge { box-shadow: 0 4px 0 var(--lip), 0 0 0 3px color-mix(in srgb, var(--line) 55%, transparent); }
.tool--wide { flex-basis: 100%; max-width: 280px; }
@media (max-width: 520px) {
  .tray { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
  .tool { flex-direction: column; gap: 3px; min-height: 64px; padding: 6px 4px; font-size: .8125rem; border-radius: 16px; }
  .tool--wide { grid-column: 1 / -1; max-width: none; flex-direction: row; min-height: 52px; font-size: .9375rem; }
}

/* ---------- Results ---------- */
.result { margin-top: 18px; padding: 22px 24px 24px; border-left: 4px solid var(--line); background: var(--raised); border-radius: 0 24px 24px 0; }
.result-title { font-size: clamp(2rem, 1.6rem + 1.6vw, 2.75rem); font-weight: 900; letter-spacing: -.025em; line-height: 1; margin-bottom: 10px; }
.result-title:focus { outline: none; }
.result-line { font-size: var(--step-1); font-weight: 800; }
.result p + p { margin-top: 6px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 12px 14px; margin-top: 20px; }
.share-preview { margin-top: 14px !important; overflow-wrap: anywhere; }
.install-line { margin-top: 18px !important; padding-top: 16px; border-top: 2px solid var(--rule); font-weight: 750; max-width: 52ch; }

/* ---------- Chapter lit card ---------- */
.lit-card { position: relative; margin-top: 18px; padding: clamp(24px, 4vw, 36px); background: var(--raised); border-radius: 28px; box-shadow: var(--shadow); overflow: hidden; }
.lit-card::before { content: ""; position: absolute; inset: -40% -10% auto auto; width: 60%; height: 90%; background: radial-gradient(closest-side, color-mix(in srgb, var(--glow) 38%, transparent), transparent); opacity: var(--glow-max); pointer-events: none; }
.lit-body { position: relative; display: grid; gap: 24px; }
.lit-title { font-size: clamp(2rem, 1.5rem + 2vw, 2.875rem); font-weight: 900; letter-spacing: -.025em; line-height: 1.02; padding-right: 48px; }
.lit-title:focus { outline: none; }
.lit-next { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 18px; align-items: center; margin-top: 18px; }
.lit-next .lead { max-width: 30ch; }
.lit-board { width: 96px; }
.lit-copy .store-slot { margin-top: 24px; }
.lit-close { position: absolute; top: 16px; right: 16px; z-index: 2; }
.lit-close svg { width: 20px; height: 20px; }
.lit-side { display: none; }
.lit-qr { width: 152px; margin: 0; }
.lit-qr .qr { width: 152px; height: 152px; border-radius: 14px; box-shadow: 0 0 0 1px var(--rule); }
.lit-qr .qr-plate { fill: #FFF8EC; }
.lit-qr .qr-ink { fill: #2A211C; }
.lit-qr figcaption { margin-top: 10px; font-size: .8125rem; }
.lit-foot { position: relative; margin-top: 22px; font-weight: 800; }
@media (min-width: 760px) and (pointer: fine) {
  .lit-body { grid-template-columns: minmax(0, 1fr) 152px; align-items: end; }
  .lit-side { display: block; }
}

/* ---------- Chapter panel: the level strip ---------- */
.chapter-panel { padding: 18px 20px 20px; background: var(--band); border-radius: 24px; }
.chapter-panel .meta { font-size: var(--step--1); font-weight: 800; color: var(--muted); }
.chapter-panel h2 { margin: 0 0 12px; }
.strip-wrap { position: relative; }
.strip-line { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.strip-track { fill: none; stroke: var(--rule); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.strip-lit { fill: none; stroke: var(--line); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; }
.strip { position: relative; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px 6px; justify-items: center; }
.node {
  position: relative; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  font-weight: 900; font-size: .9375rem; font-variant-numeric: tabular-nums; text-decoration: none;
  color: var(--muted); background: var(--band); box-shadow: inset 0 0 0 3px var(--rule);
}
.node.is-open { color: var(--ink); background: var(--tile); box-shadow: 0 3px 0 var(--tile-lip); }
.node.is-lit { color: var(--pip-lit-num); background: var(--pip-lit); box-shadow: 0 3px 0 color-mix(in srgb, var(--pip-lit) 60%, #000); }
.node.is-locked { cursor: not-allowed; }
.node[aria-current] { outline: 3px solid var(--line); outline-offset: 3px; }
.node.is-tag::after { content: ""; position: absolute; top: -2px; right: -2px; width: 12px; height: 12px; border-radius: 50%; background: var(--copper); box-shadow: 0 0 0 3px var(--band); }
.node:not(.is-locked):hover { filter: brightness(1.05); }
#ch-count { margin-top: 12px; }
.app-node {
  display: flex; align-items: center; gap: 14px; width: 100%; margin-top: 12px; padding: 8px 14px; min-height: 54px;
  border: 2px dashed color-mix(in srgb, var(--muted) 55%, transparent); border-radius: 20px; background: transparent;
  color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.app-node:hover { background: var(--raised); }
.app-node strong { display: block; font-weight: 850; }
.app-node .small { display: block; }
.app-node-pips { display: inline-flex; gap: 5px; flex: none; }
.app-node-pips i { width: 10px; height: 10px; border-radius: 50%; box-shadow: inset 0 0 0 2.5px var(--copper); }
.panel-links { margin-top: 10px; }

@media (prefers-reduced-motion: reduce) {
  .play-board .b-cell, .play-board .b-glow, .play-board .b-line, .play-board .pip .pip-ring { transition: none; }
  .play-board .b-cell.is-pulse { animation: none; fill: color-mix(in srgb, var(--tile) 70%, var(--copper)); }
}

/* Level nodes are 38 px to keep the strip compact; the hit area stays 44 px. */
.node::before { content: ""; position: absolute; inset: -3px; border-radius: 50%; }
.stage-heading .small, .app-node .small, .storage-note { text-wrap: balance; }
