/* ============================================================
   TDXRay — Main Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Mono:ital,wght@0,300;0,400;0,500;1,300&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,300&display=swap');

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:         #080d14;
  --bg-card:    #0d1520;
  --bg-card2:   #111c2a;
  --bg-terminal:#050b12;
  --border:     rgba(0,210,210,0.12);
  --border-mid: rgba(0,210,210,0.22);
  --teal:       #00d2d2;
  --teal-dim:   #009fa0;
  --teal-glow:  rgba(0,210,210,0.18);
  --teal-faint: rgba(0,210,210,0.06);
  --teal-faint-2: rgba(0, 210, 210, 0.394);
  --white:      #eef2f7;
  --muted:      #7a92ab;
  --muted2:     #4f6478;
  --red:        #ff4f6a;
  --yellow:     #f5c542;
  --nav-bg:     rgba(8,13,20,0.85);
  --font-head:  'DM Sans', sans-serif;
  --font-body:  'DM Sans', sans-serif;
  --font-mono:  'DM Mono', monospace;
  --radius:     12px;
  --radius-lg:  20px;
}

[data-theme="light"] {
  --bg:         #f0f4f9;
  --bg-card:    #ffffff;
  --bg-card2:   #e4eaf2;
  --bg-terminal:#1a2233;
  --border:     rgba(0,160,160,0.15);
  --border-mid: rgba(0,160,160,0.32);
  --teal:       #008a8a;
  --teal-dim:   #006e6e;
  --teal-glow:  rgba(0,160,160,0.18);
  --teal-faint: rgba(0,160,160,0.07);
  --teal-faint-2: rgba(0,160,160,0.15);
  --white:      #111827;
  --muted:      #4a6280;
  --muted2:     #7a98b0;
  --nav-bg:     rgba(240,244,249,0.92);
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
}

a { color: var(--teal); text-decoration: none; transition: opacity .2s; }
a:hover { opacity: .75; }

img { max-width: 100%; display: block; }

/* ── Noise texture overlay ──────────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: .5;
}

/* ── Nav ────────────────────────────────────────────────────── */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2.5rem;
  height: 64px;
  background: var(--nav-bg);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  display: flex; align-items: center; gap: .6rem;
}
.nav-logo img {
  width: 32px; height: 32px; object-fit: contain;
}
.nav-logo span {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: .04em;
  color: var(--white);
}
.nav-logo span em {
  font-style: normal;
  color: var(--teal);
}

.nav-links {
  display: flex; align-items: center; gap: 2rem;
  list-style: none;
}
.nav-links a {
  font-family: var(--font-mono);
  font-size: .78rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color .2s;
}
.nav-links a:hover { color: var(--teal); opacity: 1; }

.nav-cta {
  background: var(--teal-faint);
  border: 1px solid var(--border-mid);
  color: var(--teal) !important;
  padding: .35rem 1rem;
  border-radius: 6px;
  transition: background .2s !important;
}
.nav-cta:hover { background: var(--teal-glow) !important; }

/* ── Hero ───────────────────────────────────────────────────── */
#hero {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  padding: 6rem 2rem 4rem;
}

/* radial glow behind hero */
/* #hero::before {
  content: '';
  position: absolute;
  width: 800px; height: 800px;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  background: radial-gradient(circle, rgba(0,210,210,0.1) 0%, transparent 65%);
  pointer-events: none;
} */

/* grid lines */
#hero::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  /* mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, black 30%, transparent 100%); */
  pointer-events: none;
}

#heatmap-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
  opacity: 0.55;
}

.hero-inner {
  text-align: center;
  max-width: 860px;
  position: relative; z-index: 2;
}

.hero-badge {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--teal-faint-2);
  border: 2px solid var(--border-mid);
  color: var(--teal);
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  padding: .35rem .85rem;
  border-radius: 99px;
  margin-bottom: 3rem;
  animation: fadeUp .7s ease both;
}
.hero-badge .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--teal);
  animation: pulse 2s ease infinite;
}

