/* ========================================
   Glassmorphism Layer
   Frosted-glass surfaces applied site-wide.
   Built on the premium.css design tokens.
   MUST be loaded AFTER css/premium.css.
   ======================================== */

/* --- Glass tokens (derived from premium.css palette) --- */
:root {
  --glass-blur: 20px;
  --glass-saturate: 180%;
  /* Raised opacity so animated blobs don't bleed through card faces */
  --glass-fill: rgba(255, 255, 255, 0.82);
  --glass-fill-strong: rgba(255, 255, 255, 0.92);
  --glass-stroke: rgba(167, 139, 250, 0.22);
  --glass-shadow: 0 8px 32px rgba(124, 58, 237, 0.10), 0 2px 8px rgba(0,0,0,0.05);
  --glass-highlight: rgba(255, 255, 255, 0.70);

  /* Ambient background blob tints — reduced so they stay atmospheric, not dominant */
  --blob-1: rgba(167, 139, 250, 0.18);
  --blob-2: rgba(196, 181, 253, 0.14);
}

/* Honour OS dark mode with a deeper frost so glass stays legible */
@media (prefers-color-scheme: dark) {
  :root {
    --glass-fill: rgba(124, 58, 237, 0.30);
    --glass-fill-strong: rgba(124, 58, 237, 0.42);
    --glass-stroke: rgba(196, 181, 253, 0.30);
    --glass-shadow: 0 20px 50px rgba(76, 29, 149, 0.5);
    --glass-highlight: rgba(196, 181, 253, 0.18);
    --blob-1: rgba(167, 139, 250, 0.32);
    --blob-2: rgba(124, 58, 237, 0.24);
  }
}

/* --- Drifting smoke layers (every page) ---------------------
   Two large blurred plumes that slowly rise, swirl and fade,
   tinted with the brand lavender for a smoky purple haze. */
html {
  position: relative;
  /* Hold the base page color here so the smoke (html pseudo-elements)
     shows through the now-transparent body. */
  background: var(--bg-primary);
}

body {
  background: transparent !important;
}

html::before,
html::after {
  content: '';
  position: fixed;
  inset: -20vh -20vw;
  z-index: -3;
  pointer-events: none;
  will-change: transform, opacity;
}

html::before {
  background:
    radial-gradient(40% 55% at 25% 80%, rgba(167, 139, 250, 0.14), transparent 60%),
    radial-gradient(35% 45% at 70% 90%, rgba(196, 181, 253, 0.10), transparent 60%),
    radial-gradient(30% 40% at 50% 70%, rgba(124, 58, 237, 0.10), transparent 65%);
  filter: blur(60px);
  animation: smokeRise1 28s ease-in-out infinite;
}

html::after {
  background:
    radial-gradient(45% 50% at 75% 85%, rgba(124, 58, 237, 0.10), transparent 60%),
    radial-gradient(35% 45% at 30% 95%, rgba(167, 139, 250, 0.12), transparent 62%),
    radial-gradient(30% 38% at 55% 75%, rgba(196, 181, 253, 0.08), transparent 65%);
  filter: blur(70px);
  animation: smokeRise2 34s ease-in-out infinite;
}

@keyframes smokeRise1 {
  0%   { transform: translate3d(0, 10vh, 0) scale(1) rotate(0deg); opacity: 0.5; }
  50%  { transform: translate3d(4vw, -6vh, 0) scale(1.25) rotate(8deg); opacity: 0.85; }
  100% { transform: translate3d(-3vw, -18vh, 0) scale(1.4) rotate(-6deg); opacity: 0.35; }
}

@keyframes smokeRise2 {
  0%   { transform: translate3d(0, 12vh, 0) scale(1.05) rotate(0deg); opacity: 0.4; }
  50%  { transform: translate3d(-5vw, -4vh, 0) scale(1.3) rotate(-10deg); opacity: 0.8; }
  100% { transform: translate3d(4vw, -16vh, 0) scale(1.5) rotate(7deg); opacity: 0.3; }
}

/* --- Animated ambient background blobs (every page) --- */
body::before,
body::after {
  content: '';
  position: fixed;
  z-index: -2;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  will-change: transform;
}

body::before {
  width: 46vw;
  height: 46vw;
  top: -12vw;
  left: -10vw;
  background: radial-gradient(circle, var(--blob-1), transparent 70%);
  animation: blobDrift1 22s ease-in-out infinite alternate;
}

body::after {
  width: 40vw;
  height: 40vw;
  bottom: -14vw;
  right: -12vw;
  background: radial-gradient(circle, var(--blob-2), transparent 70%);
  animation: blobDrift2 26s ease-in-out infinite alternate;
}

@keyframes blobDrift1 {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(8vw, 6vw) scale(1.15); }
  100% { transform: translate(4vw, 12vw) scale(0.95); }
}

@keyframes blobDrift2 {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(-7vw, -5vw) scale(1.12); }
  100% { transform: translate(-3vw, -10vw) scale(0.92); }
}

/* --- Frosted glass surfaces ---------------------------------
   Targets the real component classes used by premium.css. */
.service-card,
.portfolio-card,
.feedback-card,
.service-stat,
.contact-form,
.modal-content {
  background: var(--glass-fill) !important;
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-stroke) !important;
  box-shadow: var(--glass-shadow);
}

/* Subtle inner top highlight for the frosted edge */
.service-card,
.portfolio-card,
.feedback-card,
.contact-form,
.modal-content {
  position: relative;
}

.service-card::before,
.feedback-card::before,
.contact-form::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, var(--glass-highlight), transparent 45%);
  opacity: 0.5;
  z-index: 0;
}

/* Keep card content above the highlight layer */
.service-card > *,
.feedback-card > *,
.contact-form > * {
  position: relative;
  z-index: 1;
}

/* Stronger frost for the modal so overlaid content stays readable */
.modal-content {
  background: var(--glass-fill-strong) !important;
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  backdrop-filter: blur(26px) saturate(180%);
}

/* --- Glass navbar (stronger frost) --- */
.navbar {
  background: var(--glass-fill-strong) !important;
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--glass-stroke);
}

/* --- Glass mobile menu panel --- */
@media (max-width: 768px) {
  .nav-links {
    background: var(--glass-fill-strong) !important;
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    backdrop-filter: blur(22px) saturate(180%);
    border-bottom: 1px solid var(--glass-stroke);
  }
}

/* --- Glass filter / tech pills --- */
.filter-btn,
.tech-pill {
  background: var(--glass-fill) !important;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--glass-stroke) !important;
}

.filter-btn.active {
  background: var(--gradient-primary) !important;
  border-color: transparent !important;
}

/* --- Smoother lift on glass cards --- */
.service-card,
.portfolio-card,
.feedback-card,
.service-stat {
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.3s ease;
}

.service-card:hover,
.service-stat:hover {
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(var(--primary-rgb), 0.18);
}

/* --- Respect reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  html::before,
  html::after,
  body::before,
  body::after {
    animation: none !important;
  }
}
