/* ============================================================
   layout.css — layout objects
   ============================================================
   Structural layout primitives and the section system: classes
   that arrange and position content but carry no visual skin.

   Contents
     1. Site width — narrow override
     2. Stack — vertical content rhythm
     3. Section system (surface, colour family, size, divider)
     4. Grid — fluid auto-fit deck (content-agnostic)
     5. Section header — narrow heading + intro block
     7. Footer columns — balanced 3-column footer
     7. Sticky footer
     9. Anchor scrolling — land below the sticky header

   Last updated: 2026-10-12 (auto-stamped by the pre-commit hook)
   ============================================================ */


/* ------------------------------------------------------------
   1. Site width — narrow override
   ------------------------------------------------------------
   Base content width + centring + horizontal gutter live on the
   Container Theme Style (every container gets them automatically).
   This file only holds the narrow override for text-only sections.
   ------------------------------------------------------------ */

/* Scoped to .brxe-container so it beats the Container Theme Style width. */
.brxe-container.site-width--narrow {
    max-width: var(--narrow-site-width);
}


/* ------------------------------------------------------------
   2. Stack — vertical content rhythm
   ------------------------------------------------------------
   A layout primitive: stacks children in a column with an even gap.
   Default gap --space-m; override the Row gap per element in Bricks.

   GOTCHA: don't get content rhythm by putting a gap on the global
   Block/Div Theme Style — it scaffolds cards and everything else, so
   the gap leaks everywhere. Use `.stack` (or a per-instance gap).
   ------------------------------------------------------------ */
.stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-m);
}


/* ------------------------------------------------------------
   3. Section system (surface, size, divider)
   ------------------------------------------------------------
   Composable section modifiers, organised by AXIS: surface, size,
   divider. Apply at most ONE per axis, combine freely across axes.
   The Hero component's own axes (overlay, content position, height,
   stacked) live in components/hero.css. Full catalogue + usage:
   DESIGN-SYSTEM.md §9.8. Every content/footer section gets an
   automatic top divider — opt out per section with .section--seamless.
   ------------------------------------------------------------ */

/* --- Surface: light --- */
/* Base surface — for when the page background isn't the base surface. */
.section--base {
    background-color: var(--surface-base);
}

/* Only needed on templates that override the site background. */
.section--subtle {
    background-color: var(--surface-subtle);
}

/* Warm beige band — stands out from both the grey page background
   and white .section--base neighbours. */
.section--soft {
    background-color: var(--surface-soft);
}

/* --- Surface: dark contexts ---
   The colour remap for these classes is GENERATED into dark-sections.css
   from the Bricks palette (so a dark island matches page Dark Mode). The
   boosted elevation + dark gradient/divider live in tokens.css. Here we
   only set the background + base text colour. */
.section--dark,
.section--dark-neutral {
    color: var(--text-on-dark);
}

/* Dark brand-colour section. */
.section--dark {
    background-color: var(--surface-dark);
}

/* Neutral near-black section. */
.section--dark-neutral {
    background-color: var(--surface-dark-neutral);
}

/* --- Colour family: .colour-accent / .colour-neutral ---
   The one place that points the primary WORKING names at another
   family (farvefamilier-plan.md §2a): everything inside — a Highlight
   Heading, links in the text, .cta--* links, buttons, the badge — speaks
   that family. Type the class on a section (the default), or on a
   container or block when one section must hold two families. Nothing
   typed = primary; there is no .colour-primary. The hero's Colour style
   classes share the same rules (the dropdown writes section--hero-*), so
   there is ONE copy; headings.css §2 has the element-level twin
   (.headline--*), which wins over this because headings.css loads later
   — an element's own choice beats its section's (plan §2c).
   Set one level down, on the children: the dark-section remap
   (dark-sections.css) writes the primary tokens ON the section, and a
   value set on the element itself beats anything inherited. Links keep
   their colour on hover — the underline carries it. */
