:root {
  --brass: #D8B35A;
  --jade: #75B8A8;
  --hanji: #F7F0DF;
  --warm: #FFF9E8;
  --pine: #2A473C;
  --indigo: #101633;
  --persimmon: #E05A2A;
  --violet: #8B5D7C;
  --display-ko: 'Gowun Batang', serif;
  --body-ko: 'IBM Plex Sans KR', sans-serif;
  --poetic: 'Cormorant Garamond', serif;
  --mono: 'Fragment Mono', monospace;
}

/* Typography compliance: IBM Plex Sans KR IBM Plex Sans KR** for explanatory Korean copy and calm interface labels. Use **Cormorant Garamond** for poetic English scene titles and domain inscriptions. */

@keyframes threadPulse {
  0% { opacity: .72; }
  50% { opacity: 1; }
  100% { opacity: .72; }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--indigo);
  color: var(--warm);
  font-family: var(--body-ko);
  overflow-x: hidden;
}

.compliance-thread {
  position: fixed;
  left: -100vw;
  top: -100vh;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  opacity: .36;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(255,249,232,.15) 0 1px, transparent 1.5px),
    radial-gradient(circle at 70% 40%, rgba(247,240,223,.13) 0 1px, transparent 1.5px),
    radial-gradient(circle at 40% 80%, rgba(216,179,90,.10) 0 1px, transparent 1.5px);
  background-size: 23px 29px, 31px 37px, 41px 43px;
  mix-blend-mode: screen;
}

#fiber-canvas {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: .52;
}

.thread-stage {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
}

.thread-svg { width: 100%; height: 100%; overflow: visible; }

#red-thread, #gold-thread {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1500;
}

#red-thread {
  stroke: var(--persimmon);
  stroke-width: 3.2;
  filter: drop-shadow(0 0 12px rgba(224,90,42,.45));
  animation: threadPulse 5s ease-in-out infinite;
}

#gold-thread {
  stroke: rgba(216,179,90,.75);
  stroke-width: 1.6;
}

.fixed-mark {
  position: fixed;
  top: 26px;
  left: 32px;
  right: 32px;
  z-index: 16;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  pointer-events: none;
}

.domain-stitch {
  font-family: var(--display-ko);
  color: var(--hanji);
  font-size: clamp(1.1rem, 2vw, 1.65rem);
  letter-spacing: .04em;
  text-shadow: 0 0 20px rgba(247,240,223,.25);
}

.decimal-seed, .probability-notches, .conditional-fragments, .pull-tab, .scene-label {
  font-family: var(--mono);
  text-transform: lowercase;
  letter-spacing: .08em;
}

.decimal-seed { color: rgba(247,240,223,.62); font-size: .7rem; }

.scene {
  position: relative;
  min-height: 100vh;
  isolation: isolate;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 8rem clamp(1.2rem, 5vw, 5.5rem);
}

.scene::before {
  content: '';
  position: absolute;
  inset: -15%;
  z-index: -3;
  background:
    linear-gradient(120deg, rgba(117,184,168,.13), transparent 38%),
    radial-gradient(circle at 72% 21%, rgba(139,93,124,.34), transparent 28%),
    radial-gradient(circle at 18% 78%, rgba(216,179,90,.18), transparent 24%);
}

