/* ─── Modal overlay blur fix ────────────────────────────────────────────────
 * Unfold's modal overlay has backdrop-blur-xs and covers the full viewport.
 * Alpine.js uses x-cloak + x-show="openModal" to hide it. When Alpine fails
 * to evaluate x-show (e.g. CSP blocks unsafe-eval), x-cloak is still removed
 * but no inline style is set — leaving the overlay visible and blurring the
 * entire page. This rule hides the overlay when Alpine has NOT set the
 * inline style attribute yet, without breaking the modal when it is open.
 */
#modal-overlay:not([style]),
#modal-overlay[style=""] {
    display: none !important;
}

/* ─── Login page ─────────────────────────────────────────────────────────── */
body.login {
    background: linear-gradient(135deg, #0f0f1a 0%, #1a1a2e 50%, #16213e 100%) !important;
}

body.login #page {
    background: transparent !important;
    min-height: 100vh;
    display: flex;
    /* Use flex-start so tall content scrolls rather than being clipped */
    align-items: flex-start;
    justify-content: center;
    position: relative;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    overflow-x: hidden;
}

/* Centre vertically only when there's enough room */
@media (min-height: 600px) {
    body.login #page {
        align-items: center;
    }
}

/* Subtle background orbs — clamp size to viewport */
body.login #page::before,
body.login #page::after {
    content: "";
    position: fixed;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}
body.login #page::before {
    width: min(500px, 80vw);
    height: min(500px, 80vw);
    background: #4f46e5;
    top: -100px;
    left: -100px;
}
body.login #page::after {
    width: min(400px, 70vw);
    height: min(400px, 70vw);
    background: #7c3aed;
    bottom: -80px;
    right: -80px;
}

/* Login card wrapper */
body.login .flex.grow.items-center {
    position: relative;
    z-index: 1;
    width: 100%;
    padding-top: 2rem;
    padding-bottom: 2rem;
    box-sizing: border-box;
}

body.login .w-full.sm\:w-96 {
    background: rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow:
        0 0 0 1px rgba(79, 70, 229, 0.1),
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 8px 24px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

/* Tighten card padding on small screens */
@media (max-width: 480px) {
    body.login .w-full.sm\:w-96 {
        padding: 1.5rem 1.25rem;
        border-radius: 12px;
    }

    body.login .flex.grow.items-center {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Site title text on login */
body.login h1,
body.login .text-2xl,
body.login .font-semibold {
    color: #f8fafc !important;
}

body.login .text-font-default-light,
body.login p,
body.login label {
    color: rgba(248, 250, 252, 0.7) !important;
}

/* Input fields */
body.login input[type="text"],
body.login input[type="password"] {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
    color: #f8fafc !important;
    transition: border-color 0.2s, background 0.2s;
}
body.login input[type="text"]:focus,
body.login input[type="password"]:focus {
    background: rgba(255, 255, 255, 0.09) !important;
    border-color: rgba(99, 102, 241, 0.6) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15) !important;
    outline: none;
}
body.login input::placeholder {
    color: rgba(248, 250, 252, 0.35) !important;
}

/* Primary button */
body.login button[type="submit"],
body.login .submit-row button {
    background: linear-gradient(135deg, #4f46e5, #7c3aed) !important;
    border: none !important;
    color: #fff !important;
    font-weight: 600 !important;
    letter-spacing: 0.02em;
    transition: opacity 0.2s, transform 0.15s;
}
body.login button[type="submit"]:hover,
body.login .submit-row button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Secondary / forgot password button */
body.login .password-reset-link a,
body.login .password-reset-link button {
    color: rgba(167, 139, 250, 0.85) !important;
    border-color: rgba(167, 139, 250, 0.2) !important;
}
body.login .password-reset-link a:hover,
body.login .password-reset-link button:hover {
    color: rgba(167, 139, 250, 1) !important;
    border-color: rgba(167, 139, 250, 0.4) !important;
}

/* Error messages */
body.login .text-red-500,
body.login .text-red-600 {
    color: #f87171 !important;
}

/* "Return to site" link */
body.login .text-primary-600 {
    color: rgba(167, 139, 250, 0.8) !important;
}
body.login .text-primary-600:hover {
    color: rgba(167, 139, 250, 1) !important;
}

/* ─── Login page — mobile touch targets & overflow guard ──────────────── */
@media (max-width: 640px) {
    /* Full-width, tappable inputs */
    body.login input[type="text"],
    body.login input[type="password"] {
        min-height: 44px !important;
        font-size: 16px !important; /* prevents iOS auto-zoom on focus */
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Full-width buttons with comfortable tap area */
    body.login button[type="submit"],
    body.login .submit-row button,
    body.login .password-reset-link a,
    body.login .password-reset-link button {
        min-height: 44px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        font-size: 0.95rem !important;
    }

    /* Prevent any child overflowing the card */
    body.login .w-full.sm\:w-96 * {
        max-width: 100%;
    }

    /* Tighten heading on mobile */
    body.login h1,
    body.login .text-2xl {
        font-size: 1.35rem !important;
    }
}
