/* mind-web — cosmic neural identity layer
 *
 * Visual translation only. The validated graph, node kinds, focus-relative
 * space, WebGPU/SVG ownership and privacy rules stay untouched. This layer
 * makes the existing semantic system read as one living cosmic/neural field:
 * source -> identity -> organizations -> implementations.
 */

:root {
  --core-gold: #f4c76b;
  --identity-blue: #5597DA;
  --organization-violet: #906FC8;
  --market-green: #93C482;
  --protocol-indigo: #7765C6;
  --cosmos-ink: #03050a;
  --cosmos-panel: rgba(5, 8, 17, 0.58);
  --cosmos-line: rgba(180, 198, 255, 0.15);
}

/* Provider-neutral palette: identity blue, then positional organization accents. */
html[data-accent="sky"] {
  --accent: var(--identity-blue);
  --accent-soft: rgba(72, 168, 255, 0.2);
}

html[data-accent="violet"] {
  --accent: var(--organization-violet);
  --accent-soft: rgba(154, 99, 255, 0.2);
}

html[data-accent="amber"] {
  --accent: var(--market-green);
  --accent-soft: rgba(119, 217, 87, 0.2);
}

body {
  background:
    radial-gradient(circle at 76% 12%, rgba(244, 199, 107, 0.09), transparent 18rem),
    radial-gradient(circle at 18% 37%, rgba(72, 168, 255, 0.08), transparent 24rem),
    radial-gradient(circle at 72% 50%, rgba(154, 99, 255, 0.08), transparent 26rem),
    radial-gradient(circle at 30% 83%, rgba(119, 217, 87, 0.045), transparent 22rem),
    var(--cosmos-ink);
}

#app::before,
#app::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -6;
  pointer-events: none;
}

/* Fine star field, intentionally CSS-only: no authored JS and no second
   renderer competing with WebGPU. */
#app::before {
  opacity: 0.65;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.54) 0 0.65px, transparent 0.8px),
    radial-gradient(circle, rgba(139,176,255,.38) 0 0.55px, transparent 0.72px),
    radial-gradient(circle, rgba(244,199,107,.35) 0 0.55px, transparent 0.72px);
  background-size: 91px 91px, 137px 137px, 181px 181px;
  background-position: 11px 17px, 37px 61px, 83px 23px;
  mask-image: linear-gradient(to bottom, #000 0 88%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 0 88%, transparent);
}

#app::after {
  background:
    linear-gradient(112deg, transparent 0 47%, rgba(116,146,255,.028) 48%, transparent 49%),
    linear-gradient(32deg, transparent 0 58%, rgba(244,199,107,.024) 59%, transparent 60%);
}

.entity-field__grid {
  opacity: 0.14;
  background-size: 72px 72px;
  mask-image: radial-gradient(circle at 58% 43%, #000 0 14%, rgba(0,0,0,.55) 38%, transparent 68%);
  -webkit-mask-image: radial-gradient(circle at 58% 43%, #000 0 14%, rgba(0,0,0,.55) 38%, transparent 68%);
}

.entity-field__orb {
  left: 64%;
  top: 38%;
  width: min(84vw, 62rem);
  opacity: 0.2;
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.16) 0 0.5%, transparent 1.1%),
    radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--accent), transparent 58%), transparent 23%),
    radial-gradient(circle at 50% 50%, rgba(3,5,10,0), rgba(3,5,10,.9) 70%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  min-height: 4.2rem;
  padding: calc(0.65rem + env(safe-area-inset-top)) var(--content-gutter) 0.65rem;
  border-bottom: 1px solid rgba(180,198,255,.09);
  background: linear-gradient(180deg, rgba(3,5,10,.94), rgba(3,5,10,.72));
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
}

.brand {
  letter-spacing: -0.035em;
}

.brand-mark {
  color: var(--core-gold);
  filter: drop-shadow(0 0 0.75rem rgba(244,199,107,.65));
}

.fork-switcher a.fork-switcher__organization {
  color: var(--muted);
  border-color: color-mix(in srgb, var(--accent), transparent 82%);
}

.fork-switcher a.fork-switcher__organization:hover,
.fork-switcher a.fork-switcher__organization:focus-visible,
.fork-switcher a.fork-switcher__organization[aria-current] {
  color: color-mix(in srgb, var(--accent), white 42%);
  border-color: color-mix(in srgb, var(--accent), transparent 48%);
  box-shadow: inset 0 0 1.5rem color-mix(in srgb, var(--accent), transparent 88%);
}

/* Hero becomes the source statement above the graph instead of a separate
   marketing panel. The gold source stays conceptual and never enters graph.v1. */
