/* Cookie consent banner + preferences modal.
   Standalone stylesheet (not run through the Tailwind build) so it works
   without requiring `npm run watch`/build -- loaded directly in base.html.
   Uses the same CSS custom properties as the rest of the site (input.css)
   so it follows the light/dark theme automatically. */

.cc-banner {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 300;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.12);
  padding: 20px;
  /* Fail-safe regardless of viewport/content: this banner must never be
     able to cover the full screen (found live on mobile, 2026-09-14 SEO
     audit -- it was hiding every tool's search bar/dropzone behind it on
     first paint). Scrolls internally in the rare case content still
     doesn't fit instead of growing past this. */
  max-height: 60vh;
  overflow-y: auto;
}
.cc-banner[hidden] { display: none; }

.cc-banner-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
}

.cc-banner-text { flex: 1 1 420px; min-width: 260px; }
.cc-banner-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 16px;
  color: var(--color-text);
  margin: 0 0 6px;
}
.cc-banner-desc {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--color-text-muted);
  margin: 0;
}
.cc-banner-links { margin-top: 8px; font-size: 12.5px; }
.cc-banner-links a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cc-banner-links span { color: var(--color-text-muted); margin: 0 6px; }

.cc-banner-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  flex: 0 0 auto;
}

.cc-btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  padding: 11px 18px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  min-height: 42px;
}
.cc-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.cc-btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.cc-btn-primary:hover { background: var(--color-primary-dark); }
.cc-btn-secondary {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text);
}
.cc-btn-secondary:hover { border-color: var(--color-primary); color: var(--color-primary); }
.cc-btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 11px 6px;
}
.cc-btn-ghost:hover { color: var(--color-primary); }

/* ── Preferences modal ─────────────────────────────────────────────── */

.cc-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 310;
  background: rgba(10, 14, 26, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.cc-modal-overlay[hidden] { display: none; }

.cc-modal {
  background: var(--color-surface);
  border-radius: 18px;
  border: 1px solid var(--color-border);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.cc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.cc-modal-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 17px;
  color: var(--color-text);
  margin: 0;
}
.cc-modal-close {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  min-width: 36px;
  min-height: 36px;
}
.cc-modal-close:hover { background: var(--color-surface-2); color: var(--color-text); }
.cc-modal-close:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.cc-modal-body {
  padding: 6px 22px;
  overflow-y: auto;
}

.cc-cat {
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border);
}
.cc-cat:last-child { border-bottom: none; }

.cc-cat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.cc-cat-name {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--color-text);
  margin: 0;
}
.cc-cat-desc {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--color-text-muted);
  margin: 6px 0 0;
}
.cc-cat-always {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--color-primary);
  white-space: nowrap;
}

/* Accessible toggle switch — real checkbox underneath, visually hidden,
   so it's still a native control for keyboard/screen readers. */
.cc-toggle { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.cc-toggle input {
  position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer;
}
.cc-toggle-track {
  position: absolute; inset: 0;
  background: var(--color-border);
  border-radius: 999px;
  transition: background-color .15s ease;
  pointer-events: none;
}
.cc-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s ease;
}
.cc-toggle input:checked + .cc-toggle-track { background: var(--color-primary); }
.cc-toggle input:checked + .cc-toggle-track::after { transform: translateX(18px); }
.cc-toggle input:focus-visible + .cc-toggle-track { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.cc-toggle input:disabled + .cc-toggle-track { opacity: 0.6; cursor: not-allowed; }

.cc-modal-footer {
  padding: 16px 22px 20px;
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.cc-modal-footer .cc-btn { flex: 1 1 auto; text-align: center; }

/* Mobile: a compact bottom sheet instead of the desktop's full multi-line
   panel with three stacked full-width buttons -- that combination was tall
   enough to cover the entire viewport (search bar, dropzone, everything)
   on first paint, blocking every tool page's primary content behind a
   compliance prompt. The full description and both secondary choices
   (Reject Optional / Manage Preferences) stay present and one tap away,
   nothing here removes a consent option -- only how much space it takes
   before the visitor interacts with it. */
@media (max-width: 640px) {
  .cc-banner { padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px)); }
  .cc-banner-inner { flex-direction: column; align-items: stretch; gap: 12px; }
  /* .cc-banner-text's desktop rule is flex: 1 1 420px -- a sensible starting
     WIDTH on the desktop row layout, but flex-basis follows the main axis,
     which this column layout has just flipped to vertical. Left alone,
     that same "420" becomes a 420px-tall box regardless of how little text
     is actually in it -- the real reason the mobile banner was tall enough
     to cover the whole viewport even before anything else here changed. */
  .cc-banner-text { flex: 1 1 auto; min-width: 0; }

  .cc-banner-title { font-size: 14.5px; margin-bottom: 3px; }
  .cc-banner-desc {
    font-size: 12.5px;
    /* Full text stays in the DOM (still read by screen readers, still
       there if the visitor scrolls the banner) -- only clamped visually
       so it can't push the buttons off-screen on its own. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .cc-banner-links { margin-top: 6px; }

  .cc-banner-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .cc-banner-actions .cc-btn { padding: 9px 10px; font-size: 12.5px; }
  /* Accept All spans the full width on its own row below the two secondary
     choices -- deliberately NOT reordered ahead of them with CSS `order`.
     `order` only moves where a button paints, not keyboard focus/tab order
     (which always follows DOM order), so a mouse user would have seen
     "Accept All" first while a keyboard/screen-reader user still tabbed to
     "Reject Optional" first -- a real mismatch, not a hypothetical one.
     Visual and tab order both follow DOM order here, same as desktop. */
  #cc-accept-all { grid-column: 1 / -1; }

  .cc-modal { max-height: calc(100vh - 24px); }
}
