/* Acceso al portal: diseño «Login passwordless – Gestor DeCA». Fuentes locales (SIL OFL, véase /fonts). */
@font-face {
    font-family: "Montserrat";
    font-style: normal;
    font-weight: 500 800;
    font-display: swap;
    src: url("../fonts/montserrat-latin.woff2") format("woff2");
}

@font-face {
    font-family: "Source Sans 3";
    font-style: normal;
    font-weight: 400 600;
    font-display: swap;
    src: url("../fonts/source-sans-3-latin.woff2") format("woff2");
}

:root {
    color-scheme: light;
    --red: #c12c2c;
    --red-hover: #a52323;
    --error: #b02525;
    --success: #2f6b3a;
    --background: #f6f4f2;
    --surface: #fff;
    --separator: #e4e0dd;
    --text: #1e1b1a;
    --text-secondary: #5c5654;
    --text-tertiary: #7a7270;
    --border: #d9d4d1;
    --border-filled: #a8a19e;
    --focus-ring: 0 0 0 3px rgba(193, 44, 44, 0.15);
    --heading: "Montserrat", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--background); }
body {
    font-family: "Source Sans 3", system-ui, sans-serif;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
h1, p { margin: 0; }
button, input { font: inherit; }
[hidden] { display: none !important; }
a:focus-visible, button:focus-visible { outline: 3px solid var(--red); outline-offset: 3px; }

.login-shell { min-height: 100vh; display: flex; flex-wrap: wrap; background: var(--background); }

/* Panel de marca */
.login-brand {
    flex: 1 1 440px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 48px;
    padding: 48px clamp(28px, 5vw, 72px);
    background: var(--red);
    color: #fff;
}
.login-brand-ring {
    position: absolute;
    right: -120px;
    bottom: -120px;
    width: 420px;
    height: 420px;
    border: 64px solid rgba(255, 255, 255, 0.06);
    border-radius: 50%;
}
.login-brand-company {
    font-family: var(--heading);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
.login-brand-body { position: relative; display: flex; flex-direction: column; gap: 20px; max-width: 460px; }
.login-brand-title {
    font-family: var(--heading);
    font-weight: 800;
    font-size: clamp(56px, 8vw, 96px);
    line-height: 0.9;
    letter-spacing: -0.03em;
}
.login-brand-subtitle { font-family: var(--heading); font-weight: 600; font-size: 20px; line-height: 1.3; text-wrap: pretty; }
.login-brand-copy { font-size: 16px; line-height: 1.55; opacity: 0.9; text-wrap: pretty; }
.login-brand-support { position: relative; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 14px; }

/* Columna del formulario */
.login-main { flex: 1 1 480px; display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
/* 459px: ancho de la frase de introducción en una línea a 16px (Source Sans 3). */
.login-box { container-type: inline-size; width: 100%; max-width: 459px; display: flex; flex-direction: column; gap: 32px; }
.login-logo { align-self: flex-start; height: 44px; width: auto; }
.login-footer { border-top: 1px solid var(--separator); padding-top: 20px; font-size: 13px; line-height: 1.5; color: var(--text-tertiary); }

.login-step { display: flex; flex-direction: column; gap: 24px; }
.login-heading { display: flex; flex-direction: column; gap: 8px; }
.login-heading h1 { font-family: var(--heading); font-weight: 700; font-size: 28px; letter-spacing: -0.01em; }
.login-heading p { font-size: 16px; line-height: 1.5; color: var(--text-secondary); text-wrap: pretty; overflow-wrap: anywhere; }
.login-heading strong { color: var(--text); font-weight: 600; }
/* Siempre en una línea; si la caja es más estrecha, se reduce la letra en proporción. */
.login-heading .login-intro { white-space: nowrap; font-size: min(16px, 100cqi * 16 / 459); overflow-wrap: normal; }

.login-field { display: flex; flex-direction: column; gap: 8px; }
.login-label { font-size: 14px; font-weight: 600; }
.login-input {
    height: 52px;
    padding: 0 16px;
    font-size: 16px;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    outline: none;
}
.login-input.is-invalid { border-color: var(--error); }
.login-input:focus { border-color: var(--red); box-shadow: var(--focus-ring); }
.login-error { font-size: 14px; color: var(--error); }
.login-success { font-size: 14px; color: var(--success); }

.login-button {
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: none;
    border-radius: 8px;
    background: var(--red);
    color: #fff;
    font-family: var(--heading);
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.02em;
    cursor: pointer;
}
.login-button:hover { background: var(--red-hover); }
.login-link-button { text-decoration: none; }
.login-button:disabled { cursor: default; }
.login-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: login-spin 0.7s linear infinite;
}
.login-button.is-loading .login-spinner { display: block; }
@keyframes login-spin { to { transform: rotate(360deg); } }

/* Código: sin JavaScript se ve un campo normal; con él, casillas sobre un único input transparente. */
.code-boxes { display: none; }
.code-input {
    width: 100%;
    height: 60px;
    padding: 0 16px;
    font-family: var(--heading);
    font-weight: 700;
    font-size: 24px;
    letter-spacing: 0.3em;
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    outline: none;
}
.code-input:focus { border-color: var(--red); box-shadow: var(--focus-ring); }
.code-field.is-invalid .code-input { border-color: var(--error); }

.js .code-field { position: relative; }
.js .code-boxes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.js .code-box {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-family: var(--heading);
    font-weight: 700;
    font-size: 24px;
    color: var(--text);
}
.js .code-box.is-filled { border-color: var(--border-filled); }
.js .code-box.is-active { border-color: var(--red); box-shadow: var(--focus-ring); }
.js .code-field.is-invalid .code-box { border-color: var(--error); }
.js .code-input {
    position: absolute;
    inset: 0;
    height: 100%;
    padding: 0;
    opacity: 0;
    font-size: 16px;
    border: none;
    box-shadow: none;
    cursor: text;
}

.login-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; font-size: 14px; }
.login-back { color: var(--text-secondary); text-decoration: none; }
.login-back:hover { color: var(--text); }
.login-links form { display: contents; }
.login-resend { padding: 0; border: none; background: none; font-weight: 600; color: var(--red); cursor: pointer; }
.login-resend:hover { color: var(--red-hover); }
.login-wait { color: var(--text-tertiary); }

@media (prefers-reduced-motion: reduce) {
    .login-spinner { animation-duration: 2s; }
}
