/*
 * @savant-realms/ui-consent-core/consent.css: the consent family's one stylesheet (ADR 0135; savant-realms/packages#8).
 * Transcribed from design-silos `designs/_site/site.css`, section "the consent family (957, 958)", on
 * the-consent-bar-uses-the-button-and-toggle-families at 7c13593. A change is made there and transcribed here.
 *
 * The class contract is `.sr-consent*` and nothing else. The buttons are the button family's two-line `.sr-btn`
 * (button.css, linked before this file) and the switches the toggle family's `.sr-toggle-switch` (toggle.css); this
 * file only places them. State is on data-* attributes, never an inline style, so the bar works under
 * `style-src 'self'`:
 *   data-dock=footer | top            in the flow directly above the footer, its bottom the footer's top | the top of the flow
 *   data-locked                       the bar locks the page: still docked on the footer (957 region 4; ADR 0149 clause 4)
 *   data-state=asking | done
 *   data-variant=categories           the first layer with three answers and an X (958)
 *   data-close                        the X is present
 *   data-fs=16 … 9                    the script's fitted text size, in half pixels (the founder's 9px floor)
 *   data-grow                         the copy did not fit at 9px: the band grows, keeping its bottom edge
 * What the bar locks carries `data-consent-locked` beside `inert`: what the page marks `data-consent-lock` (a service's
 * main) is blurred, and each `data-sets-cookie` control (a sign-in action) is drawn at half opacity. Nothing else is.
 *
 * Each colour is a `--sr-consent-*` property that falls back from the website token to the console token (elysian-ui
 * defines no --sr-site-*), so one file serves both brands.
 *
 * The drawing board's stand-ins are replaced by what they stand for: `@container` by `@media` (the band is the window's width), `[data-pointer="coarse"]` by
 * `@media (pointer: coarse)`, `.is-focus` by :focus-visible, `.visually-hidden` by `.sr-consent-title`, `.cb-scrim` by
 * `::backdrop`, the mock dialog's centring by the `<dialog>` top layer, and `.cb-locked`'s blur and half
 * opacity by `[data-consent-locked]` on what the page marks `data-consent-lock` and `data-sets-cookie`. The `.sheet`, `.frame--w*`, `.cb-*` layout is not transcribed.
 */

/* ------------------------------------------------------------------ the family's properties */

:where(.sr-consent, .sr-consent-dialog) {
  --sr-consent-bg: var(--sr-site-surface, var(--sr-bg-raised));
  --sr-consent-fg: var(--sr-site-text, var(--sr-fg));
  --sr-consent-fg-sub: var(--sr-site-text-sub, var(--sr-fg-muted));
  --sr-consent-edge: var(--sr-site-border-strong, var(--sr-border-strong));
  --sr-consent-rule: var(--sr-site-border, var(--sr-border));
  --sr-consent-btn-edge: var(--sr-site-border-strong, var(--sr-border-strong));
  --sr-consent-focus: var(--sr-site-cyan, var(--sr-focus-ring));
  --sr-consent-link: var(--sr-site-cyan, var(--sr-accent));
  --sr-consent-shadow: var(--sr-site-shadow, rgb(0 0 0 / 30%));
  --sr-consent-scrim: var(--sr-site-bg, var(--sr-bg));
  --sr-consent-radius: var(--sr-site-radius, var(--sr-radius-lg));
  --sr-consent-radius-sm: var(--sr-site-radius-sm, var(--sr-radius-sm));
  /* --sr-consent-font and --sr-consent-font-head are read with their defaults below rather than declared here, so a
     container (the shell's frame row) can set them for the bar and its dialog by inheritance. */
  --sr-consent-font-mono: var(--sr-site-font-mono, var(--sr-font-mono));
  --sr-consent-h: var(--sr-site-footer-h, 58px);
}

/* ------------------------------------------------------------------ the bar */

/* A framework view's own element around the bar and its dialog (the Angular view's `sr-consent-bar`) draws no box, so
   the bar is a box of the page's flow (the frame's consent row), not of a host around it. */
.sr-consent-host { display: contents; }

.sr-consent {
  z-index: 290;
  box-sizing: border-box;
  display: flex; align-items: center; gap: .5rem max(1.25rem, 16px);
  padding-block: 0; padding-inline: 1.5rem;
  background: var(--sr-consent-bg); color: var(--sr-consent-fg);
  font-family: var(--sr-consent-font, var(--sr-site-font-body, var(--sr-font-sans)));
}
.sr-consent[hidden] { display: none; }

