/* =====================================================================
   Inter, served from this origin.

   The design system is set in Inter, and the pages already asked for it by
   name — with no @font-face behind it, so every page quietly fell back to
   whatever sans the machine had. Two people looking at the same screen saw
   different type.

   Self-hosted rather than pulled from a font CDN: the pages are meant to work
   with no network at all (that is the whole point of ?demo and of the
   emulator run), and a CDN link makes the type a thing that can fail. One
   variable file covers every weight the interface uses; it is subset to Latin
   plus the punctuation and symbols actually drawn, which takes it from 875 KB
   to 127 KB.
   ===================================================================== */

@font-face {
  font-family: 'Inter';
  src: url('/fonts/Inter.woff2') format('woff2');
  font-weight: 100 900;                 /* variable: one file, every weight */
  font-style: normal;
  font-display: swap;                   /* text first, in the fallback face */
}

/* =====================================================================
   RBFA Play design tokens, and the chrome every page shares.

   Lifted from the design set rather than approximated — the maroon header,
   the paper background, the hairline card borders. Shared by the explorer and
   the report so the two cannot drift into looking like different products.

   Link this before a page's own stylesheet.
   ===================================================================== */

:root {
  --paper: var(--c-neutral-96);          /* page background */
  --card: var(--c-neutral-100);
  --hairline: var(--c-neutral-93);       /* card borders */
  --rule: var(--c-neutral-82);           /* input borders, a shade stronger */
  --ink: var(--c-neutral-00);
  --ink-soft: var(--c-neutral-35);       /* body copy */
  --ink-mute: var(--c-neutral-61);       /* labels, uppercase captions */
  --mono-ink: var(--c-brand-30);       /* the alias, always monospace */
  --link: var(--c-info-29);

  /* An epic sits above a requirement, and takes the deeper end of the same
     plum ramp so the two read as one hierarchy rather than two hues. */
  --epic: var(--c-accent-10);
  --requirement: var(--c-accent-17);    /* also the header */
  --requirement-soft: var(--c-accent-86);
  --story: var(--c-info-32a);
  --bug: var(--c-danger-41a);
  --improvement: var(--c-brand-53);

  --bug-bg: var(--c-danger-96);
  --improvement-bg: var(--c-brand-95);

  --node-w: 340px;
  --radius: 10px;

  /* Only Inter is shipped, so the mono stack names what browsers actually
     have rather than a face this origin does not serve. Inter's own tabular
     figures carry most aligned numbers; this is for aliases and ids. */
  --mono: ui-monospace, SFMono-Regular, Menlo, 'Cascadia Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 500;
  font-size: 14px;
  line-height: 20px;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
/* Without !important a later display rule silently wins and the gate stays
   laid out over the page it is meant to be blocking. */
[hidden] { display: none !important; }

/* The default page: one column, padded. A page that has adopted the version
   2 frame opts out by name — its layout is the rail beside the main column,
   and an id selector here would quietly outrank the shell's own class. */
#app:not(.v2-frame) { display: flex; flex-direction: column; gap: 16px; min-height: 100vh; padding: 24px; }


/* ---------- gate, spinner, toast ---------- */

.gate { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.gate-card {
  background: var(--card); border: 1px solid var(--hairline); border-radius: 12px;
  padding: 32px; max-width: 460px; text-align: center;
}
.gate-mark { font-size: 32px; }
.gate-card h2 { margin: 8px 0 12px; font-size: 20px; }
.gate-card p { color: var(--ink-soft); font-size: 13px; line-height: 1.5; }
.gate-card .btn { margin: 4px; }
.gate-note { font-size: 12px; color: var(--ink-mute); margin-top: 18px; }

/*
 * The address the person is signed in as.
 *
 * Only on the states that follow a successful sign-in. It is the fact those
 * screens are really about — "approved for whom" — and without it somebody
 * with two Google accounts cannot tell which one is waiting.
 */
.gate-email {
  margin: 10px 0 0; font-family: var(--mono); font-size: 12px;
  color: var(--mono-ink); word-break: break-all;
}

/* ---------- the profile form ---------- */

/*
 * Who somebody is, asked in two places and drawn once.
 *
 * The registration gate asks a person for it, and the accounts list in
 * System Settings lets an administrator fill one in on their behalf —
 * lib/profile-form.js builds both, and these are its clothes. Built from the
 * version 2 tokens the rest of the application uses, because the gate copy
 * is the first screen a new colleague ever sees and it should not look like
 * a different product from the one behind it.
 *
 * Here rather than in a page's own stylesheet because the gate is on every
 * page, and a component two screens share cannot live in one of them.
 */

/*
 * The card is a notice in every other state, so it is centred and narrow. A
 * form is not a notice — a label centred over its own input is read twice
 * before anybody works out which one it belongs to — so this one state
 * widens and squares up.
 */
#gate[data-state="registration"] .gate-card {
  max-width: 560px; text-align: left;
}

.profile-form {
  display: grid; gap: 18px;
  margin: 22px 0 0; text-align: left;
}

.profile-field { display: grid; gap: 7px; }

.profile-label {
  font-size: 12px; font-weight: 700; letter-spacing: .01em;
  color: var(--v2-ink, var(--c-info-11));
}

.profile-hint {
  font-size: 12px; line-height: 1.45;
  color: var(--v2-ink-meta, var(--c-neutral-46));
}

.profile-form input[type="text"] {
  width: 100%; box-sizing: border-box;
  padding: 9px 11px; font: inherit; font-size: 14px;
  color: var(--v2-ink, var(--c-info-11));
  background: var(--v2-surface, var(--c-neutral-100));
  border: 1px solid var(--v2-rule, var(--c-neutral-84));
  border-radius: var(--v2-radius, 8px);
}
.profile-form input[type="text"]:focus-visible {
  outline: 2px solid var(--v2-accent, var(--c-accent-49a)); outline-offset: 1px;
  border-color: var(--v2-accent, var(--c-accent-49a));
}

/*
 * The company, shown and not editable.
 *
 * Drawn as a fact rather than as a disabled input: a greyed-out text box
 * invites somebody to click into it and wonder why they cannot, where a
 * plain line of text with a sentence under it reads as what it is.
 */
.profile-readonly {
  padding: 9px 11px; font-size: 14px; font-weight: 600;
  color: var(--v2-ink, var(--c-info-11));
  background: var(--v2-band, var(--c-neutral-98b));
  border: 1px solid var(--v2-hairline, var(--c-neutral-91));
  border-radius: var(--v2-radius, 8px);
}

.profile-choice, .profile-teams { display: flex; flex-wrap: wrap; gap: 8px; }

/* One answer, as a chip — the same shape the filter chips elsewhere use, so
   "chosen" looks the same here as it does on every other screen. */
.profile-pick {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; font-size: 13px; cursor: pointer;
  color: var(--v2-ink-soft, var(--c-neutral-27));
  background: var(--v2-surface, var(--c-neutral-100));
  border: 1px solid var(--v2-hairline, var(--c-neutral-91));
  border-radius: var(--v2-radius-pill, 1000px);
}
.profile-pick:hover { border-color: var(--v2-rule, var(--c-neutral-84)); }
.profile-pick:has(input:checked) {
  color: var(--v2-ink, var(--c-info-11)); font-weight: 600;
  border-color: var(--v2-accent, var(--c-accent-49a));
  background: color-mix(in srgb, var(--v2-accent, var(--c-accent-49a)) 6%, var(--c-neutral-100));
}
.profile-pick input { margin: 0; accent-color: var(--v2-accent, var(--c-accent-49a)); }

/* What is still missing, and — after a save was refused — what was wrong.
   Two tones rather than two elements: it is one line in one place, and
   moving it would make the second message read as a new one. */
.profile-problems { margin: 0; font-size: 13px; }
.profile-problems[data-tone="note"] { color: var(--v2-ink-meta, var(--c-neutral-46)); }
.profile-problems[data-tone="bad"] {
  color: var(--v2-accent, var(--c-accent-35b)); font-weight: 600;
}

/* The administrator's copy: the company is a choice rather than a fact, so
   it is a dropdown, wearing the same box the text fields wear. */
.profile-form select {
  width: 100%; box-sizing: border-box;
  padding: 9px 11px; font: inherit; font-size: 14px;
  color: var(--v2-ink, var(--c-info-11));
  background: var(--v2-surface, var(--c-neutral-100));
  border: 1px solid var(--v2-rule, var(--c-neutral-84));
  border-radius: var(--v2-radius, 8px);
}

#reg-save { justify-self: start; margin: 2px 0 0; }

/*
 * A successful sign-in awaiting approval is good news, and has to look like
 * it. The old screen said so in the same grey paragraph, under the same
 * heading, with the same button as the screen that had just refused somebody
 * — which made a sign-in that worked indistinguishable from one that did not.
 */
#gate[data-state="pending"] .gate-card {
  border-color: var(--ok-border, var(--c-success-83));
  background: var(--ok-bg, var(--c-success-97));
}
#gate[data-state="pending"] .gate-card h2 { color: var(--ok-ink, var(--c-success-11)); }

