/* "See it work": a picture of Rafa that, when pressed, plays his film for a moment and then the product doing
   that job in a small window drawn here in CSS (see-it-work.js). The same pieces serve the home page's wheel
   and accordion (index.html) and the Hours Back variant's chore cards (hours-back/index.html).

   A host is the element that holds a picture and a stage: a figure.film (the stage sits in its .film-pane) or a
   wheel face (.ww-face). It carries data-siw="<demo>", class siw-host, and gets is-leading (the film has the
   stage), is-demo (the product has it) and is-done (the last frame holds) from the script. */

/* ---------- The pill that starts it, and the way back ---------- */

.siw-play {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 15px 9px 12px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--violet);
  font: 600 0.86rem/1 var(--font-body);
  cursor: pointer;
  box-shadow: 0 8px 20px -10px rgba(6, 1, 15, 0.55), 0 0 0 1px rgba(127, 60, 232, 0.14);
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease), opacity 0.25s;
}
.siw-play svg { width: 12px; height: 12px; fill: currentColor; }
.siw-play:hover, .siw-play:focus-visible { background: var(--violet); color: #fff; }
.siw-play:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.siw-host.is-leading .siw-play, .siw-host.is-demo:not(.is-done) .siw-play { opacity: 0; pointer-events: none; }
.siw-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 6;
  display: none;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font: 400 18px/1 var(--font-body);
  cursor: pointer;
}
.siw-host.is-demo .siw-close { display: grid; }
.siw-close:hover, .siw-close:focus-visible { background: var(--violet); color: #fff; }
.siw-host.is-demo .film-toggle { display: none; }
/* Anywhere on the picture starts it; while it plays, the picture is just the stage. */
.siw-host { cursor: pointer; }
.siw-host.is-leading, .siw-host.is-demo:not(.is-done) { cursor: default; }

/* A film the script plays itself, where site.js has none (the wheel's faces). */
.siw-film { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.35s ease; pointer-events: none; }
.siw-host.is-filming .siw-film { opacity: 1; }

/* On the wheel, the pill belongs to the card at the front, and the film sits over the still. */
.ww-face .siw-play { display: none; left: 12px; bottom: 12px; }
.ww-card.is-front .siw-play { display: inline-flex; }
.ww-face .siw-close { top: 10px; right: 10px; }
.ww-face .siw-num-under { z-index: 2; }

/* ---------- The stage ---------- */

/* It covers the picture, which keeps moving faintly underneath: the character stays in view on the right,
   the product window plays on the calmer left. */
.siw-demo { position: absolute; inset: 0; z-index: 4; display: none; }
.siw-host.is-demo .siw-demo { display: block; }
.siw-demo::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(6, 1, 15, 0.74) 0%, rgba(6, 1, 15, 0.6) 50%, rgba(6, 1, 15, 0.2) 100%);
}
.siw-win {
  position: absolute;
  left: 4%;
  top: 44%;
  width: min(60%, 320px);
  transform: translateY(-50%);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(6, 1, 15, 0.08), 0 24px 50px -20px rgba(6, 1, 15, 0.45);
  overflow: hidden;
  font-size: clamp(11px, 1.1vw + 6px, 13px);
  line-height: 1.4;
  color: var(--ink);
  text-align: left;
  animation: siw-win-in 0.5s var(--ease) both;
}
.siw-win-bar { display: flex; align-items: center; gap: 6px; padding: 7px 10px; background: var(--surface-2); border-bottom: 1px solid var(--hairline); font-size: 0.85em; color: var(--ink-500); }
.siw-win-bar i { width: 9px; height: 9px; border-radius: 50%; background: #E3E6EE; }
.siw-win-bar span { margin-left: 6px; }
.siw-win-body { position: relative; min-height: 8.6em; padding: 12px 14px; }
.siw-win p { margin: 0; }
.siw-doc-line + .siw-doc-line { margin-top: 4px; }
.siw-caret { display: inline-block; width: 2px; height: 1.05em; margin-left: 1px; vertical-align: -0.15em; background: var(--violet); animation: siw-blink 1s steps(2) infinite; }
.siw-keys-pop { position: absolute; right: 12px; top: 10px; display: flex; gap: 3px; animation: siw-pop 0.35s 0.2s var(--ease) both; }
.siw-keys-pop kbd { font-size: 0.9em; }
.siw-done-tag {
  position: absolute;
  right: 14px;
  bottom: 14px;
  margin: 0;
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--mint-ink);
  color: #fff;
  font: 700 0.82rem/1 var(--font-body);
  white-space: nowrap;
  animation: siw-pop 0.35s var(--siw-done-at, 2.8s) var(--ease) both;
}

