/* ==================================================================
   Cookie consent: the popup, the settings switches, the footer links
   and the Cookie Settings page's panel and table.

   Every colour comes from the tokens in assets/theme.css, so this
   follows the light/dark toggle like the rest of the site. Class names
   are cc- prefixed so nothing collides with the guide's own CSS.
================================================================== */

.cc-visually-hidden {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* The page behind an open popup does not scroll. The gutter stays so the
   page doesn't shift sideways when the scrollbar goes. */
html.cc-locked {
  overflow: hidden;
  scrollbar-gutter: stable;
}

/* ---------------- the popup ---------------- */

.cc-dialog {
  box-sizing: border-box;
  width: min(36rem, calc(100vw - 2rem));
  max-width: none;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: auto;
  padding: 1.75rem 1.75rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg, 18px);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  font-family: 'Source Sans 3', system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  text-align: start;
}
.cc-dialog::backdrop { background: rgba(8, 14, 25, 0.62); }
.cc-dialog *, .cc-dialog *::before, .cc-dialog *::after { box-sizing: border-box; }

.cc-title {
  font-family: 'Fraunces', serif;
  font-weight: 700;
  font-size: 1.4rem;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 0 2.5rem 0.75rem 0;
}

.cc-intro, .cc-links {
  margin: 0 0 0.75rem;
  color: var(--ink-mid);
  font-size: 0.97rem;
  max-width: 68ch;
}
.cc-dialog a, .cc-panel a { color: var(--accent); text-underline-offset: 2px; }
.cc-dialog a:hover { color: var(--accent-deep); }

.cc-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-mid);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.cc-close:hover { background: var(--card-tint); color: var(--ink); }
.cc-close[hidden] { display: none; }

/* ---------------- buttons ----------------
   "Accept all", "Reject non-essential" and "Save my choices" share one
   style and one column width: no option looks more official than another. */

.cc-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.625rem;
  margin-top: 1.25rem;
}
.cc-btn {
  min-height: 2.75rem;
  padding: 0.625rem 1.125rem;
  border-radius: 999px;
  font-family: 'Source Sans 3', system-ui, sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.cc-btn[hidden] { display: none; }
.cc-btn-choice {
  background: var(--accent);
  border: 1px solid transparent;
  color: #fff;
}
.cc-btn-choice:hover { background: var(--accent-deep); color: #fff; }
/* The dark theme's accent is a light cyan: dark text keeps the contrast. */
:root[data-theme="dark"] .cc-btn-choice,
:root[data-theme="dark"] .cc-btn-choice:hover { color: #06202A; }

.cc-btn-quiet {
  background: transparent;
  border: 1px solid var(--ink-soft);
  color: var(--ink);
}
.cc-btn-quiet:hover { border-color: var(--accent); color: var(--accent); }

.cc-dialog :focus-visible,
.cc-panel :focus-visible,
.cc-footer-link:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
/* Headings take focus only so screen readers start reading there. They
   are not controls, so they get no focus ring (and must win over the
   rule above). */
.cc-dialog [tabindex="-1"]:focus,
[data-cc-settings-heading]:focus { outline: none; }

/* ---------------- categories and switches ---------------- */

.cc-settings {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.cc-settings[hidden] { display: none; }
.cc-settings-title {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--ink);
  margin: 0 0 0.375rem;
}
.cc-settings-intro { margin: 0 0 0.75rem; color: var(--ink-mid); font-size: 0.93rem; }

.cc-cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.625rem; }
.cc-cat {
  border: 1px solid var(--line);
  border-radius: var(--radius, 12px);
  background: var(--card-tint);
  padding: 0.875rem 1rem;
}
.cc-cat-head { display: flex; align-items: center; gap: 0.75rem; }
.cc-cat-name { flex: 1; font-weight: 700; color: var(--ink); cursor: pointer; }
.cc-cat.is-required .cc-cat-name { cursor: default; }
.cc-cat-desc { margin: 0.375rem 0 0; font-size: 0.9rem; color: var(--ink-mid); }

.cc-switch {
  position: relative;
  flex: none;
  display: inline-block;
  width: 2.75rem;
  height: 1.625rem;
}
.cc-switch-input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.cc-switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  border: 2px solid var(--ink-soft);
  background: var(--surface);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.cc-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--ink-soft);
  transition: transform 0.15s ease;
}
.cc-switch-input:checked + .cc-switch-track { background: var(--accent); border-color: var(--accent); }
.cc-switch-input:checked + .cc-switch-track::after { transform: translateX(1.125rem); background: #fff; }
:root[data-theme="dark"] .cc-switch-input:checked + .cc-switch-track::after { background: #06202A; }
.cc-switch-input:focus-visible + .cc-switch-track { outline: 3px solid var(--accent); outline-offset: 2px; }
.cc-switch-input[aria-disabled="true"] { cursor: not-allowed; }
.cc-switch-input[aria-disabled="true"] + .cc-switch-track { opacity: 0.72; }
.cc-switch-state {
  flex: none;
  min-width: 4.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-mid);
}

@media (forced-colors: active) {
  .cc-switch-track { forced-color-adjust: none; border-color: ButtonText; background: Canvas; }
  .cc-switch-track::after { background: ButtonText; }
  .cc-switch-input:checked + .cc-switch-track { background: Highlight; border-color: Highlight; }
  .cc-switch-input:checked + .cc-switch-track::after { background: HighlightText; }
}

.cc-cat-items { margin-top: 0.5rem; font-size: 0.85rem; color: var(--ink-mid); }
.cc-cat-items summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.cc-cat-items ul { margin: 0.5rem 0 0; padding-left: 1.1rem; display: grid; gap: 0.375rem; }
.cc-cat-items code, .cc-table code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  overflow-wrap: break-word;   /* breaks at hyphens first, mid-word only if it must */
  color: var(--ink);
}
.cc-meta { display: block; margin-top: 0.2rem; font-size: 0.78rem; font-weight: 400; color: var(--ink-soft); }
.cc-dur { color: var(--ink-soft); }

