html:has(#atelier:target) { scroll-behavior: auto; }

.atelier {
  padding-block: clamp(2.7rem, 7vw, 6rem) clamp(1.5rem, 3.8vw, 3.5rem);
  background: linear-gradient(155deg, var(--lavender), #faeef0 72%, var(--paper));
}
.atelier-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .7rem 2rem;
  margin-bottom: clamp(1rem, 2.9vw, 2rem);
}
.atelier-heading h2 { text-wrap: pretty; }
.atelier-heading p { color: var(--text); font-size: clamp(.95rem, 1.5vw, 1.2rem); }
.atelier[data-open] .atelier-heading p { visibility: hidden; }
.atelier-stage {
  position: relative;
  isolation: isolate;
  aspect-ratio: 324 / 184;
  overflow: hidden;
  border: 1px solid #9d7685;
  background: #191526;
  box-shadow: 0 0 0 4px #dbbdcf, 0 1rem 2rem #4d263824;
  transition: box-shadow .45s ease;
}
.atelier[data-open] .atelier-stage { box-shadow: 0 0 0 4px #cba99c, 0 1rem 2.4rem #64485335; }
.atelier-still, .atelier-frames, .atelier-idle {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
}
.atelier-open-still { opacity: var(--atelier-progress, 0); }
.atelier-idle { opacity: 0; pointer-events: none; }
.atelier[data-idle] .atelier-idle { opacity: 1; }
.atelier-idle-toggle {
  position: absolute;
  inset: auto .7rem .7rem auto;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid #d8c1a878;
  background: #15111cbb;
  color: #fff0d7;
  cursor: pointer;
}
.atelier-idle-toggle::before {
  content: "";
  width: .65rem;
  height: .8rem;
  background: currentColor;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
.atelier-idle-toggle[data-playing]::before {
  background: linear-gradient(90deg, currentColor 0 32%, transparent 32% 68%, currentColor 68%);
  clip-path: none;
}
.atelier-idle-toggle:focus-visible { outline-color: #ffe6a7; outline-offset: 2px; }
.atelier-thread {
  position: absolute;
  z-index: 1;
  inset-block-start: 29%;
  inset-inline-start: 74%;
  translate: calc(-50% + var(--atelier-thread-sway, 0px)) var(--atelier-thread-offset, 0px);
  display: grid;
  place-items: center;
  width: clamp(3.4rem, 8vw, 5.2rem);
  height: clamp(3.4rem, 8vw, 5.2rem);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.atelier-thread::before {
  content: "";
  position: absolute;
  inset-block-end: 50%;
  width: 3px;
  height: var(--atelier-thread-length, 100vh);
  rotate: var(--atelier-thread-angle, 0rad);
  transform-origin: center bottom;
  z-index: -1;
  background: linear-gradient(90deg, #a97129, #ffe5a1 58%, #b88b41);
  box-shadow: 0 0 .55rem #eac6636b;
  pointer-events: none;
}
.atelier-thread span {
  display: block;
  width: clamp(1.1rem, 2.25vw, 1.65rem);
  aspect-ratio: 1;
  background: linear-gradient(135deg, #fff1b1 0 19%, #cc963f 19% 29%, #682b3f 29% 65%, #c29956 65% 83%, #886030 83%);
  border: 1px solid #ffe6a7;
  rotate: 45deg;
  box-shadow: 0 0 0 3px #402438, 0 0 .95rem #f8cf6f91;
}
.atelier-thread:hover span, .atelier-thread:focus-visible span, .atelier-thread:active span {
  box-shadow: 0 0 0 3px #402438, 0 0 1.2rem #ffdf90;
}
.atelier-thread[data-pulling]::before {
  background: linear-gradient(90deg, #c38d3d, #fff1bd 58%, #cf9d49);
  box-shadow: 0 0 .65rem #ffd47194;
}
.atelier-thread:active { cursor: grabbing; }
.atelier-thread:focus-visible { outline: 2px dashed #ffe6a7; outline-offset: 1px; }
.atelier-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .6rem 1.1rem;
  min-height: 4rem;
  padding-top: .85rem;
  font-size: clamp(.92rem, 1.45vw, 1.1rem);
}
.atelier-status { margin-inline-end: auto; color: var(--text); }
.atelier-continue, .atelier-reset {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  padding: .35rem .75rem;
  border: 1px solid #a78291;
  color: var(--ink);
  background: #fff5f2;
  text-decoration: none;
  cursor: pointer;
}
.atelier-continue { color: #fff7ef; background: #52344f; border-color: #52344f; }
.atelier-continue:hover { background: #693f5f; }
.atelier-reset:hover { background: #fffaf8; }

@media (max-width: 560px) {
  .atelier-stage { aspect-ratio: 5 / 4; }
  .atelier-thread { inset-inline-start: 78%; }
}
@media (prefers-reduced-motion: reduce) {
  .atelier-stage { transition: none; }
}
