/* ==========================================================================
   Replanta Cedro · La entrada (login)
   docs/anillos/pantallas/entrada.md (E4.3). No carga panel.css: usa los mismos tokens --cp-* (copiados del bloque
   de tokens de panel.css; tests/test_anillos_entrada_cuenta.py comprueba que son iguales) y las mismas formas.
   Claro u oscuro con html[data-theme], que pone login.html con el tema guardado o el del sistema.
   ========================================================================== */

.cedro-login {
    --cp-bg:          #F1F3ED;
    --cp-green:       #93F1C9;
    --cp-accent:      #1F5A41;
    --cp-red-text:    #8C1D18;
    --cp-ink:         #111615;
    --cp-sub:         #2C3834;
    --cp-muted:       #46534E;
    --cp-border:      #DDE3DA;
    --cp-border-hi:   #CDD5CA;
    --cp-surface:     #FFFFFF;
    --cp-surface2:    #EEF1EA;
    --cp-tint-green:  #DDF7EA;
    --cp-tint-red:    #F8E3E1;
    --cp-line-red:    #E9B4AF;
    --cp-btn-bg:      #93F1C9;
    --cp-btn-hover:   #B9F8DC;
    --cp-btn-text:    #111615;
    --cp-focus:       #1F5A41;
    --cp-link:        #1F5A41;
    --cp-r-md:        14px;
    --cp-r-lg:        20px;
    --cp-r-pill:      999px;
    --cp-font-display: 'Inter', system-ui, sans-serif;
    --cp-font-body:   'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    /* El borde de los campos, a 3:1 como mínimo con el papel y con el campo (WCAG 1.4.11, #625): 3,38:1 y 3,78:1.
       --cp-border-hi (1,34:1) se queda para filetes y botones, que se leen por su texto. */
    --rl-field-line:  #7A8680;
}

/* La columna de marca va siempre en tinta: lleva los tokens del tema oscuro en los dos temas. */
[data-theme="dark"] .cedro-login, .cedro-login .rl-brand {
    --cp-bg:          #0E1412;
    --cp-accent:      #93F1C9;
    --cp-red-text:    #F2A39C;
    --cp-ink:         #ECF1EC;
    --cp-sub:         #CED8D1;
    --cp-muted:       #A6B5AE;
    --cp-border:      #26302C;
    --cp-border-hi:   #323E39;
    --cp-surface:     #161F1C;
    --cp-surface2:    #1C2622;
    --cp-tint-green:  rgba(147,241,201,.12);
    --cp-tint-red:    rgba(242,163,156,.12);
    --cp-line-red:    rgba(242,163,156,.3);
    --cp-btn-bg:      #93F1C9;
    --cp-btn-hover:   #B9F8DC;
    --cp-btn-text:    #0E1412;
    --cp-focus:       #D0FFE9;
    --cp-link:        #93F1C9;
    --rl-field-line:  #62716A;  /* 3,63:1 con el papel y 3,28:1 con el campo */
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; }
.cedro-login {
    display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(380px, .85fr); min-height: 100vh;
    background: var(--cp-bg); color: var(--cp-ink);
    font: 400 15px/1.6 var(--cp-font-body); -webkit-font-smoothing: antialiased;
}
.cedro-login [hidden] { display: none !important; }
.cedro-login .ng-hide { display: none !important; }
.rl-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Marca ─────────────────────────────────────────── */
.rl-brand { display: flex; flex-direction: column; gap: 48px; padding: 40px clamp(28px, 5vw, 72px); background: var(--cp-bg); color: var(--cp-ink); }
.rl-top { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--cp-border); }
.rl-top img { display: block; width: 168px; height: auto; }
.rl-top span { color: var(--cp-muted); font-size: 14px; font-weight: 500; }
.rl-hero { margin-top: auto; }
.rl-hero h1 { margin: 0; font-family: var(--cp-font-display); font-size: clamp(38px, 4vw, 62px); font-weight: 800; line-height: 1.05; letter-spacing: -.045em; text-wrap: balance; }
.rl-hero h1 span { display: block; color: var(--cp-green); }
.rl-lead { max-width: 46ch; margin: 24px 0 0; color: var(--cp-muted); font-size: 17px; line-height: 1.6; }
.rl-foot { padding-top: 18px; border-top: 1px solid var(--cp-border); font-size: 14px; }
.rl-foot a { color: var(--cp-ink); text-decoration: underline; text-decoration-color: var(--cp-border-hi); text-underline-offset: 4px; }
.rl-foot a:hover { color: var(--cp-green); text-decoration-color: currentColor; }
.rl-foot a:focus-visible { outline: 2px solid var(--cp-focus); outline-offset: 4px; border-radius: 4px; }

