/*
  CHELABS Unified UI v2 — layout
  Version: 2.2.0

  The application shell (sidebar, main column, content container, page
  header, grid/stack), the authentication shell, and the responsive
  rules — ported from docs/design-system/v2-reference/chelabs-ui.css.
  Every colour and structural size is a token from tokens.css.

  Class names carry the `chelabs-` prefix so the system can be vendored
  into a product next to that product's own CSS without collisions; the
  reference's unprefixed names (.sidebar, .nav-item, .page-header ...)
  map one-to-one onto the prefixed ones below.

  Deliberately not ported from the reference: .balance-card (billing has
  no counterpart in the Control Plane), the hash-based screen switcher
  (a static-demo device), and the 78px icon rail at <=860px — below
  that width the sidebar becomes an off-canvas drawer opened from a
  mobile top bar, with no JavaScript (a checkbox toggle), because a
  hidden sidebar with no way to open it is not usable on a phone.
*/

/* ============= APP SHELL ============= */
.chelabs-shell {
  min-height: 100vh;
  display: flex;
  background: var(--cl-page);
}

.chelabs-sidebar {
  position: sticky;
  top: 0;
  width: var(--cl-sidebar-w);
  min-width: var(--cl-sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 18px 16px;
  background: var(--cl-sidebar);
  border-right: 1px solid var(--cl-sidebar-line);
  z-index: 20;
  overflow-y: auto;
}

/* brand row: mark + wordmark */
.chelabs-brand {
  height: var(--cl-brand-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 15px;
  border-bottom: 1px solid var(--cl-line);
  margin-bottom: 16px;
}
/* [2.1.0, DS-07 / ADR-037] THE MARK IS AN IMAGE, AND THAT IS THE POINT.
   Until 2.0.0 this rule DREW a mark: a rotated gradient tile with two
   white strokes across it, built from ::before and ::after. That shape
   was taken from the third-party interface used as the visual reference
   for v2 and belongs to that third party (Root Owner decision,
   2026-09-19, roadmap DS-07).

   Deleting the geometry is the whole remedy. Recolouring it, or keeping
   it behind a flag, would still be reproducing someone else's mark, so
   nothing here draws anything any more: this is a box for an <img>
   whose src is the product's own approved asset. A product therefore
   sets its mark by pointing that src at its own file — it never edits
   its vendored copy of this stylesheet, which is what
   docs/DESIGN_SYSTEM.md section 7 step 5 requires of it.

   NO border-radius, deliberately. The approved artwork for this size is
   a rounded tile that carries its OWN corners, transparent outside
   them — measured at roughly 14% of its side. A CSS radius on top of
   that would clip a second, tighter curve into a shape that is already
   curved, biting into the tile. Rounding belongs to whoever drew it. */
.chelabs-brand-mark {
  width: var(--cl-brand-mark-size);
  height: var(--cl-brand-mark-size);
  flex: 0 0 auto;
  object-fit: contain;
}
.chelabs-brand-name {
  color: var(--cl-brand-wordmark);
  font-size: var(--cl-text-brand);
  font-weight: 800;
  letter-spacing: -0.025em;
}

/* navigation groups */
.chelabs-nav-group { margin-top: 4px; }
.chelabs-nav-label {
  padding: 14px 13px 8px;
  color: var(--cl-nav-label);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.chelabs-nav-item {
  height: var(--cl-nav-item-h);
  width: 100%;
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 2px 0;
  padding: 0 13px;
  border: 0;
  border-radius: var(--cl-r-nav);
  background: transparent;
  color: var(--cl-nav-text);
  font-weight: 500;
  text-align: left;
  transition: color var(--cl-fast), background var(--cl-fast);
}
.chelabs-nav-item:hover {
  color: var(--cl-nav-hover);
  background: var(--cl-nav-hover-bg);
}
.chelabs-nav-item.active {
  color: var(--cl-nav-active);
  background: var(--cl-brand-soft);
  font-weight: 650;
}
.chelabs-nav-item .icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============= A COLLAPSIBLE SIDEBAR SECTION =============
   The approved ui-reference/01_menu_and_registry.png (Root Owner,
   2026-09-24): a section is an icon, a label and a chevron, and it
   opens and closes.

   <details>/<summary>, NOT JavaScript. The panel has zero lines of it
   by decision, and a disclosure widget is one of the things HTML
   already does -- including the keyboard handling, the ARIA state and
   the chevron's own open/closed knowledge, all of which a hand-rolled
   version gets wrong first and fixes later.

   The consequence, stated rather than discovered: which sections are
   open is NOT remembered across a navigation, because remembering it
   would need either script or a cookie. The server opens the section
   that contains the current page, which is the state that matters and
   is the one the reference shows. */
.chelabs-nav-section { margin-top: 4px; }
.chelabs-nav-section > summary {
  height: var(--cl-nav-item-h);
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 2px 0;
  padding: 0 13px;
  border-radius: var(--cl-r-nav);
  color: var(--cl-nav-text);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  transition: color var(--cl-fast), background var(--cl-fast);
}
/* Safari/Chrome draw their own triangle on a summary; this system has
   its own chevron, on the other side. */
.chelabs-nav-section > summary::-webkit-details-marker { display: none; }
.chelabs-nav-section > summary:hover { color: var(--cl-nav-hover); background: var(--cl-nav-hover-bg); }
.chelabs-nav-section > summary > .icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chelabs-nav-section > summary > span { flex: 1; min-width: 0; }
.chelabs-nav-chevron {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--cl-fast);
}
.chelabs-nav-section[open] > summary > .chelabs-nav-chevron { transform: rotate(180deg); }
/* The children: visually nested and a little more compact than the
   parent, per the brief. */
.chelabs-nav-section .chelabs-nav-group { margin: 2px 0 6px; padding-left: 18px; }
.chelabs-nav-section .chelabs-nav-item { height: 42px; font-size: 14px; }

.chelabs-sidebar-spacer { flex: 1; min-height: 20px; }

/* the signed-in user, pinned above the footer links */
.chelabs-profile {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border-radius: var(--cl-r-nav);
  min-width: 0;
}
/* the name/role block; scoped to its own children so the avatar span
   next to it keeps its own centring */
.chelabs-profile > div { min-width: 0; }
.chelabs-profile > div > strong {
  display: block;
  font-size: 14px;
  color: var(--cl-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chelabs-profile > div > span {
  display: block;
  font-size: 12px;
  color: var(--cl-profile-sub);
}
.chelabs-sidebar-footer-link { margin-top: 3px; height: 42px; }
.chelabs-sidebar-form { margin: 0; }

.chelabs-main {
  flex: 1;
  min-width: 0;
  background: var(--cl-page);
}
.chelabs-content {
  width: 100%;
  max-width: var(--cl-content-max);
  margin: 0 auto;
  padding: var(--cl-content-pad);
}

/* ============= MOBILE TOP BAR + DRAWER TOGGLE ============= */
/* Hidden on desktop; the drawer rules at <=860px reveal it. */
.chelabs-topbar {
  display: none;
  height: var(--cl-topbar-h);
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: var(--cl-surface);
  border-bottom: 1px solid var(--cl-sidebar-line);
  position: sticky;
  top: 0;
  z-index: 15;
}
.chelabs-topbar .chelabs-brand {
  height: auto;
  padding: 0;
  margin: 0;
  border: 0;
}
.chelabs-topbar .chelabs-brand-mark { width: 26px; height: 26px; }
.chelabs-topbar .chelabs-brand-name { font-size: 18px; }
/* on desktop the drawer does not exist, so its checkbox is not in the
   tab order at all; the <=860px block below places it over the
   hamburger, where Space toggles the drawer and the focus ring shows */
.chelabs-nav-toggle {
  display: none;
  padding: 0;
  border: 0;
}
.chelabs-nav-open {
  width: 42px;
  height: 42px;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: var(--cl-r-btn);
  color: var(--cl-nav-text);
  cursor: pointer;
}
.chelabs-nav-open:hover { color: var(--cl-nav-hover); background: var(--cl-nav-hover-bg); }
.chelabs-nav-open .icon { width: 22px; height: 22px; stroke-width: 1.9; stroke-linecap: round; }
.chelabs-scrim { display: none; }

/* ============= PAGE HEADER ============= */
.chelabs-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--cl-gap);
  margin-bottom: 34px;
}
.chelabs-page-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.chelabs-page-title {
  margin: 0;
  color: var(--cl-ink);
  font-size: var(--cl-text-page-title);
  line-height: 1.12;
  letter-spacing: -.03em;
  font-weight: 760;
}
.chelabs-page-subtitle { margin: 9px 0 0; color: var(--cl-subtitle); font-size: 16px; }
.chelabs-page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; flex: 0 0 auto; }
.chelabs-page-actions form { margin: 0; }

.chelabs-breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cl-muted);
}
.chelabs-breadcrumbs a { color: var(--cl-link); }
.chelabs-breadcrumbs a:hover { color: var(--cl-brand-text-hover); }
.chelabs-breadcrumbs .sep { color: var(--cl-muted-2); }