/* The region's name, read and never drawn. */
.sr-consent-title {
  position: absolute; inline-size: 1px; block-size: 1px; margin: 0; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* Locked or not: edge to edge, in the flow in the row before the footer's, so its bottom is the footer's top by
   construction and it never lies over it (957 regions 1 and 4; ADR 0149 clause 4). Not sticky and not offset: the
   page's main region gives up the bar's height, and nothing is covered. `--sr-consent-h` is its height only. */
.sr-consent[data-dock="footer"] {
  --sr-consent-fs: 10.5px;
  position: relative;
  block-size: var(--sr-consent-h); overflow: hidden;
  border-block-start: 1px solid var(--sr-consent-edge);
  box-shadow: 0 -8px 24px var(--sr-consent-shadow);
}
/* In the flow at the top: as tall as its content, so its text keeps a readable size and nothing is fitted. */
.sr-consent[data-dock="top"] {
  position: static; padding-block: .85rem;
  border-block-end: 1px solid var(--sr-consent-edge);
}

.sr-consent-body { flex: 1 1 auto; min-width: 0; display: grid; gap: .15rem; }
.sr-consent-body p { margin: 0; line-height: 1.3; color: var(--sr-consent-fg-sub); text-align: start; }
.sr-consent-body p a { color: var(--sr-consent-link); }
.sr-consent-body strong { color: var(--sr-consent-fg); font-weight: 600; }
.sr-consent[data-dock="footer"] .sr-consent-body p { font-size: var(--sr-consent-fs, 9px); }
.sr-consent[data-dock="top"] .sr-consent-body p { font-size: .86rem; }

/* A locked page's *choose categories*: a button, drawn as the copy's link. */
.sr-consent-choose {
  display: inline; margin: 0; padding: 0; border: 0; background: none;
  font: inherit; color: var(--sr-consent-link); text-decoration: underline; cursor: pointer;
}
.sr-consent-choose:focus-visible { outline: 2px solid var(--sr-consent-focus); outline-offset: 2px; border-radius: 2px; }

/* Every answer one size and one weight: the grid makes every column as wide as the widest. */
.sr-consent-actions { flex: 0 0 auto; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .6rem; margin: 0; }

/* An X that means *reject* (958), never *dismiss*. */
.sr-consent-x {
  flex: none; box-sizing: border-box; inline-size: 32px; block-size: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--sr-consent-btn-edge); border-radius: var(--sr-consent-radius-sm);
  background: transparent; color: var(--sr-consent-fg-sub); cursor: pointer;
}
.sr-consent-x-icon { inline-size: 16px; block-size: 16px; }
.sr-consent-x:focus-visible { outline: 2px solid var(--sr-consent-focus); outline-offset: 2px; }
@media (pointer: coarse) {
  .sr-consent-x { min-block-size: 44px; inline-size: 44px; }
}

/* After a choice: one line that takes focus and says how to change it (GOV.UK's pattern). */
.sr-consent[data-state="done"] .sr-consent-body p { font-size: .82rem; color: var(--sr-consent-fg); }
.sr-consent-done:focus-visible { outline: 2px solid var(--sr-consent-focus); outline-offset: 2px; border-radius: 2px; }
/* Above the button family's own minimum width, which button.css sets at equal specificity. */
.sr-consent .sr-btn.sr-consent-hide { min-inline-size: 7rem; }

/* Behind a locked bar (ADR 0135 clause 5; 957 Q12 and Q13): what the page marks for the lock, its main, is blurred and
   inert; a control that would add a cookie (a sign-in action) is inert and drawn at half opacity, not hidden. The
   header, the footer and everything else in them stay sharp and usable. */
[data-consent-lock][data-consent-locked] { filter: blur(4px); opacity: .7; }
[data-sets-cookie][data-consent-locked] { opacity: .5; pointer-events: none; }

@media (prefers-reduced-motion: no-preference) { .sr-consent { transition: opacity .15s ease; } }
@media (forced-colors: active) {
  .sr-consent { border: 1px solid CanvasText; }
  .sr-consent-x { border: 1px solid ButtonText; forced-color-adjust: none; background: ButtonFace; color: ButtonText; }
  .sr-consent-x:focus-visible, .sr-consent-choose:focus-visible { outline-color: Highlight; }
  [data-consent-lock][data-consent-locked] { filter: none; }
}

