/* WishNap loop demo — share it, let it nap, decide awake.
   Four real boards (Design/boards cap-01, main-01, main-04, main-07) ported
   as HTML at their native 393×852, inside a CSS phone scaled to the mount's
   width (js/loop-demo.js sets --ld-s). The phone is a generic frame on
   purpose: no Dynamic Island, no side buttons, so it isn't a home-drawn
   iPhone (Apple asks for its own product images). Colors: tokens.css only. */

.loop-demo { display: block; position: relative; --ld-s: 0.72; }

/* ---------- Phone ---------- */
.ld-phone {
  position: relative;
  width: 100%;
  aspect-ratio: 417 / 876;
  border-radius: calc(67px * var(--ld-s));
  box-shadow: var(--ld-phone-shadow);
  overflow: hidden;
}
.ld-device {
  position: absolute; top: 0; left: 0;
  width: 417px; height: 876px;
  transform: scale(var(--ld-s));
  transform-origin: 0 0;
}
.ld-bezel {
  position: absolute; inset: 0;
  border-radius: 67px;
  background: var(--ld-bezel);
  box-shadow: inset 0 0 0 1.5px var(--ld-bezel-edge), inset 0 0 0 4px var(--ld-bezel);
}
.ld-screen {
  position: absolute; top: 12px; left: 12px;
  width: 393px; height: 852px;
  border-radius: 55px;
  clip-path: inset(0 round 55px);
  overflow: hidden;
  isolation: isolate;
  background: var(--base);
}

/* ---------- Board basics (the boards' own globals) ---------- */
.ld-scene {
  position: absolute; inset: 0; overflow: hidden;
  background: var(--base); color: var(--ink);
  font-family: var(--font-text);
  -webkit-font-smoothing: antialiased;
  text-align: left; line-height: normal; letter-spacing: normal;
  box-sizing: border-box;
}
.ld-scene *, .ld-scene *::before, .ld-scene *::after { box-sizing: border-box; }
.ld-scene svg { display: block; flex-shrink: 0; }
.ld-num { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.ld-abs { position: absolute; }
.ld-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 600; flex-shrink: 0;
}
.ld-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.ld-grain {
  position: absolute; inset: 0; pointer-events: none;
  background-image: var(--grain); background-size: var(--grain-size) var(--grain-size);
  mix-blend-mode: overlay; opacity: var(--grain-opacity);
}
[data-press] { will-change: opacity, transform; }

