/* The G1 operator shell: a sidebar or a rail beside a topbar, and one
   content edge for everything under them. Every value is a var(--...) from lib/tokens/g1.css; this
   file sets no colour, length or typeface of its own. lib/shell/shell.js builds the nav and the
   topbar; a product writes only what goes in .bc-main.

   The rail at any width (data-nav="rail") and the phone collapse (767 px and under) change the
   same few custom properties on .bc-shell, so the nav and the topbar read one set of values. */

.bc-shell {
  --bc-nav: var(--shell-sidebar);
  --bc-nav-pad: var(--space-12);
  --bc-label: inline;
  --bc-justify: start;
  --bc-gutter: var(--shell-gutter);
  --bc-control: var(--space-40);

  display: grid;
  grid-template-columns: var(--bc-nav) minmax(0, 1fr);
  grid-template-rows: var(--shell-topbar) 1fr;
  grid-template-areas:
    "nav top"
    "nav main";
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--surface);
  color: var(--ink);
  font: var(--text-row-weight) var(--text-row-size) / var(--text-row-line)
    var(--font-sans);
}

.bc-shell[data-nav="rail"] {
  --bc-nav: var(--shell-rail);
  /* the rail's hairline sits inside its 48 px, so a link takes the whole inner width */
  --bc-nav-pad: var(--space-0);
  --bc-label: none;
  --bc-justify: center;
}

body:has(> .bc-shell) {
  margin: 0;
  background: var(--surface);
}

[data-theme="dark"] {
  color-scheme: dark;
}

.bc-shell :focus-visible {
  outline: var(--space-2) solid var(--accent);
  outline-offset: var(--space-2);
}

/* nav: the quiet column; the accent is only the active item's tint */
.bc-nav {
  grid-area: nav;
  border-right: thin solid var(--line);
  box-sizing: border-box;
  background: var(--surface);
}

.bc-nav-list {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 100vh;
  max-height: 100dvh;
  overflow-y: auto;
  padding: var(--space-12) var(--bc-nav-pad);
  box-sizing: border-box;
}

.bc-nav a {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: var(--bc-justify);
  gap: var(--space-12);
  min-height: var(--bc-control);
  padding: 0 var(--space-12);
  border-radius: var(--radius-control);
  box-sizing: border-box;
  color: var(--ink-2);
  text-decoration: none;
}

.bc-nav a:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.bc-nav a[aria-current="page"] {
  background: color-mix(in oklab, var(--accent) 12%, transparent);
  color: var(--ink);
}

.bc-nav svg {
  flex: none;
  width: var(--space-16);
  height: var(--space-16);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bc-nav-label {
  display: var(--bc-label);
}

/* topbar: the screen's title on the content edge, its actions at the far end */
.bc-topbar {
  grid-area: top;
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: 0 var(--bc-gutter);
  border-bottom: thin solid var(--line);
  box-sizing: border-box;
  background: var(--surface);
}

.bc-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--text-title-size);
  font-weight: var(--text-title-weight);
  line-height: var(--text-title-line);
}

.bc-actions {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.bc-action,
.bc-theme {
  display: inline-flex;
  align-items: center;
  min-height: var(--bc-control);
  padding: 0 var(--space-12);
  border: thin solid var(--line-strong);
  border-radius: var(--radius-control);
  box-sizing: border-box;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.bc-theme {
  border-color: transparent;
  color: var(--ink-2);
}

.bc-action:hover,
.bc-theme:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

/* content: one edge, the gutter from the nav, full width (no max-width) */
.bc-main {
  grid-area: main;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
  gap: var(--space-24);
  min-width: 0;
  padding: var(--bc-gutter);
}

/* split: two columns of one height; the shorter one's content sits in the middle */
.bc-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-24);
}

.bc-split > * {
  display: grid;
  align-content: center;
}

/* surface: the one bordered level; inside another it is a plain group */
.bc-surface {
  padding: var(--space-16) var(--space-20);
  border: thin solid var(--line);
  border-radius: var(--radius-container);
  box-sizing: border-box;
  background: var(--surface-raised);
}

.bc-surface .bc-surface {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
}

@media (max-width: 767px) {
  .bc-shell {
    --bc-nav: var(--shell-rail);
    --bc-nav-pad: var(--space-0);
    --bc-label: none;
    --bc-justify: center;
    --bc-gutter: var(--shell-gutter-phone);
    --bc-control: var(--target-min);
  }

  .bc-split {
    grid-template-columns: minmax(0, 1fr);
  }

  .bc-surface {
    padding: var(--space-12) var(--space-16);
  }
}

/* paper: the day without the chrome */
@media print {
  .bc-shell {
    display: block;
  }

  .bc-nav,
  .bc-topbar {
    display: none;
  }
}
