/* ================================
   Wild Wheel — Layout & Theme
   ================================ */

/* Theme tokens (podem ser sobrepostos inline via JS com --ww-*) */
.wild-wheel-wrapper {
  --ww-text: #1f2937;            /* texto base */
  --ww-muted: #6b7280;           /* texto secundário */
  --ww-border: #e5e7eb;          /* bordas neutras */
  --ww-surface: #ffffff;         /* cartões / inputs */
  --ww-surface-2: #f9fafb;       /* fundos suaves */
  --ww-accent: #2563eb;          /* cor do CTA */
  --ww-btn-text: #ffffff;        /* texto do botão */
  --ww-link: #2563eb;            /* links */
  --ww-focus: rgba(37, 99, 235, 0.4); /* focus ring */
--ww-result: #fff;
--ww-success-text: #fff;

  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 28px 20px 36px;
  border-radius: 20px;
  box-shadow: 0 0 30px rgba(0,0,0,0.08);
  text-align: center;
  background: transparent !important;
  color: var(--ww-text);
}

/* Melhor respiração em ecrãs maiores */
@media (min-width: 640px) {
  .wild-wheel-wrapper {
    padding: 36px 28px 44px;
  }
}

/* ================================
   Roda
   ================================ */
#wild-wheel-canvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 50%;
  box-shadow:
    inset 0 0 20px rgba(255,255,255,0.3),
    0 10px 20px rgba(0,0,0,0.18);
  transition: transform 4s ease-out;
  background: radial-gradient(circle, #fff 0%, #ddd 80%);
}

/* ================================
   Botão SPIN
   ================================ */
#btn-spin {
  display: block;
  margin: 20px auto 10px;
  padding: 12px 24px;
  background-color: #d63638;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  transition: transform .08s ease, opacity .2s ease, box-shadow .2s ease;
  box-shadow: 0 6px 18px rgba(214,54,56,0.35);
}

#btn-spin:hover:not(:disabled) {
  transform: translateY(-1px);
}

#btn-spin:active:not(:disabled) {
  transform: translateY(0);
}

#btn-spin:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

/* ================================
   Resultado
   ================================ */
#wild-wheel-result {
  margin-top: 10px;
  font-size: 16px;
  font-weight: 800;
  color: var(--ww-result);
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}

/* ================================
   Mensagens Globais
   ================================ */
#wild-wheel-message {
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ww-muted);
  text-align: center;
}

.wild-wheel-error {
  color: #d32f2f !important;
  font-weight: 700;
}
.wild-wheel-success {
  color: #ffffff !important; /* ligeiramente mais escuro para contraste */
  font-weight: 700;
}

/* Links dentro da wrapper */
.wild-wheel-wrapper a {
  color: var(--ww-link);
  text-decoration: underline;
  font-weight: 600;
  text-underline-offset: 2px;
}

/* ================================
   Formulário (novo layout)
   ================================ */
#wild-wheel-form {
  margin-top: 18px;
  text-align: left;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

/* Cabeçalho opcional do formulário (JS pode preencher) */
.ww-form-head {
  margin-bottom: 8px;
  color: var(--ww-muted);
  font-size: 14px;
}

/* Grid responsivo para campos */
.ww-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 520px) {
  .ww-form-grid {
    grid-template-columns: 1fr 1fr;
  }
  /* Contacto ocupa 2 colunas quando presente */
  .ww-form-grid .ww-field:nth-child(3) {
    grid-column: 1 / -1;
  }
}

/* Campo base */
.ww-field {}

/* Control com label flutuante */
.ww-control {
  position: relative;
  background: var(--ww-surface);
  border: 1px solid var(--ww-border);
  border-radius: 12px;
  padding: 12px 14px 10px;
  transition: border-color .2s ease, box-shadow .2s ease, background-color .2s ease;
}

/* Inputs */
#wild-wheel-form input[type="text"],
#wild-wheel-form input[type="email"],
#wild-wheel-form input[type="tel"] {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--ww-text);
  font-size: 16px;
  line-height: 1.4;
  padding: 8px 0 2px; /* espaço extra para label flutuante */
}

/* Esconder placeholder só nos campos de texto (para flutuação) */
#wild-wheel-form input[type="text"]::placeholder,
#wild-wheel-form input[type="email"]::placeholder,
#wild-wheel-form input[type="tel"]::placeholder {
  color: transparent;
}

/* Label flutuante – APLICAR APENAS dentro da .ww-control */
.ww-control > label {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--ww-surface);
  padding: 0 6px;
  color: var(--ww-muted);
  font-weight: 600;
  font-size: 14px;
  pointer-events: none;
  transition: all .18s ease;
}

/* Estados de foco e preenchido */
.ww-control:focus-within {
  border-color: var(--ww-accent);
  box-shadow: 0 0 0 4px var(--ww-focus);
}

#wild-wheel-form input:not(:placeholder-shown) + label,
#wild-wheel-form input:focus + label {
  top: 0;
  transform: translateY(-50%) scale(.92);
  color: var(--ww-accent);
}

/* Hints e Erros */
.ww-hint {
  color: #fff !important;
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
}


.ww-error {
  display: none;
  margin: 6px 2px 0;
  font-size: 12px;
  color: #d32f2f;
  font-weight: 600;
}

