/* ============================================================
   BeforeYouAccept — sistema de diseño
   ============================================================ */

:root {
  /* Marca — paleta "Azul confianza" (modo claro: papel cálido + tinta) */
  --primary: #1f56d6;
  --primary-600: #1a45ad;
  --primary-050: #eef3ff;
  --accent: #38bdf8;
  --marker: #f4c744; /* subrayador ámbar — la firma "marcamos el contrato" */

  /* Logo (semáforo) */
  --logo-housing: #17314d;
  --sem-r: #e5484d;
  --sem-a: #f4c744;
  --sem-g: #3fb26b;

  /* Riesgo (semáforo) */
  --rojo: #d02546;
  --rojo-bg: #fdf0f2;
  --amarillo: #b5730a;
  --amarillo-bg: #fbf4e6;
  --verde: #15803d;
  --verde-bg: #eef8f0;

  /* Neutros (modo claro) — papel cálido, no blanco frío */
  --bg: #f6f5f1;
  --bg-grad-1: #efece2;
  --bg-grad-2: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #faf9f4;
  --border: #e7e3d8;
  --text: #1a1e29;
  --text-soft: #55606f;
  --text-mute: #9a9488;
  --shadow: 0 1px 2px rgba(40, 35, 20, .05), 0 8px 24px rgba(40, 35, 20, .07);
  --shadow-lg: 0 10px 40px color-mix(in srgb, var(--primary) 18%, transparent);
  --radius: 16px;
  --radius-sm: 10px;

  /* Tipografía */
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;

  /* Anillo de foco (accesibilidad) */
  --ring: 0 0 0 3px color-mix(in srgb, var(--primary) 45%, transparent);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --primary: #60a5fa;
  --primary-600: #3b82f6;
  --primary-050: #0c2340;
  --accent: #38bdf8;
  --marker: #f4c744; /* mismo subrayador ámbar que en claro (firma coherente) */

  --logo-housing: #26344b;
  --sem-r: #fb7185;
  --sem-a: #f4c744;
  --sem-g: #4ade80;

  --rojo: #fb7185;
  --rojo-bg: #2a1620;
  --amarillo: #fbbf24;
  --amarillo-bg: #2a2110;
  --verde: #4ade80;
  --verde-bg: #10231a;

  --bg: #0b0f1a;
  --bg-grad-1: #131a2e;
  --bg-grad-2: #0b0f1a;
  --surface: #131826;
  --surface-2: #1a2032;
  --border: #262d40;
  --text: #e8ecf6;
  --text-soft: #a9b3c9;
  --text-mute: #6b7590;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, .45);

  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

/* Foco visible coherente en todo lo interactivo (accesibilidad por teclado) */
:where(a, button, [role="button"], [role="tab"], summary, textarea, input, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: 8px;
}

/* Objetivos tactiles sin retardo de doble tap */
a, button, [role="button"], [role="tab"], summary, .theme-toggle { touch-action: manipulation; }

/* Enlace de salto al contenido (visible solo al enfocar con teclado) */
.skip-link {
  position: absolute;
  left: 50%;
  top: .6rem;
  transform: translate(-50%, -160%);
  z-index: 100;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: .88rem;
  padding: .55rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: var(--shadow-lg);
  transition: transform .18s ease;
}
.skip-link:focus-visible { transform: translate(-50%, 0); }

/* ---------------------------- Barra superior ---------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .8rem 1.25rem;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-weight: 800;
  letter-spacing: -.02em;
  font-size: 1.1rem;
}
.brand .logo {
  display: grid;
  place-items: center;
  height: 30px;
}
.logo-svg .hs { fill: var(--logo-housing); }
.logo-svg .d-r { fill: var(--sem-r); }
.logo-svg .d-a { fill: var(--sem-a); }
.logo-svg .d-g { fill: var(--sem-g); }
.brand em { color: var(--primary); font-style: normal; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.chip-demo {
  font-size: .72rem;
  font-weight: 700;
  padding: .25rem .6rem;
  border-radius: 999px;
  background: var(--amarillo-bg);
  color: var(--amarillo);
  border: 1px solid color-mix(in srgb, var(--amarillo) 30%, transparent);
}
.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  width: 38px; height: 38px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.05rem;
  transition: background .15s, transform .15s;
}
.theme-toggle:hover { background: var(--surface-2); transform: translateY(-1px); }
.lang-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  height: 38px;
  padding: 0 .7rem;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: .82rem;
  letter-spacing: .03em;
  transition: background .15s, transform .15s;
}
.lang-toggle:hover { background: var(--surface-2); transform: translateY(-1px); }
/* Chip verde cuando la IA real está activa */
.chip-demo.chip-ia {
  background: var(--verde-bg);
  color: var(--verde);
  border-color: color-mix(in srgb, var(--verde) 30%, transparent);
}

/* -------------------------------- Hero --------------------------------- */
.hero {
  text-align: center;
  padding: 3.4rem 1.25rem 1.6rem;
  background: radial-gradient(1200px 400px at 50% -50px, var(--bg-grad-1), var(--bg-grad-2));
}
.eyebrow {
  margin: 0 0 .9rem;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--primary);
}
.hero h1 {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: clamp(2.1rem, 5vw, 3.4rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -.02em;
  text-wrap: balance;
  max-width: 16ch;
  margin: 0 auto .75rem;
}
/* Firma de marca: subrayado de "rotulador" bajo lo que importa */
.hero h1 .mark {
  position: relative;
  white-space: nowrap;
}
.hero h1 .mark::after {
  content: "";
  position: absolute;
  left: -.06em;
  right: -.06em;
  bottom: .04em;
  height: .34em;
  z-index: -1;
  background: color-mix(in srgb, var(--marker) 78%, transparent);
  border-radius: .18em .5em .28em .4em;
  transform: rotate(-.6deg);
}
@media (max-width: 560px) { .hero h1 .mark { white-space: normal; } }
.hero p.lead {
  font-size: clamp(1.02rem, 2.2vw, 1.2rem);
  color: var(--text-soft);
  max-width: 560px;
  margin: 0 auto 1.4rem;
  text-wrap: pretty;
}
.trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: center;
}
.trust {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: .4rem .8rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

/* ------------------------------ Contenedor ------------------------------ */
.wrap { max-width: 860px; margin: 0 auto; padding: 0 1.25rem 4rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.elevated { box-shadow: var(--shadow-lg); }
.card-body { padding: 1.5rem; }

/* --------------------------- Pestañas (segment) -------------------------- */
.segment {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 1rem;
}
.segment button {
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-weight: 600;
  font-size: .92rem;
  padding: .5rem .95rem;
  border-radius: 9px;
  cursor: pointer;
  transition: all .15s;
}
.segment button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
}

/* -------------------------------- Inputs -------------------------------- */
textarea#texto {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  padding: .9rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: .98rem;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
textarea#texto:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent);
}
.input-foot {
  display: flex;
  justify-content: space-between;
  font-size: .82rem;
  color: var(--text-mute);
  margin-top: .4rem;
}
#contador-chars { font-variant-numeric: tabular-nums; }