.hero-logo {
  width: 400px; height: 400px;
  margin: 0 auto 1.8rem;
  object-fit: contain;
  filter: drop-shadow(0 0 60px rgba(0, 210, 210, 0.776));
  animation: fadeUp .7s .1s ease both;
}

.hero-title {
  font-family: var(--font-head);
  font-size: clamp(3.2rem, 7vw, 5.5rem);
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1;
  margin-bottom: 1rem;
  animation: fadeUp .7s .2s ease both;
}
.hero-title .accent { color: var(--teal); }

.hero-sub {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 620px;
  margin: 0 auto 2.5rem;
  animation: fadeUp .7s .3s ease both;
}

.hero-authors {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--muted2);
  margin-bottom: 2.5rem;
  animation: fadeUp .7s .35s ease both;
}
.hero-authors span { color: var(--muted); }

.hero-actions {
  display: flex; align-items: center; justify-content: center;
  gap: 1rem; flex-wrap: wrap;
  animation: fadeUp .7s .4s ease both;
}

.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .65rem 1.5rem;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: .82rem;
  letter-spacing: .06em;
  font-weight: 500;
  transition: all .2s;
  cursor: pointer;
  border: none;
}
.btn-primary {
  background: var(--teal);
  color: var(--bg);
}
.btn-primary:hover {
  background: #00f0f0;
  color: var(--bg);
  box-shadow: 0 0 24px rgba(0,210,210,0.4);
  transform: translateY(-1px);
  opacity: 1;
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.13);
  color: var(--white);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 2px 8px rgba(0,0,0,0.25);
}
.btn-ghost:hover {
  background: rgba(0, 210, 210, 0.10);
  border-color: var(--teal);
  color: var(--teal);
  box-shadow: inset 0 1px 0 rgba(0,210,210,0.12), 0 0 18px rgba(0,210,210,0.18);
  opacity: 1;
}
.btn svg { width: 14px; height: 14px; }

/* scroll indicator */
.hero-scroll {
  position: absolute;
  bottom: 2rem; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  animation: fadeUp .7s .8s ease both;
}
.hero-scroll span {
  font-family: var(--font-mono);
  font-size: .65rem;
  letter-spacing: .15em;
  color: var(--muted2);
  text-transform: uppercase;
}
.scroll-line {
  width: 1px; height: 40px;
  background: linear-gradient(to bottom, var(--teal), transparent);
  animation: scrollDrop 1.8s ease infinite;
}

/* ── Section base ───────────────────────────────────────────── */
section { padding: 6rem 2rem; }

.container {
  max-width: 1100px;
  margin: 0 auto;
}

.section-label {
  font-family: var(--font-mono);
  font-size: .7rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: .7rem;
}

.section-title {
  font-family: var(--font-head);
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 1.2rem;
}

.section-intro {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 660px;
  margin-bottom: 3.5rem;
}

/* ── What is TDX strip ──────────────────────────────────────── */
#explainer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 5rem 2rem;
}

.explainer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: center;
}

.explainer-visual {
  position: relative;
}

/* animated chip diagram */
.chip-diagram {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  aspect-ratio: 1;
  position: relative;
}

.chip-box {
  position: absolute; inset: 15%;
  border: 2px solid var(--border-mid);
  border-radius: 16px;
  background: var(--bg-card2);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: .6rem;
}

.chip-label {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--teal);
  letter-spacing: .1em;
}

/* pin rows */
.chip-pins {
  position: absolute;
  display: flex; gap: 8px;
}
.chip-pins.top    { top: 8%; left: 22%; right: 22%; justify-content: space-between; }
.chip-pins.bottom { bottom: 8%; left: 22%; right: 22%; justify-content: space-between; }
.chip-pins.left   { flex-direction: column; left: 8%; top: 22%; bottom: 22%; justify-content: space-between; }
.chip-pins.right  { flex-direction: column; right: 8%; top: 22%; bottom: 22%; justify-content: space-between; }

.pin {
  width: 12px; height: 30px;
  background: var(--muted2);
  border-radius: 2px;
}
.chip-pins.left .pin,
.chip-pins.right .pin {
  width: 30px; height: 12px;
}