/* Tres datos: lista con punto (.cedro-dotlist), etiqueta en frase normal. */
.cedro-dotlist { list-style: none; margin: 0; padding: 0; }
.cedro-dotlist li { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 14px; align-items: start; padding: 14px 0; border-top: 1px solid var(--cp-border); }
.cedro-dotlist li:first-child { border-top: 0; }
.cedro-dot { width: 12px; height: 12px; margin-top: 6px; border-radius: 50%; background: var(--cp-accent); }
.rl-fact { display: grid; gap: 2px; min-width: 0; }
.rl-fact-k { color: var(--cp-accent); font-size: 13px; font-weight: 600; }
.rl-fact strong { font-size: 15px; font-weight: 600; line-height: 1.4; }
.rl-fact small { color: var(--cp-muted); font-size: 13px; line-height: 1.5; }

/* ── Formulario ────────────────────────────────────── */
.rl-side { display: flex; align-items: center; justify-content: center; padding: 48px clamp(24px, 4vw, 56px); border-left: 1px solid var(--cp-border); }
.rl-form { width: 100%; max-width: 380px; }
.rl-form-brand { display: none; }
.rl-form h2 { margin: 0 0 28px; font-family: var(--cp-font-display); font-size: 32px; font-weight: 800; line-height: 1.15; letter-spacing: -.035em; }
.cedro-form { display: grid; gap: 16px; }
.cedro-field { display: grid; gap: 6px; min-width: 0; }
.cedro-field > span, .cedro-field > label { color: var(--cp-ink); font-size: 14px; font-weight: 600; }
.cedro-field small { color: var(--cp-sub); font-size: 13.5px; line-height: 1.5; }
.cedro-field input, .cedro-field select {
    width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--rl-field-line); border-radius: var(--cp-r-md);
    background: var(--cp-surface); color: var(--cp-ink); font: 400 15px/1.45 var(--cp-font-body);
}
.cedro-field select {
    appearance: none; -webkit-appearance: none; padding-right: 40px;
    background-image: linear-gradient(45deg, transparent 50%, var(--cp-muted) 50%), linear-gradient(135deg, var(--cp-muted) 50%, transparent 50%);
    background-position: calc(100% - 22px) 50%, calc(100% - 17px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
.cedro-field input:hover, .cedro-field select:hover { border-color: var(--cp-muted); }
.cedro-field input:focus, .cedro-field select:focus { outline: 2px solid var(--cp-focus); outline-offset: 2px; }

/* «Entrar»: el primario, a todo el ancho. Mientras se comprueba, «Entrando…» con el giro dentro. */
.cedro-button {
    display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 48px; padding: 10px 18px;
    border-radius: var(--cp-r-pill); font: 600 15px var(--cp-font-body); text-decoration: none; cursor: pointer;
    transition: background .2s, border-color .2s; white-space: nowrap;
}
.cedro-button--primary { width: 100%; border: 1px solid var(--cp-btn-bg); background: var(--cp-btn-bg); color: var(--cp-btn-text); }
.cedro-button--primary:hover { background: var(--cp-btn-hover); border-color: var(--cp-btn-hover); }
.cedro-button:focus-visible { outline: 2px solid var(--cp-focus); outline-offset: 2px; }
.cedro-button:disabled { cursor: progress; }
#verifyingLogin { display: none; align-items: center; gap: 10px; }
.cedro-button.is-busy #verifyingLogin { display: inline-flex !important; }
.cedro-button.is-busy .rl-submit-label { display: none; }
.rl-spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rl-spin .8s linear infinite; }
@keyframes rl-spin { to { transform: rotate(360deg); } }

/* Avisos: P3 (error, encima del botón) y el de sesión caducada (--medio, encima del formulario). */
.cedro-alert { display: grid; gap: 4px; padding: 14px 16px; border-radius: var(--cp-r-lg); background: var(--cp-tint-green); color: var(--cp-ink); }
.cedro-alert--error { background: var(--cp-tint-red); box-shadow: inset 0 0 0 1px var(--cp-line-red); }
.cedro-alert--error .cedro-alert-title { color: var(--cp-red-text); }
.cedro-alert-title { margin: 0; font-size: 14.5px; font-weight: 700; line-height: 1.4; }
.cedro-alert-detail { margin: 0; color: var(--cp-sub); font-size: 14px; line-height: 1.5; }
.cedro-alert a { color: var(--cp-link); font-weight: 600; text-underline-offset: 3px; }
.cedro-alert:focus { outline: 2px solid var(--cp-focus); outline-offset: 2px; }
#loginFailed { display: none; }
.rl-session { margin-bottom: 20px; }

/* Entrar con Google (ADR 0052): encima del usuario y la contraseña, con «o con tu usuario» debajo. */
.cedro-button--secondary { width: 100%; border: 1px solid var(--cp-border-hi); background: var(--cp-surface); color: var(--cp-ink); }
.cedro-button--secondary:hover { border-color: var(--cp-muted); }
.rl-google { display: grid; gap: 18px; margin-bottom: 18px; }
.rl-google-g { flex: none; width: 18px; height: 18px; }
.rl-or { display: flex; align-items: center; gap: 12px; margin: 0; color: var(--cp-sub); font-size: 13.5px; }
.rl-or::before, .rl-or::after { content: ""; flex: 1; height: 1px; background: var(--cp-border); }
.rl-google-alert { margin-bottom: 18px; }
/* El paso que falta tras Google (entrar_google.html): confirmar la cuenta o los dos pasos. */
.cedro-login--paso { grid-template-columns: 1fr; }
.cedro-login--paso .rl-side { border-left: 0; }
.cedro-login--paso .rl-form-brand { display: grid; gap: 14px; margin-bottom: 28px; }
.cedro-login--paso .rl-form-brand img { display: block; width: 140px; height: auto; }
.rl-step-text, .rl-step-who { margin: -14px 0 24px; color: var(--cp-sub); font-size: 15px; line-height: 1.5; }
.rl-step-who { margin-top: 0; color: var(--cp-ink); overflow-wrap: anywhere; }
.rl-code { display: grid; gap: 16px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--cp-border); }
.rl-code .rl-step-text { margin: 0; }
.rl-busy { display: none; align-items: center; gap: 10px; }
.cedro-button.is-busy .rl-busy { display: inline-flex; }