/* Refusals wear the opposite, and quietly: a red card is a statement about
   the person, not about the account, so it stops at the border. */
#gate[data-state="rejected"] .gate-card,
#gate[data-state="suspended"] .gate-card,
#gate[data-state="refused"] .gate-card,
#gate[data-state="wrong-account"] .gate-card { border-color: var(--c-danger-86); }

#gate[data-state="fatal"] .gate-card { border-color: var(--rule); }

.spinner {
  width: 22px; height: 22px; margin: 0 auto 16px;
  border: 2px solid var(--hairline); border-top-color: var(--requirement);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--c-neutral-10); color: var(--c-neutral-100); padding: 10px 16px; border-radius: 8px;
  font-size: 13px; z-index: 50; max-width: 80vw;
}
.toast[data-kind="error"] { background: var(--bug); }

/* ---------- buttons ---------- */

.btn {
  font-family: inherit; font-size: 13px; font-weight: 700;
  padding: 9px 16px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--rule); background: var(--card); color: var(--ink);
  text-decoration: none; display: inline-block;
}
.btn-hero { background: var(--c-accent-15); border-color: var(--c-accent-34); color: var(--c-neutral-100); }
.btn-hero:hover { background: var(--c-accent-21); }
.btn-primary { background: var(--requirement); border-color: var(--requirement); color: var(--c-neutral-100); }
.btn-ghost { background: transparent; }
.btn-small { font-size: 12px; padding: 5px 11px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Icons sit inside a button that already has its text: an icon-only control
   is a guess, and the guess is usually wrong. The flex switch is on the
   button rather than global, so a plain .btn keeps its inline-block layout. */
.btn.has-icon { display: inline-flex; align-items: center; gap: 7px; }
.icon { flex: none; }


/* ---------- the header every page wears ---------- */

.hero {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between;
  gap: 16px; background: var(--requirement); color: var(--c-neutral-100);
  border-radius: 12px; padding: 18px 22px;
}
.hero-text { display: flex; flex-direction: column; gap: 4px; min-width: 280px; }
.hero h1 { margin: 0; font-weight: 700; font-size: 20px; line-height: 26px; }
.hero p { margin: 0; font-size: 12px; line-height: 18px; color: var(--requirement-soft); max-width: 62ch; }
.hero-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.who { font-size: 12px; color: var(--requirement-soft); margin-right: 4px; }

/* A panel: white, hairline border, the shape everything sits in. */
.panel {
  background: var(--card); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 14px 18px;
}
.panel-title {
  font-weight: 700; font-size: 11px; color: var(--ink-mute);
  text-transform: uppercase; letter-spacing: .02em; margin: 0 0 10px;
}

/* ---------- the demo banner ----------------------------------------------

   Permanent, not a toast. The whole risk of a demo is someone reading
   invented numbers as real ones ten minutes after the notice disappeared.
   ------------------------------------------------------------------------ */

.demo-banner {
  position: sticky; top: 0; z-index: 60;
  padding: 9px 20px;
  background: var(--c-brand-53); color: var(--c-neutral-10);
  font-size: 12px; font-weight: 700; line-height: 18px;
  text-align: center;
}
