/*
 * First-step spinner (tools.ts): the plate, the wheel and the two minutes, over tools.css. The wheel wears the orange
 * and the sky's stars on a dark rim, its pointer a flapper the pegs push aside as they pass; what it lands on rises
 * into the amber glow of the thing the magpie holds. Under Reduce Motion nothing spins, pulses or pops.
 */

.spin {
  container: spin / inline-size;
}

.spin .tool-steps li.just-done::before {
  animation: spin-tick-pop 520ms var(--spring);
}

.spin-layout {
  display: grid;
  grid-template-areas:
    "plate"
    "side"
    "done";
  gap: 30px;
}

@container spin (min-width: 700px) {
  .spin-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 360px);
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "plate side"
      "done side";
    gap: 26px clamp(32px, 6cqi, 56px);
    align-items: start;
  }
}

/* The plate: a field to add to, and a chip for each thing on the wheel, its dot the colour of its slice. */

.spin-plate {
  grid-area: plate;
  min-width: 0;
}

.spin-label {
  display: block;
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.spin-field {
  position: relative;
}

.spin-field .tool-field {
  padding-right: 92px;
}

/* Inside the field, as the app's composer holds its send button. Two classes deep, to stand over site.css's
   waitlist rule for every submit button (a full-width block). */
.spin-field .spin-add-button {
  position: absolute;
  top: 6px;
  right: 6px;
  bottom: 6px;
  display: inline-flex;
  width: auto;
  min-height: 0;
  margin: 0;
  padding: 0 20px;
  font-size: 1rem;
  font-weight: 800;
  border-radius: 11px;
  box-shadow: 0 8px 18px -10px rgb(255 138 51 / 0.85);
}

@media (hover: hover) {
  .spin-field .spin-add-button:hover {
    transform: none;
  }
}

.spin-note {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
  margin: 12px 2px 0;
  color: var(--ink-3);
  font-size: 0.9375rem;
  line-height: 1.45;
}

.spin-example,
.spin-clear {
  padding: 2px 0;
  color: var(--accent-text);
  font: inherit;
  font-weight: 750;
  background: none;
  border: 0;
  border-bottom: 1px dashed rgb(255 176 113 / 0.55);
  cursor: pointer;
}

@media (hover: hover) {
  .spin-example:hover,
  .spin-clear:hover {
    border-bottom-style: solid;
  }
}

.spin-example:disabled {
  cursor: default;
  opacity: 0.5;
}

.spin-tally {
  justify-content: space-between;
}

.spin-tally .tool-count {
  color: var(--ink);
  font-weight: 800;
}

.spin-clear {
  color: var(--ink-3);
  font-weight: 650;
  border-bottom-color: rgb(201 176 160 / 0.45);
}

.spin-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.spin-chips:empty {
  display: none;
}

/* Before the first thing is added, on a wide stage: where the chips will go, drawn faintly. */
.spin-ghost {
  display: none;
}

@container spin (min-width: 700px) {
  .spin-ghost {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin: 22px 0 0;
    padding: 18px;
    border: 1.5px dashed rgb(255 226 200 / 0.14);
    border-radius: 22px;
  }
}

.spin-ghost-chip {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  height: 40px;
  padding: 0 16px 0 14px;
  border: 1px solid rgb(255 226 200 / 0.09);
  border-radius: 999px;
}

.spin-ghost-chip i {
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.45;
}

.spin-ghost-chip:nth-child(2) i {
  background: var(--star-2);
}

.spin-ghost-chip:nth-child(3) i {
  background: var(--star-3);
}

.spin-ghost-chip b {
  width: 86px;
  height: 8px;
  background: rgb(255 236 220 / 0.08);
  border-radius: 4px;
}

.spin-ghost-chip:nth-child(2) b {
  width: 120px;
}

.spin-ghost-chip:nth-child(3) b {
  width: 64px;
}

.spin-ghost-line {
  flex-basis: 100%;
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 0.9375rem;
}

.spin-chip {
  --chip: var(--accent);
  display: inline-flex;
  gap: 9px;
  align-items: center;
  max-width: 100%;
  min-height: 42px;
  padding: 4px 4px 4px 14px;
  color: var(--ink);
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.25;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition:
    border-color 300ms ease,
    box-shadow 300ms ease,
    opacity 300ms ease;
}

.spin-chip-dot {
  flex: none;
  width: 10px;
  height: 10px;
  background: var(--chip);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--chip);
  transition:
    background-color 320ms ease,
    box-shadow 320ms ease;
}

.spin-chip-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spin-chip-remove {
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--ink-3);
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition:
    color 160ms ease,
    background-color 160ms ease;
  -webkit-tap-highlight-color: transparent;
}

