/* ============================================================
   Ivanagro · Formulario de registro
   Tratamiento editorial de marca — compromiso deliberado con
   un único mundo visual (verde de marca sobre papel cálido),
   como una pieza impresa de identidad. Un solo tema, cuidado.
   ============================================================ */

:root {
  /* Color — verdes con sesgo de marca, neutros elegidos (no puros) */
  --forest:   #0E5C2A;   /* verde bosque del hero */
  --forest-2: #0A4A22;   /* sombra del hero */
  --green:    #1E9E3E;   /* verde de acción */
  --green-d:  #17812F;   /* hover */
  --lime:     #8DC63F;   /* acento */
  --lime-soft:#B7E27A;

  --ink:      #16211A;   /* casi negro con sesgo verde */
  --text:     #33413A;   /* cuerpo */
  --muted:    #6B7A6E;   /* secundario */
  --paper:    #FBFCF9;   /* fondo cálido con sesgo verde */
  --sage:     #EEF2EA;   /* superficie suave */
  --sage-2:   #E3EADD;
  --line:     #D8E0D2;   /* bordes */
  --white:    #FFFFFF;
  --danger:   #C0473B;

  --radius:   14px;
  --radius-s: 11px;
  --shadow-sm: 0 1px 2px rgba(22, 33, 26, 0.05);
  --shadow:    0 24px 60px -20px rgba(14, 92, 42, 0.28);
  --focus:     0 0 0 4px rgba(30, 158, 62, 0.20);

  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body:    "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--f-body);
  color: var(--text);
  background: var(--paper);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; }

/* ============================================================
   Eyebrow / etiquetas reutilizables
   ============================================================ */
.eyebrow {
  font-family: var(--f-display);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--green);
  margin: 0 0 12px;
}
.eyebrow--light { color: var(--lime-soft); }

.req { color: var(--green); font-weight: 700; }
.optional { color: var(--muted); font-weight: 500; letter-spacing: 0; text-transform: none; }

/* ============================================================
   Layout
   ============================================================ */
.layout {
  display: grid;
  grid-template-columns: 1.02fr 1fr;
  min-height: 100vh;
}

/* ---------- Hero (solo imagen + gradiente + partículas) ---------- */
.hero {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  background: var(--forest);
}

/* Imagen de marca centrada */
.hero__bg {
  position: absolute;
  inset: 0;
  background: var(--forest) url("assets/background.png") center center / cover no-repeat;
  animation: heroZoom 24s ease-in-out infinite alternate;
}

/* Gradiente verde refinado: viñeta + tinte de marca + brillo lima,
   suave para que la imagen se aprecie. */
.hero__scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(72% 55% at 50% 30%, rgba(141, 198, 63, 0.16) 0%, transparent 60%),
    linear-gradient(155deg,
      rgba(12, 84, 38, 0.80) 0%,
      rgba(9, 60, 29, 0.66) 45%,
      rgba(7, 40, 20, 0.88) 100%),
    radial-gradient(130% 112% at 50% 46%, transparent 44%, rgba(6, 30, 16, 0.86) 100%);
}

/* Canvas de partículas flotando */
.hero__particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

@keyframes heroZoom {
  from { transform: scale(1.04); }
  to   { transform: scale(1.12); }
}

/* ---------- Panel del formulario ---------- */
.panel {
  display: flex;
  justify-content: center;
  padding: clamp(40px, 5vw, 72px) clamp(24px, 4vw, 60px);
}
.panel__inner {
  width: 100%;
  max-width: 620px;
  animation: rise 0.7s 0.08s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Logo encima de la card: centrado, sin fondo, borde ni sombra */
.panel__logo {
  display: block;
  width: 234px;
  max-width: 72%;
  height: auto;
  margin: 0 auto 24px;
  background: none;
  border: none;
  box-shadow: none;
}

/* Card blanca con borde que contiene el formulario */
.form-card {
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: 20px;
  padding: clamp(24px, 3.2vw, 38px);
  box-shadow: var(--shadow);
}

.formhead { margin-bottom: 30px; }
.formhead .eyebrow { margin-bottom: -2px; }
.formhead h2 {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(1.7rem, 2.6vw, 2.1rem);
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 8px;
}
.formhead__sub { margin: 0; color: var(--muted); font-size: 0.96rem; }

/* ============================================================
   Secciones (fieldset)
   ============================================================ */
.section {
  border: none;
  margin: 0 0 26px;
  padding: 0;
}
.section__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--f-display);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
  padding: 0;
  margin-bottom: 16px;
}
.section__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px var(--sage);
}