/* scan line inside chip */
.scan-line {
  position: absolute;
  left: 16%; right: 16%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--teal), transparent);
  animation: scanDown 3s ease-in-out infinite;
  box-shadow: 0 0 8px var(--teal);
  top: 20%;
}

/* cache line boxes inside chip */
.cache-lines {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 0 1rem;
}
.cl {
  height: 20px;
  border-radius: 3px;
  background: var(--teal-faint);
  border: 1px solid var(--border);
  transition: background .3s;
}
.cl.hit {
  background: rgba(0,210,210,0.3);
  border-color: var(--teal);
  box-shadow: 0 0 6px rgba(0,210,210,0.4);
}

/* ── How it Works ───────────────────────────────────────────── */
#how {
  position: relative;
}

.primitives-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.primitive-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  position: relative;
  overflow: hidden;
  transition: border-color .3s, transform .3s;
}
.primitive-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--teal), transparent);
  opacity: 0;
  transition: opacity .3s;
}
.primitive-card:hover {
  border-color: var(--border-mid);
  transform: translateY(-3px);
}
.primitive-card:hover::before { opacity: 1; }

.primitive-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--teal-faint);
  border: 1px solid var(--border-mid);
  display: grid; place-items: center;
  margin-bottom: 1.2rem;
}
.primitive-icon svg {
  width: 20px; height: 20px;
  stroke: var(--teal);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primitive-tag {
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .12em;
  color: var(--teal);
  text-transform: uppercase;
  margin-bottom: .4rem;
}

.primitive-card h3 {
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: .6rem;
}
.primitive-card p {
  font-size: .9rem;
  color: var(--muted);
  line-height: 1.65;
}

.granularity {
  display: inline-flex; align-items: center; gap: .4rem;
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: .68rem;
  color: var(--muted2);
  background: rgba(255,255,255,0.04);
  padding: .25rem .65rem;
  border-radius: 99px;
  border: 1px solid rgba(255,255,255,0.07);
}
.granularity .g-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--teal);
}

/* ── TDXRay Framework strip ─────────────────────────────────── */
#framework {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6rem 2rem;
}

.framework-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5rem;
  align-items: center;
}

.flow-diagram {
  display: flex; flex-direction: column; gap: .5rem;
}

.flow-row {
  display: flex; align-items: center; gap: .8rem;
}

.flow-box {
  flex: 1;
  padding: .8rem 1rem;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: .8rem;
  border: 1px solid var(--border);
  background: var(--bg-card2);
  color: var(--white);
  text-align: center;
  transition: all .3s;
}
.flow-box.active {
  border-color: var(--teal);
  background: var(--teal-faint);
  color: var(--teal);
  box-shadow: 0 0 20px rgba(0,210,210,0.15);
}
.flow-box.host {
  border-color: rgba(245,197,66,0.3);
  background: rgba(245,197,66,0.06);
  color: var(--yellow);
}
.flow-box.td {
  border-color: rgba(0,210,210,0.3);
  background: var(--teal-faint);
  color: var(--teal);
}

.flow-arrow {
  color: var(--muted2);
  font-size: 1.2rem;
}

.flow-label {
  font-family: var(--font-mono);
  font-size: .65rem;
  color: var(--muted2);
  text-align: center;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.accuracy-bar-group {
  display: flex; flex-direction: column; gap: 1rem;
  margin-top: 2rem;
}

.accuracy-item label {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--muted);
  margin-bottom: .4rem;
}
.accuracy-item label span { color: var(--teal); font-weight: 500; }

.bar-track {
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 99px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--teal-dim), var(--teal));
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 1.2s cubic-bezier(.22,1,.36,1);
}
.bar-fill.animate { transform: scaleX(1); }

/* ── Attack / Demo ──────────────────────────────────────────── */
#attack {
  padding: 6rem 2rem;
}

.attack-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: start;
  margin-bottom: 4rem;
}