.upload-zone {
  border: 2px dashed var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 2.5rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
.upload-zone:hover, .upload-zone.dragover, .upload-zone:focus-visible {
  border-color: var(--primary);
  background: var(--primary-050);
}
.upload-zone .big { font-size: 2.2rem; }

/* ---------------------------- Turnstile + CTA --------------------------- */
#turnstile-container { min-height: 66px; margin: 1.1rem 0; }

.btn-primary-xl {
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  padding: .95rem 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 38%, transparent);
  transition: transform .12s, box-shadow .12s, opacity .12s;
}
.btn-primary-xl:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 12px 28px color-mix(in srgb, var(--primary) 48%, transparent); }
.btn-primary-xl:active:not(:disabled) { transform: translateY(0) scale(.99); }
.btn-primary-xl:disabled { opacity: .6; cursor: not-allowed; }
.uso-line { text-align: center; color: var(--text-mute); font-size: .84rem; margin: .7rem 0 0; }

/* ------------------------------ Resultado ------------------------------- */
.reveal { animation: reveal .45s ease both; }
@keyframes reveal { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.section-title {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 1.7rem 0 .85rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* Veredicto general */
.verdict {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}
.verdict.alto { background: var(--rojo-bg); }
.verdict.medio { background: var(--amarillo-bg); }
.verdict.bajo { background: var(--verde-bg); }
.verdict .dot {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.5rem; flex-shrink: 0;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.verdict h3 { margin: 0; font-family: var(--font-display); font-optical-sizing: auto; font-size: 1.3rem; font-weight: 600; }
.verdict.alto h3 { color: var(--rojo); }
.verdict.medio h3 { color: var(--amarillo); }
.verdict.bajo h3 { color: var(--verde); }
.verdict p { margin: .1rem 0 0; font-size: .9rem; color: var(--text-soft); }
.counts { margin-left: auto; display: flex; gap: .4rem; flex-shrink: 0; }
.count-pill {
  display: inline-flex; align-items: center; gap: .3rem;
  font-weight: 700; font-size: .85rem;
  font-variant-numeric: tabular-nums;
  padding: .3rem .6rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
}

.meta-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.1rem; }
.meta-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .8rem;
  color: var(--text-soft);
  padding: .28rem .7rem;
}

.resumen-box {
  background: var(--primary-050);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  border-radius: var(--radius-sm);
  padding: 1.15rem 1.25rem;
}
.resumen-box p { margin: .3rem 0 0; }

/* Tarjetas de riesgo */
.riesgo {
  border: 1px solid var(--border);
  border-left: 5px solid var(--text-mute);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: .95rem 1.1rem;
  transition: transform .12s, box-shadow .12s;
}
.riesgo:hover { transform: translateX(2px); box-shadow: var(--shadow); }
.riesgo.rojo { border-left-color: var(--rojo); }
.riesgo.amarillo { border-left-color: var(--amarillo); }
.riesgo.verde { border-left-color: var(--verde); }
.riesgo-head { display: flex; align-items: center; gap: .55rem; }
.riesgo-head .titulo { font-weight: 700; }
.nivel-tag {
  margin-left: auto;
  font-size: .68rem; font-weight: 800; letter-spacing: .05em;
  text-transform: uppercase;
  padding: .2rem .5rem; border-radius: 6px;
}
.riesgo.rojo .nivel-tag { color: var(--rojo); background: var(--rojo-bg); }
.riesgo.amarillo .nivel-tag { color: var(--amarillo); background: var(--amarillo-bg); }
.riesgo.verde .nivel-tag { color: var(--verde); background: var(--verde-bg); }
.riesgo .detalle { color: var(--text-soft); font-size: .9rem; margin-top: .45rem; }
.stack { display: flex; flex-direction: column; gap: .6rem; }

/* Puntos clave */
.puntos { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.puntos li {
  display: flex; gap: .6rem;
  padding: .7rem .9rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .92rem;
}

/* FAQ acordeón */
.faq details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: .55rem;
  overflow: hidden;
}
.faq summary {
  cursor: pointer;
  list-style: none;
  padding: .85rem 1rem;
  font-weight: 600;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: '＋'; color: var(--text-mute); font-weight: 700; }
.faq details[open] summary::after { content: '－'; }
.faq .answer { padding: 0 1rem 1rem; color: var(--text-soft); font-size: .9rem; }

/* Aviso legal */
.disclaimer {
  margin-top: 1.3rem;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-mute);
  font-size: .82rem;
}
.alert-warn {
  background: var(--amarillo-bg);
  border: 1px solid color-mix(in srgb, var(--amarillo) 35%, transparent);
  color: var(--amarillo);
  padding: .9rem 1.1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Acciones del resultado (copiar / descargar / compartir / nuevo) */
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.result-actions button {
  font: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: background .15s, border-color .15s, transform .12s;
}
.result-actions button:hover { background: var(--surface-2); border-color: var(--primary); transform: translateY(-1px); }
.result-actions button.ghost { margin-left: auto; color: var(--primary); }

/* Impresión: dejar solo el resultado, limpio, para "Guardar como PDF" */
@media print {
  .topbar, .hero, .card.elevated, #cargando, .como, .foot,
  .apoyo, #anuncio-slot, .skip-link, .result-actions, #btn-donar { display: none !important; }
  body { background: #fff; color: #000; }
  .wrap { max-width: none; padding: 0; }
  #resultado { display: block !important; margin: 0; }
  #resultado .card, .riesgo, .faq details, .puntos li, .resumen-box { box-shadow: none; }
  .riesgo, .faq details, .verdict { break-inside: avoid; }
}

/* Spinner */
.loading { text-align: center; padding: 3rem 1rem; }
.spinner {
  width: 42px; height: 42px; margin: 0 auto 1rem;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Footer */
.foot {
  text-align: center;
  color: var(--text-mute);
  font-size: .82rem;
  padding: 2rem 1.25rem 2.5rem;
  border-top: 1px solid var(--border);
}

/* ------------------------------ Donaciones ------------------------------ */
/* Boton pequeno en la barra superior */
.btn-donar {
  font-size: .82rem;
  font-weight: 700;
  text-decoration: none;
  padding: .4rem .75rem;
  border-radius: 999px;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  transition: background .18s ease, transform .18s ease;
  white-space: nowrap;
}
.btn-donar:hover { background: color-mix(in srgb, var(--primary) 18%, transparent); transform: translateY(-1px); }

/* Bloque de apoyo antes del footer */
.apoyo { max-width: 720px; margin: 2.5rem auto 0; padding: 0 1.25rem; }
.apoyo-card {
  text-align: center;
  padding: 2rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, transparent);
  background: color-mix(in srgb, var(--primary) 6%, var(--card));
}
.apoyo-card h3 { margin: 0 0 .5rem; font-family: var(--font-display); font-optical-sizing: auto; font-weight: 600; font-size: 1.35rem; }
.apoyo-card p { margin: 0 auto 1.2rem; max-width: 460px; color: var(--text-soft); }
.btn-donar-xl {
  display: inline-block;
  text-decoration: none;
  font-weight: 700;
  color: #fff;
  padding: .8rem 1.6rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 38%, transparent);
  transition: transform .18s ease, box-shadow .18s ease;
}
.btn-donar-xl:hover { transform: translateY(-2px); box-shadow: 0 12px 28px color-mix(in srgb, var(--primary) 48%, transparent); }

/* ------------------------------ Anuncio (discreto) ---------------------- */
.anuncio-slot {
  max-width: 720px;
  margin: 2rem auto 0;
  padding: .5rem 1.25rem 0;
  text-align: center;
}
.anuncio-label {
  display: block;
  font-size: .68rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: .4rem;
}
.anuncio-cuerpo {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .75rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--text) 3%, transparent);
}
.anuncio-cuerpo img { max-width: 100%; height: auto; }

