/* ==========================================================================
   FERNGLAS — LAYOUT PRIMITIVES. A handful of composable classes that cover
   the layout shapes almost every screen needs, so a new screen composes
   these instead of hand-writing another one-off flex/grid block.

   Gap size defaults to --space-4 (16px); override per-instance with
   [data-gap="1".."10"] (matches the --space-* scale) or [data-gap="0"].
   ========================================================================== */

/* -- Stack: vertical flow, consistent gap -- */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* -- Cluster: horizontal flow that wraps, consistent gap -- */
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

/* -- Grid: responsive card/tile grid, no breakpoints needed -- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--grid-min, 200px), 1fr));
  gap: var(--space-4);
}

/* -- Container: centers content, caps line length. Default stays the
   --container-max override point (backward compatible); [data-width] picks
   a named step off tokens.css's container scale instead. -- */
.container {
  max-width: var(--container-max, 960px);
  width: 100%;
  margin-inline: auto;
}
.container[data-width='sm'] { max-width: var(--container-sm); }
.container[data-width='md'] { max-width: var(--container-md); }
.container[data-width='lg'] { max-width: var(--container-lg); }
.container[data-width='xl'] { max-width: var(--container-xl); }

/* -- App shell: header/sidebar/main grid composition for a persistent-nav
   app — see foundations/app-shell.html. Below --bp-md (copy the literal
   value per the project's breakpoint policy, same as every other component
   that needs one) it collapses to a single stacked column; a real app
   typically swaps SidebarNav for a Drawer or a bottom Nav at that width
   rather than leaning on this fallback alone. -- */
.app-shell {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: 'header header' 'sidebar main';
  min-height: 100%;
}
.app-shell-header {
  grid-area: header;
}
.app-shell-sidebar {
  grid-area: sidebar;
  overflow-y: auto;
}
.app-shell-main {
  grid-area: main;
  min-width: 0;
  overflow-y: auto;
}
@media (max-width: 767px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: 'header' 'main' 'sidebar';
  }
}

/* -- Gap overrides, shared by stack/cluster/grid. No CSS nesting used here
   on purpose — this file must parse in any browser a zero-build project
   targets, not just ones with native nesting support. -- */
.stack[data-gap='0'], .cluster[data-gap='0'], .grid[data-gap='0'] { gap: 0; }
.stack[data-gap='1'], .cluster[data-gap='1'], .grid[data-gap='1'] { gap: var(--space-1); }
.stack[data-gap='2'], .cluster[data-gap='2'], .grid[data-gap='2'] { gap: var(--space-2); }
.stack[data-gap='3'], .cluster[data-gap='3'], .grid[data-gap='3'] { gap: var(--space-3); }
.stack[data-gap='4'], .cluster[data-gap='4'], .grid[data-gap='4'] { gap: var(--space-4); }
.stack[data-gap='5'], .cluster[data-gap='5'], .grid[data-gap='5'] { gap: var(--space-5); }
.stack[data-gap='6'], .cluster[data-gap='6'], .grid[data-gap='6'] { gap: var(--space-6); }
.stack[data-gap='7'], .cluster[data-gap='7'], .grid[data-gap='7'] { gap: var(--space-7); }
.stack[data-gap='8'], .cluster[data-gap='8'], .grid[data-gap='8'] { gap: var(--space-8); }
.stack[data-gap='9'], .cluster[data-gap='9'], .grid[data-gap='9'] { gap: var(--space-9); }
.stack[data-gap='10'], .cluster[data-gap='10'], .grid[data-gap='10'] { gap: var(--space-10); }

/* -- Divider: a rule between sections. Horizontal by default; add
   [data-orientation="vertical"] inside a flex row (it stretches to the
   row's cross-size via align-self, so no explicit height is needed). -- */
.divider {
  border: none;
  border-block-start: 1px solid var(--border);
  margin: 0;
}
.divider[data-orientation='vertical'] {
  border-block-start: none;
  border-inline-start: 1px solid var(--border);
  align-self: stretch;
  width: 0;
}

/* -- Divider with centered label ("or", a date, a section name) — two
   flex-line pseudo-elements flank whatever text content is passed in. -- */
.divider-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}
.divider-label::before,
.divider-label::after {
  content: '';
  flex: 1;
  border-block-start: 1px solid var(--border);
}
