/* facely-design components as plain CSS, for the IdP's server-rendered pages.
 *
 * Each block below is a port of one component in facely-design/components —
 * same tokens, same measurements — because the IdP origin runs no React and
 * its CSP forbids inline styles. When a component changes there, change it
 * here. Classes are named after the component: .btn = Button, .pill = Pill,
 * .field = Input, .modal = Modal, .detail-row = DetailRow, .tabs = Tabs.
 */

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--surface-app);
  color: var(--text-ink);
  font-family: var(--font-sans);
  font-size: var(--text-body-size);
  line-height: var(--leading-body);
}

a { color: var(--brand-primary); font-weight: var(--weight-semibold); text-decoration: none; }
a:hover { color: var(--brand-primary-hover); }
[hidden] { display: none !important; }

/* ── Icon ─────────────────────────────────────────────────────────────────
 * Monochrome mask, so any icon takes any token colour. */
.icon {
  display: inline-block; flex-shrink: 0; width: 20px; height: 20px;
  background: var(--icon-default);
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}
.icon--14 { width: 14px; height: 14px; }
.icon--18 { width: 18px; height: 18px; }
.icon--24 { width: 24px; height: 24px; }
.icon--quiet { background: var(--icon-quiet); }
.i-person { --icon: url("/assets/icons/person.svg"); }
.i-group { --icon: url("/assets/icons/group.svg"); }
.i-mail { --icon: url("/assets/icons/mail.svg"); }
.i-copy { --icon: url("/assets/icons/content_copy.svg"); }
.i-add { --icon: url("/assets/icons/add_circle.svg"); }
.i-rename { --icon: url("/assets/icons/app_registration.svg"); }
.i-passkey { --icon: url("/assets/icons/passkey.svg"); }
.i-devices { --icon: url("/assets/icons/devices.svg"); }
.i-key { --icon: url("/assets/icons/key.svg"); }
.i-history { --icon: url("/assets/icons/history.svg"); }
.i-logout { --icon: url("/assets/icons/logout.svg"); }
.i-apps { --icon: url("/assets/icons/apps.svg"); }
.i-visibility { --icon: url("/assets/icons/visibility.svg"); }
.i-visibility-off { --icon: url("/assets/icons/visibility_off.svg"); }

/* ── Button ───────────────────────────────────────────────────────────── */
.btn {
  height: var(--h-button); padding: 0 34px; border-radius: var(--radius-control);
  font: var(--weight-semibold) var(--text-body-size) / var(--leading-tight) var(--font-sans);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-4);
  cursor: pointer; border: none;
  background: var(--brand-primary); color: var(--text-on-brand);
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.btn:hover { background: var(--brand-primary-hover); }
.btn--secondary {
  background: var(--surface-card); color: var(--text-placeholder);
  border: var(--border-w-control) solid var(--border-secondary-btn);
}
.btn--secondary:hover { background: var(--surface-card); border-color: var(--text-secondary); color: var(--text-secondary); }
.btn--outline {
  background: var(--surface-card); color: var(--brand-primary);
  border: var(--border-w-control) solid var(--border-control);
}
.btn--outline:hover { background: var(--brand-tint); }
.btn .icon { background: currentColor; }
.btn--full { width: 100%; }
.btn--tall { height: var(--h-input); }
/* Sidebar-sized outline button (Create Event in the gallery sidebar). */
.btn--compact { height: var(--h-dropdown); padding: 0 var(--space-5); font-size: var(--text-ui); }
.btn:disabled, .btn:disabled:hover {
  background: var(--surface-disabled); color: var(--text-disabled); border: none; cursor: not-allowed;
}

/* ── Pill ─────────────────────────────────────────────────────────────── */
.pill {
  height: var(--h-pill); padding: 0 var(--space-6); border: none; border-radius: var(--radius-segment);
  background: var(--brand-tint); color: var(--brand-primary);
  font: var(--weight-semibold) var(--text-pill) / 1 var(--font-sans);
  display: inline-flex; align-items: center; gap: var(--space-2);
  cursor: pointer; transition: background var(--transition-fast); white-space: nowrap;
}
.pill:hover { background: var(--brand-tint-hover); }
.pill .icon { width: 14px; height: 14px; }

