/* ============================================================================
   FILMPARTY_F5E_STEPPED_AUTH v2 — cinematic-dark brand theme.
   Direction distilled from 20+ leading auth pages (Netflix, Spotify, Disney+,
   Apple, Stripe, Linear, Vercel, Telegram, Revolut, Google): full-bleed dark
   backdrop, no glass/neon, typography-led hierarchy, ONE accent (the brand
   gradient) reserved for CTA / focus / progress, restrained 200–350ms motion.
   All inputs are ≥16px so iOS never focus-zooms (kept the page zoom-lock
   intact). RTL-first: back-links carry an outward (left) chevron.
   ========================================================================== */

:root {
    --afx-bg: #0a0c10;
    --afx-surface: #12151b;
    --afx-line: rgba(255, 255, 255, 0.09);
    --afx-well: rgba(255, 255, 255, 0.045);
    --afx-well-line: rgba(255, 255, 255, 0.11);
    --afx-text: #f4f6f8;
    --afx-dim: rgba(255, 255, 255, 0.62);
    --afx-faint: rgba(255, 255, 255, 0.38);
    --afx-amber: #ffb347;
    --afx-coral: #ff7a45;
    --afx-rose: #ff4d7b;
    --afx-magenta: #e02e8a;
    --afx-grad: linear-gradient(135deg, #ffb347 0%, #ff7a45 34%, #ff4d7b 68%, #e02e8a 100%);
    --afx-danger: #ff5c70;
    --afx-good: #43d17c;
    --afx-ease: cubic-bezier(0.33, 1, 0.68, 1);
    --afx-fast: 200ms;
    --afx-med: 320ms;
}

/* ------------------------------------------------------------------ shell */
.afx-shell {
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    isolation: isolate;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: max(20px, env(safe-area-inset-top)) 20px max(28px, env(safe-area-inset-bottom));
    background: var(--afx-bg);
    overflow-x: hidden;
}

/* two whisper-soft brand washes — the only color in the backdrop */
.afx-wash {
    position: absolute;
    border-radius: 50%;
    filter: blur(110px);
    pointer-events: none;
    z-index: -1;
}

.afx-wash-warm {
    width: 420px;
    height: 420px;
    top: -160px;
    inset-inline-start: -120px;
    background: rgba(255, 138, 60, 0.09);
}

.afx-wash-pink {
    width: 460px;
    height: 460px;
    bottom: -200px;
    inset-inline-end: -140px;
    background: rgba(224, 46, 138, 0.075);
}

/* ------------------------------------------------------------------- card */
.afx-card {
    width: 100%;
    max-width: 396px;
    margin-top: clamp(8px, 9vh, 84px);
    animation: afx-card-in 480ms var(--afx-ease) both;
}

@keyframes afx-card-in {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}

/* desktop: a quiet elevated surface — solid, never glass */
@media (min-width: 720px) {
    .afx-card {
        max-width: 428px;
        padding: 40px 36px 32px;
        border-radius: 26px;
        background: var(--afx-surface);
        border: 1px solid var(--afx-line);
        box-shadow: 0 40px 90px -38px rgba(0, 0, 0, 0.75);
    }
}

/* ------------------------------------------------------------------ brand */
.afx-brand {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.afx-brand-mark {
    width: 56px;
    height: 56px;
    /* no drop-shadow: the svg canvas is rectangular, a filter paints a box */
}

/* ---------------------------------------------------------------- heading */
.afx-heading {
    text-align: center;
    margin-bottom: 24px;
}

.afx-title {
    margin: 0 0 7px;
    font-size: 22px;
    font-weight: 900;
    color: var(--afx-text);
    letter-spacing: -0.2px;
    transition: opacity 160ms ease;
}

.afx-subtitle {
    margin: 0;
    font-size: 13.5px;
    line-height: 2;
    color: var(--afx-dim);
    transition: opacity 160ms ease;
}

.afx-heading.is-switching .afx-title,
.afx-heading.is-switching .afx-subtitle {
    opacity: 0;
}

/* --------------------------------------------------------------- progress */
.afx-progress {
    list-style: none;
    display: flex;
    justify-content: center;
    gap: 7px;
    margin: 0 0 20px;
    padding: 0;
}

.afx-progress li {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    transition: all var(--afx-med) var(--afx-ease);
}

.afx-progress li.is-done {
    background: var(--afx-grad);
    width: 22px;
}

/* ------------------------------------------------------------ view/panels */
.afx-view {
    position: relative;
    transition: height var(--afx-med) var(--afx-ease);
}

.afx-panel { width: 100%; }

.afx-panel.is-leaving,
.afx-panel.is-entering {
    position: absolute;
    inset: 0 0 auto 0;
}

.afx-panel.is-leaving {
    animation: afx-leave var(--afx-med) var(--afx-ease) both;
    pointer-events: none;
}

.afx-panel.is-entering {
    animation: afx-enter var(--afx-med) var(--afx-ease) both;
}

@keyframes afx-leave {
    from { opacity: 1; transform: none; }
    to   { opacity: 0; transform: translateX(22px); }
}

@keyframes afx-enter {
    from { opacity: 0; transform: translateX(-22px); }
    to   { opacity: 1; transform: none; }
}

.afx-panel.is-leaving.afx-dir-back { animation-name: afx-leave-back; }
.afx-panel.is-entering.afx-dir-back { animation-name: afx-enter-back; }

@keyframes afx-leave-back {
    from { opacity: 1; transform: none; }
    to   { opacity: 0; transform: translateX(-22px); }
}

@keyframes afx-enter-back {
    from { opacity: 0; transform: translateX(22px); }
    to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ forms */
.afx-form {
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.afx-field-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.afx-field {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 54px;
    border-radius: 16px;
    background: var(--afx-well);
    border: 1px solid var(--afx-well-line);
    transition: border-color var(--afx-fast) ease, box-shadow var(--afx-fast) ease, background var(--afx-fast) ease;
}

.afx-field:focus-within {
    border-color: rgba(255, 122, 69, 0.7);
    box-shadow: 0 0 0 4px rgba(255, 122, 69, 0.14);
    background: rgba(255, 255, 255, 0.06);
}

.afx-field input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: var(--afx-text);
    padding: 15px 17px;
    font: inherit;
    font-size: 16px; /* ≥16px — iOS must never focus-zoom */
    line-height: 1.4;
}

.afx-field input[dir="ltr"] { text-align: left; }

.afx-field input::placeholder { color: var(--afx-faint); }

.afx-field.is-error {
    border-color: rgba(255, 92, 112, 0.75);
    box-shadow: 0 0 0 4px rgba(255, 92, 112, 0.11);
    animation: afx-shake 400ms ease;
}

@keyframes afx-shake {
    15%, 85% { transform: translateX(-1px); }
    30%, 70% { transform: translateX(3px); }
    45%      { transform: translateX(-4px); }
    60%      { transform: translateX(4px); }
}

.afx-field-note {
    min-height: 0;
    margin: 0;
    padding: 0 6px;
    font-size: 12.5px;
    line-height: 1.9;
    color: var(--afx-danger);
    opacity: 0;
    transform: translateY(-3px);
    transition: opacity var(--afx-fast) ease, transform var(--afx-fast) var(--afx-ease);
}

.afx-field-note.is-on { opacity: 1; transform: none; }
.afx-field-note.is-ok { color: #7ee2a8; }

/* --------------------------------------------------------------- collapse */
.afx-collapse {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transform: translateY(-6px);
    transition:
        grid-template-rows var(--afx-med) var(--afx-ease),
        opacity var(--afx-med) ease,
        transform var(--afx-med) var(--afx-ease);
}

.afx-collapse.is-open {
    grid-template-rows: 1fr;
    opacity: 1;
    transform: none;
}

.afx-collapse-inner {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px;
    margin: -4px;
    visibility: hidden;
    transition: visibility 0s var(--afx-med);
}

.afx-collapse.is-open .afx-collapse-inner {
    visibility: visible;
    transition: visibility 0s;
}

/* --------------------------------------------------- password ⇄ code swap */
.afx-swap { position: relative; }

.afx-swap-face { display: none; }

.afx-swap-face.is-front {
    display: block;
    animation: afx-face-in var(--afx-fast) var(--afx-ease) both;
}

@keyframes afx-face-in {
    from { opacity: 0; transform: scale(0.98); }
    to   { opacity: 1; transform: none; }
}

/* -------------------------------------------------------------------- eye */
.afx-eye {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    margin-inline-end: 6px;
    border: none;
    border-radius: 12px;
    background: transparent;
    cursor: pointer;
    position: relative;
    opacity: 0.5;
    transition: opacity var(--afx-fast) ease;
}

.afx-eye:hover { opacity: 0.85; }

.afx-eye::before {
    content: "";
    position: absolute;
    inset: 11px 10px;
    border-radius: 60% 60% 60% 60% / 100% 100% 100% 100%;
    border: 1.8px solid var(--afx-text);
}

.afx-eye::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5.5px;
    height: 5.5px;
    border-radius: 50%;
    background: var(--afx-text);
    transform: translate(-50%, -50%);
}

.afx-eye.is-off::before {
    -webkit-mask-image: linear-gradient(135deg, #000 44%, transparent 46%, transparent 54%, #000 56%);
    mask-image: linear-gradient(135deg, #000 44%, transparent 46%, transparent 54%, #000 56%);
}

/* ------------------------------------------------------------------ links */
.afx-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.afx-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    background: transparent;
    padding: 5px 2px;
    font: inherit;
    font-size: 13.5px;
    color: var(--afx-dim);
    cursor: pointer;
    transition: color var(--afx-fast) ease;
}

.afx-link:hover { color: var(--afx-amber); }

.afx-link-center { align-self: center; }

/* RTL back affordance: chevron sits on the LEFT of the text, pointing out */
.afx-link-back::after {
    content: "";
    width: 7px;
    height: 7px;
    border-inline-start: 1.8px solid currentColor;
    border-bottom: 1.8px solid currentColor;
    transform: rotate(45deg);
    margin-inline-start: 1px;
    transition: transform var(--afx-fast) var(--afx-ease);
}

.afx-link-back:hover::after { transform: rotate(45deg) translate(-1.5px, 1.5px); }

.afx-link-dot {
    width: 3.5px;
    height: 3.5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.24);
}

/* -------------------------------------------------------------- OTP boxes */
.afx-otp {
    display: flex;
    justify-content: center;
    gap: 9px;
}

.afx-otp input {
    width: 46px;
    height: 56px;
    border-radius: 14px;
    border: 1px solid var(--afx-well-line);
    background: var(--afx-well);
    color: var(--afx-text);
    font: inherit;
    font-size: 22px;
    font-weight: 800;
    text-align: center;
    outline: none;
    transition:
        border-color var(--afx-fast) ease,
        box-shadow var(--afx-fast) ease,
        transform 140ms var(--afx-ease);
    caret-color: var(--afx-coral);
}

.afx-otp input:focus {
    border-color: rgba(255, 122, 69, 0.7);
    box-shadow: 0 0 0 4px rgba(255, 122, 69, 0.14);
}

.afx-otp input.is-filled {
    border-color: rgba(255, 179, 71, 0.45);
    animation: afx-otp-pop 180ms var(--afx-ease);
}

@keyframes afx-otp-pop {
    45% { transform: scale(1.07); }
    100% { transform: none; }
}

.afx-otp.is-error input {
    border-color: rgba(255, 92, 112, 0.7);
    animation: afx-shake 400ms ease;
}

.afx-otp-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 22px;
}

.afx-otp-meta-center { justify-content: center; }

.afx-otp-hint {
    font-size: 12.5px;
    color: var(--afx-faint);
}

.afx-resend {
    border: none;
    background: transparent;
    padding: 5px 2px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    color: var(--afx-dim);
    cursor: pointer;
    transition: color var(--afx-fast) ease;
    font-variant-numeric: tabular-nums;
}

.afx-resend:hover:not(:disabled) { color: var(--afx-amber); }

.afx-resend:disabled {
    color: var(--afx-faint);
    cursor: default;
}

/* ------------------------------------------------------------- phone chip */
.afx-phone-chip {
    align-self: center;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 15px;
    border-radius: 999px;
    border: 1px solid var(--afx-well-line);
    background: var(--afx-well);
    color: var(--afx-text);
    font: inherit;
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color var(--afx-fast) ease, background var(--afx-fast) ease;
}

.afx-phone-chip:hover {
    border-color: rgba(255, 179, 71, 0.45);
    background: rgba(255, 179, 71, 0.08);
}

.afx-phone-chip svg { opacity: 0.6; }

.afx-panel-hint {
    margin: 0;
    text-align: center;
    font-size: 13.5px;
    line-height: 2;
    color: var(--afx-dim);
}

/* --------------------------------------------------------- username state */
.afx-uname-state {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    margin-inline-end: 8px;
    position: relative;
    display: grid;
    place-items: center;
}

.afx-uname-state::before {
    content: "";
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.16);
    border-top-color: var(--afx-amber);
    opacity: 0;
    transition: opacity 120ms ease;
}

.afx-uname-state.is-checking::before {
    opacity: 1;
    animation: afx-spin 700ms linear infinite;
}

.afx-uname-state svg {
    position: absolute;
    width: 20px;
    height: 20px;
}

.afx-uname-state .afx-ok path {
    stroke: var(--afx-good);
    stroke-dasharray: 26;
    stroke-dashoffset: 26;
}

.afx-uname-state.is-free .afx-ok path {
    animation: afx-draw 300ms var(--afx-ease) forwards;
}

.afx-uname-state .afx-no path { stroke: var(--afx-danger); opacity: 0; }
.afx-uname-state.is-taken .afx-no path { opacity: 1; }

@keyframes afx-draw { to { stroke-dashoffset: 0; } }
@keyframes afx-spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------- strength meter */
.afx-strength {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 6px;
    min-height: 16px;
}

.afx-strength-bars {
    display: flex;
    gap: 5px;
    flex: 0 0 auto;
}

.afx-strength-bars i {
    width: 26px;
    height: 4px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.11);
    transition: background var(--afx-med) ease;
}

