/* ================================================================
   INSCRICAO.CSS — Typeform-style one-question-per-screen
   Built on top of styles.css (vars, fonts, .btn, pixel-canvas)

   Works in TWO modes:
   1. Standalone page  → <body class="form-body"> wraps a .form-shell
   2. Modal dialog     → <dialog class="inscricao-dialog"> wraps a .form-shell
   The .form-shell is the layout container; topbar/stage/nav are positioned
   relative to it (never to the viewport).
   ================================================================ */

/* ============== STANDALONE PAGE MODE ============== */
.form-body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background-color: #0A0A0F;
}

.form-body::before {
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(65, 182, 240, 0.12), transparent 70%),
    radial-gradient(50% 40% at 80% 100%, rgba(143, 237, 251, 0.08), transparent 70%),
    linear-gradient(180deg, rgba(8, 10, 14, 0.6), rgba(8, 10, 14, 0.85));
}

.form-body > .form-shell {
  height: 100vh;
  height: 100dvh;
}

/* ============== FORM SHELL ============== */
/* The container that holds topbar, stage, and nav. Sized by its parent
   (body in page mode, dialog in modal mode). All inner elements position
   relative to this shell. */
.form-shell {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: #0A0A0F;
  isolation: isolate;
}

/* Decorative gradient overlay inside the shell (both modes — replaces
   the body::before gradient which would be hidden by the shell's solid bg) */
.form-shell::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(65, 182, 240, 0.12), transparent 70%),
    radial-gradient(50% 40% at 80% 100%, rgba(143, 237, 251, 0.06), transparent 70%);
}

.form-shell > * {
  position: relative;
  z-index: 1;
}

/* ============== TOP BAR ============== */
.form-topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-md) var(--space-xl);
  background: rgba(10, 10, 15, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.form-topbar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
  font-weight: 600;
  font-size: var(--fs-sm);
  white-space: nowrap;
}

.form-topbar__brand .text-gradient {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.form-topbar__logo-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-primary);
  border-radius: 2px;
}
.form-topbar__logo-dot--cyan {
  background: var(--accent-secondary);
  margin-right: 4px;
}

.form-topbar__progress {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}

.form-topbar__progress-bar {
  position: absolute;
  inset: 0 100% 0 0;
  background: var(--accent-gradient);
  border-radius: 99px;
  transition: right 600ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 16px rgba(143, 237, 251, 0.4);
}

.form-topbar__exit {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  transition: background var(--transition-base), border-color var(--transition-base);
}
.form-topbar__exit:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
}
.form-topbar__exit span {
  position: absolute;
  top: 50%; left: 50%;
  width: 14px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 1px;
  transition: background var(--transition-base);
}
.form-topbar__exit span:first-child { transform: translate(-50%, -50%) rotate(45deg); }
.form-topbar__exit span:last-child { transform: translate(-50%, -50%) rotate(-45deg); }
.form-topbar__exit:hover span { background: var(--error); }

/* ============== STAGE & SLIDES ============== */
.form-stage {
  position: relative;
  flex: 1 1 0;
  width: 100%;
  overflow: hidden;
}

.slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl) var(--space-xl) calc(var(--space-3xl) + 16px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(40px);
  transition: opacity 500ms cubic-bezier(0.16, 1, 0.3, 1),
              transform 500ms cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
}

/* When content is taller than viewport (review with many cards, etc.),
   anchor at top so the title is never pushed above the visible area. */
.slide--review,
.slide[data-type="multi"] {
  align-items: flex-start;
}
.slide--review .slide__inner,
.slide[data-type="multi"] .slide__inner {
  margin-top: 0;
}

.slide.is-active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.slide.is-leaving-up {
  opacity: 0;
  transform: translateY(-40px);
}

.slide.is-leaving-down {
  opacity: 0;
  transform: translateY(40px);
}

