/* =============================================================================
   TaVare cookie-consent + Google Consent Mode v2 — self-hosted banner styles.

   SINGLE SOURCE OF TRUTH. This file (and its sibling consent.js) is authored ONCE
   in marketing/public/ and served at the tavare.com origin root as /consent.css.
   BOTH surfaces load it from that same root path:
     - the marketing landing        (served at / by nginx)
     - the booking app /repair-service (host-gated to tavare.com; same origin ⇒
       the browser fetches the very same /consent.css served from the marketing root)
   Because it is per-origin, the design + logic can never fork between surfaces.

   Design language mirrors the site: DM Sans, house-navy #36476F, white paper,
   #F2F2F7 soft surface, #E5E5E5 hairlines. Theme-aware (prefers-color-scheme),
   motion-aware (prefers-reduced-motion), and keyboard/AT accessible.

   All classes are namespaced `tv-consent-` to avoid any collision with Tailwind
   (marketing) or MUI (booking).
   ============================================================================= */

:root {
  --tvc-font: "DM Sans", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --tvc-navy: #36476f;      /* house brand primary (marketing textColor + composed HOUSE_PRIMARY) */
  --tvc-navy-hover: #2d384c;
  --tvc-navy-deep: #161e33;
  --tvc-ink: #0a0a0a;
  --tvc-ink-2: #4a4f5a;
  --tvc-paper: #ffffff;
  --tvc-surface: #f2f2f7;
  --tvc-hairline: #e5e5e5;
  --tvc-hairline-strong: #d4d4d4;
  --tvc-radius-card: 16px;
  --tvc-radius-btn: 10px;
  --tvc-shadow-bar: 0 12px 32px rgba(10, 10, 10, 0.12), 0 2px 8px rgba(10, 10, 10, 0.06);
  --tvc-shadow-modal: 0 24px 64px rgba(10, 10, 10, 0.24), 0 6px 16px rgba(10, 10, 10, 0.10);
  --tvc-z: 2147483000;      /* above the site header, MUI modals, and the Calendly widget */
}

/* Reset only inside our own tree, so host CSS can't distort the banner. */
.tv-consent *,
.tv-consent *::before,
.tv-consent *::after {
  box-sizing: border-box;
}

/* ---------------------------------------------------------------- banner --- */
.tv-consent-banner {
  position: fixed;
  z-index: var(--tvc-z);
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(14px);
  width: min(640px, calc(100vw - 32px));
  background: var(--tvc-paper);
  color: var(--tvc-ink);
  border: 1px solid var(--tvc-hairline);
  border-radius: var(--tvc-radius-card);
  box-shadow: var(--tvc-shadow-bar);
  padding: 20px 22px;
  font-family: var(--tvc-font);
  font-size: 14px;
  line-height: 1.55;
  opacity: 0;
  transition: opacity 260ms ease, transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
}
.tv-consent-banner.is-in {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.tv-consent-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--tvc-ink);
}
.tv-consent-body {
  margin: 0 0 16px;
  color: var(--tvc-ink-2);
  font-size: 14px;
}

.tv-consent-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
/* The two decision buttons share ONE flex basis => identical width, weight and
   prominence (EDPB: refusing must be exactly as easy as accepting). */
.tv-consent-actions .tv-consent-btn--primary {
  flex: 1 1 0;
  min-width: 140px;
}
.tv-consent-manage {
  flex-basis: 100%;
  text-align: center;
  margin-top: 2px;
}

/* ----------------------------------------------------------------- buttons - */
.tv-consent-btn {
  appearance: none;
  font-family: var(--tvc-font);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  border-radius: var(--tvc-radius-btn);
  padding: 12px 18px;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
  border: 1px solid transparent;
}
/* Accept-all AND Reject-all both use this identical treatment. */
.tv-consent-btn--primary {
  background: var(--tvc-navy);
  color: #ffffff;
  border-color: var(--tvc-navy);
}
.tv-consent-btn--primary:hover {
  background: var(--tvc-navy-hover);
  border-color: var(--tvc-navy-hover);
}
.tv-consent-btn--outline {
  background: var(--tvc-paper);
  color: var(--tvc-navy);
  border-color: var(--tvc-hairline-strong);
}
.tv-consent-btn--outline:hover {
  background: var(--tvc-surface);
}
/* The lower-key "manage" affordance — clearly secondary to the two decisions,
   but a legible text button, never a faint/greyed link. */
.tv-consent-linkbtn {
  appearance: none;
  background: none;
  border: none;
  font-family: var(--tvc-font);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--tvc-navy);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 6px;
}
.tv-consent-linkbtn:hover {
  color: var(--tvc-navy-hover);
}

/* Visible keyboard focus everywhere. */
.tv-consent :focus-visible,
.tv-consent-reopen:focus-visible {
  outline: 2px solid var(--tvc-navy);
  outline-offset: 2px;
}

