/* The live demo (apps.core.demo): the bar on every page, the chooser (the demo's front door), the
   page that opens a copy and the demo's short notices. Loaded only in demo mode, after pms.css
   (templates/base.html), and written in its tokens: the same emerald, gold, type and shapes.
   - The bar is one line of brand ink above everything. From 900 px it stays at the top
     (position: sticky) and sets --shell-top to its height, which the shells read: the console's
     sidebar and top bar and the portal's header stick below it, the full-height pages leave it
     room, and the scroll-padding counts it (workspace.css, portal.css, pms.css). On phones it
     scrolls away with the page and --shell-top stays 0.
   - Above the sticky headers (z-index 20) and the portal's tab bar (25), so its role menu drops
     over them; under the console drawer's scrim (35) and the drawer itself (40).
   - The role menu is a <details> disclosure: Enter or Space opens it, Tab walks its personas,
     Escape or a click elsewhere closes it (ui.js). Each persona is a form that signs this copy in
     as them; the current one is aria-current.
   - On phones the sentence goes and Start over and Full screen keep their icons, at least 44 px to
     touch; their words stay for screen readers. "Full screen" only shows inside a frame (ui.js puts
     is-embedded on <html>).
   - The chooser is laid out like the sign-in pages (entrance.html): the emerald panel beside the
     roles from 960 px, a short emerald header with the roles on a sheet under it on phones. */

:root { --demo-bar-h: 48px; }
@media (min-width: 900px) { :root { --demo-bar-h: 40px; --shell-top: var(--demo-bar-h); } }

/* ---------- The bar ---------- */
.demo-bar {
  position: relative; z-index: 30; view-transition-name: pms-demo-bar;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--demo-bar-h);
  padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
  background: var(--brand-ink); color: var(--on-dark-2);
  border-bottom: 1px solid var(--on-dark-line);
  font: 500 0.8125rem/1.3 var(--font); letter-spacing: 0;
}
@media (min-width: 900px) {
  .demo-bar { position: sticky; top: 0; height: var(--demo-bar-h); min-height: 0; padding-inline: 16px; }
}
.demo-bar :focus-visible { outline: 2px solid var(--focus-dark); outline-offset: 2px; }

.demo-bar__what { flex: 0 1 auto; min-width: 0; margin: 0; display: flex; align-items: center; gap: 14px; white-space: nowrap; }
/* "Live demo": the website's kicker, a gold dot in a soft halo before the words */
.demo-bar__tag { flex: none; display: inline-flex; align-items: center; gap: 9px; color: var(--accent-soft); font-weight: 600; }
.demo-bar__tag::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 24%, transparent);
}
.demo-bar__note { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--on-dark-2); font-weight: 400; }
@media (max-width: 1023px) { .demo-bar__note { display: none; } }

.demo-bar__tools { flex: 0 1 auto; min-width: 0; display: flex; align-items: center; gap: 6px; }
.demo-bar__tools > form { margin: 0; flex: none; }

/* The controls: small pills on the ink, like the emerald panels' light outline buttons */
.demo-bar__ctl {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 30px; padding-inline: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 999px; background: rgba(255, 255, 255, 0.05);
  color: #fff; font: 600 0.8125rem/1 var(--font); letter-spacing: 0; white-space: nowrap; text-decoration: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.demo-bar__ctl::after { content: ""; position: absolute; inset: -5px -2px; border-radius: inherit; }   /* 40 px to touch */
.demo-bar__ctl:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(255, 255, 255, 0.4); }
.demo-bar__ctl .i { width: 15px; height: 15px; stroke-width: 2; color: var(--accent-soft); }
.demo-bar__btn[aria-busy="true"] { opacity: 0.7; pointer-events: none; }
.demo-bar__full { display: none; }
.is-embedded .demo-bar__full { display: inline-flex; }

/* The role menu's button: the persona's initials, their role and (on wide screens) their name */
.demo-bar__roles { position: relative; min-width: 0; }
.demo-bar__roles > summary { max-width: 100%; padding-inline: 4px 10px; list-style: none; }
.demo-bar__roles > summary::-webkit-details-marker { display: none; }
.demo-bar__roles[open] > summary { background: rgba(255, 255, 255, 0.11); border-color: rgba(255, 255, 255, 0.4); }
.demo-bar__roles > summary > .i:last-child { color: var(--on-dark-2); transition: transform var(--dur) var(--ease); }
.demo-bar__roles > summary > .i:first-child { margin-inline-start: 6px; }
.demo-bar__role { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.demo-bar__name { color: var(--on-dark-2); font-weight: 500; }
.demo-bar__name > [aria-hidden] { margin-inline-end: 7px; color: var(--on-dark-3); }
@media (max-width: 1279px) { .demo-bar__name { display: none; } }
.demo-bar__avatar {
  display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--brand-ink); font: 700 0.625rem/1 var(--font); letter-spacing: 0.02em;
}