/* Find and Paste: the keys, the overlay rises, a clip is picked, it lands in the text. */
.siw-overlay {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--violet-soft), 0 14px 30px -12px rgba(127, 60, 232, 0.55);
  animation: siw-overlay-in 0.4s 0.7s var(--ease) both, siw-overlay-out 0.3s 2.3s var(--ease) forwards;
}
.siw-overlay-search { padding: 7px 10px; border-bottom: 1px solid var(--hairline); font-family: var(--font-mono); color: var(--ink); min-height: 1.4em; }
.siw-typed { display: inline-block; width: 0; overflow: hidden; white-space: nowrap; vertical-align: bottom; animation: siw-type 0.5s 1.1s steps(4, end) forwards; }
.siw-overlay-list { list-style: none; margin: 0; padding: 4px; }
.siw-overlay-list li { padding: 4px 8px; border-radius: 6px; color: var(--ink-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.siw-overlay-list .siw-hit { animation: siw-hit 0.25s 1.8s both; }
.siw-pasted { display: inline-block; color: var(--violet); animation: siw-pop 0.3s 2.6s var(--ease) both; }
.siw-demo-find .siw-done-tag { --siw-done-at: 3s; }
.siw-demo-paste .siw-overlay { animation: siw-overlay-in 0.4s 0.6s var(--ease) both, siw-overlay-out 0.3s 1.9s var(--ease) forwards; }
.siw-demo-paste .siw-overlay-list .siw-hit { animation: siw-hit 0.25s 1.3s both; }
.siw-demo-paste .siw-pasted { animation: siw-pop 0.3s 2.2s var(--ease) both; }
.siw-demo-paste .siw-done-tag { --siw-done-at: 2.6s; }

/* Scoop: the words sit on a picture; the box is drawn over them and they lift into a clip. */
.siw-slide {
  background:
    radial-gradient(circle at 82% 22%, rgba(255, 232, 180, 0.95) 0 11%, rgba(255, 232, 180, 0) 12%),
    linear-gradient(165deg, #7FB3D5 0%, #B9D6EA 45%, #F2DFC4 100%);
  color: #fff;
  text-shadow: 0 1px 2px rgba(6, 1, 15, 0.35);
  min-height: 10.6em;
}
.siw-slide-title { font-family: var(--font-display); font-weight: 700; font-size: 1.25em; margin-bottom: 6px !important; }
.siw-slide-line { color: #fff; animation: siw-glow 0.35s 1.4s both; }
.siw-scoop-box { position: absolute; left: 0.7em; top: 2.75em; width: 0; height: 0; border: 2px dashed #fff; border-radius: 5px; box-shadow: 0 0 0 1px rgba(127, 60, 232, 0.6), inset 0 0 0 1px rgba(127, 60, 232, 0.6); animation: siw-draw-box 0.6s 0.7s var(--ease) both; }
.siw-clip-card {
  position: absolute;
  right: 10px;
  bottom: 8px;
  width: 50%;
  padding: 6px 10px;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-shadow: none;
  box-shadow: 0 0 0 1px var(--violet-soft), 0 12px 26px -10px rgba(127, 60, 232, 0.55);
  animation: siw-rise 0.4s 1.9s var(--ease) both;
}
.siw-clip-card b { display: block; font-size: 0.78em; letter-spacing: 0.06em; text-transform: uppercase; color: var(--violet); margin-bottom: 2px; }
.siw-clip-card span { display: block; font-size: 0.92em; color: var(--ink); }
.siw-demo-scoop .siw-done-tag { --siw-done-at: 2.6s; }

/* Tidy: the menu picks JSON tidy and the blob becomes readable. */
.siw-json pre { margin: 0; font: 0.92em/1.45 var(--font-mono); color: var(--ink); white-space: pre-wrap; word-break: break-all; }
.siw-json-raw { animation: siw-fade-out 0.25s 1.5s forwards; }
.siw-json-tidy { position: absolute; inset: 12px 14px; animation: siw-fade-in 0.35s 1.6s both; }
.siw-menu {
  position: absolute;
  right: 12px;
  top: 10px;
  padding: 4px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 0 0 1px var(--hairline), 0 14px 30px -12px rgba(6, 1, 15, 0.4);
  animation: siw-pop 0.3s 0.4s var(--ease) both, siw-fade-out 0.25s 1.4s forwards;
}
.siw-menu span { display: block; padding: 4px 10px; border-radius: 5px; font-size: 0.92em; color: var(--ink); }
.siw-menu .is-pick { animation: siw-pick 0.2s 0.9s both; }
.siw-demo-tidy .siw-done-tag { --siw-done-at: 2.3s; }

/* Clean: the workflow runs and the tracking falls off the link. */
.siw-url { font-family: var(--font-mono); font-size: 0.95em; color: var(--ink); word-break: break-all; animation: siw-url-glow 0.4s 1.9s both; }
.siw-junk { display: inline; color: var(--ink-400); animation: siw-strike 0.3s 1s both, siw-shrink 0.5s 1.3s var(--ease) forwards; }
.siw-flow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px !important;
  padding: 5px 10px 5px 7px;
  border-radius: 999px;
  background: var(--mint-wash);
  color: var(--mint-ink);
  font-weight: 600;
  font-size: 0.9em;
  animation: siw-pop 0.35s 0.4s var(--ease) both;
}
.siw-flow i { width: 12px; height: 12px; border-radius: 50%; border: 2.5px solid var(--mint-ink); border-right-color: transparent; animation: siw-spin 0.9s linear infinite; }
.siw-demo-clean .siw-done-tag { --siw-done-at: 2.4s; }

/* Convert: a big video, a size to hit, and the small one that comes out. */
.siw-file { display: flex; align-items: center; gap: 10px; }
.siw-file i { flex: none; width: 2.6em; height: 2em; border-radius: 5px; background: linear-gradient(135deg, #5B4BD6, #9DA8E0); }
.siw-file b { display: block; font-weight: 600; }
.siw-file small { display: block; color: var(--ink-500); font-size: 0.9em; }
.siw-file-out { position: absolute; left: 14px; right: 14px; top: 12px; background: #fff; animation: siw-fade-in 0.35s 2s both; }
.siw-file-out i { background: linear-gradient(135deg, var(--mint-ink), #6FCFA1); }
.siw-file-in { animation: siw-fade-out 0.3s 1.9s forwards; }
.siw-limit { position: absolute; right: 12px; top: 10px; padding: 4px 9px; border-radius: 999px; background: var(--violet-wash); color: var(--violet); font-size: 0.85em; font-weight: 600; animation: siw-pop 0.35s 0.4s var(--ease) both; }
.siw-bar { position: absolute; left: 14px; right: 14px; bottom: 14px; height: 6px; border-radius: 6px; background: var(--hairline-2); overflow: hidden; }
.siw-bar i { display: block; height: 100%; width: 0; border-radius: 6px; background: var(--violet); animation: siw-fill 1s 0.9s var(--ease) forwards; }
.siw-demo-convert .siw-done-tag { --siw-done-at: 2.5s; }

/* Palette: the loupe crosses a picture, stops on the violet, and the swatch is kept. */
.siw-swatchland {
  background:
    radial-gradient(circle at 72% 62%, #7F3CE8 0 14%, rgba(127, 60, 232, 0) 15%),
    radial-gradient(circle at 20% 30%, rgba(255, 232, 180, 0.9) 0 10%, rgba(255, 232, 180, 0) 11%),
    linear-gradient(165deg, #8AB6D6 0%, #DDECF5 50%, #F2DFC4 100%);
  min-height: 9.4em;
}
.siw-loupe {
  position: absolute;
  left: 18%;
  top: 28%;
  width: 2.4em;
  height: 2.4em;
  margin: -1.2em 0 0 -1.2em;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(6, 1, 15, 0.25), 0 8px 18px -6px rgba(6, 1, 15, 0.5);
  background: rgba(255, 255, 255, 0.15);
  animation: siw-loupe 1s 0.3s var(--ease) both;
}
.siw-loupe::before, .siw-loupe::after { content: ""; position: absolute; background: #fff; }
.siw-loupe::before { left: 50%; top: 20%; bottom: 20%; width: 1px; }
.siw-loupe::after { top: 50%; left: 20%; right: 20%; height: 1px; }
.siw-hex { position: absolute; left: 60%; top: 24%; padding: 4px 8px; border-radius: 6px; background: #fff; color: var(--ink); font: 600 0.9em/1 var(--font-mono); box-shadow: 0 6px 14px -6px rgba(6, 1, 15, 0.5); animation: siw-pop 0.3s 1.5s var(--ease) both; }
.siw-hex::before { content: ""; display: inline-block; width: 0.9em; height: 0.9em; margin-right: 6px; border-radius: 3px; background: var(--violet); vertical-align: -2px; }
.siw-swatches { position: absolute; right: 10px; bottom: 8px; display: flex; gap: 6px; padding: 6px; border-radius: 8px; background: #fff; box-shadow: 0 0 0 1px var(--violet-soft), 0 12px 26px -10px rgba(127, 60, 232, 0.55); animation: siw-rise 0.4s 1.9s var(--ease) both; }
.siw-swatches i { width: 1.5em; height: 1.5em; border-radius: 5px; }
.siw-swatches i:nth-child(1) { background: #8AB6D6; }
.siw-swatches i:nth-child(2) { background: #F2DFC4; }
.siw-swatches i:nth-child(3) { background: var(--violet); box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--violet); }
.siw-demo-palette .siw-done-tag { --siw-done-at: 2.4s; }

@keyframes siw-win-in { from { opacity: 0; transform: translateY(-46%) scale(0.96); } to { opacity: 1; transform: translateY(-50%) scale(1); } }
@keyframes siw-pop { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes siw-blink { 50% { opacity: 0; } }
@keyframes siw-overlay-in { from { opacity: 0; transform: translateY(110%); } to { opacity: 1; transform: none; } }
@keyframes siw-overlay-out { to { opacity: 0; transform: translateY(110%); } }
@keyframes siw-type { to { width: 4ch; } }
@keyframes siw-hit { to { background: var(--violet-wash); color: var(--violet); box-shadow: inset 0 0 0 1.5px var(--violet); } }
@keyframes siw-draw-box { from { width: 0; height: 0; opacity: 0; } 10% { opacity: 1; } to { width: 15em; height: 3.5em; opacity: 1; } }
@keyframes siw-glow { to { color: var(--violet-soft); } }
@keyframes siw-rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes siw-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes siw-fade-out { to { opacity: 0; } }
@keyframes siw-pick { to { background: var(--violet); color: #fff; } }
@keyframes siw-strike { to { text-decoration: line-through; text-decoration-color: var(--danger); text-decoration-thickness: 2px; } }
@keyframes siw-shrink { to { opacity: 0; font-size: 0; letter-spacing: -1em; } }
@keyframes siw-url-glow { to { color: var(--violet); } }
@keyframes siw-spin { to { transform: rotate(360deg); } }
@keyframes siw-fill { to { width: 100%; } }
@keyframes siw-loupe { to { left: 72%; top: 62%; } }

@media (max-width: 760px) {
  .siw-play { left: 10px; bottom: 10px; padding: 8px 12px 8px 10px; font-size: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  /* The demos show their last frame: the job done. */
  .siw-demo, .siw-demo * { animation-duration: 0.001s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; }
  .siw-caret { animation: none; }
  .siw-play { transition: none; }
}