.slide__inner {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* Slide number + arrow (Typeform signature) */
.slide__num {
  font-size: var(--fs-sm);
  color: var(--accent-secondary);
  font-weight: 600;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0.85;
}

.slide__arrow {
  display: inline-block;
  font-weight: 400;
}

/* Question heading */
.slide__question {
  font-size: clamp(1.5rem, 1.1rem + 2vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.slide__req {
  color: var(--accent-secondary);
  margin-left: 4px;
}

.slide__hint-inline {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.85em;
}

.slide__sub {
  font-size: var(--fs-base);
  color: var(--text-secondary);
  line-height: 1.55;
  margin-top: -8px;
}

.slide__title {
  font-size: clamp(1.75rem, 1.2rem + 2.4vw, 3rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.slide__desc {
  font-size: var(--fs-lg);
  color: var(--text-secondary);
  line-height: 1.6;
}

.slide__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(65, 182, 240, 0.08);
  border: 1px solid rgba(65, 182, 240, 0.2);
  border-radius: 99px;
  color: var(--accent-secondary);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  width: fit-content;
}

.slide__hint {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.slide__hint kbd {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--font-family);
  font-size: 0.85em;
  font-weight: 500;
  color: var(--text-secondary);
}

.slide__actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-xs);
  flex-wrap: wrap;
}

.slide__actions--row {
  flex-direction: row;
}

/* ============== INPUT FIELDS ============== */
.field {
  display: flex;
  align-items: stretch;
  border-bottom: 2px solid var(--border);
  transition: border-color var(--transition-base);
  padding-bottom: 4px;
}

.field:focus-within {
  border-bottom-color: var(--accent-secondary);
}

.field--phone {
  align-items: baseline;
  gap: 10px;
}

.field__prefix {
  font-size: var(--fs-xl);
  font-weight: 500;
  color: var(--text-muted);
  flex-shrink: 0;
}

.field__input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: clamp(1.125rem, 0.9rem + 1.2vw, 1.5rem);
  font-weight: 500;
  padding: 12px 0;
  letter-spacing: -0.01em;
  width: 100%;
}

.field__input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
  font-weight: 400;
}

.field__input--textarea {
  resize: none;
  line-height: 1.5;
  min-height: 120px;
  font-size: clamp(1rem, 0.85rem + 0.8vw, 1.25rem);
}

.field__error {
  color: var(--error);
  font-size: var(--fs-sm);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: -4px;
  animation: slide-in-error 250ms ease;
}

.field__error[hidden] {
  display: none;
}

.field__error::before {
  content: '⚠';
  font-size: 1em;
}

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

/* ============== CHOICES (radio/multi) ============== */
.choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: var(--space-xs);
}

.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--text-primary);
  transition: background var(--transition-base),
              border-color var(--transition-base),
              transform 120ms ease;
  position: relative;
}

.choice:hover {
  background: var(--surface-hover);
  border-color: rgba(143, 237, 251, 0.35);
  transform: translateX(2px);
}

.choice:focus-visible {
  outline: none;
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 3px rgba(143, 237, 251, 0.15);
}

.choice.is-selected {
  background: rgba(65, 182, 240, 0.08);
  border-color: var(--accent-secondary);
  box-shadow: 0 0 0 2px rgba(143, 237, 251, 0.18), 0 0 24px rgba(143, 237, 251, 0.12);
}

.choice__key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  flex-shrink: 0;
  transition: background var(--transition-base), color var(--transition-base);
}

.choice:hover .choice__key {
  background: rgba(143, 237, 251, 0.12);
  color: var(--accent-secondary);
  border-color: rgba(143, 237, 251, 0.3);
}

.choice.is-selected .choice__key {
  background: var(--accent-gradient);
  color: #0A0A0F;
  border-color: transparent;
}

.choice__label {
  flex: 1;
  line-height: 1.4;
}

/* Multi-select: show checkmark on selected */
.choices--multi .choice.is-selected::after {
  content: '✓';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  background: var(--accent-gradient);
  color: #0A0A0F;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.choices--multi .choice.is-selected {
  padding-right: 48px;
}

/* ============== BUTTONS (extra variants) ============== */
.btn__check {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.9em;
  opacity: 0.7;
}

.btn--ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 10px 22px;
  border-radius: 99px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--fs-sm);
  transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base);
}
.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.18);
}