/* The menu: a light card under the bar, the personas in the chooser's two groups */
.demo-bar__menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 1;
  width: 292px; max-height: calc(100vh - var(--demo-bar-h) - 16px); max-height: calc(100dvh - var(--demo-bar-h) - 16px); overflow-y: auto;
  padding: 6px; background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-3);
  animation: demo-menu-in 160ms var(--ease) both;
}
@keyframes demo-menu-in { from { opacity: 0; transform: translateY(-4px); } }
.demo-bar__menu ul { list-style: none; margin: 0; padding: 0; }
.demo-bar__menu form { margin: 0; }
.demo-bar__group { margin: 0; padding: 10px 10px 4px; color: var(--text-3); font: 600 0.75rem/1.4 var(--font); }
.demo-bar__group:first-child { padding-top: 6px; }
.demo-bar__item {
  display: flex; align-items: center; gap: 11px; width: 100%; min-height: 48px; padding: 7px 10px;
  border: 0; border-radius: 9px; background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer;
  transition: background-color var(--dur) var(--ease);
}
.demo-bar__item:hover { background: var(--surface-2); }
.demo-bar__menu .demo-bar__item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.demo-bar__item .demo-bar__avatar { width: 32px; height: 32px; font-size: 0.75rem; }
.demo-bar__item--staff .demo-bar__avatar { background: var(--brand); color: var(--accent-soft); }
.demo-bar__item--portal .demo-bar__avatar { background: var(--brand-tint-2); color: var(--brand); }
.demo-bar__who { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.demo-bar__who b { color: var(--heading); font-size: 0.875rem; font-weight: 600; }
.demo-bar__who span { color: var(--text-2); font-size: 0.8125rem; }
.demo-bar__item[aria-current="true"] { background: var(--brand-tint); }
.demo-bar__item[aria-current="true"] > .i { color: var(--brand); stroke-width: 2.4; }
/* Under the personas: the chooser, where each role says what to try */
.demo-bar__more {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 40px; margin-top: 6px; padding: 0 10px;
  border-top: 1px solid var(--line-soft); border-radius: 0 0 8px 8px; color: var(--brand); font-size: 0.8125rem; font-weight: 600; text-decoration: none;
}
.demo-bar__more:hover { text-decoration: underline; text-underline-offset: 3px; }
.demo-bar__more .i { width: 15px; height: 15px; stroke-width: 2; }
.demo-bar__menu .demo-bar__more:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

/* Phones: no sentence, a taller bar, and Start over and Full screen as round icon buttons */
@media (max-width: 899px) {
  .demo-bar__ctl { height: 36px; }
  .demo-bar__ctl::after { inset: -4px -2px; }
  .demo-bar__roles { position: static; }
  .demo-bar__menu { top: calc(100% - 2px); inset-inline-end: 8px; width: min(320px, calc(100% - 16px)); }
}
@media (max-width: 559px) {
  .demo-bar { gap: 8px; }
  .demo-bar__tools { gap: 4px; }
  .demo-bar__btn { width: 36px; padding: 0; justify-content: center; }
  .demo-bar__btn .i { width: 16px; height: 16px; }
  .demo-bar__label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}

/* ---------- The chooser (/demo/) ---------- */
@media (min-width: 960px) {
  .demo-door { grid-template-columns: minmax(400px, 42%) minmax(0, 1fr); }
  .demo-door .entrance__form { align-items: flex-start; padding: 48px 48px 64px; }
}
@media (min-width: 1280px) { .demo-door .entrance__form { padding-inline: 64px; } }
.demo-door .entrance__art .logo img { height: 44px; }
@media (min-width: 600px) { .demo-door .entrance__art .logo img { height: 48px; } }
@media (min-width: 960px) { .demo-door .entrance__art .logo img { height: 60px; } }
.demo-door .entrance__art .copy > p:not(.eyebrow):not(.h1) { max-width: 32em; }
@media (max-width: 599px) { .demo-door .entrance__art .h1 { font-size: 1.875rem; } }
/* On the emerald: a gold pill to carry on, a light outline to start over (as on the covers) */
.demo-door__now { margin-top: 20px; gap: 10px; }
.demo-door__now form { margin: 0; }
.demo-door__now .btn:not(.btn-ghost) {
  --btn-bg: var(--accent); --btn-fg: var(--brand-ink); --btn-bd: var(--accent); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.24);
}
.demo-door__now .btn:not(.btn-ghost):hover { --btn-bg: var(--accent-soft); --btn-bd: var(--accent-soft); }
.demo-door__now .btn-ghost { --btn-bg: transparent; --btn-fg: #fff; --btn-bd: rgba(255, 255, 255, 0.42); box-shadow: none; }
.demo-door__now .btn-ghost:hover { --btn-bg: rgba(255, 255, 255, 0.1); --btn-bd: rgba(255, 255, 255, 0.72); }
@media (min-width: 960px) { .demo-door__now { margin-top: 28px; } }
/* A short screen beside the panel (the website's laptop frame is 1024 by 640): a smaller panel,
   so the logo, the words, both buttons and the skyline still fit in it */
@media (min-width: 960px) and (max-height: 760px) {
  .demo-door .entrance__art { --bp-sky: 96px; padding-top: 28px; }
  .demo-door .entrance__art .logo img { height: 48px; }
  .demo-door .entrance__art .copy { margin-bottom: 20px; }
  .demo-door .entrance__art .h1 { font-size: 2.25rem; }
  .demo-door .entrance__art .copy > p:not(.eyebrow):not(.h1) { margin-top: 12px; font-size: 0.9375rem; }
  .demo-door__now { margin-top: 18px; }
  .demo-door__now .btn { min-height: 42px; padding-inline: 18px; }
}

.demo-door__panel { width: 100%; max-width: 680px; }
.demo-door__panel > .notice { margin-bottom: 24px; }
/* Light, then its key words in bold emerald, as the sign-in form's title */
.demo-door__title { margin: 0; font-size: clamp(1.625rem, 1.45rem + 0.7vw, 2.125rem); font-weight: var(--bp-light, 400); letter-spacing: -0.03em; line-height: 1.1; }
.demo-door__title b { color: var(--brand); font-weight: var(--bp-bold, 680); }
.demo-door__lede { margin: 8px 0 0; color: var(--text-2); font-size: 0.9375rem; line-height: 1.55; max-width: 38em; }

.demo-group { margin-top: 26px; }
.demo-group__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 16px; margin-bottom: 10px; }
.demo-group__head h3 { margin: 0; font-size: 0.9375rem; font-weight: 650; letter-spacing: -0.01em; }
.demo-group__head p { margin: 0; color: var(--text-3); font-size: 0.8125rem; }

