/* ============================================================
   Decision Wheel — page-specific styles
   Built on the shared CSS custom properties from css/style.css
   (--accent, --bg-card, --text-primary, etc.) for dark/light parity.
   ============================================================ */

* {
  box-sizing: border-box;
}

/* An author `display:` declaration beats the UA `[hidden]{display:none}` rule
   (author origin wins over UA regardless of specificity), so elements styled
   with display:flex/grid and toggled via the `hidden` attribute would never
   actually hide. This restores `hidden` as the authority across the page. */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-main);
  color: var(--text-secondary);
  font-family: "Poppins", sans-serif;
  font-weight: 300;
  min-height: 100vh;
}

.wheel-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ----- header ----- */
.wheel-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--scrollbar-thumb);
}

.wheel-header__title {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: left;
}

.wheel-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wheel-icon-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--scrollbar-thumb);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.wheel-icon-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.wheel-theme-icon-dark { display: none; }
[data-theme="light"] .wheel-theme-icon-light { display: none; }
[data-theme="light"] .wheel-theme-icon-dark { display: inline-block; }

.wheel-mute-icon-off { display: none; }
#muteToggle[aria-pressed="true"] .wheel-mute-icon-on { display: none; }
#muteToggle[aria-pressed="true"] .wheel-mute-icon-off { display: inline-block; }
#muteToggle[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

/* ----- main / layout ----- */
.wheel-main {
  flex: 1;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

/* ----- shared form controls ----- */
.wheel-field-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-subtle);
  margin: 18px 0 8px;
}

.wheel-optional {
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
}

.wheel-input,
.wheel-textarea {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--scrollbar-thumb);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  padding: 11px 14px;
  transition: border-color 0.2s ease;
}

.wheel-input:focus,
.wheel-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.wheel-textarea {
  resize: vertical;
  line-height: 1.7;
}

.wheel-error {
  color: #ff6b6b;
  font-size: 12px;
  margin: 10px 0 0;
}

.wheel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 6px;
  padding: 11px 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s ease;
}

.wheel-btn:active {
  transform: scale(0.97);
}

.wheel-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.wheel-btn--primary {
  background: var(--accent);
  color: var(--text-on-accent);
}

.wheel-btn--primary:hover:not(:disabled) {
  opacity: 0.9;
}

.wheel-btn--ghost {
  background: transparent;
  border: 1px solid var(--scrollbar-thumb);
  color: var(--text-secondary);
}

.wheel-btn--ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.wheel-btn--block {
  width: 100%;
  margin-top: 24px;
  padding: 14px 20px;
}

/* ----- setup view ----- */
.wheel-setup {
  max-width: 560px;
  margin: 0 auto;
}

.wheel-setup__lede {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.8;
  text-align: center;
  margin-bottom: 8px;
}

/* ----- wheel view ----- */
.wheel-view__header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 24px;
}

.wheel-view__title {
  text-align: center;
  color: var(--text-primary);
  font-size: 20px;
  margin: 0;
  word-break: break-word;
}

.wheel-title-edit {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 13px;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s ease;
}

.wheel-title-edit:hover {
  color: var(--accent);
}

.wheel-title-edit-form {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  max-width: 480px;
  margin: 0 auto 24px;
}

.wheel-title-edit-form .wheel-input {
  flex: 1;
  min-width: 180px;
}

#titleError {
  text-align: center;
  margin: -16px 0 20px;
}

.wheel-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.9fr);
  gap: 32px;
  align-items: start;
}

/* ----- wheel stage ----- */
.wheel-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wheel-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1 / 1;
}

#wheelCanvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 8px 28px var(--shadow-color);
}

.wheel-pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 22px solid var(--accent);
  z-index: 3;
  filter: drop-shadow(0 2px 3px var(--shadow-color));
}

.wheel-spin-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 4px solid var(--bg-main);
  background: #000000;
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--shadow-color);
  z-index: 4;
  transition: transform 0.15s ease;
}

.wheel-spin-hub:hover:not(:disabled) {
  transform: translate(-50%, -50%) scale(1.05);
}

.wheel-spin-hub:active:not(:disabled) {
  transform: translate(-50%, -50%) scale(0.96);
}

.wheel-spin-hub:disabled {
  cursor: not-allowed;
  opacity: 0.75;
}

.wheel-winner-banner {
  min-height: 28px;
  margin-top: 20px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
}

.wheel-winner-banner:empty {
  visibility: hidden;
}

/* ----- sidebar panels ----- */
.wheel-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wheel-panel {
  background: var(--bg-card);
  border: 1px solid var(--scrollbar-thumb);
  border-radius: 8px;
  padding: 18px;
}