/* ============== BOTTOM NAVIGATION ============== */
.form-nav {
  position: absolute;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 10;
  display: flex;
  background: rgba(15, 18, 26, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.form-nav__btn {
  width: 42px;
  height: 38px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-base);
  position: relative;
}

.form-nav__btn:hover:not(:disabled) {
  background: rgba(143, 237, 251, 0.08);
}
.form-nav__btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.form-nav__btn + .form-nav__btn {
  border-left: 1px solid var(--border);
}

.form-nav__arrow {
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
}

.form-nav__arrow--up {
  border-width: 0 6px 8px 6px;
  border-color: transparent transparent var(--text-secondary) transparent;
}
.form-nav__arrow--down {
  border-width: 8px 6px 0 6px;
  border-color: var(--text-secondary) transparent transparent transparent;
}
.form-nav__btn:hover:not(:disabled) .form-nav__arrow--up { border-bottom-color: var(--accent-secondary); }
.form-nav__btn:hover:not(:disabled) .form-nav__arrow--down { border-top-color: var(--accent-secondary); }

/* ============== REVIEW SLIDE ============== */
.review {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: var(--space-md) 0;
}

.review__item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-base), border-color var(--transition-base);
}

.review__item:hover {
  background: var(--surface-hover);
  border-color: rgba(143, 237, 251, 0.25);
}

