/* ═══════════════════════════════════════════════════════════════════════════
   InSightYou — Safari & Cross-Browser Patch
   Appended to main.css (or included separately via functions.php)
   Version: v15 — fixes parallax, images, cursor, video backgrounds
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── CURSOR: use left/top not transform (Safari compositing fix) ── */
.isy-cursor-dot,
.isy-cursor-ring {
  /* JS sets left/top; ensure transform is not competing */
  transform: none !important;
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  border-radius: 50%;
  z-index: 99999;
}
.isy-cursor-dot {
  width: 6px;
  height: 6px;
  background: var(--soft-violet);
  box-shadow: 0 0 10px rgba(192,144,240,0.8);
  transition: background 0.2s, box-shadow 0.2s, width 0.2s, height 0.2s;
}
.isy-cursor-ring {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(192,144,240,0.4);
  background: transparent;
  transition: border-color 0.25s, width 0.25s, height 0.25s;
}

/* ── HERO: supports image OR video as full-bleed background ── */
.isy-hero {
  position: relative;
  overflow: hidden;
  /* Must be set so absolute-positioned bg fills correctly */
  isolation: isolate;
}

/* The background element (img or video) — positioned by JS but pre-styled here */
.isy-hero__bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 110%;            /* Extra height for parallax room */
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
  transform-origin: top center;
  /* Start at top so parallax shift is visible */
  transform: translateY(0) scale(1.12);
  will-change: transform;
}

/* Overlay so text stays readable over any background */
.isy-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: radial-gradient(ellipse at center,
    rgba(4,2,10,0.35) 0%,
    rgba(4,2,10,0.72) 70%,
    rgba(4,2,10,0.92) 100%
  );
  pointer-events: none;
}

/* Hero content sits above the overlay */
.isy-hero > *:not(.isy-hero__bg) {
  position: relative;
  z-index: 2;
}

/* ── PARALLAX SECTION BACKGROUNDS ── */
.isy-section-bg {
  position: absolute;
  inset: -10% 0;           /* Overshoot so parallax doesn't show edges */
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.isy-section-bg img,
.isy-section-bg video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  will-change: transform;
  transform: translateY(0) scale(1.1);
}

/* Parallax target class — JS moves this */
.isy-parallax-bg {
  will-change: transform; /* JS controls this */
}

/* ── OVERFLOW PARALLAX: Safari fallback ── */
/* CSS animation-timeline (scroll-linked) only works in Chrome 115+.
   On Safari we fall back to the JS parallax above. */
@supports not (animation-timeline: scroll()) {
  .isy-overflow-image.in-view img {
    animation: none;
  }
}

/* ── IMAGE BLUR-UP ── */
img[loading="lazy"] {
  filter: blur(8px);
  transition: filter 0.5s ease;
}
img[loading="lazy"].loaded {
  filter: blur(0);
}
/* Never blur hero backgrounds */
.isy-hero__bg,
.isy-hero__bg[loading="lazy"],
.isy-parallax-bg img {
  filter: none !important;
  transition: none !important;
}

/* ── CARD INIT / REVEAL ── */
.card-init {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.75s var(--transition), transform 0.75s var(--transition);
}
.card-init.card-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── SECTION TRANSITIONS ── */
.isy-section--init {
  /* Very subtle: sections don't dramatically animate on first load */
  transition: opacity 0.6s ease;
}
.isy-section--entered {
  /* Already visible by default — this is mainly a hook for CSS rules */
}

/* ── SAFARI: disable background-attachment:fixed (broken on iOS) ── */
/* background-attachment:fixed creates a new stacking context on iOS Safari
   and causes the background to be fixed to the VIEWPORT not the element.
   We use JS parallax instead. */
.is-safari .isy-section--parallax-bg,
.is-touch  .isy-section--parallax-bg {
  background-attachment: scroll !important;
}

/* ── NAV TRANSITION ── */
.isy-nav {
  transition: padding 0.4s, background 0.4s, border-color 0.4s, transform 0.4s;
  /* Ensure transition fires smoothly on Safari */
  -webkit-transition: padding 0.4s, background 0.4s, border-color 0.4s, -webkit-transform 0.4s;
}

/* ── SAFARI: smooth scroll polyfill ── */
/* Safari < 15.4 doesn't support scroll-behavior:smooth on html element */
.is-safari html {
  scroll-behavior: auto;
}
/* JS handles smooth scroll for anchor links */

/* ── SOUND BUTTON ── */
.isy-sound-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: rgba(232,224,248,0.25);
  cursor: none;
  padding: 0;
  transition: color 0.3s;
  flex-shrink: 0;
}
.isy-sound-btn svg {
  width: 16px;
  height: 16px;
}

