/* Design "Cadastro Katuxa Mobile" (claude.ai/design) */
:root {
  --ink: #141414;
  --muted: #6b6464;
  --subtle: #8a8383;
  --placeholder: #9a9494;

  --border: #e3dddc;
  --border-soft: #ebe6e5;
  --bg: #f4f2f1;
  --surface: #ffffff;
  --surface-2: #faf8f8;
  --toggle-off: #d9d3d2;

  --red: #c8201a;
  --red-bright: #e8403a;
  --red-soft: #fdf3f2;
  --red-disabled: #e59a96;
  --red-ring: rgba(200, 32, 26, 0.12);

  --warn: #8a5a12;
  --warn-bg: #fbf1de;

  --sans: "Geist", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  color: var(--ink);
}

.mono {
  font-family: var(--mono);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

/* Fundo de pontos e faíscas do toque */
.fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.fx-grid {
  z-index: 0;
}

.fx-sparks {
  z-index: 10;
}

/* Cartão: tela cheia no celular, cartão centralizado a partir de 540px */
.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.card {
  position: relative;
  width: 100%;
  max-width: 500px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 24px 60px -30px rgba(20, 20, 20, 0.35);
  animation: kxCardIn 0.7s var(--ease) both;
}

/* luz que acompanha o ponteiro */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(
    420px circle at var(--mx, -500px) var(--my, -500px),
    rgba(200, 32, 26, 0.1),
    transparent 60%
  );
}

@media (min-width: 540px) {
  .page {
    align-items: center;
    padding: 48px 16px;
  }

  .card {
    min-height: 0;
    border: 1px solid var(--border-soft);
    border-radius: 16px;
  }
}

/* Cabeçalho */
.brand {
  background: var(--ink);
  padding: 60px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

@media (min-width: 540px) {
  .brand {
    padding: 22px 24px 24px;
  }
}

.brand-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--red);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.brand-name {
  font-weight: 600;
  font-size: 14px;
  color: #ffffff;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(200, 32, 26, 0.18);
  border: 1px solid rgba(232, 64, 56, 0.4);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
}

.brand-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red-bright);
  animation: kxPulse 2s ease-in-out infinite;
}

.badge-text {
  color: transparent;
  background-image: linear-gradient(110deg, #ff8f88 40%, #ffffff 50%, #ff8f88 60%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  animation: kxShine 3s linear infinite;
}

h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: #ffffff;
  display: flex;
  flex-wrap: wrap;
  column-gap: 0.28em;
}

.word {
  display: inline-block;
  opacity: 0;
  animation: kxBlurIn 0.8s var(--ease) forwards;
}

.word-accent {
  color: var(--red-bright);
}

.subtitle {
  margin: -10px 0 0;
  font-size: 13px;
  color: #b9b3b3;
}

h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.muted {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  text-wrap: pretty;
}

/* Subseção numerada */
.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}

.section-head h2 {
  font-size: 14px;
}

.section-gap {
  margin-top: 4px;
}

.section-num {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--red);
}

/* Estados: carregando, erro e confirmação */
.state {
  text-align: center;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.state .muted {
  max-width: 320px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.icon-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
}

.icon-error {
  background: var(--red-soft);
  color: var(--red);
}

.icon-success {
  background: var(--red);
  color: #ffffff;
  animation: kxPop 0.55s var(--ease) both;
}

/* Seletor de campanhas */
#view-selector {
  padding: 24px 24px 8px;
}

.intro {
  margin: 12px 0;
}

.campaign-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.campaign-option {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  font-family: var(--sans);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  transition: background 0.2s, border-color 0.2s;
}

.campaign-option:hover {
  background: var(--red-soft);
  border-color: var(--red);
}

.campaign-option:focus-visible {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-ring);
}

.campaign-option strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.campaign-option span {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

.campaign-arrow {
  font-family: var(--mono);
  flex-shrink: 0;
}

/* Formulário */
.form {
  padding: 24px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.fields {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.field label {
  font-size: 13px;
  font-weight: 500;
}

.field input {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  accent-color: var(--red);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input.mono {
  font-family: var(--mono);
  font-size: 13px;
}

.field input::placeholder {
  color: var(--placeholder);
}

.field input::-webkit-date-and-time-value {
  text-align: left;
}

.field input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-ring);
}

.field input.is-invalid {
  border-color: var(--red);
  background: var(--red-soft);
}

/* iOS dá zoom ao focar campos com fonte menor que 16px */
@supports (-webkit-touch-callout: none) {
  .field input,
  .field input.mono {
    font-size: 16px;
  }
}

.field-error {
  font-size: 12px;
  font-weight: 500;
  color: var(--red);
}

.info-box {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 14px;
  font-size: 12px;
  color: var(--muted);
}

.info-box strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  color: var(--ink);
}

.info-box p {
  margin: 0;
  white-space: pre-line;
}

/* Aceite LGPD: o cartão inteiro é o interruptor */
.toggle-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  transition: background 0.25s, border-color 0.25s;
}

