/* ==========================================================================
   Shared Enhancements CSS
   Cross-theme compatibility styles for all JS-driven enhancements.
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. Scroll Animation Initial States
   -------------------------------------------------------------------------- */

[data-animate] {
  opacity: 0;
  transition: all 0.8s ease;
}

[data-animate="fade-up"] {
  transform: translateY(40px);
}

[data-animate="fade-down"] {
  transform: translateY(-40px);
}

[data-animate="fade-left"] {
  transform: translateX(40px);
}

[data-animate="fade-right"] {
  transform: translateX(-40px);
}

[data-animate="fade-in"] {
  /* opacity-only fade, no transform needed */
}

[data-animate="zoom-in"] {
  transform: scale(0.85);
}

[data-animate="zoom-out"] {
  transform: scale(1.15);
}

[data-animate="flip-up"] {
  transform: perspective(600px) rotateX(15deg);
}

[data-animate="flip-left"] {
  transform: perspective(600px) rotateY(15deg);
}

[data-animate="slide-up"] {
  transform: translateY(60px);
}

[data-animate="slide-down"] {
  transform: translateY(-60px);
}

[data-animate="slide-left"] {
  transform: translateX(60px);
}

[data-animate="slide-right"] {
  transform: translateX(-60px);
}

/* Animated (visible) state — resets all transforms */
[data-animate].animated {
  opacity: 1;
  transform: none;
}


/* --------------------------------------------------------------------------
   2. Dark Mode Override Utilities
   -------------------------------------------------------------------------- */