:is(.section--hero-accent, .colour-accent) > * {
    --action-primary: var(--action-accent);
    --action-primary-hover: var(--action-accent-hover);
    --action-primary-text: var(--action-accent-text);
    --text-highlight-primary: var(--text-highlight-accent);
    --list-marker-primary: var(--list-marker-accent);
    --border-highlight-primary: var(--border-highlight-accent);
    --surface-inverse-primary: var(--surface-inverse-accent);
    --text-inverse-primary: var(--text-inverse-accent);
    --text-link: var(--text-highlight-accent);
    --text-link-hover: var(--text-highlight-accent);
}

/* Neutral: greys only. No colour to highlight with, so the whole title
   goes --text-strong and the highlighted word is marked by weight (the
   .font-highlight knob); links too are --text-strong. The outline
   button's hover border stays --border-strong — the wash and the lift
   carry the hover. Decided on a trial page, 14-09-2026. */
:is(.section--hero-neutral, .colour-neutral) > * {
    --action-primary: var(--action-neutral);
    --action-primary-hover: var(--action-neutral-hover);
    --action-primary-text: var(--action-neutral-text);
    --text-highlight-primary: var(--text-strong);
    --list-marker-primary: var(--text-strong);
    --border-highlight-primary: var(--border-strong);
    --surface-inverse-primary: var(--surface-inverse-neutral);
    --text-inverse-primary: var(--text-inverse-neutral);
    --text-heading: var(--text-strong);
    --font-highlight-weight: 700;
    --text-link: var(--text-strong);
    --text-link-hover: var(--text-strong);
}

/* --- Size --- */
/* Scoped to .brxe-section to out-specify the Section Theme Style's base
   padding (a Theme Style is unlayered and loads after the child theme, so
   it wins a specificity tie — beat it with specificity, not !important). */
.brxe-section.section--spacious {
    padding-block: var(--space-2xl);
}

.brxe-section.section--slim {
    padding-block: var(--space-xs);
}

/* --- Divider ---
   A hairline at a section's top/bottom edge; colour --border-divider
   auto-contrasts (tokens.css §3). Solid or gradient (fades at the ends).
   The gradient uses border-image, NOT a pseudo-element, so it never
   competes with a component's own ::before/::after. GOTCHA: border-image
   styles ALL borders at once — don't mix a solid + gradient on one
   section. */

/* Solid hairline */
.section--divider-t  { border-block-start: var(--border-width-thin) solid var(--border-divider); }
.section--divider-b  { border-block-end:   var(--border-width-thin) solid var(--border-divider); }
.section--divider-tb { border-block:       var(--border-width-thin) solid var(--border-divider); }

/* Gradient hairline — fades out at both ends. The transparent border
   colour is replaced by the gradient; width still comes from the
   border, so only the sides with a width get drawn. */
.section--divider-gradient-t {
    border-block-start: var(--border-width-thin) solid transparent;
    border-image: linear-gradient(to right, transparent, var(--border-divider), transparent) 1;
}
.section--divider-gradient-b {
    border-block-end: var(--border-width-thin) solid transparent;
    border-image: linear-gradient(to right, transparent, var(--border-divider), transparent) 1;
}
.section--divider-gradient-tb {
    border-block: var(--border-width-thin) solid transparent;
    border-image: linear-gradient(to right, transparent, var(--border-divider), transparent) 1;
}

/* Universal divider — EVERY content/footer section automatically gets
   a tonal gradient hairline on its top edge (--border-divider derives
   from the section's own surface, tokens.css §3). The header is
   excluded; opt out with .section--seamless. Never add manual
   top-divider classes — one line per seam. */
:where(#brx-content, #brx-footer) .brxe-section:where(:not(.section--seamless)) {
    border-block-start: var(--border-width-thin) solid transparent;
    border-image: linear-gradient(to right, transparent, var(--border-divider), transparent) 1;
}

/* .section--seamless also works on a WRAPPER: put it on a template's
   Post Content element and the FIRST section inside loses its auto
   divider on every page using that template — e.g. no line under the
   breadcrumb bar. Set once per template. (This also out-specifies a
   manual divider class on that section — seamless wins there.) */
.section--seamless > .brxe-section:first-child {
    border-block-start: none;
    border-image: none;
}

