/* Cookie card: one glass surface, bottom-centre; the floating bar keeps its
   corner. see DESIGN.md → Components · Cookie card

   Never the bar grown wide: the shape() fallback measures a pill's half-height
   once and never re-measures, so a card at --radius-pill reads as a lozenge. */

.cookie-card {
  position: fixed;
  left: 50%;
  bottom: var(--bar-inset, 1rem);
  z-index: 39;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: min(27rem, calc(100vw - 2 * var(--bar-inset, 1rem)));
  max-height: calc(100dvh - 2 * var(--bar-inset, 1rem));
  overflow: auto;
  padding: var(--space-md);
  --r: var(--radius-bar);
  border-radius: var(--radius-bar);
  color: var(--glass-ink);
  /* Centring rides transform, so the entrance composes with it. */
  transform: translate(-50%, 0.75rem);
  transition: transform 0.32s var(--ease-spring);
}

/* The bar steps aside while the card is open, so the card can own the floor
   instead of climbing into the page: it used to rise 9.75rem and land on the
   hero's store buttons, which are the only thing the site exists to offer. */
html[data-consent-open] .float-bar {
  opacity: 0;
  visibility: hidden;
}

/* `html` in the selector, not decoration: the base .cookie-card.is-open rule
   sits below this block and would otherwise win the transform, shifting the
   full-width sheet half a viewport to the left. */
@media (max-width: 639px) {
  html .cookie-card {
    left: var(--bar-inset, 1rem);
    right: var(--bar-inset, 1rem);
    bottom: calc(var(--bar-inset, 1rem) + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-height: 62dvh;
    transform: translate(0, 0.75rem);
  }

  html .cookie-card.is-open {
    transform: translate(0, 0);
  }
}

/* `display: flex` above would beat the UA's [hidden] rule. */
.cookie-card[hidden] {
  display: none;
}

.cookie-card.is-open {
  transform: translate(-50%, 0);
}

/* The dialog takes focus so screen readers land inside it, but it is not a
   control: no ring. */
.cookie-card:focus-visible {
  outline: none;
}

/* --- Head ------------------------------------------------------------- */

.cookie-head {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: var(--space-sm);
}

.cookie-mark {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: var(--space-2xs);
}

.cookie-mark svg {
  width: 1.5rem;
  height: 1.5rem;
}

.cookie-title {
  margin: 0;
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  line-height: var(--lh-ui);
  text-wrap: balance;
}

.cookie-switch:focus-visible {
  /* Inside the shape: the shape() fallback clips an outline that sits outside.
     Re-point the token, never re-colour the ring (DESIGN.md → focus). */
  --focus-color: currentColor;
  outline: var(--focus-w) solid var(--focus-color);
  outline-offset: -2px;
}

.cookie-link:focus-visible {
  --focus-color: currentColor;
  outline: var(--focus-w) solid var(--focus-color);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* --- Views ------------------------------------------------------------ */

.cookie-view {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  /* Only the content cross-fades; the glass never animates opacity. Durations
     follow the floating bar's morph. */
  transition: opacity 0.168s var(--ease-out), filter 0.168s var(--ease-out);
}

.cookie-view[hidden] {
  display: none;
}

/* View morph: 123ms out, 224ms height, 168ms in. The card's own transform
   (centring + entrance) is untouched. */
.cookie-card.is-leaving .cookie-view:not([hidden]) {
  opacity: 0;
  filter: blur(6px);
  transition-duration: 123ms;
  transition-timing-function: var(--ease-in);
}

.cookie-card.is-entering .cookie-view:not([hidden]) {
  opacity: 0;
  filter: blur(6px);
  transition: none; /* hold the from-state for one frame, then fade in */
}

.cookie-card.is-morphing {
  overflow: hidden;
  transition: transform 0.32s var(--ease-spring),
    height 224ms var(--ease-in-out);
}

/* The caption role owns the type; the rules below own the box and the muted ink. */
.cookie-lead {
  margin: 0;
  text-wrap: pretty;
}

.cookie-links {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0 var(--space-xs);
}

/* The box and the bold label size are the row's; the ink, the dotted baseline and
   the hover fill come from the shared text paint (`a.link-text`, shared.css). */
a.link-text.cookie-page-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--fs-label);
  font-weight: var(--fw-bold);
  /* The bright green is a surface colour: at label size on this card it measured
     2.70:1. --kind-feature is the same hue a step down (5:1). Two classes plus
     the element, because a.link-text (shared.css) outranks a single class. */
  color: var(--kind-feature);
}

/* --- Actions ---------------------------------------------------------- */

.cookie-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
}

.cookie-pills {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-xs);
  margin-left: auto;
}

.cookie-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* A short label ("Done") must still be a 44px target. */
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--space-2xs);
  border: 0;
  background: transparent;
  color: var(--color-link);
  font: inherit;
  font-size: var(--fs-caption);
  font-weight: var(--fw-bold);
  cursor: pointer;
}

.cookie-link:hover,
.cookie-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

/* Reject is a ring at Accept's height: refusing is one click of the same size,
   never a hidden link. */
.cookie-pill {
  --ring-color: var(--color-border-strong);
  --ring-face: var(--color-card);
  display: inline-flex;
  font: inherit;
  cursor: pointer;
}

.cookie-pill-face {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* 40px face + the ring's own 2px on each side = the 44px of .btn beside it. */
  min-height: 40px;
  padding: 0.45rem var(--space-md);
  color: var(--color-heading);
  white-space: nowrap;
}

.cookie-accept {
  font: inherit;
  min-height: 44px;
  padding: 0.55rem var(--space-md);
  font-size: var(--fs-caption);
  white-space: nowrap;
}

/* --- Categories ------------------------------------------------------- */

.cookie-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

.cookie-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-sm);
  min-height: 44px;
}

.cookie-row-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
}

/* Switch: a 44px target around a 40×24 track. The track is an element, not a
   ::before — the shape() fallback measures a pill's half-height per element and
   a pseudo never gets that marker. */
.cookie-switch {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-circle);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.cookie-switch-track {
  width: 2.5rem;
  height: 1.5rem;
  border-radius: var(--radius-pill);
  background: var(--glass-hover);
  transition: background-color var(--dur-fast) var(--ease-out);
}

.cookie-switch-knob {
  position: absolute;
  width: 1.125rem;
  height: 1.125rem;
  border-radius: var(--radius-circle);
  background: var(--color-bg);
  transform: translateX(-0.5rem);
  transition: transform var(--dur-fast) var(--ease-out);
}

.cookie-switch[aria-checked="true"] .cookie-switch-track {
  background: var(--color-heading);
}

.cookie-switch[aria-checked="true"] .cookie-switch-knob {
  transform: translateX(0.5rem);
}

/* Necessary: the same track, painted on, not operable. */
.cookie-switch.is-on {
  pointer-events: none;
}

.cookie-switch.is-on .cookie-switch-track {
  background: var(--color-heading);
}

.cookie-switch.is-on .cookie-switch-knob {
  transform: translateX(0.5rem);
}

/* --- Saved ------------------------------------------------------------ */

.cookie-saved {
  flex-direction: row;
  align-items: center;
  gap: var(--space-sm);
}

.cookie-saved .cookie-mark {
  margin-top: 0;
}

.cookie-saved-text {
  margin: 0;
}

/* --- Reduced motion --------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .cookie-card,
  .cookie-card.is-morphing,
  .cookie-view,
  .cookie-switch-track,
  .cookie-switch-knob {
    transition: none;
  }
}
