/* Acceso a Sofía · diseño aprobado A8 "libreta de crayolas" (design/login-propuestas/a8.html). */
:root {
  --paper: #fffefb;
  --paper-rule: #e7edf3;
  --margin-red: #eeb3ae;
  --brand-red: #b52e30;
  /* crayolas */
  --c-rojo: #e0402e;
  --c-azul: #2f63d6;
  --c-amarillo: #f4b400;
  --c-verde: #3aa047;
  --c-naranja: #f27a1a;
  --c-morado: #8b4fc4;
  --card: #ffffff;
  --card-line: #e4ddcd;
  --ink: #1b2c45;
  --muted: #4a5568;
  --green: #176b3c;
  --green-2: #11552f;
  --mostaza: #d4a62a;
  --focus: #1b2c45;
  --font-display: "Newsreader", Georgia, serif;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --r: 10px;
  --line-gap: 32px;
}
* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: clip; }
body {
  position: relative;
  min-height: 100dvh;
  font-family: var(--font-ui);
  color: var(--ink);
  background-color: var(--paper);
  --margin-x: 88px;
  background-image:
    linear-gradient(90deg, transparent calc(var(--margin-x) - 2px), var(--margin-red) calc(var(--margin-x) - 2px), var(--margin-red) var(--margin-x), transparent var(--margin-x)),
    repeating-linear-gradient(180deg, transparent 0 calc(var(--line-gap) - 1px), var(--paper-rule) calc(var(--line-gap) - 1px) var(--line-gap));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  display: grid;
  place-items: center;
  padding: 32px 16px 32px calc(var(--margin-x) + 24px);
}
.hoja {
  position: relative; z-index: 1;
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 440px);
  gap: 64px;
  align-items: center;
}
.intro { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.marca { display: inline-flex; align-items: center; gap: 14px; max-width: 100%; }
.marca img { display: block; width: auto; height: 68px; flex: none; }
.wordmark {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.75rem; line-height: 1.1; letter-spacing: -0.01em; color: var(--ink);
}
.wordmark .sofia { color: var(--green); }
.wordmark .sep { color: var(--brand-red); padding: 0 .12em; }
h1 {
  width: fit-content; max-width: 100%;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.3rem, 5vw, 4.4rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin: 36px 0 14px;
  overflow-wrap: anywhere;
}
h1 .verde { color: var(--green); }
.sub { width: fit-content; font-size: 1.1875rem; line-height: 1.55; color: var(--muted); margin: 0; max-width: 30ch; }

.ficha {
  position: relative;
  background: var(--card);
  border: 1px solid #e6e2d8;
  border-radius: var(--r);
  padding: 36px 36px 26px;
  box-shadow: 0 1px 0 #ece5d4, 0 18px 40px -24px rgba(27, 44, 69, .35);
}
.ficha h2 { font-size: 1.125rem; font-weight: 700; margin: 0 0 22px; }
.campo { display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; margin-bottom: 18px; }
label { font-size: .875rem; font-weight: 600; color: var(--ink); }
.control {
  display: flex; align-items: center; gap: 8px;
  min-height: 50px; background: #fff;
  border: 1.5px solid #b9c0cb; border-radius: 8px;
  padding: 0 6px 0 14px;
  transition: border-color .15s cubic-bezier(.2,.7,.2,1);
}
.control:hover { border-color: #7d8796; }
.control:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23, 107, 60, .18); }
.control svg.ico { flex: none; width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 1.8; stroke-linecap: round; }
select, input {
  flex: 1; min-width: 0; height: 46px;
  border: 0; outline: none; background: transparent;
  font: 500 1rem var(--font-ui); color: var(--ink);
  appearance: none; -webkit-appearance: none;
}
input::placeholder { color: #6b7280; }
.control.sel { padding-right: 14px; }
.control.sel .flecha { width: 14px; height: 14px; stroke: var(--ink); fill: none; stroke-width: 2; flex: none; pointer-events: none; }
.ver {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 12px;
  border: 1.5px solid var(--ink); border-radius: 6px;
  background: #fff; color: var(--ink);
  font: 600 .875rem var(--font-ui); cursor: pointer;
}
.ver svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.ver:hover { background: #f3f5f8; }
.entrar {
  width: 100%; margin-top: 6px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; border: 0; border-radius: 8px;
  background: var(--green); color: #fff;
  font: 700 1.0625rem var(--font-ui); cursor: pointer;
  box-shadow: 0 2px 0 var(--green-2);
  transition: background-color .15s cubic-bezier(.2,.7,.2,1), transform .15s cubic-bezier(.2,.7,.2,1);
}
.entrar:hover { background: var(--green-2); }
.entrar:active { transform: translateY(1px); box-shadow: none; }
.entrar svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.2; stroke-linecap: round; }
:is(.ver, .entrar):focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.ayuda {
  display: flex; gap: 8px; align-items: flex-start;
  margin: 16px 0 0; padding-top: 14px;
  border-top: 1px dashed var(--card-line);
  font-size: .875rem; line-height: 1.45; color: var(--muted);
}
.ayuda svg { flex: none; width: 16px; height: 16px; margin-top: 2px; stroke: var(--green); fill: none; stroke-width: 2; }

/* Dibujos: capa decorativa, posiciones calculadas por JS en zonas libres */
.garabatos { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.d {
  position: absolute; display: block; overflow: visible;
  opacity: .88; fill: none;
  stroke-linecap: round; stroke-linejoin: round;
  transform: rotate(var(--r, 0deg));
}
.d .w { transform-box: fill-box; transform-origin: center; }
.d .t, .d .z { stroke-dasharray: 1; }
.d { stroke-width: var(--sw, 3); }
.d .z { stroke-width: calc(var(--sw, 3) * .72); stroke-opacity: .9; }
.rojo { stroke: var(--c-rojo); } .azul { stroke: var(--c-azul); } .amarillo { stroke: var(--c-amarillo); }
.verde { stroke: var(--c-verde); } .naranja { stroke: var(--c-naranja); } .morado { stroke: var(--c-morado); }
.p { stroke: none; transform-box: fill-box; transform-origin: center; }
.p.azul { fill: var(--c-azul); } .p.rojo { fill: var(--c-rojo); } .p.verde { fill: var(--c-verde); }

@media (max-width: 860px) {
  body { --margin-x: 28px; padding: 24px 16px 24px calc(var(--margin-x) + 14px); place-items: start center; }
  .hoja { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .marca img { height: 52px; }
  .wordmark { font-size: 1.3rem; }
  h1 { margin: 22px 0 8px; font-size: 2.25rem; }
  .sub { font-size: 1rem; }
  .ficha { padding: 26px 20px 18px; }
}
/* Celular acostado / alto corto */
@media (max-height: 30rem) and (min-width: 560px) {
  body { --margin-x: 36px; padding: 16px 16px 16px calc(var(--margin-x) + 18px); place-items: center; }
  .hoja { grid-template-columns: minmax(0, 1fr) minmax(0, 380px); gap: 28px; }
  .marca img { height: 42px; }
  .wordmark { font-size: 1.15rem; }
  h1 { font-size: 1.9rem; margin: 12px 0 6px; }
  .sub { font-size: .9375rem; }
  .ficha { padding: 18px 18px 12px; }
  .ficha h2 { display: none; }
  .campo { margin-bottom: 10px; gap: 4px; }
  .control { min-height: 44px; }
  select, input { height: 40px; }
  .entrar { min-height: 46px; }
  .ayuda { margin-top: 10px; padding-top: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ── Login real: estados que maneja login.js ───────────────────────────── */
[hidden] { display: none !important; }
.campos { display: block; }
.ver::before {
  content: ""; width: 16px; height: 16px; flex: none; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8'%3E%3Cpath d='M2 12s3.6-7 10-7 10 7 10 7-3.6 7-10 7S2 12 2 12Z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E") center / contain no-repeat;
}
.ver[aria-pressed="true"] { background: var(--ink); color: #fff; }
select { cursor: pointer; }
select:disabled { color: var(--muted); cursor: not-allowed; }
.control:has(select:disabled) { background: #f6f7f9; border-color: #d3d8df; }
/* Error: campo marcado por login.js (aria-invalid) o nombre sin elegir */
.control:has([aria-invalid="true"]),
#loginForm[data-state="error"] .control.sel:has(select:invalid) {
  border-color: #b42318; box-shadow: 0 0 0 3px rgba(180, 35, 24, .14);
}
.aviso {
  margin: 14px 0 0; padding: 10px 12px;
  border-radius: 8px; border-left: 3px solid var(--green);
  background: #eef6f0; color: var(--green-2);
  font-size: .875rem; line-height: 1.45; font-weight: 500;
}
.aviso[data-error] { border-left-color: #b42318; background: #fdf0ef; color: #8f1d14; }
/* Cargando / deshabilitado */
.entrar:disabled { cursor: progress; background: var(--green-2); opacity: .78; transform: none; box-shadow: none; }
#loginForm[data-state="loading"] .control { opacity: .7; }
/* Segundo factor */
.paso-2fa { margin: 0 0 16px; font-size: .9375rem; line-height: 1.5; color: var(--muted); }
.enlace-2fa {
  display: inline-flex; align-items: center; min-height: 44px; margin: 4px 0 0; padding: 0;
  border: 0; background: none; color: var(--green);
  font: 600 .875rem var(--font-ui); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.enlace-2fa:hover { color: var(--green-2); }
.enlace-2fa:disabled { color: var(--muted); cursor: progress; }
#emailOtpButton { margin: -8px 0 12px; }
.enlace-2fa:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
@media (max-height: 30rem) and (min-width: 560px) {
  .aviso { margin-top: 8px; padding: 6px 10px; }
  .paso-2fa { margin-bottom: 8px; font-size: .875rem; }
}