/* ── Tag (non-removable) ──────────────────────────────────────────────── */
.tag {
  height: var(--h-tag); padding: 0 var(--space-5);
  background: var(--surface-card); border: var(--border-w-control) solid var(--border-control);
  border-radius: var(--radius-segment); display: inline-flex; align-items: center;
  font-size: var(--text-ui); font-weight: var(--weight-semibold); color: var(--brand-primary); white-space: nowrap;
}
.tag--small { height: 24px; font-size: var(--text-caption); padding: 0 var(--space-3); }

/* ── Input ────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 11px; }
.field > label { font-size: var(--text-label); color: var(--text-ink); line-height: var(--leading-tight); }
.field__shell {
  height: var(--h-input); display: flex; align-items: center; gap: var(--space-5);
  background: var(--surface-card); border: var(--border-w-control) solid var(--border-control);
  border-radius: var(--radius-control); padding: 10px var(--space-6);
  transition: border-color var(--transition-fast);
}
.field__shell:focus-within { border-color: var(--brand-primary); }
.field--filled .field__shell {
  background: var(--surface-field); border: var(--border-w-hairline) solid var(--border-field);
  border-radius: var(--radius-field); padding: 10px 13px;
}
.field--filled .field__shell:focus-within { border-color: var(--brand-primary); }
.field input {
  flex: 1; min-width: 0; border: none; background: none; outline: none; padding: 0;
  font: var(--text-body-size) var(--font-sans); color: var(--text-ink);
}
.field input::placeholder { color: var(--text-placeholder); }
/* The show/hide-password affordance from LoginScreen. */
.field__reveal { display: flex; background: none; border: none; padding: 0; cursor: pointer; }
.field__hint { margin: 0; font-size: var(--text-ui); color: var(--text-secondary); line-height: var(--leading-body); }

/* ── Select ───────────────────────────────────────────────────────────────
 * A native <select> dressed as the toolbar Select trigger: 43px, control
 * border, grey label, brand-blue chevron. Native keeps keyboard and screen
 * reader behaviour for free. */
.select {
  appearance: none; -webkit-appearance: none;
  height: var(--h-dropdown); padding: 0 40px 0 var(--space-6);
  background: var(--surface-card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234451F5' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right var(--space-6) center;
  border: var(--border-w-control) solid var(--border-control); border-radius: var(--radius-control);
  font: var(--weight-semibold) var(--text-ui) var(--font-sans); color: var(--text-control);
  cursor: pointer; transition: border-color var(--transition-fast);
}
.select:hover, .select:focus { border-color: var(--border-control-hover); outline: none; }
.field .select { width: 100%; }
/* In a form the Select sits among filled inputs, so it takes their skin. */
.field--filled .select {
  height: var(--h-input); padding-left: 13px;
  background-color: var(--surface-field); border: var(--border-w-hairline) solid var(--border-field);
  border-radius: var(--radius-field); font-weight: var(--weight-regular); font-size: var(--text-body-size); color: var(--text-ink);
}
.field--filled .select:focus { border-color: var(--brand-primary); }

/* ── Modal ────────────────────────────────────────────────────────────────
 * A native <dialog>: the browser supplies focus trapping and Escape. */
.modal {
  width: var(--width-modal); max-width: calc(100% - 2 * var(--space-8));
  background: var(--surface-card); color: var(--text-ink);
  border: var(--border-w-popup) solid var(--border-popup); border-radius: var(--radius-card);
  padding: var(--pad-card); box-shadow: var(--shadow-card);
}
.modal[open] { display: flex; flex-direction: column; gap: var(--gap-stack); }
.modal::backdrop { background: rgba(0, 0, 0, 0.18); }
.modal__title { margin: 0; font-size: var(--text-title); font-weight: var(--weight-semibold); line-height: var(--leading-snug); }
.modal__rule, .rule { height: 0; border: none; border-top: var(--border-w-hairline) solid var(--border-divider); margin: 0; }
.modal__body { margin: 0; color: var(--text-body); line-height: var(--leading-body); }
.modal__fields { display: flex; flex-direction: column; gap: var(--gap-stack); }
.modal__image { display: block; width: 200px; height: 200px; margin: 0 auto; image-rendering: pixelated; }
.modal__footer { display: flex; justify-content: flex-end; gap: var(--gap-modal-actions); }
.modal__footer .btn { width: 120px; padding: 0; }
.modal__footer .btn--wide { width: auto; padding: 0 34px; }

/* ── DetailRow ────────────────────────────────────────────────────────── */
.detail-row {
  display: flex; flex-direction: column; gap: var(--space-4);
  border-bottom: var(--border-w-hairline) solid var(--border-divider); padding-bottom: 18px;
}
.detail-row:last-child { border-bottom: none; padding-bottom: 0; }
.detail-row__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); }
.detail-row__label { font-weight: var(--weight-semibold); color: var(--text-ink); }
.detail-row__value { font-size: var(--text-ui); color: var(--text-secondary); line-height: var(--leading-body); }

