/**
 * VLP Cookie Consent: full-width bar over the bottom edge of the screen.
 * Colours come from the VoiceLinkPA theme tokens when present (they follow the five-element
 * colour set) and fall back to the default navy / cyan with any other theme.
 */

.vlpcc {
  --vlpcc-bg-rgb: var(--vlp-navy-900-rgb, 8 27 44);
  --vlpcc-text: #f8fafc;
  --vlpcc-muted: #cbd5e1;
  --vlpcc-accent: var(--vlp-cyan-300, #7dd3fc);
  --vlpcc-line: rgba(255, 255, 255, 0.14);

  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 100000;
  font-family: var(--vlp-font-body, var(--vlp-font-thai, system-ui, -apple-system, 'Segoe UI', sans-serif));
  font-size: 15px;
  line-height: 1.6;
  color: var(--vlpcc-text);
}
.vlpcc[hidden],
.vlpcc [hidden],
.vlpcc-reopen[hidden] { display: none !important; }

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

.vlpcc__bar {
  background: rgb(var(--vlpcc-bg-rgb) / 0.9);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border-top: 1px solid var(--vlpcc-line);
  box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.28);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  animation: vlpcc-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}
/* Without blur support the bar stays readable by being a little more opaque. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .vlpcc__bar { background: rgb(var(--vlpcc-bg-rgb) / 0.96); }
}
/* A thin brand line along the top edge. */
.vlpcc__bar::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--vlp-cyan-400, #38bdf8), var(--vlp-emerald-400, #34d399));
}

.vlpcc__inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 24px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px 24px;
  align-items: center;
}

.vlpcc__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--vlpcc-line);
  color: var(--vlpcc-accent);
}
.vlpcc__icon svg { width: 26px; height: 26px; }

.vlpcc__title {
  margin: 0 0 2px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--vlpcc-text);
}
.vlpcc__title:focus { outline: none; }
.vlpcc__msg {
  margin: 0;
  color: var(--vlpcc-muted);
  max-width: 78ch;
}
.vlpcc__msg a,
.vlpcc__link {
  color: var(--vlpcc-accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
}
.vlpcc__msg a:hover,
.vlpcc__link:hover { color: #ffffff; }
.vlpcc__link {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 0;
  background: none;
  border: 0;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.vlpcc__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* "Accept all" and "Reject all" look the same on purpose: refusing must be as easy as accepting (GDPR / PDPA guidance). */
.vlpcc__btn {
  min-height: 44px;
  padding: 10px 22px;
  border-radius: 999px;
  border: 2px solid #ffffff;
  background: #ffffff;
  color: rgb(var(--vlpcc-bg-rgb));
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.2s;
}
.vlpcc__btn:hover { background: var(--vlpcc-accent); border-color: var(--vlpcc-accent); }
.vlpcc__btn:active { transform: translateY(1px); }
.vlpcc__btn--ghost {
  background: transparent;
  color: var(--vlpcc-text);
  border-color: rgba(255, 255, 255, 0.55);
}
.vlpcc__btn--ghost:hover,
.vlpcc__btn--ghost[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.1);
  border-color: #ffffff;
  color: #ffffff;
}

.vlpcc button:focus-visible,
.vlpcc a:focus-visible,
.vlpcc input:focus-visible,
.vlpcc-reopen:focus-visible {
  outline: 3px solid var(--vlpcc-accent, #7dd3fc);
  outline-offset: 3px;
}

/* ---------- Settings panel ---------- */

.vlpcc__prefs {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 20px;
  max-height: min(55vh, 480px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.vlpcc__cats {
  margin: 0;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.vlpcc__legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.vlpcc__cat {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--vlpcc-line);
}
.vlpcc__cat-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.vlpcc__cat-label { font-weight: 700; color: var(--vlpcc-text); cursor: pointer; }
.vlpcc__cat-desc { font-size: 13.5px; line-height: 1.55; color: var(--vlpcc-muted); }
.vlpcc__always {
  flex-shrink: 0;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--vlp-emerald-300, #6ee7b7);
  white-space: nowrap;
}

/* Switch: a real checkbox, so keyboard, forms and screen readers work as usual. */
.vlpcc__switch {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  position: relative;
  width: 48px;
  height: 28px;
  margin: 2px 0 0;
  border-radius: 999px;
  border: 2px solid #94a3b8;
  background: transparent;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}
.vlpcc__switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #cbd5e1;
  transition: transform 0.2s, background-color 0.2s;
}
.vlpcc__switch:checked {
  background: var(--vlpcc-accent);
  border-color: var(--vlpcc-accent);
}
.vlpcc__switch:checked::after {
  transform: translateX(20px);
  background: rgb(var(--vlpcc-bg-rgb));
}

.vlpcc__gpc {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border-left: 3px solid var(--vlpcc-accent);
  font-size: 13.5px;
  color: var(--vlpcc-muted);
}
/* Stays at the bottom of the scrolling panel, so "save" is always in reach on small screens. */
.vlpcc__prefs-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
  padding-top: 10px;
  background: linear-gradient(rgb(var(--vlpcc-bg-rgb) / 0), rgb(var(--vlpcc-bg-rgb) / 0.95) 10px);
}

/* ---------- Reopen button and helpers ---------- */

.vlpcc-reopen {
  position: fixed;
  left: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 9990;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgb(var(--vlp-navy-900-rgb, 8 27 44) / 0.88);
  color: var(--vlp-cyan-300, #7dd3fc);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transition: transform 0.2s;
}
.vlpcc-reopen:hover { transform: scale(1.06); }
.vlpcc-reopen svg { width: 22px; height: 22px; }

.vlpcc-inline-btn {
  padding: 0;
  background: none;
  border: 0;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.vlpcc-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Keyboard focus stays visible above the bar while it is open (WCAG 2.4.11). */
html.vlpcc-open { scroll-padding-bottom: calc(var(--vlpcc-h, 0px) + 16px); }

@keyframes vlpcc-in {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ---------- Smaller screens ---------- */

@media (max-width: 1024px) {
  .vlpcc__inner { grid-template-columns: auto minmax(0, 1fr); }
  .vlpcc__actions { grid-column: 1 / -1; justify-content: stretch; }
  .vlpcc__actions .vlpcc__btn { flex: 1 1 0; }
  .vlpcc__cats { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .vlpcc { font-size: 14px; }
  .vlpcc__inner { padding: 16px; gap: 12px; grid-template-columns: minmax(0, 1fr); }
  .vlpcc__icon { display: none; }
  .vlpcc__title { font-size: 16px; }
  .vlpcc__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .vlpcc__actions .vlpcc__btn { padding: 10px 12px; white-space: normal; }
  .vlpcc__actions .vlpcc__btn--ghost { grid-column: 1 / -1; order: 3; }
  .vlpcc__prefs { padding: 0 16px 16px; max-height: 50vh; }
  .vlpcc__prefs-actions .vlpcc__btn { width: 100%; }
  .vlpcc-reopen { left: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  .vlpcc__bar { animation: none; }
  .vlpcc__btn,
  .vlpcc__switch,
  .vlpcc__switch::after,
  .vlpcc-reopen { transition: none; }
}

@media print {
  .vlpcc,
  .vlpcc-reopen { display: none !important; }
}