/* Measured text sizes, per width band (957, *Text fitting*): the CSS-first value, which the script's fit refines. */
@media (max-width: 991px) {
  .sr-consent[data-dock="footer"] { --sr-consent-fs: 12.5px; }
}
@media (max-width: 699px) {
  .sr-consent[data-dock="footer"] { --sr-consent-fs: 10.5px; }
}
@media (max-width: 599px) {
  .sr-consent[data-dock="footer"] {
    --sr-consent-fs: 9px;
    block-size: auto; min-block-size: var(--sr-consent-h); padding-block: .5rem; overflow: visible;
  }
}
/* Stacked, copy above the answers, below 1280px: the row gives the copy only what the three two-line answers leave
   (savant-realms/packages#8). On the DOM fixture's page, in system-ui, the row band was 425px with a 38px column at 992px,
   168px at 1100px, 110px at 1200px and 98px up to 1258px, reaching its designed height only from 1259px. Those heights
   are that page's (its footer, font and scrollbar move them); the threshold reproduced on another page at 1258-1259px. 1280px, the design's own width, keeps the row where it is drawn. Stacked, the band is 122px at every width,
   with the text fitted at 12px or more. */
@media (max-width: 1279.98px) {
  .sr-consent[data-dock="footer"] {
    flex-direction: column; align-items: stretch; justify-content: center; padding-inline: 1rem; gap: .4rem;
    --sr-consent-h: 122px;
  }
  .sr-consent-body { flex: 0 0 auto; }
  .sr-consent[data-dock="footer"] .sr-consent-actions { inline-size: 100%; }
  .sr-consent-actions .sr-btn { --sr-btn-pad: .5rem; }
  .sr-consent[data-dock="top"] { flex-direction: column; align-items: stretch; }
  .sr-consent[data-dock="top"] .sr-consent-actions { inline-size: 100%; }
}
/* A window shorter than 480px: the band plus the footer would leave almost no page (957, region 5). Without a frame
   the view moves the bar to the top; inside one, the frame flows and puts its consent row first (ADR 0149 clause 4).
   Either way the band is as tall as its content there. */
@media (max-height: 479.98px) {
  .sr-consent[data-dock="footer"] { block-size: auto; overflow: visible; padding-block: .5rem; }
}

/* ------------------------------------------------------------------ the first layer with categories (958) */

.sr-consent[data-variant="categories"] { position: relative; }
.sr-consent[data-variant="categories"][data-close] { padding-inline-end: 3.75rem; }
.sr-consent[data-variant="categories"] .sr-consent-x { position: absolute; inset-block-start: .5rem; inset-inline-end: .5rem; }
/* In the row, from 1280px up, its copy does not fit the footer's 58px even at the 9px floor (measured), so it starts
   there and grows. */
.sr-consent[data-variant="categories"][data-dock="footer"] {
  --sr-consent-fs: 9px;
  block-size: auto; min-block-size: var(--sr-consent-h); padding-block: .5rem; overflow: visible;
}
/* Stacked (below 1280px, as above): the band's designed height, and the fit's starting size. */
@media (max-width: 1279.98px) {
  .sr-consent[data-variant="categories"][data-dock="footer"] {
    --sr-consent-fs: 10.5px;
    block-size: var(--sr-consent-h); padding-block: 0; overflow: hidden;
  }
  .sr-consent[data-variant="categories"][data-close] { padding-inline-end: 3.75rem; }
}
@media (max-width: 599px) {
  .sr-consent[data-variant="categories"][data-dock="footer"] {
    --sr-consent-fs: 9px;
    block-size: auto; padding-block: .5rem; overflow: visible;
  }
  .sr-consent[data-variant="categories"] .sr-consent-actions { grid-auto-flow: row; }
  .sr-consent[data-variant="categories"][data-close] { padding-inline-end: 1rem; }
  .sr-consent[data-variant="categories"][data-close] .sr-consent-body { padding-inline-end: 2.75rem; }
}
@media (max-width: 599px) and (pointer: coarse) {
  .sr-consent[data-variant="categories"][data-close] .sr-consent-body { padding-inline-end: 3.5rem; }
}

/* ------------------------------------------------------------------ the preferences dialog (958, region 2) */