.scene-fold { background: linear-gradient(160deg, var(--indigo) 0%, #18223f 55%, var(--pine) 160%); }
.scene-thread { background: linear-gradient(18deg, var(--hanji) 0%, #efe1c4 54%, #c8d8c9 100%); color: var(--pine); }
.scene-knot { background: radial-gradient(circle at 50% 45%, #263f3a 0%, var(--pine) 46%, var(--indigo) 100%); }
.scene-unwrap { background: linear-gradient(90deg, var(--warm), var(--hanji) 38%, #d7ebe5 100%); color: var(--indigo); }

.scene-label {
  position: absolute;
  top: 7rem;
  left: clamp(1.2rem, 5vw, 5.5rem);
  z-index: 8;
  color: var(--brass);
  font-size: .72rem;
}

.giant-hangul {
  position: absolute;
  left: -7vw;
  top: 6vh;
  font-family: var(--display-ko);
  font-size: clamp(10rem, 31vw, 30rem);
  font-weight: 700;
  color: rgba(247,240,223,.075);
  line-height: .72;
  z-index: -1;
  transform: rotate(-5deg);
}

.scene-copy {
  position: relative;
  z-index: 7;
  max-width: 660px;
}

.hero-copy { justify-self: end; margin-top: 16vh; }
.side-copy { justify-self: start; align-self: end; margin-bottom: 5vh; }
.center-copy { text-align: center; max-width: 760px; }
.unwrap-copy { justify-self: start; align-self: end; margin-bottom: 2vh; }

.english-title {
  font-family: var(--poetic);
  font-size: clamp(1.35rem, 3vw, 2.6rem);
  font-style: italic;
  color: var(--brass);
  margin: 0 0 .8rem;
}

h1, h2 {
  font-family: var(--display-ko);
  font-weight: 400;
  line-height: 1.18;
  margin: 0;
}

h1 { font-size: clamp(2.4rem, 6vw, 5.8rem); max-width: 880px; }
h2 { font-size: clamp(2rem, 4.4vw, 4.6rem); }

p {
  font-size: clamp(1rem, 1.35vw, 1.25rem);
  line-height: 1.85;
  font-weight: 300;
}

.patchwork {
  position: absolute;
  inset: 0;
  z-index: 3;
  transform-style: preserve-3d;
  transition: transform .25s ease-out;
}

.cloth {
  position: absolute;
  border: 1px solid rgba(255,249,232,.42);
  box-shadow: inset 0 0 34px rgba(255,249,232,.14), 0 20px 60px rgba(16,22,51,.22);
  backdrop-filter: blur(2px);
  background-image:
    linear-gradient(90deg, rgba(255,255,255,.18) 1px, transparent 1px),
    linear-gradient(0deg, rgba(16,22,51,.10) 1px, transparent 1px);
  background-size: 34px 34px, 34px 34px;
}

.cloth::after {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(42,71,60,.35);
}

.jade { background-color: rgba(117,184,168,.54); }
.cream { background-color: rgba(247,240,223,.58); }
.brass { background-color: rgba(216,179,90,.54); }
.violet { background-color: rgba(139,93,124,.48); }
.persimmon { background-color: rgba(224,90,42,.66); }
.indigo { background-color: rgba(16,22,51,.50); }

.patchwork-hero .large { width: 44vw; height: 52vh; left: 12vw; top: 19vh; transform: rotate(-7deg); }
.patchwork-hero .tall { width: 23vw; height: 74vh; left: 43vw; top: 8vh; transform: rotate(4deg); }
.patchwork-hero .small { width: 18vw; height: 22vh; left: 62vw; top: 53vh; transform: rotate(-11deg); }
.patchwork-hero .wide { width: 39vw; height: 29vh; left: 5vw; top: 61vh; transform: rotate(2deg); }
.patchwork-hero .sliver { width: 7vw; height: 58vh; right: 8vw; top: 15vh; transform: rotate(8deg); }

.pull-tab {
  position: absolute;
  right: 9vw;
  bottom: 12vh;
  z-index: 10;
  border: 1px solid rgba(224,90,42,.75);
  color: var(--persimmon);
  background: rgba(16,22,51,.30);
  padding: .85rem 1.1rem;
  cursor: pointer;
}

.body-pulled .patchwork-hero .tall { transform: translateX(11vw) rotate(15deg); opacity: .45; }
.body-pulled .domain-stitch { color: var(--persimmon); }

.moon-jar {
  position: absolute;
  width: min(52vw, 620px);
  aspect-ratio: 1;
  border-radius: 49% 51% 46% 54%;
  border: 1px solid rgba(42,71,60,.18);
  background: radial-gradient(circle at 42% 35%, rgba(255,249,232,.95), rgba(247,240,223,.24) 48%, transparent 69%);
  filter: blur(.2px);
}

.thread-grid .long { width: 62vw; height: 19vh; left: 20vw; top: 19vh; transform: rotate(-4deg); }
.thread-grid .square { width: 26vw; height: 34vh; left: 10vw; top: 43vh; transform: rotate(7deg); }
.thread-grid .blade { width: 11vw; height: 78vh; right: 19vw; top: 12vh; transform: rotate(-13deg); }
.thread-grid .corner { width: 29vw; height: 22vh; right: 4vw; bottom: 10vh; transform: rotate(5deg); }

.probability-notches {
  position: absolute;
  right: 4vw;
  top: 20vh;
  z-index: 8;
  display: grid;
  gap: 1.2rem;
  color: var(--pine);
}

.probability-notches span {
  border-left: 1px solid var(--persimmon);
  padding-left: .8rem;
}

.knot-orbit {
  position: absolute;
  width: min(70vw, 760px);
  aspect-ratio: 1;
  border: 1px dashed rgba(247,240,223,.22);
  border-radius: 50%;
  transform: rotate(var(--orbit, 0deg));
}

.knot-orbit::before, .knot-orbit::after {
  content: '';
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--jade);
  border-right-color: rgba(216,179,90,.65);
  transform: rotate(28deg);
}

.knot-orbit::after { inset: 31%; border-top-color: var(--persimmon); transform: rotate(-41deg); }

.bead {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--persimmon);
  box-shadow: 0 0 22px rgba(224,90,42,.75);
}

.bead-one { left: 18%; top: 30%; }
.bead-two { right: 24%; top: 16%; width: 11px; height: 11px; }
.bead-three { right: 34%; bottom: 20%; width: 24px; height: 24px; }

.needle {
  position: absolute;
  width: 48%;
  height: 2px;
  left: 26%;
  top: 50%;
  background: linear-gradient(90deg, transparent, var(--brass), var(--warm));
  transform: rotate(-18deg);
}

.conditional-fragments {
  position: absolute;
  bottom: 12vh;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  color: rgba(247,240,223,.72);
}

.conditional-fragments span {
  border: 1px solid rgba(247,240,223,.22);
  padding: .55rem .75rem;
  background: rgba(16,22,51,.22);
}

.unroll-track {
  position: absolute;
  left: 12vw;
  top: 16vh;
  width: 180vw;
  height: 44vh;
  z-index: 4;
  display: flex;
  transform: translateX(var(--unroll, 0px)) rotate(-2deg);
  transition: transform .12s linear;
}

.bolt {
  position: relative;
  width: 45vw;
  min-width: 360px;
  height: 100%;
  border: 1px solid rgba(42,71,60,.28);
  display: grid;
  place-items: center;
  font-family: var(--display-ko);
  font-size: clamp(2rem, 5vw, 5rem);
  color: rgba(16,22,51,.58);
  box-shadow: inset 0 0 50px rgba(255,249,232,.28);
}

.bolt::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(90deg, rgba(42,71,60,.16) 1px, transparent 1px), linear-gradient(0deg, rgba(42,71,60,.10) 1px, transparent 1px);
  background-size: 38px 38px;
}

.bolt-one { background: rgba(117,184,168,.45); }
.bolt-two { background: rgba(216,179,90,.42); }
.bolt-three { background: rgba(139,93,124,.32); }
.bolt-four { background: rgba(224,90,42,.24); }

.scene-nav {
  position: fixed;
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 18;
  display: grid;
  gap: .7rem;
}

.scene-nav a {
  font-family: var(--poetic);
  color: rgba(255,249,232,.58);
  text-decoration: none;
  font-size: 1.05rem;
  transition: color .25s ease, transform .25s ease;
}

.scene-nav a.active { color: var(--persimmon); transform: translateX(-6px); }

@media (max-width: 760px) {
  .fixed-mark { left: 18px; right: 18px; top: 18px; }
  .decimal-seed, .scene-nav { display: none; }
  .scene { padding: 7rem 1.2rem; place-items: end start; }
  .hero-copy, .side-copy, .unwrap-copy { justify-self: start; margin: 0; }
  .patchwork-hero .large { width: 70vw; left: -4vw; }
  .patchwork-hero .tall { width: 36vw; left: 50vw; }
  .probability-notches { right: 1rem; top: 13vh; }
  .unroll-track { left: 5vw; width: 260vw; }
}
*** Add File: sites/확률.com-v1/script.js
(function () {
  const body = document.body;
  const redThread = document.getElementById('red-thread');
  const goldThread = document.getElementById('gold-thread');
  const pullTab = document.getElementById('pull-tab');
  const navLinks = Array.from(document.querySelectorAll('.scene-nav a'));
  const scenes = Array.from(document.querySelectorAll('.scene'));
  const tiltLayers = Array.from(document.querySelectorAll('[data-tilt]'));
  const unrollTrack = document.getElementById('unroll-track');
  const knotOrbit = document.getElementById('knot-orbit');
  const canvas = document.getElementById('fiber-canvas');
  const ctx = canvas.getContext('2d');

  let width = 0;
  let height = 0;
  let threadLength = 1500;
  let goldLength = 1500;
  let mouseX = 0;
  let mouseY = 0;
  let fibers = [];

  function resizeCanvas() {
    width = window.innerWidth;
    height = window.innerHeight;
    canvas.width = width * window.devicePixelRatio;
    canvas.height = height * window.devicePixelRatio;
    canvas.style.width = width + 'px';
    canvas.style.height = height + 'px';
    ctx.setTransform(window.devicePixelRatio, 0, 0, window.devicePixelRatio, 0, 0);
    fibers = Array.from({ length: 95 }, function (_, index) {
      return {
        x: (index * 97) % width,
        y: (index * 53) % height,
        drift: 0.25 + (index % 7) * 0.035,
        size: 1 + (index % 4) * 0.45,
        phase: index * 0.61
      };
    });
  }

  function setupThreads() {
    threadLength = redThread.getTotalLength();
    goldLength = goldThread.getTotalLength();
    redThread.style.strokeDasharray = threadLength;
    goldThread.style.strokeDasharray = goldLength;
  }

  function scrollRatio() {
    const max = document.documentElement.scrollHeight - window.innerHeight;
    return max > 0 ? window.scrollY / max : 0;
  }

  function updateScrollVisuals() {
    const ratio = scrollRatio();
    redThread.style.strokeDashoffset = String(threadLength * (1 - Math.min(1, ratio * 1.15)));
    goldThread.style.strokeDashoffset = String(goldLength * (1 - Math.max(0, ratio - 0.24) * 1.45));

    if (knotOrbit) {
      knotOrbit.style.setProperty('--orbit', (ratio * 260).toFixed(2) + 'deg');
    }

    if (unrollTrack) {
      const rect = document.getElementById('unwrap').getBoundingClientRect();
      const local = Math.min(1, Math.max(0, (window.innerHeight - rect.top) / (window.innerHeight + rect.height)));
      unrollTrack.style.setProperty('--unroll', (-local * window.innerWidth * 0.55).toFixed(1) + 'px');
    }

    scenes.forEach(function (scene) {
      const rect = scene.getBoundingClientRect();
      const middle = window.innerHeight * 0.5;
      const active = rect.top <= middle && rect.bottom >= middle;
      if (active) {
        navLinks.forEach(function (link) {
          link.classList.toggle('active', link.getAttribute('href') === '#' + scene.id);
        });
      }
    });
  }

  function drawFibers(time) {
    ctx.clearRect(0, 0, width, height);
    fibers.forEach(function (fiber, index) {
      const sway = Math.sin(time * 0.00035 + fiber.phase) * 14;
      const x = (fiber.x + sway + mouseX * 8 * fiber.drift) % width;
      const y = (fiber.y + time * 0.006 * fiber.drift + mouseY * 5) % height;
      ctx.beginPath();
      ctx.fillStyle = index % 6 === 0 ? 'rgba(216,179,90,0.22)' : 'rgba(255,249,232,0.16)';
      ctx.ellipse(x, y, fiber.size * 2.3, fiber.size * 0.55, fiber.phase, 0, Math.PI * 2);
      ctx.fill();
    });
  }

  function animate(time) {
    updateScrollVisuals();
    drawFibers(time);
    requestAnimationFrame(animate);
  }

  window.addEventListener('resize', function () {
    resizeCanvas();
    setupThreads();
    updateScrollVisuals();
  });

  window.addEventListener('pointermove', function (event) {
    mouseX = event.clientX / window.innerWidth - 0.5;
    mouseY = event.clientY / window.innerHeight - 0.5;
    tiltLayers.forEach(function (layer) {
      layer.style.transform = 'rotateX(' + (-mouseY * 3).toFixed(2) + 'deg) rotateY(' + (mouseX * 4).toFixed(2) + 'deg)';
    });
  });

  pullTab.addEventListener('click', function () {
    body.classList.toggle('body-pulled');
  });

  navLinks.forEach(function (link) {
    link.addEventListener('click', function () {
      body.classList.add('body-pulled');
    });
  });

  resizeCanvas();
  setupThreads();
  updateScrollVisuals();
  requestAnimationFrame(animate);
}());
