/*
 * Park Mall — login page (templates/login/page.php).
 * Visual reference: docs/mockups/Main.dc.html and Verification.dc.html (390 px phone canvas).
 * Logical properties only (RTL), light/dark from the OS, motion reduced on request.
 */

:root {
    color-scheme: light dark;
    --pm-font: "Readex Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Arabic", "Noto Sans", Tahoma, sans-serif;
    --pm-page: #F3F5F9;
    --pm-surface: #FFFFFF;
    --pm-tint: #F3F5F9;
    --pm-line: #E3E7EF;
    --pm-ink: #0B0D24;
    --pm-label: #33384F;
    --pm-text-2: #4F556D;
    --pm-muted: #646A82;
    --pm-focus: #009DE1;
    --pm-blue-text: #0071A3;
    --pm-blue-hover: #00557A;
    --pm-blue-soft: #E3F4FC;
    --pm-ring-1: #CDEBF9;
    --pm-ring-2: #9ED8F3;
    --pm-green-text: #3D7A1A;
    --pm-green-soft: #EAF6E1;
    --pm-danger: #C62F2F;
    --pm-danger-soft: #FCE9E9;
    --pm-primary-bg: #0B0D24;
    --pm-primary-fg: #FFFFFF;
    --pm-shadow: 0 1px 3px rgba(11, 13, 36, 0.12);
    --pm-card-shadow: 0 24px 60px -24px rgba(11, 13, 36, 0.25);
    --pm-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --pm-page: #070818;
        --pm-surface: #10132A;
        --pm-tint: #161A36;
        --pm-line: #262B4A;
        --pm-ink: #EEF0F8;
        --pm-label: #D5D8E6;
        --pm-text-2: #B4B9CF;
        --pm-muted: #9AA0BA;
        --pm-focus: #4CC0F2;
        --pm-blue-text: #4CC0F2;
        --pm-blue-hover: #8AD7F7;
        --pm-blue-soft: #10314A;
        --pm-ring-1: #173A55;
        --pm-ring-2: #1F5577;
        --pm-green-text: #95D466;
        --pm-green-soft: #1A2E14;
        --pm-danger: #FF6B6B;
        --pm-danger-soft: #3A1620;
        --pm-primary-bg: #EEF0F8;
        --pm-primary-fg: #0B0D24;
        --pm-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
        --pm-card-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.7);
    }
}

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

[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.pm-body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--pm-surface);
    color: var(--pm-ink);
    font-family: var(--pm-font);
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
    color: inherit;
}

a {
    color: var(--pm-blue-text);
}

a:hover {
    color: var(--pm-blue-hover);
}

:focus-visible {
    outline: 3px solid var(--pm-focus);
    outline-offset: 2px;
}

[dir="rtl"] .pm-flip-rtl {
    transform: scaleX(-1);
}

.pm-icon {
    flex: none;
}

/* ---------------------------------------------------------------- layout */

.pm-login {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
}

.pm-screen {
    position: relative;
    width: 100%;
    max-width: 440px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--pm-surface);
    animation: pm-enter 280ms var(--pm-ease) both;
}

@media (min-width: 600px) {
    body.pm-body {
        background: var(--pm-page);
    }

    .pm-login {
        align-items: center;
        padding: 32px 16px;
    }

    .pm-screen {
        min-height: min(844px, calc(100dvh - 64px));
        border-radius: 28px;
        box-shadow: var(--pm-card-shadow);
    }

    .pm-screen--password .pm-hero {
        background: var(--pm-tint);
    }
}

/* ---------------------------------------------------------------- hero (password step) */

.pm-hero {
    position: relative;
    height: 330px;
    flex: none;
    overflow: hidden;
    background: var(--pm-tint);
}

/* Brand motion "Lumières" (validated, docs/brand/motion): the symbol pops in while its four leaves light up
   one after the other (60 ms apart), each turning around the stem. Transform and opacity only. */
.pm-hero-symbol {
    position: absolute;
    inset-inline-end: -96px;
    top: -84px;
    width: 320px;
    height: 320px;
    animation: pm-symbol-pop 1000ms cubic-bezier(0.45, 0, 0.55, 1) both;
}

.pm-hero-leaf {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    transform-origin: 37% 91%;
    animation: pm-leaf-pop 600ms cubic-bezier(0.45, 0, 0.55, 1) both;
}

.pm-hero-leaf:nth-child(2) {
    animation-delay: 60ms;
}

.pm-hero-leaf:nth-child(3) {
    animation-delay: 120ms;
}

.pm-hero-leaf:nth-child(4) {
    animation-delay: 180ms;
}