/* ── Sidebar navigation rows (FolderRow shape, no checkbox) ───────────── */
.nav-row {
  display: flex; align-items: center; gap: var(--space-6);
  padding: 13px var(--space-5); border-radius: var(--radius-segment);
  color: var(--text-ink); font-weight: var(--weight-semibold);
  transition: background var(--transition-fast);
}
.nav-row:hover { background: var(--surface-row-hover); color: var(--text-ink); }
.nav-row[aria-current="true"], .nav-row[aria-current="page"] { background: var(--brand-tint); }
.sidebar__heading { margin: 0; padding: 0 var(--space-5); font-size: var(--text-caption); font-weight: var(--weight-semibold); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Auth screen (LoginScreen) ────────────────────────────────────────── */
.auth {
  min-height: 100vh; background-color: var(--surface-app);
  background-image: url("/assets/pattern_union.svg"); background-size: 96px 96px;
  display: flex; flex-direction: column; align-items: center; gap: 50px;
  padding: 125px var(--space-8) 80px;
}
.auth__logo { width: 192px; height: auto; display: block; }
.auth__card {
  width: var(--width-auth); max-width: 100%; background: var(--surface-card);
  border: var(--border-w-popup) solid var(--border-popup); border-radius: var(--radius-card);
  padding: 45px 50px; display: flex; flex-direction: column; gap: var(--space-9);
}
.auth__head { display: flex; flex-direction: column; gap: var(--space-5); align-items: center; text-align: center; margin-bottom: 5px; }
.auth__title { margin: 0; font-size: var(--text-display); font-weight: var(--weight-semibold); line-height: var(--leading-snug); }
.auth__sub { margin: 0; font-size: var(--text-hero-body); color: var(--text-body); }
.auth__links { display: flex; justify-content: space-between; gap: var(--space-5); font-size: var(--text-ui); }
.auth__form { display: flex; flex-direction: column; gap: var(--space-9); }

/* ── Console shell ────────────────────────────────────────────────────────
 * The gallery app's frame: 20px gutters, a 305px white sidebar, cards on the
 * canvas. The gallery is desktop-only; the account page is not, because
 * people enroll passkeys from their phones, so below 900px the sidebar
 * folds above the content. */
.shell { display: flex; gap: var(--gap-stack); padding: var(--gap-stack); min-height: 100vh; }
.sidebar {
  width: var(--width-sidebar); flex-shrink: 0; align-self: flex-start; position: sticky; top: var(--gap-stack);
  background: var(--surface-card); border-radius: var(--radius-card); padding: 23px 17px;
  display: flex; flex-direction: column; gap: 18px;
}
.sidebar__logo { width: 128px; height: auto; display: block; margin: 4px 0 0 8px; }
.sidebar__rule { height: 0; border: none; border-top: var(--border-w-hairline) solid var(--border-tab); margin: 0; }
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--gap-stack); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-8); padding: 4px 8px; min-height: 44px; }
.topbar__title { margin: 0; font-size: var(--text-screen-title); font-weight: var(--weight-semibold); line-height: var(--leading-snug); }
.account-block { display: flex; align-items: center; gap: var(--space-5); }
.avatar {
  width: 44px; height: 44px; border-radius: var(--radius-full); flex-shrink: 0;
  background: repeating-linear-gradient(45deg, var(--brand-tint), var(--brand-tint) 6px, var(--border-control) 6px, var(--border-control) 12px);
}
.account-block__text { display: flex; flex-direction: column; gap: 2px; }
.account-block__name { font-weight: var(--weight-semibold); color: var(--text-heading); line-height: var(--leading-snug); }
.account-block__meta {
  background: none; border: none; padding: 0; cursor: pointer; text-align: left;
  font: 13px var(--font-sans); color: var(--text-muted);
}
.account-block__meta:hover { color: var(--brand-primary); }

