/* ===================================================================
   Levora — consent banner and preference panel
   Uses the theme tokens defined in levora.css, so it follows the
   visitor's dark/light choice without a second palette.
   =================================================================== */

.consent-root { position: relative; z-index: 9000; }

/* Visually hidden live region for the save/withdraw confirmations. */
.consent-live {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- First layer ------------------------------------------- */

.consent-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9001;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, .18);
}

.consent-banner-inner {
  max-width: var(--max-w, 1120px);
  margin: 0 auto;
  padding: 20px 24px 22px;
  /* The banner is fixed to the bottom edge, which on an iPhone is where
     the home indicator sits. env() resolves to 0 under the default
     viewport-fit=auto, so this costs nothing today and keeps the buttons
     clear of the indicator if the page ever goes viewport-fit=cover. */
  padding-bottom: max(22px, env(safe-area-inset-bottom));
}

.consent-title {
  font-size: 16px; font-weight: 600; letter-spacing: -.3px;
  color: var(--text-0); margin: 0 0 8px;
}

.consent-body {
  font-size: 14px; line-height: 1.65; color: var(--text-1);
  margin: 0 0 10px; max-width: 70ch;
}

.consent-links { font-size: 13px; margin: 0 0 16px; color: var(--text-2); }
.consent-links a { color: var(--text-1); text-decoration: underline; }
.consent-links a:hover { color: var(--text-0); }

.consent-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.consent-btn {
  padding: 10px 20px; border-radius: 8px;
  background: transparent; color: var(--text-0);
  font: inherit; font-size: 14px; font-weight: 500;
  border: 1px solid var(--border); cursor: pointer;
  transition: border-color .2s, background .2s, opacity .2s;
}
.consent-btn:hover { border-color: var(--border-h); background: var(--bg-2); }

.consent-btn-primary {
  background: var(--text-0); color: var(--bg-0);
  border-color: var(--text-0); font-weight: 600;
}
.consent-btn-primary:hover { opacity: .85; background: var(--text-0); }

.consent-btn-quiet {
  border-color: transparent; color: var(--text-1); text-decoration: underline;
}
.consent-btn-quiet:hover { background: transparent; color: var(--text-0); border-color: transparent; }

/* ---------- Preference panel -------------------------------------- */

.consent-overlay {
  position: fixed; inset: 0; z-index: 9002;
  background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; overflow-y: auto;
}

.consent-panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  width: 100%; max-width: 620px;
  padding: 24px;
  /* 100vh on iOS Safari is the LARGE viewport — the height with the URL
     bar hidden — so a panel sized to it can run underneath the browser
     chrome and put "Save choices" out of reach. dvh tracks the visible
     area; the vh line stays first as the fallback for older browsers. */
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .35);
}

.consent-panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}

.consent-x {
  background: none; border: none; cursor: pointer;
  color: var(--text-2); font-size: 26px; line-height: 1;
  padding: 0 4px; margin: -4px -4px 0 0;
}
.consent-x:hover { color: var(--text-0); }

/* ---------- One category ------------------------------------------ */

.consent-row {
  border: 1px solid var(--border);
  border-radius: var(--radius, 8px);
  padding: 14px 16px; margin: 14px 0;
  background: var(--bg-0);
}

.consent-row-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}

.consent-row-title { font-size: 14px; font-weight: 600; color: var(--text-0); }

.consent-row-state {
  font-size: 12px; color: var(--text-2); white-space: nowrap;
}

.consent-row-body {
  font-size: 13px; line-height: 1.6; color: var(--text-1);
  margin: 8px 0 0; max-width: 62ch;
}

/* ---------- Switch -------------------------------------------------
   A real checkbox, visually hidden but focusable, with the track drawn
   beside it — so it is operable by keyboard and announced by a screen
   reader as the checkbox it is. */

.consent-switch {
  display: inline-flex; align-items: center; gap: 10px;
  cursor: pointer; position: relative;
}
.consent-switch.is-locked { cursor: default; }

.consent-switch input {
  position: absolute; opacity: 0; width: 36px; height: 20px; margin: 0;
  cursor: inherit;
}

.consent-track {
  width: 36px; height: 20px; flex: 0 0 36px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  position: relative;
  transition: background .2s, border-color .2s;
}

.consent-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-2);
  transition: transform .2s, background .2s;
}

.consent-switch input:checked ~ .consent-track {
  background: var(--accent); border-color: var(--accent);
}
.consent-switch input:checked ~ .consent-track .consent-thumb {
  transform: translateX(16px); background: #fff;
}
.consent-switch input:disabled ~ .consent-track { opacity: .6; }

.consent-switch input:focus-visible ~ .consent-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- While the modal is open -------------------------------- */

html.consent-open, html.consent-open body { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .consent-btn, .consent-track, .consent-thumb { transition: none; }
}

@media (max-width: 560px) {
  .consent-banner-inner { padding: 16px 16px 18px; }
  .consent-actions { flex-direction: column; }
  .consent-btn { width: 100%; }
  .consent-overlay { padding: 12px; }
  .consent-panel { padding: 18px; }
}