/* Vertical gradient hairline — faded divider on the LEFT/RIGHT edge. On
   footer columns / cards (not sections), so no `.section--` prefix.
   GOTCHA: border-image owns ALL borders — don't add another border (e.g.
   a .card border) on the same element. */
.divider-gradient-l {
    border-inline-start: var(--border-width-thin) solid transparent;
    border-image: linear-gradient(to bottom, transparent, var(--border-divider), transparent) 1;
}
.divider-gradient-r {
    border-inline-end: var(--border-width-thin) solid transparent;
    border-image: linear-gradient(to bottom, transparent, var(--border-divider), transparent) 1;
}
.divider-gradient-lr {
    border-inline: var(--border-width-thin) solid transparent;
    border-image: linear-gradient(to bottom, transparent, var(--border-divider), transparent) 1;
}

/* Faded hairline BETWEEN stacked list items. Composable add-on on the
   <ul>, e.g. `class="list--check divider-gradient-rows"`. Painted with
   ::after (the markers use ::before); items are already relative via the
   list base in components/list.css. */
:is(.list--bullet, .list--check).divider-gradient-rows {
    gap: var(--space-m);           /* more air so the line breathes */
}
:is(.list--bullet, .list--check).divider-gradient-rows > li:not(:last-child)::after {
    content: "";
    position: absolute;
    inset-inline: 0;                       /* span the full list width */
    bottom: calc(var(--space-m) / -2);     /* centre the line in the gap below */
    block-size: var(--border-width-thin);
    background-image: linear-gradient(to right, transparent, var(--border-divider), transparent);
}


/* ------------------------------------------------------------
   4. Grid — fluid auto-fit deck (content-agnostic)
   ------------------------------------------------------------
   Fluid auto-fit grid via --grid-fluid (no column-count breakpoints),
   independent of what the items are — cards, image figures, anything.
   The number is
   the MOST columns the deck gets: each variant caps the count at N and
   shares the 16rem column floor (--col-min), so .grid--3 holds three
   columns exactly as long as .grid--4 does, then two, then one — the
   whole family reflows the same way (Katrine, 19-09-2026; before, each
   variant raised its own floor and dropped a column earlier than its
   name suggested). The cap is the max() in the formula: a column is at
   least the floor, and at least an N-th of the width. Variants are
   standalone: one .grid--N per element, never combined.
   ------------------------------------------------------------ */
:is(.grid--4, .grid--3, .grid--2, .grid--6) {
    display: grid;
    grid-template-columns: var(--grid-fluid);
    gap: var(--space-m);
}

/* At most three. The template formula must be written out per variant —
   var(--grid-fluid) resolves its inner --col-min at :root, where the
   variable is DEFINED, so a local --col-min override never reaches it
   (CSS custom-property substitution rule). The max() caps the count:
   a column is never narrower than an N-th of the width, so auto-fit
   cannot fit more than N. The gap term must match the grid's gap. */
.grid--3 {
    --col-min: 16rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, max(var(--col-min), calc((100% - 2 * var(--space-m)) / 3))), 1fr));
}

/* At most two — two wide items side by side, one when even two floors
   no longer fit. */
.grid--2 {
    --col-min: 16rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, max(var(--col-min), calc((100% - 1 * var(--space-m)) / 2))), 1fr));
}

/* At most six, with a lower floor — small repeated items such as the
   colour swatches or a logo wall. */
.grid--6 {
    --col-min: 11rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, max(var(--col-min), calc((100% - 5 * var(--space-m)) / 6))), 1fr));
}

/* Equal-height cards: block-size:100% fills the grid track, so every
   card in a row matches the tallest. The second selector covers looped
   component cards: the query loop lives on a `.display-contents`
   wrapper Div (a component instance can't loop itself), and
   display:contents removes the wrapper from LAYOUT but not from the
   DOM — so the direct-child selector alone would miss those cards. */
:is(.grid--4, .grid--3, .grid--2, .grid--6) > :is(.card, .card--cover),
:is(.grid--4, .grid--3, .grid--2, .grid--6) > .display-contents > :is(.card, .card--cover) {
    block-size: 100%;
}