.spin-chip-remove::before,
.spin-chip-remove::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 2px;
  margin: -1px 0 0 -6px;
  background: currentColor;
  border-radius: 2px;
  transform: rotate(45deg);
  content: "";
}

.spin-chip-remove::after {
  transform: rotate(-45deg);
}

@media (hover: hover) {
  .spin-chip-remove:hover {
    color: var(--ink);
    background: var(--well-hover);
  }
}

.spin-chip-remove:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 1px;
}

.spin-chip-remove:disabled {
  cursor: default;
  opacity: 0.35;
}

.spin-chip.is-new {
  animation: spin-chip-in 540ms var(--spring) both;
}

.spin-chip.is-leaving {
  pointer-events: none;
  animation: spin-chip-out 260ms ease-in both;
}

.spin-chip.is-chosen {
  border-color: var(--lit);
  box-shadow:
    0 0 0 1px var(--lit),
    0 0 24px -6px var(--lit-glow);
}

.spin-chips.has-chosen .spin-chip:not(.is-chosen) {
  opacity: 0.6;
}

@keyframes spin-chip-in {
  from {
    opacity: 0;
    transform: scale(0.4);
  }

  60% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes spin-chip-out {
  to {
    opacity: 0;
    transform: scale(0.6);
  }
}

/* The wheel: a rim of dark glass, the slices turning inside it, a glowing hub and the pointer on top. */

.spin-side {
  display: flex;
  flex-direction: column;
  grid-area: side;
  align-items: center;
  min-width: 0;
}

.spin-wheel {
  position: relative;
  width: min(100%, 360px);
  margin-top: 20px;
  aspect-ratio: 1;
  -webkit-tap-highlight-color: transparent;
}

.spin-wheel.is-ready {
  cursor: pointer;
}

.spin-glow {
  position: absolute;
  inset: -9%;
  background: radial-gradient(
    closest-side,
    rgb(255 138 51 / 0.24),
    rgb(255 138 51 / 0.08) 64%,
    rgb(255 138 51 / 0)
  );
  border-radius: 50%;
  pointer-events: none;
  transition: opacity 400ms ease;
}

.spin-wheel.is-ready .spin-glow {
  animation: spin-breathe 3.4s ease-in-out infinite;
}

.spin-wheel.is-spinning .spin-glow {
  background: radial-gradient(
    closest-side,
    rgb(255 138 51 / 0.34),
    rgb(255 138 51 / 0.12) 64%,
    rgb(255 138 51 / 0)
  );
}

@keyframes spin-breathe {
  50% {
    opacity: 0.55;
    transform: scale(0.97);
  }
}

.spin-base,
.spin-face,
.spin-rotor,
.spin-rotor svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.spin-base {
  filter: drop-shadow(0 18px 30px rgb(0 0 0 / 0.5));
}

.spin-face {
  pointer-events: none;
}

.spin-rotor svg {
  overflow: visible;
}

.spin-rim {
  stroke: rgb(255 226 200 / 0.22);
  stroke-width: 1;
}

.spin-well {
  fill: #1c1315;
  stroke: rgb(0 0 0 / 0.4);
  stroke-width: 2;
}

.spin-well-ring {
  fill: none;
  stroke: rgb(255 226 200 / 0.16);
  stroke-width: 1;
  stroke-dasharray: 2 5;
  transition: opacity 300ms ease;
}

.spin-wheel.has-slices .spin-well-ring {
  opacity: 0;
}

.spin-slice {
  stroke: rgb(30 20 22 / 0.55);
  stroke-width: 0.8;
  stroke-linejoin: round;
  transition:
    fill 320ms ease,
    opacity 360ms ease;
}

.spin-slice.is-dim {
  opacity: 0.3;
}

.spin-slice.is-chosen {
  stroke: #fff3ea;
  stroke-width: 1.6;
}

.spin-flash {
  fill: #fff6ee;
  pointer-events: none;
}

.spin-labels text {
  fill: #2b1e1a;
  font-family: var(--font);
  font-weight: 800;
}

.spin-label {
  transition: opacity 360ms ease;
}

.spin-label.is-dim {
  opacity: 0.35;
}

.spin-probe {
  visibility: hidden;
}

.spin-peg {
  fill: #fff3ea;
  stroke: rgb(30 20 22 / 0.6);
  stroke-width: 0.8;
}

.spin-pegs.is-ghost .spin-peg {
  fill: rgb(255 243 234 / 0.22);
  stroke: none;
}

.spin-gloss {
  pointer-events: none;
}

.spin-hub {
  fill: #2b1e1a;
  stroke: rgb(255 226 200 / 0.3);
  stroke-width: 1.5;
}

.spin-orb {
  filter: drop-shadow(0 0 5px rgb(255 138 51 / 0.7));
  transition: filter 400ms ease;
}

.spin-wheel.is-spinning .spin-orb {
  filter: drop-shadow(0 0 9px rgb(255 176 113 / 0.95));
}

.spin-star {
  fill: #fff3ea;
}

/* The pointer: pinned at the head, its tip down among the pegs. */
.spin-pointer {
  position: absolute;
  top: -7.4%;
  left: 44.5%;
  width: 11%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 3px 4px rgb(0 0 0 / 0.45));
  transform-origin: 50% 33.9%;
  pointer-events: none;
}