/* ============= CONTENT COMPOSITION ============= */
.chelabs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: var(--cl-gap);
  align-items: start;
}
.chelabs-stack { display: grid; gap: var(--cl-gap); }

/* ============= AUTH SHELL ============= */
.chelabs-auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 53% 47%;
  background: var(--cl-surface);
}
.chelabs-auth-left {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 80px;
}
.chelabs-auth-box { width: min(560px, 100%); }
.chelabs-auth-logo { border: 0; margin: 0 0 54px; padding-left: 0; height: auto; }
.chelabs-auth-title {
  text-align: center;
  font-size: var(--cl-text-auth-title);
  color: var(--cl-ink);
  font-weight: 780;
  letter-spacing: -.03em;
  margin: 0;
}
.chelabs-auth-sub {
  text-align: center;
  color: var(--cl-auth-sub);
  margin: 12px 0 36px;
  font-size: 15px;
}
.chelabs-auth-form .chelabs-input {
  height: var(--cl-auth-input-h);
  border-radius: var(--cl-r-notice);
  font-size: 16px;
}
.chelabs-auth-form .chelabs-form-row { margin-bottom: 22px; }
.chelabs-auth-form .chelabs-btn {
  width: 100%;
  height: var(--cl-auth-input-h);
  border-radius: var(--cl-r-notice);
  font-size: 16px;
}
.chelabs-auth-link {
  text-align: center;
  color: var(--cl-auth-muted);
  font-weight: 500;
  font-size: 14px;
  margin: 28px 0 0;
}
.chelabs-auth-link + .chelabs-auth-link { margin-top: 14px; }
.chelabs-auth-link a { color: var(--cl-brand-text); font-weight: 650; }
.chelabs-auth-link a:hover { color: var(--cl-brand-text-hover); }
.chelabs-auth-right {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px;
  color: var(--cl-on-accent);
  background: var(--cl-auth-right);
}
.chelabs-auth-pitch { width: min(620px, 100%); text-align: center; }
.chelabs-auth-pitch h2 { font-size: 36px; line-height: 1.12; margin: 0 0 24px; letter-spacing: -.025em; }
.chelabs-auth-pitch p { color: var(--cl-on-accent-soft); font-size: 17px; line-height: 1.55; margin: 0 auto 42px; max-width: 540px; }
.chelabs-auth-benefits { display: inline-grid; gap: 22px; text-align: left; color: var(--cl-on-accent-strong); }
.chelabs-auth-benefit { display: flex; gap: 14px; align-items: center; }
.chelabs-auth-check { color: var(--cl-auth-check); font-size: 24px; font-weight: 900; }

