/* ReduceDrift login theme.
 *
 * ITS magenta (#CF1C66) + grey wordmark over an animated gradient
 * background with subtle parallax tilt on the card. Pure CSS apart
 * from a tiny enhancement script in resources/js/effects.js.
 */

:root {
    --rd-magenta: #CF1C66;
    --rd-magenta-dark: #A01550;
    --rd-magenta-glow: rgba(207, 28, 102, 0.45);
    --rd-grey-900: #0F1115;
    --rd-grey-800: #1F242C;
    --rd-grey-600: #4B5563;
    --rd-grey-500: #6B7280;
    --rd-grey-300: #D1D5DB;
    --rd-grey-200: #E5E7EB;
    --rd-grey-100: #F3F4F6;
    --rd-grey-50: #F9FAFB;
    --rd-white: #FFFFFF;
    --rd-error: #EF4444;
    --rd-success: #16A34A;
    --rd-warn: #F59E0B;
    --rd-info: #3B82F6;
    --rd-shadow-card: 0 30px 60px -20px rgba(15, 17, 21, 0.45),
                      0 18px 36px -12px rgba(207, 28, 102, 0.18);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    color: var(--rd-grey-900);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body.rd-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #F8FAFC 0%, #FDF2F8 50%, #F8FAFC 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* the blobs slide */
    position: relative;
}

/* ----------------------------------------------------------------------
 * Animated background
 * ---------------------------------------------------------------------- */

.rd-bg {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.rd-bg__blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.55;
    will-change: transform;
}

.rd-bg__blob--1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    max-width: 720px;
    max-height: 720px;
    background: radial-gradient(circle at 30% 30%, var(--rd-magenta) 0%, rgba(207, 28, 102, 0) 65%);
    animation: rd-drift-a 22s ease-in-out infinite alternate;
}

