/* David Parra Trainer · Manual de identidad visual v1.0 */
:root {
  --bg-dark: #111111;
  --bg-light: #FAF8F3;
  --accent: #A6C615;
  --accent-dark: #5B6C0B;
  --accent-hover: #96b213;
  --card-hover-bg: #f3f1ea;
  --error: #B3261E;
  --error-on-dark: #FF8A80;
  --input-bg: #FFFFFF;
  --line-field: rgba(17, 17, 17, .2);
  --radius-sm: 2px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ancho: 600px;
  --margen: 20px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent; /* cada control tiene su propio :active */
  overscroll-behavior-y: none; /* sin "tirar para recargar" a mitad del formulario */
  background: var(--bg-dark);
}

/* Dos temas con las mismas variables: oscuro (inicio y final) y claro (preguntas). */
body {
  --fondo: var(--bg-dark);
  --texto: var(--bg-light);
  --texto-2: rgba(250, 248, 243, .72);
  --borde: rgba(250, 248, 243, .33);
  --ceja: var(--accent);
  --foco: var(--accent);
  --color-error: var(--error-on-dark);
  color-scheme: dark;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overscroll-behavior-y: none;
  background: var(--fondo);
  color: var(--texto);
  font-family: -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
body.claro {
  --fondo: var(--bg-light);
  --texto: var(--bg-dark);
  --texto-2: rgba(17, 17, 17, .72);
  --borde: var(--line-field);
  --ceja: var(--accent-dark);
  --foco: var(--accent-dark);
  --color-error: var(--error);
  color-scheme: light;
}

::selection { background: var(--accent); color: var(--bg-dark); }
:focus-visible { outline: 2px solid var(--foco); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; }

.caja {
  width: 100%;
  max-width: var(--ancho);
  margin: 0 auto;
  padding-left: var(--margen);
  padding-right: var(--margen);
  padding-left: max(var(--margen), env(safe-area-inset-left));
  padding-right: max(var(--margen), env(safe-area-inset-right));
}
/* overflow-x: la pregunta entra desplazada de lado y no debe crear scroll horizontal. */
main { flex: 1; padding-top: 32px; padding-bottom: calc(40px + env(safe-area-inset-bottom)); overflow-x: hidden; overflow-x: clip; overflow-wrap: anywhere; }

/* ---------- Cabecera ---------- */
.cabecera { position: sticky; top: 0; z-index: 10; padding-top: env(safe-area-inset-top); background: var(--bg-dark); color: var(--bg-light); -webkit-user-select: none; user-select: none; }
.cabecera-fila { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; }
.logo { display: inline-flex; align-items: center; gap: 10px; }
.logo-punto { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
/* Es el logotipo: no se parte en dos líneas aunque se use la letra muy grande. */
.logo-texto { font-size: 1.0625rem; font-size: min(1.0625rem, 5.4vw); font-weight: 700; white-space: nowrap; text-transform: uppercase; letter-spacing: .06em; }
.contador { flex: none; font-size: .8125rem; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.avance { height: 4px; overflow: hidden; background: rgba(250, 248, 243, .14); }
.avance-relleno { height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .38s var(--ease-out); }

/* ---------- Texto ---------- */
.pantalla { animation: entrar .38s var(--ease-out); }
@keyframes entrar { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.ceja { margin: 0 0 12px; font-size: .8125rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ceja); }
h1 { margin: 0 0 16px; font-size: clamp(1.625rem, 1.2rem + 2vw, 2.125rem); line-height: 1.15; font-weight: 700; text-wrap: balance; }
p { margin: 0 0 16px; text-wrap: pretty; }
.entradilla { font-size: 1.125rem; }
.ayuda, .nota { color: var(--texto-2); }
.ayuda { white-space: pre-line; } /* algunas ayudas tienen dos párrafos */
.nota { font-size: .875rem; margin: 24px 0 0; }

/* ---------- Pregunta ---------- */
#contenido::before { content: ""; display: block; width: 40px; height: 3px; margin-bottom: 16px; background: var(--accent); }
/* Respuesta a lo que acabas de contestar: frase normal, no etiqueta en mayúsculas. */
.previo { margin: 0 0 8px; font-weight: 700; color: var(--ceja); }

/* ---------- Campos ---------- */
.campo {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  background: var(--input-bg);
  color: var(--bg-dark);
  color-scheme: light;
  caret-color: var(--accent-dark);
  border: 1px solid var(--line-field);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 1.0625rem;
  font-size: max(16px, 1.0625rem); /* por debajo de 16px iOS hace zoom al escribir */
  touch-action: manipulation;
  transition: border-color .16s ease;
}
textarea.campo { min-height: 128px; resize: vertical; }
.campo[aria-invalid="true"] { border-color: var(--error); box-shadow: 0 0 0 1px var(--error); }
.campo[aria-invalid="true"]:focus-visible { outline-color: var(--color-error); }
.error { margin: 12px 0 0; font-size: .875rem; font-weight: 700; color: var(--color-error); }
.quedan { margin: 8px 0 0; font-size: .875rem; text-align: right; color: var(--texto-2); font-variant-numeric: tabular-nums; }
.quedan:empty { display: none; }

/* ---------- Controles ---------- */
.opcion, .boton, .enlace {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ---------- Opciones y escalas ---------- */
.opciones { display: grid; gap: 12px; margin-top: 8px; }
.escala { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.opcion {
  min-height: 56px;
  padding: 14px 16px;
  background: var(--input-bg);
  color: var(--bg-dark);
  border: 1px solid var(--line-field);
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .1s var(--ease-out);
}
.opciones .opcion { text-align: left; line-height: 1.4; }
/* Contestar "no" sin escribir: debajo del campo, a todo el ancho. */
.atajo { display: block; width: 100%; margin-top: 12px; }
.escala .opcion { padding: 0; font-size: 1.125rem; }
.opcion:active { transform: scale(.97); }
.opcion[aria-pressed="false"]:active { background: var(--card-hover-bg); border-color: var(--bg-dark); }
.opcion[aria-pressed="true"] { background: var(--bg-dark); border-color: var(--bg-dark); color: var(--bg-light); }
@media (hover: hover) and (pointer: fine) { .opcion[aria-pressed="false"]:hover { background: var(--card-hover-bg); border-color: var(--bg-dark); } }
.extremos { display: flex; justify-content: space-between; gap: 16px; margin: 10px 0 0; font-size: .875rem; line-height: 1.4; color: var(--texto-2); }
.extremos span:last-child { text-align: right; }

/* ---------- Botones ---------- */
.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 14px 30px;
  background: var(--accent);
  color: var(--bg-dark);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .9375rem;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, opacity .16s ease, transform .1s var(--ease-out);
}
.boton:active { transform: scale(.97); background: var(--accent-hover); border-color: var(--accent-hover); }
.boton:disabled { opacity: .5; cursor: default; transform: none; }
@media (hover: hover) and (pointer: fine) { .boton:not(:disabled):hover { background: var(--accent-hover); border-color: var(--accent-hover); } }
/* Esperando a n8n: no es un botón apagado, así que se lee entero y late el punto de la marca. */
.boton[aria-busy="true"] { opacity: 1; cursor: progress; }
.boton[aria-busy="true"]::before { content: ""; width: 8px; height: 8px; margin-right: 10px; border-radius: 50%; background: currentColor; animation: latido .7s ease-in-out infinite alternate; }
@keyframes latido { from { opacity: 1; } to { opacity: .2; } }
.boton-ancho { width: 100%; margin-top: 24px; }
.boton-secundario { background: transparent; color: var(--texto); border-color: var(--borde); padding-left: 22px; padding-right: 22px; }
.boton-secundario:active { background: var(--card-hover-bg); border-color: var(--bg-dark); }
@media (hover: hover) and (pointer: fine) { .boton-secundario:not(:disabled):hover { background: var(--card-hover-bg); border-color: var(--bg-dark); } }
.acciones { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.acciones .boton[type="submit"] { flex: 1 1 9rem; }

.enlace { min-height: 44px; padding: 0 2px; background: none; border: 0; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; transition: opacity .16s ease; }
.enlace:active { opacity: .6; }

/* ---------- Pie fijo de la bienvenida: el botón siempre a mano aunque el texto no quepa ---------- */
.pie { position: sticky; bottom: 0; margin-top: 8px; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); background: var(--fondo); }
.pie::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 24px; background: linear-gradient(rgba(17, 17, 17, 0), var(--bg-dark)); pointer-events: none; }
.pie .boton-ancho { margin-top: 0; }
#pantalla-inicio { animation-name: aparecer; } /* una transformación aquí dejaría el pie descolocado durante la entrada */
@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Avisos y final ---------- */
.aviso { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; column-gap: 16px; margin: 0 0 24px; padding: 4px 14px; background: rgba(166, 198, 21, .14); border: 1px solid var(--accent-dark); border-radius: var(--radius-sm); font-size: .875rem; }
.aviso-error { background: transparent; border-color: var(--color-error); color: var(--color-error); padding: 14px; }
.resultado { position: relative; padding-top: 32px; }
.resultado::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--accent); transform-origin: left; animation: trazar .6s var(--ease-out) .15s both; }
@keyframes trazar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
#espera:empty { display: none; }

@media (max-width: 359px) {
  :root { --margen: 16px; }
  .escala { gap: 6px; }
}

/* Teléfono apaisado: un pie fijo se comería la mitad de la pantalla. */
@media (max-height: 480px) {
  .pie { position: static; }
  .pie::before { display: none; }
}

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