/* ==========================================================================
   effects.css - accent palettes, glass surfaces, cursor sheen, ambient mesh.
   Loaded AFTER style.css. Every visual effect lives inside @media screen so
   style.css keeps full control of print. Paint order: body background ->
   body::before mesh (z-index -1, body is isolated) -> content.
   Sheen = a white radial highlight painted as a BACKGROUND layer of the one
   surface under the pointer (fx.js sets the pointer-position variables on that
   surface only), so text always sits on top of it. A softer accent-tinted glow
   sits under the white highlight so the effect is visible on light surfaces too. All alpha values are tokens the tests read.
   ========================================================================== */

/* 1. Effect constants (dark values appear twice on purpose, like style.css) */
:root { --mesh: 14%; --glass: 78%; --glass-card: 70%; --glass-nav: 95%; --gloss-a: 0.3; --sheen-a: 0.55; --glow: 10%; }
html[data-theme="dark"] { --gloss-a: 0.04; --sheen-a: 0.06; --glow: 4%; }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) { --gloss-a: 0.04; --sheen-a: 0.06; --glow: 4%; }
}

/* 2. Accent palettes. Green is the default and lives in style.css.
      Per accent: light, dark (explicit toggle), dark (system preference). */
html[data-accent="blue"] {
  --bg: #f2f6fd; --surface: #ffffff; --text: #131a2c; --muted: #465470; --border: #d3ddf0;
  --link: #1d4ed8; --accent: #2f6fe0; --header-from: #9cc4ff; --header-to: #7fb0ff; --header-text: #0a1a3a;
  --accent-soft: rgba(47, 111, 224, 0.14); --hover: rgba(19, 26, 44, 0.07); --shadow: 0 10px 24px rgba(19, 40, 90, 0.14);
}
html[data-accent="violet"] {
  --bg: #f6f3fd; --surface: #ffffff; --text: #1a1530; --muted: #55486f; --border: #ddd5f0;
  --link: #5b21b6; --accent: #7c4ddb; --header-from: #cbbcff; --header-to: #b39dff; --header-text: #1a1040;
  --accent-soft: rgba(124, 77, 219, 0.14); --hover: rgba(26, 21, 48, 0.07); --shadow: 0 10px 24px rgba(50, 28, 100, 0.14);
}
html[data-accent="amber"] {
  --bg: #fdf8ec; --surface: #ffffff; --text: #2a2008; --muted: #6b5a33; --border: #efe3c3;
  --link: #8a3a05; --accent: #c26a00; --header-from: #fcd34d; --header-to: #fbbf24; --header-text: #2f1b00;
  --accent-soft: rgba(194, 106, 0, 0.14); --hover: rgba(42, 32, 8, 0.07); --shadow: 0 10px 24px rgba(90, 60, 0, 0.14);
}
html[data-accent="rose"] {
  --bg: #fdf3f5; --surface: #ffffff; --text: #2c1218; --muted: #6e4a53; --border: #f0d5da;
  --link: #be123c; --accent: #e11d48; --header-from: #fda4b4; --header-to: #fb8aa0; --header-text: #3b0614;
  --accent-soft: rgba(225, 29, 72, 0.12); --hover: rgba(44, 18, 24, 0.07); --shadow: 0 10px 24px rgba(100, 20, 40, 0.14);
}

html[data-theme="dark"][data-accent="blue"] {
  --bg: #0c1220; --surface: #141b2d; --text: #e8edf8; --muted: #a8b3cb; --border: #28344f;
  --link: #8fb8ff; --accent: #60a5fa; --header-from: #16305a; --header-to: #0d1c3a; --header-text: #eaf2ff;
  --accent-soft: rgba(96, 165, 250, 0.16); --hover: rgba(255, 255, 255, 0.07); --shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"][data-accent="violet"] {
  --bg: #100d1f; --surface: #1a1630; --text: #ece9fb; --muted: #b0a9cc; --border: #302a52;
  --link: #c4b5fd; --accent: #a78bfa; --header-from: #2e2060; --header-to: #1a1240; --header-text: #f2eeff;
  --accent-soft: rgba(167, 139, 250, 0.16); --hover: rgba(255, 255, 255, 0.07); --shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"][data-accent="amber"] {
  --bg: #15110a; --surface: #1f1a10; --text: #f5eedf; --muted: #bfb297; --border: #3a301a;
  --link: #fbbf24; --accent: #fbbf24; --header-from: #4a3408; --header-to: #2b1e04; --header-text: #fff6dc;
  --accent-soft: rgba(251, 191, 36, 0.16); --hover: rgba(255, 255, 255, 0.07); --shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}