.rd-bg__blob--2 {
    bottom: -15%;
    right: -10%;
    width: 55vw;
    height: 55vw;
    max-width: 800px;
    max-height: 800px;
    background: radial-gradient(circle at 40% 40%, #FF5BA0 0%, rgba(255, 91, 160, 0) 65%);
    animation: rd-drift-b 28s ease-in-out infinite alternate;
}

.rd-bg__blob--3 {
    top: 20%;
    right: 25%;
    width: 30vw;
    height: 30vw;
    max-width: 460px;
    max-height: 460px;
    background: radial-gradient(circle at 50% 50%, #6B7280 0%, rgba(107, 114, 128, 0) 65%);
    opacity: 0.30;
    animation: rd-drift-c 35s ease-in-out infinite alternate;
}

.rd-bg__grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(to right, rgba(15, 17, 21, 0.04) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(15, 17, 21, 0.04) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, #000 30%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, #000 30%, transparent 80%);
}

@keyframes rd-drift-a {
    0%   { transform: translate(0, 0)       scale(1); }
    50%  { transform: translate(80px, 60px) scale(1.08); }
    100% { transform: translate(40px, 120px) scale(0.95); }
}
@keyframes rd-drift-b {
    0%   { transform: translate(0, 0)         scale(1); }
    50%  { transform: translate(-100px, -40px) scale(1.10); }
    100% { transform: translate(-50px, -90px)  scale(0.92); }
}
@keyframes rd-drift-c {
    0%   { transform: translate(0, 0); }
    100% { transform: translate(-60px, 80px); }
}

@media (prefers-reduced-motion: reduce) {
    .rd-bg__blob { animation: none; }
}

/* ----------------------------------------------------------------------
 * Shell + card
 * ---------------------------------------------------------------------- */

.rd-shell {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 460px;
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rd-card {
    width: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(22px) saturate(140%);
    -webkit-backdrop-filter: blur(22px) saturate(140%);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 22px;
    box-shadow: var(--rd-shadow-card);
    overflow: hidden;
    transition: transform 180ms ease-out;
    transform-style: preserve-3d;
    animation: rd-card-in 540ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes rd-card-in {
    0%   { opacity: 0; transform: translateY(18px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0)    scale(1); }
}

.rd-card__brand {
    padding: 36px 36px 16px;
    display: flex;
    justify-content: center;
    border-bottom: 1px solid rgba(15, 17, 21, 0.05);
    background: linear-gradient(180deg, rgba(207, 28, 102, 0.04) 0%, rgba(255, 255, 255, 0) 100%);
}

.rd-logo {
    height: 52px;
    width: auto;
    user-select: none;
    -webkit-user-drag: none;
    transition: transform 240ms ease;
}
.rd-logo:hover {
    transform: translateY(-1px) scale(1.02);
}

.rd-card__body {
    padding: 28px 36px 24px;
}

.rd-heading {
    margin: 0 0 22px;
    font-size: 22px;
    font-weight: 600;
    color: var(--rd-grey-900);
    text-align: center;
    letter-spacing: -0.01em;
}

.rd-card__foot {
    padding: 14px 36px 22px;
    text-align: center;
    font-size: 12px;
    color: var(--rd-grey-500);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.rd-foot-dot { margin: 0 8px; opacity: 0.5; }
/* Build identifier is subdued — smaller, lower opacity, monospace so
 * it's recognisable as a SHA at a glance without screaming for attention.
 */
.rd-foot-build {
    font-family: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
    font-size: 11px;
    opacity: 0.65;
    text-transform: none;
    letter-spacing: 0;
}

/* ----------------------------------------------------------------------
 * Form
 * ---------------------------------------------------------------------- */

.rd-form__body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.rd-field {
    display: block;
}

.rd-field__label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--rd-grey-600);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.rd-input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    font-size: 15px;
    color: var(--rd-grey-900);
    background: var(--rd-white);
    border: 1.5px solid var(--rd-grey-200);
    border-radius: 12px;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
    font-family: inherit;
}

.rd-input::placeholder {
    color: var(--rd-grey-500);
}

.rd-input:hover {
    border-color: var(--rd-grey-300);
}

.rd-input:focus {
    border-color: var(--rd-magenta);
    box-shadow: 0 0 0 4px rgba(207, 28, 102, 0.15);
    background: var(--rd-white);
}

.rd-input[aria-invalid="true"] {
    border-color: var(--rd-error);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.10);
}

.rd-input-group {
    position: relative;
    display: block;
}

.rd-input-group .rd-input {
    padding-right: 50px;
}

.rd-eye-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--rd-grey-600);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 140ms ease;
    font-size: 16px;
}
.rd-eye-btn:hover { background: var(--rd-grey-100); }
.rd-eye-btn:focus-visible {
    outline: 2px solid var(--rd-magenta);
    outline-offset: 2px;
}

.rd-field__error {
    display: block;
    margin-top: 6px;
    color: var(--rd-error);
    font-size: 13px;
    font-weight: 500;
}

.rd-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    font-size: 14px;
    color: var(--rd-grey-600);
    margin-top: -2px;
}

.rd-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.rd-checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--rd-magenta);
    cursor: pointer;
}

