/* ============================================================
   ATLAS — chrome layout
   Ported from the design handoff's app.css
   (docs/design-references/design_handoff_atlas/source/src/app.css),
   the chrome subset only: app shell grid, topbar, impersonation
   banner, sidenav, main scroll region. The Landing / Bundles / audit
   / palette / toast view styles land with their surfaces next cycle.

   Deliberately NOT ported (design README §6 + spec §4.2): the dead
   .topbar__switcher / .surfacebtn rules — the surface switcher was
   removed; the operator shell does not dangle dead links to unbuilt
   siblings.
   ============================================================ */

/* Suppress all transitions for one frame during a theme switch so
   custom-property-driven surfaces repaint instantly (no stale paint).
   The appTheme.set shim in index.html toggles .theme-switching. */
:root.theme-switching,
:root.theme-switching *,
:root.theme-switching *::before,
:root.theme-switching *::after {
  transition: none !important;
}

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 44px auto 1fr;
  grid-template-areas:
    "top top"
    "imp imp"
    "nav main";
  height: 100vh;
  background: var(--bg-1);
  overflow: hidden;
}
.app--collapsed { grid-template-columns: 56px 1fr; }

/* ---------- TopBar ---------- */
.topbar {
  grid-area: top;
  display: grid;
  grid-template-columns: 220px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 0 12px 0 0;
  background: var(--bg-0);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.app--collapsed .topbar { grid-template-columns: 56px 1fr auto; }

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 14px;
  height: 100%;
  border-right: 1px solid var(--line);
  min-width: 0;
}
.topbar__name {
  display: flex;
  flex-direction: column;
  line-height: 1;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
}
/* Crossroads surface lockup — Crossroads (serif) · Atlas (mono caps).
   Reads as "product of the Crossroads family, this surface is Atlas." */
.topbar__lockup {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
  min-width: 0;
}
.topbar__parent {
  font-family: "Source Serif 4", "Source Serif Pro", Charter, Georgia, serif;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.012em;
  color: var(--fg-1);
  font-feature-settings: "liga", "dlig";
}
.topbar__sep {
  display: inline-block;
  width: 1px;
  height: 11px;
  background: var(--line-bright);
}
.topbar__product {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--cyan);
}
.topbar__env {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-4);
  letter-spacing: 0.06em;
}
.app--collapsed .topbar__name { display: none; }

.topbar__search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 460px;
  height: 28px;
  padding: 0 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  color: var(--fg-3);
  font-size: 13px;
  cursor: text;
  transition: border-color 120ms;
}
.topbar__search:hover { border-color: var(--line-strong); }
.topbar__search > span:nth-child(2) {
  flex: 1;
  text-align: left;
  color: var(--fg-3);
}
.topbar__shortcut { display: inline-flex; gap: 2px; }

.topbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 4px;
}
.topbar__avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-1);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* ---------- Impersonation banner ---------- */
.imp-banner {
  grid-area: imp;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  background: var(--impersonation-bg);
  border-bottom: 1px solid color-mix(in oklab, var(--amber) 30%, var(--bg-0));
  color: var(--amber);
  position: relative;
}
.imp-banner::before {
  /* tactile diagonal hatching to distinguish from the rest of chrome */
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(0,0,0,0.12) 0,
    rgba(0,0,0,0.12) 1px,
    transparent 1px,
    transparent 8px
  );
  pointer-events: none;
}
.imp-banner__icon { display: inline-flex; }
.imp-banner__msg {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  font-size: 12.5px;
  color: var(--amber);
  position: relative;
}
.imp-banner__who { color: var(--fg-1); font-weight: 550; }
.imp-banner__where { color: var(--fg-2); }
.imp-banner__reason, .imp-banner__time { color: var(--amber); opacity: 0.85; font-size: 11px; }
.imp-banner__sep { color: var(--amber); opacity: 0.5; }
.imp-banner__end {
  position: relative;
  color: var(--amber);
  border-color: color-mix(in oklab, var(--amber) 40%, transparent);
  background: rgba(0,0,0,0.15);
}
.imp-banner__end:hover {
  background: var(--red-tint);
  color: var(--red);
  border-color: var(--red);
}
:root[data-theme="light"] .imp-banner::before { background-image: repeating-linear-gradient(-45deg, rgba(170,110,20,0.10) 0, rgba(170,110,20,0.10) 1px, transparent 1px, transparent 8px); }
:root[data-theme="light"] .imp-banner__who { color: var(--fg-1); }

/* ---------- Sidenav ---------- */
.sidenav {
  grid-area: nav;
  background: var(--bg-0);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 12px 0 0 0;
}
.sidenav__section { padding: 0 8px 4px; }
.sidenav__heading {
  font-size: 10px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--fg-5);
  font-family: var(--font-mono);
  padding: 14px 8px 6px;
  font-weight: 500;
}
.sidenav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.sidenav__item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  height: 28px;
  background: transparent;
  border: 0;
  border-radius: var(--r-2);
  color: var(--fg-2);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: color 80ms;
  white-space: nowrap;
  position: relative;
}
.sidenav__item:hover:not(:disabled) { background: var(--bg-2); color: var(--fg-1); }
.sidenav__item.is-active {
  background: var(--bg-3);
  color: var(--fg-1);
  font-weight: 550;
  box-shadow: inset 2px 0 0 var(--cyan);
}
.sidenav__item.is-stub { color: var(--fg-3); }
.sidenav__item.is-reserved {
  color: var(--fg-5);
  cursor: not-allowed;
  opacity: 0.7;
}
.sidenav__item.is-reserved:hover { background: transparent; color: var(--fg-5); }
.sidenav__icon { display: inline-flex; color: var(--fg-3); }
.sidenav__item.is-active .sidenav__icon { color: var(--cyan); }
.sidenav__item.is-reserved .sidenav__icon { color: var(--fg-5); }
.sidenav__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidenav__reserved {
  width: 5px; height: 5px;
  border-radius: 50%;
  border: 1px solid var(--fg-5);
  display: inline-block;
  flex-shrink: 0;
}
.sidenav__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  color: var(--amber);
  background: var(--bg-tint-amber);
  border-radius: var(--r-1);
}
.sidenav__foot {
  margin-top: auto;
  padding: 14px 12px 12px;
  border-top: 1px solid var(--line);
}
.sidenav__build {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--fg-4);
}

.app--collapsed .sidenav__label,
.app--collapsed .sidenav__heading,
.app--collapsed .sidenav__build,
.app--collapsed .sidenav__reserved,
.app--collapsed .sidenav__badge { display: none; }
.app--collapsed .sidenav__item { justify-content: center; padding: 0; }

/* ---------- Main scroll region ---------- */
.main {
  grid-area: main;
  overflow: auto;
  background: var(--bg-1);
  min-width: 0;
  position: relative;
}
