/* Static dial and movable cards share a center. Only the dial receives pointer input. */
#deck-spread.card-wheel {
  display: block;
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  width: min(100% - 18px, 520px);
  aspect-ratio: 1;
  margin: clamp(12px, 3vw, 25px) auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid #ba887862;
  border-radius: 50%;
  background:
    repeating-conic-gradient(from 0deg, #99634b0d 0deg 1deg, transparent 1deg 30deg),
    radial-gradient(circle closest-side, #fff7e9 0%, #f9e7d9 48%, #f3ddd3 75%, #f8ece2 100%);
  box-shadow: inset 0 0 0 5px #fff9f49e, 0 8px 24px #9b5c4318;
  cursor: pointer;
  touch-action: pan-y pinch-zoom;
}

#deck-spread.card-wheel::before,
#deck-spread.card-wheel::after {
  position: absolute;
  content: "";
  pointer-events: none;
  border-radius: 50%;
}

#deck-spread.card-wheel::before {
  inset: 1px;
  background: repeating-conic-gradient(#9b65575e 0deg .55deg, transparent .55deg 6deg);
  mask: radial-gradient(circle closest-side, transparent 92%, #000 92.3% 95.2%, transparent 95.5%);
}

#deck-spread.card-wheel::after {
  inset: 16%;
  border: 1px solid #b4837450;
  box-shadow: inset 0 0 0 5px #fff7eb4d;
}

#deck-spread.card-wheel .wheel-rotor {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  animation: wheel-turn 55s linear infinite paused;
}

html[data-card-motion="on"] #deck-spread.card-wheel.is-spinning:not(.is-interacting):not(.is-hovering):not(.has-wheel-preview):not(:focus-within) .wheel-rotor {
  animation-play-state: running;
}

@keyframes wheel-turn {
  to { transform: rotate(1turn); }
}

#deck-spread.card-wheel .wheel-rotor > .card-back {
  --wheel-card-width: clamp(44px, 13cqw, 68px);
  --wheel-card-half-height: calc(var(--wheel-card-width) * .75);
  --wheel-radius: min(36cqw, calc(50cqw - 50px));
  --wheel-lift: 0px;
  /* Taper each edge towards the center so all 78 overlap evenly, including the seam. */
  --wheel-edge-outer: calc((var(--wheel-radius) + var(--wheel-card-half-height)) * .0425);
  --wheel-edge-inner: calc((var(--wheel-radius) - var(--wheel-card-half-height)) * .0425);
  position: absolute;
  inset: 50% auto auto 50%;
  width: var(--wheel-card-width);
  height: auto;
  aspect-ratio: 2 / 3;
  gap: 0;
  place-items: center;
  transform: translate(-50%, -50%) rotate(var(--wheel-angle, 0deg))
    translateY(calc(-1 * (var(--wheel-radius) + var(--wheel-lift))));
  transition: transform .2s ease-out;
  pointer-events: none;
}

#deck-spread.card-wheel .wheel-rotor > .card-back:is(.is-previewed, :focus-visible, .is-picked) {
  --wheel-lift: clamp(11px, 3.25cqw, 17px);
  z-index: 1;
}

#deck-spread.card-wheel .card-back img {
  border-color: #ad807a;
  box-shadow: 0 5px 14px #76555263;
}

#deck-spread.card-wheel .card-back:not(.is-previewed, :focus-visible, .is-picked) img {
  clip-path: polygon(
    0 0,
    calc(var(--wheel-edge-outer) * 2) 0,
    calc(var(--wheel-edge-outer) + var(--wheel-edge-inner)) 100%,
    calc(var(--wheel-edge-outer) - var(--wheel-edge-inner)) 100%
  );
  border-radius: 2px;
  transform: translateX(calc(50% - var(--wheel-edge-outer)));
  transition: none;
}

#deck-spread.card-wheel .card-back:not(.is-previewed, :focus-visible, .is-picked)::after {
  display: none;
}