.rd-link {
    color: var(--rd-magenta);
    text-decoration: none;
    font-weight: 500;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font-size: inherit;
    font-family: inherit;
}
.rd-link:hover { color: var(--rd-magenta-dark); text-decoration: underline; }
.rd-link:focus-visible {
    outline: 2px solid var(--rd-magenta);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ----------------------------------------------------------------------
 * Button
 * ---------------------------------------------------------------------- */

.rd-button {
    margin-top: 8px;
    width: 100%;
    height: 50px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--rd-magenta) 0%, #E03A82 50%, var(--rd-magenta) 100%);
    background-size: 200% 100%;
    color: var(--rd-white);
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 8px 16px -6px var(--rd-magenta-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    transition: transform 160ms ease, box-shadow 200ms ease, background-position 280ms ease;
    font-family: inherit;
}

.rd-button:hover {
    transform: translateY(-1px);
    background-position: 100% 0;
    box-shadow: 0 14px 28px -8px var(--rd-magenta-glow), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.rd-button:active {
    transform: translateY(0);
    box-shadow: 0 4px 10px -2px var(--rd-magenta-glow);
}
.rd-button:focus-visible {
    outline: 3px solid rgba(207, 28, 102, 0.5);
    outline-offset: 3px;
}
.rd-button[disabled] {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.rd-button__arrow {
    transition: transform 200ms ease;
    font-size: 18px;
}
.rd-button:hover .rd-button__arrow {
    transform: translateX(4px);
}

/* ----------------------------------------------------------------------
 * Alerts
 * ---------------------------------------------------------------------- */

.rd-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 18px;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid transparent;
    animation: rd-alert-in 280ms ease-out both;
}

@keyframes rd-alert-in {
    0%   { opacity: 0; transform: translateY(-4px); }
    100% { opacity: 1; transform: translateY(0); }
}

.rd-alert__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.rd-alert--error   { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.rd-alert--error   .rd-alert__dot { background: var(--rd-error); }
.rd-alert--warning { background: #FFFBEB; color: #92400E; border-color: #FDE68A; }
.rd-alert--warning .rd-alert__dot { background: var(--rd-warn); }
.rd-alert--success { background: #F0FDF4; color: #166534; border-color: #BBF7D0; }
.rd-alert--success .rd-alert__dot { background: var(--rd-success); }
.rd-alert--info    { background: #EFF6FF; color: #1E40AF; border-color: #BFDBFE; }
.rd-alert--info    .rd-alert__dot { background: var(--rd-info); }

/* ----------------------------------------------------------------------
 * Social / divider / info
 * ---------------------------------------------------------------------- */

.rd-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--rd-grey-500);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 22px 0 10px;
}
.rd-divider::before,
.rd-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--rd-grey-200);
}

.rd-social {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.rd-social__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 44px;
    border-radius: 12px;
    background: var(--rd-white);
    border: 1.5px solid var(--rd-grey-200);
    color: var(--rd-grey-900);
    text-decoration: none;
    font-weight: 500;
    transition: border-color 160ms ease, background 160ms ease, transform 120ms ease;
}
.rd-social__btn:hover {
    border-color: var(--rd-grey-300);
    background: var(--rd-grey-50);
    transform: translateY(-1px);
}

.rd-info {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid var(--rd-grey-200);
    text-align: center;
    color: var(--rd-grey-600);
    font-size: 14px;
}
.rd-info__row { display: flex; justify-content: center; gap: 8px; }

.rd-tryanother {
    margin-top: 16px;
    text-align: center;
}

/* Fallback styling for base templates we haven't overridden
 * (info.ftl, error.ftl, login-update-password.ftl, etc.). These use
 * patternfly markup we can't easily theme with a single class — but
 * we can make the most common containers presentable inside our card. */

#kc-error-message,
#kc-info-message {
    text-align: center;
    color: var(--rd-grey-700, var(--rd-grey-800));
    font-size: 14px;
    line-height: 1.5;
    padding: 8px 0;
}
#kc-error-message .instruction,
#kc-info-message .instruction { margin: 0 0 12px; }

/* Buttons that base templates render with patternfly classes —
 * keep them looking on-brand even if we haven't overridden the .ftl. */
.pf-c-button.pf-m-primary,
input[type="submit"].pf-c-button {
    background: linear-gradient(135deg, var(--rd-magenta) 0%, #E03A82 50%, var(--rd-magenta) 100%);
    color: #fff;
    border: 0;
    border-radius: 12px;
    height: 48px;
    padding: 0 18px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 16px -6px var(--rd-magenta-glow);
}
.pf-c-button.pf-m-primary:hover { transform: translateY(-1px); }

/* ----------------------------------------------------------------------
 * Responsive
 * ---------------------------------------------------------------------- */

@media (max-width: 520px) {
    .rd-card__brand { padding: 28px 24px 14px; }
    .rd-card__body  { padding: 22px 24px 18px; }
    .rd-card__foot  { padding: 12px 24px 18px; }
    .rd-logo        { height: 44px; }
    .rd-heading     { font-size: 19px; }
    .rd-bg__grid    { background-size: 40px 40px; }
}

/* ----------------------------------------------------------------------
 * OTP — challenge screen (login-otp.ftl) + enrollment (login-config-totp.ftl)
 *
 * Same visual system as the password login: rd-field labels, rd-input
 * borders, rd-button submit. Adds:
 *   - rd-input--otp  — monospaced + tracking for a numeric code
 *   - rd-otp-step    — numbered "1, 2, 3" enrollment steps
 *   - rd-otp-qr      — framed QR code with brand-tinted shadow
 *   - rd-otp-manual  — monospaced secret + manual-entry metadata list
 *   - rd-otp-apps    — supported authenticator app pill list
 *   - rd-otp-credentials — radio list when a user has multiple TOTP devices
 *   - rd-required    — magenta * for required-field markers
 *   - rd-button--ghost — secondary action (AIA cancel)
 * ---------------------------------------------------------------------- */

.rd-required {
    color: var(--rd-magenta);
    margin-left: 2px;
    font-weight: 700;
}

.rd-input--otp {
    font-family: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
    font-size: 22px;
    letter-spacing: 8px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    padding-left: 14px;
    padding-right: 14px;
}

.rd-otp-step {
    margin-top: 18px;
}
.rd-otp-step:first-child { margin-top: 0; }

.rd-otp-step__head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.rd-otp-step__head--sub {
    margin-top: 18px;
}
.rd-otp-step__num {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--rd-magenta), var(--rd-magenta-dark));
    color: var(--rd-white);
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 4px 10px -2px var(--rd-magenta-glow);
}
.rd-otp-step__text {
    margin: 0;
    color: var(--rd-grey-600);
    font-size: 13.5px;
    line-height: 1.5;
}