.terminal {
  background: var(--bg-terminal);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: .8rem;
}
.terminal-bar {
  display: flex; align-items: center; gap: .5rem;
  padding: .75rem 1rem;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid var(--border);
}
.terminal-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
}
.terminal-dot:nth-child(1) { background: #ff5f57; }
.terminal-dot:nth-child(2) { background: #febc2e; }
.terminal-dot:nth-child(3) { background: #28c840; }
.terminal-title {
  margin-left: auto; margin-right: auto;
  font-size: .7rem;
  color: var(--muted2);
  letter-spacing: .08em;
}
.terminal-body {
  padding: 1.5rem;
  line-height: 1.9;
}
.terminal-body .prompt { color: var(--teal); }
.terminal-body .comment { color: var(--muted2); }
.terminal-body .value { color: var(--yellow); }
.terminal-body .success { color: #28c840; }
.terminal-body .leaked { color: var(--red); }
.terminal-body .normal { color: #b0cce0; }

/* ── Tokenization Pipeline Viz ──────────────────────────────── */
.tok-viz {
  background: var(--bg-terminal);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.tok-viz-bar {
  display: flex; align-items: center; gap: .4rem;
  padding: .65rem 1rem;
  background: rgba(255,255,255,0.025);
  border-bottom: 1px solid var(--border);
}
.tok-viz-body {
  padding: 1.4rem 1.5rem 1.8rem;
  display: flex; flex-direction: column; gap: 1.1rem;
}

/* stages */
.tok-stage { display: flex; flex-direction: column; gap: .5rem; }
.tok-stage-lbl {
  font-family: var(--font-mono); font-size: .63rem;
  letter-spacing: .13em; text-transform: uppercase;
  color: var(--muted2);
}
.tok-stage-sub { color: var(--muted2); font-weight: 400; letter-spacing: .05em; text-transform: none; }

/* interactive input */
.tok-input-wrap {
  display: flex; align-items: center; gap: .5rem;
}
.tok-input-field {
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .9rem;
  font-family: var(--font-mono); font-size: .9rem;
  color: var(--white); letter-spacing: .03em;
  outline: none; transition: border-color .2s, box-shadow .2s;
}
.tok-input-field::placeholder { color: var(--muted2); }
.tok-input-field:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0,210,210,0.12);
}
.tok-input-field:read-only { opacity: .75; cursor: default; }
.tok-run-btn {
  flex-shrink: 0;
  width: 2.3rem; height: 2.3rem;
  border-radius: 8px;
  background: var(--teal-faint);
  border: 1px solid var(--teal);
  color: var(--teal);
  cursor: pointer;
  display: grid; place-items: center;
  transition: background .2s, box-shadow .2s;
}
.tok-run-btn:hover {
  background: rgba(0,210,210,0.2);
  box-shadow: 0 0 14px rgba(0,210,210,0.3);
}
.tok-word-count {
  font-family: var(--font-mono); font-size: .63rem;
  color: var(--muted2); letter-spacing: .08em;
  margin-top: .25rem; text-align: right;
}
.tok-word-count.warn { color: var(--red); }
[data-theme="light"] .tok-input-field {
  background: rgba(0,0,0,0.04); color: var(--text);
}

/* arrows */
.tok-pipe-arrow {
  display: flex; align-items: center; gap: .55rem;
  opacity: 0; transform: translateY(-3px);
  transition: opacity .3s, transform .3s;
}
.tok-pipe-arrow.show { opacity: 1; transform: translateY(0); }
.tok-pipe-line { flex: 1; height: 1px; background: var(--border-mid); }
.tok-pipe-label {
  font-family: var(--font-mono); font-size: .63rem;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--teal); white-space: nowrap;
}
.tok-pipe-arrow--warn .tok-pipe-line { background: rgba(255,79,106,0.25); }
.tok-pipe-arrow--warn .tok-pipe-label { color: var(--red); }

/* pairs grid */
.tok-pairs { display: flex; flex-wrap: wrap; gap: .55rem; align-items: flex-start; }
.tok-pair {
  display: flex; flex-direction: column; align-items: center; gap: .28rem;
  opacity: 0; transform: translateY(7px);
  transition: opacity .22s, transform .22s;
}
.tok-pair.show { opacity: 1; transform: translateY(0); }

.tok-chip {
  padding: .3rem .65rem; border-radius: 6px;
  background: color-mix(in srgb, var(--tc) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--tc) 38%, transparent);
  color: var(--tc);
  font-family: var(--font-mono); font-size: .8rem; font-weight: 600;
  letter-spacing: .03em; white-space: nowrap;
}
.tok-connector {
  width: 1px; height: 12px;
  background: color-mix(in srgb, var(--tc) 28%, transparent);
}
.tok-id {
  font-family: var(--font-mono); font-size: .85rem; font-weight: 700;
  color: color-mix(in srgb, var(--tc) 95%, var(--white));
  letter-spacing: .04em;
  opacity: 0;
}
/* ID auto-reveals with a flash 280ms after the parent pair pops in */
.tok-pair.show .tok-id {
  animation: tokIdReveal .6s ease 0.28s both;
}
@keyframes tokIdReveal {
  0%   { opacity: 0; text-shadow: none; }
  40%  { opacity: 1; text-shadow: 0 0 16px var(--tc); }
  100% { opacity: 1; text-shadow: 0 0 5px color-mix(in srgb, var(--tc) 25%, transparent); }
}

/* cache line address chip — appears after the vocab ID */
.tok-connector--sm {
  width: 1px; height: 8px;
  background: rgba(255, 100, 120, 0.3);
}
.tok-cache {
  font-family: var(--font-mono); font-size: .7rem; font-weight: 600;
  background: rgba(255, 79, 106, 0.1);
  border: 1px solid rgba(255, 79, 106, 0.28);
  border-radius: 4px;
  padding: .12rem .42rem;
  color: #ff8fa3;
  letter-spacing: .04em;
  white-space: nowrap;
  opacity: 0;
}
.tca-dot { opacity: 0.45; }
/* reveals 580ms after parent pair pops in (after the vocab ID at 280ms) */
.tok-pair.show .tok-cache {
  animation: tokCacheReveal .55s ease 0.58s both;
}
@keyframes tokCacheReveal {
  0%   { opacity: 0; transform: translateY(4px); }
  50%  { opacity: 1; transform: translateY(0); box-shadow: 0 0 10px rgba(255,79,106,0.45); }
  100% { opacity: 1; transform: translateY(0); box-shadow: 0 0 3px rgba(255,79,106,0.15); }
}

/* ── Vocab hash-map grid visualization ──────────────────────── */

/* chips stage — fades out after tokens fire into the grid */
.tvg-chips-stage { transition: opacity 0.45s; }
.tvg-chips { display: flex; flex-wrap: wrap; gap: .4rem; }

/* chip "fire" pulse when it triggers a cell lookup */
@keyframes chipFire {
  0%   { transform: scale(1);    filter: brightness(1);   }
  45%  { transform: scale(1.22); filter: brightness(1.9); }
  100% { transform: scale(1);    filter: brightness(1);   }
}
.tok-chip.firing { animation: chipFire .32s ease both; }

/* grid wrapper */
.tvg-wrap {
  position: relative;
  width: 100%;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px;
}

/* DOM cell grid — many small tiles */
.tvg-grid-dom {
  display: grid;
  grid-template-columns: repeat(20, 1fr);
  gap: 2px;
}
.tvg-cell {
  height: 20px;
  border-radius: 2px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.055);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  font-family: var(--font-mono); font-weight: 700;
  font-size: 0;           /* text hidden until red */
  color: transparent;
  letter-spacing: -0.02em;
  transition: background .3s, border-color .3s, box-shadow .3s,
              font-size .25s, color .25s;
}
.tvg-cell.cyan {
  background: rgba(0, 210, 228, 0.42);
  border-color: rgba(0, 228, 238, 0.72);
  box-shadow: 0 0 8px rgba(0, 222, 238, 0.65),
              inset 0 0 5px rgba(0, 222, 238, 0.25);
}
.tvg-cell.red {
  background: rgba(255, 75, 105, 0.42);
  border-color: rgba(255, 90, 118, 0.72);
  box-shadow: 0 0 8px rgba(255, 79, 106, 0.6),
              inset 0 0 5px rgba(255, 79, 106, 0.25);
  font-size: 0.42rem;
  color: rgba(255, 215, 222, 0.93);
}

/* sweep line */
.tvg-sweep {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: 3px;
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(255, 85, 110, 0.35) 20%,
    rgba(255, 79, 106, 0.95) 50%,
    rgba(255, 85, 110, 0.35) 80%,
    transparent 100%);
  box-shadow: 0 0 14px rgba(255, 79, 106, 0.7), 0 0 5px rgba(255, 79, 106, 1);
  opacity: 0;
  pointer-events: none;
}

