/* Cookie consent banner and preferences dialog. Markup is injected by
   consent.js. Tokens fall back to the brand values, so this drops into any
   page; link it after that page's own <style> so it wins at equal specificity.

   Centred by transform, not `inset:0; margin:auto`: with top and bottom both
   pinned, an auto height resolves to "fill" instead of hugging the content. */
.cc-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  z-index: 1000;
  width: min(540px, calc(100vw - 32px));
  max-height: min(84vh, 680px);
  overflow-y: auto;
  padding: 0;
  border: 1px solid var(--border, rgba(44, 62, 80, 0.18));
  border-radius: 14px;
  background: #fff;
  color: var(--slate, #2C3E50);
  box-shadow: 0 20px 60px rgba(44, 62, 80, 0.28);
  animation: cc-rise 320ms ease-out both;
}

.cc-banner:not([open]) { display: none; }

/* Focused programmatically only. */
.cc-banner:focus { outline: none; }

.cc-banner::backdrop { background: rgba(44, 62, 80, 0.45); }

.cc-card { padding: 26px 26px 22px; }

.cc-copy { margin-bottom: 22px; }

.cc-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--slate-muted, #4A5968);
  margin: 0 0 6px;
}

.cc-text {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--slate, #2C3E50);
  margin: 0;
}

.cc-link {
  color: var(--cyan, #167C89);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.cc-link:hover { color: var(--slate, #2C3E50); }

/* Buttons ------------------------------------------------------------- */

.cc-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

/* Keeps "Preferences" left and the two decisions together on the right. */
.cc-actions .cc-btn-quiet { margin-right: auto; }

/* Reject and accept are the same size and weight on purpose. */
.cc-btn {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 11px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 180ms ease, color 180ms ease, border-color 180ms ease;
}

.cc-btn-solid {
  background: var(--orange-cta, #C2410C);
  border-color: var(--orange-cta, #C2410C);
  color: #fff;
}

.cc-btn-solid:hover {
  background: var(--orange-cta-hover, #9A3412);
  border-color: var(--orange-cta-hover, #9A3412);
}

.cc-btn-outline {
  background: transparent;
  border-color: rgba(44, 62, 80, 0.32);
  color: var(--slate, #2C3E50);
}

.cc-btn-outline:hover { background: rgba(44, 62, 80, 0.07); }

.cc-btn-quiet {
  background: transparent;
  border-color: transparent;
  color: var(--slate-muted, #4A5968);
  padding-left: 8px;
  padding-right: 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cc-btn-quiet:hover { color: var(--slate, #2C3E50); }

.cc-btn:focus-visible,
.cc-toggle:focus-visible,
.cc-link:focus-visible {
  outline: 3px solid var(--focus, #0B5CAD);
  outline-offset: 3px;
}

/* Preferences dialog --------------------------------------------------- */

/* Centred as above; works for a native modal and the showModal() fallback. */
.cc-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  z-index: 1001;
  width: min(560px, calc(100vw - 32px));
  max-height: min(84vh, 680px);
  overflow-y: auto;
  padding: 0;
  border: 1px solid var(--border, rgba(44, 62, 80, 0.18));
  border-radius: 14px;
  background: #fff;
  color: var(--slate, #2C3E50);
  box-shadow: 0 20px 60px rgba(44, 62, 80, 0.28);
}

.cc-modal:not([open]) { display: none; }

.cc-modal::backdrop { background: rgba(44, 62, 80, 0.45); }

.cc-modal-inner { padding: 26px 26px 22px; }

.cc-modal .cc-title { font-size: 0.8125rem; margin-bottom: 10px; }

.cc-modal .cc-text { margin-bottom: 20px; }

.cc-list {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  border-top: 1px solid var(--border, rgba(44, 62, 80, 0.18));
}

/* margin:0 is not redundant: privacy.html gives bare `li` a bottom margin. */
.cc-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin: 0;
  padding: 16px 0;
  border-bottom: 1px solid var(--border, rgba(44, 62, 80, 0.18));
}

.cc-row-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.cc-row-title {
  display: block;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--slate, #2C3E50);
  margin-bottom: 3px;
}

.cc-row-text {
  display: block;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--slate-muted, #4A5968);
}

.cc-actions-modal { justify-content: flex-end; }

/* The checkbox itself is restyled, so keyboard behaviour stays native. */
.cc-toggle {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  position: relative;
  width: 44px;
  height: 24px;
  margin: 2px 0 0;
  border-radius: 999px;
  border: 1px solid var(--border, rgba(44, 62, 80, 0.18));
  background: rgba(44, 62, 80, 0.22);
  cursor: pointer;
  transition: background-color 180ms ease;
}

.cc-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  transition: transform 180ms ease;
}

.cc-toggle:checked { background: var(--orange-cta, #C2410C); }

.cc-toggle:checked::after { transform: translateX(20px); }

.cc-toggle:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Footer trigger ------------------------------------------------------- */

/* Sits among real anchors, so it sheds the UA button defaults. */
.cc-open {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--border, rgba(44, 62, 80, 0.18));
  border-radius: 0;
  padding: 0;
  cursor: pointer;
  transition: color 200ms ease, border-color 200ms ease;
}

.cc-open:hover {
  color: var(--cyan, #167C89);
  border-color: var(--cyan, #167C89);
}

.cc-open:focus-visible {
  outline: 3px solid var(--focus, #0B5CAD);
  outline-offset: 3px;
  border-radius: 4px;
}

/* The centring translate must be repeated here: an animated `transform`
   replaces the rule's own, and `both` keeps the last frame applied. */
@keyframes cc-rise {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

@media (max-width: 640px) {
  .cc-card { padding: 22px 18px 18px; }
  .cc-modal-inner { padding: 22px 18px 18px; }
  /* Stacked, with the two decisions kept together on one row. */
  .cc-actions .cc-btn-outline,
  .cc-actions .cc-btn-solid { flex: 1 1 140px; }
  .cc-actions .cc-btn-quiet {
    flex: 1 0 100%;
    order: -1;
    margin-right: 0;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cc-banner,
  .cc-btn,
  .cc-toggle,
  .cc-toggle::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
