/* The consent bar on Quarry School's tokens (site/scss/_tokens.scss). @framerslab/analytics-consent's stylesheet reads
   these --ac-* properties (its README, "Tokens"); each maps to a token the site already switches for its dark look, so
   the bar follows the reader's look with no rule of its own. Copied into the edition as vendor/analytics-consent/quarry.css
   by tools/courses/analytics/build.mjs, and only while an analytics layer is set. */
:root {
  --ac-panel: var(--panel);
  --ac-panel-border: 1px solid var(--line);
  --ac-panel-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 14%, transparent);
  --ac-ink: var(--ink);
  --ac-ink-2: var(--dim);
  --ac-line: var(--line);
  --ac-edge: var(--dim);
  --ac-well: var(--rulebg);
  --ac-accent: var(--accent);
  --ac-on-accent: var(--bg);
  --ac-key-bg: var(--panel);
  --ac-radius-card: 12px;
  --ac-radius-pill: 999px;
  --ac-font-ui: var(--ui);
}

/* The room the bar takes at the foot while it shows, so the page's last line scrolls clear of it. */
body {
  padding-bottom: var(--consent-room, 0px);
}

/* A lesson's narration bar and the watch bar stand fixed at the foot (--bar-h, site/scss/_narration.scss and _watch.scss):
   the consent bar stands above them, and the page keeps room for both. */
html.narrated,
html.watching {
  --ac-room-below: calc(var(--bar-h) + 16px);
}

html.narrated body,
html.watching body {
  padding-bottom: calc(var(--bar-h) + var(--consent-room, 0px));
}

/* The footer's line under its Analytics choices link. */
.foot .ac-status {
  margin-left: 0.4em;
  color: var(--dim);
}

/* Catalogue consent uses the same words and controls with a docked first layer on a phone. */
.pg-catalog {
  --ac-panel: var(--cc-ground);
  --ac-panel-border: 1px solid var(--cc-accent);
  --ac-ink: var(--cc-ink);
  --ac-ink-2: var(--cc-ink);
  --ac-edge: var(--cc-accent);
  --ac-accent: var(--cc-accent);
  --ac-on-accent: var(--cc-on-accent);
  --ac-key-bg: var(--cc-ground);
  --ac-radius-pill: 5px;
}

.pg-catalog .ac-bar :is(.ac-heading, .ac-sentence) {
  font-size: 1.125rem;
  line-height: 1.55;
}

.pg-catalog .ac-bar :is(.ac-heading, .ac-key) {
  font-weight: 650;
}

.pg-catalog .ac-bar .ac-key {
  border-color: var(--cc-accent);
}

.pg-catalog .ac-bar .ac-key:hover {
  background: var(--cc-tinted);
}

.pg-catalog .ac-bar .ac-key:active {
  background: var(--cc-pressed);
  color: var(--cc-on-accent);
}

.pg-catalog .ac-bar :is(.ac-key, .cc-consent-copy):focus-visible {
  outline: 2px solid var(--cc-accent);
  outline-offset: 3px;
}

@media (max-width: 599px) {
  .pg-catalog .ac-bar:not(.ac-bar-choose) {
    inset-inline: 0;
    inset-block-end: 0;
    width: 100%;
    max-width: none;
    max-height: 25dvh;
    grid-template-rows: minmax(0, 1fr);
    padding: 7px 12px;
    border-radius: 0;
    overflow: hidden;
  }

  .pg-catalog .ac-bar [data-ac-layer="first"]:not([hidden]) {
    display: grid;
    max-height: calc(25dvh - 16px);
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 3px;
  }

  /* Post-build can supply the shared markup, with the heading and copy in one scrollable track. */
  .pg-catalog .ac-bar [data-ac-layer="first"]:has(> .ac-text):not([hidden]) {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .pg-catalog .ac-bar .cc-consent-copy {
    overflow: auto;
    overscroll-behavior: contain;
  }

  .pg-catalog .ac-bar [data-ac-layer="first"] .ac-key-row {
    overflow: visible;
    padding: 0;
    margin: 0;
  }

  .pg-catalog .ac-bar [data-ac-layer="first"] .ac-keys {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }

  .pg-catalog .ac-bar [data-ac-layer="first"] .ac-key {
    min-width: 0;
    min-height: 44px;
    padding-inline: 3px;
    white-space: nowrap;
  }
}

@media (min-width: 600px) {
  .pg-catalog .ac-bar:not(.ac-bar-choose) {
    left: auto;
    right: 16px;
    width: min(calc(100% - 32px), 480px);
    grid-template-rows: auto;
    transform: none;
  }

  .pg-catalog .ac-bar [data-ac-layer="first"]:not([hidden]) {
    display: grid;
    gap: 8px;
  }
}