.rd-otp-apps {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.rd-otp-apps li {
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--rd-grey-100);
    color: var(--rd-grey-600);
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.rd-otp-qr {
    margin: 6px auto 6px;
    padding: 14px;
    width: max-content;
    border-radius: 14px;
    background: var(--rd-white);
    box-shadow:
        0 18px 35px -16px var(--rd-magenta-glow),
        0 0 0 1px var(--rd-grey-200);
}
.rd-otp-qr img {
    display: block;
    width: 192px;
    height: 192px;
    image-rendering: pixelated;
}
.rd-otp-manual-fallback {
    margin: 4px 0 0;
    text-align: center;
    font-size: 12.5px;
}

.rd-otp-manual {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--rd-grey-50);
    border: 1px dashed var(--rd-grey-300);
}
.rd-otp-manual__secret {
    font-family: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
    font-size: 14px;
    letter-spacing: 1.5px;
    word-break: break-all;
    color: var(--rd-grey-900);
    user-select: all;
}

.rd-otp-meta {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 18px;
    font-size: 12.5px;
    color: var(--rd-grey-600);
}
.rd-otp-meta li strong {
    color: var(--rd-grey-900);
    font-weight: 600;
}

.rd-otp-credentials {
    border: 0;
    padding: 0;
    margin: 0 0 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.rd-otp-credentials__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--rd-grey-200);
    cursor: pointer;
    font-size: 13.5px;
    color: var(--rd-grey-900);
    transition: border-color 0.15s ease, background 0.15s ease;
}
.rd-otp-credentials__item:hover {
    border-color: var(--rd-grey-300);
    background: var(--rd-grey-50);
}
.rd-otp-credentials__item input[type="radio"]:checked + span {
    color: var(--rd-magenta);
    font-weight: 600;
}

.rd-otp-actions {
    display: flex;
    gap: 10px;
}
.rd-otp-actions .rd-button { flex: 1; }

.rd-button--ghost {
    background: transparent;
    color: var(--rd-grey-600);
    border: 1px solid var(--rd-grey-300);
    box-shadow: none;
}
.rd-button--ghost:hover {
    background: var(--rd-grey-50);
    color: var(--rd-grey-900);
    border-color: var(--rd-grey-500);
    transform: none;
}

@media (max-width: 520px) {
    .rd-input--otp        { font-size: 18px; letter-spacing: 6px; }
    .rd-otp-qr img        { width: 168px; height: 168px; }
    .rd-otp-meta          { grid-template-columns: 1fr; }
    .rd-otp-actions       { flex-direction: column-reverse; }
}