/* --------------------------- Enlace "probar ejemplo" -------------------- */
.example-hint {
  text-align: center;
  margin: .9rem 0 0;
  font-size: .86rem;
  color: var(--text-mute);
}
.example-hint button {
  border: 0;
  background: none;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.example-hint button:hover { color: var(--primary-600); }

/* ----------------------------- Cómo funciona ---------------------------- */
.como {
  margin-top: 2.5rem;
  text-align: center;
}
.como h2 {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-size: clamp(1.5rem, 3vw, 1.9rem);
  font-weight: 600;
  letter-spacing: -.01em;
  text-wrap: balance;
  margin: 0 0 1.6rem;
}
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  text-align: left;
}
.step {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.4rem 1.2rem;
  transition: transform .18s, border-color .18s, box-shadow .18s;
}
.step:hover { transform: translateY(-4px); border-color: var(--primary); box-shadow: var(--shadow); }
.step .num {
  position: absolute;
  top: -12px; right: 14px;
  font-size: .8rem; font-weight: 800;
  color: var(--primary);
  background: var(--primary-050);
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
}
.step .ico {
  width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 1.5rem;
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  color: #fff;
  margin-bottom: .8rem;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--primary) 35%, transparent);
}
.step h3 { margin: 0 0 .3rem; font-size: 1.02rem; font-weight: 700; }
.step p { margin: 0; font-size: .9rem; color: var(--text-soft); }

/* ------------------------- Animación al hacer scroll -------------------- */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .55s ease, transform .55s ease;
}
.reveal-on-scroll.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal-on-scroll { opacity: 1; transform: none; transition: none; }
  .reveal, .step, .riesgo, .btn-primary-xl { animation: none !important; }
}

@media (max-width: 640px) {
  .steps { grid-template-columns: 1fr; }
}

.hidden { display: none !important; }

@media (max-width: 560px) {
  .verdict { flex-wrap: wrap; }
  .counts { margin-left: 0; width: 100%; }
}