/* ------------------------------------------------------- manage modal ----- */
.tv-consent-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--tvc-z);
  background: rgba(10, 14, 25, 0.44);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 200ms ease;
}
.tv-consent-backdrop.is-in {
  opacity: 1;
}
.tv-consent-modal {
  width: min(520px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--tvc-paper);
  color: var(--tvc-ink);
  border: 1px solid var(--tvc-hairline);
  border-radius: var(--tvc-radius-card);
  box-shadow: var(--tvc-shadow-modal);
  font-family: var(--tvc-font);
  padding: 24px;
  transform: translateY(8px) scale(0.98);
  transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
}
.tv-consent-backdrop.is-in .tv-consent-modal {
  transform: translateY(0) scale(1);
}

.tv-consent-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.tv-consent-modal-title {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.tv-consent-modal-intro {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: var(--tvc-ink-2);
  line-height: 1.55;
}
.tv-consent-close {
  appearance: none;
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: none;
  color: var(--tvc-ink-2);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.tv-consent-close:hover {
  background: var(--tvc-surface);
  color: var(--tvc-ink);
}

/* Category rows */
.tv-consent-cat {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--tvc-hairline);
  border-radius: 12px;
  background: var(--tvc-surface);
  margin-bottom: 12px;
}
.tv-consent-cat-text {
  flex: 1 1 auto;
  min-width: 0;
}
.tv-consent-cat-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 700;
  margin: 0 0 4px;
}
.tv-consent-cat-desc {
  margin: 0;
  font-size: 13px;
  color: var(--tvc-ink-2);
  line-height: 1.5;
}
.tv-consent-chip {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tvc-navy);
  background: rgba(54, 71, 111, 0.10);
  border-radius: 999px;
  padding: 3px 8px;
}

/* Toggle switch (role="switch") */
.tv-consent-switch {
  appearance: none;
  flex: 0 0 auto;
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  border: none;
  background: var(--tvc-hairline-strong);
  cursor: pointer;
  transition: background-color 160ms ease;
  margin-top: 2px;
}
.tv-consent-switch .tv-consent-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(10, 10, 10, 0.28);
  transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}
.tv-consent-switch[aria-checked="true"] {
  background: var(--tvc-navy);
}
.tv-consent-switch[aria-checked="true"] .tv-consent-thumb {
  transform: translateX(18px);
}
.tv-consent-switch[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.9;
}

.tv-consent-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.tv-consent-modal-actions .tv-consent-btn {
  flex: 1 1 0;
}

/* --------------------------------------------------- reopen affordance ---- */
/* Unobtrusive, persistent way to change/withdraw consent at any time.
   Bottom-LEFT to stay clear of bottom-right widgets (e.g. Calendly). */
.tv-consent-reopen {
  position: fixed;
  z-index: 2147482000;
  left: 16px;
  bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--tvc-font);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--tvc-navy);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid var(--tvc-hairline);
  border-radius: 999px;
  padding: 8px 13px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(10, 10, 10, 0.12);
  opacity: 0.72;
  transition: opacity 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}
.tv-consent-reopen:hover {
  opacity: 1;
  box-shadow: 0 6px 18px rgba(10, 10, 10, 0.18);
  transform: translateY(-1px);
}
.tv-consent-reopen svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
}
.tv-consent-hidden {
  display: none !important;
}

/* ---------------------------------------------------------- responsive ---- */
@media (max-width: 560px) {
  /* Full-width bottom sheet on mobile. */
  .tv-consent-banner {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    transform: translateY(16px);
    border-left: none;
    border-right: none;
    border-bottom: none;
    border-radius: 18px 18px 0 0;
    padding: 20px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  }
  .tv-consent-banner.is-in {
    transform: translateY(0);
  }
  .tv-consent-actions .tv-consent-btn--primary {
    flex: 1 1 100%;
  }
  .tv-consent-modal-actions {
    flex-wrap: wrap;
  }
  .tv-consent-modal-actions .tv-consent-btn {
    flex: 1 1 100%;
  }
}

/* --------------------------------------------------------- dark scheme ---- */
@media (prefers-color-scheme: dark) {
  :root {
    --tvc-navy: #4e62a0;
    --tvc-navy-hover: #5c71b6;
    --tvc-ink: #f2f4f8;
    --tvc-ink-2: #aeb6c6;
    --tvc-paper: #171c28;
    --tvc-surface: rgba(255, 255, 255, 0.05);
    --tvc-hairline: rgba(255, 255, 255, 0.13);
    --tvc-hairline-strong: rgba(255, 255, 255, 0.26);
  }
  .tv-consent-btn--outline {
    color: var(--tvc-ink);
  }
  .tv-consent-chip {
    color: #b9c6ee;
    background: rgba(120, 143, 214, 0.18);
  }
  .tv-consent-switch .tv-consent-thumb {
    background: #f2f4f8;
  }
  .tv-consent-reopen {
    color: #c3cdec;
    background: rgba(23, 28, 40, 0.92);
    border-color: rgba(255, 255, 255, 0.16);
  }
}

/* ------------------------------------------------------ reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .tv-consent-banner,
  .tv-consent-banner.is-in,
  .tv-consent-backdrop,
  .tv-consent-modal,
  .tv-consent-backdrop.is-in .tv-consent-modal,
  .tv-consent-switch .tv-consent-thumb,
  .tv-consent-reopen {
    transition: none !important;
    transform: none !important;
  }
  /* keep the mobile sheet flush to the bottom without a transform */
  .tv-consent-banner { opacity: 1; }
}
