/*
 * Cookie consent banner — shared minimal CSS.
 *
 * Intentionally vanilla CSS (no Tailwind/PostCSS pipeline) so the file is
 * a single artifact dropped into all 6 sites without per-site rebuilds.
 * Pairs with the markup in packages/shared/components/cookie-banner.njk
 * and the JS in packages/shared/assets/js/cookie-banner.js.
 *
 * Brand colors are exposed as CSS custom properties on .cookie-consent
 * itself, so per-site overrides are a single :root { --cookie-* } block in
 * each site's main.css if they want to drift away from the navy/gold default.
 *
 * Accessibility:
 *  - Focus styles use a thick gold ring (>= 3px, ≥ 4.5:1 contrast on white).
 *  - Hit areas on buttons + toggles are ≥ 44px on mobile.
 *  - Hidden via [hidden] + [aria-hidden] for assistive-tech consistency.
 */

.cookie-consent {
  /* ── Custom properties (per-site override these in main.css if desired) ── */
  --cookie-bg: #ffffff;
  --cookie-bg-elevated: #ffffff;
  --cookie-text: #0f172a;            /* navy */
  --cookie-text-muted: #475569;      /* slate */
  --cookie-border: #e2e8f0;
  --cookie-shadow: 0 -4px 24px rgba(15, 23, 42, 0.12);
  --cookie-shadow-modal: 0 24px 48px rgba(15, 23, 42, 0.24);

  --cookie-primary: #0f172a;         /* navy */
  --cookie-primary-text: #ffffff;
  --cookie-primary-hover: #1e293b;

  --cookie-accent: #d4a843;          /* gold */
  --cookie-accent-text: #0f172a;
  --cookie-accent-hover: #c4982e;

  --cookie-ghost-border: #cbd5e1;
  --cookie-ghost-bg: transparent;
  --cookie-ghost-text: #0f172a;
  --cookie-ghost-hover: #f1f5f9;

  --cookie-toggle-off: #cbd5e1;
  --cookie-toggle-on: #16a34a;       /* green-600 */
  --cookie-toggle-locked: #94a3b8;
  --cookie-toggle-thumb: #ffffff;

  --cookie-focus-ring: #d4a843;      /* gold */

  --cookie-z-banner: 9990;
  --cookie-z-modal: 9999;

  --cookie-radius: 12px;
  --cookie-radius-input: 6px;
  --cookie-font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;

  /* Default state: hidden until JS sets data-state="banner-visible" or "modal-open". */
  font-family: var(--cookie-font);
}

.cookie-consent[data-state="hidden"] .cookie-consent__banner {
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
}
.cookie-consent[data-state="banner-visible"] .cookie-consent__banner,
.cookie-consent[data-state="modal-open"] .cookie-consent__banner {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ──────────────────────────────────────────────────────────────────────
   Banner (sticky bottom)
   ────────────────────────────────────────────────────────────────────── */

.cookie-consent__banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--cookie-z-banner);
  background: var(--cookie-bg);
  color: var(--cookie-text);
  border-top: 1px solid var(--cookie-border);
  box-shadow: var(--cookie-shadow);
  padding: 16px;
  /* iOS safe area (so the banner clears the home indicator on iPhone). */
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transition: transform 280ms ease, opacity 280ms ease;
  /* Stays above page chrome but lets sticky CTAs (z-index 9990+) coexist via
     stacking-context. We're at 9990 so floating "Get a Quote" CTAs (typically
     z-index 30-100) sit BELOW. The modal is at 9999 so it always wins. */
}

.cookie-consent__banner-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}

@media (min-width: 768px) {
  .cookie-consent__banner-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
  }
}

.cookie-consent__copy {
  flex: 1 1 auto;
  min-width: 0;
}

.cookie-consent__title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--cookie-text);
}

.cookie-consent__desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--cookie-text-muted);
}

.cookie-consent__link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cookie-consent__link:hover { color: var(--cookie-text); }

.cookie-consent__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .cookie-consent__actions {
    /* On narrow screens stack buttons full-width for easy thumb taps. */
    flex-direction: column;
  }
  .cookie-consent__actions .cookie-consent__btn { width: 100%; }
}

/* ──────────────────────────────────────────────────────────────────────
   Buttons
   ────────────────────────────────────────────────────────────────────── */

.cookie-consent__btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--cookie-radius-input);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease,
              box-shadow 160ms ease, transform 80ms ease;
  white-space: nowrap;
}

.cookie-consent__btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--cookie-focus-ring);
}

.cookie-consent__btn:active { transform: translateY(1px); }

.cookie-consent__btn--primary {
  background: var(--cookie-primary);
  color: var(--cookie-primary-text);
  border-color: var(--cookie-primary);
}
.cookie-consent__btn--primary:hover { background: var(--cookie-primary-hover); }