.shell-intro {
  position: relative;
  min-height: clamp(25rem, 58dvh, 44rem);
  padding: clamp(5rem, 13vw, 8rem) 0 clamp(2.25rem, 7vw, 4.5rem);
  grid-template-columns: minmax(0, 1fr);
  align-content: end;
  gap: 1.5rem;
}

.shell-intro::before {
  inset: 2% auto auto 50%;
  width: clamp(13rem, 36vw, 25rem);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translateX(-50%);
  background:
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.95) 0 0.7%, rgba(255,224,157,.92) 1%, rgba(244,199,107,.42) 5%, rgba(244,199,107,.13) 19%, transparent 45%),
    conic-gradient(from 18deg, transparent, rgba(244,199,107,.11), transparent 20%, rgba(244,199,107,.08), transparent 48%, rgba(244,199,107,.12), transparent 72%);
  filter: drop-shadow(0 0 2.6rem rgba(244,199,107,.21));
  opacity: 1;
}

.shell-intro::after {
  content: "CORE  †\A soul / source\A from core, identity emerges.\A from identity, creation follows.";
  position: absolute;
  top: clamp(2.5rem, 8vw, 4.5rem);
  left: 50%;
  z-index: 4;
  width: min(25rem, 82vw);
  transform: translateX(-50%);
  color: rgba(244,199,107,.82);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: clamp(.61rem, 1.7vw, .75rem);
  font-weight: 540;
  line-height: 1.75;
  letter-spacing: .12em;
  text-align: center;
  text-transform: uppercase;
  white-space: pre-line;
  text-shadow: 0 0 1.25rem rgba(244,199,107,.28);
}

.shell-intro > div:first-child,
.shell-intro__anonymous,
.shell-intro__copy {
  width: min(100%, 52rem);
  margin-inline: auto;
  text-align: center;
}

.shell-intro__anonymous {
  align-self: end;
}

.shell-intro__copy--anonymous {
  margin-top: 0;
}

.shell-intro > div:first-child::before {
  display: none;
}

.route {
  color: rgba(180,198,255,.6);
  letter-spacing: .26em;
  text-transform: uppercase;
}

.hero__signal {
  justify-content: center;
  color: color-mix(in srgb, var(--accent), white 22%);
}

.shell-intro h1 {
  margin-top: 1.25rem;
  font-size: clamp(3.2rem, 14vw, 8rem);
  line-height: .88;
  text-shadow: 0 0 3.5rem color-mix(in srgb, var(--accent), transparent 74%);
}

.shell-intro h1::after {
  left: 50%;
  width: min(7rem, 28vw);
  transform: translateX(-50%);
}

.statement {
  max-width: none;
  color: #f5f7ff;
  font-size: clamp(1.55rem, 5vw, 2.35rem);
  line-height: 1.02;
}

.description {
  max-width: 43rem;
  margin-inline: auto;
  color: rgba(201,210,232,.68);
  white-space: pre-line;
}

.primary-action-slot {
  display: flex;
  justify-content: center;
}

.primary-action {
  width: auto;
  min-width: min(100%, 17rem);
  min-height: 3.6rem;
  color: color-mix(in srgb, var(--accent), white 72%);
  border-color: color-mix(in srgb, var(--accent), transparent 52%);
  background: rgba(5,8,17,.56);
  box-shadow:
    inset 0 0 2rem color-mix(in srgb, var(--accent), transparent 92%),
    0 0 2rem color-mix(in srgb, var(--accent), transparent 92%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.primary-action:hover,
.primary-action:focus-visible {
  box-shadow:
    inset 0 0 2.8rem color-mix(in srgb, var(--accent), transparent 86%),
    0 0 2.8rem color-mix(in srgb, var(--accent), transparent 86%);
}

.graph-section {
  padding-top: 1rem;
}

.section-heading {
  position: relative;
  padding: 1.2rem 0 1.65rem;
  border-top: 1px solid rgba(180,198,255,.09);
}

.section-heading::before {
  content: "living topology";
  position: absolute;
  top: -0.55rem;
  left: 0;
  padding-right: .65rem;
  color: rgba(180,198,255,.42);
  background: var(--cosmos-ink);
  font: 600 .58rem/1 ui-monospace, "SFMono-Regular", Menlo, monospace;
  letter-spacing: .22em;
  text-transform: uppercase;
}

.section-heading h2 {
  max-width: 15ch;
  margin-top: .35rem;
  font-size: clamp(2.1rem, 8vw, 4.65rem);
  color: #eef2ff;
}

.kicker {
  color: color-mix(in srgb, var(--accent), rgba(180,198,255,.55) 58%);
  letter-spacing: .18em;
  text-transform: uppercase;
}

.graph-status span,
.graph-status button {
  border-color: rgba(180,198,255,.12);
  background: rgba(4,7,14,.52);
}

.graph-layout {
  margin-top: 0;
}

.graph-stage {
  min-height: max(36rem, 72dvh);
}

.renderer-surface {
  height: clamp(39rem, 78dvh, 66rem);
  min-height: 39rem;
  border-top: 1px solid rgba(180,198,255,.075);
  border-bottom: 1px solid rgba(180,198,255,.075);
  background:
    radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--accent), transparent 87%), transparent 34%),
    radial-gradient(circle at 18% 31%, rgba(72,168,255,.07), transparent 24%),
    radial-gradient(circle at 74% 46%, rgba(154,99,255,.065), transparent 27%),
    radial-gradient(circle at 36% 76%, rgba(119,217,87,.04), transparent 23%),
    #02040a;
  box-shadow:
    inset 0 8rem 12rem rgba(0,0,0,.21),
    inset 0 -8rem 12rem rgba(0,0,0,.36);
}

