/*
  Consent banner and preference dialog.

  The rules only use the palette custom properties declared by index.html, so the
  banner follows the light and dark themes without a second definition of the
  colours.
*/

.consent-banner {
  position: fixed;
  z-index: 40;
  right: 16px;
  bottom: 16px;
  left: 16px;
  margin: 0 auto;
  width: min(720px, calc(100% - 32px));
  padding: 20px 22px;
  border: 1px solid var(--cp-border);
  border-radius: 0.875rem;
  background: var(--cp-panel-strong);
  box-shadow: var(--cp-shadow);
  backdrop-filter: blur(16px);
}

.consent-banner[hidden] {
  display: none;
}

.consent-banner h2 {
  margin-bottom: 6px;
  font-size: 1rem;
  font-weight: 750;
}

.consent-banner p {
  margin-bottom: 16px;
  color: var(--cp-text-muted);
  font-size: 0.9rem;
}

.consent-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.consent-actions .button {
  min-height: 38px;
  padding: 8px 16px;
  font-size: 0.9rem;
}

.consent-actions .link-button {
  margin-left: auto;
}

/*
  The page gives .button an explicit display, which outranks the user agent rule
  for the hidden attribute, so hiding a consent action has to be stated here.
*/
.consent-actions .button[hidden],
.consent-dialog-actions .button[hidden] {
  display: none;
}

.link-button {
  padding: 8px 4px;
  border: 0;
  background: none;
  color: var(--cp-link);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.link-button:hover,
.link-button:focus-visible {
  text-decoration: underline;
}

.consent-dialog {
  width: min(560px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--cp-border);
  border-radius: 0.875rem;
  background: var(--cp-surface);
  color: var(--cp-text);
  box-shadow: var(--cp-shadow);
}

/*
  A browser without <dialog> support ignores the element's own display rules, so
  the visibility is stated here rather than inherited. The fallback in
  cookie-consent.js toggles the same open attribute the native element uses.
*/
.consent-dialog:not([open]) {
  display: none;
}

.consent-dialog[open] {
  display: block;
  position: fixed;
  z-index: 50;
  top: 50%;
  left: 50%;
  max-height: calc(100vh - 32px);
  overflow: auto;
  transform: translate(-50%, -50%);
}

.consent-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.consent-dialog-body {
  padding: 24px;
}

.consent-dialog h2 {
  margin-bottom: 6px;
  font-size: 1.15rem;
  font-weight: 750;
}

.consent-dialog > form > .consent-dialog-body > p {
  color: var(--cp-text-muted);
  font-size: 0.9rem;
}

.consent-policy {
  max-width: 780px;
}

.consent-policy code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--cp-highlight);
  font-size: 0.85em;
}

.consent-policy .link-button {
  padding-left: 0;
}

.consent-category {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--cp-border);
  border-radius: 0.625rem;
  background: var(--cp-surface-soft);
}

.consent-category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}

.consent-category-head strong {
  font-size: 0.95rem;
}

.consent-category p {
  margin-bottom: 0;
  color: var(--cp-text-muted);
  font-size: 0.85rem;
}

.consent-state {
  color: var(--cp-text-soft);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.consent-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.consent-switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--cp-accent);
}

.consent-switch input:disabled {
  cursor: not-allowed;
}

.consent-note {
  margin: 16px 0 0;
  color: var(--cp-text-soft);
  font-size: 0.82rem;
}

.consent-note[hidden] {
  display: none;
}

.consent-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--cp-border);
  background: var(--cp-bg-elevated);
}

.consent-dialog-actions .button {
  min-height: 38px;
  padding: 8px 16px;
  font-size: 0.9rem;
}

@media (max-width: 620px) {
  .consent-actions .button {
    flex: 1 1 auto;
  }

  .consent-actions .link-button {
    margin-left: 0;
    width: 100%;
    text-align: left;
  }
}