/* ---------------- footer links (every page) ---------------- */

.cc-footer-links { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; }
.cc-footer-link[aria-current="page"] { font-weight: 700; }

/* ---------------- the Cookie Settings page ---------------- */

.cc-panel .cc-actions { grid-template-columns: repeat(3, 1fr); }
.cc-current { margin: 0 0 1rem; color: var(--ink-mid); }
.cc-status { margin: 0.75rem 0 0; min-height: 1.5em; font-weight: 600; color: var(--pass); }

.cc-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; box-shadow: none; }
.cc-table caption {
  caption-side: top;
  text-align: start;
  font-weight: 700;
  color: var(--ink);
  padding: 0 0 0.5rem;
}
.cc-table th, .cc-table td {
  text-align: start;
  vertical-align: top;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--line);
  color: var(--ink-mid);
}
.cc-table thead th {
  background: var(--card-tint);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 700;
}
.cc-table th[scope="row"] { color: var(--ink); font-weight: 600; }
.cc-table td:nth-child(3) { min-width: 8rem; }
.cc-table td:nth-child(4) { white-space: nowrap; }

/* Narrow screens: each row becomes a labelled card instead of a table
   that needs sideways scrolling. */
@media (max-width: 44rem) {
  .cc-table thead {
    position: absolute;
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
    overflow: hidden;
  }
  .cc-table, .cc-table caption, .cc-table tbody, .cc-table tr, .cc-table th[scope="row"], .cc-table td { display: block; }
  .cc-table tr {
    border: 1px solid var(--line);
    border-radius: var(--radius, 12px);
    margin-bottom: 0.75rem;
    padding: 0.625rem 0.875rem;
    background: var(--surface);
  }
  .cc-table th[scope="row"], .cc-table td { border: 0; padding: 0.2rem 0; }
  .cc-table td::before {
    content: attr(data-label) ": ";
    content: attr(data-label) ": " / "";
    font-weight: 700;
    color: var(--ink);
  }
}

/* ---------------- narrow screens ---------------- */

@media (max-width: 34rem) {
  .cc-dialog { padding: 1.375rem 1.125rem 1.125rem; }
  .cc-title { font-size: 1.25rem; }
  .cc-actions, .cc-panel .cc-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .cc-btn, .cc-switch-track, .cc-switch-track::after { transition: none; }
}
