/* Nullchat landing page. No framework, no third-party requests.
   Fonts: Martian Mono and Instrument Sans, both SIL Open Font License 1.1, self-hosted (latin subset). */

@font-face {
  font-family: "Martian Mono";
  src: url("fonts/martian-mono-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-stretch: 75% 112.5%;
  font-display: swap;
}
@font-face {
  font-family: "Instrument Sans";
  src: url("fonts/instrument-sans-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  /* light: cool lab paper */
  --paper: #eceef2;
  --paper-2: #e2e5eb;
  --ink: #161b26;
  --muted: #586074;
  --line: #c6cbd5;
  --uv: #5536e8;
  --uv-soft: #e4defd;
  --amber: #a25d00;
  --amber-soft: #f6e6cc;
  --code-bg: #161b26;
  --code-ink: #dfe3ec;
  --focus: #5536e8;

  /* ghost panel is always dark: it's the product's dark-chat theme */
  --ghost-bg: #0b0e1c;
  --ghost-panel: #12162a;
  --ghost-ink: #d9dcf0;
  --ghost-dim: #7d83a6;
  --ghost-uv: #a594ff;

  --mono: "Martian Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --max: 1140px;
  --gutter: clamp(16px, 4vw, 40px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1220;
    --paper-2: #131a2c;
    --ink: #e3e6ee;
    --muted: #949cb2;
    --line: #27304a;
    --uv: #a594ff;
    --uv-soft: #221d4a;
    --amber: #f0b35a;
    --amber-soft: #2f2410;
    --code-bg: #080b15;
    --code-ink: #dfe3ec;
    --focus: #b9acff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--uv); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
code, pre { font-family: var(--mono); }
code { font-size: 0.88em; }

.wrap { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }

.skip {
  position: absolute; left: 8px; top: -60px; z-index: 10;
  background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: 6px;
}
.skip:focus { top: 8px; }

/* ---------- top bar ---------- */
.top { border-bottom: 1px solid var(--line); }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 600 1.05rem/1 var(--mono); font-stretch: 112.5%; letter-spacing: -0.02em; }
.brand-mark { width: 24px; height: 24px; color: var(--uv); }
.top nav { display: flex; align-items: center; gap: clamp(12px, 2.5vw, 28px); font-size: 0.95rem; }
.top nav a { text-decoration: none; color: var(--muted); }
.top nav a:hover { color: var(--ink); }
.top nav .nav-get { color: var(--ink); font-weight: 600; }
@media (max-width: 640px) {
  .top nav a:not(.nav-get) { display: none; }
}

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: clamp(32px, 6vw, 88px);
  align-items: center;
  padding-block: clamp(48px, 9vw, 112px) clamp(56px, 8vw, 104px);
}
.hero h1 {
  margin: 0 0 24px;
  font-family: var(--mono);
  font-weight: 700;
  font-stretch: 87.5%;
  font-size: clamp(2.6rem, 6.4vw, 5rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}
.lede { margin: 0 0 32px; font-size: clamp(1.08rem, 1.5vw, 1.22rem); line-height: 1.55; color: var(--muted); max-width: 34em; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 28px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 22px; border-radius: 999px;
  font: 600 0.98rem/1 var(--sans); text-decoration: none;
  border: 1.5px solid var(--ink);
  transition: background-color .15s, color .15s;
}
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--uv); border-color: var(--uv); color: #fff; }
.btn-ghost { color: var(--ink); }
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.facts { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 0; font: 400 0.78rem/1.4 var(--mono); color: var(--muted); }
.facts span { display: inline-flex; align-items: center; gap: 8px; }
.facts span::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--uv); }

