/* The cookie dialog and the Cookie settings button (design/consent/), on every
   page. A modal dialog centred over the design's backdrop; on a phone it fills
   the width inside the gutters, from the breakpoint up it is the measure wide.
   The round button sits at the bottom left once a choice exists. Every value
   is a token from design/tokens.css. */
.consent [hidden] { display: none !important; }

/* The backdrop, and the dialog on it. The layer scrolls nothing itself; the
   dialog scrolls inside the dynamic viewport when it is taller than the screen. */
.consent-layer {
  position: fixed;
  inset: 0;
  z-index: 200;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gutter-phone);
  background: var(--backdrop);
  overscroll-behavior: contain;
}
.consent-dialog {
  box-sizing: border-box;
  width: 100%;
  max-height: calc(100vh - 2 * var(--gutter-phone));
  max-height: calc(100dvh - 2 * var(--gutter-phone));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--paper-raised);
  color: var(--ink);
  border: thin solid var(--paper-line);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--type-body-phone-size);
  line-height: var(--type-body-phone-line);
}
.consent-dialog:focus { outline: none; }
.consent-dialog * { box-sizing: border-box; }
.consent-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.consent-dialog h2 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: var(--type-subhead-weight);
  font-size: var(--type-subhead-size);
  line-height: var(--type-subhead-line);
  color: var(--ink);
}
.consent-dialog p { margin: 0; color: var(--ink-muted); }
.consent-dialog a { color: var(--ink); }

/* The categories: a hairline above each row. */
.consent-cats { display: flex; flex-direction: column; margin-top: var(--space-1); }
.consent-cat {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4) 0;
  border-top: thin solid var(--paper-line);
}
.consent-ct { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.consent-ct b, .consent-ct label {
  font-size: var(--type-label-size);
  line-height: var(--type-label-line);
  font-weight: 600;
  color: var(--ink);
}
.consent-ct label { cursor: pointer; }
.consent-ct span, .consent-always {
  font-size: var(--type-caption-size);
  line-height: var(--type-caption-line);
  color: var(--ink-muted);
}
.consent-always { flex: none; white-space: nowrap; }

/* The switch: off is a sunk track with its knob on the left, on is an ink track
   with its knob on the right. Its tap area reaches the tap target's height. */
.consent-switch {
  position: relative;
  flex: none;
  width: var(--switch-width);
  height: var(--switch-height);
  margin: 0;
  padding: var(--switch-inset);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: var(--paper-sunk);
  border: thin solid var(--paper-edge);
  border-radius: var(--radius-full);
  cursor: pointer;
}
.consent-switch::after {
  content: "";
  position: absolute;
  inset: calc((var(--switch-height) - var(--tap-target)) / 2) calc((var(--switch-height) - var(--tap-target)) / 2);
}
.consent-switch span {
  display: block;
  width: var(--switch-knob);
  height: var(--switch-knob);
  background: var(--paper-raised);
  border: thin solid var(--paper-edge);
  border-radius: var(--radius-full);
}
.consent-switch[aria-checked="true"] { background: var(--ink); border-color: var(--ink); justify-content: flex-end; }
.consent-switch[aria-checked="true"] span { background: var(--paper); border-color: var(--ink); }

.consent-dialog .consent-pn {
  padding-top: var(--space-4);
  border-top: thin solid var(--paper-line);
  font-size: var(--type-caption-size);
  line-height: var(--type-caption-line);
}

/* The actions: three alike, none in the accent. Stacked on a phone, one row
   from the breakpoint up. */
.consent-acts { display: flex; flex-direction: column; gap: var(--space-3); margin-top: var(--space-1); }
.consent-acts button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap-target);
  margin: 0;
  padding: 0 var(--space-5);
  background: none;
  color: var(--ink);
  border: thin solid var(--paper-edge);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--type-label-size);
  line-height: var(--type-label-line);
  font-weight: 600;
  cursor: pointer;
}
.consent-x {
  flex: none;
  width: var(--tap-target);
  height: var(--tap-target);
  margin: calc(var(--space-3) * -1) calc(var(--space-3) * -1) calc(var(--space-3) * -1) 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  color: var(--ink);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.consent-x svg, .consent-button svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: square;
  stroke-linejoin: miter;
}
.consent-x svg { width: var(--icon-size); height: var(--icon-size); }

/* The Cookie settings button: round, bottom left, under the dialog. */
.consent-button {
  position: fixed;
  z-index: 190;
  left: var(--gutter-phone);
  bottom: var(--gutter-phone);
  width: var(--tap-target);
  height: var(--tap-target);
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-raised);
  color: var(--ink);
  border: thin solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
}
.consent-button svg { width: var(--icon-size-lg); height: var(--icon-size-lg); }
.consent-button circle { fill: currentColor; stroke: none; }

/* The room under the footer that the button sits in, so the page's last line
   ends above it; the footer's own ground carries on into it. A control the
   keyboard reaches that lands under the button is brought up clear of it by
   src/consent.js, so focus elsewhere never moves the page. */
.consent-room { height: calc(var(--tap-target) + 2 * var(--gutter-phone)); background: var(--paper-sunk); }

.consent a:focus-visible, .consent button:focus-visible {
  outline: var(--focus-width) solid var(--focus-ring);
  outline-offset: var(--focus-offset);
}
@media (hover: hover) {
  .consent-acts button:hover, .consent-x:hover, .consent-button:hover { background: var(--paper-sunk); }
  .consent-dialog a:hover { color: var(--ink-muted); }
}

/* While the dialog is open the page behind it holds still, on iOS too: the
   body is pinned where it was and given back on close (src/consent.js). */
html.consent-locked { overflow: hidden; }
html.consent-locked body { position: fixed; left: 0; right: 0; overflow: hidden; }

/* After the first choice focus goes to the start of the page, held by the body. */
body[data-consent-start]:focus { outline: none; }

@media (prefers-reduced-motion: no-preference) {
  .consent-layer { animation: consent-in 160ms ease-out; }
  .consent-switch, .consent-switch span, .consent-acts button, .consent-x, .consent-button { transition: background-color 160ms ease, border-color 160ms ease; }
}
@keyframes consent-in { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 760px) {
  .consent-layer { padding: var(--gutter-desktop); }
  .consent-dialog {
    width: var(--measure);
    max-width: 100%;
    max-height: calc(100vh - 2 * var(--gutter-desktop));
    max-height: calc(100dvh - 2 * var(--gutter-desktop));
    font-size: var(--type-body-size);
    line-height: var(--type-body-line);
  }
  .consent-acts { flex-direction: row; }
  .consent-acts button { flex: 1 1 0; min-width: 0; }
  .consent-button { left: var(--space-5); bottom: var(--space-5); }
  .consent-room { height: calc(var(--tap-target) + 2 * var(--space-5)); }
}