.renderer-surface::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: .42;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.6) 0 .55px, transparent .72px),
    radial-gradient(circle, rgba(122,160,255,.45) 0 .48px, transparent .65px);
  background-size: 107px 107px, 163px 163px;
  background-position: 19px 31px, 71px 87px;
  mask-image: radial-gradient(ellipse at center, #000, transparent 82%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000, transparent 82%);
}

/* The cosmic field paints below the render surface, so these layers only need
   to sit above it — they must keep their own positioning. Forcing them into
   normal flow stacked the SVG semantic layer *underneath* the canvas instead of
   over it, where the surface's `overflow: hidden` clipped it away: the graph
   kept its accessible names and keyboard focus but lost every pointer hit,
   because the layer that owns hit testing was no longer where the graph is. */
.renderer-gpu-canvas,
.renderer-svg-layer,
.render-overlay,
.graph-toast {
  z-index: 2;
}

/* The cosmic field only tempers the strands; the relation colour itself is
   semantic and stays exactly what the legend says it is. */
.wasm-strand {
  stroke-opacity: .62;
  filter: drop-shadow(0 0 6px color-mix(in srgb, currentColor, transparent 55%));
}

.wasm-node__halo {
  fill: color-mix(in srgb, currentColor, transparent 91%);
  filter: drop-shadow(0 0 10px color-mix(in srgb, currentColor, transparent 45%));
}

.wasm-node__core {
  fill: color-mix(in srgb, currentColor, #080b14 82%);
  stroke: color-mix(in srgb, currentColor, white 28%);
  filter:
    drop-shadow(0 0 6px color-mix(in srgb, currentColor, transparent 24%))
    drop-shadow(0 0 18px color-mix(in srgb, currentColor, transparent 62%));
}

.wasm-node[aria-current="true"] .wasm-node__halo,
.wasm-node:focus-visible .wasm-node__halo {
  fill: color-mix(in srgb, currentColor, transparent 78%);
}

.wasm-label {
  fill: rgba(226,232,255,.86);
  text-shadow: 0 0 10px rgba(70,94,160,.35);
}

.node-details {
  position: relative;
  width: min(calc(100% - (2 * var(--content-gutter))), var(--max-width));
  padding: clamp(1rem, 3vw, 1.5rem);
  border: 1px solid rgba(180,198,255,.1);
  border-radius: 1.25rem;
  background: linear-gradient(180deg, rgba(5,8,17,.7), rgba(5,8,17,.34));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.node-details__header,
.node-metadata,
.document-tabs {
  border-color: rgba(180,198,255,.09);
}

.runtime-footer {
  margin-top: 4rem;
  border-top: 1px solid rgba(180,198,255,.08);
}

@media (min-width: 720px) {
  .topbar {
    padding-inline: max(var(--content-gutter), calc((100vw - var(--max-width)) / 2));
  }

  .shell-intro {
    min-height: clamp(31rem, 64dvh, 49rem);
    grid-template-columns: minmax(0, 1fr);
  }

  .section-heading {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (max-width: 719px) {
  .topbar {
    position: relative;
  }

  .shell-intro {
    min-height: 39rem;
    padding-top: 9rem;
  }

  .shell-intro::before {
    top: 1rem;
    width: 15rem;
  }

  .shell-intro::after {
    top: 2.6rem;
    width: 88vw;
    font-size: .58rem;
  }

  .route {
    font-size: .64rem;
  }

  .graph-stage,
  .renderer-surface {
    min-height: 43rem;
    height: 76dvh;
  }

  .node-details {
    width: calc(100% - 1.5rem);
    max-width: calc(100% - 1.5rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  #app::before,
  .shell-intro::before {
    filter: none;
  }
}
