/**
 * File:     main.css
 * Project:  CatalystLivingLibrary
 * Author:   Thomas Dobler - SYNTHETIXMIND
 * Version:  1.1.0
 * Created:  2026-10-08
 * Updated:  2026-10-08
 */

/*
 * Living Library integration styles. Everything is scoped to .living-library (the canvas
 * container) and .living-library-overlay, so the host hero keeps its own styling. The host hero
 * needs position: relative, isolation: isolate and overflow: hidden; its content sits at z-index 2.
 */

/* The host's --color-* tokens are the palette; the hex values are fallbacks for a page without
   them (the development preview). */
:root {
  --ce-deep-space: var(--color-deep-space, #2d3142);
  --ce-digital-blue: var(--color-digital-blue, #058ed9);
  --ce-steel-mist: var(--color-steel-mist, #7a93ac);
  --ce-cloud-white: var(--color-cloud-white, #eef0f2);
  --ce-golden-accent: var(--color-golden-accent, #bf9b30);
  --ce-deep-space-mid: #292d3c;
  --ce-deep-space-low: #222635;
  /* Must match RENDERER.fadeInMs in js/config.js. */
  --ll-fade-duration: 1200ms;
}

/* Canvas container: decorative layer behind the hero content, CSS fallback included. */
.living-library {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  isolation: isolate;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 84% 20%, rgba(5, 142, 217, 0.18) 0%, rgba(5, 142, 217, 0.04) 28%, transparent 58%),
    radial-gradient(ellipse at 14% 80%, rgba(122, 147, 172, 0.15) 0%, transparent 46%),
    linear-gradient(135deg, var(--ce-deep-space) 0%, var(--ce-deep-space-mid) 55%, var(--ce-deep-space-low) 100%);
}

/* Two thin outline frames: the static "pages" of the fallback. */
.living-library::before,
.living-library::after {
  position: absolute;
  z-index: 0;
  content: "";
  pointer-events: none;
  opacity: 0.16;
  border: 1px solid rgba(238, 240, 242, 0.22);
  transform: rotate(-11deg);
  transition: opacity var(--ll-fade-duration) ease;
}

.living-library::before {
  top: 10%;
  right: -10%;
  width: 32rem;
  height: 18rem;
}

.living-library::after {
  bottom: -18%;
  left: -8%;
  width: 24rem;
  height: 34rem;
  border-color: rgba(122, 147, 172, 0.3);
}

.living-library__canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--ll-fade-duration) ease;
}

/* After the first WebGL frame: show the canvas, retire the fallback frames. */
.living-library[data-ll-ready="true"] .living-library__canvas {
  opacity: 1;
}

.living-library[data-ll-ready="true"]::before,
.living-library[data-ll-ready="true"]::after {
  opacity: 0;
}

/* Contrast protection for centred hero copy. */
.living-library-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(
    ellipse 60% 55% at 50% 50%,
    rgba(45, 49, 66, 0.82) 0%,
    rgba(45, 49, 66, 0.5) 55%,
    rgba(45, 49, 66, 0) 100%
  );
}

/* Contrast protection for copy BESIDE the scene (a left column): dark across the copy, clearing
   over the scene. --ll-copy-edge is the copy's right edge, set by the loader from the measured
   quiet zone; 60% is the default until it has been measured. */
.living-library-overlay--beside-copy {
  background: linear-gradient(
    90deg,
    rgba(45, 49, 66, 0.86) 0%,
    rgba(45, 49, 66, 0.86) var(--ll-copy-edge, 60%),
    rgba(45, 49, 66, 0.55) calc(var(--ll-copy-edge, 60%) + 8%),
    rgba(45, 49, 66, 0) calc(var(--ll-copy-edge, 60%) + 30%)
  );
}

@media (max-width: 767px) {
  .living-library-overlay,
  .living-library-overlay--beside-copy {
    background: rgba(45, 49, 66, 0.76);
  }
}

@media (prefers-reduced-motion: reduce) {
  .living-library::before,
  .living-library::after,
  .living-library__canvas {
    transition: none;
  }
}