/* ---------- ghost demo ---------- */
.demo { margin: 0; justify-self: center; width: 100%; max-width: 400px; }
.phone {
  background: var(--ghost-bg);
  color: var(--ghost-ink);
  border-radius: 34px;
  padding: 14px 14px 16px;
  box-shadow:
    0 0 0 1px #2a2f4d inset,
    0 0 0 8px #1a1e33,
    0 30px 60px -20px rgba(28, 18, 90, .55);
  position: relative;
  overflow: hidden;
}
.phone::before {
  /* faint scanline grain so the dark panel doesn't read flat */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,.018) 0 1px, transparent 1px 3px);
}
.phone-head { display: flex; align-items: center; gap: 12px; padding: 6px 6px 14px; border-bottom: 1px solid #1f2440; }
.avatar svg { width: 36px; height: 36px; }
.who { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.who strong { font: 600 0.98rem/1.2 var(--sans); }
.who small { font: 400 0.68rem/1.4 var(--mono); color: var(--ghost-dim); }
.ghost-ico { width: 22px; height: 22px; color: var(--ghost-uv); }

.thread {
  list-style: none; margin: 0; padding: 18px 4px 10px;
  height: 340px;
  display: flex; flex-direction: column; justify-content: flex-end; gap: 10px;
  overflow: hidden;
}
.sys { align-self: center; text-align: center; font: 400 0.66rem/1.5 var(--mono); color: var(--ghost-dim); max-width: 30ch; margin-bottom: auto; }
.sys.flash { color: var(--ghost-uv); }

.msg {
  position: relative;
  max-width: 84%;
  padding: 10px 14px 8px;
  border-radius: 18px;
  font-size: 0.95rem; line-height: 1.4;
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows .45s ease, padding .45s ease, margin .45s ease, opacity .3s ease;
}
.msg > .inner { overflow: hidden; min-height: 0; }
.msg.in { align-self: flex-start; background: var(--ghost-panel); border-bottom-left-radius: 6px; box-shadow: 0 0 0 1px #232849 inset; }
.msg.out { align-self: flex-end; background: #2b2366; color: #ece9ff; border-bottom-right-radius: 6px; }
.msg code { font-size: 0.84em; color: #fff; background: rgba(165,148,255,.18); padding: 1px 5px; border-radius: 4px; }
.msg .text { display: block; overflow-wrap: anywhere; }
.msg .meta { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 4px; font: 400 0.62rem/1 var(--mono); color: var(--ghost-dim); }
.msg.out .meta { color: #a9a0e6; }

.ring { width: 14px; height: 14px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 2.6; }
.ring-track { stroke: rgba(165,148,255,.18); }
.ring-fill { stroke: var(--ghost-uv); stroke-dasharray: 50.27; stroke-dashoffset: 0; }
.msg.burning .ring-fill { animation: ring var(--ttl, 5s) linear forwards; }
@keyframes ring { to { stroke-dashoffset: 50.27; } }

.msg.dissolve .text { animation: dissolve .9s ease-in forwards; }
.msg.dissolve { animation: bubble-fade .9s ease-in forwards; }
@keyframes dissolve {
  0% { filter: blur(0); letter-spacing: 0; opacity: 1; }
  60% { opacity: .8; }
  100% { filter: blur(6px); letter-spacing: .3em; opacity: 0; }
}
@keyframes bubble-fade {
  0% { background-color: var(--bg0, #12162a); }
  100% { background-color: transparent; box-shadow: 0 0 0 1px transparent inset; }
}
.msg.collapse { grid-template-rows: 0fr; padding-block: 0; margin-block: -5px; opacity: 0; }
.msg.enter { animation: enter .35s cubic-bezier(.2,.8,.2,1); }
@keyframes enter { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.composer {
  display: flex; align-items: center; gap: 2px;
  margin-top: 8px; padding: 12px 16px; border-radius: 999px;
  background: #151a30; color: var(--ghost-dim); font-size: 0.9rem;
}
.caret { width: 2px; height: 1.1em; background: var(--ghost-uv); margin-left: 6px; animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.demo figcaption { margin-top: 18px; font-size: 0.85rem; color: var(--muted); text-align: center; padding-inline: 8px; }

/* ---------- shared section bits ---------- */
section h2 {
  margin: 0 0 12px;
  font-family: var(--mono);
  font-weight: 600;
  font-stretch: 87.5%;
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -0.035em;
}
.section-lede { margin: 0 0 40px; color: var(--muted); max-width: 40em; }
.help, .how, .security, .selfhost, .get { padding-block: clamp(56px, 8vw, 104px); border-top: 1px solid var(--line); }

/* ---------- --help ---------- */
.prompt span { color: var(--uv); }
.flags { margin: 32px 0 0; display: grid; grid-template-columns: 1fr 1fr; column-gap: 56px; }
.flags > div { display: grid; grid-template-columns: 9.5rem 1fr; gap: 16px; padding: 18px 0; border-bottom: 1px dashed var(--line); }
.flags dt { font: 500 0.9rem/1.6 var(--mono); color: var(--uv); }
.flags dd { margin: 0; font-size: 0.98rem; line-height: 1.55; }

/* ---------- diagram ---------- */
.diagram { margin: 0 0 48px; padding: clamp(16px, 3vw, 32px); border: 1px solid var(--line); border-radius: 20px; background: var(--paper-2); }
.diagram svg { width: 100%; height: auto; }
.diagram-tall { display: none !important; max-width: 420px; margin-inline: auto; }
.dg-phone { fill: var(--ink); }
.dg-screen { fill: #0b0e1c; }
.dg-bubble { fill: #2a3050; }
.dg-bubble-out { fill: #5536e8; }
.dg-wrap { fill: var(--paper); stroke: var(--uv); stroke-width: 1.5; stroke-dasharray: 5 4; }
.dg-seal { fill: var(--uv-soft); stroke: var(--uv); stroke-width: 1.2; }
.dg-rumor { fill: var(--paper); stroke: var(--line); }
.dg-relay rect { fill: var(--paper); stroke: var(--line); stroke-width: 1.2; }
.dg-line { fill: none; stroke: var(--muted); stroke-width: 1.6; }
.dg-dash { stroke: var(--uv); stroke-dasharray: 4 5; }
.dg-arrowhead { fill: var(--muted); }
.dg-label { font: 600 15px var(--sans); fill: var(--ink); }
.dg-sub { font: 400 12px var(--mono); fill: var(--muted); }
.dg-tag { font: 600 13px var(--mono); fill: var(--ink); }
.dg-tag-rumor { font-family: var(--sans); font-weight: 500; font-size: 14px; }
.dg-mono { font: 500 13.5px var(--mono); fill: var(--ink); }
.dg-accent { fill: var(--uv); }

.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 32px; }
.steps li { counter-increment: step; position: relative; padding-top: 44px; font-size: 0.97rem; color: var(--muted); }
.steps li::before {
  content: counter(step);
  position: absolute; top: 0; left: 0;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font: 600 0.8rem/1 var(--mono); color: var(--uv); border: 1.5px solid var(--uv);
}
.steps strong { display: block; color: var(--ink); font-family: var(--mono); font-weight: 600; font-size: 1rem; margin-bottom: 6px; }

/* ---------- security ---------- */
.sec-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: clamp(32px, 5vw, 64px); align-items: start; }
.event { margin: 0; position: sticky; top: 24px; }
.event figcaption { font: 400 0.8rem/1 var(--mono); color: var(--muted); margin-bottom: 12px; }
pre {
  margin: 0; padding: 22px 24px; border-radius: 16px;
  background: var(--code-bg); color: var(--code-ink);
  font-size: 0.8rem; line-height: 1.75; overflow-x: auto;
  box-shadow: 0 0 0 1px var(--line);
}
pre code { font-size: inherit; }
pre .k { color: #b9acff; }
pre .s { color: #9fdcc4; }
pre .n { color: #f0c27a; }
pre .c { color: #7a83a3; }
pre .c.warn { color: #f0b35a; }
pre .pr { color: #a594ff; user-select: none; }

.ledger h3 { margin: 0 0 14px; font: 600 1.05rem/1.3 var(--mono); }
.ledger h3:not(:first-child) { margin-top: 36px; }
.ledger ul { list-style: none; margin: 0; padding: 0; }
.ledger li { position: relative; padding: 10px 0 10px 32px; border-bottom: 1px solid var(--line); font-size: 0.98rem; }
.ledger li::before { position: absolute; left: 0; top: 10px; font: 600 0.95rem/1.6 var(--mono); }
.yes li::before { content: "+"; color: var(--uv); }
.no li::before { content: "!"; color: var(--amber); left: 4px; }
.no li strong { color: var(--ink); }
.no li { color: var(--muted); }
.sec-links { display: flex; flex-wrap: wrap; gap: 20px; margin: 28px 0 0; font: 500 0.9rem/1.4 var(--mono); }

/* ---------- self-host ---------- */
.sh-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(24px, 4vw, 48px); }
.term header h3 { margin: 0 0 6px; font: 600 1.15rem/1.3 var(--mono); }
.term header p { margin: 0 0 18px; color: var(--muted); font-size: 0.98rem; }
.term pre { font-size: 0.8rem; }
.term-foot { margin: 16px 0 0; font-size: 0.92rem; color: var(--muted); }
.term-foot code { color: var(--ink); }

/* ---------- get ---------- */
.stores { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.store {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; column-gap: 14px;
  padding: 20px; border-radius: 16px; border: 1.5px solid var(--line);
  text-decoration: none; height: 100%;
  cursor: default;
}
.store:hover { color: inherit; border-color: var(--muted); }
.store svg { grid-row: 1 / 3; width: 30px; height: 30px; color: var(--ink); }
.store-name { font: 600 1.05rem/1.2 var(--sans); }
.store-where { font-size: 0.85rem; color: var(--muted); line-height: 1.35; }
.store-state { grid-column: 1 / -1; margin-top: 16px; font: 400 0.72rem/1 var(--mono); color: var(--amber); }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); padding-block: 32px 48px; font-size: 0.9rem; color: var(--muted); }
.foot-inner { display: flex; flex-wrap: wrap; gap: 16px 32px; justify-content: space-between; align-items: baseline; }
.foot p { margin: 0; }
.foot nav { display: flex; flex-wrap: wrap; gap: 8px 22px; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .demo { max-width: 420px; }
  .flags { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr 1fr; gap: 28px 32px; }
  .sec-grid { grid-template-columns: 1fr; }
  .event { position: static; }
  .sh-grid { grid-template-columns: 1fr; }
  .stores { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .diagram-wide { display: none !important; }
  .diagram-tall { display: block !important; }
  .flags > div { grid-template-columns: 1fr; gap: 4px; }
  .steps { grid-template-columns: 1fr; }
  .stores { grid-template-columns: 1fr; }
  pre { font-size: 0.72rem; padding: 18px; }
  .thread { height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .caret { animation: none; }
}
.dg-arrowhead-uv { fill: var(--uv); }
.msg code { white-space: nowrap; }
pre { font-stretch: 87.5%; }
.sh-grid > *, .sec-grid > *, .hero > * { min-width: 0; }