/* ---------- cap-01 · Share extension ---------- */
.ld-cap-page { position: absolute; inset: 0; background: var(--ld-white); }
.ld-cap-url { top: 59px; left: 16px; right: 16px; height: 36px; border-radius: 10px; background: var(--ld-urlbar); }
.ld-cap-hero {
  top: 112px; left: 0; right: 0; height: 300px; background: var(--ld-hero);
  display: flex; align-items: center; justify-content: center; color: var(--ld-hero-glyph);
}
.ld-cap-l1 { top: 428px; left: 16px; width: 240px; height: 16px; border-radius: 8px; background: var(--ld-skel-1); }
.ld-cap-l2 { top: 456px; left: 16px; width: 120px; height: 22px; border-radius: 8px; background: var(--ld-skel-2); }
.ld-cap-dim { position: absolute; inset: 0; background: var(--ld-dim); will-change: opacity; }
.ld-cap-sheet {
  position: absolute; left: 0; right: 0; top: 196px; bottom: 0;
  background: var(--base); border-radius: 22px 22px 0 0;
  box-shadow: var(--ld-sheet-shadow); will-change: transform;
}
.ld-grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--ld-grabber); margin: 6px auto 0; }
.ld-cap-bar { height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; position: relative; }
.ld-cap-cancel { height: 44px; display: flex; align-items: center; color: var(--accent); font-size: 17px; }
.ld-cap-title { position: absolute; left: 0; right: 0; text-align: center; font-size: 17px; font-weight: 600; }
.ld-cap-body { padding: 4px 20px 0; display: flex; flex-direction: column; gap: 18px; }
.ld-cap-item { display: flex; gap: 14px; align-items: stretch; }
.ld-cap-thumb {
  position: relative; width: 104px; height: 104px; flex-shrink: 0; border-radius: 18px;
  background: var(--lav-300); display: flex; align-items: center; justify-content: center; color: var(--ink-muted);
}
.ld-cap-edit {
  position: absolute; right: -6px; bottom: -6px; width: 32px; height: 32px; border-radius: 16px;
  border: 2px solid var(--base); background: var(--card); color: var(--ink-muted);
  display: flex; align-items: center; justify-content: center;
}
.ld-cap-fields { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ld-cap-input {
  height: 44px; border-radius: 12px; border: 1px solid var(--ink-line); background: var(--ld-white);
  padding: 0 12px; font-size: 17px; color: var(--ink); width: 100%;
  display: flex; align-items: center; white-space: nowrap; overflow: hidden;
}
.ld-cap-input span { overflow: hidden; min-width: 0; }
.ld-cap-from { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.ld-cap-price { display: flex; flex-direction: column; gap: 2px; }
.ld-cap-amount { width: 200px; height: 64px; line-height: 64px; font-size: 56px; font-weight: 700; color: var(--ink); }
.ld-cap-feel { display: flex; flex-direction: column; gap: 10px; }
.ld-cap-q { font-size: 15px; font-weight: 600; }
.ld-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ld-chip {
  height: 36px; padding: 0 14px; border-radius: 20px; font-size: 15px; font-weight: 500;
  background: var(--card); color: var(--ink); border: 1px solid var(--ink-line); white-space: nowrap;
  display: inline-flex; align-items: center;
}
.ld-chip.is-on { background: var(--ink); color: var(--base); border-color: var(--ink); }
.ld-cap-cool { display: flex; align-items: center; gap: 14px; background: var(--ld-callout); border-radius: 16px; padding: 14px 16px; }
.ld-cap-cool > svg { color: var(--ld-callout-glyph); }
.ld-cap-cool-t { font-size: 17px; font-weight: 600; }
.ld-cap-cool-d { font-size: 13px; color: var(--ink-muted); margin-top: 2px; }
.ld-cap-change { height: 44px; display: flex; align-items: center; color: var(--accent); font-size: 15px; font-weight: 600; padding: 0 4px; }
.ld-cap-cta { left: 20px; right: 20px; bottom: 42px; }
.ld-btn-park { height: 56px; border-radius: 14px; background: var(--accent-mid); color: var(--ld-white); font-size: 17px; }

/* ---------- main-01 · Parked ---------- */
.ld-list-top { top: 59px; left: 20px; right: 20px; height: 44px; display: flex; justify-content: flex-end; align-items: center; }
.ld-list-add { width: 36px; height: 36px; border-radius: 18px; background: var(--ld-add); color: var(--accent); display: flex; align-items: center; justify-content: center; }
.ld-list-head { top: 103px; left: 20px; right: 20px; }
.ld-h1 { margin: 0; font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; text-wrap: balance; }
.ld-list-sub { font-size: 15px; color: var(--ink-soft); margin-top: 4px; }
.ld-cards { top: 196px; left: 16px; right: 16px; display: flex; flex-direction: column; gap: 12px; }
.ld-card { position: relative; background: var(--card); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 16px; }
.ld-card.is-focus { z-index: 2; will-change: transform; }
.ld-card-lift {
  position: absolute; inset: 0; border-radius: inherit; box-shadow: var(--shadow-lift);
  opacity: 0; pointer-events: none;
}
.ld-row { display: flex; gap: 14px; align-items: center; }
.ld-thumb { width: 64px; height: 64px; flex-shrink: 0; border-radius: 16px; display: flex; align-items: center; justify-content: center; color: var(--ink-muted); }
.ld-t-candle { background: var(--ld-thumb-candle); }
.ld-t-sneaker { background: var(--ld-thumb-sneaker); }
.ld-t-lamp { background: var(--ld-thumb-lamp); }
.ld-t-phones { background: var(--lav-300); }
.ld-t-jacket { background: var(--ld-thumb-jacket); }
.ld-col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ld-title { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ld-meta { display: flex; align-items: center; gap: 8px; }
.ld-left { font-size: 15px; color: var(--ink-muted); display: flex; align-items: center; gap: 4px; }
.ld-left .ld-num { white-space: nowrap; }
.ld-tonight { font-size: 13px; font-weight: 600; color: var(--accent); background: var(--ld-chip); padding: 3px 8px; border-radius: 8px; }
.ld-tonight[hidden] { display: none; }
.ld-price { font-size: 22px; font-weight: 700; }
.ld-track { margin-top: 14px; width: 100%; height: 4px; border-radius: 4px; background: var(--timer-track); overflow: hidden; }
.ld-fill { width: 100%; height: 100%; border-radius: 4px; background: var(--timer-fill); }
.ld-tabs {
  left: 0; right: 0; bottom: 0; height: 83px; display: flex;
  background: var(--ld-tabbar); box-shadow: 0 -0.5px 0 var(--ink-line);
}
.ld-tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding-top: 8px; color: var(--ink-faint); }
.ld-tab.is-on { color: var(--accent-mid); }
.ld-tab span { font-size: 10px; font-weight: 600; letter-spacing: 0.1px; }
/* The time-skip: the list softens, the parked item stays in focus */
.ld-scrim { position: absolute; inset: 0; z-index: 1; background: var(--ld-skip-scrim); opacity: 0; will-change: opacity; }
.ld-skip {
  position: absolute; left: 0; right: 0; top: 500px; z-index: 3;
  display: flex; justify-content: center; opacity: 0; will-change: opacity, transform;
}
.ld-skip-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border-radius: var(--radius-pill); box-shadow: var(--shadow-card);
  padding: 10px 18px 10px 14px; font-size: 17px; font-weight: 600; color: var(--ink);
}
.ld-skip-pill svg { color: var(--ld-callout-glyph); }

/* ---------- main-04 · Expiry prompt (night) ---------- */
.ld-night { background: var(--night-ground); color: var(--night-text); }
.ld-night-glow {
  left: -80px; right: -80px; top: 60px; height: 420px; border-radius: 50%;
  background: radial-gradient(circle, var(--ld-night-glow) 0%, var(--ld-night-glow-0) 65%);
}
.ld-night-item { top: 112px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.ld-night-tile { width: 148px; height: 148px; flex-shrink: 0; border-radius: 32px; background: var(--night-tile); display: flex; align-items: center; justify-content: center; color: var(--night-glyph); }
.ld-night-meta { text-align: center; display: flex; flex-direction: column; gap: 6px; }
.ld-night-name { font-size: 17px; color: var(--night-muted); }
.ld-night-price { font-size: 56px; line-height: 1; font-weight: 700; letter-spacing: -0.02em; color: var(--night-text); }
.ld-night-when { font-size: 15px; color: var(--night-muted); }
.ld-night-q { top: 470px; left: 28px; right: 28px; text-align: center; }
.ld-night-q .ld-h1 { font-size: 36px; color: var(--night-text); }
.ld-night-actions { left: 20px; right: 20px; bottom: 44px; display: flex; flex-direction: column; align-items: stretch; }
.ld-btn-go { height: 64px; border-radius: 16px; background: var(--night-answer); color: var(--ink); font-size: 19px; font-weight: 700; }
.ld-btn-keep { height: 64px; border-radius: 16px; border: 2px solid var(--night-outline); color: var(--night-text); font-size: 19px; margin-top: 12px; }
.ld-night-later { height: 44px; display: flex; align-items: center; justify-content: center; padding: 0 12px; align-self: center; color: var(--night-muted); font-size: 15px; font-weight: 500; margin-top: 6px; }

/* ---------- main-07 · Let it go ---------- */
.ld-win-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(70% 45% at 50% 42%, var(--ld-win-sun) 0%, var(--ld-win-sun-0) 70%),
    radial-gradient(90% 60% at 0% 10%, var(--ld-win-clay) 0%, var(--ld-win-clay-0) 65%),
    radial-gradient(90% 60% at 100% 0%, var(--ld-win-lilac) 0%, var(--ld-win-lilac-0) 60%),
    radial-gradient(110% 60% at 50% 110%, var(--ld-win-ember) 0%, var(--ld-win-ember-0) 70%),
    var(--ld-win-ground);
}
.ld-win-blob { top: 118px; left: 0; right: 0; display: flex; justify-content: center; }
.ld-squash { width: 230px; height: 268px; transform-origin: 50% 100%; }
.ld-squash.is-on { animation: ld-squash 2s ease-in-out 1; }
.ld-squash img { display: block; width: 230px; height: 268px; }
.ld-win-total { top: 408px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.ld-win-pill { font-size: 17px; font-weight: 600; color: var(--ink); background: var(--ld-win-pill); padding: 7px 14px; border-radius: 16px; }
.ld-win-sum { font-size: 80px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; color: var(--ink); }
.ld-win-sub { font-size: 17px; color: var(--ink); opacity: 0.8; }
.ld-win-note { top: 630px; left: 36px; right: 36px; text-align: center; font-size: 20px; font-weight: 600; line-height: 1.35; }
.ld-win-cta { left: 20px; right: 20px; bottom: 50px; }
.ld-btn-done { height: 56px; border-radius: 14px; background: var(--ink); color: var(--base); font-size: 17px; }

/* The board's own keyframe (main-07 "squash"), renamed to stay out of the page's namespace */
@keyframes ld-squash {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  40% { transform: translateY(-10px) scale(0.97, 1.04); }
  70% { transform: translateY(0) scale(1.04, 0.96); }
}
.loop-demo.is-paused .ld-squash { animation-play-state: paused; }

/* Scenes: JS sets opacity/transform only */
.ld-cap, .ld-list, .ld-night, .ld-win { will-change: opacity; }

/* ---------- Controls under the phone ---------- */
.ld-controls {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-top: 18px; min-height: 44px;
  font-family: var(--font-text); color: var(--ink-muted);
}
.ld-ctl {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: var(--radius-pill);
  border: 0; padding: 0; margin: 0; cursor: pointer;
  background: var(--card); color: var(--ink-muted); box-shadow: var(--shadow-card);
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity 200ms var(--ease-calm);
}
.ld-ctl:hover { color: var(--ink); }
.ld-ctl:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.ld-ctl[disabled] { opacity: 0.4; cursor: default; }
.ld-ctl svg { display: block; }
.ld-caption { margin: 0; min-width: 0; flex: 1; max-width: 190px; text-align: center; font-size: 15px; line-height: 1.3; color: var(--ink-muted); }
.ld-caption b { display: block; font-weight: 600; color: var(--ink); }
.ld-sr {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  .ld-squash.is-on { animation: none; }
  .ld-ctl { transition: none; }
}
.ld-in { position: absolute; inset: 0; will-change: opacity; }
