/* Shared header controls for every canvas page (chat, /publish, /insights,
   /people, /levels, /forms): the header icon buttons, the "back to assistant"
   button, and the account menu (initials -> name/email, Admin links, Sign out).
   Colours come from each page's own :root tokens (fleet-standard look), so this
   file holds layout only. Behaviour: src/shell.js. Linked as /shell.css (absolute:
   /forms/<id> is a nested path). */

.hbtn {
  flex: 0 0 auto;
  height: 34px; min-width: 34px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 10px;
  font: inherit; font-size: 13px; line-height: 1;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 9px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.hbtn:hover { color: var(--ink); border-color: var(--ink-soft); }
.hbtn svg { flex: 0 0 auto; }
.hbtn.themetoggle { padding: 0; width: 34px; }

/* Account: initials button -> menu with who you are, admin pages, sign out. */
.acct { position: relative; flex: 0 0 auto; }
.acctbtn { display: inline-flex; align-items: center; gap: 4px; height: 34px; padding: 0 6px 0 3px;
  border: 1px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink-soft);
  cursor: pointer; font: inherit; }
.acctbtn:hover, .acctbtn[aria-expanded="true"] { border-color: var(--ink-soft); color: var(--ink); }
.acctbtn .initials { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bubble-user, var(--paper)); color: var(--ink); font-size: 11.5px; font-weight: 700; letter-spacing: .3px; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 240px;
  max-width: min(320px, calc(100vw - 24px)); background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 6px; text-align: left;
  box-shadow: 0 2px 4px rgba(16,24,40,.06), 0 12px 32px rgba(16,24,40,.14); }
:root[data-theme="dark"] .menu { box-shadow: 0 12px 32px rgba(0,0,0,.5); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .menu { box-shadow: 0 12px 32px rgba(0,0,0,.5); } }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; line-height: 1.35; }
.menu .who b { display: block; font-size: 14px; font-weight: 650; color: var(--ink); }
.menu .who span { display: block; font-size: 12.5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu .who:empty { display: none; }
.menu .grp { border-bottom: 1px solid var(--line); margin-bottom: 6px; padding-bottom: 6px; }
.menu .grp-h { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); padding: 4px 10px; }
/* No admin pages for this person -> no Admin section at all. */
.menu .grp.admin:not(:has(a:not([hidden]))) { display: none; }
.menu a, .menu button.signout { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px;
  border-radius: 8px; font: inherit; font-size: 14px; color: var(--ink); text-decoration: none; background: none;
  border: 0; cursor: pointer; text-align: left; }
.menu a:hover, .menu button.signout:hover, .menu a:focus-visible, .menu button.signout:focus-visible { background: var(--paper); outline: none; }
/* The page you are on: marked, not a dead link. */
.menu a[aria-current="page"] { font-weight: 650; background: var(--paper); }
.menu a[aria-current="page"]::after { content: ""; margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.menu button.signout { color: var(--ink-soft); }
.menu button.signout:hover { color: var(--ink); }

@media (max-width: 640px) {
  .hbtn .lbl { display: none; }
  .hbtn.back { padding: 0; width: 34px; }
}

/* Standard header layout for the admin/form pages (header.hdr-std); the chat's
   own header in index.html follows the same rules. */
header.hdr-std { gap: 12px; padding: 12px 20px; }
.hdr-std .titles { min-width: 0; line-height: 1.25; }
.hdr-std .mark.has-logo + .titles { padding-left: 14px; border-left: 1px solid var(--line); }
.hdr-std .titles h1, .hdr-std .titles p { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 820px) { .hdr-std .titles p { display: none; } }
@media (max-width: 640px) {
  header.hdr-std { gap: 8px; padding: 8px 12px; }
  .hdr-std .mark.has-logo { height: 28px !important; max-width: 27vw; }
  .hdr-std .titles h1 { font-size: 15.5px; }
  .hdr-std .mark.has-logo + .titles { padding-left: 10px; }
}

/* A header logo of ANY shape fits the mark's height (a curator can upload a tall
   or square logo, site-settings.md). The mark is a grid box, where an image's
   height:100% does not resolve — a flex box makes it definite. */
.mark.has-logo { display: flex !important; align-items: center; overflow: hidden; }
.mark.has-logo img { height: 100% !important; max-height: 100% !important; width: auto !important; max-width: 100% !important; object-fit: contain; }

/* ---- Live demo bar + end card (live-demo.md; only on the livedemo client) ---- */
.demo-bar { flex: 0 0 auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 6px 14px; font-size: 13.5px; line-height: 1.3;
  background: #14304a; color: #fff; }
.demo-bar .demo-tag { font-weight: 700; letter-spacing: .06em; text-transform: uppercase; font-size: 11.5px; background: #f59f00; color: #1b1f24; border-radius: 4px; padding: 2px 6px; }
.demo-bar .demo-text { opacity: .9; }
.demo-bar .demo-left { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.demo-bar.soon .demo-left { color: #ffd27a; }
.demo-bar .demo-link { color: #fff; text-decoration: underline; margin-left: auto; }
.demo-ended { position: fixed; inset: 0; z-index: 1000; background: rgba(10, 20, 30, .72); display: grid; place-items: center; padding: 16px; }
.demo-ended-card { max-width: 440px; width: 100%; background: var(--surface, #fff); color: var(--ink, #1b1f24); border-radius: 14px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.demo-ended-card h2 { margin: 0 0 10px; font-size: 22px; }
.demo-ended-card p { margin: 0 0 10px; }
.demo-ended-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.demo-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line, #c9d3dd);
  background: transparent; color: inherit; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.demo-btn.primary { background: var(--accent, #1f6fb2); border-color: transparent; color: #fff; }
