/*
 * forge_shell.css — Tokamak's global app shell on the Forge "Vellum Ink"
 * register (ADR-0007). The topbar + sidebar + page grid are ported from the
 * Forge prototype (product-forge/prototypes/vellum-ink/today-diverging.html),
 * consuming forge.css tokens via var(--forge-*) / var(--vl-*).
 *
 * Two Tokamak-specific additions Forge does not ship:
 *   - the app/area switcher in the sidebar header (Forge removed its
 *     customer-workspace switcher — maintainer fix #6 — but Tokamak hosts
 *     multiple apps, so the switcher is reintroduced here; see ADR-0007), and
 *   - topbar__account (renamed from the prototype's topbar__workspace): the
 *     account associated with the current user, with a profile-menu switcher.
 *
 * The register itself (cream canvas, body filter, fonts) is applied by the
 * .vellum-ink wrapper on <body> (see forge.base.css).
 */

/* ---- App grid: sticky sidebar (col 1) + topbar/main (col 2) ---- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w, 224px) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  transition: grid-template-columns 280ms var(--vl-motion-ease);
}
.app.is-sidebar-collapsed { --sidebar-w: 64px; }

/* ---- Topbar (col 2, row 1): account · search · profile ---- */
.topbar {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 16px;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--vl-border-subtle);
  background: var(--forge-surface-primary);
  height: 48px;
  box-sizing: border-box;
  position: sticky;
  top: 0;
  z-index: 20;
}
@supports (backdrop-filter: blur(20px)) or (-webkit-backdrop-filter: blur(20px)) {
  .topbar {
    background: var(--vl-surface-chrome);
    -webkit-backdrop-filter: blur(var(--vl-blur-chrome)) saturate(160%);
    backdrop-filter: blur(var(--vl-blur-chrome)) saturate(160%);
  }
}
/* position:relative anchors the account dropdown (.topbar__menu, position:absolute)
   to the trigger — without it the menu resolves against the sticky .topbar and
   opens flush to the topbar's left edge / bottom instead of under the account. */
.topbar__account { justify-self: start; display: flex; align-items: center; gap: 8px; position: relative; }
.topbar__account-logo { height: 22px; width: auto; max-width: none; display: block; }
.topbar__account-name {
  font-family: var(--vl-font-serif);
  font-weight: 600;
  font-size: 15px;
  color: var(--forge-text-primary);
  letter-spacing: -0.01em;
}

.topbar__search {
  justify-self: stretch;
  width: 100%;
  max-width: 620px;
  margin-inline: auto;
  position: relative;
  display: flex;
  align-items: center;
}
.topbar__search svg {
  position: absolute;
  left: 14px;
  width: 15px;
  height: 15px;
  color: var(--forge-text-tertiary);
  opacity: 0.6;
  pointer-events: none;
  transition: opacity 180ms ease-out;
}
.topbar__search input {
  width: 100%;
  padding: 7px 14px 7px 38px;
  border-radius: var(--vl-radius-chip);
  background: var(--vl-surface-well);
  border: 1px solid var(--vl-border-subtle);
  color: var(--forge-text-secondary);
  font-size: 13px;
  font-family: inherit;
  transition: background 180ms, border-color 180ms, color 180ms, box-shadow 180ms;
}
.topbar__search input::placeholder {
  color: var(--forge-text-tertiary);
  font-style: italic;
  font-family: var(--vl-font-serif);
}
.topbar__search:hover svg,
.topbar__search:focus-within svg { opacity: 1; }
.topbar__search input:focus {
  outline: none;
  background: var(--vl-surface-content);
  border-color: var(--forge-interactive-default);
  color: var(--forge-text-primary);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--forge-interactive-default) 16%, transparent);
}

.topbar__right { justify-self: end; display: flex; align-items: center; gap: 10px; }
/* Topbar icon controls (Help, Notifications, the workspace-settings gear) are
   app chrome, not Forge Buttons: the topbar wants a tighter, circular rhythm
   (32px circle vs Button's 36px rounded-square icon size — Forge exposes
   neither), the design-mock "resting chip" look (well fill + subtle border),
   and a frost hover tint. The pre-ADR-025 markup rendered Forge Buttons and
   re-pointed the kit's private --_btn-* props; those props retired with
   forge.kit.css, so the treatment now lives here outright — same pixels,
   matching .topbar__avatar's chip idiom next to it. */
