/* Blueline Atelier — blueprint grid (website revamp, draft)
 * Spec: studio-redesign.md, "The blueprint grid". Values come from tokens.json
 * (grid-*, bp-*, pd-*, sp-*). Layout only: no colour, type or decoration.
 */

/* 4K tiers scale every rem token */
/* Root size = screen tier × the visitor's text-size setting (site settings) */
html { font-size: calc(var(--root-scale, 100%) * var(--text-scale, 1)); }
@media (min-width: 2560px) { html { --root-scale: 125%; } } /* grid-root-xl */
@media (min-width: 3840px) { html { --root-scale: 150%; } } /* grid-root-2xl */

/* --- Sheet ---------------------------------------------------------------
 * A centred column with rails (frame lines) on both sides: full width below md
 * (padding = margin), 100rem on desktop, 72rem on large displays (which also
 * scale the root). Side padding stays at the margin from 320px up to 1600px.
 */
.bp-page { container: bp-page / inline-size; }
.bp-sheet {
  --bp-cols: 4;                 /* grid-cols-xs */
  --bp-margin: 0.5rem;          /* grid-margin-xs = sp-sm: 8px on phones */
  /* section anatomy (see layout-patterns.css) */
  --inset-cell: 1.25rem;        /* inset-cell-xs = pd-lg */
  --inset-section: 1.25rem;     /* inset-section-xs = pd-lg */
  --head-pt: 3rem;              /* head-top-xs = sp-5xl */
  --head-pb: 2rem;              /* head-bottom-xs = sp-3xl */
  --head-gap: 0.75rem;          /* head-gap-xs = sp-md */
  --banner-py: 5rem;            /* banner-pad-xs = sp-7xl */
  container: bp-sheet / inline-size;
  max-width: none;              /* full width below md: the side padding is the margin */
  margin-inline: auto;
  padding-inline: var(--bp-margin);
}
@container bp-page (min-width: 600px) {
  .bp-sheet {
    --bp-cols: 8;
    --inset-cell: 1.5rem;                          /* pd-xl */
    --inset-section: 3rem;                         /* sp-5xl */
    --head-pt: 3.75rem; --head-pb: 2.5rem; --head-gap: 1rem;  /* sp-6xl, sp-4xl, sp-lg */
    --banner-py: 7rem;                             /* sp-8xl */
  }
}
@container bp-page (min-width: 1024px) {
  /* desktop: a wide cap keeps the side padding small (grid-sheet-max-desktop) */
  .bp-sheet { --bp-cols: 12; max-width: 100rem; }
}
/* Sheet margin = the side padding, keyed to the screen width (like the root scaling)
 * so a 1024 or 1440 screen gets its margin even with a desktop scrollbar. */
@media (min-width: 600px)  { .bp-sheet { --bp-margin: 1.25rem; } }  /* grid-margin-sm = pd-lg */
@media (min-width: 1024px) { .bp-sheet { --bp-margin: 2rem; } }     /* grid-margin-md = sp-3xl */
@media (min-width: 1440px) { .bp-sheet { --bp-margin: 3rem; } }     /* grid-margin-lg = sp-5xl */
/* large displays (with the root scaling): reading-width cap, margin as before */
@media (min-width: 2560px) { .bp-sheet { --bp-margin: 1.5rem; max-width: 72rem; } }  /* grid-margin-xl, grid-sheet-max */

/* --- Grid ----------------------------------------------------------------- */
.bp-grid {
  --bp-col: calc(100cqi / var(--bp-cols));   /* cqi = the sheet's content box */
  --bp-mod: calc(var(--bp-col) / 4);         /* grid-subdivisions */
  display: grid;
  /* minmax(0, 1fr): wide content (tables, long words) can never stretch a column */
  grid-template-columns: repeat(var(--bp-cols), minmax(0, 1fr));
}
/* stack: holds regions; rows size to content (always whole modules) */
.stack  { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; }
/* region: a landmark or section; rows are modules */
.region { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; grid-auto-rows: var(--bp-mod); }
/* sub: a cell whose children keep the columns */
.sub { display: grid; grid-template-columns: subgrid; }
.bp-snap > .bp-content { align-self: start; }
.cell { min-width: 0; }
.bp-content { padding: var(--inset-cell); }
/* A subgrid takes no padding (it would push items off the column lines);
   its children carry the inset instead. */
.sub > .bp-content.sub { grid-column: 1 / -1; padding: 0; }

/* --- Named spans ---------------------------------------------------------- */
.span-full           { grid-column: span var(--bp-cols); }
.span-three-quarters { grid-column: span var(--bp-cols); }
.span-two-thirds     { grid-column: span min(var(--bp-cols), 8); }
.span-center         { grid-column: 1 / -1; }
.span-half, .span-third { grid-column: span 4; }
.span-quarter, .span-sixth { grid-column: span 2; }
@container bp-page (min-width: 600px)  { .span-quarter { grid-column: span 4; } }
@container bp-page (min-width: 1024px) {
  .span-three-quarters { grid-column: span 9; }
  .span-center { grid-column: 3 / span 8; }
  .span-half { grid-column: span 6; }
  .span-quarter { grid-column: span 3; }
}