.pm-hero-text {
    position: absolute;
    inset-inline: 28px;
    bottom: 34px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.pm-logo {
    display: block;
    width: 148px;
    height: auto;
}

.pm-hero-heading {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pm-hero h1 {
    margin: 0;
    font-size: 31px;
    line-height: 1.1;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.pm-hero p {
    margin: 0;
    font-size: 15px;
    line-height: 1.45;
    color: var(--pm-text-2);
}

/* ---------------------------------------------------------------- forms */

.pm-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 30px 28px 0;
}

.pm-screen--password .pm-form {
    flex: 1;
}

.pm-form--grow {
    flex: 1;
    padding: 24px 28px 28px;
}

.pm-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.pm-label {
    font-size: 13.5px;
    font-weight: 500;
    color: var(--pm-label);
}

.pm-input {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 54px;
    padding: 0 16px;
    border-radius: 16px;
    background: var(--pm-tint);
    border: 1.5px solid var(--pm-line);
    color: var(--pm-muted);
    transition: border-color 150ms var(--pm-ease), box-shadow 150ms var(--pm-ease);
}

.pm-input--action {
    padding-inline-end: 8px;
}

.pm-input:focus-within {
    border-color: var(--pm-focus);
    color: var(--pm-blue-text);
}

.pm-input[data-invalid] {
    border-color: var(--pm-danger);
}

.pm-input input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--pm-ink);
    font-size: 16px;
}

.pm-input input[type="password"] {
    letter-spacing: 0.12em;
}

.pm-input input::placeholder {
    color: var(--pm-muted);
    opacity: 1;
}

.pm-icon-button {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    display: grid;
    place-items: center;
    cursor: pointer;
    color: var(--pm-muted);
}

.pm-icon-button .pm-when-shown,
.pm-icon-button[aria-pressed="true"] .pm-when-hidden {
    display: none;
}

.pm-icon-button[aria-pressed="true"] .pm-when-shown {
    display: block;
}

.pm-hint {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--pm-muted);
}

.pm-text {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: var(--pm-label);
}

.pm-note {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--pm-muted);
    text-align: center;
}

.pm-spacer {
    flex: 1;
}

/* Error under the field itself (audit E-27). */
.pm-field-error {
    margin: 6px 2px 0;
    font-size: 14px;
    line-height: 1.4;
    font-weight: 500;
    color: var(--pm-danger);
}

/* "Mot de passe oublié ?": who to contact, behind a (!) (audit E-27). */
.pm-station {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pm-station-hint {
    margin: 0;
    color: var(--pm-muted);
    font-size: 0.875rem;
    text-align: center;
}
.pm-station-or {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0 2px;
    color: var(--pm-muted);
    font-size: 0.8125rem;
}
.pm-station-or::before,
.pm-station-or::after {
    content: "";
    flex: 1;
    border-top: 1px solid currentColor;
    opacity: 0.35;
}
.pm-forgot {
    align-self: center;
    max-width: 100%;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--pm-muted);
    text-align: center;
}

.pm-forgot summary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 8px;
    border-radius: 12px;
    color: var(--pm-label);
    font-weight: 500;
    cursor: pointer;
    list-style: none;
}

.pm-forgot summary::-webkit-details-marker {
    display: none;
}

.pm-forgot summary:focus-visible {
    outline: 2px solid var(--pm-focus);
    outline-offset: 2px;
}

.pm-info-dot {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.pm-forgot p {
    margin: 4px 0 0;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--pm-tint);
    color: var(--pm-label);
    text-align: start;
}

.pm-step-count--form {
    align-self: flex-start;
}

.pm-error {
    margin: 0;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--pm-danger-soft);
    color: var(--pm-danger);
    font-size: 14px;
    line-height: 1.45;
    font-weight: 500;
    animation: pm-shake 320ms var(--pm-ease) both;
}

.pm-error--inset {
    margin: 16px 28px 0;
}

/* ---------------------------------------------------------------- buttons */

.pm-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    border-radius: 18px;
    cursor: pointer;
    text-decoration: none;
    transition: transform 150ms var(--pm-ease), opacity 150ms var(--pm-ease), background-color 150ms var(--pm-ease);
    -webkit-tap-highlight-color: transparent;
}

.pm-button:active:not(:disabled) {
    transform: scale(0.98);
}

.pm-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.pm-button--primary {
    height: 56px;
    border: 0;
    background: var(--pm-primary-bg);
    color: var(--pm-primary-fg);
    font-size: 16.5px;
    font-weight: 600;
}

.pm-screen--password .pm-submit {
    margin-top: 6px;
}

.pm-button--secondary {
    height: 52px;
    border: 1.5px solid var(--pm-line);
    background: var(--pm-surface);
    font-size: 15.5px;
    font-weight: 500;
}

