/*
 * Formulário "Abrir minha conta" (30/09/2026). CSS do handoff do Claude Design (site/lead-lightbox/handoff-claude-design),
 * com três trocas: o fundo é o próprio <dialog class="ll-modal"> (::backdrop escurece e desfoca), o cartão é .ll-card
 * (era .ll-dialog) e existe o modo embutido .ll-inline (card da /abrir-conta, sem pop e sem bottom sheet).
 * Tokens e classes .it-field / .it-btn do DS 2.0 (assets/tokens.css e assets/bundle.css). Bottom sheet abaixo de 640px.
 */

/* ---------- pop: <dialog> ocupa a tela e rola; o cartão fica no centro ---------- */
.ll-modal {
  --ll-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: var(--space-6);
  border: 0;
  background: transparent;
  color: var(--text);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.ll-modal[open] { display: flex; }
.ll-modal::backdrop {
  background: rgba(10, 10, 10, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: ll-fade 250ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
html.ll-lock, html.ll-lock body { overflow: hidden; }

.ll-card {
  --ll-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  box-sizing: border-box;
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: auto;
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  color: var(--text);
  font-family: var(--font-sans);
  text-align: left;
}
.ll-modal[open] .ll-card { animation: ll-rise 250ms var(--ll-ease); }
.ll-card *, .ll-card *::before, .ll-card *::after { box-sizing: border-box; }
/* o DS usa display:flex em .it-field; hidden precisa vencer */
.ll-card [hidden] { display: none !important; }
.ll-handle { display: none; }
.ll-step { display: flex; flex-direction: column; gap: var(--space-6); }

/* ---------- embutido na /abrir-conta ---------- */
.ll-inline { min-width: 0; }
.ll-inline .ll-card { max-width: none; margin: 0; }
.ll-inline .ll-close { display: none; }

/* ---------- cabeçalho ---------- */
.ll-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); }
.ll-head__text { display: flex; flex-direction: column; gap: var(--space-3); }
/* .ll-card .ll-title vence o h2 da base e o .lp main h2 do abrir-conta (títulos de dobra de 80px) */
.ll-card .ll-title {
  margin: 0; max-width: none;
  font-size: 28px; line-height: 32px; font-weight: 500; letter-spacing: -0.01em;
  text-transform: none; color: var(--text);
}
/* destaque no mesmo peso do título (preferência do Paulo; o handoff usava 300) */
.ll-title__light { font-weight: inherit; color: var(--accent); }
.ll-subtitle { margin: 0; font-size: 16px; line-height: 24px; color: var(--text-2); }

.ll-close {
  width: 40px; height: 40px; flex: none;
  margin: -8px -8px 0 0; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--radius-md);
  background: transparent; color: var(--text);
  cursor: pointer;
  transition: background-color 150ms var(--ll-ease);
}
.ll-close:hover { background: var(--surface-2); }
.ll-close:disabled { opacity: 0.4; cursor: not-allowed; }

.ll-close:focus-visible,
.ll-select__box:focus-visible,
.ll-sr:focus-visible + .ll-radio__mark,
.ll-legal a:focus-visible,
.ll-skip:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ---------- formulário ---------- */
.ll-form { margin: 0; display: flex; flex-direction: column; gap: var(--space-4); }
.ll-form .it-field { min-width: 0; }
.ll-form .it-field__box input { width: 100%; }

