/*
 * The cookie banner and its settings panel (views/consent.php).
 *
 * Plain CSS, no build: the plugin ships these files as they are. Colours and
 * the font are the theme's tokens (resources/css/theme.css and app.css: the
 * Tailwind theme puts them on :root), with the brand book's values as the
 * fallback for a page without the theme. Stone #EAE8E3 and the description
 * grey #4A4945 have no token in the theme yet, so they are tokens here.
 *
 * Desktop from 768px: a card centred at the bottom, 860 wide for the banner,
 * 560 for the panel. Below 768: a card with 12px margins. position: fixed,
 * so it never moves the page (no CLS).
 *
 * Modal: the backdrop (.bcc-backdrop, after the card) dims the whole page
 * and takes its clicks, and html.bcc-locked stops the page scrolling while
 * the card shows (assets/consent.js). The backdrop is the same light veil in
 * a dark theme.
 *
 * env(safe-area-inset-bottom) is 0 while the theme's viewport meta has no
 * viewport-fit=cover (Safari keeps the page above its own bars then); it is
 * there for the day the theme sets it.
 */
.bcc {
  --bcc-orange: var(--color-orange-secondary, #ff7900);
  --bcc-stone: #eae8e3;
  --bcc-stone-hover: #dfdcd5;
  --bcc-orange-hover: #ff8b26;
  --bcc-off: var(--color-dark-grey, #d7d7d4);
  --bcc-card: var(--color-panel, #ffffff);
  --bcc-ink: #000000;
  --bcc-muted: #4a4945;
  --bcc-shadow: 0 18px 44px -6px rgba(16, 16, 26, 0.18), 0 3px 10px rgba(16, 16, 26, 0.06);

  position: fixed;
  /* Above everything of the theme, the app download window (1000) too: the
     site cannot be used until the visitor answers */
  z-index: 1002;
  left: 0;
  right: 0;
  bottom: 24px;
  width: 860px;
  max-width: calc(100vw - 48px);
  margin: 0 auto;
  color: var(--bcc-ink);
  font-family: var(--sans, 'SF Pro Display', -apple-system, BlinkMacSystemFont, Inter, 'Segoe UI', system-ui, sans-serif);
  font-weight: 500;
  text-align: left;
  -webkit-font-smoothing: antialiased;
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 240ms ease-out,
    transform 240ms ease-out;
}

.bcc[hidden],
.bcc [hidden],
.bcc-backdrop[hidden] {
  display: none !important;
}

.bcc-backdrop {
  position: fixed;
  z-index: 1001;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 240ms ease-out;
  /* No scroll or zoom gesture reaches the page through it */
  touch-action: none;
  overscroll-behavior: contain;
}

.bcc-backdrop.bcc-backdrop--in {
  opacity: 1;
}

html.bcc-locked,
html.bcc-locked body {
  overflow: hidden !important;
  overscroll-behavior: none;
}

/* A page that had a scrollbar keeps its room, so nothing moves sideways */
html.bcc-locked--gutter {
  scrollbar-gutter: stable;
}

.bcc.bcc--in {
  opacity: 1;
  transform: none;
}

.bcc.bcc--panel {
  width: 560px;
}

.bcc *,
.bcc *::before,
.bcc *::after {
  box-sizing: border-box;
}

/* Peeks over the card's top edge; the card, later in the markup, covers its bottom */
.bcc__mascot {
  position: absolute;
  left: 32px;
  top: -32px;
  display: block;
  width: 72px;
  height: 44px;
  overflow: visible;
  pointer-events: none;
}

.bcc__card {
  position: relative;
  border-radius: 28px;
  background: var(--bcc-card);
  box-shadow: var(--bcc-shadow);
}

/* ── Banner ──────────────────────────────────────────────────────────── */

.bcc__banner {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px 18px 18px 28px;
}

.bcc__text {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--bcc-ink);
  font-size: 15px;
  line-height: 20px;
  font-weight: 500;
}

.bcc__inline-link,
.bcc__inline-link:visited {
  color: var(--bcc-ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.bcc__actions {
  flex: none;
  display: flex;
  gap: 8px;
}

/* The dialogs take focus as a modal does; the ring is for their buttons */
.bcc__banner:focus,
.bcc__panel:focus {
  outline: none;
}

.bcc__btn,
.bcc__close,
.bcc__switch {
  margin: 0;
  border: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.bcc__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  color: var(--bcc-ink);
  font-size: 15px;
  line-height: 20px;
  font-weight: 600;
  white-space: nowrap;
}

.bcc__btn--stone {
  background: var(--bcc-stone);
}

/* On orange the text is black, always (brand book) */
.bcc__btn--orange {
  background: var(--bcc-orange);
  color: #000000;
}

.bcc__btn--tall {
  height: 48px;
}

@media (hover: hover) {
  .bcc__btn--stone:hover,
  .bcc__close:hover {
    background: var(--bcc-stone-hover);
  }

  .bcc__btn--orange:hover {
    background: var(--bcc-orange-hover);
  }

  .bcc__inline-link:hover {
    text-decoration-thickness: 2px;
  }
}

.bcc__btn:focus-visible,
.bcc__close:focus-visible,
.bcc__switch:focus-visible,
.bcc__inline-link:focus-visible {
  outline: 2px solid var(--bcc-ink);
  outline-offset: 2px;
}

/* ── Panel ───────────────────────────────────────────────────────────── */

/* A panel taller than the window scrolls inside the card, on every width:
   64 = 24 under the card + 40 for the mascot above it */
.bcc__panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 24px 24px 20px;
  max-height: calc(100vh - 64px);
  max-height: calc(100dvh - 64px - env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}

.bcc__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}

.bcc__title {
  margin: 0;
  color: var(--bcc-ink);
  font-family: inherit;
  font-size: 24px;
  line-height: 1.05;
  font-weight: 500;
  letter-spacing: inherit;
}

.bcc__close {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  background: var(--bcc-stone);
  color: var(--bcc-ink);
}

.bcc__close svg {
  display: block;
}

.bcc__row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--bcc-stone);
}

.bcc__row:nth-last-child(2) {
  border-bottom: none;
}

.bcc__row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bcc__row-name {
  color: var(--bcc-ink);
  font-size: 16px;
  line-height: 1.25;
  font-weight: 600;
}

.bcc__row-desc {
  color: var(--bcc-muted);
  font-size: 14px;
  line-height: 1.2;
  font-weight: 500;
}

.bcc__status {
  flex: none;
  color: var(--bcc-muted);
  font-size: 14px;
  font-weight: 600;
}

.bcc__switch {
  flex: none;
  position: relative;
  width: 48px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  background: var(--bcc-off);
  transition: background-color 160ms ease-out;
}

.bcc__switch[aria-checked='true'] {
  background: var(--bcc-orange);
}

.bcc__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #ffffff;
  transition: transform 160ms ease-out;
}