.pm-button--small {
    height: 44px;
    border-radius: 14px;
    font-size: 14.5px;
}

.pm-button[aria-busy="true"] {
    position: relative;
    color: transparent;
}

.pm-button[aria-busy="true"]::after {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2.5px solid var(--pm-primary-fg);
    border-inline-end-color: transparent;
    animation: pm-spin 700ms linear infinite;
}

.pm-button--secondary[aria-busy="true"]::after {
    border-color: var(--pm-ink);
    border-inline-end-color: transparent;
}

.pm-link {
    align-self: center;
    min-height: 44px;
    padding: 10px;
    border: 0;
    background: transparent;
    color: var(--pm-blue-text);
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.pm-link:hover {
    color: var(--pm-blue-hover);
}

.pm-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pm-row {
    display: flex;
    gap: 10px;
}

/* ---------------------------------------------------------------- footer (password step) */

.pm-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px 28px 30px;
}

.pm-lang {
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 999px;
    background: var(--pm-tint);
}

.pm-lang button {
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    font-size: 14px;
    color: var(--pm-text-2);
    cursor: pointer;
    transition: background-color 200ms var(--pm-ease), box-shadow 200ms var(--pm-ease);
}

.pm-lang button[aria-pressed="true"] {
    background: var(--pm-surface);
    box-shadow: var(--pm-shadow);
    font-weight: 600;
    color: var(--pm-ink);
}

.pm-protected {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 12.5px;
    color: var(--pm-muted);
}

.pm-protected-icon {
    color: var(--pm-green-text);
}

/* ---------------------------------------------------------------- second factor */

.pm-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px 0 10px;
    padding-inline: 10px 16px;
}

.pm-back {
    height: 44px;
    padding-block: 0;
    padding-inline: 6px 12px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--pm-label);
    font-size: 15px;
    cursor: pointer;
}

.pm-step-count {
    font-size: 13px;
    color: var(--pm-muted);
}

.pm-heading {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px 28px 0;
}

.pm-heading--top {
    padding-top: 40px;
}

.pm-heading h1 {
    margin: 0;
    font-size: 27px;
    line-height: 1.15;
    font-weight: 650;
    letter-spacing: -0.01em;
}

.pm-heading p {
    margin: 0;
    font-size: 15px;
    line-height: 1.5;
    color: var(--pm-text-2);
}

.pm-view {
    animation: pm-enter 240ms var(--pm-ease) both;
}

.pm-view[data-view="passkey"] {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 28px 28px;
}

.pm-view[data-view="code"],
.pm-view[data-view="recovery"] {
    padding-top: 34px;
}

.pm-passkey-visual {
    position: relative;
    flex: 1;
    min-height: 260px;
    display: grid;
    place-items: center;
}

.pm-passkey-visual--small {
    flex: none;
    min-height: 190px;
    transform: scale(0.8);
    margin-block: -20px;
}

.pm-ring {
    position: absolute;
    left: 50%;
    top: 50%;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.pm-ring--outer {
    width: 236px;
    height: 236px;
    border: 1.5px solid var(--pm-ring-1);
}

.pm-ring--inner {
    width: 184px;
    height: 184px;
    border: 1.5px solid var(--pm-ring-2);
}

.pm-passkey-disc {
    position: relative;
    width: 132px;
    height: 132px;
    border-radius: 50%;
    background: var(--pm-blue-soft);
    display: grid;
    place-items: center;
    color: var(--pm-blue-text);
}

.pm-login[data-busy="passkey"] .pm-ring {
    animation: pm-pulse 1600ms var(--pm-ease) infinite;
}

.pm-login[data-busy="passkey"] .pm-ring--inner {
    animation-delay: 300ms;
}

.pm-passkey-hint {
    margin: 0 0 20px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--pm-label);
    text-align: center;
}

.pm-otp {
    position: relative;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    direction: ltr;
}

.pm-otp-box {
    height: 60px;
    border-radius: 14px;
    background: var(--pm-tint);
    border: 1.5px solid var(--pm-line);
    display: grid;
    place-items: center;
    font-size: 26px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: border-color 150ms var(--pm-ease), transform 150ms var(--pm-ease);
}

.pm-otp-box[data-filled] {
    animation: pm-pop 160ms var(--pm-ease) both;
}

.pm-otp:focus-within .pm-otp-box[data-active] {
    border: 2px solid var(--pm-focus);
}

.pm-otp-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.01;
    border: 0;
    font-size: 16px;
    color: transparent;
    caret-color: transparent;
    background: transparent;
    letter-spacing: 3em;
}

.pm-otp:focus-within {
    outline: none;
}

.pm-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 28px 26px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--pm-tint);
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--pm-text-2);
}

