@import url('./variables.css');
@import url('./button-states.css');
.auth-page { min-height: 65vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: min(100% - 32px, 440px); padding: 32px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg1); color: var(--text); box-shadow: var(--shadow); text-align: start; }
.auth-card h1 { font-size: inherit; margin-block: 0 16px; }
.auth-card > p { color: var(--muted); }
.auth-form { display: grid; gap: 16px; margin-block: 24px; }
.auth-form label { display: grid; gap: 8px; }
.auth-form input { width: 100%; border: 1px solid var(--text3); border-radius: var(--radius2); padding: 12px; background: var(--bg2); color: var(--text); font: inherit; }
.auth-button { border: 0; border-radius: var(--radius2); padding: 10px 16px; background: var(--primary-2); color: var(--white); font: inherit; cursor: pointer; text-decoration: none; }
.auth-button:disabled { opacity: .6; cursor: wait; }
.auth-form :is(input, select, textarea):focus-visible { outline: 2px solid var(--text1); outline-offset: 3px; }
.auth-message { color: var(--ui-error-text, #ff969e); margin: 0; overflow-wrap: anywhere; }
.auth-form .auth-message[data-success="true"] { color: var(--text-green, #94d924); }
.auth-message:empty { display: none; }
.auth-dialog { box-sizing: border-box; width: min(100% - 32px, 440px); padding: 24px; border: 1px solid #303844; border-radius: 12px; background: #11151b; color: #f9f9f9; box-shadow: 0 18px 48px rgba(0, 0, 0, .53); text-align: start; margin: auto; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; }
.auth-dialog::backdrop { background: rgba(0, 0, 0, .72); }
.auth-close { display: flex; align-items: center; justify-content: center; width: 30px; height: 30px; margin-inline-start: auto; padding: 0; border: 1px solid #202630; border-radius: 5px; background: transparent; color: #f9f9f9; cursor: pointer; }
@media (max-width: 600px) {
    .auth-card { padding: 24px 20px; }
}

.auth-form [hidden] { display: none; }
.auth-form h3, .auth-form p { margin: 0; }
.auth-form [data-auth-email]:empty, .auth-form [data-auth-dispatch]:empty { display: none; }
.auth-email, .auth-form input[dir="ltr"] { text-align: left; overflow-wrap: anywhere; }
.auth-link { border: 0; background: transparent; color: var(--text1); font: inherit; cursor: pointer; text-decoration: underline; padding: 8px; }
.auth-link:disabled { opacity: .6; cursor: wait; }
.auth-form [name="otp"] { letter-spacing: .2em; }

.auth-nav { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 12px; }
.auth-nav [hidden] { display: none !important; }
.auth-nav a, .auth-nav button { color: var(--text, #f9f9f9); background: var(--bg1, #0c0f14); border: 1px solid var(--line, #303844); border-radius: 5px; padding: 8px 10px; font: inherit; text-decoration: none; cursor: pointer; }
.auth-nav button:disabled { opacity: .6; cursor: wait; }
.auth-nav [data-auth-nav-message] { max-width: 220px; overflow-wrap: anywhere; }
.auth-nav [data-auth-nav-message]:empty { display: none; }
.auth-form [data-auth-help] { color: var(--muted); font: inherit; }

/* Match current dark surfaces; light-theme consumers can override color-scheme. */
.auth-card, .auth-dialog, .auth-nav, .simulator-page { color-scheme: dark; --ui-error-text: #ff969e; --ui-error-text: light-dark(#b42332, #ff969e); }
.headerContainer > .auth-nav { margin-inline-start: auto; flex-shrink: 0; }
.auth-nav [data-auth-nav-message][data-error="true"] { color: var(--ui-error-text); }

.auth-form [data-error="true"] { color: var(--ui-error-text, #ff969e); }
@media (max-width: 600px) { .headerContainer { flex-wrap: wrap; column-gap: 12px; row-gap: 8px; } }

/* Inherit the host site's Yekan/IRANYekan scale, including native form controls. */
.auth-card, .auth-dialog { font: inherit; direction: rtl; }
.auth-card :is(h1, h2, h3, label, input, button, p), .auth-dialog :is(label, input, button, p) { font: inherit; }
.auth-card :is(h1, h2, h3) { font-weight: bold; }
.auth-dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-block-start: 18px; }


/* Figma Journal 1:2318 and destructive modal 1:3392; Persian font stays local. */
.auth-dialog h2 { font-size: 20px; font-weight: 700; line-height: normal; margin: 18px 0 8px; }
.auth-dialog h3 { font-size: 15px; font-weight: 400; line-height: normal; }
.auth-dialog p { font-size: 12px; line-height: 1.55; color: #a7adb6; margin: 0; }
.auth-dialog .auth-form { gap: 14px; margin-block: 18px; }
.auth-dialog .auth-form label { gap: 6px; font-size: 10px; color: #6e7174; }
.auth-dialog .auth-form input { box-sizing: border-box; height: 34px; padding: 7px 10px; border-color: #303844; border-radius: 5px; background: #07090c; color: #f9f9f9; font-size: 12px; line-height: normal; }
.auth-dialog :is(.auth-button, .auth-link) { box-sizing: border-box; min-height: 34px; padding: 0 12px; border: 1px solid #161b23; border-radius: 5px; background: #161b23; color: #f9f9f9; font-size: 11px; line-height: normal; text-decoration: none; }
.auth-dialog .auth-button:not(.auth-button-danger) { border-color: #0067ff; background: #0067ff; }
.auth-dialog .auth-message, .auth-dialog [data-error="true"] { color: var(--ui-error-text, #ff969e); }
.auth-dialog-top { display: flex; justify-content: space-between; align-items: flex-start; }
.auth-dialog-warning { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 999px; background: #321820; }
.auth-dialog-warning img { display: block; }

.auth-dialog .auth-button.auth-button-danger { background: #321820; color: #ff5b68; border-color: #ff5b68; }
.auth-dialog-top .auth-close { margin: 0; }

/* Shared native-dialog motion; close() waits for the exit in shared/dialog.js. */
.auth-dialog[open] { animation: nomagar-dialog-in 180ms cubic-bezier(.2,.7,.3,1) both; }
.auth-dialog[open]::backdrop { animation: nomagar-backdrop-in 180ms ease-out both; }
.auth-dialog[open].is-closing { animation: nomagar-dialog-out 180ms ease-in both; pointer-events: none; }
.auth-dialog[open].is-closing::backdrop { animation: nomagar-backdrop-out 180ms ease-in both; }
@keyframes nomagar-dialog-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
@keyframes nomagar-dialog-out { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(.96); } }
@keyframes nomagar-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes nomagar-backdrop-out { from { opacity: 1; } to { opacity: 0; } }
.auth-button[data-loading="true"]::before { content: ''; display: inline-block; width: 1em; height: 1em; margin-inline-end: 8px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; vertical-align: middle; animation: nomagar-spin .8s linear infinite; }
@keyframes nomagar-spin { to { transform: rotate(360deg); } }
.auth-captcha { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 8px 12px; }
.auth-captcha [data-captcha-widget] { grid-column: 1 / -1; min-width: 0; max-width: 100%; display: flex; overflow-x: auto; overflow-y: hidden; }
.auth-captcha [data-captcha-widget] > div { flex: none; margin-inline: auto; }
/* Trim Google's outer iframe gutter/rim; keep checkbox, branding and focus intact. */
.auth-captcha [data-captcha-widget] iframe { display: block; clip-path: inset(3px round 5px); }
.auth-form .auth-captcha [data-captcha-status] { font: inherit; font-size: 12px; line-height: 1.55; color: var(--muted); overflow-wrap: anywhere; }
.auth-form .auth-captcha [data-captcha-refresh] { min-height: 24px; padding: 2px 4px; border: 0; background: transparent; color: var(--muted); font-size: 12px; line-height: 1.55; text-decoration: underline; white-space: nowrap; }
.auth-form .auth-captcha [data-captcha-status][data-error="true"] { color: var(--ui-error-text, #ff969e); }
/* Plain links retain their keyboard indicator; buttons use button-states.css. */
:is(.auth-card, .auth-dialog) a:not(.auth-button):focus-visible { outline: 2px solid var(--text, #f9f9f9); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
    .auth-dialog[open], .auth-dialog[open]::backdrop, .auth-button[data-loading="true"]::before { animation: none; }
}

/* Auth uses a document layer: Google's external image/audio portal must remain above it. */
.auth-dialog.auth-overlay-dialog[open] { position: fixed; inset: 0; height: fit-content; z-index: 10000; }
.auth-modal-backdrop { position: fixed; inset: 0; z-index: 9999; background: rgba(0, 0, 0, .72); animation: nomagar-backdrop-in 180ms ease-out both; }
.auth-modal-backdrop.is-closing { animation: nomagar-backdrop-out 180ms ease-in both; }
@media (prefers-reduced-motion: reduce) { .auth-modal-backdrop { animation: none; } }