.wheel-panel__title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.wheel-panel__title--toggle {
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  margin-bottom: 0;
  cursor: pointer;
  justify-content: space-between;
}

.wheel-chevron {
  transition: transform 0.2s ease;
  font-size: 11px;
}

/* ----- info icon + tooltip ----- */
.wheel-info {
  position: relative;
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  padding: 0;
  margin-left: -2px;
  color: var(--text-subtle);
  cursor: help;
  font-size: 12px;
  line-height: 1;
}

.wheel-info:hover,
.wheel-info:focus-visible {
  color: var(--accent);
  outline: none;
}

.wheel-info-tip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 230px;
  max-width: 72vw;
  background: var(--bg-darkest);
  color: var(--text-secondary);
  border: 1px solid var(--scrollbar-thumb);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 300;
  line-height: 1.6;
  text-transform: none;
  letter-spacing: 0.3px;
  text-align: left;
  box-shadow: 0 6px 20px var(--shadow-color);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
  z-index: 5;
  pointer-events: none;
}

.wheel-info:hover .wheel-info-tip,
.wheel-info:focus .wheel-info-tip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.wheel-panel__title--toggle[aria-expanded="true"] .wheel-chevron {
  transform: rotate(180deg);
}

.wheel-share-row,
.wheel-add-row {
  display: flex;
  gap: 8px;
}

.wheel-share-row .wheel-input {
  font-size: 11px;
}

/* ----- name list ----- */
.wheel-name-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wheel-name-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--bg-main);
  font-size: 12px;
  color: var(--text-primary);
}

.wheel-name-list .wheel-name-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-right: 8px;
}

.wheel-name-list .wheel-name-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* disabled = temporarily sat out (still in the list, off the wheel) */
.wheel-name-list li.is-disabled .wheel-name-text {
  color: var(--text-subtle);
  text-decoration: line-through;
  text-decoration-color: var(--scrollbar-thumb);
}

.wheel-name-list li.is-disabled .wheel-name-swatch {
  background: var(--scrollbar-thumb) !important;
}

.wheel-name-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.wheel-name-edit,
.wheel-name-remove {
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  line-height: 1;
  transition: color 0.2s ease;
}

.wheel-name-edit:hover {
  color: var(--accent);
}

.wheel-name-remove {
  font-size: 13px;
}

.wheel-name-remove:hover {
  color: #ff6b6b;
}

.wheel-name-remove:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ----- per-name enable/disable switch ----- */
.wheel-name-toggle {
  flex-shrink: 0;
  width: 30px;
  height: 17px;
  padding: 0;
  border: none;
  border-radius: 9px;
  background: var(--scrollbar-thumb);
  cursor: pointer;
  position: relative;
  transition: background 0.2s ease;
}

.wheel-name-toggle[aria-checked="true"] {
  background: var(--accent);
}

.wheel-name-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--bg-card);
  box-shadow: 0 1px 3px var(--shadow-color);
  transition: transform 0.2s ease;
}

.wheel-name-toggle[aria-checked="true"] .wheel-name-toggle-thumb {
  transform: translateX(13px);
}

/* inline name edit (swaps in place of the name text) */
.wheel-name-list li.is-editing .wheel-name-text {
  display: none;
}

.wheel-name-edit-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  padding: 4px 8px;
}

.wheel-name-edit-input:focus {
  outline: none;
}

/* ----- stats panel ----- */
.wheel-stats-range {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.wheel-stats-range__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-subtle);
}

.wheel-select {
  flex: 1;
  min-width: 120px;
  cursor: pointer;
  padding-top: 8px;
  padding-bottom: 8px;
  appearance: none;
  -webkit-appearance: none;
}

.wheel-stats-custom {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.wheel-stats-custom .wheel-input {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  font-size: 12px;
  color-scheme: light dark;
}

.wheel-stats-custom__sep {
  font-size: 11px;
  color: var(--text-subtle);
  flex-shrink: 0;
}

.wheel-stats-total {
  font-size: 11px;
  color: var(--text-subtle);
  margin: 0 0 12px;
}

.wheel-stats-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wheel-stats-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}

.wheel-stats-row .wheel-stats-name {
  flex-shrink: 0;
  width: 84px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
}

.wheel-stats-bar-track {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--bg-main);
  overflow: hidden;
}

.wheel-stats-bar-fill {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.3s ease;
}

.wheel-stats-row .wheel-stats-wins {
  flex-shrink: 0;
  width: 24px;
  text-align: right;
  color: var(--text-subtle);
  font-size: 11px;
}

.wheel-stats-empty {
  font-size: 12px;
  color: var(--text-subtle);
  font-style: italic;
}