html[data-theme="dark"][data-accent="rose"] {
  --bg: #170c10; --surface: #211318; --text: #f8e9ec; --muted: #c4a9b0; --border: #402430;
  --link: #fda4b4; --accent: #fb7185; --header-from: #5a1228; --header-to: #330a16; --header-text: #ffecef;
  --accent-soft: rgba(251, 113, 133, 0.16); --hover: rgba(255, 255, 255, 0.07); --shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"])[data-accent="blue"] {
    --bg: #0c1220; --surface: #141b2d; --text: #e8edf8; --muted: #a8b3cb; --border: #28344f;
    --link: #8fb8ff; --accent: #60a5fa; --header-from: #16305a; --header-to: #0d1c3a; --header-text: #eaf2ff;
    --accent-soft: rgba(96, 165, 250, 0.16); --hover: rgba(255, 255, 255, 0.07); --shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  }
  html:not([data-theme="light"])[data-accent="violet"] {
    --bg: #100d1f; --surface: #1a1630; --text: #ece9fb; --muted: #b0a9cc; --border: #302a52;
    --link: #c4b5fd; --accent: #a78bfa; --header-from: #2e2060; --header-to: #1a1240; --header-text: #f2eeff;
    --accent-soft: rgba(167, 139, 250, 0.16); --hover: rgba(255, 255, 255, 0.07); --shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  }
  html:not([data-theme="light"])[data-accent="amber"] {
    --bg: #15110a; --surface: #1f1a10; --text: #f5eedf; --muted: #bfb297; --border: #3a301a;
    --link: #fbbf24; --accent: #fbbf24; --header-from: #4a3408; --header-to: #2b1e04; --header-text: #fff6dc;
    --accent-soft: rgba(251, 191, 36, 0.16); --hover: rgba(255, 255, 255, 0.07); --shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  }
  html:not([data-theme="light"])[data-accent="rose"] {
    --bg: #170c10; --surface: #211318; --text: #f8e9ec; --muted: #c4a9b0; --border: #402430;
    --link: #fda4b4; --accent: #fb7185; --header-from: #5a1228; --header-to: #330a16; --header-text: #ffecef;
    --accent-soft: rgba(251, 113, 133, 0.16); --hover: rgba(255, 255, 255, 0.07); --shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
  }
}

/* 3. Screen-only effects */
@media screen {
  /* ambient mesh: three soft accent glows behind the content */
  body { isolation: isolate; }
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
      radial-gradient(60vmax 45vmax at 6% -6%, color-mix(in srgb, var(--accent) var(--mesh), transparent), transparent 70%),
      radial-gradient(50vmax 40vmax at 100% 32%, color-mix(in srgb, var(--accent) var(--mesh), transparent), transparent 70%),
      radial-gradient(55vmax 40vmax at 28% 108%, color-mix(in srgb, var(--accent) var(--mesh), transparent), transparent 70%);
  }

  /* glossy surfaces: sheen follows the pointer on the ACTIVE surface only */
  main section, .card, nav.site-nav { --sx: -999px; --sy: -999px; }
  main section, .card {
    background-color: var(--surface);
    background-color: color-mix(in srgb, var(--surface) var(--glass), transparent);
    background-image:
      radial-gradient(circle 200px at var(--sx) var(--sy), rgba(255, 255, 255, var(--sheen-a)), transparent 70%),
      radial-gradient(circle 380px at var(--sx) var(--sy), color-mix(in srgb, var(--accent) var(--glow), transparent), transparent 70%),
      linear-gradient(135deg, rgba(255, 255, 255, var(--gloss-a)), transparent 45%);
  }
  #projects .card {
    background-color: var(--bg);
    background-color: color-mix(in srgb, var(--bg) var(--glass-card), transparent);
    background-image:
      radial-gradient(circle 200px at var(--sx) var(--sy), rgba(255, 255, 255, var(--sheen-a)), transparent 70%),
      radial-gradient(circle 380px at var(--sx) var(--sy), color-mix(in srgb, var(--accent) var(--glow), transparent), transparent 70%),
      linear-gradient(135deg, rgba(255, 255, 255, var(--gloss-a)), transparent 45%);
  }
  nav.site-nav {
    background-color: var(--surface);
    background-color: color-mix(in srgb, var(--surface) var(--glass-nav), transparent);
    background-image:
      radial-gradient(circle 200px at var(--sx) var(--sy), rgba(255, 255, 255, var(--sheen-a)), transparent 70%),
      radial-gradient(circle 380px at var(--sx) var(--sy), color-mix(in srgb, var(--accent) var(--glow), transparent), transparent 70%),
      linear-gradient(135deg, rgba(255, 255, 255, var(--gloss-a)), transparent 45%);
  }

  /* thin scroll-progress bar under the nav (progressive enhancement, CSS only) */
  @supports (animation-timeline: scroll()) {
    nav.site-nav::after {
      content: "";
      position: absolute;
      left: 0;
      bottom: -1px;
      width: 100%;
      height: 3px;
      background: var(--accent);
      transform: scaleX(0);
      transform-origin: 0 50%;
      animation: scroll-progress linear both;
      animation-timeline: scroll(root block);
    }
    @keyframes scroll-progress { to { transform: scaleX(1); } }
  }

  @media (prefers-reduced-motion: reduce) {
    nav.site-nav::after { display: none; }
  }
  @media (prefers-reduced-transparency: reduce) {
    main section, .card, nav.site-nav { background-color: var(--surface) !important; }
    #projects .card { background-color: var(--bg) !important; }
    body::before { display: none; }
  }
  @supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    nav.site-nav { background-color: var(--surface); }
  }
}

/* 4. Print: undo accent colours so paper output stays black on white */
@media print {
  body::before { display: none !important; }
  html, html[data-accent], html[data-theme][data-accent], html:not([data-theme="light"])[data-accent] {
    --text: #000000 !important; --muted: #333333 !important; --link: #000000 !important; --border: #999999 !important;
    --surface: #ffffff !important; --bg: #ffffff !important;
  }
}
