/* ============================================================
   CBS: Layout & responsive tokens
   Mobile-first, fluid. See guidelines/web-layout-guide.md.
   Breakpoint vars are documentation only (custom properties
   cannot be used inside @media): copy the em values.
   ============================================================ */

:root {
  /* Breakpoints (min-width, em = 16px) */
  --bp-sm:   30em;   /* 480  large phones / phablets          */
  --bp-md:   48em;   /* 768  tablet portrait                  */
  --bp-lg:   64em;   /* 1024 tablet landscape / small laptop  */
  --bp-xl:   80em;   /* 1280 desktop                          */
  --bp-2xl:  96em;   /* 1536 large desktop                    */
  --bp-3xl: 120em;   /* 1920 FHD / QHD                        */
  --bp-uw:  160em;   /* 2560 ultrawide 21:9                   */
  --bp-suw: 215em;   /* 3440+ super-ultrawide 32:9            */

  /* Content containers */
  --container-prose:   68ch;    /* reading measure, never wider */
  --container-narrow:  48rem;   /* 768  forms, dialogs, articles */
  --container-content: 80rem;   /* 1280 default page content    */
  --container-wide:    100rem;  /* 1600 dashboards, galleries   */
  --container-max:     120rem;  /* 1920 hard cap for any layout */
  --container-stage:   150rem;  /* 2400 multi-pane apps on UW   */

  /* Fluid page frame */
  --page-margin:  clamp(1.25rem, 0.6rem + 3.2vw, 6rem);   /* 20 to 96 */
  --grid-gutter:  clamp(1rem, 0.75rem + 1.1vw, 2rem); /* @kind spacing */     /* 16 to 32 */
  --grid-columns: 4; /* @kind other */
  --section-y-fluid: clamp(3rem, 2rem + 5vw, 8rem); /* @kind spacing */       /* 48 to 128 */
  --stack-gap:    clamp(1rem, 0.8rem + 1vw, 1.5rem);

  /* Fluid type (ceilings stop growth on ultrawide) */
  --fs-fluid-display: clamp(2.75rem, 1.6rem + 4.6vw, 6rem); /* @kind other */    /* 44 to 96 */
  --fs-fluid-h1:      clamp(2rem, 1.5rem + 2.2vw, 3.5rem); /* @kind other */     /* 32 to 56 */
  --fs-fluid-h2:      clamp(1.5rem, 1.25rem + 1.1vw, 2.25rem); /* @kind other */ /* 24 to 36 */
  --fs-fluid-h3:      clamp(1.25rem, 1.15rem + 0.45vw, 1.5rem); /* @kind other *//* 20 to 24 */
  --fs-fluid-lead:    clamp(1.0625rem, 1rem + 0.35vw, 1.3125rem); /* @kind other */ /* 17 to 21 */

  /* Chrome */
  --header-h:    clamp(3.5rem, 2.8rem + 2vw, 5.25rem); /* @kind spacing */  /* 56 to 84 */
  --sidebar-w:   17.5rem;  /* 280 */
  --rail-w:      4.5rem;   /* 72 collapsed sidebar */
  --inspector-w: 22.5rem;  /* 360 right panel on wide screens */
  --tap-target:  44px;     /* minimum touch target */

  /* Safe areas (notches, home indicators) */
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);

  /* Z-index scale */
  --z-base: 0; /* @kind other */
  --z-sticky: 100; /* @kind other */
  --z-header: 200; /* @kind other */
  --z-drawer: 300; /* @kind other */
  --z-modal: 400; /* @kind other */
  --z-toast: 500; /* @kind other */
}

@media (min-width: 48em) { :root { --grid-columns: 8; /* @kind other */ } }
@media (min-width: 64em) { :root { --grid-columns: 12; /* @kind other */ } }

/* ---- Layout primitives (opt-in classes) ---- */
.cbs-container {
  width: 100%;
  max-width: calc(var(--container-content) + 2 * var(--page-margin));
  margin-inline: auto;
  padding-inline: max(var(--page-margin), var(--safe-left)) max(var(--page-margin), var(--safe-right));
  box-sizing: border-box;
}
.cbs-container--narrow { max-width: calc(var(--container-narrow) + 2 * var(--page-margin)); }
.cbs-container--wide   { max-width: calc(var(--container-wide) + 2 * var(--page-margin)); }
.cbs-container--max    { max-width: calc(var(--container-max) + 2 * var(--page-margin)); }

.cbs-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), minmax(0, 1fr));
  gap: var(--grid-gutter);
}
.cbs-auto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--cbs-min, 18rem)), 1fr));
  gap: var(--grid-gutter);
}
.cbs-prose { max-width: var(--container-prose); }
.cbs-section { padding-block: var(--section-y-fluid); }
.cbs-bleed { width: 100%; } /* full-bleed background band; put a .cbs-container inside */
.cbs-cq { container-type: inline-size; }