.review__q {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.review__a {
  font-size: var(--fs-base);
  color: var(--text-primary);
  font-weight: 500;
  line-height: 1.4;
  word-break: break-word;
}

.review__a--empty {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
}

/* ============== SUCCESS SLIDE ============== */
.slide--success .slide__inner {
  align-items: center;
  text-align: center;
  gap: var(--space-xl);
}

.success__check {
  position: relative;
  width: 88px;
  height: 88px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 4px;
  animation: success-pop 600ms cubic-bezier(0.16, 1, 0.3, 1);
}

.success__check span {
  background: var(--accent-gradient);
  border-radius: 4px;
  box-shadow: 0 0 24px rgba(143, 237, 251, 0.3);
  animation: success-pixel 800ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
}
.success__check span:nth-child(1) { animation-delay: 0ms; }
.success__check span:nth-child(2) { animation-delay: 100ms; }
.success__check span:nth-child(3) { animation-delay: 200ms; }
.success__check span:nth-child(4) { animation-delay: 300ms; }

@keyframes success-pop {
  from { transform: scale(0.5); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes success-pixel {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ============== RESPONSIVE (mobile) ============== */
@media (max-width: 720px) {
  /* Topbar: respect notch */
  .form-topbar {
    padding: var(--space-sm) var(--space-md);
    padding-top: max(var(--space-sm), env(safe-area-inset-top));
    gap: var(--space-sm);
  }
  .form-topbar__brand {
    font-size: var(--fs-xs);
  }
  .form-topbar__logo-text {
    display: none;
  }

  /* SLIDE LAYOUT — the key mobile fix:
     'safe center' centralizes vertically when content fits, but falls
     back to flex-start when it overflows (preventing top cut-off).
     This keeps the input/button within thumb's reach on short forms
     while still allowing scroll on longer ones. */
  .slide {
    padding: var(--space-md) var(--space-md);
    padding-bottom: calc(var(--space-3xl) + env(safe-area-inset-bottom, 0px));
    align-items: safe center;
  }

  .slide__inner {
    gap: var(--space-md);
    width: 100%;
  }

  /* Tighter typography so dense slides (intro, review) actually fit
     in a small mobile viewport without the OK button being below the fold. */
  .slide__title {
    font-size: clamp(1.375rem, 3.5vw + 0.75rem, 1.875rem);
    line-height: 1.2;
  }
  .slide__question {
    font-size: clamp(1.25rem, 3vw + 0.7rem, 1.625rem);
    line-height: 1.25;
  }
  .slide__desc {
    font-size: var(--fs-base);
    line-height: 1.5;
  }
  .slide__sub {
    font-size: var(--fs-sm);
  }
  .slide__badge {
    padding: 5px 12px;
  }

  /* Bottom nav: respect home indicator */
  .form-nav {
    bottom: max(var(--space-md), env(safe-area-inset-bottom));
    right: var(--space-md);
  }

  .field__input {
    font-size: 1.125rem;
  }
  .field__input--textarea {
    min-height: 96px;
  }
  .field__prefix {
    font-size: var(--fs-lg);
  }

  .choice {
    padding: 12px 14px;
    font-size: var(--fs-sm);
  }
  .choices--multi .choice.is-selected {
    padding-right: 44px;
  }

  /* Auto-focus inputs cause iOS to zoom if font-size < 16px. We use 1.125rem
     (18px) above which prevents zoom. Also disable user-zoom in dialog only. */
}

@media (max-width: 480px) {
  .slide__actions {
    width: 100%;
  }
  .slide__hint {
    width: 100%;
  }
}

/* ============== SUBMITTING STATE ============== */
.btn.is-loading {
  pointer-events: none;
  opacity: 0.7;
  position: relative;
}
.btn.is-loading::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============== REDUCED MOTION ============== */
@media (prefers-reduced-motion: reduce) {
  .slide,
  .form-topbar__progress-bar,
  .choice,
  .field,
  .success__check,
  .success__check span,
  .inscricao-dialog,
  .inscricao-dialog::backdrop {
    transition: none !important;
    animation: none !important;
  }
}

/* ================================================================
   DIALOG (modal) MODE
   ================================================================ */
.inscricao-dialog {
  /* Reset default <dialog> styles */
  padding: 0;
  border: none;
  outline: none;
  margin: auto;          /* native dialog centers via margin: auto */
  color: var(--text-primary);

  /* Sizing — desktop */
  width: min(880px, 92vw);
  height: min(840px, 90vh);
  max-width: none;
  max-height: none;

  /* Surface */
  background: transparent;
  border-radius: var(--radius-xl);
  overflow: visible;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 255, 255, 0.04);

  /* Animation: JS adds .is-opening before showModal for one frame, then
     removes it so the transition runs to the open state. .is-closing is
     added before close(). @starting-style + allow-discrete proved
     unreliable in Chromium for transformed dialogs. */
  opacity: 1;
  transform: scale(1) translateY(0);
  transition:
    opacity 240ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 240ms cubic-bezier(0.16, 1, 0.3, 1);
}

.inscricao-dialog .form-shell {
  border-radius: inherit;
  height: 100%;
  width: 100%;
}

/* Backdrop */
.inscricao-dialog::backdrop {
  background: rgba(5, 6, 10, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 1;
  transition: opacity 240ms ease;
}

/* Entrance/closing states (driven by JS class toggles) */
.inscricao-dialog.is-opening,
.inscricao-dialog.is-closing {
  opacity: 0;
  transform: scale(0.96) translateY(20px);
}
.inscricao-dialog.is-opening::backdrop,
.inscricao-dialog.is-closing::backdrop {
  opacity: 0;
}

/* Body scroll lock while a dialog is open */
body.has-dialog-open {
  overflow: hidden;
}

/* ============== DIALOG MOBILE (full-screen sheet) ============== */
@media (max-width: 720px) {
  .inscricao-dialog {
    /* !important needed: the UA stylesheet for native <dialog> in
       top-layer (after showModal) re-asserts position/margin in a way
       that overrode our rules in Chromium, leaving the dialog off-screen
       at y=-448. Forcing the values fixes the bug across Chromium and iOS Safari. */
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    border-radius: 0;
    margin: 0 !important;
    box-shadow: none;
  }

  /* Mobile dialog state. Use a keyframe animation for the slide-up
     entrance — keyframes are far more reliable than CSS transitions
     across browsers and rendering modes (transitions on transformed
     dialogs in the top-layer left the dialog stuck off-screen). */
  .inscricao-dialog {
    transform: translateY(0) !important;
    opacity: 1 !important;
    animation: dialog-slide-up 280ms cubic-bezier(0.16, 1, 0.3, 1);
  }
  .inscricao-dialog.is-closing {
    animation: dialog-slide-down 240ms ease forwards;
  }
}

@keyframes dialog-slide-up {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes dialog-slide-down {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(100%); opacity: 0; }
}