.rl-help { margin: 24px 0 0; padding-top: 18px; border-top: 1px solid var(--cp-border); color: var(--cp-sub); font-size: 14px; }
.rl-help a { color: var(--cp-link); font-weight: 600; text-underline-offset: 3px; }

@media (max-width: 980px) {
    .cedro-login { grid-template-columns: 1fr; }
    .rl-brand { gap: 32px; padding-bottom: 32px; }
    .rl-hero h1 { font-size: clamp(34px, 8vw, 52px); }
    .rl-side { border-left: 0; border-top: 1px solid var(--cp-border); }
}
/* Por debajo de 640 px, la columna de marca se oculta (con los tres datos): arriba, el logo y la frase. */
@media (max-width: 640px) {
    .rl-brand { display: none; }
    .rl-side { align-items: flex-start; padding: 32px 24px 40px; border-top: 0; }
    .rl-form-brand { display: grid; gap: 14px; margin-bottom: 28px; }
    .rl-form-brand img { display: block; width: 140px; height: auto; }
    .rl-form-brand p { margin: 0; color: var(--cp-sub); font-size: 15px; line-height: 1.45; }
    .rl-form h2 { margin-bottom: 22px; font-size: 28px; }
}
.rl-logo-dark { display: none !important; }
[data-theme="dark"] .rl-logo-light { display: none !important; }
[data-theme="dark"] .rl-logo-dark { display: block !important; }
@media (prefers-reduced-motion: reduce) { .cedro-login * { transition: none !important; } .rl-spin { animation: none; border-right-color: currentColor; opacity: .6; } }