/* ----- legend mode (>20 options) ----- */
.wheel-legend {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  font-size: 11px;
}

.wheel-legend li {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  overflow: hidden;
}

.wheel-legend .wheel-name-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.wheel-legend .wheel-legend-num {
  color: var(--text-subtle);
  flex-shrink: 0;
}

.wheel-legend .wheel-legend-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ----- footer ----- */
.wheel-footer {
  text-align: center;
  font-size: 10px;
  color: var(--text-subtle);
  padding: 20px 24px 28px;
  border-top: 1px solid var(--scrollbar-thumb);
}

.wheel-footer a {
  color: var(--text-subtle);
}

.wheel-footer a:hover {
  color: var(--accent);
}

.wheel-footer div + div {
  margin-top: 4px;
}

/* ----- responsive ----- */
@media (max-width: 820px) {
  .wheel-layout {
    grid-template-columns: 1fr;
  }

  .wheel-header__title {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .wheel-main {
    padding: 20px 16px 40px;
  }

  .wheel-spin-hub {
    width: 72px;
    height: 72px;
    font-size: 12px;
  }

  .wheel-legend {
    grid-template-columns: 1fr;
  }
}

/* ----- idle pulse on the spin hub (invites the first click) -----
   Two rings offset by half a cycle for a "sonar ping" effect, more visible
   than a single ring. .wheel-spin-hub is already `position: absolute` (see
   above), which is enough to anchor these — do not redeclare position here,
   it would override the absolute positioning that centers the button. */
.wheel-spin-hub:not(:disabled)::after,
.wheel-spin-hub:not(:disabled)::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 3px solid #ffffff;
  /* Keeps the white ring visible against light theme's near-white
     background, without changing its color. */
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.25));
  opacity: 0;
  pointer-events: none;
  animation: wheelIdlePulse 2.2s ease-out infinite;
}

.wheel-spin-hub:not(:disabled)::before {
  animation-delay: 1.1s;
}

@keyframes wheelIdlePulse {
  0% { transform: scale(0.85); opacity: 0.7; }
  70% { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .wheel-spin-hub:not(:disabled)::after,
  .wheel-spin-hub:not(:disabled)::before {
    animation: none;
  }
}

/* ----- name list enter/exit transitions ----- */
.wheel-name-list li {
  animation: wheelNameEnter 0.25s ease-out;
  transition: opacity 0.18s ease, transform 0.18s ease, max-height 0.18s ease, margin 0.18s ease, padding 0.18s ease;
  max-height: 44px;
  overflow: hidden;
}

.wheel-name-list li.wheel-name-exit {
  opacity: 0;
  transform: translateX(8px);
  max-height: 0;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
}

@keyframes wheelNameEnter {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ----- landing flash (fires the instant the wheel stops) ----- */
.wheel-canvas-wrap.wheel-landing-flash::before {
  content: '';
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  pointer-events: none;
  animation: wheelLandingFlash 0.5s ease-out;
}

@keyframes wheelLandingFlash {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.85); opacity: 1; }
  100% { box-shadow: 0 0 0 40px rgba(255, 255, 255, 0); opacity: 0; }
}

/* ----- winner overlay ----- */
.winner-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 14, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition: background 0.3s ease, backdrop-filter 0.3s ease, -webkit-backdrop-filter 0.3s ease;
  padding: 20px;
}

/* [hidden] and .winner-overlay{display:flex} have equal specificity, and
   this stylesheet loads after the UA sheet, so without this override the
   flex display would win and the overlay would block clicks while hidden. */
.winner-overlay[hidden] {
  display: none;
}

.winner-overlay.is-visible {
  background: rgba(10, 10, 14, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.winner-confetti {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.winner-card {
  position: relative;
  z-index: 1;
  background: var(--bg-card);
  border: 1px solid var(--scrollbar-thumb);
  border-radius: 16px;
  padding: 44px 40px 36px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px var(--shadow-color);
  opacity: 0;
  transform: scale(0.75);
}

.winner-card.winner-pop {
  animation: winnerPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes winnerPop {
  0% { opacity: 0; transform: scale(0.6); }
  60% { opacity: 1; transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}

.winner-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 13px;
  transition: color 0.2s ease, background 0.2s ease;
}

.winner-close:hover {
  color: var(--text-primary);
  background: var(--bg-main);
}

.winner-eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-subtle);
}

.winner-name {
  margin: 0 0 28px;
  font-size: 40px;
  font-weight: 800;
  line-height: 1.2;
  word-break: break-word;
  color: var(--accent);
}

.winner-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .winner-card {
    padding: 36px 24px 28px;
  }

  .winner-name {
    font-size: 30px;
  }
}