/* legend row */
.tvg-legend {
  display: flex; align-items: center; gap: .55rem;
  margin-top: .45rem;
  font-family: var(--font-mono); font-size: .62rem;
  letter-spacing: .07em; opacity: .65;
}
.tvgl-cyan { color: #00d4dc; }
.tvgl-red  { color: #ff8fa3; }
.tvgl-sep  { color: var(--muted2); }

/* light theme */
[data-theme="light"] .tvg-wrap { background: rgba(0,0,0,0.05); }
[data-theme="light"] .tvg-cell { background: rgba(0,0,0,0.04); border-color: rgba(0,0,0,0.09); }
[data-theme="light"] .tvg-cell.red { color: #8a0020; }

/* legacy — kept for safety */
/* legend under the pairs */
.tok-cache-legend {
  display: flex; align-items: center; gap: .5rem;
  margin-top: .55rem;
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .07em;
  opacity: 0.65;
}
.tcl-teal { color: var(--teal); }
.tcl-red  { color: #ff8fa3; }
.tcl-sep  { color: var(--muted2); }
[data-theme="light"] .tok-cache {
  background: rgba(200, 20, 50, 0.07);
  border-color: rgba(200, 20, 50, 0.22);
  color: #c0003a;
}
[data-theme="light"] .tcl-red { color: #c0003a; }

/* recovered box */
.tok-stage--recovered {
  opacity: 0; transition: opacity .4s;
}
.tok-stage--recovered.show { opacity: 1; }
.tok-recovered-box {
  display: flex; align-items: center; gap: .55rem;
  background: rgba(255,79,106,0.07);
  border: 1px solid rgba(255,79,106,0.22);
  border-radius: 8px; padding: .55rem .9rem;
  font-family: var(--font-mono); font-size: .9rem;
}
.tok-rec-arrow { color: var(--red); font-weight: 700; }
.tok-recovered-box span:last-child { color: var(--white); letter-spacing: .03em; }

/* light mode */
[data-theme="light"] .tok-viz { background: var(--bg-card2); }
[data-theme="light"] .tok-input-box { background: rgba(0,0,0,0.03); }
[data-theme="light"] .tok-recovered-box { background: rgba(255,79,106,0.06); }

/* ── Tokenization replay button ─────────────────────────────── */
.tok-replay-btn {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: .45rem;
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-mid);
  border-radius: 8px;
  padding: .4rem .9rem;
  font-family: var(--font-mono); font-size: .72rem;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--teal);
  cursor: pointer;
  transition: background .2s, box-shadow .2s;
  animation: tokReplayFadeIn .4s ease both;
}
.tok-replay-btn:hover {
  background: var(--teal-faint);
  box-shadow: 0 0 14px rgba(0,210,210,0.2);
}
.tok-replay-btn svg {
  width: 13px; height: 13px;
  stroke: var(--teal);
}
@keyframes tokReplayFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* demo video placeholder */
.demo-video-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 16/9;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1rem;
  position: relative;
}
.demo-video-wrap video,
.demo-video-wrap iframe {
  width: 100%; height: 100%;
  border: none;
  position: absolute; inset: 0;
}

/* ── Demo GIF canvas player ──────────────────────────────────── */
.demo-layer {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}

.demo-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: .6rem;
  background: rgba(5,11,18,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
  transition: background .25s;
  z-index: 4;
}
.demo-overlay:hover { background: rgba(5,11,18,0.4); }

.demo-overlay .play-btn {
  margin: 0;           /* override old margin:auto  */
  pointer-events: none;/* click is on overlay */
}

.demo-overlay p {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--white);
  letter-spacing: .1em;
  text-transform: uppercase;
  opacity: .8;
}

.demo-replay-btn {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .6rem;
  background: rgba(5,11,18,0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: none;
  border-radius: var(--radius-lg);
  width: 100%; height: 100%;
  font-family: var(--font-mono); font-size: .75rem;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--white);
  cursor: pointer;
  transition: background .25s;
}
.demo-replay-btn:hover { background: rgba(5,11,18,0.4); }
.demo-replay-btn .play-btn {
  margin: 0;
  pointer-events: none;
}

.demo-placeholder {
  text-align: center;
  z-index: 2;
}
.play-btn {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--teal);
  display: grid; place-items: center;
  margin: 0 auto 1rem;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  box-shadow: 0 0 30px rgba(0,210,210,0.4);
}
.play-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 50px rgba(0,210,210,0.6);
}
.play-btn svg { width: 24px; height: 24px; fill: var(--bg); margin-left: 3px; }
.demo-placeholder p {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--muted);
  letter-spacing: .08em;
}

