/* Dirección C · «Invitación»: tokens, tipografía, botones, campos y hojas comunes a la página,
   la compra y la sala. La página es papel crema con tinta cálida; la sala (room.css) redefine los
   tokens en tonos café oscuros. Contrastes comprobados (AA): tinta/papel 14:1, tinta suave 6,3:1,
   terracota de texto 5,9:1, texto claro sobre botón terracota 5,7:1. */

:root {
  --paper: #f5eee3;
  --paper-2: #ede3d3;
  --paper-3: #fbf7f0;
  --ink: #271e18;
  --ink-2: #62544a;
  --rule: #d9cbb6;
  --rule-strong: #b9a68c;
  --terra: #a6461f;
  --terra-ink: #9a3f1b;
  --terra-press: #8a3818;
  --on-terra: #fff8f0;
  --ok: #3f6b3a;
  --error: #a3271a;
  --focus: #a6461f;

  --serif: "Fraunces Variable", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter Variable", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --script: "Mrs Saint Delafield", "Snell Roundhand", cursive;

  --gutter: 20px;
  --measure: 34rem;
  --radius: 12px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 17px/1.55 var(--serif);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, video { max-width: 100%; height: auto; display: block; }
a { color: var(--terra-ink); text-decoration-thickness: 1px; text-underline-offset: .18em; }
h1, h2, h3 { margin: 0; font-weight: 500; line-height: 1.12; text-wrap: balance; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
small { font-size: inherit; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
.help { font: 400 .875rem/1.45 var(--sans); color: var(--ink-2); }
.error { font: 500 .9rem/1.4 var(--sans); color: var(--error); }
.error:empty { display: none; }

/* Firma manuscrita (fuente autoalojada; es texto, no imagen) */
.signature {
  font: 400 3.4rem/1 var(--script); color: var(--ink);
  margin: .1rem 0 0 -.1rem; letter-spacing: .01em;
  transform: rotate(-4deg); transform-origin: left center;
}
.signature-small { font-size: 2.6rem; }

/* Marca de simulación (común), con el estilo de la dirección */
.sim-mark {
  display: inline-block; font: 500 .7rem/1.5 var(--sans); letter-spacing: .02em;
  padding: 0 .5rem; border-radius: 99px; border: 1px dashed currentColor;
  color: var(--ink-2); vertical-align: .1em; white-space: nowrap;
}

/* ---------------------------------------------------------------- botones */
.btn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: .7rem 1.15rem; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: var(--ink);
  font: 600 1rem/1.2 var(--sans); letter-spacing: -.005em;
  text-decoration: none; text-align: center; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .12s ease, box-shadow .18s ease;
}
.btn:active { transform: scale(.985); }
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--terra); color: var(--on-terra); box-shadow: 0 1px 0 rgb(255 255 255 / .18) inset, 0 6px 16px -10px rgb(122 45 15 / .9); }
.btn-primary:hover { background: var(--terra-press); }
.btn-primary:active { background: var(--terra-press); }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn-secondary:active { background: var(--paper-2); }
.btn-quiet { background: transparent; color: var(--terra-ink); border-color: transparent; padding-inline: .6rem; }
.btn-quiet:active { background: var(--paper-2); }
.btn-small { min-height: 44px; padding: .45rem .9rem; font-size: .92rem; }
.btn-compact { min-height: 44px; padding: .55rem 1rem; font-size: .95rem; }
.btn-wallet { background: #000; color: #fff; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: default; transform: none; box-shadow: none; }
.btn:focus-visible { outline-offset: 3px; border-radius: 999px; }

/* Cargando: htmx pone aria-busy en el formulario y desactiva los botones */
.btn-busy { display: none; width: 1.05em; height: 1.05em; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: c-spin .8s linear infinite; }
form[aria-busy="true"] .btn-busy, form.htmx-request .btn-busy { display: inline-block; }
@keyframes c-spin { to { transform: rotate(360deg); } }

.choice { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }

/* ---------------------------------------------------------------- campos */
.field { display: grid; gap: .35rem; margin-bottom: 1rem; }
.field label, .lobby-form label { font: 600 .92rem/1.3 var(--sans); }
input[type="email"], input[type="text"], textarea {
  font: 400 1.0625rem/1.4 var(--sans); width: 100%; min-height: 50px; padding: .7rem .9rem;
  border: 1px solid var(--rule-strong); border-radius: 12px; background: var(--paper-3); color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type="email"]:focus, input[type="text"]:focus, textarea:focus {
  outline: none; border-color: var(--terra); box-shadow: 0 0 0 3px rgb(166 70 31 / .18);
}
input::placeholder, textarea::placeholder { color: #8a7a6c; }
.has-error input { border-color: var(--error); }
.field-check { grid-template-columns: auto 1fr; align-items: center; column-gap: .75rem; min-height: 44px; }
.field-check label { font-weight: 500; cursor: pointer; }
.field-check input {
  appearance: none; -webkit-appearance: none; margin: 0; width: 26px; height: 26px; flex: none;
  border: 1.5px solid var(--rule-strong); border-radius: 7px; background: var(--paper-3);
  display: grid; place-items: center; cursor: pointer;
}
.field-check input::after {
  content: ""; width: 12px; height: 7px; border: solid var(--on-terra); border-width: 0 0 2.2px 2.2px;
  transform: translateY(-2px) rotate(-45deg) scale(0); transition: transform .15s var(--ease);
}
.field-check input:checked { background: var(--terra); border-color: var(--terra); }
.field-check input:checked::after { transform: translateY(-2px) rotate(-45deg) scale(1); }
.field-check .error { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- hojas (dialog) */
.sheet-dialog {
  margin: auto auto 0; padding: 0; border: 0; width: 100%; max-width: 560px;
  max-height: 92dvh; border-radius: 22px 22px 0 0;
  background: var(--paper); color: var(--ink);
  box-shadow: 0 -12px 40px rgb(39 30 24 / .25);
  overscroll-behavior: contain;
}
.sheet-dialog::backdrop { background: rgb(31 22 16 / .5); }
.sheet-dialog[open] { animation: c-sheet-in .32s var(--ease); }
.sheet-dialog[open]::backdrop { animation: c-fade-in .25s ease; }
@keyframes c-sheet-in { from { transform: translateY(48px); } }
@keyframes c-fade-in { from { opacity: 0; } }
.sheet { padding: .5rem var(--gutter) calc(1.25rem + env(safe-area-inset-bottom)); }
.sheet-grip { width: 40px; height: 4px; border-radius: 4px; background: var(--rule); margin: 0 auto .9rem; }
.sheet-head { display: flex; align-items: flex-start; gap: .8rem; margin-bottom: 1.1rem; }
.sheet-head-text { flex: 1; min-width: 0; }
.sheet-head h2 { font: 500 1.5rem/1.15 var(--serif); letter-spacing: -.01em; }
.sheet-avatar { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; flex: none; }
.sheet-kicker { font: 600 .75rem/1.3 var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); margin-bottom: .2rem; }
.sheet-kicker-serif { font: italic 400 .98rem/1.35 var(--serif); letter-spacing: 0; text-transform: none; }
.sheet-summary { font: 400 .9rem/1.45 var(--sans); color: var(--ink-2); margin-top: .3rem; }
.sheet-close {
  flex: none; width: 44px; height: 44px; margin: -4px -8px 0 0; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--ink); cursor: pointer; text-decoration: none;
}
.sheet-close:active { background: var(--paper-2); }

/* Garantía: escudo pequeño + frase tranquila */
.guarantee { display: flex; gap: .55rem; align-items: flex-start; font: 500 .95rem/1.45 var(--sans); color: var(--ok); }
.guarantee-icon { flex: none; margin-top: .05rem; }
.guarantee-small { font-size: .875rem; }

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