/* kordi.ai log in, sign up and account pages.
 * Loaded after research-preview/public/styles.css and assets/public/theme.css,
 * and only by these pages. They use the home page's tokens, type, buttons,
 * header and footer; this file adds forms, cards and the account layout.
 * The fonts come from theme.css. */

:root {
  --surface: #fcfbf9;
  --rule-strong: #d6c6bf;
  --error: #b42318;
  --error-bg: #fdf3f1;
  --error-rule: #f1d3cc;
}

[hidden] { display: none !important; }

/* The footer stays at the bottom of short pages. */
body[data-page], body.x-auth-page { min-height: 100vh; display: flex; flex-direction: column; }
body[data-page] > main, body.x-auth-page > main { flex: 1 0 auto; }

/* Buttons are the home page's: cardinal primary, outlined secondary. */
.btn, .registration-form .btn { justify-content: center; border-radius: 999px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:disabled:hover { transform: none; }
.btn:not(.secondary):disabled:hover { background: var(--cardinal); border-color: var(--cardinal); }
.btn.secondary:disabled:hover { color: var(--ink); background: transparent; border-color: var(--ink); }
.btn .mark, .btn .x-ic { width: 16px; height: 16px; flex: none; }

/* Text buttons that read as links. */
.x-linkbtn { padding: 0; border: 0; background: none; color: var(--cardinal); font: inherit; font-weight: 500; cursor: pointer; }
.x-linkbtn:hover { color: var(--deep-red); text-decoration: underline; text-underline-offset: 4px; }
.registration-back { display: block; width: fit-content; color: var(--muted); font-size: .875rem; text-decoration: none; }
.registration-back:hover { color: var(--cardinal); }

/* "or" divider on the hairline. */
.x-or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: .875rem; }
.x-or::before, .x-or::after { content: ""; flex: 1; height: 1px; background: var(--rule); }

/* Fields: the iPhone request form's inputs. */
.registration-form { display: grid; gap: 20px; }
.registration-field { display: grid; gap: 8px; font-size: .875rem; }
.registration-field label { color: var(--ink); font-size: .875rem; font-weight: 500; }
.registration-field input, .registration-field textarea { width: 100%; min-width: 0; border: 1px solid var(--rule); border-radius: 8px; padding: 12px 14px; background: var(--paper); color: var(--ink); font: 400 1rem/1.5 var(--body); transition: border-color 120ms ease; }
.registration-field input { height: 48px; }
.registration-field textarea { min-height: 112px; resize: vertical; }
.registration-field input:hover, .registration-field textarea:hover { border-color: var(--rule-strong); }
.registration-field input:focus-visible, .registration-field textarea:focus-visible { outline: 2px solid var(--cardinal); outline-offset: 2px; border-color: var(--rule); }
.registration-field input:user-invalid, .registration-field textarea:user-invalid { border-color: var(--error); }
.registration-field input[readonly] { background: var(--paper-alt); color: var(--muted); }
.registration-field input[readonly]:hover { border-color: var(--rule); }
.registration-field .field-help { margin: 0; color: var(--muted); font-size: .8125rem; line-height: 1.5; }
.registration-field .field-help a { font-weight: 500; }
.registration-status[role="alert"] { margin: 0; padding: 10px 14px; border: 1px solid var(--error-rule); border-radius: 8px; background: var(--error-bg); color: var(--error); font-size: .875rem; line-height: 1.5; }

/* Cards and rows: the home page's bordered panels. */
.x-card { padding: 24px; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); }
.x-card h2, .x-card h3 { margin: 0; color: var(--ink); font-family: var(--body); font-size: 1rem; font-weight: 500; line-height: 1.45; letter-spacing: -.01em; }
.x-card p { margin: 2px 0 0; color: var(--muted); font-size: .9375rem; line-height: 1.55; overflow-wrap: anywhere; }
.x-card .x-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.x-card .registration-form { margin-top: 16px; }
.x-card-row { display: flex; align-items: center; gap: 14px; }
.x-grow { flex: 1; min-width: 0; }
.x-card-row .btn { margin: 0; padding: .5rem .9rem; font-size: .875rem; white-space: nowrap; }
.x-meta { flex: none; color: var(--muted); font-size: .875rem; white-space: nowrap; }
.x-list { padding: 0; }
.x-list > .x-card-row { padding: 16px 24px; }
.x-list > .x-card-row:not([hidden]) ~ .x-card-row { border-top: 1px solid var(--rule); }
.x-sep:not(:empty)::before { content: " · "; }
.is-due { color: var(--ink); font-weight: 500; }

