/* ============================================================
   CelunOS — style.css
   Dark violet neon over a live WebGL signal-system.
   ============================================================ */

:root {
  --bg: #050009;
  --bg-2: #0a0214;
  --violet: #7F00FF;
  --violet-bright: #9D4DFF;
  --violet-soft: #B98AFF;
  --lilac: #C9A0FF;
  --ink: #F4EFFF;
  --text: #A89CC8;
  --dim: #6E6390;
  --line: rgba(159, 109, 255, 0.16);
  --line-bright: rgba(159, 109, 255, 0.38);
  --up: #4DFFC4;
  --dn: #FF4D88;
  --font-display: "Space Grotesk", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* vertical swipes scroll; horizontal swipes are left to the scene
   (drag-to-rotate), pinch zoom stays available */
main, .panel, .inner, .cards-section, .site-footer {
  touch-action: pan-y pinch-zoom;
}

.mono { font-family: var(--font-mono); }

::selection { background: rgba(127, 0, 255, 0.55); color: #fff; }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: #2a1545;
  border-radius: 5px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: #3d2066; }

:focus-visible {
  outline: 2px solid var(--violet-bright);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- backdrop layers ---------- */

.bg-fallback {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 80% 55% at 70% 12%, rgba(127, 0, 255, 0.16), transparent 60%),
    radial-gradient(ellipse 70% 60% at 15% 85%, rgba(85, 0, 180, 0.14), transparent 65%),
    radial-gradient(ellipse 45% 35% at 50% 50%, rgba(127, 0, 255, 0.08), transparent 70%),
    var(--bg);
}

#scene {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  /* size to the large viewport so the canvas keeps covering the screen
     when the mobile URL bar collapses mid-scroll (no gap at the bottom) */
  height: 100vh;
  height: 100lvh;
  display: block;
}

.no-webgl #scene { display: none; }
.no-webgl #labels, .no-webgl #tooltip, .no-webgl #callout { display: none !important; }

#grain {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%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");
}

/* ---------- node labels (projected from 3D) ---------- */

#labels {
  position: fixed;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.nlabel {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  white-space: nowrap;
  opacity: 0;
  will-change: transform, opacity;
}

.nlabel > i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--violet-soft);
  box-shadow: 0 0 8px rgba(157, 77, 255, 0.9);
}

.nlabel b { color: var(--lilac); font-weight: 500; }
.nlabel span { color: var(--dim); }
.nlabel span .up { color: var(--up); font-style: normal; }
.nlabel span .dn { color: var(--dn); font-style: normal; }

.nlabel.hot b { color: #fff; text-shadow: 0 0 14px rgba(157, 77, 255, 1); }
.nlabel.hot i { background: #fff; box-shadow: 0 0 14px #fff; }

/* ---------- tooltip ---------- */

#tooltip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  min-width: 190px;
  padding: 12px 14px;
  background: rgba(11, 4, 22, 0.95);
  border: 1px solid var(--line-bright);
  border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.55), 0 0 24px rgba(127, 0, 255, 0.18);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#tooltip.show { opacity: 1; transform: translateY(0); }
#tooltip .tt-name { color: var(--lilac); font-weight: 700; letter-spacing: 0.18em; }
#tooltip .tt-val { color: var(--ink); font-size: 1.15rem; font-weight: 500; margin: 4px 0 2px; }
#tooltip .tt-val .up { color: var(--up); font-style: normal; font-size: 0.7rem; }
#tooltip .tt-val .dn { color: var(--dn); font-style: normal; font-size: 0.7rem; }
#tooltip svg { display: block; margin: 6px 0 4px; }
#tooltip svg polyline {
  fill: none;
  stroke: var(--violet-bright);
  stroke-width: 1.5;
  stroke-linejoin: round;
}
#tooltip .tt-cap { color: var(--dim); font-size: 0.6rem; }

/* ---------- computed-action callout ---------- */

