/* =========================================================================
   ENHANCE.CSS — optional "expensive restraint" layer for FCS
   Load AFTER styles.css. Everything here degrades gracefully and is fully
   disabled under prefers-reduced-motion.
   ========================================================================= */

/* ---- 1. Scroll progress hairline -------------------------------------- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: var(--ink);
  z-index: 200;
  pointer-events: none;
}
.on-dark:not(.is-scrolled) ~ .scroll-progress,
body:has(.site-header.on-dark:not(.is-scrolled)) .scroll-progress { background: var(--on-dark); }

/* ---- 2. Fine grain (adds depth, most visible on dark) ----------------- */
.grain {
  position: fixed;
  inset: 0;
  z-index: 150;
  pointer-events: none;
  opacity: .05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 140px 140px;
}

/* ---- 3. Kinetic hero (word fade-up, no clipping) --------------------- */
html.js .hero-title.kin-ready { opacity: 1; transform: none; }   /* release base reveal */
.hero-title .word {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.42em);
  transition: opacity .7s var(--ease), transform .9s cubic-bezier(.16,1,.3,1);
  will-change: opacity, transform;
}
.hero-title.kin-in .word { opacity: 1; transform: none; }

/* ---- 4. Magnetic + refined quiet links -------------------------------- */
.link-quiet { transition: color var(--dur-1) var(--ease); }
.link-quiet .arrow { transition: transform var(--dur-2) var(--ease); display: inline-block; }
.link-quiet:hover .arrow { transform: translateX(6px); }
[data-magnetic] { transition: transform var(--dur-2) cubic-bezier(.16,1,.3,1); will-change: transform; }

/* ---- 5. Self-drawing coordination diagram ----------------------------- */
.diagram-sec .diagram-wrap { max-width: 940px; margin: var(--space-6) auto 0; }
.coord-diagram { width: 100%; height: auto; display: block; }

.coord-diagram .edge {
  stroke: var(--line-dark);
  stroke-width: 1;
  fill: none;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.1s cubic-bezier(.65,0,.35,1);
}
.coord-diagram .node-ring,
.coord-diagram .node-dot,
.coord-diagram .node-label {
  opacity: 0;
  transition: opacity .7s var(--ease);
}
.coord-diagram .core-ring {
  opacity: 0;
  transform: scale(.6);
  transform-origin: center;
  transition: opacity .8s var(--ease), transform .9s cubic-bezier(.16,1,.3,1);
}
.coord-diagram .core-label { opacity: 0; transition: opacity .7s var(--ease) .2s; }
.coord-diagram .core-logo  { opacity: 0; transition: opacity .8s var(--ease) .3s; }
.coord-diagram.drawn .core-logo { opacity: 1; }

/* draw sequence */
.coord-diagram.drawn .core-ring  { opacity: 1; transform: scale(1); }
.coord-diagram.drawn .core-label { opacity: 1; }
.coord-diagram.drawn .edge       { stroke-dashoffset: 0; }
.coord-diagram.drawn .edge:nth-of-type(1) { transition-delay: .25s; }
.coord-diagram.drawn .edge:nth-of-type(2) { transition-delay: .33s; }
.coord-diagram.drawn .edge:nth-of-type(3) { transition-delay: .41s; }
.coord-diagram.drawn .edge:nth-of-type(4) { transition-delay: .49s; }
.coord-diagram.drawn .edge:nth-of-type(5) { transition-delay: .57s; }
.coord-diagram.drawn .edge:nth-of-type(6) { transition-delay: .65s; }
.coord-diagram.drawn .node-ring,
.coord-diagram.drawn .node-dot,
.coord-diagram.drawn .node-label { opacity: 1; transition-delay: 1s; }

.coord-diagram .core-ring, .coord-diagram .node-ring { fill: none; stroke: var(--line-dark); stroke-width: 1; }
.coord-diagram .core-fill { fill: var(--paper); }
.coord-diagram .node-dot  { fill: var(--on-dark); }
.coord-diagram .core-label { fill: var(--ink); }
.coord-diagram .node-label { fill: var(--on-dark-mute); font-family: var(--font-sans); font-size: 13px; letter-spacing: .04em; }
.coord-diagram .node-label.k { fill: var(--on-dark); }

