/*
 * ChristianPure spacing system (owner's pick A, 12 November 2026; design-system decision D-055).
 *
 * One ladder of five gaps, named by how closely two things belong together, and six paddings, named by the
 * kind of container. A sheet never types a number: it says what the relationship is. Since stage 4 (13 Nov
 * 2026) seven roles ARE the Theme Editor's steps (theme.json spacingSizes, slugs 20 to 80): the number after
 * each var() is only the fallback for a page that prints no Theme Editor styles, and must equal theme.json.
 *
 * Loaded straight after tokens.css. The system and its rules: output/spacing-system-2026-11/SPEC.md.
 * scripts/rules/no_hand_set_spacing.py refuses a margin, padding or gap that is not one of these roles.
 */

:root {
	/* Gaps: the space BETWEEN two things. Pick by relationship, closest first. */
	--cp-gap-bound: var(--wp--preset--spacing--20, 0.25rem);    /* parts of one thing: a name and its meaning, a tile's title and its sub-line */
	--cp-gap-label: var(--wp--preset--spacing--30, 0.5rem);     /* a label and what it names: label and field, small heading and its text, field and Send */
	--cp-gap-item: var(--wp--preset--spacing--40, 1rem);        /* things of the same kind in one group: paragraphs, tiles, cards in a row */
	--cp-gap-group: var(--wp--preset--spacing--50, clamp(1.5rem, 1.314rem + 0.762vw, 2rem));      /* one group and the next: words and form, one labelled control and the next */
	--cp-gap-section: var(--wp--preset--spacing--70, clamp(3rem, 2.629rem + 1.524vw, 4rem));      /* one section of a page and the next */

	/* Insets: the padding INSIDE a container. Pick by what the container is. */
	--cp-inset-chip: 0.5rem;    /* above and below the words of a chip, a menu row, a text field */
	--cp-inset-field: 1rem;     /* left and right of the words in a text field or menu */
	--cp-inset-tile: 1rem;      /* a small tile or option */
	--cp-inset-card: 1.5rem;    /* a card */
	--cp-inset-box: var(--wp--preset--spacing--60, clamp(1.5rem, 1.129rem + 1.524vw, 2.5rem));    /* a box that holds a whole piece: the prayer card, an offer */
	--cp-inset-band: var(--wp--preset--spacing--80, clamp(3rem, 2.257rem + 3.048vw, 5rem));       /* above and below the content of a full-width band */
	--cp-gutter: clamp(1.25rem, 1.157rem + 0.381vw, 1.5rem);      /* the page's side margin */

	/* Two fixed relationships. */
	--cp-gap-row: var(--cp-gap-item);   /* above and below a line that divides rows: always the same on both sides */
	--cp-gap-check: 0.75rem;            /* a tick box or radio button and its words (owner, 12 Nov 2026) */
}

/* ---- Stack: things one under another ------------------------------------------------------------------
   The parent owns the space. Children carry no margins. A child that belongs more closely to (or further
   from) the one before it says so with --cp-follows or a cp-follows class; nothing else moves. */
.cp-stack { display: flex; flex-direction: column; gap: var(--cp-stack-gap); --cp-stack-gap: var(--cp-gap-item); }
.cp-stack--bound { --cp-stack-gap: var(--cp-gap-bound); }
.cp-stack--label { --cp-stack-gap: var(--cp-gap-label); }
.cp-stack--item { --cp-stack-gap: var(--cp-gap-item); }
.cp-stack--group { --cp-stack-gap: var(--cp-gap-group); }
.cp-stack--section { --cp-stack-gap: var(--cp-gap-section); }
:where(.cp-stack, .cp-flow) > * { --cp-follows: initial; }
:root .cp-stack > * { margin-block: calc(var(--cp-follows, var(--cp-stack-gap)) - var(--cp-stack-gap)) 0 !important; }   /* inside a stack, the stack owns the margins */
.cp-follows--bound { --cp-follows: var(--cp-gap-bound); }
.cp-follows--label { --cp-follows: var(--cp-gap-label); }
.cp-follows--item { --cp-follows: var(--cp-gap-item); }
.cp-follows--group { --cp-follows: var(--cp-gap-group); }
.cp-follows--section { --cp-follows: var(--cp-gap-section); }

/* ---- Cluster: things side by side that may wrap (buttons, chips, a count and a link) ------------------- */
.cp-cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--cp-gap-label) var(--cp-gap-item); }
.cp-cluster--label { gap: var(--cp-gap-bound) var(--cp-gap-label); }
.cp-cluster--group { gap: var(--cp-gap-item) var(--cp-gap-group); }

/* ---- Columns: cards or fields in a row, equal widths, dropping to one column when there is no room ---- */
.cp-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--cp-columns-min, 14rem)), 1fr)); gap: var(--cp-gap-item); }
.cp-columns--group { gap: var(--cp-gap-group); }

