/**
 * @file
 * Layout - the page's bands and its content column - task T-610.
 *
 * SMACSS `layout`: this file positions the three regions the theme declares and
 * does nothing else. It holds no colour literal, like every file in this theme
 * except the token file, and the invariant tests/bin/no-colour-literals is what
 * makes that a fact rather than an intention.
 *
 * ONLY DECLARED PAIRS ARE COMBINED, and this is where that rule bites hardest.
 * The token file declares which foreground may appear on which background, and
 * every one of those pairs has a computed contrast ratio behind it. Inventing a
 * combination by eye is precisely what the token file exists to stop.
 *
 * THE HEADER IS A LIGHT BAND AND THE FOOTER IS THE DARK ONE. Both used to sit
 * on the inverse surface, and the result was a tall near-black slab at the top
 * of every page with a vertical list of underlined links in it. Two things
 * changed together. First, the mark is a portico that has to be READ, and it is
 * drawn with `currentColor` so that it takes the colour of the text around it;
 * it is legible on the light band and it is the reason the branding sits there.
 * Second, the ONLY foreground the token file declares against the inverse
 * surface is the inverse text - so every link in a dark band has to be plain
 * white and underlined, which is exactly the debug-dump look. On the light band
 * the ordinary link, hover, visited and accent tokens are all available and all
 * checked, so the navigation can be designed instead of merely tolerated.
 *
 * The footer keeps the dark band, and there it earns its place: it closes the
 * page, it holds few links, and white-on-navy at 14.29:1 is the most legible
 * pair in the file.
 *
 * NO GRID FRAMEWORK, NO UTILITY CLASSES. Flex, a max-width and a wrap. A page
 * that shows tables of contracts needs a column and a footer, not a layout
 * system, and D-014 rider (f) forbids a generic CSS framework anyway.
 */

.agora-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.agora-page__container {
  width: 100%;
  max-width: var(--agora-container-width);
  margin-inline: auto;
  padding-inline: var(--agora-space-m);
}

/**
 * The banner band.
 *
 * On the page surface, closed by a rule in the brand accent. The accent is
 * checked against this surface at 3.41:1, which clears SC 1.4.11 - it is the
 * one place in the theme where the brand colour is unmistakable at a glance and
 * it costs nothing in legibility, because nothing is written in it.
 */
.agora-page__header {
  border-block-end: var(--agora-rule-accent) solid var(--agora-color-accent);
  background-color: var(--agora-color-surface);
}

/**
 * The contentinfo band.
 *
 * The inverse surface, and therefore the inverse text colour throughout -
 * including links, which are white and underlined here rather than link-blue,
 * because the link tokens carry no computed pair against this background and
 * inventing one by eye is what the token file exists to stop. The focus ring
 * switches to the inverse ring for the same reason: that is the pair that was
 * computed at the 3:1 non-text threshold.
 */
.agora-page__footer {
  padding-block: var(--agora-space-xl) var(--agora-space-l);
  color: var(--agora-color-text-inverse);
  border-block-start: var(--agora-rule-accent) solid var(--agora-color-accent);
  background-color: var(--agora-color-surface-inverse);
}

/**
 * THE SELECTOR IS THE REGION AND NOT THE CONTAINER, and that distinction cost a
 * render to find. The container has exactly one child: the region wrapper. Flex
 * or grid properties on the container therefore lay out ONE item, and the
 * blocks - its grandchildren - stack as they always did.
 * templates/region.html.twig exists to give that wrapper a name so these rules
 * can reach it. The banner below is the one place the container itself IS the
 * row, because it holds two children rather than one: the region, and the
 * search field the page template prints beside it.
 */
/**
 * The banner as ONE row: the mark and the name, the navigation, and the search
 * field pushed to the inline end.
 *
 * ⚠️ THE PARAGRAPH IN css/components.css HEADED "The banner band's two rows"
 * DESCRIBES THE LAYOUT THIS REPLACES AND HAS DELIBERATELY NOT BEEN EDITED. Its
 * argument - that a navigation of real register names squeezed beside a mark
 * and a name is what forces the abbreviations nobody can search for - still
 * stands and is the reason the row below is built to WRAP rather than to
 * compress. Whether one row survives contact with real labels is a
 * measurement, and the measurement belongs in the task report rather than in a
 * comment written by the person who changed the layout.
 *
 * THE ROW HAS TWO ITEMS, NOT THREE, AND THAT IS WHY IT DEGRADES WELL. The
 * outer row holds the header REGION and the search field. The region is itself
 * a row holding the mark-and-name and the navigation. So there are two
 * independent wrap points rather than one: the search drops to its own line
 * first, and only then does the navigation drop below the name. A single flat
 * row of three items would take all three to their own lines at once.
 *
 * NOTHING IS COMPRESSED TO MAKE IT FIT. No label is shortened, no font size
 * steps down at a breakpoint, and there is no breakpoint. If the labels a
 * council really uses do not fit, the row wraps and the banner is two rows
 * again - which is the honest outcome and the one the older argument predicts.
 */
/*
 * THE BAND'S OWN HEIGHT IS THIS ONE DECLARATION, and it came down a step on the
 * spacing scale rather than to a number somebody liked. The row's height is its
 * tallest item plus this padding twice, and the tallest item is the search
 * control at the target-size floor - 44px, which WCAG 2.2 SC 2.5.8 puts a floor
 * under and this theme will not go below. So the padding was the only part of
 * the banner free to move: 8px on each side gives a 60px row, closed by the 4px
 * accent rule. Nothing was compressed and no label was shortened.
 *
 * FOR THE RECORD, BECAUSE THE NUMBER IS SMALLER THAN THE APPROVED DESIGN'S AND
 * THAT IS DELIBERATE. The design's banner scales to 73px at a 1440 viewport.
 * This one measures 60 plus the rule, and the difference is 9px of air that
 * costs nothing: the row holds the same mark, the same name, the same
 * navigation and the same field at the same sizes. Growing the padding to match
 * would buy empty band. The number is recorded so that the next person to
 * compare a screenshot against the mockup finds the arithmetic instead of
 * repeating it.
 */
