/* =============================================================================
   COOKIE CONSENT — banner, preferences panel, no-JS fallback
   -----------------------------------------------------------------------------
   Uses the shared tokens from theme.css (--bg-elevated, --border-strong,
   --text-*, --accent*, --radius-*, --shadow-*, --z-*) so it inherits dark/light
   automatically. Nothing here hardcodes a theme colour except the pink brand
   gradient, which is identical in both.
   ========================================================================== */

.sp-root {
  /* The root is a pure container — it must never intercept pointer events or it
     would swallow clicks across the whole viewport. */
  pointer-events: none;
}

/* Self-contained box model. landing.css sets this globally, but this partial is
   also included on dashboard/admin/checkout pages that never load landing.css —
   without it the banner's horizontal padding is added ON TOP of its width and
   the card overflows the viewport. */
.sp-root, .sp-root *, .sp-root *::before, .sp-root *::after,
.sp-wall, .sp-wall *, .sp-wall *::before, .sp-wall *::after {
  box-sizing: border-box;
}

.sp-root [hidden] { display: none !important; }

/* ---------- Banner ---------- */

.sp-banner {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(16px);
  width: min(100%, var(--w-content, 1340px));
  /* Never taller than the screen. Without this the banner can grow past the
     viewport on small/short devices and become unusable — its buttons end up
     off-screen with nothing to scroll. */
  max-height: 100dvh;
  z-index: 2147483000; /* above every in-app overlay, below nothing */
  padding: 0 16px 16px;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.28s var(--ease-out, ease), transform 0.28s var(--ease-out, ease);
}

.sp-banner.sp-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.sp-banner-inner {
  display: flex;
  align-items: flex-start;
  gap: 28px;
  padding: 20px 24px;
  border-radius: var(--radius-lg, 16px);
  background: var(--bg-elevated, #160d1f);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.18));
  box-shadow: var(--shadow-lg, 0 18px 50px rgba(0, 0, 0, 0.5));
  /* Last-resort escape valve: if the copy plus buttons still cannot fit a very
     short viewport, the card scrolls internally rather than overflowing it. */
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* A hairline of brand colour along the top edge — ties it to the product
   without shouting over the page content behind it. */
.sp-banner-inner::before {
  content: "";
  position: absolute;
  inset: 0 24px auto;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, #EC4899, #C026D3, #8B5CF6);
  opacity: 0.9;
}

.sp-banner-inner { position: relative; }

.sp-banner-copy { flex: 1 1 auto; min-width: 0; }

.sp-banner-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary, #fbeef6);
  letter-spacing: var(--tracking-tight, -0.02em);
}

.sp-banner-icon { font-size: 18px; line-height: 1; }

.sp-banner-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-body, #cbb8c8);
}