.topbar__icon-btn {
  width: 32px; height: 32px; padding: 0;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--vl-surface-well);
  color: var(--forge-text-secondary);
  border: 1px solid var(--vl-border-subtle);
  cursor: pointer;
  font-family: inherit;
  transition: background 180ms, border-color 180ms, color 180ms;
}
.topbar__icon-btn:hover {
  color: var(--forge-text-primary);
  background: color-mix(in oklch, var(--forge-interactive-default) 10%, transparent);
  border-color: color-mix(in oklch, var(--forge-interactive-default) 32%, transparent);
}
.topbar__icon-btn:focus-visible {
  outline: 2px solid var(--forge-interactive-default);
  outline-offset: 2px;
}
.topbar__icon-btn:active { transform: translateY(1px); }
.topbar__icon-btn svg { width: 15px; height: 15px; }
/* The gear's frost-blue "active workspace" tint on /voices/config is app
   state, driven from the active <details> wrapper. */
.topbar__menu-wrap.is-active > .topbar__icon-btn {
  color: var(--forge-interactive-default);
  border-color: color-mix(in oklch, var(--forge-interactive-default) 32%, transparent);
  background: color-mix(in oklch, var(--forge-interactive-default) 12%, transparent);
}
.topbar__menu-wrap.is-active > .topbar__icon-btn:hover {
  background: color-mix(in oklch, var(--forge-interactive-default) 18%, transparent);
}

/* Workspace-settings gear menu (<details> driven by nav_menu_controller). */
.topbar__menu-wrap { position: relative; }
.topbar__menu-wrap > summary { list-style: none; cursor: pointer; }
.topbar__menu-wrap > summary::-webkit-details-marker { display: none; }

/* Profile menu (<details> driven by nav_menu_controller) */
.topbar__profile { position: relative; }
.topbar__profile > summary { list-style: none; cursor: pointer; }
.topbar__profile > summary::-webkit-details-marker { display: none; }
/* Avatar = the profile-menu trigger. A 32px circle matching the icon buttons'
   resting chip (well fill + subtle border) and their frost hover tint — it's a
   menu control, so it should read as pressable, not just scale. */
.topbar__avatar {
  width: 32px; height: 32px;
  border-radius: 999px;
  background: var(--vl-surface-well);
  color: var(--forge-text-secondary);
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--vl-border-subtle);
  cursor: pointer;
  font-size: 13px; font-weight: 600;
  font-family: var(--vl-font-sans);
  overflow: hidden;
  transition: background 180ms, border-color 180ms;
}
.topbar__avatar:hover {
  background: color-mix(in oklch, var(--forge-interactive-default) 10%, transparent);
  border-color: color-mix(in oklch, var(--forge-interactive-default) 32%, transparent);
}

.topbar__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--vl-surface-deep);
  border: 1px solid var(--vl-border-subtle);
  border-radius: var(--vl-radius-card-sm);
  box-shadow: var(--vl-shadow-popover);
  padding: 8px;
  z-index: 40;
}
@supports (backdrop-filter: blur(20px)) {
  .topbar__menu { backdrop-filter: blur(var(--vl-blur-deep)) saturate(150%); }
}
.topbar__menu-label {
  display: block;
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--forge-text-tertiary);
  padding: 6px 10px 4px;
  font-weight: 500;
}
.topbar__menu-email { padding: 2px 10px 8px; font-size: 12px; color: var(--forge-text-tertiary); }
.topbar__menu form { margin: 0; }
.topbar__menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 8px;
  background: transparent; border: 0;
  color: var(--forge-text-secondary); font-size: 13px;
  font-family: var(--vl-font-sans);
  text-align: left; text-decoration: none; cursor: pointer;
  transition: background 140ms, color 140ms;
}
.topbar__menu-item:hover,
.topbar__menu-item:focus-visible {
  background: color-mix(in oklch, var(--forge-interactive-default) 10%, transparent);
  color: var(--forge-text-primary);
}
.topbar__menu-item:focus-visible {
  outline: 2px solid var(--forge-interactive-default);
  outline-offset: -2px;
}
.topbar__menu-item[aria-current="true"] { color: var(--forge-interactive-default); font-weight: 500; }
.topbar__menu-item img { height: 16px; width: auto; }
/* Size the leading menu-item icon to 16px (parity with the app switcher + sidebar
   nav items); unclassed lucide icons otherwise fall back to their 24px default.
   `:first-child` targets only the leading icon, sparing the account row's trailing
   check (a last child, sized 14px inline). */
.topbar__menu-item > svg:first-child { width: 16px; height: 16px; flex-shrink: 0; }
.topbar__menu-divider { height: 1px; background: var(--vl-border-hairline); margin: 6px 4px; border: 0; }

