/* Rifa: editor (index.html) e link público (ver.html). As cores vêm do tema da rifa (publico/js/temas.js), aplicadas
   como variáveis CSS no <html>; o padrão abaixo é o tema rosa, pra tela já nascer colorida antes do JS. */
@font-face {
  font-family: Fredoka;
  src: url(/fontes/fredoka-v17.woff2) format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --fundo: #ffe4ef;
  --papel: #fffafc;
  --cor: #dd266a;
  --sobre: #ffffff;
  --escura: #8e1f4c;
  --texto: #4a1830;
  --suave: #f7b6cd;
  --numero: #8e1f4c;
  --campo: color-mix(in srgb, var(--fundo) 40%, var(--papel));
  --sombra: 0 10px 30px rgb(30 10 40 / 0.08);
  --erro: #b3261e;
  font-family: Fredoka, "Trebuchet MS", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

*,
::before,
::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--fundo);
  color: var(--texto);
  font-size: 17px;
  line-height: 1.45;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

h1,
h2,
h3 {
  color: var(--escura);
  line-height: 1.15;
  margin: 0 0 0.5em;
}

p {
  margin: 0 0 0.75em;
}

a {
  color: var(--escura);
}

:focus-visible {
  outline: 3px solid var(--cor);
  outline-offset: 2px;
}

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

.miudo {
  font-size: 0.88rem;
  opacity: 0.8;
}

/* ---- botões */

button {
  appearance: none;
  min-height: 44px;
  padding: 0.5em 1.1em;
  border: 2px solid var(--suave);
  border-radius: 999px;
  background: var(--papel);
  color: var(--escura);
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 0.12s,
    border-color 0.12s,
    background-color 0.12s;
}

button:hover {
  border-color: var(--cor);
}

button:active {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

button.primario {
  border-color: var(--cor);
  background: var(--cor);
  color: var(--sobre);
}

button.primario:hover {
  border-color: var(--escura);
}

button.leve {
  border-color: transparent;
  background: transparent;
}

button.perigo {
  color: var(--erro);
}

.botoes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.botoes.fim {
  justify-content: flex-end;
}

.botoes.meio {
  justify-content: center;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips button {
  min-height: 40px;
  padding: 0.3em 0.95em;
  font-weight: 500;
}

.chips button[aria-pressed="true"],
.segmento button[aria-pressed="true"] {
  border-color: var(--cor);
  background: var(--cor);
  color: var(--sobre);
}

.segmento {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 999px;
  background: var(--campo);
  border: 2px solid var(--suave);
}

.segmento button {
  border: 0;
  background: transparent;
  min-height: 38px;
}

/* ---- campos */

.campo {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
  font-weight: 600;
  color: var(--escura);
}

.campo small {
  font-weight: 400;
  color: var(--texto);
  opacity: 0.8;
}

input:not([type="checkbox"], [type="radio"], [type="file"]),
textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.55em 0.85em;
  border: 2px solid var(--suave);
  border-radius: 14px;
  background: var(--campo);
  font-weight: 400;
}

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

textarea {
  min-height: 150px;
  resize: vertical;
}

fieldset {
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
  padding: 0;
  font-weight: 600;
  color: var(--escura);
}

.chave {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  cursor: pointer;
}

.chave.espaco {
  margin-top: 18px;
}

.chave input {
  appearance: none;
  position: relative;
  flex: none;
  width: 52px;
  height: 30px;
  margin: 0;
  border-radius: 999px;
  background: var(--suave);
  cursor: pointer;
  transition: background-color 0.15s;
}

.chave input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
  transition: translate 0.15s;
}

.chave input:checked {
  background: var(--cor);
}

.chave input:checked::after {
  translate: 22px 0;
}

.opcao {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 8px 0;
  cursor: pointer;
}

.opcao input {
  width: 20px;
  height: 20px;
  margin-top: 3px;
  accent-color: var(--cor);
  flex: none;
}

/* ---- topo e rodapé */

.topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px clamp(14px, 4vw, 32px);
}

.marca {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--escura);
  font-size: 1.4rem;
  font-weight: 700;
  text-decoration: none;
}

.marca img {
  width: 38px;
  height: 38px;
}

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