.pm-notice-icon {
    margin-top: 1px;
    color: var(--pm-blue-text);
}

/* ---------------------------------------------------------------- enrolment */

.pm-choices {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 28px 28px 28px;
}

.pm-choice {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 88px;
    padding: 16px;
    border: 1.5px solid var(--pm-line);
    border-radius: 20px;
    background: var(--pm-surface);
    text-align: start;
    cursor: pointer;
    transition: transform 150ms var(--pm-ease), border-color 150ms var(--pm-ease);
}

.pm-choice:hover {
    border-color: var(--pm-focus);
}

.pm-choice:active {
    transform: scale(0.98);
}

.pm-choice-icon {
    flex: none;
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: grid;
    place-items: center;
}

.pm-choice-icon--blue {
    background: var(--pm-blue-soft);
    color: var(--pm-blue-text);
}

.pm-choice-icon--green {
    background: var(--pm-green-soft);
    color: var(--pm-green-text);
}

.pm-choice-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pm-choice-text strong {
    font-size: 16px;
    font-weight: 600;
}

.pm-choice-text span {
    font-size: 13.5px;
    color: var(--pm-muted);
}

.pm-choice-arrow {
    color: var(--pm-muted);
}

.pm-qr {
    align-self: center;
    width: 208px;
    height: 208px;
    padding: 8px;
    border-radius: 20px;
    background: #FFFFFF;
    border: 1.5px solid var(--pm-line);
    display: grid;
    place-items: center;
}

.pm-qr svg {
    display: block;
    width: 100%;
    height: 100%;
}

.pm-qr svg path,
.pm-qr svg rect {
    fill: #0B0D24;
}

.pm-secret {
    display: block;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--pm-tint);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 15px;
    letter-spacing: 0.08em;
    word-spacing: 0.25em;
    text-align: center;
    user-select: all;
    overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- recovery codes */

.pm-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding: 14px;
    border-radius: 18px;
    background: var(--pm-tint);
    list-style: none;
    counter-reset: pm-code;
}

.pm-codes li {
    padding: 10px 8px;
    border-radius: 12px;
    background: var(--pm-surface);
    text-align: center;
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.04em;
    animation: pm-enter 240ms var(--pm-ease) both;
}

.pm-codes li:nth-child(2) { animation-delay: 35ms; }
.pm-codes li:nth-child(3) { animation-delay: 70ms; }
.pm-codes li:nth-child(4) { animation-delay: 105ms; }
.pm-codes li:nth-child(5) { animation-delay: 140ms; }
.pm-codes li:nth-child(6) { animation-delay: 175ms; }
.pm-codes li:nth-child(7) { animation-delay: 210ms; }
.pm-codes li:nth-child(8) { animation-delay: 245ms; }
.pm-codes li:nth-child(9) { animation-delay: 280ms; }
.pm-codes li:nth-child(10) { animation-delay: 315ms; }

.pm-status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--pm-green-text);
}

.pm-check {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    font-size: 15px;
    cursor: pointer;
}

.pm-check input {
    width: 22px;
    height: 22px;
    margin: 0;
    accent-color: var(--pm-focus);
}

.pm-noscript {
    margin: 24px;
    padding: 16px;
    border-radius: 14px;
    background: var(--pm-danger-soft);
    color: var(--pm-danger);
    text-align: center;
}

/* ---------------------------------------------------------------- motion */

@keyframes pm-enter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes pm-symbol-pop {
    0%,
    16% {
        opacity: 0;
        transform: scale(0.5) rotate(-14deg);
        animation-timing-function: cubic-bezier(0.2, 0.9, 0.3, 1);
    }

    28% {
        opacity: 1;
    }

    48% {
        transform: scale(1.1) rotate(3deg);
        animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
    }

    68% {
        transform: scale(0.965) rotate(-1deg);
    }

    84% {
        transform: scale(1.012) rotate(0deg);
    }

    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes pm-leaf-pop {
    0%,
    20% {
        opacity: 0;
        transform: scale(0.3) rotate(-20deg);
        animation-timing-function: cubic-bezier(0.34, 1.5, 0.6, 1);
    }

    40% {
        opacity: 1;
    }

    86%,
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

@keyframes pm-pulse {
    0%,
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        opacity: 0.45;
        transform: translate(-50%, -50%) scale(1.06);
    }
}

@keyframes pm-pop {
    from {
        transform: scale(0.9);
    }

    to {
        transform: scale(1);
    }
}

@keyframes pm-shake {
    0%,
    100% {
        transform: none;
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

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

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0ms !important;
        transition-duration: 1ms !important;
    }

    .pm-button[aria-busy="true"]::after {
        animation: pm-spin 1400ms linear infinite !important;
    }
}