/* ---- Sidebar (col 1, rows 1-3): brand · app switcher · nav · footer ---- */
.sidebar {
  grid-column: 1;
  grid-row: 1 / 3;
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--vl-border-hairline);
  background: transparent;
  overflow: hidden;
  z-index: 15;
}
.sidebar__header {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--vl-border-subtle);
  height: 48px;
  box-sizing: border-box;
  position: relative;
  background: var(--forge-surface-primary);
}
@supports (backdrop-filter: blur(20px)) or (-webkit-backdrop-filter: blur(20px)) {
  .sidebar__header {
    background: var(--vl-surface-chrome);
    -webkit-backdrop-filter: blur(var(--vl-blur-chrome)) saturate(160%);
    backdrop-filter: blur(var(--vl-blur-chrome)) saturate(160%);
  }
}
.sidebar__brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; text-decoration: none; }
/* max-width:none defeats Tailwind preflight's `img { max-width:100% }`, which
   otherwise clamps the mark to 0 when the brand is 0-width (collapsed rail). */
.sidebar__topodot { width: 24px; height: 24px; max-width: none; flex-shrink: 0; display: block; transition: opacity 200ms; }
.sidebar__wordmark { height: 14px; width: auto; display: block; transition: opacity 200ms; }
.sidebar__collapse,
.sidebar__expand {
  width: 26px; height: 26px;
  border: 0; background: transparent;
  border-radius: 6px;
  color: var(--forge-text-tertiary);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  font-family: inherit;
  transition: background 180ms, color 180ms;
}
.sidebar__collapse:hover,
.sidebar__expand:hover { background: var(--vl-surface-content); color: var(--forge-text-primary); }
.sidebar__collapse svg, .sidebar__expand svg { width: 14px; height: 14px; }
.sidebar__expand {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0; pointer-events: none;
  width: 30px; height: 30px;
  border-radius: 999px;
  background: var(--vl-surface-deep);
  border: 1px solid var(--vl-border-subtle);
  transition: opacity 200ms;
}

/* App/area switcher (reintroduced — see ADR-0007). <details> + nav_menu. */
.sidebar__switcher { position: relative; padding: 12px 12px 0; }
.sidebar__switcher > summary { list-style: none; cursor: pointer; }
.sidebar__switcher > summary::-webkit-details-marker { display: none; }
.sidebar__switcher-current {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--vl-border-subtle);
  background: var(--vl-surface-well);
  color: var(--forge-text-primary);
  transition: background 160ms, border-color 160ms;
}
.sidebar__switcher-current:hover { background: var(--vl-surface-content); }
.sidebar__switcher-current svg:first-child { width: 16px; height: 16px; color: var(--forge-interactive-default); flex-shrink: 0; }
.sidebar__switcher-labels { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sidebar__switcher-eyebrow { font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--forge-text-tertiary); }
.sidebar__switcher-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__switcher-caret { width: 14px; height: 14px; color: var(--forge-text-tertiary); transition: transform 200ms; flex-shrink: 0; }
.sidebar__switcher[open] .sidebar__switcher-caret { transform: rotate(180deg); }
.sidebar__switcher-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 12px; right: 12px;
  background: var(--vl-surface-deep);
  border: 1px solid var(--vl-border-subtle);
  border-radius: var(--vl-radius-card-sm);
  box-shadow: var(--vl-shadow-popover);
  padding: 6px;
  z-index: 30;
}
@supports (backdrop-filter: blur(20px)) {
  .sidebar__switcher-menu { backdrop-filter: blur(var(--vl-blur-deep)) saturate(150%); }
}
.sidebar__switcher-option {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--forge-text-secondary); font-size: 13px;
  text-decoration: none; transition: background 140ms, color 140ms;
}
.sidebar__switcher-option svg { width: 16px; height: 16px; color: var(--forge-text-tertiary); }
.sidebar__switcher-option:hover { background: var(--vl-surface-content); color: var(--forge-text-primary); }
.sidebar__switcher-option[aria-current="true"] { color: var(--forge-interactive-default); font-weight: 500; }
.sidebar__switcher-option[aria-current="true"] svg { color: var(--forge-interactive-default); }

