/**
 * Shared CMS colour palette bridge (Template G pattern).
 * Admin panel → :root --primary, --secondary, --dark, --light, --text (app.blade.php).
 * Per-template bridges add layout-specific overrides on top of this file.
 */

body[class^="cms-active-template-"] {
  /* Image section scrims — true black (not palette primary/secondary tint) */
  --cms-image-overlay: rgba(0, 0, 0, 0.5);
  --cms-image-overlay-light: rgba(0, 0, 0, 0.4);
  --cms-image-overlay-heavy: rgba(0, 0, 0, 0.6);
  --cms-image-overlay-home: rgba(0, 0, 0, 0.55);

  --accent-color: var(--primary);
  --background-color: var(--light);
  --default-color: var(--text);
  --heading-color: var(--dark);
  --surface-color: color-mix(in srgb, var(--light), var(--dark) 14%);
  --contrast-color: var(--secondary);

  --nav-color: color-mix(in srgb, var(--text), var(--dark) 20%);
  --nav-hover-color: var(--primary);
  --nav-mobile-background-color: var(--dark);
  --nav-dropdown-background-color: color-mix(in srgb, var(--dark), var(--primary) 18%);
  --nav-dropdown-color: color-mix(in srgb, var(--secondary), var(--text) 35%);
  --nav-dropdown-hover-color: var(--primary);
}

body[class^="cms-active-template-"] .light-background {
  --background-color: color-mix(in srgb, var(--light), var(--dark) 6%);
  --default-color: var(--text);
  --heading-color: var(--dark);
  --surface-color: color-mix(in srgb, var(--light), var(--dark) 12%);
  --contrast-color: var(--secondary);
}

body[class^="cms-active-template-"] .dark-background {
  --background-color: var(--dark);
  --default-color: color-mix(in srgb, var(--secondary) 75%, var(--text));
  --heading-color: var(--secondary);
  --surface-color: color-mix(in srgb, var(--dark), var(--primary) 16%);
  --contrast-color: var(--secondary);
}

/* Sections that use NiceHotel / Clarity semantic tokens */
body[class^="cms-active-template-"] .section.light-background,
body[class^="cms-active-template-"] .section.dark-background {
  color: var(--default-color);
  background-color: var(--background-color);
}

body[class^="cms-active-template-"] .light-background h1,
body[class^="cms-active-template-"] .light-background h2,
body[class^="cms-active-template-"] .light-background h3,
body[class^="cms-active-template-"] .light-background h4,
body[class^="cms-active-template-"] .light-background h5,
body[class^="cms-active-template-"] .light-background h6,
body[class^="cms-active-template-"] .dark-background h1,
body[class^="cms-active-template-"] .dark-background h2,
body[class^="cms-active-template-"] .dark-background h3,
body[class^="cms-active-template-"] .dark-background h4,
body[class^="cms-active-template-"] .dark-background h5,
body[class^="cms-active-template-"] .dark-background h6 {
  color: var(--heading-color);
}

body[class^="cms-active-template-"] .light-background p,
body[class^="cms-active-template-"] .dark-background p {
  color: var(--default-color);
}

/* Bootstrap utility alignment (palette-driven) */
body[class^="cms-active-template-"] .text-primary { color: var(--primary) !important; }
body[class^="cms-active-template-"] .text-dark { color: var(--dark) !important; }
body[class^="cms-active-template-"] .text-body { color: var(--text) !important; }
body[class^="cms-active-template-"] .text-muted {
  color: color-mix(in srgb, var(--text) 65%, transparent) !important;
}
body[class^="cms-active-template-"] .bg-primary { background-color: var(--primary) !important; }
body[class^="cms-active-template-"] .bg-secondary { background-color: var(--secondary) !important; }
body[class^="cms-active-template-"] .bg-dark { background-color: var(--dark) !important; }
body[class^="cms-active-template-"] .bg-light { background-color: var(--light) !important; }
body[class^="cms-active-template-"] .border-primary { border-color: var(--primary) !important; }

/* Primary actions (Template G) */
body[class^="cms-active-template-"] .btn-primary:not(.btn-link) {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  color: var(--secondary) !important;
}

body[class^="cms-active-template-"] .btn-primary:not(.btn-link):hover,
body[class^="cms-active-template-"] .btn-primary:not(.btn-link):focus {
  background-color: color-mix(in srgb, var(--primary), var(--dark) 15%) !important;
  border-color: color-mix(in srgb, var(--primary), var(--dark) 15%) !important;
  color: var(--secondary) !important;
}

body[class^="cms-active-template-"] .btn-outline-primary {
  color: var(--primary) !important;
  border-color: var(--primary) !important;
}

body[class^="cms-active-template-"] .btn-outline-primary:hover,
body[class^="cms-active-template-"] .btn-outline-primary:focus {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  color: var(--secondary) !important;
}

body[class^="cms-active-template-"] a:not(.btn):hover {
  color: var(--primary);
}

/* Back to top / scroll to top — fixed on viewport + smooth show/hide (all CMS templates) */
body[class^="cms-active-template-"] a.back-to-top,
body[class^="cms-active-template-"] a.scroll-top {
  position: fixed !important;
  right: 30px;
  bottom: calc(30px + env(safe-area-inset-bottom, 0px));
  left: auto !important;
  top: auto !important;
  z-index: 99999;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  margin: 0 !important;
  text-decoration: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(14px) scale(0.94);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  transition:
    opacity 0.4s ease,
    visibility 0.4s ease,
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    background-color 0.25s ease,
    box-shadow 0.25s ease;
}

body[class^="cms-active-template-"] a.back-to-top.active,
body[class^="cms-active-template-"] a.scroll-top.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

body[class^="cms-active-template-"] a.back-to-top.active:hover,
body[class^="cms-active-template-"] a.back-to-top.active:focus-visible,
body[class^="cms-active-template-"] a.scroll-top.active:hover,
body[class^="cms-active-template-"] a.scroll-top.active:focus-visible {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
}

body[class^="cms-active-template-"] a.back-to-top.active:active,
body[class^="cms-active-template-"] a.scroll-top.active:active {
  transform: translateY(-1px) scale(1.02);
  transition-duration: 0.12s;
}

@media (max-width: 991.98px) {
  body[class^="cms-active-template-"]:not(.cms-active-template-templateD):not(.cms-active-template-templateE) a.back-to-top,
  body[class^="cms-active-template-"]:not(.cms-active-template-templateD):not(.cms-active-template-templateE) a.scroll-top {
    right: 16px;
    bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  body[class^="cms-active-template-"] a.back-to-top,
  body[class^="cms-active-template-"] a.scroll-top {
    transition: opacity 0.15s ease, visibility 0.15s ease;
    transform: none;
  }

  body[class^="cms-active-template-"] a.back-to-top.active,
  body[class^="cms-active-template-"] a.scroll-top.active,
  body[class^="cms-active-template-"] a.back-to-top.active:hover,
  body[class^="cms-active-template-"] a.scroll-top.active:hover {
    transform: none;
  }
}