.bcc__switch[aria-checked='true'] .bcc__knob {
  transform: translateX(20px);
}

/* «Save» across the card, the panel's one answer */
.bcc__panel-actions {
  display: flex;
  margin-top: 8px;
}

.bcc__panel-actions .bcc__btn {
  flex: 1;
}

/* ── Phone ───────────────────────────────────────────────────────────── */

@media (max-width: 767.98px) {
  .bcc,
  .bcc.bcc--panel {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: none;
  }

  .bcc__mascot {
    left: 24px;
    top: -30px;
    width: 66px;
    height: 40px;
  }

  .bcc__banner {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 18px;
  }

  /* «Settings» and «Accept» side by side, the same size, in markup order */
  .bcc__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .bcc__actions .bcc__btn {
    height: 48px;
    padding: 0 12px;
  }

  .bcc__panel-actions .bcc__btn {
    padding: 0 12px;
  }

  .bcc__panel {
    gap: 4px;
    padding: 20px 18px 18px;
  }

  .bcc__head {
    margin-bottom: 4px;
  }

  .bcc__title {
    font-size: 22px;
  }

  .bcc__row {
    gap: 14px;
    padding: 12px 0;
  }

  /* 72 = 12 under the card + the mascot above it, with some air */
  .bcc__panel {
    max-height: calc(100vh - 72px);
    max-height: calc(100dvh - 72px - env(safe-area-inset-bottom, 0px));
  }
}

/* Narrow phones (320–359): a long label may take two lines in its pill */
@media (max-width: 359.98px) {
  .bcc__actions .bcc__btn,
  .bcc__panel-actions .bcc__btn {
    padding: 0 8px;
    white-space: normal;
    line-height: 18px;
    text-align: center;
  }
}

/* Low windows (a phone on its side, a browser with its bars): the card goes
   lower and the mascot away, so the panel gets the whole height */
@media (max-height: 480px) {
  .bcc,
  .bcc.bcc--panel {
    bottom: 12px;
  }

  .bcc__mascot {
    display: none;
  }

  .bcc__panel {
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bcc,
  .bcc-backdrop,
  .bcc__switch,
  .bcc__knob {
    transition: none;
  }

  .bcc {
    transform: none;
  }
}

@media print {
  .bcc,
  .bcc-backdrop {
    display: none !important;
  }
}