#deck-spread.card-wheel .card-back:is(.is-previewed, :focus-visible, .is-picked) img {
  border-color: #98644d;
  box-shadow: 0 6px 22px #86534175;
  filter: brightness(1.05);
  transform: none;
}

#deck-spread.card-wheel .wheel-rotor > .card-back > span {
  position: absolute;
  inset: auto 3px 4px;
  border-radius: 10px;
  padding: 1px 2px;
  color: #593642;
  background: #fff6e9ee;
  font-size: clamp(.5rem, 2cqw, .68rem);
  letter-spacing: .04em;
  opacity: 0;
}

#deck-spread.card-wheel .wheel-rotor > .card-back:is(.is-previewed, :focus-visible, .is-picked) > span {
  opacity: 1;
}

#deck-spread.card-wheel .wheel-center {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 2;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(2px, 1.2cqw, 5px);
  width: 29%;
  min-width: 60px;
  padding: 6px;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 1px solid #835747;
  border-radius: 50%;
  color: #fff7e9;
  background: radial-gradient(circle at 36% 23%, #9f715b, #754941 86%);
  box-shadow: inset 0 0 0 3px #eed0a48c, 0 5px 15px #97604d42;
  cursor: pointer;
  touch-action: manipulation;
  font: inherit;
  text-align: center;
}

#deck-spread.card-wheel .wheel-center:hover {
  background: radial-gradient(circle at 36% 23%, #ab7a5d, #825247 86%);
}

#deck-spread.card-wheel .wheel-center:focus-visible {
  outline: 3px solid #5b3740;
  outline-offset: 4px;
}

#deck-spread.card-wheel .wheel-center:active {
  transform: translate(-50%, -50%) scale(.97);
}

#daily-reading[aria-busy="true"] .wheel-center { cursor: wait; }

#deck-spread.card-wheel .wheel-center span {
  color: #ffe7bc;
  font-size: clamp(.9rem, 5.1cqw, 1.65rem);
  line-height: 1;
}

#deck-spread.card-wheel .wheel-center strong {
  font-size: clamp(.65rem, 3.4cqw, .98rem);
  line-height: 1.18;
  max-width: 100%;
}

#deck-spread.card-wheel .wheel-center small {
  font: 700 clamp(.48rem, 2.4cqw, .72rem) / 1 Georgia, serif;
  letter-spacing: .13em;
  color: #ffe8cf;
}

[data-daily-window] #deck-spread.card-wheel {
  width: min(100% - 14px, 405px);
  margin-block: 10px 14px;
}

@media (max-width: 430px) {
  [data-daily-window] #deck-spread.card-wheel { width: min(100% - 28px, 405px); }
}

#deck-spread.card-wheel ~ .deck-tools {
  flex-wrap: wrap;
  align-items: center;
}

#deck-spread.card-wheel ~ .deck-tools .deck-arrows {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
  gap: 6px;
}

#deck-spread.card-wheel ~ .deck-tools .wheel-preview-label {
  color: #704a63;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

#deck-spread.card-wheel ~ .deck-tools [data-wheel-confirm]:not([hidden]) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 5rem;
  flex: 0 0 auto;
  padding: 6px 14px;
  border: 1px solid #79504b;
  border-radius: 999px;
  background: #79504b;
  color: #fff6ec;
  font-size: .85rem;
}

#deck-spread.card-wheel ~ .deck-tools [data-wheel-confirm]:not(:disabled):hover {
  background: #623b38;
}

#deck-spread.card-wheel ~ .deck-tools [data-wheel-confirm]:disabled {
  background: #f2e6df;
  border-color: #cfb1a8;
  color: #765956;
  cursor: default;
}

@media (prefers-reduced-motion: reduce) {
  #deck-spread.card-wheel .wheel-rotor { animation: none; }
  #deck-spread.card-wheel .wheel-rotor > .card-back { transition: none; }
}
