/* ─── Caffeinemood OTP Login — light theme ─── */

/* Center the login card vertically + horizontally inside the viewport. */
.cm-login-wrapper {
    min-height: calc(100vh - 200px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

/*
 * Design tokens — every value falls back to a sane default but inherits
 * the active theme's variables when present. This keeps the form
 * visually consistent with whichever theme the site runs.
 *
 *   --paletteColor1   Blocksy / Stackable primary
 *   --theme-palette-color-1   Generic block themes
 *   --wp--preset--color--*    block.json based themes (Twenty Twenty-*, etc.)
 */
.cm-login {
    --cm-bg: #ffffff;
    --cm-surface: #ffffff;
    --cm-input-bg: #ffffff;
    --cm-input-border: rgba(0, 0, 0, .12);
    --cm-text: currentColor;
    --cm-text-muted: rgba(0, 0, 0, .6);
    --cm-text-dim: rgba(0, 0, 0, .4);
    --cm-primary: var(--theme-palette-color-1, var(--paletteColor1, #0e5b3a));
    --cm-primary-hover: var(--theme-palette-color-2, var(--paletteColor2, #0a4a2f));
    --cm-input-border-focus: var(--cm-primary);
    --cm-link: var(--cm-primary);
    --cm-error: #d92626;
    --cm-radius: var(--theme-border-radius, 12px);
    --cm-shadow: 0 24px 60px -20px rgba(15, 23, 42, .18), 0 8px 24px -8px rgba(15, 23, 42, .10), 0 1px 3px rgba(15, 23, 42, .06);

    max-width: 560px;
    margin: 32px auto;
    padding: clamp(28px, 6vw, 80px) clamp(20px, 5vw, 72px);
    background: var(--cm-bg);
    color: var(--cm-text);
    border: 1px solid rgba(0, 0, 0, .06);
    border-radius: calc(var(--cm-radius) * 1.3);
    box-shadow: var(--cm-shadow);
    font-family: inherit;
    line-height: 1.6;
    direction: rtl;
}

.cm-login *,
.cm-login *::before,
.cm-login *::after {
    box-sizing: border-box;
}

/* HEADER */
.cm-login__head {
    position: relative;
    text-align: center;
    margin-bottom: 32px;
    padding-bottom: 16px;
}

.cm-login__title {
    color: var(--cm-text);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 0 0 8px;
}

.cm-login__subtitle {
    color: var(--cm-text-muted);
    font-size: 14px;
    margin: 0;
    line-height: 1.7;
}

.cm-login__accent {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 48px;
    height: 3px;
    background: var(--cm-primary);
    border-radius: 999px;
}

/* BACK BUTTON in step 2 */
.cm-login__back-btn {
    position: absolute;
    top: 0;
    right: 0;
    background: none;
    border: 0;
    padding: 8px;
    cursor: pointer;
    color: var(--cm-text-muted);
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.cm-login__back-btn:hover { background: color-mix(in srgb, var(--cm-text) 6%, transparent); color: var(--cm-text); }
.cm-login__back-btn svg { transform: scaleX(-1); /* visual flip for RTL */ }

.cm-login__mobile-display {
    color: var(--cm-text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* FIELD */
.cm-login__field {
    margin-bottom: 16px;
}

.cm-login__label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--cm-text-muted);
    font-size: 13px;
    margin-bottom: 8px;
    text-align: right;
    justify-content: flex-start;
    direction: rtl;
}

.cm-login__label .cm-login__icon {
    color: var(--cm-text-muted);
    line-height: 0;
    flex-shrink: 0;
}

.cm-login__input-wrap {
    position: relative;
}

/* legacy: hide icon if it still lives inside the input wrap */
.cm-login__input-wrap > .cm-login__icon {
    display: none;
}

.cm-login__input {
    width: 100%;
    padding: 13px 14px;
    background: var(--cm-input-bg);
    border: 1px solid var(--cm-input-border);
    border-radius: var(--cm-radius);
    color: var(--cm-text);
    font-family: inherit;
    font-size: 15px;
    direction: ltr;
    text-align: left;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}


.cm-login__input::placeholder {
    color: var(--cm-text-dim);
    text-align: left;
}

.cm-login__input:focus {
    border-color: var(--cm-input-border-focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cm-primary) 18%, transparent);
}

.cm-login__input--code {
    padding: 16px 14px;
    font-size: 22px;
    letter-spacing: 8px;
    text-align: center !important;
    font-variant-numeric: tabular-nums;
}
.cm-login__input--code::placeholder {
    text-align: center;
    letter-spacing: 8px;
}

/* Invalid state */
.cm-login__input[aria-invalid="true"] {
    border-color: var(--cm-error);
    box-shadow: 0 0 0 3px rgba(217, 38, 38, .08);
}

/* OTP boxes — split 6-digit input */
.cm-login__otp-boxes {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 8px;
    width: 100%;
}

.cm-login__otp-box {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    aspect-ratio: 1 / 1;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    font-family: ui-monospace, 'SF Mono', Consolas, 'Liberation Mono', monospace;
    background: var(--cm-input-bg);
    border: 1.5px solid var(--cm-input-border);
    border-radius: 10px;
    color: var(--cm-text);
    outline: none;
    transition: border-color .15s, box-shadow .15s, transform .08s;
    -moz-appearance: textfield;
    padding: 0 !important;
    box-sizing: border-box !important;
}
.cm-login__otp-box::-webkit-outer-spin-button,
.cm-login__otp-box::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cm-login__otp-box:focus {
    border-color: var(--cm-input-border-focus);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--cm-primary) 18%, transparent);
    transform: translateY(-1px);
}
.cm-login__otp-box[data-filled="true"] {
    border-color: var(--cm-primary);
    background: color-mix(in srgb, var(--cm-primary) 6%, transparent);
}
.cm-login__otp-boxes[aria-invalid="true"] .cm-login__otp-box {
    border-color: var(--cm-error);
}

/* BUTTON */
.cm-login__btn {
    display: block;
    width: 100%;
    padding: 13px 16px;
    background: var(--cm-primary);
    color: #fff;
    border: 1px solid var(--cm-primary);
    border-radius: var(--cm-radius);
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, transform .05s, box-shadow .15s;
    margin-top: 12px;
    text-align: center;
}

.cm-login__btn:hover:not(:disabled) {
    background: var(--cm-primary-hover);
    border-color: var(--cm-primary-hover);
}

.cm-login__btn:active:not(:disabled) {
    transform: scale(.99);
}

.cm-login__btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.cm-login__btn--primary {
    position: relative;
}

.cm-login__btn[aria-busy="true"] .cm-login__btn__label {
    visibility: hidden;
}

.cm-login__btn__spinner {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cm-spin .6s linear infinite;
}

@keyframes cm-spin { to { transform: rotate(360deg); } }

/* TERMS */
.cm-login__terms {
    font-size: 12px;
    color: var(--cm-text-muted);
    text-align: center;
    margin: 18px 0 0;
    line-height: 1.9;
}

.cm-login__terms a {
    color: var(--cm-text);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.cm-login__terms a:hover { color: var(--cm-primary); }

/* RESEND */
.cm-login__resend {
    text-align: center;
    margin-top: 16px;
    font-size: 13px;
}

.cm-login__link {
    background: none;
    border: none;
    color: var(--cm-link);
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    padding: 4px 8px;
    text-decoration: none;
    border-radius: 6px;
    transition: background .15s;
}

.cm-login__link:hover:not(:disabled) {
    background: color-mix(in srgb, var(--cm-primary) 8%, transparent);
}

.cm-login__link:disabled {
    color: var(--cm-text-dim);
    cursor: not-allowed;
}

.cm-login__cooldown {
    font-variant-numeric: tabular-nums;
    color: var(--cm-text-dim);
    margin-inline-start: 4px;
}

.cm-login__cooldown:empty { display: none; }

/* ERROR */
.cm-login__error {
    color: var(--cm-error);
    font-size: 12.5px;
    margin-top: 8px;
    min-height: 16px;
    text-align: end;
    line-height: 1.5;
}
.cm-login__error:not(:empty) { animation: cm-error-shake 0.3s ease-out; }
.cm-login__error:empty { display: none; }

@keyframes cm-error-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* SUCCESS SPLASH */
.cm-login__success {
    text-align: center;
    padding: 24px 0;
    animation: cm-success-fade 0.4s ease-out;
}
.cm-login__success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--cm-primary) 12%, transparent);
    color: var(--cm-primary);
    margin-bottom: 20px;
    animation: cm-success-pop 0.5s cubic-bezier(.34, 1.56, .64, 1);
}
.cm-login__success-title {
    color: var(--cm-text);
    font-size: 22px;
    font-weight: 800;
    margin: 0 0 6px;
}
.cm-login__success-subtitle {
    color: var(--cm-text-muted);
    font-size: 14px;
    margin: 0;
}
@keyframes cm-success-pop {
    0%   { transform: scale(0); opacity: 0; }
    60%  { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}
@keyframes cm-success-fade {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Disable form while submitting */
.cm-login[aria-busy="true"] {
    pointer-events: none;
    opacity: 0.85;
}

/* NOTICES */
.cm-login__notice {
    text-align: center;
    color: var(--cm-text-muted);
    padding: 24px;
    font-size: 14px;
    background: color-mix(in srgb, var(--cm-text) 4%, transparent);
    border-radius: var(--cm-radius);
}

/* WC OVERRIDE — kill default form */
.cm-login-account-override { margin-bottom: 24px; }

/* Override theme heading colors leaking in via h2 selectors */
.cm-login h2.cm-login__title,
.cm-login__title {
    line-height: 1.4;
}

/* Responsive */
@media (max-width: 560px) {
    .cm-login {
        margin: 0;
        padding: 24px 18px;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }
    .cm-login__brand img { height: 36px; }
    .cm-login__title { font-size: 17px; }
}