/* ------------------------------------------------------------
   5. Split — two parts of a section side by side
   ------------------------------------------------------------
   Two columns with a FIXED ratio, named after it: .split--50-50 and
   .split--60-40. Where .grid--N is a row of equal, repeating items
   (cards, image figures), a split divides one section into two parts
   of content. Standalone variants, put on a Container. Both stack to
   one column when their SECTION is narrower than 54rem (a container
   query on the section, not a viewport query). Order is set in the
   builder, not here.
   .brxe-container prefix: the Container Theme Style sets a gap on
   .brxe-container that would otherwise win (same specificity, loaded
   later) and silently shrink --split-gap.
   ------------------------------------------------------------ */
.brxe-container.split--50-50 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: var(--split-gap);
}
.brxe-container.split--60-40 {
    display: grid;
    /* 3fr/2fr: the text column lands at roughly 70 characters per line at
       full site width — in two-column sections the COLUMN owns the reading
       measure (single-column sections use .site-width--narrow). */
    grid-template-columns: var(--split-60-40);
    align-items: start;
    gap: var(--split-gap);
}

/* Images in a split fill their column and keep the house radius. */
:is(.split--50-50, .split--60-40) img {
    inline-size: 100%;
    block-size: auto;
}
.split--50-50 img {
    border-radius: var(--radius-3);
}