.rodape {
  margin-top: auto;
  padding: 24px 16px 32px;
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.85;
}

/* ---- editor */

.editor {
  display: grid;
  gap: 18px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(10px, 3vw, 32px) 24px;
}

.cartao-tela {
  background: var(--papel);
  border-radius: 26px;
  box-shadow: var(--sombra);
}

.previa {
  margin: 0;
  padding: 12px;
}

.previa canvas {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 42vh;
  margin: 0 auto;
  border-radius: 14px;
  cursor: zoom-in;
}

.previa.inteira canvas {
  max-height: none;
  cursor: zoom-out;
}

.previa figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 4px 2px;
}

.estado {
  font-size: 0.88rem;
  opacity: 0.85;
}

.painel {
  padding: 0 clamp(14px, 3vw, 26px) 24px;
}

@media (min-width: 920px) {
  .editor {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    align-items: start;
  }

  .lado-previa {
    position: sticky;
    top: 14px;
  }

  .previa canvas {
    max-height: calc(100dvh - 170px);
  }
}

.abas {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 2px;
  margin: 0 calc(-1 * clamp(14px, 3vw, 26px)) 20px;
  padding: 8px clamp(8px, 2vw, 18px) 0;
  overflow-x: auto;
  border-bottom: 2px solid var(--suave);
  border-radius: 26px 26px 0 0;
  background: var(--papel);
  scrollbar-width: none;
}

.abas button {
  flex: none;
  border: 0;
  border-radius: 14px 14px 0 0;
  background: transparent;
  color: var(--texto);
  opacity: 0.75;
}

.abas button[aria-selected="true"] {
  opacity: 1;
  color: var(--escura);
  box-shadow: inset 0 -4px 0 var(--cor);
}

.textos-lista {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.texto-item {
  display: flex;
  gap: 8px;
}

.texto-item button {
  flex: none;
  width: 46px;
  padding: 0;
}

.quantidade {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.quantidade input {
  width: 110px !important;
}

.resumo {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: baseline;
  margin-bottom: 12px;
  font-weight: 600;
  color: var(--escura);
}

.resumo strong {
  font-size: 1.5rem;
}

.filtro {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 14px 0 12px;
}

.filtro input {
  flex: 1 1 180px;
  width: auto !important;
}

.vazio {
  padding: 18px;
  text-align: center;
  opacity: 0.8;
}

/* ---- grade de números (editor e link) */

.numeros {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(54px, 1fr));
  gap: 8px;
}

.com-nomes .numeros {
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
}

.numeros button {
  display: grid;
  place-content: center;
  min-width: 0;
  min-height: 54px;
  padding: 4px;
  border-radius: 14px;
  background: var(--papel);
  color: var(--numero);
  font-size: 1.05rem;
  line-height: 1.1;
}

.numeros button small {
  max-width: 100%;
  overflow: hidden;
  font-size: 0.7rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.numeros button.ocupado {
  border-color: var(--cor);
  background: var(--cor);
  color: var(--sobre);
}

.numeros button.ocupado:disabled {
  opacity: 1;
  cursor: default;
}

.numeros button[aria-pressed="true"] {
  border-color: var(--escura);
  background: var(--escura);
  color: var(--papel);
  transform: scale(1.06);
}

.numeros button.meu {
  box-shadow:
    0 0 0 3px var(--papel),
    0 0 0 6px var(--escura);
}

.legenda {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  font-weight: 500;
}

.ponto {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  border: 2px solid var(--suave);
  border-radius: 50%;
  background: var(--papel);
  vertical-align: -2px;
}

.ponto.cheio {
  border-color: var(--cor);
  background: var(--cor);
}

/* ---- visual */

.cores {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 10px;
}

.cores button,
.estilos button {
  display: grid;
  justify-items: center;
  gap: 6px;
  height: auto;
  padding: 10px 6px;
  border-radius: 18px;
  font-weight: 500;
}

.cores button[aria-pressed="true"],
.estilos button[aria-pressed="true"] {
  border-color: var(--cor);
  background: var(--campo);
  box-shadow: 0 0 0 2px var(--cor);
}

.bolinha {
  width: 42px;
  height: 42px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--a) 50%, var(--b) 50%);
  box-shadow: 0 0 0 2px var(--suave);
}

