/* ============================================================
   Sistema visual — mobile-first, sin dependencias (RNF-3/4)
   ============================================================ */

:root {
  --tinta:        #2e2723;
  --tinta-suave:  #6d635c;
  --tinta-tenue:  #9a8f87;
  --papel:        #fbf8f6;
  --superficie:   #ffffff;
  --borde:        #e8e0da;
  --borde-fuerte: #d3c7bd;
  --acento:       #8c6f66;
  --acento-claro: #f3ebe7;
  --error:        #a4402f;
  --ok:           #3f7150;

  --r-chico:  8px;
  --r:        12px;
  --r-grande: 18px;

  --sombra: 0 1px 2px rgba(46, 39, 35, .04), 0 6px 20px rgba(46, 39, 35, .06);

  /* 44px es el mínimo táctil cómodo; en un form largo en el celular
     es la diferencia entre completarlo y abandonarlo. */
  --touch: 44px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  color: var(--tinta);
  background: var(--papel);
  -webkit-font-smoothing: antialiased;
}

/* ---------- contenedor ---------- */

.hoja {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1.25rem 1.15rem 4rem;
}

.hoja--centrada {
  min-height: 100dvh;
  display: grid;
  place-items: center;
}

/* ---------- portada ---------- */

.portada { padding: 1.5rem 0 .5rem; }

.portada__quien {
  margin: 0;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--acento);
}

.portada__titulo {
  margin: .3rem 0 .7rem;
  font-size: 1.9rem;
  font-weight: 650;
  letter-spacing: -.02em;
}

.portada__bajada {
  margin: 0 0 1rem;
  color: var(--tinta-suave);
  text-wrap: pretty;
}

.portada__privacidad {
  margin: 0;
  padding: .7rem .85rem;
  font-size: .88rem;
  color: var(--tinta-suave);
  background: var(--acento-claro);
  border-radius: var(--r-chico);
}

/* ---------- bloques ---------- */

.bloque {
  margin: 1.5rem 0;
  padding: 1.35rem 1.15rem;
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--r-grande);
  box-shadow: var(--sombra);
}

.bloque__titulo {
  margin: 0 0 .2rem;
  font-size: 1.12rem;
  font-weight: 640;
  letter-spacing: -.01em;
}

.bloque__ayuda {
  margin: .35rem 0 0;
  padding: .6rem .75rem;
  font-size: .86rem;
  line-height: 1.45;
  color: var(--tinta-suave);
  background: var(--acento-claro);
  border-radius: var(--r-chico);
  text-wrap: pretty;
}

/* ---------- campos ---------- */

.campo { margin-top: 1.4rem; }
.bloque__ayuda + .campo { margin-top: 1.1rem; }

.campo__label {
  display: block;
  margin-bottom: .3rem;
  font-size: .96rem;
  font-weight: 560;
  text-wrap: pretty;
}

.req { color: var(--acento); font-weight: 400; }

.campo__ayuda {
  margin: 0 0 .5rem;
  font-size: .83rem;
  line-height: 1.4;
  color: var(--tinta-tenue);
  text-wrap: pretty;
}

.campo__error {
  margin: .4rem 0 0;
  font-size: .84rem;
  font-weight: 550;
  color: var(--error);
}

.campo--error .control { border-color: var(--error); }

/* ---------- controles ---------- */

.control {
  width: 100%;
  min-height: var(--touch);
  padding: .6rem .75rem;
  font: inherit;
  font-size: 16px; /* <16px hace que iOS zoomee al enfocar. No bajar. */
  color: var(--tinta);
  background: var(--papel);
  border: 1.5px solid var(--borde-fuerte);
  border-radius: var(--r-chico);
  transition: border-color .12s, box-shadow .12s;
}

.control--area { min-height: 5rem; resize: vertical; line-height: 1.45; }

.control:focus-visible {
  outline: none;
  border-color: var(--acento);
  box-shadow: 0 0 0 3px var(--acento-claro);
}

/* ---------- opciones (radio / checkbox como targets grandes) ---------- */

.opciones { display: flex; flex-direction: column; gap: .45rem; }

.opciones--bool { flex-direction: row; }
.opciones--bool .opcion { flex: 1; justify-content: center; }

.opcion {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: var(--touch);
  padding: .55rem .8rem;
  background: var(--papel);
  border: 1.5px solid var(--borde-fuerte);
  border-radius: var(--r-chico);
  cursor: pointer;
  transition: background .12s, border-color .12s;
  -webkit-tap-highlight-color: transparent;
}