/* ---- Inset: padding by the kind of container. Equal on all four sides. --------------------------------
   A container with a decorative edge (a cornice, a sill, a mosaic strip) names the edge's height in
   --cp-edge-top / --cp-edge-bottom, and the padding starts after it, so words never touch the ornament. */
.cp-inset--tile { --cp-inset: var(--cp-inset-tile); }
.cp-inset--card { --cp-inset: var(--cp-inset-card); }
.cp-inset--box { --cp-inset: var(--cp-inset-box); }
[class*="cp-inset--"] {
	padding: calc(var(--cp-edge-top, 0px) + var(--cp-inset)) var(--cp-inset) calc(var(--cp-edge-bottom, 0px) + var(--cp-inset));
}

/* ---- Band: a full-width strip of the page ------------------------------------------------------------- */
.cp-band { padding: calc(var(--cp-edge-top, 0px) + var(--cp-inset-band)) var(--cp-gutter) calc(var(--cp-edge-bottom, 0px) + var(--cp-inset-band)); }

/* ---- Rows: a list divided by lines. The line always has the same space above and below it. ------------ */
.cp-rows { margin: 0; padding: 0; list-style: none; }
:root .cp-rows > * { margin: 0; padding-block: var(--cp-gap-row); border-block-end: 1px solid var(--cp-color-line); }
.cp-rows:not(.cp-rows--open) > :first-child { border-block-start: 1px solid var(--cp-color-line); }
.cp-rows--open > :first-child { padding-block-start: 0; }
.cp-rows--open > :last-child { padding-block-end: 0; border-block-end: 0; }

/* ---- Flow: running text (an article body), where the blocks sit side by side with no wrappers ---------
   Each block's distance from the one before it comes from what the two are:
   a new section gets the section gap; a sub-heading gets the group gap above and sits a label gap from its
   own text; a box set into the text gets the group gap on both sides; everything else is one item gap. */
:root .cp-flow > * { margin-block: 0 !important; }
:root .cp-flow > * + * { margin-block-start: var(--cp-follows, var(--cp-gap-item)) !important; }   /* in running text, the flow owns the margins */
.cp-flow > :where(h3, h4, h5, h6, .cp-subhead),
.cp-flow > :where(figure, blockquote, table, .wp-block-table, .wp-block-image, .wp-block-quote, .wp-block-buttons, .cp-series-note),
.cp-flow > :where(figure, blockquote, table, .wp-block-table, .wp-block-image, .wp-block-quote, .wp-block-buttons, .cp-series-note) + * { --cp-follows: var(--cp-gap-group); }
/* These rules use :where(), so they all weigh the same and the later one wins: what a block follows
   (a heading) outranks what the block is, so a prayer unit straight after a heading stays close to it.
   A new section: a main heading (with or without its picture), and any whole piece set into the article:
   a prayer or verse unit, an offer, a course box, a tool (prayer picker, verse finder, name card, church
   answers) or an interactive entry. An advert is not a piece of the article and stays an item. */
.cp-flow > :where(h2, .h2-image-group, [class*="cp-"][class*="-unit"]:not(.cp-ad-unit), [class*="cp-"][class*="-entry"], .cp-offer, .cp-course-box, .cp-pick, .cp-verse, .cp-name, .cp-ans, .cp-ce, .cp-series-note--end),
.cp-flow > :where([class*="cp-"][class*="-unit"]:not(.cp-ad-unit), [class*="cp-"][class*="-entry"], .cp-offer, .cp-course-box, .cp-pick, .cp-verse, .cp-name, .cp-ans, .cp-ce) + * { --cp-follows: var(--cp-gap-section); }
.cp-flow > :where(h3, h4, h5, h6, .cp-subhead) + * { --cp-follows: var(--cp-gap-label); }
.cp-flow > :where(h2, .h2-image-group) + * { --cp-follows: var(--cp-gap-item); }
/* A boxed piece straight after a section heading is a box set into the text, not a line of it: at an item
   gap the heading's band and the box read as one slab. */
.cp-flow > :where(h2, .h2-image-group) + :where([class*="cp-"][class*="-unit"]:not(.cp-ad-unit), [class*="cp-"][class*="-entry"], .cp-offer, .cp-course-box, .cp-pick, .cp-verse, .cp-name, .cp-ans, .cp-ce, figure, blockquote, table, .wp-block-table) { --cp-follows: var(--cp-gap-group); }
/* The parent theme pads the top of every heading in page content by 20px. In a flow the space above a
   heading is the flow's, so that padding goes (the Theme Editor setting itself goes at stage 4). */
:root .cp-flow > :is(h1, h2, h3, h4, h5, h6) { padding-block-start: 0; }