/* A <dialog> opened with showModal(): the top layer centres it, traps focus and draws ::backdrop. */
.sr-consent-dialog {
  box-sizing: border-box; padding: 0;
  inline-size: min(560px, calc(100% - 1.5rem)); max-block-size: calc(100% - 1.5rem); overflow: auto;
  border: 1px solid var(--sr-consent-edge); border-radius: var(--sr-consent-radius);
  background: var(--sr-consent-bg); color: var(--sr-consent-fg);
  font-family: var(--sr-consent-font, var(--sr-site-font-body, var(--sr-font-sans)));
  box-shadow: 0 16px 36px var(--sr-consent-shadow);
}
.sr-consent-dialog::backdrop { background: color-mix(in srgb, var(--sr-site-bg, var(--sr-bg, Canvas)) 70%, transparent); }
.sr-consent-dialog-head { display: flex; align-items: flex-start; gap: .75rem; padding: 1rem 1.1rem .5rem; }
.sr-consent-dialog-head h2 { flex: 1; margin: 0; font-family: var(--sr-consent-font-head, var(--sr-site-font-head, var(--sr-font-sans))); font-size: 1.05rem; line-height: 1.3; }
.sr-consent-dialog-lede { margin: 0; padding: 0 1.1rem; font-size: .82rem; color: var(--sr-consent-fg-sub); }
.sr-consent-cats { list-style: none; margin: .75rem 0 0; padding: 0; border-block-start: 1px solid var(--sr-consent-rule); }
.sr-consent-cat { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem 1rem; padding: .75rem 1.1rem; border-block-end: 1px solid var(--sr-consent-rule); }
.sr-consent-cat-name { font-weight: 600; font-size: .9rem; }
.sr-consent-cat-text { grid-column: 1; font-size: .8rem; color: var(--sr-consent-fg-sub); }
.sr-consent-cat-services { grid-column: 1 / -1; font-family: var(--sr-consent-font-mono); font-size: .7rem; color: var(--sr-consent-fg-sub); }
/* Each category's switch is the toggle family's; only its cell in the row is this file's. */
.sr-consent-cat .sr-toggle-switch { grid-row: 1 / span 2; grid-column: 2; align-self: start; }
.sr-consent-dialog-foot { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: .6rem; padding: .9rem 1.1rem 1.1rem; }
@media (max-width: 520px) {
  .sr-consent-dialog-foot { grid-auto-flow: row; }
}
@media (forced-colors: active) {
  .sr-consent-dialog { border: 1px solid CanvasText; }
}

/* ------------------------------------------------------------------ without JavaScript (958, region 5) */

.sr-consent-form { display: grid; gap: .6rem; }
.sr-consent-checks { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin: 0; padding: 0; border: 0; }
.sr-consent-checks legend { font-size: .78rem; font-weight: 600; color: var(--sr-consent-fg-sub); margin-block-end: .25rem; }
.sr-consent-check { display: inline-flex; align-items: center; gap: .4rem; min-block-size: 24px; font-size: .8rem; color: var(--sr-consent-fg-sub); }
.sr-consent-check input { inline-size: 18px; block-size: 18px; accent-color: var(--sr-consent-link); }
@media (pointer: coarse) { .sr-consent-check { min-block-size: 44px; } }

/* ------------------------------------------------------------------ the script's fit (ADR 0135 clause 4)

   The largest size, tried from 16px down in half pixels, at which the band's text stays 8px inside it; below 9px the
   band grows instead (`data-grow`). These come last, and name the dock, so they win over every per-width step above. */
.sr-consent[data-dock][data-fs="16"] { --sr-consent-fs: 16px; }
.sr-consent[data-dock][data-fs="15.5"] { --sr-consent-fs: 15.5px; }
.sr-consent[data-dock][data-fs="15"] { --sr-consent-fs: 15px; }
.sr-consent[data-dock][data-fs="14.5"] { --sr-consent-fs: 14.5px; }
.sr-consent[data-dock][data-fs="14"] { --sr-consent-fs: 14px; }
.sr-consent[data-dock][data-fs="13.5"] { --sr-consent-fs: 13.5px; }
.sr-consent[data-dock][data-fs="13"] { --sr-consent-fs: 13px; }
.sr-consent[data-dock][data-fs="12.5"] { --sr-consent-fs: 12.5px; }
.sr-consent[data-dock][data-fs="12"] { --sr-consent-fs: 12px; }
.sr-consent[data-dock][data-fs="11.5"] { --sr-consent-fs: 11.5px; }
.sr-consent[data-dock][data-fs="11"] { --sr-consent-fs: 11px; }
.sr-consent[data-dock][data-fs="10.5"] { --sr-consent-fs: 10.5px; }
.sr-consent[data-dock][data-fs="10"] { --sr-consent-fs: 10px; }
.sr-consent[data-dock][data-fs="9.5"] { --sr-consent-fs: 9.5px; }
.sr-consent[data-dock][data-fs="9"] { --sr-consent-fs: 9px; }
.sr-consent[data-dock="footer"][data-fs]:not([data-grow]) { block-size: var(--sr-consent-h); padding-block: 0; overflow: hidden; }
.sr-consent[data-dock="footer"][data-grow] { block-size: auto; min-block-size: var(--sr-consent-h); padding-block: .5rem; overflow: visible; }