.toggle-card:has(.toggle-input:checked) {
  border-color: var(--red);
  background: var(--red-soft);
}

.toggle-card:has(.toggle-input:focus-visible) {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-ring);
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.toggle-copy {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.toggle-title {
  font-size: 14px;
  font-weight: 600;
}

.toggle-hint {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  text-wrap: pretty;
}

.toggle-track {
  position: relative;
  flex-shrink: 0;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--toggle-off);
  transition: background 0.2s;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: left 0.25s cubic-bezier(0.5, 1.6, 0.4, 1);
}

.toggle-input:checked ~ .toggle-track {
  background: var(--red);
}

.toggle-input:checked ~ .toggle-track .toggle-thumb {
  left: 18px;
}

.alert-error {
  background: var(--red-soft);
  border: 1px solid var(--red-disabled);
  color: var(--red);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

/* Botões */
.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn {
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 14px;
  cursor: pointer;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--red-ring);
}

.btn-primary,
.btn-secondary {
  width: 100%;
  height: 44px;
}

.btn-primary {
  border: none;
  background-color: var(--red);
  background-image: linear-gradient(110deg, transparent 35%, rgba(255, 255, 255, 0.28) 50%, transparent 65%);
  background-size: 200% 100%;
  color: #ffffff;
  font-weight: 600;
  animation: kxShine 2.4s linear infinite;
  transition: background-color 0.3s, transform 0.15s;
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-primary:disabled {
  background-color: var(--red-disabled);
  background-image: none;
  animation: none;
  cursor: not-allowed;
}

.btn-secondary {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
}

.btn-secondary:hover {
  background: var(--bg);
}

.btn-outline {
  margin-top: 8px;
  padding: 10px 18px;
  border: 1px solid var(--ink);
  background: none;
  color: var(--ink);
  font-weight: 500;
}

.btn-outline:hover {
  background: var(--ink);
  color: #ffffff;
}

/* Confirmação (QR de campanha) */

.success-note {
  margin: 0;
  max-width: 320px;
  font-size: 12px;
  color: var(--subtle);
  text-wrap: pretty;
}

.summary-card {
  width: 100%;
  max-width: 320px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 4px 14px;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  font-size: 13px;
  color: var(--muted);
}

.summary-row + .summary-row {
  border-top: 1px solid var(--border-soft);
}

.summary-row strong {
  color: var(--ink);
}

.pill-warn {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 12px;
  font-weight: 500;
}

.card-footer {
  margin: 18px 24px 0;
  padding: 14px 0 24px;
  border-top: 1px solid var(--border-soft);
  text-align: center;
  font-size: 12px;
  color: var(--subtle);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes kxCardIn {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes kxBlurIn {
  0% {
    opacity: 0;
    filter: blur(10px);
    transform: translateY(-14px);
  }
  60% {
    opacity: 0.6;
    filter: blur(4px);
    transform: translateY(3px);
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
  }
}

@keyframes kxReveal {
  from {
    opacity: 0;
    transform: translateY(12px);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

@keyframes kxShine {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@keyframes kxPop {
  0% {
    transform: scale(0) rotate(-45deg);
  }
  70% {
    transform: scale(1.15) rotate(0);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes kxPulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(232, 64, 58, 0.6);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(232, 64, 58, 0);
  }
}

/* entrada em sequência dos blocos do formulário (reinicia sempre que o formulário reaparece) */
[data-reveal] {
  animation: kxReveal 0.5s var(--ease) backwards;
}

.form > [data-reveal]:nth-child(1) { animation-delay: 0.25s; }
.form > [data-reveal]:nth-child(2) { animation-delay: 0.31s; }
.fields > [data-reveal]:nth-child(1) { animation-delay: 0.37s; }
.fields > [data-reveal]:nth-child(2) { animation-delay: 0.43s; }
.fields > [data-reveal]:nth-child(3) { animation-delay: 0.49s; }
.form > [data-reveal]:nth-child(4) { animation-delay: 0.55s; }
.form > [data-reveal]:nth-child(5) { animation-delay: 0.61s; }
.form > [data-reveal]:nth-child(7) { animation-delay: 0.67s; }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