.estilos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (min-width: 560px) {
  .estilos {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.estilos canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
}

/* ---- compartilhar */

.cartao {
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 2px solid var(--suave);
  border-radius: 20px;
}

.cartao h3 {
  margin-bottom: 0.3em;
  font-size: 1.12rem;
}

.ja-comecou {
  border-style: dashed;
  background: var(--campo);
}

.link-url {
  display: block;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--campo);
  font-weight: 600;
  word-break: break-all;
}

/* ---- janelas */

dialog {
  width: min(94vw, 500px);
  max-height: 92dvh;
  padding: 22px;
  border: 0;
  border-radius: 26px;
  background: var(--papel);
  color: var(--texto);
  box-shadow: 0 30px 80px rgb(20 10 30 / 0.35);
}

dialog[open] {
  animation: sobe 0.2s ease-out;
}

dialog::backdrop {
  background: rgb(20 10 30 / 0.45);
}

dialog h2 {
  padding-right: 36px;
  font-size: 1.35rem;
}

dialog .fechar {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  min-height: 40px;
  padding: 0;
  border-color: transparent;
  font-size: 1.3rem;
  line-height: 1;
}

.erro-texto {
  color: var(--erro);
  font-weight: 600;
}

.analise {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--campo);
}

.analise p:last-child {
  margin-bottom: 0;
}

.ignoradas {
  max-height: 150px;
  margin: 6px 0 0;
  padding-left: 1.1em;
  overflow: auto;
  font-size: 0.9rem;
}

details summary {
  cursor: pointer;
  font-weight: 600;
}

.codigo {
  font-size: 1.6rem !important;
  letter-spacing: 0.4em;
  text-align: center;
}

.minhas {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.minhas li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 2px solid var(--suave);
  border-radius: 18px;
}

.minhas .bolinha {
  flex: none;
  width: 28px;
  height: 28px;
  border-width: 2px;
}

.minhas .info {
  flex: 1;
  min-width: 0;
}

.minhas .info strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.minhas button {
  min-height: 40px;
  padding: 0.3em 0.9em;
}

/* ---- avisos e confete */

#avisos {
  position: fixed;
  bottom: 16px;
  left: 50%;
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(92vw, 440px);
  translate: -50% 0;
  pointer-events: none;
}

.com-barra #avisos {
  bottom: 96px;
}

.aviso {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--escura);
  color: var(--papel);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.25);
  pointer-events: auto;
  animation: sobe 0.25s ease-out;
}

.aviso.erro {
  background: var(--erro);
  color: #fff;
}

.aviso button {
  flex: none;
  min-height: 36px;
  border-color: currentColor;
  background: transparent;
  color: inherit;
}