/* The section around a split is the query container. */
.brxe-section:has(> :is(.split--50-50, .split--60-40)) {
    container: split / inline-size;
}
@container split (inline-size < 54rem) {
    .brxe-container:is(.split--50-50, .split--60-40) {
        /* minmax(0, …) lets the column shrink below its widest content;
           plain 1fr grew past the container at 320 px (WCAG 1.4.10). */
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Split divider — a faded hairline on the start edge of ONE column, with
   the same space again inside it, so the line sits in the middle of the
   gap. Put it on the column that follows the line (the panel). Same
   technique as .divider-gradient-l: a transparent border painted with a
   border-image gradient. Stacked, it turns horizontal on the panel's top
   edge, with the same gap above and below it. */
.split-divider {
    border-inline-start: var(--border-width-thin) solid transparent;
    border-image: linear-gradient(to bottom, transparent, var(--border-divider), transparent) 1;
    padding-inline-start: var(--split-gap);
}
@container split (inline-size < 54rem) {
    .split-divider {
        border-inline-start: 0;
        border-block-start: var(--border-width-thin) solid transparent;
        border-image: linear-gradient(to right, transparent, var(--border-divider), transparent) 1;
        padding-inline-start: 0;
        padding-block-start: var(--split-gap);
    }
}


/* ------------------------------------------------------------
   6. Section header — narrow heading + intro block
   ------------------------------------------------------------
   For a narrow heading+intro block while the rest of the section keeps
   full width. Holds .section-heading (centred) + .section-intro (left).
   Structural only: caps the measure, centres itself, stacks the parts.
   Sets NO text-align — each part owns its alignment.
   ------------------------------------------------------------ */
/* Scoped to .brxe-block so margin-inline:auto beats the Block Theme
   Style margin (same trick as .section--spacious). Add only
   `section-header` in Bricks — .brxe-block is automatic. */
.brxe-block.section-header {
    display: flex;
    flex-direction: column;
    gap: var(--space-s);

    max-inline-size: var(--narrow-site-width);
    margin-inline: auto;
}


/* ------------------------------------------------------------
   7. Footer columns — balanced 3-column footer
   ------------------------------------------------------------
   `.footer-columns` on the Container holding the three footer columns
   (nav · brand · contact). A fixed 3 → 1 grid, NOT an auto-fit one —
   the three blocks are unequal, so auto-fit would give an awkward
   2-up-1-down and the dividers no clean on/off point.

   Wide: brand centred in the middle (auto) track, nav/contact fill the
   side tracks so the vertical dividers frame the brand. Stacked: one
   centred column, dividers off. Scoped to .brxe-container to beat
   Bricks' element defaults. */
.brxe-container.footer-columns {
    display: grid;
    /* The two side columns are always equal, and never narrower than the
       wider side's content: the contact block (14.5rem — its 225 px measured
       06-09-2026, plus a little slack) plus the space-m of air to its
       divider. CSS cannot read one column's width into another, so the
       content part is a figure, not a formula — if the contact text ever
       outgrows it, the address wraps instead of crossing the divider. The
       brand column takes the rest and wraps first; below 57rem it can no
       longer hold the logo with space-m to each divider, and the footer
       stacks. */
    --footer-side-min: calc(14.5rem + var(--space-m));
    grid-template-columns: minmax(var(--footer-side-min), 1fr) auto minmax(var(--footer-side-min), 1fr);
    gap: var(--space-m);
    align-items: stretch;   /* equal-height columns → equal-height dividers */
}
/* Nav: centred vertically; space-m of air before its divider. */
.footer-columns > :nth-child(1) { justify-content: center; padding-inline-end: var(--space-m); }
/* Brand: centred in the middle track. */
.footer-columns > :nth-child(2) { justify-self: center; text-align: center; }
/* Contact: space-m of air after its divider; .contact-list centres its group. */
.footer-columns > :nth-child(3) { padding-inline-start: var(--space-m); }

/* The footer section is the query container: the columns ask the section's
   own width, not the viewport's (responsive ladder step 2). */
.brxe-section:has(> .footer-columns) {
    container: footer / inline-size;
}

/* STACKED — one centred column. */
@container footer (inline-size < 57rem) {
    .brxe-container.footer-columns {
        grid-template-columns: 1fr;
        row-gap: var(--space-l);
    }

    /* Reorder (CSS only): brand → contact → nav. */
    .footer-columns > :nth-child(2) { order: 1; }   /* brand */
    .footer-columns > :nth-child(3) { order: 2; }   /* contact */
    .footer-columns > :nth-child(1) { order: 3; }   /* nav */

    .footer-nav .bricks-nav-menu { align-items: center; }

    /* Swap the vertical framing dividers for a horizontal one BETWEEN the
       stacked blocks (top border on contact + nav; brand is first, none).
       padding matches the row gap so the line sits midway. */
    .footer-columns > :nth-child(3),
    .footer-columns > :nth-child(1) {
        border-inline: 0;
        padding-inline: 0;
        border-block-start: var(--border-width-thin) solid transparent;
        border-image: linear-gradient(to right, transparent, var(--border-divider), transparent) 1;
        padding-block-start: var(--space-l);
    }
}


/* ------------------------------------------------------------
   8. Sticky footer (body-level)
   ------------------------------------------------------------
   Body is a flex column at least as tall as the viewport, so
   #brx-content grows and the footer sits at the bottom on short pages.

   `dvh` follows the mobile browser's collapsing address bar; `vh` is the
   fallback for anything that doesn't know it. Order matters — the last
   value a browser understands is the one it uses.

   Admin-bar fix: WordPress adds `.admin-bar` to <body> when its toolbar
   shows (logged in). The toolbar (32px desktop, 46px ≤782px) makes a
   full-viewport body overflow and gap the footer, so subtract it there. */
body {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}
/* The content area grows to fill leftover space — this is the actual
   sticky mechanism; the footer needs no margin-top:auto. */
#brx-content {
    flex: 1 0 auto;
}
body.admin-bar {
    min-height: calc(100vh - 32px);
    min-height: calc(100dvh - 32px);
}
@media screen and (width <= 782px) {
    body.admin-bar {
        min-height: calc(100vh - 46px);
        min-height: calc(100dvh - 46px);
    }
}


/* ------------------------------------------------------------
   9. Anchor scrolling — land below the sticky header
   ------------------------------------------------------------
   scroll-padding reserves room for the sticky header (its height
   token, tokens.css §5) plus breathing space, so in-page anchor
   targets (#id links) aren't hidden behind it. Smooth scroll only
   when the user hasn't asked for reduced motion.
   ------------------------------------------------------------ */
html {
    scroll-padding-block-start: calc(var(--header-height) + var(--space-m));
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}
