/* ============================================================
   Shared styles for the legal pages (terms, privacy, gdpr,
   ai-policy). The marketing page keeps its CSS inline; these
   documents are long-form and near-identical, so they share a
   cached stylesheet instead.

   Tokens are kept in sync with the :root block in index.html.
   ============================================================ */

:root {
  /* shared across themes */
  --display: "Unbounded", sans-serif;
  --body: "Albert Sans", sans-serif;
  --mono: "IBM Plex Mono", monospace;
  --pad: clamp(20px, 5vw, 72px);
  --acid-fill: #8dfa4e;
  --acid-fill-ink: #06130a;

  /* dark theme (default) */
  color-scheme: dark;
  --bg: #070a07;
  --bg-2: #0b100b;
  --bg-3: #101710;
  --ink: #e9f1e4;
  --muted: #8fa08a;
  --faint: #5b6a58;
  --acid: #8dfa4e;
  --acid-dim: #5fbd33;
  --amber: #ffc24b;
  --line: rgba(233, 241, 228, 0.1);
  --line-strong: rgba(233, 241, 228, 0.2);
  --scroll-thumb: #263524;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5ec;
  --bg-2: #ebedde;
  --bg-3: #e0e4cf;
  --ink: #1c2415;
  --muted: #5d6b54;
  --faint: #9aa58e;
  --acid: #3e8e11;
  --acid-dim: #57a82b;
  --amber: #a56f00;
  --line: rgba(28, 36, 21, 0.12);
  --line-strong: rgba(28, 36, 21, 0.24);
  --scroll-thumb: #c3cbb4;
}

/* ============ reset ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: var(--acid-fill); color: var(--acid-fill-ink); }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--acid-dim); }

/* Static grain, matching the marketing page's texture without the
   animation — these pages are read, not scanned. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2000;
  opacity: 0.04;
  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='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============ header ============ */
header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px var(--pad);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.brand .ant-mark { width: 26px; height: 26px; }
.ant-mark { stroke: var(--acid); }
.brand em { font-style: normal; color: var(--acid); }

nav { display: flex; align-items: center; gap: clamp(12px, 3vw, 28px); }
nav a.navlink {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.2s;
  position: relative;
}
nav a.navlink::before {
  content: ">";
  position: absolute;
  left: -12px;
  color: var(--acid);
  opacity: 0;
  transition: opacity 0.2s;
}
nav a.navlink:hover { color: var(--ink); }
nav a.navlink:hover::before { opacity: 1; }
nav a.navlink[aria-current="page"] { color: var(--acid); }
@media (max-width: 900px) { nav a.navlink { display: none; } }

.theme-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 100px;
}
.theme-switch button {
  appearance: none;
  background: none;
  border: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--faint);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.theme-switch button svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-switch button:hover { color: var(--ink); }
.theme-switch button[aria-pressed="true"] { background: var(--bg-3); color: var(--acid); }
@media (max-width: 480px) {
  header { padding: 12px 16px; }
  .brand { font-size: 0.78rem; }
  .brand .ant-mark { width: 22px; height: 22px; }
  nav { gap: 8px; }
  .theme-switch button { width: 20px; height: 20px; }
  .theme-switch button svg { width: 12px; height: 12px; }
}

/* ============ document shell ============ */
.doc {
  max-width: 1180px;
  margin: 0 auto;
  padding: calc(64px + 6vh) var(--pad) 10vh;
}
.mono {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--acid);
}
.doc-head {
  border-bottom: 1px solid var(--line);
  padding-bottom: clamp(24px, 4vh, 40px);
  margin-bottom: clamp(28px, 5vh, 48px);
}
.doc-head h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(2rem, 5.5vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 14px 0 18px;
}
.doc-head .lede {
  color: var(--muted);
  font-size: clamp(1rem, 1.4vw, 1.15rem);
  max-width: 62ch;
}
.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  margin-top: 22px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--faint);
  text-transform: uppercase;
}