.afx-strength[data-level="1"] i:nth-child(1) { background: var(--afx-amber); }
.afx-strength[data-level="2"] i:nth-child(-n+2) { background: #9ed75a; }
.afx-strength[data-level="3"] i { background: var(--afx-good); }

.afx-strength-label {
    font-size: 12px;
    color: var(--afx-faint);
}

/* ------------------------------------------------------------ match state */
.afx-match {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    margin-inline-end: 9px;
    display: grid;
    place-items: center;
    font-size: 15px;
    font-weight: 900;
    opacity: 0;
    transform: scale(0.6);
    transition: all 180ms var(--afx-ease);
}

.afx-match.is-on { opacity: 1; transform: none; }
.afx-match.is-ok { color: var(--afx-good); }
.afx-match.is-no { color: var(--afx-danger); }

/* ------------------------------------------------------------ avatar grid */
.afx-avatar-title {
    margin: 6px 0 0;
    text-align: center;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--afx-dim);
}

.afx-avatars {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    max-height: 236px;
    overflow-y: auto;
    padding: 6px 4px 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

/* bulletproof square cells (no aspect-ratio dependency) */
.afx-avatar {
    position: relative;
    width: 100%;
    padding: 0 0 100%;
    border: none;
    background: transparent;
    cursor: pointer;
}

.afx-avatar-inner {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    overflow: hidden;
    background: var(--afx-well);
    border: 2px solid transparent;
    display: grid;
    place-items: center;
    color: var(--afx-faint);
    transition: transform 170ms var(--afx-ease), border-color 170ms ease, box-shadow 170ms ease;
}

.afx-avatar-inner img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.afx-avatar:hover .afx-avatar-inner { transform: scale(1.06); }

.afx-avatar.is-selected .afx-avatar-inner {
    border-color: var(--afx-rose);
    box-shadow: 0 0 0 4px rgba(255, 77, 123, 0.2);
    transform: scale(1.04);
}

.afx-avatar-upload .afx-avatar-inner {
    border: 1.6px dashed rgba(255, 255, 255, 0.26);
    background: rgba(255, 255, 255, 0.03);
}

.afx-avatar-upload img:not([hidden]) ~ svg { display: none; }

/* -------------------------------------------------------------------- CTA */
.afx-cta {
    position: relative;
    overflow: hidden;
    min-height: 54px;
    border: none;
    border-radius: 16px;
    padding: 15px;
    font: inherit;
    font-size: 16.5px;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    background: var(--afx-grad);
    box-shadow:
        0 14px 34px -12px rgba(224, 46, 138, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    transition: transform var(--afx-fast) var(--afx-ease), box-shadow var(--afx-fast) ease, filter var(--afx-fast) ease;
}

.afx-cta:hover {
    transform: translateY(-1px);
    box-shadow:
        0 18px 40px -12px rgba(224, 46, 138, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.afx-cta:active { transform: scale(0.985); }

.afx-cta-label {
    display: inline-block;
    transition: opacity var(--afx-fast) ease, transform var(--afx-fast) var(--afx-ease);
}

.afx-cta-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border-radius: 50%;
    border: 2.5px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    opacity: 0;
    transition: opacity var(--afx-fast) ease;
}

.afx-cta.is-loading { pointer-events: none; filter: saturate(0.85); }

.afx-cta.is-loading .afx-cta-label {
    opacity: 0;
    transform: translateY(8px);
}

.afx-cta.is-loading .afx-cta-spinner {
    opacity: 1;
    animation: afx-spin 700ms linear infinite;
}

/* ---------------------------------------------------------------- message */
.afx-message {
    min-height: 0;
    margin: 14px 0 0;
    text-align: center;
    font-size: 13px;
    line-height: 1.9;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity var(--afx-fast) ease, transform var(--afx-fast) var(--afx-ease);
}

.afx-message.is-on { opacity: 1; transform: none; }
.afx-message.is-error { color: #ff8291; }
.afx-message.is-ok { color: #7ee2a8; }

/* --------------------------------------------------------------- noscript */
.afx-noscript {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

/* --------------------------------------------------------- honeypot field */
.auth-honeypot-field {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---------------------------------------------------------- small screens */
@media (max-width: 420px) {
    .afx-otp { gap: 7px; }

    .afx-otp input {
        width: 42px;
        height: 52px;
        font-size: 20px;
    }

    .afx-avatars { grid-template-columns: repeat(4, 1fr); }
}

/* ---------------------------------------------------------------- motion- */
@media (prefers-reduced-motion: reduce) {
    .afx-card,
    .afx-panel.is-leaving,
    .afx-panel.is-entering {
        animation-duration: 1ms !important;
        animation-delay: 0ms !important;
    }

    .afx-view,
    .afx-collapse {
        transition-duration: 1ms !important;
    }
}