.cookie-consent__btn--ghost {
  background: var(--cookie-ghost-bg);
  color: var(--cookie-ghost-text);
  border-color: var(--cookie-ghost-border);
}
.cookie-consent__btn--ghost:hover { background: var(--cookie-ghost-hover); }

/* ──────────────────────────────────────────────────────────────────────
   Modal
   ────────────────────────────────────────────────────────────────────── */

.cookie-consent__modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--cookie-z-modal);
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  /* Slightly delay opacity so backdrop doesn't pop hard. */
  animation: cc-fade-in 200ms ease forwards;
}

@keyframes cc-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.cookie-consent__modal {
  background: var(--cookie-bg-elevated);
  color: var(--cookie-text);
  border-radius: var(--cookie-radius);
  box-shadow: var(--cookie-shadow-modal);
  max-width: 560px;
  width: 100%;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  outline: none;
  animation: cc-modal-in 220ms ease forwards;
}

@keyframes cc-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.cookie-consent__modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--cookie-border);
}

.cookie-consent__modal-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--cookie-text);
}

.cookie-consent__modal-close {
  appearance: none;
  background: transparent;
  border: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--cookie-text-muted);
  border-radius: 6px;
  transition: background 160ms ease, color 160ms ease;
}
.cookie-consent__modal-close:hover {
  background: var(--cookie-ghost-hover);
  color: var(--cookie-text);
}
.cookie-consent__modal-close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--cookie-focus-ring);
}

.cookie-consent__modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.cookie-consent__modal-desc {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--cookie-text-muted);
}

.cookie-consent__modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--cookie-border);
  background: #f8fafc;
}

@media (max-width: 480px) {
  .cookie-consent__modal-footer {
    flex-direction: column-reverse;
  }
  .cookie-consent__modal-footer .cookie-consent__btn { width: 100%; }
}

/* ──────────────────────────────────────────────────────────────────────
   Categories
   ────────────────────────────────────────────────────────────────────── */

.cookie-consent__category {
  border: 0;
  margin: 0;
  padding: 14px 0;
  border-bottom: 1px solid var(--cookie-border);
}
.cookie-consent__category:last-of-type { border-bottom: 0; padding-bottom: 4px; }

.cookie-consent__category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.cookie-consent__category-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--cookie-text);
  margin: 0;
  padding: 0;
}
.cookie-consent__category-label label { cursor: pointer; }

.cookie-consent__category-desc {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--cookie-text-muted);
}

/* ──────────────────────────────────────────────────────────────────────
   Toggles
   ────────────────────────────────────────────────────────────────────── */

.cookie-consent__toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  /* Larger hit area on touch screens. */
  min-height: 32px;
}

.cookie-consent__toggle-input {
  /* Hide native input, retain accessibility. */
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cookie-consent__toggle-track {
  position: relative;
  width: 40px;
  height: 22px;
  background: var(--cookie-toggle-off);
  border-radius: 999px;
  transition: background 200ms ease;
  flex-shrink: 0;
}

.cookie-consent__toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cookie-toggle-thumb);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 200ms ease;
}

.cookie-consent__toggle-input:checked ~ .cookie-consent__toggle-track {
  background: var(--cookie-toggle-on);
}
.cookie-consent__toggle-input:checked ~ .cookie-consent__toggle-track .cookie-consent__toggle-thumb {
  transform: translateX(18px);
}

.cookie-consent__toggle-input:focus-visible ~ .cookie-consent__toggle-track {
  box-shadow: 0 0 0 3px var(--cookie-focus-ring);
}

.cookie-consent__toggle--locked .cookie-consent__toggle-track {
  background: var(--cookie-toggle-locked);
  opacity: 0.7;
}
.cookie-consent__toggle--locked .cookie-consent__toggle-thumb {
  transform: translateX(18px);
}

.cookie-consent__toggle-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--cookie-text-muted);
  min-width: 26px;
  text-align: left;
}

.cookie-consent__toggle-on,
.cookie-consent__toggle-off { display: inline; }
.cookie-consent__toggle-on { display: none; }
.cookie-consent__toggle-input:checked ~ .cookie-consent__toggle-text .cookie-consent__toggle-on { display: inline; }
.cookie-consent__toggle-input:checked ~ .cookie-consent__toggle-text .cookie-consent__toggle-off { display: none; }

/* ──────────────────────────────────────────────────────────────────────
   Reduced motion
   ────────────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .cookie-consent__banner,
  .cookie-consent__btn,
  .cookie-consent__toggle-track,
  .cookie-consent__toggle-thumb,
  .cookie-consent__modal-backdrop,
  .cookie-consent__modal {
    transition: none !important;
    animation: none !important;
  }
}