.festa {
  position: fixed;
  inset: 0;
  z-index: 60;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@keyframes sobe {
  from {
    opacity: 0;
    translate: 0 12px;
  }
}

/* ---- link público (ver.html): o estilo da rifa vira classe no <body> */

.link {
  width: min(100%, 880px);
  margin: 0 auto;
  padding: 14px clamp(10px, 4vw, 28px) 120px;
}

.cabeca {
  margin-bottom: 16px;
  padding: 30px 22px 26px;
  border-radius: 30px;
  background: var(--cor);
  color: var(--sobre);
  text-align: center;
}

.cabeca h1 {
  margin-bottom: 0.25em;
  color: inherit;
  font-size: clamp(2rem, 7vw, 3.2rem);
  overflow-wrap: anywhere;
}

.cabeca .sub {
  margin: 0;
  font-size: clamp(1.1rem, 3.6vw, 1.4rem);
  font-weight: 500;
}

.etiqueta {
  display: inline-block;
  margin: 0 0 12px;
  padding: 0.3em 1em;
  border-radius: 999px;
  /* invertido (cor sobre "sobre"): o mesmo par dos botões, AA nas 8 cores; translúcido sobre a faixa dava 3,5:1 */
  background: var(--sobre);
  color: var(--cor);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.quadro {
  margin-bottom: 16px;
  padding: 18px clamp(12px, 3vw, 22px);
  border-radius: 26px;
  background: var(--papel);
  box-shadow: var(--sombra);
}

.quadro.textos p {
  margin: 0.25em 0;
  text-align: center;
}

.quadro .legenda {
  justify-content: space-between;
  margin-bottom: 14px;
}

.fechada {
  padding: 14px 18px;
  border-radius: 18px;
  background: var(--escura);
  color: var(--papel);
  font-weight: 600;
  text-align: center;
}

.estilo-classico:not(.com-nomes) .numeros button {
  aspect-ratio: 1;
  border-radius: 50%;
}

.estilo-bilhete {
  background-image: repeating-linear-gradient(45deg, transparent 0 24px, color-mix(in srgb, var(--suave) 40%, transparent) 24px 34px);
}

.estilo-bilhete .cabeca {
  mask:
    radial-gradient(circle 20px at 0 50%, #0000 98%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle 20px at 100% 50%, #0000 98%, #000) right / 51% 100% no-repeat;
}

.estilo-bilhete .numeros button:not(.ocupado) {
  border-style: dashed;
}

.estilo-bilhete .numeros button {
  border-radius: 8px;
}

.estilo-confete {
  background-image:
    radial-gradient(var(--suave) 3px, transparent 4px), radial-gradient(color-mix(in srgb, var(--cor) 55%, transparent) 2.5px, transparent 3.5px);
  background-size:
    46px 46px,
    74px 74px;
  background-position:
    0 0,
    22px 31px;
}

.estilo-confete .cabeca {
  background: transparent;
  color: var(--texto);
}

.estilo-confete .cabeca h1 {
  color: var(--escura);
  -webkit-text-stroke: 0.22em var(--papel);
  paint-order: stroke fill;
}

.estilo-confete .cabeca .etiqueta {
  background: var(--cor);
  color: var(--sobre);
}

.estilo-confete .numeros button {
  box-shadow: 0 4px 0 var(--suave);
}

.estilo-confete .numeros button.ocupado {
  box-shadow: 0 4px 0 var(--escura);
}

.estilo-lista {
  background: var(--papel);
}

.estilo-lista .cabeca {
  padding: 10px 0;
  background: transparent;
  color: var(--texto);
  text-align: left;
}

.estilo-lista .cabeca h1 {
  color: var(--escura);
}

.estilo-lista .cabeca .etiqueta {
  background: var(--cor);
  color: var(--sobre);
}

.estilo-lista .quadro {
  box-shadow: none;
  border: 2px solid var(--suave);
}

.estilo-lista .quadro.textos p {
  text-align: left;
}

.estilo-lista .link .numeros {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px 18px;
}

.estilo-lista .link .numeros button {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-start;
  min-height: 46px;
  border-width: 0 0 2px;
  border-style: dotted;
  border-color: var(--suave);
  border-radius: 0;
  background: transparent;
  color: var(--texto);
  text-align: left;
}

.estilo-lista .link .numeros button > span {
  flex: none;
  min-width: 3em;
  padding: 0.15em 0.6em;
  border: 2px solid var(--suave);
  border-radius: 999px;
  color: var(--numero);
  text-align: center;
}

.estilo-lista .link .numeros button.ocupado {
  color: var(--texto);
}

.estilo-lista .link .numeros button.ocupado > span {
  border-color: var(--cor);
  background: var(--cor);
  color: var(--sobre);
}

.estilo-lista .link .numeros button[aria-pressed="true"] {
  transform: none;
  background: var(--campo);
}

.estilo-lista .link .numeros button[aria-pressed="true"] > span {
  border-color: var(--escura);
  background: var(--escura);
  color: var(--papel);
}

.estilo-lista .link .numeros button small {
  font-size: 0.95rem;
}

.barra-escolha {
  position: fixed;
  bottom: 14px;
  left: 50%;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(94vw, 560px);
  padding: 8px 8px 8px 20px;
  border-radius: 999px;
  background: var(--escura);
  color: var(--papel);
  box-shadow: 0 14px 40px rgb(0 0 0 / 0.3);
  translate: -50% 0;
  animation: sobe 0.2s ease-out;
}

.barra-escolha span {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.barra-escolha .primario {
  flex: none;
  border-color: var(--papel);
}

.meus {
  font-weight: 600;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *,
  ::before,
  ::after {
    animation: none !important;
    transition: none !important;
  }
}
