/* Identity pages (sign in, sign up, password, verification, workspace choice, sign out).
   Tokens mirror the SPA's src/Apps/ClientApp/src/index.css (light :root and .dark) and the
   Swatch Book rules in DESIGN.md: warm paper ground, white sheets, graphite ink, violet only for
   the primary action and focus. Keep the values in step with index.css when it changes. */

:root {
    color-scheme: light;
    --background: oklch(97.5% 0.002 90);
    --foreground: oklch(21% 0.006 285);
    --card: oklch(100% 0 0);
    --muted: oklch(96.4% 0.003 90);
    --muted-foreground: oklch(46% 0.008 285);
    --surface-hover: oklch(21% 0.006 285 / 0.065);
    --border: oklch(92% 0.004 90);
    --border-field: oklch(86% 0.005 90);
    --border-strong: oklch(64% 0.006 285);
    --input-background: oklch(100% 0 0);
    --input-placeholder: oklch(50% 0.008 285);
    --primary: oklch(52% 0.24 295);
    --primary-foreground: oklch(99% 0.004 295);
    --primary-hover: oklch(43% 0.2 295);
    --ring: oklch(55% 0.2 295);
    --destructive: oklch(54% 0.19 25);
    --destructive-200: oklch(97% 0.02 25);
    --brand-1: oklch(45% 0.24 285);
    --brand-2: oklch(55% 0.22 295);
    --brand-3: oklch(52% 0.24 295);
    --brand-4: oklch(65% 0.18 305);
    --brand-5: oklch(60% 0.2 315);
    --shadow-color: oklch(21% 0.006 285);
    --shadow-xs: 0 1px 2px 0 color-mix(in oklch, var(--shadow-color) 6%, transparent);
    --font-sans: 'Inter', 'Noto Sans Arabic', ui-sans-serif, system-ui, sans-serif;
}

/* Graphite dark, applied by the stored choice or, before the toggle is used, the system setting. */
:root[data-theme="dark"] {
    color-scheme: dark;
    --background: oklch(18% 0.004 285);
    --foreground: oklch(94.5% 0.003 285);
    --card: oklch(21% 0.005 285);
    --muted: oklch(25% 0.005 285);
    --muted-foreground: oklch(72% 0.008 285);
    --surface-hover: oklch(94.5% 0.003 285 / 0.065);
    --border: oklch(28.5% 0.005 285);
    --border-field: oklch(35% 0.006 285);
    --border-strong: oklch(56% 0.006 285);
    --input-background: oklch(19.5% 0.004 285);
    --input-placeholder: oklch(66% 0.008 285);
    --primary: oklch(70% 0.16 295);
    --primary-foreground: oklch(18% 0.03 295);
    --primary-hover: oklch(62% 0.145 295);
    --ring: oklch(72% 0.14 295);
    --destructive: oklch(70% 0.16 25);
    --destructive-200: oklch(25% 0.05 25);
    --brand-1: oklch(63% 0.15 285);
    --brand-2: oklch(70% 0.15 295);
    --brand-3: oklch(70% 0.16 295);
    --brand-4: oklch(74% 0.13 160);
    --brand-5: oklch(68% 0.13 315);
    --shadow-color: oklch(6% 0.004 285);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
        --background: oklch(18% 0.004 285);
        --foreground: oklch(94.5% 0.003 285);
        --card: oklch(21% 0.005 285);
        --muted: oklch(25% 0.005 285);
        --muted-foreground: oklch(72% 0.008 285);
        --surface-hover: oklch(94.5% 0.003 285 / 0.065);
        --border: oklch(28.5% 0.005 285);
        --border-field: oklch(35% 0.006 285);
        --border-strong: oklch(56% 0.006 285);
        --input-background: oklch(19.5% 0.004 285);
        --input-placeholder: oklch(66% 0.008 285);
        --primary: oklch(70% 0.16 295);
        --primary-foreground: oklch(18% 0.03 295);
        --primary-hover: oklch(62% 0.145 295);
        --ring: oklch(72% 0.14 295);
        --destructive: oklch(70% 0.16 25);
        --destructive-200: oklch(25% 0.05 25);
        --brand-1: oklch(63% 0.15 285);
        --brand-2: oklch(70% 0.15 295);
        --brand-3: oklch(70% 0.16 295);
        --brand-4: oklch(74% 0.13 160);
        --brand-5: oklch(68% 0.13 315);
        --shadow-color: oklch(6% 0.004 285);
    }
}

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

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

body {
    margin: 0;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    font-feature-settings: 'cv11' 1, 'ss03' 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* ---------- Flow frame: brand at the top, one task in a centred column ---------- */

.flow {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.flow-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    max-width: 72rem;
    height: 64px;
    margin-inline: auto;
    padding-inline: 16px;
    flex-shrink: 0;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    border-radius: 6px;
}

.brand-link:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.logo {
    display: block;
    width: auto;
    height: 28px;
    /* SVG text follows the page's direction; the Latin wordmark must not flip in Arabic. */
    direction: ltr;
    unicode-bidi: isolate;
}

.logo-clock-hand {
    transform-origin: 0 0;
    animation: clio-clock-hand 4s ease-in-out infinite;
}

@keyframes clio-clock-hand {
    0%, 100% { transform: rotate(-30deg); }
    50% { transform: rotate(-25deg); }
}

.flow-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.control-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted-foreground);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: background-color 150ms, color 150ms;
}

.control-button:hover { background: var(--surface-hover); color: var(--foreground); }
.control-button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.control-icon { width: 36px; padding: 0; }