/* ============================================================
   Campos
   ============================================================ */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.grid-2 .field { margin-bottom: 0; }   /* el gap + margin del grid dan el espacio */

.field label {
  display: block;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 7px;
}

/* Pista bajo un campo (ej. validación del teléfono) */
.hint {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}
.hint.is-ok { color: var(--green); font-weight: 600; }
.hint.is-bad { color: var(--danger); font-weight: 600; }

input[type="text"],
input[type="tel"],
input[type="email"],
select,
textarea {
  width: 100%;
  padding: 13px 15px;
  font-family: inherit;
  font-size: 0.98rem;
  color: var(--ink);
  background: var(--white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
  appearance: none;
}
input::placeholder,
textarea::placeholder { color: #9AA79C; }

textarea {
  resize: vertical;
  min-height: 92px;
  line-height: 1.5;
}

select {
  cursor: pointer;
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231E9E3E' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
}
select:required:invalid { color: #9AA79C; }

input:hover,
select:hover { border-color: #BFCBB7; }

input:focus,
select:focus {
  outline: none;
  border-color: var(--green);
  background: var(--white);
  box-shadow: var(--focus);
}

/* Estado de error (clase .invalid puesta por JS) */
.field.invalid input,
.field.invalid select {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(192, 71, 59, 0.14);
}

/* ---------- Teléfono con selector de indicativo ---------- */
.phone-input { display: flex; }
.dial {
  flex: 0 0 auto;
  width: auto;
  min-width: 96px;
  max-width: 118px;
  font-weight: 600;
  color: var(--ink);
  background-color: var(--sage);
  border-right: none;
  border-radius: var(--radius-s) 0 0 var(--radius-s);
  padding-left: 13px;
  padding-right: 30px;
}
.phone-input input {
  flex: 1;
  min-width: 0;
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
}
.dial:focus, .phone-input input:focus { position: relative; z-index: 1; }

/* ============================================================
   Autorización (checkbox)
   ============================================================ */
.field--check {
  margin: 6px 0 20px;
  background: var(--sage);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color 0.16s, background 0.16s;
}
.field--check:has(input:checked) {
  background: #EAF4E4;
  border-color: var(--lime);
}
/* .field--check .check gana en especificidad a `.field label { display:block }` */
.field--check .check {
  display: flex;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  margin: 0;
}
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check__box {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #9BAD90;
  border-radius: 6px;
  background: var(--white);
  color: var(--white);
  box-shadow: inset 0 1px 2px rgba(22, 33, 26, 0.06);
  transition: background 0.16s, border-color 0.16s, transform 0.12s;
}
.check__box svg { width: 13px; height: 13px; opacity: 0; transform: scale(0.5); transition: opacity 0.16s, transform 0.16s; }
.check:hover .check__box { border-color: var(--green); }
.check input:checked + .check__box {
  background: var(--green);
  border-color: var(--green);
  box-shadow: none;
}
.check input:checked + .check__box svg { opacity: 1; transform: scale(1); }
.check input:focus-visible + .check__box { box-shadow: var(--focus); }
.check__text { flex: 1; min-width: 0; font-size: 0.8rem; color: var(--text); line-height: 1.4; }
.field--check.invalid { border-color: var(--danger); background: #FBEEEC; }

/* ============================================================
   Mensaje de error general
   ============================================================ */
.form-error {
  margin: 0 0 16px;
  padding: 12px 15px;
  background: #FBEEEC;
  border: 1px solid rgba(192, 71, 59, 0.35);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-s);
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 600;
}

/* ============================================================
   Botón
   ============================================================ */
.btn {
  width: 100%;
  padding: 15px 22px;
  font-family: var(--f-display);
  font-size: 1.04rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--white);
  background: linear-gradient(180deg, var(--green) 0%, var(--green-d) 100%);
  border: none;
  border-radius: var(--radius-s);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 14px 26px -12px rgba(30, 158, 62, 0.7);
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 20px 32px -14px rgba(30, 158, 62, 0.8); filter: brightness(1.03); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: none; box-shadow: var(--focus), 0 14px 26px -12px rgba(30, 158, 62, 0.7); }
.btn__arrow { transition: transform 0.16s ease; }
.btn:hover .btn__arrow { transform: translateX(4px); }

/* Deshabilitado real (autorización sin marcar) */
.btn[disabled]:not(.is-loading) {
  background: #BFCEBA;
  color: #F2F6EF;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}
/* Estado cargando */
.btn.is-loading { cursor: progress; filter: saturate(0.9); transform: none; }
.btn.is-loading .btn__label { opacity: 0.85; }
.btn__spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn.is-loading .btn__spinner { display: inline-block; }

.panel__legal {
  margin: 16px 0 0;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
}
/* Ícono inline, al inicio de la frase, alineado con el texto */
.panel__legal-ico {
  display: inline-block;
  vertical-align: -2px;
  margin-right: 5px;
  color: var(--green);
}

/* ============================================================
   Pantalla de éxito
   ============================================================ */
.success {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(11, 40, 22, 0.55);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.28s ease;
}
.success[hidden] { display: none; }
.success.is-hiding { animation: fadeOut 0.35s ease forwards; }

.success__card {
  background: var(--white);
  border-radius: 22px;
  padding: 46px 44px;
  text-align: center;
  max-width: 410px;
  box-shadow: var(--shadow);
  animation: pop 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.success__card h2 {
  font-family: var(--f-display);
  margin: 20px 0 10px;
  font-size: 1.8rem;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.success__card p { margin: 0; color: var(--muted); }

.success__circle {
  stroke: var(--green);
  stroke-width: 2.5;
  stroke-dasharray: 151;
  stroke-dashoffset: 151;
  animation: drawCircle 0.5s ease forwards;
}
.success__tick {
  stroke: var(--green);
  stroke-width: 3.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 40;
  stroke-dashoffset: 40;
  animation: drawTick 0.35s 0.45s ease forwards;
}

/* ============================================================
   Animaciones
   ============================================================ */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes drawCircle { to { stroke-dashoffset: 0; } }
@keyframes drawTick { to { stroke-dashoffset: 0; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ============================================================
   Responsive
   ============================================================ */
/* ---- Tablet / móvil: enfoque total en el formulario ---- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; min-height: 0; }
  .hero { display: none; }               /* el logo + card toman el protagonismo */
  .panel {
    padding: 36px 20px 52px;
    background: var(--paper);
    min-height: 100vh;
    align-items: flex-start;
  }
  .panel__inner { max-width: 540px; }
  .panel__logo { width: 190px; max-width: 62%; }   /* tamaño previo en responsive */
}

/* ---- Celular ---- */
@media (max-width: 520px) {
  .grid-2 { grid-template-columns: 1fr; }  /* apila con gap 16 + margin-bottom */
  .panel { padding: 26px 16px 44px; }
  .panel__logo { width: 170px; max-width: 60%; margin-bottom: 18px; }
  .form-card { padding: 22px 18px; border-radius: 16px; }

  /* 16px evita el zoom automático de iOS al enfocar un campo */
  input[type="text"],
  input[type="tel"],
  input[type="email"],
  select,
  textarea { font-size: 16px; padding: 14px 15px; }

  .section { margin-bottom: 22px; }
  .field--check { padding: 14px; }
  .btn { padding: 16px 20px; }        /* área táctil cómoda */
  .success__card { padding: 36px 24px; }
  .success__card h2 { font-size: 1.6rem; }
}

/* ---- Celular angosto ---- */
@media (max-width: 360px) {
  .panel { padding: 20px 12px 40px; }
  .form-card { padding: 18px 14px; }
  .formhead h2 { font-size: 1.5rem; }
}

/* Accesibilidad: reducir movimiento */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