/* A group's roles: one card, a row each; the row's arrow is the form's button and its hit area the
   whole row */
.demo-roles {
  list-style: none; margin: 0; padding: 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-1);
}
.demo-role {
  position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr) 36px; grid-template-areas: "avatar head go" "avatar try go";
  align-items: start; gap: 3px 14px; padding: 15px 16px 16px;
  box-shadow: inset 0 1px 0 var(--line-soft);
  transition: background-color var(--dur) var(--ease);
}
.demo-role:first-child { box-shadow: none; }
.demo-role:hover { background: var(--surface-2); }
.demo-role.is-current { background: var(--brand-tint); }
.demo-role__avatar {
  grid-area: avatar; display: inline-grid; place-items: center; width: 40px; height: 40px; margin-top: 1px; border-radius: 50%;
  font: 650 0.8125rem/1 var(--font); letter-spacing: 0.02em;
}
.demo-role--staff .demo-role__avatar { background: var(--brand); color: var(--accent-soft); }
.demo-role--portal .demo-role__avatar { background: var(--brand-tint-2); color: var(--brand); }
.demo-role.is-current .demo-role__avatar { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--accent); }
.demo-role__head { grid-area: head; margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 10px; }
.demo-role__name { color: var(--heading); font-size: 1rem; font-weight: 650; letter-spacing: -0.012em; line-height: 1.35; }
.demo-role__title { color: var(--brand); font-size: 0.8125rem; font-weight: 600; }
.demo-role__now {
  align-self: center; padding: 2px 8px; border-radius: 999px; background: var(--brand-tint-2); color: var(--brand);
  font-size: 0.75rem; font-weight: 600; line-height: 1.4;
}
.demo-role__try { grid-area: try; margin: 0; color: var(--text-2); font-size: 0.875rem; line-height: 1.5; }
.demo-role form { grid-area: go; align-self: center; margin: 0; }
.demo-role__go {
  display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%;
  background: var(--surface-2); color: var(--brand); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease), transform 220ms var(--ease);
}
.demo-role__go .i { width: 18px; height: 18px; stroke-width: 2; }
.demo-role__go::after { content: ""; position: absolute; inset: 0; }
.demo-role__go:focus-visible { outline: none; }
.demo-role__go:focus-visible::after { outline: 2px solid var(--focus); outline-offset: -3px; border-radius: var(--r-l); }
.demo-role:hover .demo-role__go { background: var(--brand); color: var(--on-brand); box-shadow: none; transform: translateX(2px); }
[dir="rtl"] .demo-role:hover .demo-role__go { transform: translateX(-2px); }
.demo-role__go[aria-busy="true"] { cursor: progress; }
@media (max-width: 559px) {
  .demo-role { grid-template-columns: 36px minmax(0, 1fr) 32px; gap: 3px 12px; padding: 14px 14px 15px; }
  .demo-role__avatar { width: 36px; height: 36px; font-size: 0.75rem; }
  .demo-role__go { width: 32px; height: 32px; }
  .demo-role__go .i { width: 16px; height: 16px; }
}