#wild-wheel-form input[aria-invalid="true"] {
  color: #b42318;
}

#wild-wheel-form input[aria-invalid="true"] ~ label {
  color: #b42318;
}

.ww-control[aria-invalid="true"],
#wild-wheel-form input[aria-invalid="true"] ~ .ww-control {
  border-color: #d32f2f;
  box-shadow: 0 0 0 4px rgba(211,47,47,0.12);
}

/* ================================
   Checkboxes custom (privacidade / marketing)
   ================================ */
/* Suporta dois markups:
   1) <label class="ww-check"> <input type="checkbox"> <span class="ww-check__label">...</span> </label>
   2) <div class="ww-check"> <input type="checkbox"> <label>...</label> </div>  (compat)
*/
.ww-check,
label.ww-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  background: var(--ww-surface-2);
  border: 1px dashed var(--ww-border);
  border-radius: 12px;
  padding: 10px 12px;
  /* anular quaisquer regras herdadas de labels flutuantes/temas */
  position: static;
  transform: none;
  background-clip: padding-box;
}

.ww-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--ww-accent);
  border-radius: 6px;
  display: inline-grid;
  place-content: center;
  margin-top: 2px; /* alinha com a 1ª linha do texto */
  cursor: pointer;
  background: #fff;
  transition: background-color .2s ease, box-shadow .2s ease, transform .05s ease;
}

.ww-check input[type="checkbox"]:focus {
  box-shadow: 0 0 0 4px var(--ww-focus);
}

.ww-check input[type="checkbox"]::before {
  content: "";
  width: 12px;
  height: 12px;
  transform: scale(0);
  transition: transform .12s ease-in-out;
  background: var(--ww-accent);
  border-radius: 3px;
}

.ww-check input[type="checkbox"]:checked::before {
  transform: scale(1);
}

/* Texto da checkbox (ambos os markups) */
.ww-check .ww-check__label,
.ww-check > label {
  position: static !important;
  transform: none !important;
  padding: 0;
  color: var(--ww-text);
  font-size: 14px;
  line-height: 1.35;
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}

/* Links dentro da checkbox */
.ww-check a {
  text-decoration: underline;
}

/* Erro para privacidade (quando precisa mostrar) */
.ww-error[data-for="privacy"] {
  display: block;
  margin-top: 6px;
}

/* ================================
   Botão Submit do Formulário
   ================================ */
#wild-wheel-form .wild-wheel-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 14px;
  padding: 12px 16px;
  background-color: var(--ww-accent);
  color: var(--ww-btn-text);
  border: 1px solid var(--ww-accent);
  border-radius: 12px;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  transition: transform .08s ease, opacity .2s ease, box-shadow .2s ease, filter .2s ease;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.25);
}

#wild-wheel-form .wild-wheel-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

#wild-wheel-form .wild-wheel-submit:active:not(:disabled) {
  transform: translateY(0);
}

#wild-wheel-form .wild-wheel-submit:disabled,
#wild-wheel-form .wild-wheel-submit[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

/* Spinner do botão */
.ww-btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.55);
  border-top-color: rgba(255,255,255,0.95);
  border-radius: 50%;
  display: none;
  animation: ww-spin 0.8s linear infinite;
}

.wild-wheel-submit.is-loading .ww-btn-spinner {
  display: inline-block;
}
.wild-wheel-submit.is-loading .ww-btn-label {
  opacity: 0.85;
}

@keyframes ww-spin {
  to { transform: rotate(360deg); }
}

/* ================================
   Estados visuais (para animações suaves)
   ================================ */
.is-hidden {
  opacity: 0;
  pointer-events: none !important;
  user-select: none !important;
  transform: translateY(6px);
  transition: opacity .2s ease, transform .2s ease;
}

#wild-wheel-form,
.wild-wheel-stage,
#wild-wheel-canvas {
  transition: opacity .2s ease, transform .2s ease;
}

/* Respeitar preferências de movimento reduzido */
@media (prefers-reduced-motion: reduce) {
  #wild-wheel-canvas,
  #btn-spin,
  #wild-wheel-form,
  .wild-wheel-stage {
    transition: none !important;
  }
  .ww-btn-spinner {
    animation: none !important;
  }
}

/* ================================
   Acessibilidade extra
   ================================ */
#wild-wheel-form input:focus {
  outline: none;
}

#wild-wheel-form input:focus-visible {
  outline: 3px solid transparent;
}

#wild-wheel-form .ww-control:focus-within {
  outline: none;
}

/* ================================
   Compat legado (mantém estilos antigos se algo cair no DOM)
   ================================ */
/* Não deixar o tema estilizar demais botões antigos no form */
#wild-wheel-form button {
  all: unset;
}
#wild-wheel-form button {
  display: inline-flex;
}

/* Manter visual de labels antigas se aparecerem fora do novo markup */
#wild-wheel-form > label {
  display: block;
  margin-bottom: 6px;
  color: var(--ww-text);
  font-weight: 600;
}

/* ================================
   Pequenos ajustes de cores herdadas
   ================================ */
.wild-wheel-wrapper .ww-error a,
.wild-wheel-wrapper .wild-wheel-error a {
  color: #b42318;
  text-decoration-color: #fca5a5;
}