/*
 * ⚠️ `align-items: start` AND NOT `center`, AND THIS ONE LINE IS THE WHOLE FIX
 * FOR A HEADER THAT MOVED WHEN YOU NAVIGATED.
 *
 * The navigation reserves room for its second level on the pages that have one.
 * Centred, that reserve does not just make the band taller - it re-centres every
 * OTHER item in the row against the new height. Measured across eleven pages at
 * a 1440 viewport, going from the front page to a register: the band grew from
 * 90px to 104px, the navigation moved UP 13px and the search field moved DOWN
 * 7px. Three elements travelling in three directions on a single click, and the
 * two that moved were the two that had no reason to.
 *
 * Aligned to the start, the mark, the name, the navigation and the search field
 * all sit at the same offset on every page and cannot move. The band still grows
 * where a section exists, but it grows DOWNWARD into the space the second level
 * actually occupies. Re-measured across the same eleven pages: every item at
 * y=8 everywhere, and the only number that changes is the band's own height.
 *
 * It costs nothing on the row itself: with the slogan no longer in the masthead
 * every item in this row is 44px tall - the target-size floor - so `start` and
 * `center` place them identically while the row is one line.
 */
.agora-page__header .agora-page__container {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  gap: var(--agora-space-s) var(--agora-space-l);
  padding-block: var(--agora-space-2xs);
}

/**
 * The region: the mark and the name, then the navigation.
 *
 * `flex: 1 1 auto` with `min-width: 0` lets it take the room the search field
 * does not want and shrink below its content width rather than pushing the
 * page wider - the SC 1.4.10 rounding error this theme guards against
 * everywhere a flex item holds text.
 */
/* `align-items: start` for the same reason as the row that holds it: the
   navigation inside here is what grows, and the mark beside it must not be
   pushed around by that. See the block above. */
.agora-page__header .agora-region--header {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: start;
  gap: var(--agora-space-s) var(--agora-space-l);
  min-width: 0;
}

/**
 * The contentinfo band's columns.
 *
 * WAS A ROW, IS NOW A GRID, and the change is what lets a site fill the footer
 * with four columns of links instead of one line of them. The blocks placed in
 * the footer region become the grid's items in source order.
 *
 * `auto-fit` AND NOT `auto-fill`, WHICH IS THE OPPOSITE OF THE CHOICE THE
 * REGISTER CARDS MAKE, so the difference is worth stating. `auto-fill` keeps
 * empty tracks, which is right for cards: a grid of six cards and a grid of
 * four should draw the same size of card. A footer is not a grid of cards - it
 * is a set of columns that should share the width they have - so `auto-fit`
 * collapses the empty tracks and three blocks make three columns rather than
 * three columns and a gap.
 *
 * NOTHING HERE SAYS FOUR. Three blocks make three columns, five make five, and
 * a narrow viewport stacks them with no breakpoint written. The 11rem floor
 * yields to the container with `min()`, so the single-column layout can never
 * be wider than the page.
 *
 * ⚠️ THAT FLOOR WAS 14rem AND IT COULD NOT HOLD THE DESIGN IT WAS WRITTEN FOR.
 * The arithmetic is here rather than a shrug, because the failure looked like a
 * design decision. The footer this theme is built for is a colophon plus FOUR
 * columns of grouped links: FIVE tracks. The content column is 75rem less its
 * inline padding, so 72rem, and five 14rem tracks with four --agora-space-xl
 * gaps need 83.5rem. The fifth block therefore wrapped to a second row and sat
 * under the colophon with three empty tracks beside it - seen in a rendered
 * fixture at 1440, not predicted. Five 11rem tracks need 68.5rem and fit. At
 * 1024 the same five wrap to four, which is what `auto-fit` is for, and at 390
 * they stack.
 *
 * `align-items: start` because the columns have different heights and a
 * baseline alignment would push a short column's heading down to meet a long
 * one's.
 */
.agora-page__footer .agora-region--footer {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(11rem, 100%), 1fr));
  align-items: start;
  gap: var(--agora-space-l) var(--agora-space-xl);
}

.agora-page__footer a,
.agora-page__footer a:visited,
.agora-page__footer a:hover {
  color: var(--agora-color-text-inverse);
}

.agora-page__footer :focus-visible {
  outline-color: var(--agora-color-focus-inverse);
}

/**
 * The main region.
 *
 * `flex: 1` keeps the footer at the bottom of a short page without either
 * `position: fixed`, which would take the footer out of the reading order, or a
 * negative margin, which breaks the moment the footer's height changes.
 */
.agora-page__main {
  flex: 1;
  padding-block: var(--agora-space-l) var(--agora-space-xl);
}

/**
 * The skip link's target.
 *
 * It renders nothing and must occupy nothing: an anchor with a line box would
 * push the first heading down by a line for every reader, to serve a link that
 * only keyboard users follow. `scroll-margin-block-start` is what stops the
 * target from landing flush against the top of the viewport when the link is
 * followed, which on a page with a sticky element would hide the very content
 * the reader jumped to.
 */
#main-content {
  display: block;
  scroll-margin-block-start: var(--agora-space-m);
}
