/* The signed-out pages: signing in, accepting an invite and approving
 * an OAuth client. These live in the design system rather than in one
 * app because two apps draw the same frame: the admin app's React
 * AuthCard (apps/admin/app/components/AuthCard.tsx) and the marketing
 * site's apex sign-in page (apps/website/src/sign-in.ts), which is
 * plain HTML from a Worker, as are the tenant OAuth workspace chooser
 * (apps/api) and superadmin's MCP consent screen, through
 * packages/ui/src/brand/page.ts. One stylesheet keeps them identical.
 *
 * Loaded after styles.css, as settings.css was, so the cascade is
 * unchanged. */

/* Desktop: a warm stage with Flip on the left, the form on the right.
 * Phone: the stage is a band above the form. */
.so-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100dvh;
  background: var(--xb-bg);
}

.so-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--xb-space-2);
  padding: var(--xb-space-2) var(--xb-space-2) var(--xb-space-3);
  overflow: hidden;
  border-radius: 0 0 var(--xb-radius-xl) var(--xb-radius-xl);
  background:
    radial-gradient(80% 60% at 85% 10%, color-mix(in srgb, var(--xb-brand-bill) 22%, transparent), transparent 70%),
    radial-gradient(70% 60% at 10% 100%, color-mix(in srgb, var(--xb-brand-ribbon) 18%, transparent), transparent 70%),
    var(--xb-brand-stage);
}

.so-brand {
  display: flex;
  align-items: center;
  gap: var(--xb-space-1);
  align-self: stretch;
  min-width: 0;
}

.so-workspace { color: var(--xb-text-muted); font-size: var(--xb-text-md); font-weight: 600; }
.so-workspace::before { content: "/"; margin-right: var(--xb-space-1); color: var(--xb-border-strong); }

.so-art { display: grid; place-items: center; }
.so-art .xb-mascot { width: 148px; }
.so-tagline { display: none; }

.so-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--xb-space-3);
  padding: var(--xb-space-3) var(--xb-space-2) var(--xb-space-2);
  min-width: 0;
}

.so-panel {
  display: flex;
  flex-direction: column;
  gap: var(--xb-space-3);
  width: min(420px, 100%);
}

.so-head { display: flex; flex-direction: column; gap: var(--xb-space-1); }
.so-head h1 { font-size: var(--xb-text-2xl); overflow-wrap: anywhere; }
.so-head p { color: var(--xb-text-muted); font-size: var(--xb-text-base); }

.so-foot { margin-top: auto; text-align: center; }

@media (min-width: 900px) {
  .so-page { grid-template-columns: minmax(380px, 46%) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
  .so-stage {
    position: sticky;
    top: 0;
    align-items: stretch;
    height: calc(100dvh - 2 * var(--xb-space-2));
    min-height: 560px;
    margin: var(--xb-space-2) 0 var(--xb-space-2) var(--xb-space-2);
    padding: var(--xb-space-4);
    border-radius: 28px;
  }
  .so-art { flex: 1 1 auto; min-height: 0; }
  .so-art .xb-mascot { width: min(340px, 78%); }
  .so-tagline {
    display: block;
    max-width: 16ch;
    font-family: var(--xb-font-display);
    font-size: clamp(28px, 3vw, 40px);
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.05;
  }
  .so-tagline span { color: var(--xb-accent); }
  .so-main { justify-content: center; padding: var(--xb-space-6) var(--xb-space-4) var(--xb-space-3); }
  .so-panel { margin-block: auto; }
  .so-foot { margin-top: 0; }
  .so-head h1 { font-size: var(--xb-text-3xl); }
}

/* The six-digit code: big, centred, easy to check at a glance. */
.xb-input.so-code {
  height: 60px;
  padding-left: 0.5em;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5em;
  text-align: center;
}

.xb-input.so-code::placeholder { color: var(--xb-border-strong); opacity: 1; }

.so-sent {
  padding: 12px var(--xb-space-2);
  border-radius: var(--xb-radius-lg);
  background: var(--xb-surface-2);
  font-size: var(--xb-text-md);
  overflow-wrap: anywhere;
}

.so-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--xb-space-1); }
.xb-btn.so-sso { width: 100%; }

/* Google and Microsoft, each with its own mark in its own colours. */
.so-social { display: flex; flex-direction: column; gap: var(--xb-space-1); }
.so-social-logo { flex: none; width: 18px; height: 18px; }

.so-or {
  display: flex;
  align-items: center;
  gap: var(--xb-space-2);
  margin-block: calc(-1 * var(--xb-space-1));
  color: var(--xb-text-muted);
  font-size: var(--xb-text-sm);
}

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