/* ============= RESPONSIVE ============= */
@media (max-width: 1180px) {
  :root { --cl-sidebar-w: 238px; --cl-content-pad: 32px 28px 48px; }
}

@media (max-width: 860px) {
  :root { --cl-sidebar-w: 282px; --cl-content-pad: 26px 18px 40px; }
  .chelabs-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(-100%);
    visibility: hidden; /* off-screen links must not stay in the tab order */
    transition: transform var(--cl-normal), box-shadow var(--cl-normal), visibility var(--cl-normal);
    z-index: 40;
  }
  .chelabs-nav-toggle:checked ~ .chelabs-sidebar {
    transform: none;
    visibility: visible;
    box-shadow: var(--cl-shadow-float);
  }
  /* the real keyboard control: the checkbox sits over the hamburger
     glyph so Space toggles the drawer and the focus ring is visible */
  .chelabs-nav-toggle {
    display: block;
    position: fixed;
    top: 7px;
    left: 14px;
    width: 42px;
    height: 42px;
    margin: 0;
    clip: auto;
    opacity: 0.001;
    appearance: none;
    cursor: pointer;
    z-index: 16;
  }
  .chelabs-nav-toggle:focus-visible { opacity: 1; background: transparent; border-radius: var(--cl-r-btn); }
  .chelabs-nav-toggle:checked ~ .chelabs-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--cl-ink);
    opacity: .35;
    z-index: 30;
  }
  .chelabs-topbar { display: flex; }
  .chelabs-nav-open { display: inline-flex; }
  .chelabs-auth-shell { grid-template-columns: 1fr; }
  .chelabs-auth-right { display: none; }
  .chelabs-auth-left { padding: 60px 24px; }
}

@media (max-width: 640px) {
  :root { --cl-content-pad: 22px 14px 36px; --cl-card-pad: 22px; }
  .chelabs-page-header { flex-direction: column; align-items: stretch; margin-bottom: 24px; gap: 14px; }
  .chelabs-page-title { font-size: var(--cl-text-page-title-sm); }
  .chelabs-page-subtitle { font-size: 14px; }
  .chelabs-grid { grid-template-columns: 1fr; gap: 14px; }
  .chelabs-stack { gap: 14px; }
  .chelabs-auth-left { padding: 50px 18px; }
}