/* ---------- Opening a copy (/demo/start/<persona>/): the website's calm emerald screen ---------- */
.demo-wait {
  /* the skyline (2400 by 293) always wider than the screen, so neither of its ends shows */
  --bp-sky: max(80px, calc(12.3vw + 8px));
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; place-items: center;
  min-height: calc(100vh - var(--demo-bar-h)); min-height: calc(100dvh - var(--demo-bar-h));   /* the screen under the bar */
  padding: 48px var(--gutter) calc(var(--bp-sky) + 32px);
  background: radial-gradient(90% 70% at 50% 0%, color-mix(in srgb, var(--brand-glow) 80%, transparent) 0%, transparent 70%),
    linear-gradient(170deg, var(--brand) 0%, var(--brand-deep) 52%, var(--brand-ink) 100%);
  color: var(--on-dark-2); text-align: center;
}
.demo-wait > .skyline { position: absolute; inset-inline: 0; bottom: 0; z-index: -1; }
.demo-wait__box { display: flex; flex-direction: column; align-items: center; max-width: 34rem; }
.demo-wait__logo { width: auto; height: 56px; margin-bottom: 28px; }
@media (min-width: 768px) { .demo-wait__logo { height: 72px; margin-bottom: 36px; } }
.demo-wait h1 {
  color: #fff; font-size: clamp(1.75rem, 1.3rem + 1.8vw, 2.75rem); font-weight: var(--bp-light, 400);
  letter-spacing: -0.035em; line-height: 1.08;
}
.demo-wait h1 b { color: var(--accent-soft); font-weight: var(--bp-bold, 680); }
.demo-wait__text { max-width: 28em; margin: 14px auto 0; color: var(--on-dark-2); font-size: 1rem; line-height: 1.55; text-wrap: balance; }
.demo-wait__bar { display: block; width: min(220px, 60vw); height: 2px; margin-top: 30px; overflow: hidden; border-radius: 2px; background: rgba(255, 255, 255, 0.14); }
.demo-wait__bar i { display: block; width: 40%; height: 100%; border-radius: inherit; background: var(--accent-soft); animation: demo-slide 1.6s var(--ease) infinite; }
@keyframes demo-slide { from { transform: translateX(-110%); } to { transform: translateX(260%); } }
.demo-wait form { margin: 0; }
.demo-wait .btn {
  margin-top: 24px; --btn-bg: var(--accent); --btn-fg: var(--brand-ink); --btn-bd: var(--accent); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.24);
}
.demo-wait .btn:hover { --btn-bg: var(--accent-soft); --btn-bd: var(--accent-soft); }
.demo-wait :focus-visible { outline-color: var(--focus-dark); }

/* ---------- The notices (busy, too many copies, switched off): the error pages' cover ---------- */
.demo-notice .cover__body .eyebrow { margin-bottom: 16px; }
.demo-notice .cover__body h1 b { display: block; }   /* "The demo is busy," then "try again in a minute." */

/* ---------- Motion, forced colours, print ---------- */
@media (prefers-reduced-motion: reduce) {
  .demo-bar__menu, .demo-wait__bar i { animation: none; }
  .demo-wait__bar i { width: 100%; opacity: 0.5; }
  .demo-bar__ctl, .demo-role, .demo-role__go { transition: none; }
}
@media (forced-colors: active) {
  .demo-bar { border-bottom-color: CanvasText; }
  .demo-bar__ctl { border-color: ButtonText; }
  .demo-bar__menu, .demo-roles { border-color: CanvasText; }
  .demo-bar__item[aria-current="true"], .demo-role.is-current { outline: 2px solid CanvasText; outline-offset: -2px; }
  .demo-wait { background: Canvas; color: CanvasText; }
  .demo-wait > .skyline { display: none; }
  /* The light logo keeps a small emerald tile, as on the sign-in panel */
  .demo-wait__logo { forced-color-adjust: none; box-sizing: content-box; padding: 6px 8px; border-radius: 8px; background: var(--brand-ink); }
}
@media print {
  .demo-bar { display: none; }
  :root { --shell-top: 0px; }
}