/* What an invite or an OAuth client is for, as a card. */
.so-invite {
  display: flex;
  flex-direction: column;
  gap: var(--xb-space-2);
  padding: var(--xb-space-2);
  border: 1px solid var(--xb-border);
  border-radius: var(--xb-radius-lg);
  background: var(--xb-surface);
  box-shadow: var(--xb-shadow-sm);
}

.so-invite-head { display: flex; align-items: center; gap: 12px; min-width: 0; }

.so-invite-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: var(--xb-radius);
  background: var(--xb-accent-soft);
  color: var(--xb-accent);
  font-family: var(--xb-font-display);
  font-size: var(--xb-text-xl);
  font-weight: 800;
}

.so-invite-name { flex: 1 1 auto; min-width: 0; font-family: var(--xb-font-display); font-size: var(--xb-text-lg); font-weight: 700; overflow-wrap: anywhere; }

.so-consent-facts { display: flex; flex-direction: column; gap: var(--xb-space-1); margin: 0; font-size: var(--xb-text-md); }
.so-consent-facts dt { color: var(--xb-text-muted); font-size: var(--xb-text-xs); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.so-consent-facts dd { margin: 0; }

.so-scopes { display: flex; flex-direction: column; gap: var(--xb-space-half); margin: 0; padding: 0; list-style: none; font-size: var(--xb-text-md); }
.so-scopes li { display: flex; align-items: center; gap: var(--xb-space-1); }
.so-scopes .xb-icon { width: 16px; height: 16px; color: var(--xb-success); }

.so-decide { display: flex; gap: var(--xb-space-1); }
.so-decide > .xb-btn { flex: 1 1 0; }

/* The permissions an OAuth client asks for, each in words with its code
 * under it: a tick where they are only shown, a checkbox where the
 * person chooses (superadmin's consent). */
.so-perms { display: flex; flex-direction: column; gap: var(--xb-space-1); margin: 0; padding: 0; list-style: none; }
.so-perm {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px var(--xb-space-2);
  border: 1px solid var(--xb-border);
  border-radius: var(--xb-radius-lg);
  background: var(--xb-surface);
}
label.so-perm { cursor: pointer; }
label.so-perm:has(input:checked) {
  border-color: color-mix(in srgb, var(--xb-accent) 50%, var(--xb-border));
  background: color-mix(in srgb, var(--xb-accent-soft) 55%, var(--xb-surface));
}
label.so-perm:has(input:focus-visible) { outline: 2px solid var(--xb-focus); outline-offset: 2px; }
.so-perm > input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--xb-accent); }
.so-perm > .xb-icon { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--xb-success); }
.so-perm-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.so-perm-what { font-size: var(--xb-text-md); line-height: 1.4; }
.so-perm-code { color: var(--xb-text-muted); font-family: var(--xb-font-mono); font-size: var(--xb-text-xs); overflow-wrap: anywhere; }

/* A workspace address typed with its domain shown after it: the apex
 * sign-in page and the OAuth workspace chooser. */
.so-address { position: relative; display: flex; align-items: stretch; }
.so-address .xb-input { flex: 1 1 auto; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.so-suffix {
  display: flex;
  align-items: center;
  flex: none;
  padding: 0 var(--xb-space-1);
  border: 1px solid var(--xb-border);
  border-left: 0;
  border-radius: 0 var(--xb-radius) var(--xb-radius) 0;
  background: var(--xb-surface-2);
  color: var(--xb-text-muted);
  font-size: var(--xb-text-md);
  font-weight: 600;
  white-space: nowrap;
}
.so-address:focus-within { outline: 2px solid var(--xb-focus); outline-offset: 1px; border-radius: var(--xb-radius); }
.so-address:focus-within .xb-input:focus-visible { outline: none; }
.so-address:focus-within .xb-input,
.so-address:focus-within .so-suffix { border-color: var(--xb-focus); }
@media (max-width: 420px) { .so-suffix { font-size: var(--xb-text-sm); } }

/* ── Storage against the plan (billing) ── */
.stor { display: flex; flex-direction: column; gap: var(--xb-space-2); min-width: 0; }
.stor-left { margin: calc(-1 * var(--xb-space-1)) 0 0; }
.stor-list { display: flex; flex-direction: column; gap: var(--xb-space-2); margin: 0; padding: 0; list-style: none; }
.stor-item { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stor-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px var(--xb-space-1); }
.stor-label { font-weight: 600; }
.stor-figure { font-variant-numeric: tabular-nums; }
.stor-bar { display: block; height: 6px; border-radius: 3px; background: var(--xb-surface-2); overflow: hidden; }
.stor-bar > span { display: block; height: 100%; border-radius: 3px; background: var(--xb-accent); }
.stor-uncounted { display: flex; flex-direction: column; gap: var(--xb-space-1); padding-top: var(--xb-space-2); border-top: 1px solid var(--xb-border); }
.stor-uncounted-h { color: var(--xb-text-muted); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