#callout {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 40;
  max-width: min(400px, 82vw);
  padding: 10px 14px;
  background: rgba(9, 2, 18, 0.92);
  border: 1px solid var(--line-bright);
  border-left: 3px solid var(--violet-bright);
  border-radius: 8px;
  box-shadow: 0 0 30px rgba(127, 0, 255, 0.25), 0 10px 36px rgba(0, 0, 0, 0.5);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  will-change: transform;
}

#callout.show { opacity: 1; }
#callout .caret {
  display: inline-block;
  width: 7px;
  height: 13px;
  margin-left: 3px;
  vertical-align: -2px;
  background: var(--violet-bright);
  animation: blink 0.85s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

/* ---------- nav ---------- */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px clamp(20px, 4vw, 48px);
  padding-top: max(16px, env(safe-area-inset-top));
  transition: background 0.4s ease, border-color 0.4s ease;
  border-bottom: 1px solid transparent;
  transform: translateZ(0); /* isolate the nav's blur layer */
}

.nav.scrolled {
  background: rgba(6, 0, 13, 0.72);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom-color: var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand-glyph {
  width: 26px;
  height: 26px;
  color: var(--violet-bright);
  filter: drop-shadow(0 0 6px rgba(127, 0, 255, 0.7));
}

.brand-word {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.26em;
  color: var(--ink);
}

.brand-word b {
  font-weight: 700;
  background: linear-gradient(120deg, var(--violet-bright), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.nav-right { display: flex; align-items: center; gap: 18px; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-block;
  padding: 14px 28px;
  border-radius: 10px;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.25s var(--ease), box-shadow 0.25s ease, filter 0.25s ease, background 0.25s ease;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #8F2BFF, #6A00D6);
  box-shadow: 0 0 24px rgba(127, 0, 255, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-primary:hover {
  transform: translateY(-2px);
  filter: brightness(1.12);
  box-shadow: 0 0 38px rgba(127, 0, 255, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  color: var(--lilac);
  border-color: var(--line-bright);
  background: rgba(20, 6, 38, 0.55);
}

.btn-ghost:hover {
  background: rgba(127, 0, 255, 0.14);
  border-color: rgba(159, 109, 255, 0.6);
  transform: translateY(-2px);
}

.btn-small { padding: 9px 18px; font-size: 0.78rem; border-radius: 8px; }
.btn-block { width: 100%; text-align: center; }

/* ---------- generic panel layout ---------- */

main { position: relative; z-index: 4; }

.panel {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 0 clamp(20px, 6vw, 96px);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  color: var(--violet-bright);
  margin-bottom: 22px;
}

.eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--violet-bright);
  box-shadow: 0 0 8px var(--violet-bright);
  flex: none;
}

.eyebrow.center { justify-content: center; }

h1 {
  font-size: clamp(2.7rem, 6.5vw, 5.2rem);
  line-height: 1.04;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-shadow: 0 2px 30px rgba(5, 0, 9, 0.8);
}

h1 em, h2 em {
  font-style: normal;
  background: linear-gradient(100deg, #ffffff, var(--lilac) 38%, var(--violet) 85%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

h2 {
  font-size: clamp(1.9rem, 4.2vw, 3.2rem);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 20px;
  text-shadow: 0 2px 26px rgba(5, 0, 9, 0.8);
}

h2.center { text-align: center; }

.lede {
  font-size: clamp(1.02rem, 1.6vw, 1.22rem);
  max-width: 620px;
  margin: 26px auto 0;
  color: #D9D0F2;
  text-shadow: 0 1px 18px rgba(5, 0, 9, 0.95), 0 0 30px rgba(127, 0, 255, 0.18);
}

.body {
  font-size: 1.02rem;
  color: var(--text);
  text-shadow: 0 1px 16px rgba(5, 0, 9, 0.9);
}

/* ---------- hero ---------- */

.hero { justify-content: center; text-align: center; }

.hero .inner { max-width: 980px; padding-bottom: 8vh; }

.hero .eyebrow { justify-content: center; }
.hero .eyebrow::before { display: none; }

.cta-row {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 38px;
}

/* ticker */

.ticker {
  position: absolute;
  bottom: 26px;
  bottom: calc(26px + env(safe-area-inset-bottom));
  left: 0;
  right: 0;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}

.ticker-track {
  display: inline-flex;
  gap: 38px;
  padding-right: 38px;
  white-space: nowrap;
  animation: tick 52s linear infinite;
  will-change: transform;
}

@keyframes tick { to { transform: translateX(-50%); } }

.ti {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  color: var(--dim);
}

.ti b { color: var(--violet-soft); font-weight: 500; }
.ti .up { color: var(--up); font-style: normal; }
.ti .dn { color: var(--dn); font-style: normal; }

/* ---------- narrative acts ---------- */

.act { min-height: 135vh; }

.act .inner { max-width: 540px; position: relative; }

.act .inner::before {
  content: "";
  position: absolute;
  inset: -48px -56px;
  background: radial-gradient(ellipse 90% 80% at 50% 50%, rgba(5, 0, 9, 0.62), transparent 75%);
  z-index: -1;
  border-radius: 40px;
}

.act[data-side="right"] { justify-content: flex-end; }

#solve { min-height: 165vh; }

.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 26px;
}

.chips li {
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: var(--violet-soft);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(127, 0, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 7px;
}

.chips li::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--violet-bright);
  box-shadow: 0 0 6px var(--violet-bright);
  animation: pulse-dot 2.4s ease-in-out infinite;
}

.chips li:nth-child(2n)::before { animation-delay: 0.5s; }
.chips li:nth-child(3n)::before { animation-delay: 1.1s; }
.chips li:nth-child(5n)::before { animation-delay: 1.7s; }

.datum {
  margin-top: 24px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--violet-soft);
}

.datum sub, .datum sup, .equation sub, .equation sup {
  font-size: 0.62em;
}

.equation {
  margin-top: 34px;
  padding: 22px 26px;
  font-size: clamp(0.95rem, 2vw, 1.3rem);
  font-weight: 500;
  color: var(--ink);
  border: 1px solid var(--line-bright);
  border-radius: 14px;
  background: rgba(10, 3, 20, 0.82);
  text-shadow: 0 0 18px rgba(157, 77, 255, 0.65);
  box-shadow: 0 0 36px rgba(127, 0, 255, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  white-space: nowrap;
  overflow-x: auto;
}

.eq-cap {
  margin-top: 12px;
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  color: var(--dim);
  text-transform: uppercase;
}

/* ---------- cards ---------- */

.cards-section {
  position: relative;
  padding: 18vh clamp(20px, 6vw, 96px);
}

.cards-head { margin-bottom: 54px; }

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  max-width: 1080px;
  margin: 0 auto;
}

/* no backdrop-filter on elements that scroll over the live canvas —
   it causes compositor tile flashes in Chrome/Safari */
.glass {
  background: rgba(13, 6, 26, 0.82);
  border: 1px solid rgba(159, 109, 255, 0.22);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  position: relative;
  overflow: hidden;
}

.glass::before {
  content: "";
  position: absolute;
  top: 0;
  left: 8%;
  right: 8%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201, 160, 255, 0.5), transparent);
}

.card {
  padding: 30px 28px 34px;
  transition: transform 0.35s var(--ease), border-color 0.35s ease, box-shadow 0.35s ease;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(159, 109, 255, 0.5);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.5), 0 0 40px rgba(127, 0, 255, 0.16);
}