.sidebar__nav { padding: 14px 12px; flex: 1; min-height: 0; overflow-y: auto; }
.sidebar__group { margin-bottom: 14px; }
.sidebar__group:last-child { margin-bottom: 0; }
.sidebar__group-label {
  display: block;
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--forge-text-tertiary);
  padding: 4px 10px 6px;
  margin-top: 4px;
  font-weight: 500;
}
.sidebar__item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--forge-text-secondary); font-size: 13px;
  text-decoration: none; cursor: pointer;
  white-space: nowrap; overflow: hidden;
  transition: background 160ms, color 160ms;
}
.sidebar__item svg { width: 16px; height: 16px; color: var(--forge-text-tertiary); flex-shrink: 0; }
.sidebar__item:hover {
  background: color-mix(in oklch, var(--vl-surface-content) 70%, transparent);
  color: var(--forge-text-primary);
}
.sidebar__item--active {
  background: var(--vl-surface-content);
  color: var(--forge-text-primary);
  box-shadow: inset 2.5px 0 0 var(--forge-interactive-default);
}
.sidebar__item--active svg { color: var(--forge-interactive-default); }
/* Unwired nav items (badge-marked, e.g. Account Admin's TBD entries). */
.sidebar__item--inert { cursor: default; }
.sidebar__item--inert:hover { background: transparent; color: var(--forge-text-secondary); }
.sidebar__item-badge {
  flex-shrink: 0;
  margin-left: auto;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: var(--vl-radius-chip);
  background: var(--vl-surface-inset);
  color: var(--forge-text-tertiary);
}

.sidebar__footer {
  border-top: 1px solid var(--vl-border-subtle);
  padding: 10px 12px 14px;
  flex-shrink: 0;
}
.sidebar__footer .sidebar__item { color: var(--forge-text-tertiary); }
.sidebar__footer .sidebar__item:hover { color: var(--forge-text-primary); background: var(--vl-surface-content); }

/* ---- Main content region (col 2, row 2) ---- */
.main {
  grid-column: 2;
  grid-row: 2;
  padding: 18px clamp(20px, 3vw, 40px) 64px;
  max-width: 1680px;
  width: 100%;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}
.main > .flash { margin: 0; }
/* On Voices pages the body is the centered .ui-page (w-full, max-width 1132,
   mx-auto); match the flash to it — full width up to 1132, centered — instead of
   left-aligning. (width:100% keeps the flex item from shrinking to its content.) */
.main--voices > .flash { width: 100%; max-width: 1132px; margin-inline: auto; }

/* Compact page header for every Voices page (parity with voices/feed): tighter
   padding, a smaller title with a leading frost bullet, no corner accent dot,
   and a slightly smaller description. Scoped to .main--voices (set by the layout
   on /voices paths) so non-Voices pages keep the full Forge page header. */
.main--voices .ui-page-header {
  padding: var(--vl-space-4, 16px) var(--vl-space-5, 20px);
  margin-bottom: var(--vl-space-4, 16px);
}
.main--voices .ui-page-header::before { content: none; }
/* Drop the all-caps eyebrow/kicker ("Voices", "<Tenant> Configuration") on
   Voices pages — the title alone carries the header. */
.main--voices .ui-page-kicker { display: none; }
.main--voices .ui-page-title {
  display: flex;
  align-items: center;
  gap: var(--vl-space-2, 8px);
  font-size: 1.5rem;
  line-height: 1.2;
  margin: 0;
}
.main--voices .ui-page-title::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: var(--vl-radius-chip, 999px);
  background: var(--forge-interactive-default);
}
.main--voices .ui-page-copy { margin-top: 6px; font-size: 0.9rem; }

/* ---- Collapsed sidebar ---- */
.app.is-sidebar-collapsed .sidebar__wordmark,
.app.is-sidebar-collapsed .sidebar__collapse,
.app.is-sidebar-collapsed .sidebar__group-label,
.app.is-sidebar-collapsed .sidebar__switcher-labels,
.app.is-sidebar-collapsed .sidebar__switcher-caret { display: none; }
.app.is-sidebar-collapsed .sidebar__switcher { padding: 12px 8px 0; }
.app.is-sidebar-collapsed .sidebar__switcher-current { justify-content: center; padding: 8px; }
.app.is-sidebar-collapsed .sidebar__footer { padding: 10px 8px 14px; }
.app.is-sidebar-collapsed .sidebar__header { padding: 0 8px; justify-content: center; }
.app.is-sidebar-collapsed .sidebar__brand { justify-content: center; flex: none; }
.app.is-sidebar-collapsed .sidebar__nav { padding: 14px 8px; }
.app.is-sidebar-collapsed .sidebar__item { justify-content: center; padding: 8px; gap: 0; }
.app.is-sidebar-collapsed .sidebar__item span { display: none; }
.app.is-sidebar-collapsed .sidebar:hover .sidebar__topodot { opacity: 0; }
.app.is-sidebar-collapsed .sidebar:hover .sidebar__expand { opacity: 1; pointer-events: auto; }

/* Responsive: collapse the grid to a single column on narrow viewports. */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { grid-column: 1; }
  .main { grid-column: 1; }
}

/* Placeholder nav items (surfaces not yet built): styled like any resting nav
   item to match the source — not dimmed — just not navigable. */
.sidebar__item[aria-disabled="true"] { cursor: default; }