.theme-icon-dark { display: none; }
:root[data-theme="dark"] .theme-icon-dark { display: block; }
:root[data-theme="dark"] .theme-icon-light { display: none; }

.flow-main {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px 64px;
}

.flow-column { width: 100%; max-width: 28rem; }
.flow-column-wide { max-width: 36rem; }

.sheet {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px 20px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
}

@media (min-width: 640px) {
    .flow-header { padding-inline: 24px; }
    .flow-main { padding-inline: 24px; }
    .sheet { padding: 32px; }
}

/* ---------- Headline block ---------- */

.intro { display: flex; flex-direction: column; gap: 8px; }

.intro-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card);
    color: var(--muted-foreground);
}

.intro-icon-attention {
    border-color: color-mix(in oklch, var(--destructive) 25%, transparent);
    background: color-mix(in oklch, var(--destructive) 10%, transparent);
    color: var(--destructive);
}

.intro-title {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.012em;
    text-wrap: balance;
}

/* Arabic joins break under letter-spacing. */
[dir="rtl"] .intro-title { letter-spacing: 0; }

.intro-description {
    margin: 0;
    color: var(--muted-foreground);
    font-size: 15px;
    line-height: 1.6;
    text-wrap: pretty;
}

/* ---------- Forms ---------- */

.form { display: flex; flex-direction: column; gap: 20px; }

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

.label { font-size: 14px; font-weight: 500; line-height: 1.25; }

.input {
    width: 100%;
    height: 36px;
    padding: 7px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--input-background);
    box-shadow: var(--shadow-xs);
    color: var(--foreground);
    font-size: 14px;
    line-height: 20px;
    outline: none;
    transition: border-color 150ms, box-shadow 150ms;
}

.input::placeholder { color: var(--input-placeholder); opacity: 1; }
.input:hover { border-color: var(--muted-foreground); }

.input:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 25%, transparent);
}

.input[aria-invalid="true"] { border-color: var(--destructive); }

.input[aria-invalid="true"]:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in oklch, var(--destructive) 25%, transparent);
}

/* Email addresses read left to right in either language; in Arabic they sit at the start edge. */
[dir="rtl"] .input[dir="ltr"] { text-align: right; }

.password-control { position: relative; }
.password-control .input { padding-inline-end: 40px; }

.password-toggle {
    position: absolute;
    inset-block: 0;
    inset-inline-end: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-block: auto;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
}

.password-toggle:hover { color: var(--foreground); }
.password-toggle:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }

.password-toggle-hide { display: none; }
.password-control:has(input[type="text"]) .password-toggle-show { display: none; }
.password-control:has(input[type="text"]) .password-toggle-hide { display: block; }

.hint { margin: 0; color: var(--muted-foreground); font-size: 13px; line-height: 1.5; }
.field-error { margin: 0; color: var(--destructive); font-size: 13px; line-height: 1.5; }

.field-aside { display: flex; justify-content: flex-end; margin-top: -8px; }

.consent { text-align: center; }

/* ---------- Buttons and links ---------- */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 150ms, border-color 150ms, color 150ms, transform 150ms;
}

.button:active { transform: scale(0.98); }

.button:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}

.button-primary {
    background: var(--primary);
    box-shadow: var(--shadow-xs);
    color: var(--primary-foreground);
}

.button-primary:hover { background: var(--primary-hover); }

.button-secondary {
    border-color: var(--border-field);
    background: var(--card);
    box-shadow: var(--shadow-xs);
    color: var(--foreground);
}

.button-secondary:hover { background: color-mix(in oklch, var(--card), var(--foreground) 5%); }

.button-block { width: 100%; }

.link {
    border-radius: 4px;
    color: var(--foreground);
    font-weight: 500;
    text-decoration: none;
    text-underline-offset: 3px;
}

.link:hover { text-decoration: underline; }
.link:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.link-quiet { color: var(--muted-foreground); font-size: 13px; }
.link-quiet:hover { color: var(--foreground); }

.back-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    border-radius: 6px;
    color: var(--muted-foreground);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: color 150ms;
}

.back-link:hover { color: var(--foreground); }
.back-link:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

[dir="rtl"] .back-link .icon,
[dir="rtl"] .choice-chevron { transform: scaleX(-1); }

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

.aside {
    margin: 20px 0 0;
    color: var(--muted-foreground);
    font-size: 14px;
    text-align: center;
}

.aside .link { margin-inline-start: 4px; }

/* ---------- Status ---------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
}

.alert p { margin: 0; }

.alert-destructive {
    border-color: color-mix(in oklch, var(--destructive) 30%, var(--card));
    background: var(--destructive-200);
    color: var(--foreground);
}

.alert-icon { flex: none; margin-top: 2px; color: var(--destructive); }

/* ---------- External providers ---------- */

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted-foreground);
    font-size: 12px;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.providers { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Workspace choice ---------- */

.choice-list {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    list-style: none;
}

.choice-list li + li { border-top: 1px solid var(--border); }
.choice-list form { margin: 0; }

.choice {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 10px 12px;
    border: 0;
    background: var(--card);
    color: var(--foreground);
    font-size: 14px;
    font-weight: 500;
    text-align: start;
    cursor: pointer;
    transition: background-color 150ms;
}

.choice:hover { background: var(--muted); }
.choice:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }

.choice-mark {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--muted);
    font-weight: 600;
}

.choice-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choice-chevron { flex: none; color: var(--muted-foreground); }

.empty-note { margin: 0; color: var(--muted-foreground); font-size: 14px; }

.icon { flex: none; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}