/* ── FAB (floating action button) ── */
.isy-fab {
  position: fixed;
  bottom: 2.5rem;
  right: 2.5rem;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.6rem;
  background: linear-gradient(135deg, var(--core-purple), var(--mid-amethyst));
  color: var(--moon-white);
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  border-radius: 50px;
  box-shadow: 0 8px 30px rgba(90,42,158,0.5);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
  text-decoration: none;
}
.isy-fab.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.isy-fab:hover {
  box-shadow: 0 12px 40px rgba(90,42,158,0.7);
  color: var(--moon-white);
}
.isy-fab__icon {
  font-size: 0.8rem;
  opacity: 0.7;
}

/* ── COOKIE BANNER ── */
.isy-cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  transform: translateY(100%);
  z-index: 9000;
  width: 100%;
  opacity: 0;
  transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
}
.isy-cookie-banner.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.isy-cookie-banner__inner {
  background: rgba(13,8,24,0.96);
  border-top: 1px solid rgba(138,92,246,0.2);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  flex-wrap: wrap;
}
.isy-cookie-banner__actions {
  display: flex;
  gap: 0.8rem;
  flex-shrink: 0;
}

/* ── MODULE DETAIL PAGE ENHANCEMENTS ── */
/* Ensure sticky purchase card doesn't cause Safari layout issues */
.isy-pcard {
  /* Safari: position:sticky + transform children causes issues */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* ── MOBILE ── */
@media (max-width: 768px) {
  .isy-fab { display: none; }
  .isy-cookie-banner { bottom: 0; }
  .isy-hero__bg { height: 120%; } /* More room for parallax on smaller viewports */
}

/* ── HIGH-CONTRAST / REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
  .isy-hero__bg,
  .isy-float-element {
    transform: none !important;
    transition: none !important;
    animation: none !important;
  }
  .isy-ring { animation: none !important; opacity: 0.7; }
  .isy-star { animation: none !important; opacity: 0.4; }
}

/* ── TTS WIDGET ── */
.isy-tts-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 800;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    font-family: var(--font-body, 'Jost', sans-serif);
}
.isy-tts-btn {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: rgba(13, 8, 24, 0.92);
    border: 1px solid rgba(201, 168, 76, 0.35);
    border-radius: 40px;
    padding: 0.55rem 1.1rem 0.55rem 0.85rem;
    color: rgba(232, 224, 248, 0.7);
    font-size: 0.65rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: color 0.25s, border-color 0.25s, background 0.25s;
    white-space: nowrap;
}
.isy-tts-btn svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}
.isy-tts-btn:hover,
.isy-tts--playing .isy-tts-btn {
    color: var(--soft-violet, #c090f0);
    border-color: rgba(201, 168, 76, 0.6);
    background: rgba(13, 8, 24, 0.97);
}
.isy-tts-controls {
    display: none;
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
    background: rgba(13, 8, 24, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 30px;
    padding: 0.35rem 0.75rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.isy-tts-voice {
    display: flex;
    gap: 0.3rem;
}
.isy-tts-voice-btn {
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: rgba(232, 224, 248, 0.45);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s;
}
.isy-tts-voice-btn.active {
    background: rgba(90, 42, 158, 0.35);
    border-color: rgba(192, 144, 240, 0.5);
    color: rgba(232, 224, 248, 0.9);
}
.isy-tts-stop {
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: transparent;
    color: rgba(232, 224, 248, 0.4);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s;
}
.isy-tts-stop:hover { color: rgba(232, 224, 248, 0.8); }

@media (max-width: 768px) {
    .isy-tts-widget { bottom: 1.2rem; right: 1.2rem; }
    .isy-tts-btn { padding: 0.5rem 1rem 0.5rem 0.75rem; }
}

/* ── DASHBOARD SIDEBAR BACKDROP (mobile) ── */
.isy-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(4, 2, 10, 0.65);
  z-index: 499;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.isy-sidebar-backdrop.visible {
  display: block;
}

/* ── TTS: paragraph highlighting ── */
/* Currently being read: glow slightly brighter */
.isy-tts-current {
    color: var(--moon-white, #e8e0f8) !important;
    opacity: 1 !important;
    transition: color 0.4s, opacity 0.4s;
}
/* Already read: dimmed, soft gold tint to show progress */
.isy-tts-read {
    opacity: 0.38;
    color: rgba(201, 168, 76, 0.7) !important;
    transition: opacity 0.5s, color 0.5s;
}
/* Headings get slightly different read treatment */
.isy-tts-read h1, .isy-tts-read h2, .isy-tts-read h3,
h1.isy-tts-read, h2.isy-tts-read, h3.isy-tts-read {
    opacity: 0.4 !important;
}