/* ---------- seletores (momento e faixa) ---------- */
.ll-select { position: relative; }
.ll-select__box {
  width: 100%;
  justify-content: space-between;
  font: inherit;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.ll-select__box:hover { border-color: var(--text-2); }
.ll-select__box.is-open { border-color: var(--focus-ring); }
.it-field--error .ll-select__box { border-color: var(--danger); }
.ll-select__value {
  flex: 1; min-width: 0;
  font-size: 16px; line-height: 24px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ll-select__value.is-placeholder { color: var(--text-2); }
.ll-select__chevron { flex: none; color: var(--text-2); transition: transform 250ms var(--ll-ease); }
.ll-select__box.is-open .ll-select__chevron { transform: rotate(180deg); }

/* top/bottom do painel saem do JS (medidos na caixa), para valer também com a mensagem de erro aberta */
.ll-select__panel {
  position: absolute;
  left: 0; right: 0;
  z-index: 10;
  max-height: min(320px, 60vh);
  overflow-y: auto;
  padding: var(--space-2);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  animation: ll-pop 150ms var(--ll-ease);
}

.ll-select__group { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.ll-select__group + .ll-select__group { margin-top: var(--space-1); padding-top: var(--space-1); border-top: 1px solid var(--border); }
.ll-select__option {
  min-height: 48px;
  padding: var(--space-3);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 16px; line-height: 24px;
  color: var(--text);
  cursor: pointer;
  transition: background-color 150ms var(--ll-ease);
}
.ll-select__option.is-active { background: var(--surface-3); }
.ll-select__option[aria-selected="true"] { font-weight: 500; }
.ll-select__option svg { flex: none; color: var(--accent); }
.ll-select__option:not([aria-selected="true"]) svg { display: none; }

/* ---------- "Já é cliente XP?" ---------- */
.ll-xp { display: flex; flex-direction: column; gap: var(--space-2); }
.ll-xp__row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.ll-xp__label { font-size: 14px; line-height: 20px; color: var(--text-2); }
.ll-xp__options { display: flex; gap: var(--space-5); }
.ll-radio {
  display: flex; align-items: center; gap: var(--space-2);
  min-height: 44px;
  font-size: 14px; line-height: 20px;
  color: var(--text);
  cursor: pointer;
}
.ll-radio__mark {
  width: 18px; height: 18px; flex: none;
  display: grid; place-items: center;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-pill);
  transition: border-color 150ms var(--ll-ease);
}
.ll-radio__mark::after {
  content: "";
  width: 8px; height: 8px;
  border-radius: var(--radius-pill);
  background: var(--itera-yellow);
  transform: scale(0);
  transition: transform 150ms var(--ll-ease);
}
.ll-sr:checked + .ll-radio__mark { border-color: var(--itera-yellow); }
.ll-sr:checked + .ll-radio__mark::after { transform: scale(1); }
.ll-xp.is-error .ll-radio__mark { border-color: var(--danger); }
.ll-xp.is-error .ll-xp__help { color: var(--danger); }
.ll-xp__help { text-align: right; }

/* tema claro do DS: amarelo nunca sobre fundo claro */
[data-theme="light"] .ll-sr:checked + .ll-radio__mark { border-color: var(--deep-black); }
[data-theme="light"] .ll-radio__mark::after { background: var(--deep-black); }

.ll-sr {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.ll-honey { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- ação, falha e texto legal ---------- */
.ll-actions { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-2); }
.ll-cta { width: 100%; text-decoration: none; font-weight: 600; }
.ll-send-error { margin: 0; font-size: 14px; line-height: 20px; color: var(--danger); }
.ll-skip {
  align-self: center;
  font-size: 14px; line-height: 20px;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.ll-skip:hover { color: var(--accent); }
.ll-legal { margin: 0; font-size: 12px; line-height: 16px; color: var(--text-2); }
.ll-legal a { color: var(--accent); }
.ll-legal a:hover { color: var(--yellow-300); }

/* ---------- transição "Levando você ao cadastro da XP" ---------- */
.ll-success {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--success);
  border-radius: var(--radius-pill);
  color: var(--success);
}
.ll-progress { display: flex; flex-direction: column; gap: var(--space-2); }
.ll-progress__track { height: 4px; border-radius: var(--radius-pill); background: var(--surface-3); overflow: hidden; }
.ll-progress__bar {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
}
.ll-progress__bar.is-running {
  animation-name: ll-bar;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
.ll-progress__text { font-size: 12px; line-height: 16px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------- celular: o pop vira bottom sheet; o card embutido só aperta o espaçamento ---------- */
@media (max-width: 639px) {
  .ll-modal { padding: var(--space-6) 0 0; }
  .ll-modal .ll-card {
    max-width: none;
    margin: auto 0 0;
    padding: var(--space-3) var(--space-5) calc(var(--space-8) + env(safe-area-inset-bottom, 0px));
    gap: var(--space-5);
    border-width: 1px 0 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
  .ll-modal[open] .ll-card { animation-name: ll-sheet; }
  /* ao focar um campo, o sheet ocupa a tela inteira; o fundo rola se o teclado apertar */
  .ll-modal .ll-card.is-expanded { min-height: calc(100dvh - var(--space-6)); }
  .ll-modal .ll-handle {
    display: block;
    width: 36px; height: 4px;
    margin: 0 auto calc(-1 * var(--space-2));
    border-radius: var(--radius-pill);
    background: var(--border-strong);
  }
  .ll-inline .ll-card { padding: var(--space-6) var(--space-5); gap: var(--space-5); }
  .ll-step { gap: var(--space-5); }
  .ll-head__text { gap: var(--space-2); }
  .ll-card .ll-title { font-size: 24px; line-height: 28px; }
  .ll-subtitle { font-size: 14px; line-height: 20px; }
  .ll-close { width: 44px; height: 44px; margin: -6px -10px 0 0; }
  .ll-form { gap: var(--space-3); }
  .ll-xp__row { gap: var(--space-3); }
  .ll-actions { gap: var(--space-3); margin-top: var(--space-2); }
}

@keyframes ll-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ll-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes ll-sheet { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes ll-pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes ll-bar { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (prefers-reduced-motion: reduce) {
  .ll-modal::backdrop, .ll-modal[open] .ll-card, .ll-select__panel { animation: none; }
  .ll-progress__bar.is-running { animation: none; transform: scaleX(1); }
  .ll-select__chevron, .ll-radio__mark, .ll-radio__mark::after, .ll-select__option, .ll-close { transition: none; }
}