/* stat cards */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 4rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  transition: border-color .3s;
}
.stat-card:hover { border-color: var(--border-mid); }
.stat-card .number {
  font-family: var(--font-head);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--teal);
  line-height: 1;
  margin-bottom: .4rem;
}
.stat-card .label {
  font-size: .8rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* ── Mitigations ────────────────────────────────────────────── */
#mitigations {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6rem 2rem;
}

.mitigation-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.mit-card {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  transition: border-color .3s, transform .3s;
}
.mit-card:hover {
  border-color: var(--border-mid);
  transform: translateY(-3px);
}

.mit-icon {
  font-size: 1.8rem;
  margin-bottom: 1rem;
}

.mit-card h3 {
  font-family: var(--font-head);
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: .6rem;
}
.mit-card p {
  font-size: .88rem;
  color: var(--muted);
  line-height: 1.65;
}

/* ── FAQ ────────────────────────────────────────────────────── */
#faq { padding: 6rem 2rem; }

.faq-list {
  max-width: 760px;
  margin: 0 auto;
  display: flex; flex-direction: column; gap: .75rem;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  transition: border-color .2s;
}
.faq-item.open { border-color: var(--border-mid); }

.faq-q {
  width: 100%;
  background: none;
  border: none;
  color: var(--white);
  font-family: var(--font-body);
  font-size: .95rem;
  font-weight: 500;
  text-align: left;
  padding: 1.2rem 1.5rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.faq-chevron {
  flex-shrink: 0;
  width: 18px; height: 18px;
  stroke: var(--muted2);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  transition: transform .3s, stroke .3s;
}
.faq-item.open .faq-chevron {
  transform: rotate(180deg);
  stroke: var(--teal);
}

.faq-a {
  font-size: .9rem;
  color: var(--muted);
  padding: 0 1.5rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s ease, padding .35s ease;
  line-height: 1.7;
}
.faq-item.open .faq-a {
  max-height: 400px;
  padding: 0 1.5rem 1.2rem;
}

/* ── Team ───────────────────────────────────────────────────── */
#team {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 6rem 2rem;
}