.opcion span { text-wrap: pretty; }

.opcion input { width: 1.15rem; height: 1.15rem; accent-color: var(--acento); flex: none; margin: 0; }

.opcion:has(input:checked) {
  background: var(--acento-claro);
  border-color: var(--acento);
  font-weight: 550;
}

.opcion:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--acento-claro); }

@media (hover: hover) {
  .opcion:hover { border-color: var(--acento); }
}

/* ---------- detalle condicional ---------- */

.detalle {
  margin-top: .55rem;
  padding-left: .85rem;
  border-left: 3px solid var(--acento-claro);
}

.detalle .campo { margin-top: .4rem; }
.detalle[hidden] { display: none; }

/* ---------- consentimiento ---------- */

.consent {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  padding: .85rem;
  background: var(--papel);
  border: 1.5px solid var(--borde-fuerte);
  border-radius: var(--r-chico);
  cursor: pointer;
}

.consent input { width: 1.25rem; height: 1.25rem; margin: .1rem 0 0; accent-color: var(--acento); flex: none; }
.consent__texto { font-size: .92rem; text-wrap: pretty; }
.consent__ayuda { display: block; margin-top: .25rem; font-size: .82rem; color: var(--tinta-tenue); }
.consent:has(input:checked) { background: var(--acento-claro); border-color: var(--acento); }

/* ---------- acciones ---------- */

.acciones { margin-top: 1.75rem; text-align: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: .8rem 1.5rem;
  font: inherit;
  font-size: 1.02rem;
  font-weight: 600;
  border: none;
  border-radius: var(--r);
  cursor: pointer;
  transition: transform .1s, filter .12s;
}

.btn--primario { color: #fff; background: var(--acento); box-shadow: var(--sombra); }
.btn--primario:active { transform: translateY(1px); filter: brightness(.94); }
.btn:focus-visible { outline: 3px solid var(--acento-claro); outline-offset: 2px; }

.acciones__nota { margin: .7rem 0 0; font-size: .84rem; color: var(--tinta-tenue); }

/* ---------- avisos ---------- */

.aviso {
  padding: 2rem 1.5rem;
  text-align: center;
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--r-grande);
  box-shadow: var(--sombra);
}

.aviso__titulo { margin: 0 0 .5rem; font-size: 1.25rem; }
.aviso__texto { margin: 0; color: var(--tinta-suave); }

/* ---------- barra de preview (solo debug) ---------- */

.preview-bar {
  margin-bottom: 1rem;
  padding: .6rem .85rem;
  font-size: .84rem;
  color: #6b4d18;
  background: #fdf3d8;
  border: 1px solid #f0dfae;
  border-radius: var(--r-chico);
}

/* ---------- compartido con el panel ---------- */

.login { width: 100%; max-width: 22rem; margin: 15vh auto 0; }

.alerta { padding: .7rem .9rem; margin: 0 0 1rem; border-radius: var(--r-chico); font-size: .92rem; }
.alerta--error { color: var(--error); background: #fbecea; border: 1px solid #f0cfc9; }
.alerta--ok    { color: var(--ok);    background: #eef5f0; border: 1px solid #cfe3d6; }

.link {
  padding: 0; font: inherit; font-size: .9rem; color: var(--acento);
  background: none; border: none; cursor: pointer; text-decoration: none;
}

.link:hover { text-decoration: underline; }
.link--riesgo { color: var(--error); }

.btn[disabled] { opacity: .5; cursor: not-allowed; }

select.control {
  appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='none' stroke='%236d635c' stroke-width='1.6' d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .7rem center;
}

.aviso--ok { border-color: #cfe3d6; }

.aviso__icono {
  display: grid; place-items: center; width: 3rem; height: 3rem;
  margin: 0 auto 1rem; border-radius: 50%;
  background: #eef5f0; color: var(--ok); font-size: 1.5rem; font-weight: 700;
}

.aviso__nota { margin: .8rem 0 0; font-size: .85rem; color: var(--tinta-tenue); }

/* El aviso solo (error / gracias) se centra vertical en la página pública. */
.publico .hoja > .aviso:only-child { margin-top: 12vh; }

/* ---------- restaurar borrador ---------- */

.restaurado {
  position: sticky;
  top: .6rem;
  z-index: 5;
  padding: .6rem .85rem;
  font-size: .86rem;
  color: var(--ok);
  background: #eef5f0;
  border: 1px solid #cfe3d6;
  border-radius: var(--r-chico);
}

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