.sp-banner-desc strong { color: var(--text-primary, #fbeef6); font-weight: 700; }

.sp-banner-desc a,
.sp-modal-intro a,
.sp-cat-desc a,
.sp-thirdparty a {
  color: var(--accent, #EC4899);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sp-banner-desc a:hover,
.sp-modal-intro a:hover,
.sp-cat-desc a:hover,
.sp-thirdparty a:hover { color: var(--accent-strong, #DB2777); }

.sp-banner-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.sp-btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Buttons ----------
   Accept and reject are the same size, weight and shape. Only the fill differs,
   which is what the EDPB "equally easy to refuse" guidance asks for — a greyed
   or text-only reject next to a solid accept is a dark pattern. */

.sp-btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm, 8px);
  padding: 10px 18px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.sp-btn:hover { transform: translateY(-1px); }
.sp-btn:active { transform: translateY(0); }

.sp-btn:focus-visible {
  outline: 2px solid var(--accent, #EC4899);
  outline-offset: 2px;
}

.sp-btn-primary {
  background: linear-gradient(135deg, #EC4899, #C026D3);
  color: #fff;
  box-shadow: var(--shadow-brand, 0 8px 24px rgba(236, 72, 153, 0.3));
}

.sp-btn-primary:hover { filter: brightness(1.07); }

.sp-btn-secondary {
  background: var(--bg-elevated-2, #1f1329);
  color: var(--text-primary, #fbeef6);
  border-color: var(--border-strong, rgba(255, 255, 255, 0.18));
}

.sp-btn-secondary:hover { border-color: var(--accent, #EC4899); }

.sp-btn-ghost {
  background: transparent;
  color: var(--text-body, #cbb8c8);
  border-color: var(--border-strong, rgba(255, 255, 255, 0.18));
}

.sp-btn-ghost:hover {
  color: var(--text-primary, #fbeef6);
  border-color: var(--accent, #EC4899);
}

/* The nuclear option. Deliberately quieter than the three real choices — it is
   a genuine right, not a recommended path, and it ends the session. */
.sp-reject-all {
  appearance: none;
  background: none;
  border: 0;
  padding: 2px 0;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.5;
  color: var(--text-subtle, #7c6c82);
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.sp-reject-all:hover { color: var(--text-body, #cbb8c8); }

.sp-reject-all:focus-visible {
  outline: 2px solid var(--accent, #EC4899);
  outline-offset: 2px;
  border-radius: 3px;
}

.sp-reject-note {
  display: block;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-subtle, #7c6c82);
  opacity: 0.85;
}

/* ---------- Preferences modal ---------- */

.sp-modal {
  position: fixed;
  inset: 0;
  z-index: 2147483001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: auto;
}

.sp-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 2, 10, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

[data-theme="light"] .sp-modal-backdrop { background: rgba(74, 8, 32, 0.42); }

.sp-modal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 640px);
  max-height: min(88vh, 780px);
  border-radius: var(--radius-lg, 16px);
  background: var(--bg-elevated, #160d1f);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.18));
  box-shadow: var(--shadow-lg, 0 18px 50px rgba(0, 0, 0, 0.5));
  overflow: hidden;
}

.sp-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.12));
}

.sp-modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary, #fbeef6);
}

.sp-modal-close {
  appearance: none;
  background: none;
  border: 0;
  font-size: 26px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  color: var(--text-subtle, #7c6c82);
  transition: color 0.15s ease;
}

.sp-modal-close:hover { color: var(--text-primary, #fbeef6); }

.sp-modal-close:focus-visible {
  outline: 2px solid var(--accent, #EC4899);
  outline-offset: 2px;
  border-radius: 4px;
}

.sp-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 22px;
}

.sp-modal-intro {
  margin: 0 0 18px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-body, #cbb8c8);
}

.sp-modal-intro strong { color: var(--text-primary, #fbeef6); }

/* ---------- Category rows ---------- */

.sp-cat {
  padding: 14px 16px;
  margin-bottom: 10px;
  border-radius: var(--radius-md, 12px);
  background: var(--bg-glass, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
}

.sp-cat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

.sp-cat-name {
  display: inline;
  margin: 0 8px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary, #fbeef6);
}

.sp-cat-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: var(--radius-pill, 999px);
  background: var(--bg-elevated-2, #1f1329);
  color: var(--text-muted, #9c8ba0);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  vertical-align: middle;
}

.sp-cat-tag-req {
  background: var(--accent-tint, rgba(236, 72, 153, 0.14));
  color: var(--accent, #EC4899);
  border-color: transparent;
}

.sp-cat-tag-none {
  background: rgba(16, 185, 129, 0.12);
  color: #10B981;
  border-color: transparent;
}

[data-theme="light"] .sp-cat-tag-none { color: #047857; }

.sp-cat-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-body, #cbb8c8);
}

.sp-cat-desc code {
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: var(--radius-xs, 4px);
  background: var(--bg-elevated-2, #1f1329);
  color: var(--text-primary, #fbeef6);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- Toggle switch ---------- */

.sp-switch {
  flex: 0 0 auto;
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.sp-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.sp-switch-track {
  display: block;
  width: 42px;
  height: 24px;
  border-radius: var(--radius-pill, 999px);
  background: var(--bg-elevated-2, #1f1329);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.18));
  transition: background 0.2s ease, border-color 0.2s ease;
}

.sp-switch-thumb {
  display: block;
  width: 18px;
  height: 18px;
  margin: 2px;
  border-radius: 50%;
  background: var(--text-subtle, #7c6c82);
  transition: transform 0.2s var(--ease-out, ease), background 0.2s ease;
}

.sp-switch input:checked ~ .sp-switch-track {
  background: linear-gradient(135deg, #EC4899, #C026D3);
  border-color: transparent;
}

.sp-switch input:checked ~ .sp-switch-track .sp-switch-thumb {
  transform: translateX(18px);
  background: #fff;
}

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

.sp-switch-locked { cursor: not-allowed; }
.sp-switch-locked input { cursor: not-allowed; }

.sp-switch input:disabled ~ .sp-switch-track {
  opacity: 0.65;
  background: linear-gradient(135deg, #EC4899, #C026D3);
  border-color: transparent;
}

.sp-switch input:disabled ~ .sp-switch-track .sp-switch-thumb {
  transform: translateX(18px);
  background: #fff;
}

/* ---------- Third-party note ---------- */

.sp-thirdparty {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border, rgba(255, 255, 255, 0.12));
}

.sp-thirdparty-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #9c8ba0);
}

.sp-thirdparty p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-body, #cbb8c8);
}

/* ---------- Modal footer ---------- */

.sp-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 22px;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  background: var(--bg-glass, rgba(255, 255, 255, 0.05));
}

.sp-modal-foot-right { display: flex; gap: 10px; flex-wrap: wrap; }

.sp-modal-nuke {
  padding: 12px 22px 16px;
  border-top: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  background: var(--bg-glass, rgba(255, 255, 255, 0.05));
}

/* ---------- No-JS fallback ---------- */

.sp-noscript {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 20px;
  pointer-events: auto;
  background: var(--bg-elevated, #160d1f);
  border-top: 1px solid var(--border-strong, rgba(255, 255, 255, 0.18));
}

.sp-noscript p {
  margin: 0;
  flex: 1 1 320px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-body, #cbb8c8);
}

.sp-noscript a { color: var(--accent, #EC4899); }
.sp-noscript-form { margin: 0; }

/* ---------- Blocking wall (cookies-blocked.ejs) ---------- */

.sp-wall {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: var(--bg, #0a0510);
}

.sp-wall-card {
  width: min(100%, var(--w-prose, 760px));
  padding: 40px;
  border-radius: var(--radius-lg, 16px);
  background: var(--bg-elevated, #160d1f);
  border: 1px solid var(--border-strong, rgba(255, 255, 255, 0.18));
  box-shadow: var(--shadow-lg, 0 18px 50px rgba(0, 0, 0, 0.5));
  text-align: center;
}

.sp-wall-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary, #fbeef6);
  text-decoration: none;
}

.sp-wall-logo img { border-radius: 8px; object-fit: contain; }

.sp-wall-icon { font-size: 44px; line-height: 1; margin-bottom: 12px; }

.sp-wall h1 {
  margin: 0 0 12px;
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 900;
  color: var(--text-primary, #fbeef6);
  letter-spacing: var(--tracking-tight, -0.02em);
}

.sp-wall p {
  margin: 0 auto 14px;
  max-width: 56ch;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-body, #cbb8c8);
}

.sp-wall-list {
  max-width: 46ch;
  margin: 0 auto 22px;
  padding: 16px 20px 16px 38px;
  text-align: left;
  border-radius: var(--radius-md, 12px);
  background: var(--bg-glass, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
}

.sp-wall-list li {
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-body, #cbb8c8);
  margin-bottom: 4px;
}

.sp-wall-list li:last-child { margin-bottom: 0; }

.sp-wall-list code {
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: var(--radius-xs, 4px);
  background: var(--bg-elevated-2, #1f1329);
  color: var(--text-primary, #fbeef6);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.sp-wall-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.sp-wall-actions .sp-btn { padding: 12px 24px; font-size: 14px; }

.sp-wall-links {
  font-size: 12.5px;
  color: var(--text-subtle, #7c6c82);
}

.sp-wall-links a {
  color: var(--text-muted, #9c8ba0);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sp-wall-links a:hover { color: var(--accent, #EC4899); }

/* ---------- Footer "Cookie settings" trigger ---------- */

.sp-settings-link {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.sp-settings-link:hover { color: var(--accent, #EC4899); }

.sp-settings-link:focus-visible {
  outline: 2px solid var(--accent, #EC4899);
  outline-offset: 2px;
  border-radius: 3px;
}

/* The trigger is a <button> (it opens a dialog, it does not navigate) so the
   footers' `a`-scoped rules miss it. Match its siblings explicitly. */
.footer-legal .sp-settings-link {
  font-size: 13px;
  color: var(--text-muted);
}

.footer-legal .sp-settings-link:hover { color: var(--text-primary); }

.app-footer .sp-settings-link {
  font-size: 12px;
  color: var(--text-muted);
}

.app-footer .sp-settings-link:hover { color: var(--text-secondary); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .sp-banner-inner {
    flex-direction: column;
    gap: 16px;
    padding: 18px;
  }

  .sp-banner-actions { width: 100%; }
  .sp-btn-row { width: 100%; }
  /* Row layout: share the width evenly, wrapping at 140px. flex-basis here is a
     WIDTH only because .sp-btn-row is still a row at this breakpoint — the 560px
     block below turns it into a column and MUST reset this. */
  .sp-btn-row .sp-btn { flex: 1 1 140px; }
}

@media (max-width: 560px) {
  .sp-banner { padding: 0 8px 8px; }
  .sp-banner-desc { font-size: 12.5px; }
  .sp-btn-row { flex-direction: column; }
  /* Resetting flex is mandatory, not cosmetic: the 900px rule above still
     applies here, and once the row becomes a column its `flex-basis: 140px`
     retargets from width to HEIGHT — giving three ~140px-tall buttons and a
     ~700px banner that swallows a phone screen. */
  .sp-btn-row .sp-btn { flex: 0 0 auto; width: 100%; }

  .sp-modal { padding: 0; align-items: flex-end; }

  .sp-modal-card {
    max-height: 92dvh;
    border-radius: var(--radius-lg, 16px) var(--radius-lg, 16px) 0 0;
    border-bottom: 0;
  }

  .sp-modal-foot { flex-direction: column-reverse; align-items: stretch; }
  .sp-modal-foot .sp-btn { width: 100%; }
  .sp-modal-foot-right { flex-direction: column; }

  .sp-wall-card { padding: 28px 20px; }
  .sp-wall-actions .sp-btn { width: 100%; }
}

/* Respect reduced-motion: keep the state change, drop the travel. */
@media (prefers-reduced-motion: reduce) {
  .sp-banner,
  .sp-btn,
  .sp-switch-track,
  .sp-switch-thumb {
    transition: none;
  }

  .sp-banner { transform: translateX(-50%); }
  .sp-banner.sp-visible { transform: translateX(-50%); }
  .sp-btn:hover { transform: none; }
}