.team-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.team-row {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.team-row .team-card {
  flex: 0 0 180px;
}

.team-card {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1rem;
  text-align: center;
  transition: border-color .3s, transform .3s;
}
.team-card:hover {
  border-color: var(--border-mid);
  transform: translateY(-3px);
}

.team-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--teal-faint);
  border: 2px solid var(--border-mid);
  margin: 0 auto .8rem;
  display: grid; place-items: center;
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  color: var(--teal);
  /* photo support */
  object-fit: cover;
  overflow: hidden;
}

.team-card h4 {
  font-family: var(--font-head);
  font-size: .88rem;
  font-weight: 600;
  margin-bottom: .25rem;
}
.team-card a {
  color: inherit;
}
.team-card p {
  font-family: var(--font-mono);
  font-size: .68rem;
  color: var(--muted2);
}

.equal-note {
  font-family: var(--font-mono);
  font-size: .75rem;
  color: var(--muted2);
  text-align: center;
  margin-bottom: 2rem;
}

/* ── Footer ─────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 3rem 2rem;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 1.5rem;
}

.footer-logo {
  display: flex; align-items: center; gap: .6rem;
}
.footer-logo img { width: 28px;  }
.footer-logo span {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
}
.footer-logo em {
  font-style: normal;
  color: var(--teal);
}

.footer-links {
  display: flex; gap: 1.5rem; list-style: none; flex-wrap: wrap;
}
.footer-links a {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--muted2);
  letter-spacing: .08em;
  transition: color .2s;
}
.footer-links a:hover { color: var(--teal); }

.footer-copy {
  font-family: var(--font-mono);
  font-size: .7rem;
  color: var(--muted2);
}

/* ── Divider line with label ────────────────────────────────── */
.divider-label {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 3rem;
}
.divider-label::before, .divider-label::after {
  content: ''; flex: 1;
  height: 1px; background: var(--border);
}
.divider-label span {
  font-family: var(--font-mono);
  font-size: .68rem;
  color: var(--muted2);
  letter-spacing: .15em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(.8); }
}
@keyframes scrollDrop {
  0% { opacity: 0; transform: scaleY(0); transform-origin: top; }
  50% { opacity: 1; transform: scaleY(1); transform-origin: top; }
  100% { opacity: 0; transform: scaleY(1); transform-origin: bottom; }
}
@keyframes scanDown {
  0%   { top: 20%; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { top: 80%; opacity: 0; }
}

/* Reveal on scroll */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity .7s ease, transform .7s ease;
}
.reveal.visible {
  opacity: 1;
  transform: none;
}