.card { background: var(--surface-card); border-radius: var(--radius-card); padding: var(--pad-panel) 32px 28px; scroll-margin-top: var(--gap-stack); }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-7); margin-bottom: var(--space-7); }
.card__head > .btn { flex-shrink: 0; white-space: nowrap; }
.card__title { margin: 0; font-size: var(--text-heading-size); font-weight: var(--weight-semibold); line-height: var(--leading-snug); display: flex; align-items: center; gap: var(--space-4); }
.card__intro { margin: var(--space-2) 0 0; font-size: var(--text-ui); color: var(--text-secondary); line-height: var(--leading-body); }
.card--callout { border: var(--border-w-control) solid var(--border-control); }

/* A list of things in a card: passkeys, sessions, orgs, events. */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: var(--space-6);
  padding: 14px 0; border-bottom: var(--border-w-hairline) solid var(--border-divider);
}
.row:first-child { padding-top: 0; }
.row:last-child { border-bottom: none; padding-bottom: 0; }
.row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.row__title { font-weight: var(--weight-semibold); color: var(--text-ink); display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.row__meta { font-size: var(--text-caption); color: var(--text-muted); }
.row__actions { display: flex; justify-content: flex-end; gap: var(--space-3); flex-shrink: 0; min-width: 150px; }
/* Search bar: an outlined Input shell with its button alongside. */
.search { display: flex; gap: var(--space-5); margin-bottom: var(--space-7); }
.search .field__shell { flex: 1; height: var(--h-dropdown); }
.search input {
  flex: 1; min-width: 0; border: none; background: none; outline: none; padding: 0;
  font: var(--text-ui) var(--font-sans); color: var(--text-ink);
}
.mono { font-family: var(--font-mono); font-size: var(--text-caption); }
.row__title.mono { font-size: var(--text-ui); }
a.row__title { color: var(--text-ink); }
a.row__title:hover { color: var(--brand-primary); }
.pager { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-7); }
.row > .avatar { width: 36px; height: 36px; }
.empty { margin: 0; font-size: var(--text-ui); color: var(--text-secondary); }

.codes {
  margin: 0; padding: var(--space-7); list-style: none;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4) var(--space-7);
  background: var(--surface-field); border-radius: var(--radius-field);
  font: var(--weight-semibold) var(--text-body-size) / var(--leading-snug) var(--font-mono);
}

/* The source designs no error colour; failures are said in plain text
 * in the heading colour rather than inventing a red. */
.notice { margin: 0; font-size: var(--text-ui); font-weight: var(--weight-semibold); color: var(--text-heading); }

@media (max-width: 900px) {
  .shell { flex-direction: column; padding: var(--space-5); gap: var(--space-5); }
  .sidebar { width: auto; align-self: stretch; position: static; padding: var(--space-5); }
  .sidebar__nav { flex-direction: row; flex-wrap: wrap; }
  .nav-row { padding: var(--space-3) var(--space-4); }
  .card { padding: var(--space-7); }
  .card__head { flex-direction: column; }
  .row { flex-wrap: wrap; }
  .auth { padding-top: 48px; gap: 32px; }
  .auth__card { padding: var(--space-10) var(--space-7); }
  .auth__title { font-size: var(--text-title); }
  .codes { grid-template-columns: 1fr; }
}