/* Leading marks: initials chips, the bird, or a device icon. */
.x-av, .x-tile { flex: none; display: grid; place-items: center; width: 40px; height: 40px; aspect-ratio: 1; border-radius: 50%; background: var(--paper-alt); color: var(--ink); font-size: .8125rem; font-weight: 500; }
.x-tile, .x-av.is-plain { border-radius: 10px; border: 1px solid var(--rule); background: var(--paper); }
.x-tile[data-account] { border: 0; background: var(--paper-alt); }
.x-av svg { width: 18px; height: 18px; color: var(--ink); }
.x-tile img { width: 20px; height: 20px; }

/* Role and status labels. */
.x-tag { flex: none; display: inline-flex; align-items: center; min-height: 24px; padding: 0 10px; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper); color: var(--muted); font-size: .8125rem; font-weight: 500; white-space: nowrap; }

/* Notices beside account rows. */
.x-status { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin: 0; padding: 14px 18px; border: 1px solid var(--rule); border-radius: 12px; background: var(--surface); color: var(--ink); font-size: .9375rem; }
.x-status span { flex: 1 1 260px; }
.x-status .btn { margin: 0; padding: .5rem .9rem; font-size: .875rem; }

/* One-time code. */
.x-code { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 0 6px 0 16px; border: 1px solid var(--rule); border-radius: 8px; background: var(--paper); font: 500 1.25rem var(--body); letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.x-code > span { min-width: 0; overflow-wrap: anywhere; }
.x-code.is-long { padding-block: 8px; font-size: .875rem; letter-spacing: 0; }
.x-code .btn { margin: 0; padding: .5rem .9rem; font-size: .875rem; letter-spacing: 0; }
.x-code-card .x-code-for { margin: 0 0 12px; color: var(--ink); font-size: .9375rem; font-weight: 500; }
.x-code-card .x-code + p { margin-top: 12px; }
.x-code-card p.x-expiry { margin-top: 4px; color: var(--muted); font-size: .8125rem; }

/* Log in, sign up and the app hand-off: the home page's header and footer
 * around one narrow column with the interior page title. */
.x-auth { display: flex; flex-direction: column; align-items: center; padding-block: clamp(40px, 8vh, 80px) 56px; }
.x-auth-card { width: min(100%, 440px); }
/* Form pages take the title size of the iPhone request and Research pages. */
.interior-page .x-auth-card h1 { font-size: clamp(2.5rem, 1.6rem + 2.6vw, 3.75rem); line-height: 1.06; letter-spacing: -.045em; }
.interior-page .x-auth-card h1 { margin: 0 0 32px; text-align: center; }
.interior-page .x-auth-card h1:has(+ .x-lede:not([hidden])) { margin-bottom: 12px; }
.x-auth .x-lede { margin: 0 0 28px; color: var(--muted); font-size: 1.0625rem; line-height: 1.6; text-align: center; }
.x-auth .x-social { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.x-auth .x-social .btn, .x-auth .registration-form .btn { width: 100%; margin: 0; }
.x-auth .registration-form > .btn[type="submit"] { margin-top: 4px; }
.x-auth .x-or { margin: 4px 0; }
.x-auth .x-sent { margin: -12px 0 4px; color: var(--muted); font-size: .9375rem; line-height: 1.6; text-align: center; }
.x-auth .x-sent span { color: var(--ink); font-weight: 500; }
.x-auth .account-switch { margin: 28px 0 0; color: var(--muted); font-size: .9375rem; text-align: center; }
.x-auth .account-switch a { font-weight: 500; }
.x-auth > .x-auth-foot { width: min(100%, 440px); margin: 40px 0 0; color: var(--muted); font-size: .8125rem; line-height: 1.6; text-align: center; }

/* The account chooser: the signed-in account as one bordered row. */
.x-chooser { gap: 10px; }
.x-choice { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; border: 1px solid var(--rule); border-radius: 12px; background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: background-color 120ms ease, border-color 120ms ease; }
.x-choice:hover { background: #f6e9e5; border-color: var(--cardinal); }
.x-choice:disabled { opacity: .6; cursor: progress; }
.x-choice .x-grow { display: grid; }
.x-choice-name { overflow: hidden; color: var(--ink); font-size: 1rem; font-weight: 500; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.x-choice-email { overflow: hidden; color: var(--muted); font-size: .875rem; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.x-chev { flex: none; width: 16px; height: 16px; color: var(--muted); }
.x-chooser .x-or { margin: 6px 0; }

/* The hand-off: a spinner while Kordi opens, then a quiet fallback. */
.x-opening { display: grid; justify-items: center; gap: 24px; padding-block: 4px; }
.interior-page .x-opening h1 { margin: 0; }
.x-spinner { width: 28px; height: 28px; border: 2px solid var(--rule); border-top-color: var(--cardinal); border-radius: 50%; animation: x-spin 700ms linear infinite; }
@keyframes x-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .x-spinner { animation-duration: 2.4s; } }
.x-done .x-quiet { margin: -16px 0 0; color: var(--muted); font-size: .9375rem; text-align: center; }
.x-done > .registration-status[role="alert"] { margin-top: 16px; }
.x-done .registration-back { margin: 16px auto 0; }
.x-done .x-confirm h2 { text-align: center; }
.x-done .x-confirm .x-actions { justify-content: center; }

/* Account settings: a side column (the signed-in person and the section
 * links) beside the page title and grouped cards of rows. Settings pages are
 * compact: a modest title, small section labels, short rows and small
 * buttons, in the home page's type and colors. */
.x-settings { max-width: 1040px; display: grid; grid-template-columns: 200px minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "side head" "side body"; align-content: start; column-gap: 48px; padding-block: 40px 80px; }
.x-side { grid-area: side; align-self: start; position: sticky; top: 24px; display: grid; gap: 8px; min-width: 0; }
.x-me { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0 10px 12px; border-bottom: 1px solid var(--rule); }
.x-me p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x-me-name { color: var(--ink); font-size: .875rem; font-weight: 500; line-height: 1.4; }
.x-me-email { color: var(--muted); font-size: .75rem; line-height: 1.4; }
/* Name and email keep their line boxes while empty, so the side column
 * never changes height when the account arrives. */
.x-me p { min-height: 1.4em; }
.x-side nav { display: grid; align-items: stretch; gap: 2px; }
.x-side nav a { display: flex; align-items: center; min-height: 34px; padding: 0 10px; border-radius: 8px; color: var(--muted); font-size: .875rem; line-height: 1.3; text-decoration: none; transition: background-color 120ms ease, color 120ms ease; }
.x-side nav a:hover { color: var(--cardinal); background: var(--selected); text-decoration: none; }
.x-side nav a[aria-current] { color: var(--cardinal); background: var(--selected); font-weight: 500; }

.x-head { grid-area: head; display: grid; align-content: start; gap: 6px; margin-bottom: 20px; }
.interior-page .x-head h1 { max-width: none; font-size: 1.875rem; line-height: 1.2; letter-spacing: -.03em; }
.x-head .registration-intro { margin: 0; max-width: 52ch; color: var(--muted); font-size: .9375rem; line-height: 1.55; }

.x-settings .x-account-body { grid-area: body; display: grid; align-content: start; gap: 8px; min-width: 0; max-width: 680px; }
.x-settings .x-section-label { margin: 20px 0 2px; color: var(--ink); font-family: var(--body); font-size: 1.0625rem; font-weight: 600; line-height: 1.4; letter-spacing: -.01em; }
.x-settings .x-section-label:first-child { margin-top: 0; }
.x-settings .x-card { padding: 18px 20px; border-radius: 12px; }
.x-settings .x-list { padding: 0; }
.x-settings .x-card.x-card-row, .x-settings .x-list > .x-card-row { min-height: 56px; padding: 12px 16px; gap: 12px; }
.x-settings .x-card h2, .x-settings .x-card h3 { font-size: .9375rem; line-height: 1.4; }
.x-settings .x-card p { margin-top: 1px; font-size: .8125rem; line-height: 1.45; }
.x-settings .x-av, .x-settings .x-tile { width: 32px; height: 32px; font-size: .75rem; }
.x-settings .x-tile, .x-settings .x-av.is-plain { border-radius: 8px; }
.x-settings .x-av svg, .x-settings .x-av .mark { width: 16px; height: 16px; }
.x-settings .x-tag { min-height: 22px; padding: 0 8px; font-size: .75rem; }
.x-settings .x-meta { font-size: .8125rem; }
.x-settings .x-profile { padding: 16px; gap: 14px; }
.x-settings .x-profile .x-av { width: 44px; height: 44px; font-size: .875rem; }
.x-settings .x-profile h2 { font-size: 1.0625rem; font-weight: 600; letter-spacing: -.01em; }
.x-settings .x-profile p { font-size: .875rem; }
.x-settings .x-profile h2 { min-height: 1.4em; }
.x-settings .x-profile p { min-height: 1.45em; }
.x-settings .x-card-row .btn, .x-settings .x-row-actions .btn, .x-settings .x-actions .btn,
.x-settings .registration-form .btn, .x-settings .x-code-field .btn { min-height: 32px; margin: 0; padding: 0 .8rem; font-size: .8125rem; line-height: 1; }
.x-settings .x-status { padding: 10px 14px; border-radius: 10px; font-size: .875rem; }
.x-settings .x-note { font-size: .8125rem; }

/* Compact fields inside settings cards. */
.x-settings .registration-form { gap: 14px; }
.x-settings .registration-field { gap: 6px; }
.x-settings .registration-field label { font-size: .8125rem; }
.x-settings .registration-field input { height: 38px; padding: 8px 12px; font-size: .9375rem; }
.x-settings .registration-field textarea { min-height: 96px; padding: 8px 12px; font-size: .9375rem; }
.x-settings .registration-field .x-password input { padding-right: 44px; }
.x-settings .registration-field .field-help, .x-settings .registration-status[role="alert"] { font-size: .8125rem; }

/* Join flow inside the settings column. */
.x-join .x-account-body { max-width: 520px; }
.x-join .x-card > p { margin-top: 8px; }
.x-join .x-card .registration-form { margin-top: 12px; }
.x-join .registration-form .btn { justify-self: start; margin: 2px 0 0; }
.x-join .x-or.x-gap { margin: 2px 0; font-size: .8125rem; }
.x-join .x-account-body > .registration-intro { margin: 0; color: var(--muted); font-size: .9375rem; }
.x-join .registration-back { margin: 8px 0 0; font-size: .8125rem; }

@media (max-width: 900px) {
 .x-settings { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "side" "head" "body"; padding-block: 20px 56px; }
 .x-side { position: static; margin-bottom: 16px; }
 .x-me { display: none; }
 .x-side nav { display: flex; flex-wrap: nowrap; gap: 4px; overflow-x: auto; padding-bottom: 10px; border-bottom: 1px solid var(--rule); scrollbar-width: none; }
 .x-side nav a { flex: none; min-height: 32px; padding: 0 10px; }
 .x-settings .x-account-body { max-width: none; }
 .x-head { margin-bottom: 16px; }
}

@media (max-width: 680px) {
 .interior-page .x-auth-card h1 { font-size: clamp(2.125rem, 9vw, 2.75rem); }
 .interior-page .x-head h1 { font-size: 1.75rem; }
}

@media (max-width: 520px) {
 .x-settings .x-card { padding: 16px; }
 .x-settings .x-list { padding: 0; }
 .x-settings .x-card.x-card-row, .x-settings .x-list > .x-card-row { min-height: 52px; padding: 12px 14px; }
 .x-settings .x-profile { padding: 14px; }
 .x-join .x-card .x-actions .btn { flex: 1 1 100%; }
 .x-auth { padding-block: 32px 40px; }
 .x-card-row .btn, .x-status .btn, .x-code .btn { padding: .5rem .75rem; font-size: .8125rem; }
}

/* Show or hide password. */
.x-password { position: relative; }
.registration-field .x-password input { padding-right: 48px; }
.x-password input::-ms-reveal { display: none; }
.x-password-toggle { position: absolute; top: 50%; right: 8px; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; transform: translateY(-50%); }
.x-password-toggle:hover { color: var(--ink); background: var(--paper-alt); }
.x-password-toggle:focus-visible { outline: 2px solid var(--cardinal); outline-offset: 1px; }
/* Screen reader only text, such as the live region that announces Copied. */
.x-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Security: inline change panels, device actions */
.x-list > .x-panel { display: block; padding-block: 16px 24px; }
.x-settings .x-list > .x-panel { padding-block: 8px 16px; }
.x-settings .x-panel .registration-form { margin-top: 0; }
.x-panel .registration-form { max-width: 420px; }
.x-panel .x-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.x-panel .x-actions .btn { margin: 0; }
.x-code-field { display: flex; gap: 8px; }
.x-code-field input { flex: 1; }
.x-code-field .btn { margin: 0; white-space: nowrap; }
.x-sent-line { margin: 0; color: var(--muted); font-size: .9375rem; }
.x-sent-line span { color: var(--ink); font-weight: 500; }
.x-note { margin: 0; color: var(--muted); font-size: .9375rem; }
.x-row-actions { display: flex; justify-content: flex-end; }
.x-row-actions .btn { margin: 0; padding: .5rem .9rem; font-size: .875rem; }

/* The server is down or in maintenance: one plain line replaces the page. */
body[data-unavailable] [data-unavailable-box] > :not(.x-unavailable),
body[data-unavailable] .x-auth-foot { display: none !important; }
.x-unavailable { margin: 0; color: var(--muted); font-size: 1.0625rem; line-height: 1.6; text-align: center; }
.x-settings > .x-unavailable { grid-area: 1 / 1 / -1 / -1; align-self: center; justify-self: center; }

/* Get Kordi for Mac (/mac): where a web sign-in in a Mac browser lands. */
.x-mac-page .mast { justify-content: flex-start; border-bottom-color: transparent; }
.x-auth.x-mac { padding-block: clamp(56px, 20vh, 200px) 56px; }
.x-mac .x-auth-card { display: flex; flex-direction: column; align-items: center; width: min(100%, 420px); }
.interior-page .x-mac h1 { margin: 0 0 12px; font-size: clamp(2.125rem, 1.5rem + 1.6vw, 2.75rem); }
.x-mac .x-lede { margin-bottom: 28px; }
.x-mac .btn { width: 100%; margin: 0; padding: .9rem 1.5rem; font-size: 1rem; }
.x-mac .btn:not(.secondary) { color: var(--button-ink); background: var(--cardinal); border-color: var(--cardinal); }
.x-mac .btn:not(.secondary):hover { background: var(--deep-red); border-color: var(--deep-red); }
.x-mac .btn.secondary { margin-top: 12px; color: var(--ink); background: transparent; border: 1.5px solid var(--ink); }
.x-mac .btn.secondary:hover { background: var(--paper-alt); }
.x-mac .x-web { margin-top: 20px; color: var(--muted); font-size: .9375rem; text-decoration: underline; text-underline-offset: 3px; }
.x-mac .x-web:hover { color: var(--ink); }
@media (max-width: 520px) {
 .x-mac-page .wrap { padding-inline: 16px; }
}

/* Account pages while the session and the page's own data load
 * (data-loading on <body>, removed by account.js): the content waits
 * invisibly in its final boxes instead of painting the sample person and
 * then shifting as real rows arrive, and comes back on its own after two
 * seconds if the script never answers. Sample fields stay hidden until the
 * script has replaced them. The footer waits too, so it does not slide down
 * as rows arrive; the header, side links and title never wait. */
body[data-loading] .x-account-body, body[data-loading] .x-join .x-head, body[data-loading] > footer { visibility: hidden; animation: x-reveal 0s 2s forwards; }
body[data-loading] [data-account], body[data-loading] [data-sample], body[data-loading] [data-password-updated],
body[data-loading] [data-linked-email], body[data-loading] [data-browser-name] { visibility: hidden; animation: none; }
@keyframes x-reveal { to { visibility: visible; } }