/* Under the wheel: the capsule that spins it, then the card it lands on. */

.spin-deck {
  display: grid;
  justify-items: center;
  width: 100%;
  margin-top: 28px;
}

.spin-go {
  display: grid;
  gap: 12px;
  justify-items: center;
}

/* The big capsule: two classes deep, to stand over tools.css's .tool-page .tool-button. */
.spin .spin-button {
  position: relative;
  min-width: 212px;
  min-height: 62px;
  padding: 16px 48px;
  overflow: hidden;
  font-size: 1.3125rem;
  letter-spacing: 0.01em;
  background: linear-gradient(180deg, #ff9a4d, var(--accent));
  box-shadow:
    0 1px 0 rgb(255 230 210 / 0.5) inset,
    0 16px 36px -14px rgb(255 138 51 / 0.85);
  isolation: isolate;
}

.spin-button::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgb(255 245 235 / 0.55) 50%,
    transparent 70%
  );
  transform: translateX(-120%);
  content: "";
}

.spin-button.is-ready {
  animation: spin-ready 1.8s ease-in-out infinite;
}

.spin-button.is-ready::after {
  animation: spin-glint 5.5s ease-in-out 1.2s infinite;
}

.spin .spin-button[aria-disabled="true"] {
  cursor: default;
  opacity: 0.75;
  transform: none;
}

@keyframes spin-ready {
  50% {
    box-shadow:
      0 1px 0 rgb(255 230 210 / 0.5) inset,
      0 0 0 7px rgb(255 138 51 / 0.16),
      0 18px 40px -12px rgb(255 138 51 / 0.95);
  }
}

@keyframes spin-glint {
  0%,
  70% {
    transform: translateX(-120%);
  }

  100% {
    transform: translateX(120%);
  }
}

.spin-hint {
  margin: 0;
  color: var(--ink-3);
  font-size: 0.9375rem;
  text-align: center;
}

.spin-card {
  position: relative;
  box-sizing: border-box;
  width: 100%;
  padding: 26px 22px 22px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgb(255 154 77 / 0.2), rgb(255 154 77 / 0) 62%),
    linear-gradient(180deg, rgb(72 49 38 / 0.95), rgb(46 32 27 / 0.96));
  border-radius: 24px;
}

.spin-card.is-fresh > * {
  animation: spin-swap 420ms var(--ease-out) both;
}