html.dark-mode {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #3a3a3a;
  --text-primary: #f5f5f5;
  --text-secondary: #b0b0b0;
  --text-muted: #808080;
  --border-color: #444444;
  --accent-color: #C9A96E;
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

html.dark-mode body {
  background: var(--bg-primary);
  color: var(--text-primary);
}

html.dark-mode .card,
html.dark-mode .navbar,
html.dark-mode .nav,
html.dark-mode header {
  background: var(--bg-secondary);
}

html.dark-mode .card {
  border-color: var(--border-color);
  box-shadow: var(--card-shadow);
}

html.dark-mode footer {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

html.dark-mode input,
html.dark-mode textarea,
html.dark-mode select {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

html.dark-mode a {
  color: var(--accent-color);
}

html.dark-mode hr {
  border-color: var(--border-color);
}

html.dark-mode table,
html.dark-mode th,
html.dark-mode td {
  border-color: var(--border-color);
}

html.dark-mode th {
  background: var(--bg-tertiary);
}

html.dark-mode img {
  opacity: 0.9;
}


/* --------------------------------------------------------------------------
   3. Image Enhancement (Lazy-load blur)
   -------------------------------------------------------------------------- */

img[data-src] {
  filter: blur(15px);
  opacity: 0.6;
  transition: filter 0.5s ease, opacity 0.5s ease;
}

img[data-src].loaded {
  filter: blur(0);
  opacity: 1;
}


/* --------------------------------------------------------------------------
   4. View Transition Styles
   -------------------------------------------------------------------------- */

@keyframes vt-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

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

::view-transition-old(root) {
  animation: vt-fade-out 0.2s ease-in forwards;
}

::view-transition-new(root) {
  animation: vt-fade-in 0.3s ease-out forwards;
}


/* --------------------------------------------------------------------------
   5. Enhanced Hover Effects for Cards
   -------------------------------------------------------------------------- */

.hover-lift {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  will-change: transform;
}

.hover-lift:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.hover-tilt {
  transition: transform 0.3s ease;
  transform-style: preserve-3d;
  will-change: transform;
}

.hover-tilt:hover {
  transform: perspective(800px) rotateX(2deg) rotateY(-2deg);
}

.hover-glow {
  transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
  box-shadow: 0 0 30px rgba(201, 169, 110, 0.3);
}

.hover-scale {
  transition: transform 0.3s ease;
}

.hover-scale:hover {
  transform: scale(1.03);
}


/* --------------------------------------------------------------------------
   6. Glassmorphism Utility
   -------------------------------------------------------------------------- */

.glass {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
}

.glass-dark {
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
}


/* --------------------------------------------------------------------------
   7. Gradient Text Utility
   -------------------------------------------------------------------------- */

.gradient-text {
  background: linear-gradient(135deg, #C9A96E 0%, #E8D5A3 50%, #C9A96E 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gradient-text-blue {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gradient-text-sunset {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}


/* --------------------------------------------------------------------------
   8. Skeleton Loading States
   -------------------------------------------------------------------------- */

@keyframes skeleton-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 4px;
  color: transparent !important;
}

.skeleton * {
  visibility: hidden;
}

html.dark-mode .skeleton {
  background: linear-gradient(90deg, #2d2d2d 25%, #3a3a3a 50%, #2d2d2d 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
  border-radius: 4px;
}

.skeleton-circle {
  border-radius: 50%;
}

.skeleton-image {
  width: 100%;
  padding-top: 56.25%; /* 16:9 aspect ratio */
  border-radius: 8px;
}


/* --------------------------------------------------------------------------
   9. Mortgage Calculator Theme Overrides (Dark Mode)
   -------------------------------------------------------------------------- */

html.dark-mode .mortgage-calculator,
html.dark-mode .calc-container,
html.dark-mode .calculator-wrapper {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

html.dark-mode .mortgage-calculator input[type="number"],
html.dark-mode .mortgage-calculator input[type="text"],
html.dark-mode .mortgage-calculator select {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

html.dark-mode .mortgage-calculator input[type="range"] {
  accent-color: var(--accent-color);
}

html.dark-mode .mortgage-calculator .result,
html.dark-mode .mortgage-calculator .result-card,
html.dark-mode .mortgage-calculator .summary {
  background: var(--bg-tertiary);
  border-color: var(--border-color);
}

html.dark-mode .mortgage-calculator label {
  color: var(--text-secondary);
}

html.dark-mode .mortgage-calculator .btn,
html.dark-mode .mortgage-calculator button {
  background: var(--accent-color);
  color: #1a1a1a;
}

html.dark-mode .mortgage-calculator table {
  background: var(--bg-secondary);
}

html.dark-mode .mortgage-calculator th {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

html.dark-mode .mortgage-calculator td {
  color: var(--text-secondary);
  border-color: var(--border-color);
}


/* --------------------------------------------------------------------------
   10. Print Styles
   -------------------------------------------------------------------------- */

@media print {
  .floating-widget,
  .scroll-progress,
  .back-to-top,
  .dark-mode-toggle,
  .particles-bg canvas,
  .cookie-banner,
  .chat-widget,
  nav,
  .navbar,
  footer {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
    font-size: 12pt;
  }

  a[href]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }

  [data-animate] {
    opacity: 1 !important;
    transform: none !important;
  }

  .glass,
  .glass-dark {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: white !important;
    border: 1px solid #ccc !important;
  }
}


/* --------------------------------------------------------------------------
   11. Reduced Motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  [data-animate] {
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .hover-lift,
  .hover-tilt,
  .hover-glow,
  .hover-scale {
    transition: none !important;
  }

  .skeleton {
    animation: none !important;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }

  * {
    scroll-behavior: auto !important;
  }
}


/* --------------------------------------------------------------------------
   12. Custom Scrollbar
   -------------------------------------------------------------------------- */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #c0c0c0;
  border-radius: 4px;
  border: 2px solid #f1f1f1;
}

::-webkit-scrollbar-thumb:hover {
  background: #a0a0a0;
}

html.dark-mode ::-webkit-scrollbar-track {
  background: #1a1a1a;
}

html.dark-mode ::-webkit-scrollbar-thumb {
  background: #555;
  border-color: #1a1a1a;
}

html.dark-mode ::-webkit-scrollbar-thumb:hover {
  background: #777;
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: #c0c0c0 #f1f1f1;
}

html.dark-mode * {
  scrollbar-color: #555 #1a1a1a;
}


/* --------------------------------------------------------------------------
   13. Selection Color
   -------------------------------------------------------------------------- */

::selection {
  background: var(--accent-color, #C9A96E);
  color: white;
}

::-moz-selection {
  background: var(--accent-color, #C9A96E);
  color: white;
}


/* --------------------------------------------------------------------------
   14. Focus Visible (Accessibility)
   -------------------------------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--accent-color, #C9A96E);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Enhanced focus for interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent-color, #C9A96E);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Skip-to-content link (accessibility) */
.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.75rem 1.5rem;
  background: var(--accent-color, #C9A96E);
  color: white;
  z-index: 10000;
  border-radius: 0 0 8px 8px;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
}


/* --------------------------------------------------------------------------
   15. Swiper Overrides (for themes using Swiper CDN)
   -------------------------------------------------------------------------- */

/* Pagination bullets */
.swiper-pagination-bullet {
  width: 10px;
  height: 10px;
  background: rgba(201, 169, 110, 0.4);
  opacity: 1;
  transition: all 0.3s ease;
}

.swiper-pagination-bullet-active {
  background: var(--accent-color, #C9A96E);
  transform: scale(1.3);
}

/* Navigation arrows */
.swiper-button-next,
.swiper-button-prev {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.swiper-button-next::after,
.swiper-button-prev::after {
  font-size: 18px;
  font-weight: bold;
  color: var(--accent-color, #C9A96E);
}

.swiper-button-next:hover,
.swiper-button-prev:hover {
  background: var(--accent-color, #C9A96E);
  box-shadow: 0 4px 15px rgba(201, 169, 110, 0.3);
}

.swiper-button-next:hover::after,
.swiper-button-prev:hover::after {
  color: white;
}

html.dark-mode .swiper-button-next,
html.dark-mode .swiper-button-prev {
  background: rgba(45, 45, 45, 0.9);
}

html.dark-mode .swiper-button-next:hover,
html.dark-mode .swiper-button-prev:hover {
  background: var(--accent-color, #C9A96E);
}

/* Swiper slide transitions */
.swiper-slide {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Scrollbar style for Swiper horizontal scrollbar */
.swiper-scrollbar {
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}

.swiper-scrollbar-drag {
  background: var(--accent-color, #C9A96E);
  border-radius: 4px;
}

html.dark-mode .swiper-scrollbar {
  background: rgba(255, 255, 255, 0.05);
}