/* two-column: sticky contents rail + prose */
.doc-body {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: start;
}
@media (max-width: 900px) {
  .doc-body { grid-template-columns: minmax(0, 1fr); }
}

.toc {
  position: sticky;
  top: calc(64px + 24px);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  line-height: 1.5;
}
.toc h2 {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--acid);
  margin-bottom: 14px;
  font-weight: 500;
}
.toc ol { list-style: none; counter-reset: toc; }
.toc li { counter-increment: toc; margin-bottom: 9px; }
.toc a {
  color: var(--muted);
  transition: color 0.2s;
  display: block;
}
.toc a::before {
  content: counter(toc) ".";
  color: var(--faint);
  margin-right: 7px;
}
.toc a:hover { color: var(--acid); }
@media (max-width: 900px) {
  .toc {
    position: static;
    border: 1px solid var(--line);
    padding: 20px 22px;
    margin-bottom: 36px;
    background: var(--bg-2);
  }
}

/* ============ prose ============ */
.prose { max-width: 74ch; }
.prose section { margin-bottom: clamp(34px, 5vh, 52px); scroll-margin-top: 90px; }
.prose h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.15rem, 2.2vw, 1.5rem);
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}
.prose h2 .num {
  font-family: var(--mono);
  font-size: 0.7em;
  color: var(--acid);
  margin-right: 10px;
  font-weight: 500;
}
.prose h3 {
  font-family: var(--body);
  font-weight: 600;
  font-size: 1.02rem;
  margin: 26px 0 10px;
  color: var(--ink);
}
.prose p { color: var(--muted); margin-bottom: 14px; }
.prose strong { color: var(--ink); font-weight: 600; }
.prose ul, .prose ol { color: var(--muted); margin: 0 0 16px 22px; }
.prose li { margin-bottom: 9px; padding-left: 4px; }
.prose ul { list-style: none; margin-left: 0; }
.prose ul > li { position: relative; padding-left: 22px; }
.prose ul > li::before {
  content: "▪";
  position: absolute;
  left: 4px;
  color: var(--acid);
  font-size: 0.8em;
  top: 0.15em;
}
.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--ink);
  background: var(--bg-3);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 3px;
  word-break: break-word;
}
.prose a:not(.email-link) {
  color: var(--acid);
  border-bottom: 1px solid var(--line-strong);
  transition: border-color 0.2s;
}
.prose a:not(.email-link):hover { border-color: var(--acid); }
.prose .email-link {
  color: var(--acid);
  font-family: var(--mono);
  font-size: 0.92em;
  cursor: pointer;
  border-bottom: 1px solid var(--line-strong);
}
.prose .email-link:hover { border-color: var(--acid); }

/* definition-style key/value rows (roles, retention, subprocessors) */
.prose .rows {
  border-top: 1px solid var(--line);
  margin-bottom: 18px;
}
.prose .rows > div {
  display: grid;
  grid-template-columns: minmax(0, 0.42fr) minmax(0, 0.58fr);
  gap: 8px 24px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
@media (max-width: 620px) {
  .prose .rows > div { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}
.prose .rows dt, .prose .rows .k {
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  padding-top: 2px;
}
.prose .rows dd, .prose .rows .v {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
}

/* highlighted note */
.note {
  border: 1px solid var(--line-strong);
  border-left: 2px solid var(--acid);
  background: var(--bg-2);
  padding: 18px 22px;
  margin: 22px 0;
}
.note p:last-child { margin-bottom: 0; }
.note .mono { display: block; margin-bottom: 8px; }

/* ============ footer ============ */
footer {
  border-top: 1px solid var(--line);
  padding: 28px var(--pad);
  display: flex;
  flex-direction: column;
  gap: 16px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: var(--faint);
}
footer .footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
footer .footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px 24px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
footer .footer-legal { display: flex; flex-wrap: wrap; gap: 8px 20px; }
footer .footer-legal a { transition: color 0.2s; }
footer .footer-reg { color: var(--faint); }
footer .heart { color: var(--acid); }
footer a:hover { color: var(--acid); }
.email-link { cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
