/*
 * sd-consent — cookie consent banner (Session 7.2; Technical_Architecture.md 11.1 and 11.3; Blueprint 18.33, 20.57;
 * D-014, D-019). New component of the theme (no prototype; reviewed with Session 7.2).
 *
 * A panel fixed to the bottom edge, above the page content (not a modal: the page stays usable and readable).
 * Two equal choices — "Accept all" and "Reject all" have the same button style and size — and "Settings", which
 * opens the categories in the same panel: Necessary (always active, described) and Statistics (a checkbox).
 * The banner is a global component: it carries its own checkbox style instead of loading field.css everywhere.
 * Calm surface: white with the brand-blue top line and the overlay shadow; no colour signals a "right" choice.
 * Phone: text, then the buttons stacked at full width; the panel scrolls inside itself when the screen is low ·
 * ≥ 1024px: text left, buttons right. Hidden without JavaScript (nothing optional loads then).
 */

.sd-consent {
  position: fixed;
  inset: auto 0 0;
  z-index: 200;
  max-height: min(85vh, 40rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-top: var(--sd-border-width-strong) solid var(--sd-color-brand-blue);
  background: var(--sd-color-surface);
  box-shadow: var(--sd-shadow-overlay);
  padding-block: var(--sd-space-4);
  padding-bottom: max(var(--sd-space-4), env(safe-area-inset-bottom));
}

.sd-consent[hidden] { display: none; }

.sd-consent__inner {
  display: grid;
  gap: var(--sd-space-4);
}

.sd-consent__title {
  margin: 0;
  color: var(--sd-color-text-heading);
  font-size: var(--sd-font-size-h4);
  line-height: var(--sd-line-height-h4);
  font-weight: var(--sd-font-weight-semibold);
}

.sd-consent__title:focus { outline: none; }
.sd-consent__title:focus-visible { outline: var(--sd-focus-ring-width) solid var(--sd-focus-ring-color); outline-offset: var(--sd-focus-ring-offset); }

.sd-consent__text {
  margin: var(--sd-space-2) 0 0;
  max-width: 70ch;
  font-size: var(--sd-font-size-ui);
  line-height: var(--sd-line-height-small);
}

.sd-consent__actions {
  display: grid;
  gap: var(--sd-space-2);
  align-content: start;
}

.sd-consent__actions .sd-button { width: 100%; }

/* Settings: the categories */
.sd-consent__settings {
  display: grid;
  gap: var(--sd-space-3);
  margin: 0;
  padding: 0;
  border: 0;
}

.sd-consent__settings[hidden] { display: none; }

.sd-consent__category {
  padding: var(--sd-space-3);
  border: var(--sd-border-width) solid var(--sd-color-border-subtle);
  border-radius: var(--sd-radius-md);
  background: var(--sd-color-surface-subtle);
}

.sd-consent__category-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--sd-space-1) var(--sd-space-3);
}

.sd-consent__category-name {
  margin: 0;
  font-size: var(--sd-font-size-ui);
  font-weight: var(--sd-font-weight-semibold);
  color: var(--sd-color-text-default);
}

.sd-consent__always {
  color: var(--sd-color-text-muted);
  font-size: var(--sd-font-size-small);
}

/* Statistics checkbox: native control in the brand colour (the banner is on every page, so it does not load field.css) */
.sd-consent__check {
  display: inline-flex;
  align-items: center;
  gap: var(--sd-space-3);
  min-height: var(--sd-target-min);
  font-size: var(--sd-font-size-ui);
  font-weight: var(--sd-font-weight-semibold);
  cursor: pointer;
}

.sd-consent__check input {
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  accent-color: var(--sd-color-action-primary);
  cursor: pointer;
}

.sd-consent__check input:focus-visible { outline: var(--sd-focus-ring-width) solid var(--sd-focus-ring-color); outline-offset: var(--sd-focus-ring-offset); }

.sd-consent__category-text {
  margin: var(--sd-space-1) 0 0;
  color: var(--sd-color-text-muted);
  font-size: var(--sd-font-size-small);
  line-height: var(--sd-line-height-small);
}


.sd-consent__check + .sd-consent__category-text { padding-left: calc(1.5rem + var(--sd-space-3)); }

@media (min-width: 640px) {
  .sd-consent__actions { grid-template-columns: repeat(3, minmax(0, max-content)); }
  .sd-consent__actions .sd-button { width: auto; }
}

@media (min-width: 1024px) {
  .sd-consent__inner { grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--sd-space-6); align-items: start; }
  .sd-consent__settings { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Footer: "Cookie settings" is a button that looks like the other legal links (footer.css .sd-footer__link) */
.sd-footer__legal button.sd-footer__link {
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  cursor: pointer;
}

.sd-footer__legal button.sd-footer__link[hidden],
.sd-footer__legal li:has(> button[hidden]) { display: none; }

@media print {
  .sd-consent { display: none; }
}