.card-num {
  font-size: 0.62rem;
  letter-spacing: 0.22em;
  color: var(--violet-bright);
  margin-bottom: 18px;
}

.card h3 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 10px;
}

.card p { font-size: 0.92rem; color: var(--text); }

.secure-strip {
  max-width: 1080px;
  margin: 22px auto 0;
  padding: 14px 22px;
  text-align: center;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(10, 3, 20, 0.75);
}

/* ---------- about ---------- */

.about .inner { max-width: 620px; }

.about-body p + p { margin-top: 16px; }

.accent-italic {
  font-style: italic;
  color: var(--lilac);
}

/* ---------- signup ---------- */

.signup { justify-content: center; min-height: 115vh; }

.signup-card {
  width: min(540px, 100%);
  padding: clamp(30px, 5vw, 52px);
  text-align: center;
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6), 0 0 80px rgba(127, 0, 255, 0.14);
}

.signup-card .eyebrow { justify-content: center; }
.signup-card .body { margin-bottom: 30px; }

#signup-form { text-align: left; }

.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--violet-soft);
  margin-bottom: 8px;
}

.form-group label .opt { color: var(--dim); letter-spacing: 0.14em; }

.form-group input {
  width: 100%;
  padding: 14px 16px;
  font-family: var(--font-display);
  font-size: 0.98rem;
  color: var(--ink);
  background: rgba(10, 4, 20, 0.6);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.form-group input::placeholder { color: #50456e; }

.form-group input:focus {
  outline: none;
  border-color: var(--violet-bright);
  box-shadow: 0 0 0 3px rgba(127, 0, 255, 0.22), 0 0 20px rgba(127, 0, 255, 0.18);
}

.form-group input.input-error { border-color: var(--dn); }

.field-error {
  display: none;
  font-size: 0.74rem;
  color: var(--dn);
  margin-top: 7px;
}

.field-error.visible { display: block; }

#err-form { text-align: center; margin-top: 12px; }

#f-submit { margin-top: 8px; font-size: 1rem; }

#f-submit:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.hp { position: absolute; left: -5000px; opacity: 0; pointer-events: none; }

.fine {
  margin-top: 22px;
  font-size: 0.58rem;
  letter-spacing: 0.18em;
  color: var(--dim);
}

.form-success { padding: 26px 0 8px; text-align: center; }

.form-success .sig {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--violet-soft);
  text-shadow: 0 0 24px rgba(157, 77, 255, 0.9);
}

.form-success .sig::before {
  content: "●";
  margin-right: 10px;
  color: var(--violet-bright);
  animation: pulse-dot 1.6s ease-in-out infinite;
}

.form-success p {
  margin-top: 14px;
  color: var(--text);
  font-size: 0.95rem;
}

/* ---------- footer ---------- */

.site-footer {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 26px clamp(20px, 6vw, 96px);
  padding-bottom: calc(26px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(5, 0, 9, 0.9);
  font-size: 0.78rem;
  color: var(--dim);
}

.site-footer .mono { font-size: 0.6rem; letter-spacing: 0.2em; }

/* ---------- reveal animations ---------- */

.reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
  transition-delay: calc(var(--i, 0) * 110ms);
}

.reveal.on { opacity: 1; transform: none; }

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; max-width: 480px; }

  .act { min-height: 120vh; }
  #solve { min-height: 130vh; }

  .act .inner {
    max-width: none;
    width: 100%;
    background: rgba(8, 2, 16, 0.82);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 30px 26px;
  }

  .act .inner::before { display: none; }

  .act[data-side="right"] { justify-content: center; }
  .act[data-side="left"] { justify-content: center; }

  .nlabel { font-size: 0.56rem; }
  .nlabel span { display: none; }
}

@media (max-width: 560px) {
  .cta-row .btn { width: 100%; text-align: center; }
  .ticker { bottom: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); }
  h1 { font-size: clamp(2.2rem, 11vw, 3.2rem); }
  .site-footer { justify-content: center; text-align: center; }
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  .ticker-track { animation: none; }
  .chips li::before, .form-success .sig::before { animation: none; }
  #callout .caret { animation: none; }

  .reveal {
    transition: none;
    opacity: 1;
    transform: none;
  }

  .btn, .card { transition: none; }
}