@keyframes spin-swap {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* The thing the card is about, as its chip on the list wears it. */
.spin-tag {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  max-width: 100%;
  margin: 0 0 12px;
  padding: 5px 14px 5px 12px;
  color: var(--ink-2);
  font-size: 0.9375rem;
  font-weight: 700;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.spin-tag-dot {
  flex: none;
  width: 9px;
  height: 9px;
  background: var(--chip, var(--accent));
  border-radius: 50%;
  box-shadow: 0 0 10px var(--chip, var(--accent));
}

.spin-tag-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spin-kicker {
  margin: 0;
  color: var(--accent-text);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.spin-title {
  margin: 8px 0 0;
  color: var(--ink);
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

/* A line drawn through what is done, line by line when it wraps. */
.spin-strike {
  background: linear-gradient(var(--accent-text), var(--accent-text)) no-repeat 0 58% / 0% 2.5px;
  transition: background-size 480ms var(--ease-out);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.spin-strike.is-struck {
  background-size: 100% 2.5px;
}

.spin-line {
  margin: 8px 0 0;
  color: var(--ink-2);
  font-size: 1rem;
  line-height: 1.45;
}

.spin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

.spin-plus {
  padding: 2px 8px;
  color: var(--accent-text);
  font-size: 0.8125rem;
  font-weight: 800;
  background: var(--accent-tint);
  border-radius: 999px;
}

.spin-foot {
  margin: 14px 0 0;
  color: var(--ink-3);
  font-size: 0.875rem;
}

/* The orb of the app's all-clear, ticked: shown when time is up and when the plate is clear. */
.spin-badge {
  position: relative;
  display: block;
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  background: radial-gradient(circle at 40% 35%, #ffd9b0, #ff8a33 70%);
  border-radius: 50%;
  box-shadow:
    0 0 40px 8px rgb(255 138 51 / 0.45),
    0 0 90px 20px rgb(255 138 51 / 0.18);
  animation: spin-orb 4s ease-in-out infinite;
}

.spin-badge::after,
.spin-done-tick::after {
  position: absolute;
  inset: 22%;
  background: var(--on-accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4.5 10.6l3.6 3.6 7.4-8.2' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4.5 10.6l3.6 3.6 7.4-8.2' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / contain no-repeat;
  content: "";
}

@keyframes spin-orb {
  50% {
    box-shadow:
      0 0 54px 12px rgb(255 138 51 / 0.55),
      0 0 110px 28px rgb(255 138 51 / 0.22);
    transform: scale(1.08);
  }
}

/* The two minutes: the ring empties as the time runs, and breathes while it does. */
.spin-clock {
  position: relative;
  display: grid;
  place-items: center;
  width: 156px;
  height: 156px;
  margin: 14px auto 6px;
}

.spin-clock::before {
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  box-shadow: 0 0 34px 2px rgb(255 138 51 / 0.22);
  animation: spin-calm 4.2s ease-in-out infinite;
  content: "";
}

.spin-clock .tool-ring {
  width: 156px;
  height: 156px;
}

/* The ring glows by a wider, fainter stroke beneath it rather than tools.css's drop-shadow, which Chrome draws as a
   faint square on the stage's frosted glass. */
.spin-clock .tool-ring .tool-ring-fill {
  filter: none;
}

.spin-clock .tool-ring .spin-halo {
  stroke-width: 16;
  opacity: 0.22;
}

.spin-time {
  position: absolute;
  color: var(--ink);
  font-size: 2.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

@keyframes spin-calm {
  50% {
    box-shadow: 0 0 52px 10px rgb(255 138 51 / 0.36);
    transform: scale(1.04);
  }
}

/* What is done: struck through, ticked, and counted. */

.spin-done {
  grid-area: done;
  min-width: 0;
}

.spin-done-head {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 800;
}

.spin-done-badge {
  padding: 3px 12px;
  color: var(--on-accent);
  font-size: 0.875rem;
  font-weight: 800;
  background: var(--lit);
  border-radius: 999px;
  box-shadow: 0 0 18px -4px var(--lit-glow);
}

.spin-done-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.spin-done-item {
  display: flex;
  gap: 11px;
  align-items: center;
  color: var(--ink-3);
  font-weight: 650;
  line-height: 1.35;
}

.spin-done-item.is-new {
  animation: spin-done-in 520ms var(--spring) both;
}

.spin-done-tick {
  position: relative;
  flex: none;
  width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 14px rgb(255 138 51 / 0.5);
}

.spin-done-item.is-new .spin-done-tick {
  animation: spin-tick-pop 560ms var(--spring) 160ms both;
}

@keyframes spin-done-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@keyframes spin-tick-pop {
  0% {
    transform: scale(0.3);
  }

  45% {
    transform: scale(1.3);
  }

  100% {
    transform: scale(1);
  }
}

.spin-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
}

.spin-noscript {
  margin: 22px 0 0;
  padding: 14px 18px;
  color: var(--ink-2);
  text-align: center;
  background: var(--well);
  border: 1px solid var(--line);
  border-radius: 16px;
}

/* A phone: the card's buttons share the width, easy to hit with a thumb. */
@container spin (max-width: 460px) {
  .spin-card {
    padding: 24px 16px 18px;
  }

  .spin-title {
    font-size: 1.5rem;
  }

  .spin-actions .tool-button {
    flex: 1 1 auto;
  }
}

@media print {
  .spin-side,
  .spin-note,
  .spin-chip-remove,
  .spin-noscript {
    display: none !important;
  }

  .spin-chip,
  .spin-done-item,
  .spin-done-head,
  .spin-label {
    color: #1e1418;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spin .tool-steps li.just-done::before,
  .spin-chip.is-new,
  .spin-chip.is-leaving,
  .spin-wheel.is-ready .spin-glow,
  .spin-button.is-ready,
  .spin-button.is-ready::after,
  .spin-card.is-fresh > *,
  .spin-badge,
  .spin-clock::before,
  .spin-done-item.is-new,
  .spin-done-item.is-new .spin-done-tick {
    animation: none;
  }

  .spin-chip,
  .spin-chip-dot,
  .spin-slice,
  .spin-label,
  .spin-orb,
  .spin-strike {
    transition: none;
  }
}