/* ── Theme toggle button ────────────────────────────────────── */
.theme-toggle {
  background: var(--teal-faint);
  border: 1px solid var(--border-mid);
  color: var(--muted);
  width: 34px; height: 34px;
  border-radius: 8px;
  display: grid; place-items: center;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--teal-glow);
  color: var(--teal);
  border-color: var(--teal);
}
.theme-toggle svg {
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* show/hide sun vs moon icons */
.icon-moon { display: block; }
.icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: block; }

/* ── Light mode adjustments ─────────────────────────────────── */
[data-theme="light"] body::before { opacity: .2; }

[data-theme="light"] #hero::after {
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
}

[data-theme="light"] #heatmap-canvas { opacity: 0.25; }

[data-theme="light"] .granularity {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.08);
}

[data-theme="light"] .flow-box {
  background: var(--bg-card2);
  color: var(--white);
}

[data-theme="light"] .bar-track {
  background: rgba(0,0,0,0.08);
}

[data-theme="light"] .terminal-bar {
  background: rgba(0,0,0,0.08);
}

[data-theme="light"] .btn-ghost {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.14);
  color: var(--white);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 2px 8px rgba(0,0,0,0.08);
}
[data-theme="light"] .btn-ghost:hover {
  background: rgba(0, 140, 140, 0.08);
  border-color: var(--teal);
  box-shadow: inset 0 1px 0 rgba(0,140,140,0.1), 0 0 14px rgba(0,140,140,0.15);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .explainer-grid,
  .framework-inner,
  .attack-grid { grid-template-columns: 1fr; }

  .primitives-grid { grid-template-columns: 1fr; }

  .stats-row { grid-template-columns: repeat(2, 1fr); }

  .mitigation-list { grid-template-columns: 1fr; }

  nav { padding: 0 1.25rem; }
  .nav-links { display: none; }
}

@media (max-width: 600px) {
  .stats-row { grid-template-columns: 1fr 1fr; }
  .hero-title { font-size: 2.8rem; }
  section { padding: 4rem 1.25rem; }
}

td.cl {
  width: 12px;
  height: 10px;
  padding: 2px;
  border-radius: 2px;
  background: var(--teal-faint);
  border: 1px solid var(--border);
  transition: background .3s, border-color .3s, box-shadow .3s;
}
td.cl.hit {
  background: rgba(0,210,210,0.35);
  border-color: var(--teal);
  box-shadow: 0 0 6px rgba(0,210,210,0.4);
}