/* Fixed flower theme orb — blooms into a semi-radial theme picker */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.theme-orb {
  --orb-size: 3rem;
  --bloom-r: 5.6rem;
  position: fixed;
  left: max(1rem, env(safe-area-inset-left, 0px));
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  z-index: 120;
  width: var(--orb-size);
  height: var(--orb-size);
  pointer-events: none;
}

.theme-orb > * {
  pointer-events: auto;
}

.theme-orb-hub {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: var(--orb-size);
  height: var(--orb-size);
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--spot-gold, #e8c04a) 45%, var(--border-subtle, #2a2824));
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--spot-gold, #e8c04a) 28%, transparent), transparent 55%),
    var(--surface, #161412);
  color: var(--spot-gold, #e8c04a);
  box-shadow:
    0 8px 28px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition:
    transform 0.28s cubic-bezier(0.23, 1, 0.32, 1),
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.theme-orb-hub:hover,
.theme-orb-hub:focus-visible {
  border-color: var(--spot-gold, #e8c04a);
  outline: none;
  box-shadow:
    0 10px 32px rgba(0, 0, 0, 0.4),
    0 0 0 3px color-mix(in srgb, var(--spot-gold, #e8c04a) 22%, transparent);
}

.theme-orb.is-open .theme-orb-hub {
  transform: scale(0.94) rotate(45deg);
}

.theme-orb-hub-ring {
  position: absolute;
  inset: 0.35rem;
  border-radius: 50%;
  border: 1.5px dashed color-mix(in srgb, var(--spot-gold, #e8c04a) 55%, transparent);
  opacity: 0.85;
  animation: theme-orb-spin 18s linear infinite;
}

.theme-orb-hub-core {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #f0d878, var(--spot-gold, #e8c04a) 55%, #9a7420);
  box-shadow: 0 0 12px color-mix(in srgb, var(--spot-gold, #e8c04a) 55%, transparent);
}

.theme-orb-bloom {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  z-index: 1;
}

.theme-orb-petal {
  --petal-angle: 0deg;
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  width: 2.65rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-secondary, #9c9890);
  cursor: pointer;
  /* The trailing counter-rotation is what keeps each petal upright. Rotating to
     place it and then leaving it rotated meant the flex column ran along the
     rotated axis, so at ~90deg the label sat *beside* its chip and overlapped
     the neighbour. Rotate to position, then rotate back. */
  transform:
    translate(-50%, -50%)
    rotate(var(--petal-angle))
    translateY(0)
    rotate(calc(var(--petal-angle) * -1))
    scale(0.35);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.42s cubic-bezier(0.23, 1, 0.32, 1),
    opacity 0.28s ease;
  transition-delay: 0s;
}

.theme-orb.is-open .theme-orb-petal {
  opacity: 1;
  pointer-events: auto;
  transform:
    translate(-50%, -50%)
    rotate(var(--petal-angle))
    translateY(calc(var(--bloom-r) * -1))
    rotate(calc(var(--petal-angle) * -1))
    scale(1);
}

.theme-orb.is-open .theme-orb-petal:nth-child(1) { transition-delay: 0.02s; }
.theme-orb.is-open .theme-orb-petal:nth-child(2) { transition-delay: 0.07s; }
.theme-orb.is-open .theme-orb-petal:nth-child(3) { transition-delay: 0.12s; }

.theme-orb-petal-chip {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  border: 2px solid var(--border-subtle, #2a2824);
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.theme-orb-petal:hover .theme-orb-petal-chip,
.theme-orb-petal:focus-visible .theme-orb-petal-chip {
  transform: scale(1.08);
}

.theme-orb-petal:focus-visible {
  outline: none;
}

.theme-orb-petal:focus-visible .theme-orb-petal-chip {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--spot-gold, #e8c04a) 35%, transparent);
}

.theme-orb-petal.is-active .theme-orb-petal-chip {
  border-color: var(--spot-gold, #e8c04a);
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--spot-gold, #e8c04a) 28%, transparent),
    0 8px 18px rgba(0, 0, 0, 0.4);
}

.theme-orb-petal-label {
  font-family: var(--sans, system-ui, sans-serif);
  font-size: 0.65rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary, #9c9890);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.65);
  white-space: nowrap;
}

.theme-orb-petal.is-active .theme-orb-petal-label {
  color: var(--spot-gold, #e8c04a);
}

.theme-orb-petal--warm .theme-orb-petal-chip {
  background: linear-gradient(145deg, #0a0a09 42%, #e8c04a 42%, #e8c04a 58%, #5eb8a8 58%);
}

.theme-orb-petal--light .theme-orb-petal-chip {
  background: linear-gradient(145deg, #f6f5f2 42%, #b8860b 42%, #b8860b 58%, #2a7a68 58%);
}

.theme-orb-petal--pink .theme-orb-petal-chip {
  background: linear-gradient(
    145deg,
    #0c080a 42%,
    #ff9ec4 42%,
    #ff9ec4 52%,
    #e8b050 52%,
    #e8b050 62%,
    #88b0e0 62%
  );
}

@keyframes theme-orb-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .theme-orb-hub,
  .theme-orb-petal,
  .theme-orb-petal-chip,
  .theme-orb-hub-ring {
    transition: none;
    animation: none;
  }
}