/* ---- 6. Page transition (View Transitions API) ------------------------ */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out .35s var(--ease) both; }
::view-transition-new(root) { animation: vt-in .45s var(--ease) both; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in  { from { opacity: 0; } }

/* ---- Reduced motion: neutralise everything ---------------------------- */
@media (prefers-reduced-motion: reduce) {
  .scroll-progress { display: none; }
  .grain { display: none; }
  .hero-title .word { opacity: 1 !important; transform: none !important; }
  .coord-diagram .edge { stroke-dashoffset: 0; transition: none; }
  .coord-diagram .core-ring, .coord-diagram .core-label,
  .coord-diagram .node-ring, .coord-diagram .node-dot, .coord-diagram .node-label {
    opacity: 1; transform: none; transition: none;
  }
  [data-magnetic] { transform: none !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

/* ---- 7. Section index numeral (editorial detail) ---------------------- */
.sec-index {
  display: block;
  font-size: .72rem;
  letter-spacing: .12em;
  color: var(--accent);
  margin-bottom: .6rem;
}
.theme-dark .sec-index { color: var(--on-dark-mute); }

/* ---- 8. Interactive ecosystem map (Family Office) --------------------- */
.eco-sec .eco-wrap { max-width: 960px; margin: var(--space-6) auto 0; }
.eco-map { width: 100%; height: auto; display: block; touch-action: manipulation; }

.eco-map .eco-edge {
  stroke: var(--line);
  stroke-width: 1;
  fill: none;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1s cubic-bezier(.65,0,.35,1), stroke .35s var(--ease), stroke-width .35s var(--ease);
}
.eco-map.drawn .eco-edge { stroke-dashoffset: 0; }
.eco-map.drawn .eco-edge:nth-of-type(1){transition-delay:.2s}
.eco-map.drawn .eco-edge:nth-of-type(2){transition-delay:.28s}
.eco-map.drawn .eco-edge:nth-of-type(3){transition-delay:.36s}
.eco-map.drawn .eco-edge:nth-of-type(4){transition-delay:.44s}
.eco-map.drawn .eco-edge:nth-of-type(5){transition-delay:.52s}
.eco-map.drawn .eco-edge:nth-of-type(6){transition-delay:.6s}

.eco-map .eco-node { cursor: pointer; }
.eco-map .eco-node circle { fill: var(--paper); stroke: var(--line); stroke-width: 1; transition: stroke .35s var(--ease), opacity .35s var(--ease); }
.eco-map .eco-node text  { fill: var(--slate); font-family: var(--font-sans); font-size: 13px; letter-spacing: .03em; transition: fill .35s var(--ease), opacity .35s var(--ease); }
.eco-map .eco-node { opacity: 0; transition: opacity .6s var(--ease); }
.eco-map.drawn .eco-node { opacity: 1; transition-delay: .9s; }
.eco-map .eco-node:focus { outline: none; }
.eco-map .eco-node:focus circle { stroke: var(--ink); stroke-width: 1.5; }
.eco-map .eco-node:focus-visible circle { stroke: var(--ink); stroke-width: 1.5; }

/* core */
.eco-map .eco-core circle { fill: var(--ink); stroke: none; }
.eco-map .eco-core .core-t1 { fill: var(--paper); font-size: 16px; font-weight: 500; letter-spacing: .01em; }
.eco-map .eco-core .core-t2 { fill: var(--on-dark-mute); font-size: 10.5px; letter-spacing: .14em; }

/* active / dim states */
.eco-map.has-active .eco-node:not(.active) { opacity: .3; }
.eco-map.has-active .eco-edge:not(.active) { stroke: var(--line); opacity: .28; }
.eco-map .eco-node.active circle { stroke: var(--ink); stroke-width: 1.5; }
.eco-map .eco-node.active text   { fill: var(--ink); }
.eco-map .eco-edge.active { stroke: var(--ink); stroke-width: 1.5; opacity: 1; }

.eco-caption {
  margin-top: var(--space-4);
  min-height: 3.2em;
  max-width: 46ch;
  color: var(--graphite);
  transition: opacity .3s var(--ease);
}
.eco-caption strong { color: var(--ink); font-weight: 500; }
.eco-hint { color: var(--slate); font-size: .86rem; }

/* ---- 9. Brand logo: invert to white where header sits over dark ------ */
.site-header.on-dark:not(.is-scrolled) .wordmark .logo { filter: brightness(0) invert(1); }
body.menu-open .wordmark .logo { filter: none !important; }
