/* ============================================================
   Snaptare — shared stylesheet for legal + documentation pages
   Mirrors the design tokens of the marketing index pages and
   the tablet app at tablet/src/index.css.
   ============================================================ */

:root {
  --bg:         245 243 237;
  --bg-raised:  253 251 246;
  --bg-sunken:  235 232 224;
  --bg-inset:   222 218 208;

  --ink:        24 28 33;
  --ink-muted:  86 95 108;
  --ink-subtle: 100 108 120; /* WCAG AA on bg-raised: 5.13:1 */

  --line:       215 211 200;

  --leaf:       56 132 81;
  --leaf-glow:  92 168 116;
  --leaf-ink:   245 247 244;

  --amber:      232 178 92;
  --amber-glow: 248 200 124;

  --brand-deep: #2A3D8F;
  --brand-mid:  #1775C6;
  --brand-cyan: #09A7E8;

  --danger:     185 56 56;

  --sans:    'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --display: 'Geist', 'Inter', system-ui, sans-serif;
  --mono:    'Geist Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --container: 1180px;
  --container-narrow: 760px;
  --gutter: clamp(20px, 4vw, 40px);

  color-scheme: light;
}

html[data-theme='dark'] {
  --bg:         11 15 18;
  --bg-raised:  21 26 32;
  --bg-sunken:  7 11 14;
  --bg-inset:   4 7 9;
  --ink:        235 240 247;
  --ink-muted:  156 167 182;
  --ink-subtle: 120 132 148;
  --line:       38 48 60;
  --leaf:       110 198 134;
  --leaf-glow:  160 230 178;
  --leaf-ink:   12 22 16;
  --danger:     239 68 68;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  font-feature-settings: 'cv11', 'ss01', 'ss03', 'cv05';
  letter-spacing: 0.005em;
  background-color: rgb(var(--bg));
  color: rgb(var(--ink));
}

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

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(1000px 500px at 100% 0%, rgb(var(--leaf) / 0.05), transparent 60%),
    radial-gradient(800px 400px at 0% 100%, rgb(var(--amber) / 0.04), transparent 65%),
    rgb(var(--bg));
  min-height: 100vh;
}

/* paper grain — multiply on light, overlay on dark */
body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.035;
  mix-blend-mode: multiply;
}
html[data-theme='dark'] body::before {
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.04;
  mix-blend-mode: overlay;
}

a { color: rgb(var(--leaf)); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: rgb(var(--leaf-glow)); text-decoration: underline; text-underline-offset: 3px; }
a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgb(var(--leaf) / 0.45);
  border-radius: 4px;
}

::selection { background: rgb(var(--leaf) / 0.3); color: rgb(var(--ink)); }

img, svg { display: block; max-width: 100%; }
strong { color: rgb(var(--ink)); font-weight: 600; }

/* skip-link — keyboard / screen-reader only */
.skip-link {
  position: absolute;
  left: 12px; top: -100px;
  background: rgb(var(--ink));
  color: rgb(var(--bg));
  padding: 10px 14px;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  z-index: 100;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; outline: none; box-shadow: 0 0 0 3px rgb(var(--leaf) / 0.45); }

/* layout */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
  position: relative;
  z-index: 1;
}
.container-narrow { max-width: var(--container-narrow); }

/* topbar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgb(var(--bg-sunken) / 0.7);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid rgb(var(--line) / 0.6);
}
.topbar-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex; align-items: center; gap: 24px;
  height: 64px;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--display);
  font-size: 18px; font-weight: 600;
  letter-spacing: -0.01em;
  color: rgb(var(--ink));
}
.brand:hover { color: rgb(var(--ink)); text-decoration: none; }
.brand svg { width: 28px; height: 28px; flex-shrink: 0; }
.topbar nav {
  margin-left: auto;
  display: flex; gap: 24px;
  font-size: 14px;
}
.topbar nav a {
  color: rgb(var(--ink-muted));
  text-decoration: none;
}
.topbar nav a:hover { color: rgb(var(--ink)); text-decoration: none; }
.topbar nav a[aria-current="page"] { color: rgb(var(--ink)); font-weight: 600; }
.lang-switch {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: rgb(var(--ink-subtle));
  display: inline-flex; gap: 6px; align-items: center;
}
.lang-switch a { color: rgb(var(--ink-subtle)); }
.lang-switch a:hover { color: rgb(var(--ink)); text-decoration: none; }
.lang-switch [aria-current="page"] { color: rgb(var(--ink)); }
.lang-switch span { opacity: 0.4; }

/* page header */
.page-head { padding: clamp(48px, 7vw, 88px) 0 clamp(28px, 4vw, 48px); }
.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgb(var(--ink-subtle));
  display: inline-flex; align-items: center; gap: 8px;
  margin-bottom: 16px;
}
.eyebrow::before { content: ""; width: 16px; height: 1px; background: rgb(var(--leaf)); }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  color: rgb(var(--ink));
}
h1 { font-size: clamp(36px, 5.5vw, 56px); line-height: 1.04; letter-spacing: -0.03em; }
h2 { font-size: clamp(24px, 3vw, 32px); margin: 32px 0 12px; }
h3 { font-size: 20px; margin: 24px 0 8px; }

p { margin: 0 0 14px; color: rgb(var(--ink-muted)); }
p:last-child { margin-bottom: 0; }
.lead { font-size: clamp(17px, 1.4vw, 19px); color: rgb(var(--ink-muted)); max-width: 64ch; margin-bottom: 8px; }
.updated { font-size: 14px; color: rgb(var(--ink-subtle)); margin: 0 0 32px; font-family: var(--mono); }

/* prose layout (long-form text) */
.prose {
  max-width: var(--container-narrow);
  margin: 0 auto;
}
.prose h2 { margin-top: 48px; }
.prose h2:first-child { margin-top: 0; }
.prose ul, .prose ol {
  padding-left: 0;
  list-style: none;
  margin: 0 0 16px;
}
.prose ul li, .prose ol li {
  padding: 4px 0 4px 24px;
  position: relative;
  color: rgb(var(--ink-muted));
}
.prose ul li::before {
  content: "·";
  position: absolute;
  left: 8px; top: -1px;
  color: rgb(var(--leaf));
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
}
.prose ol { counter-reset: prose-ol; }
.prose ol li {
  counter-increment: prose-ol;
}
.prose ol li::before {
  content: counter(prose-ol) ".";
  position: absolute;
  left: 4px; top: 4px;
  font-family: var(--mono);
  font-size: 13px;
  color: rgb(var(--leaf));
  font-weight: 600;
}
.prose hr {
  border: 0;
  border-top: 1px solid rgb(var(--line) / 0.6);
  margin: 40px 0;
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: rgb(var(--bg-sunken));
  border: 1px solid rgb(var(--line) / 0.6);
  color: rgb(var(--leaf));
  padding: 1px 7px;
  border-radius: 6px;
  font-weight: 500;
  white-space: nowrap;
}
pre {
  background: rgb(var(--bg-sunken));
  border: 1px solid rgb(var(--line) / 0.6);
  border-radius: 12px;
  padding: 16px 20px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 14px;
  margin: 16px 0;
}
pre code { background: transparent; border: 0; padding: 0; color: rgb(var(--ink)); }

/* notes / callouts */
.note {
  background:
    radial-gradient(60% 100% at 0% 0%, rgb(var(--leaf) / 0.1), transparent 70%),
    rgb(var(--bg-sunken) / 0.6);
  border: 1px solid rgb(var(--leaf) / 0.4);
  border-left: 3px solid rgb(var(--leaf));
  padding: 14px 18px;
  border-radius: 12px;
  margin: 18px 0;
  font-size: 15px;
  color: rgb(var(--ink-muted));
}
.note strong { color: rgb(var(--ink)); }
.note code { background: rgb(var(--bg-raised)); }

.note-warn {
  background: rgb(var(--amber) / 0.1);
  border: 1px solid rgb(var(--amber) / 0.45);
  border-left: 3px solid rgb(var(--amber));
}

/* card / step */
.card {
  background: rgb(var(--bg-raised));
  border: 1px solid rgb(var(--line) / 0.7);
  border-radius: 20px;
  padding: 28px 32px 24px;
  margin: 20px 0;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.5),
    0 1px 0 rgb(var(--line) / 0.4);
}

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px; font-weight: 600;
  font-family: var(--sans);
  letter-spacing: -0.005em;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, filter 0.15s ease;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary {
  background: rgb(var(--leaf));
  color: rgb(var(--leaf-ink));
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.22),
    0 10px 26px -12px rgb(var(--leaf) / 0.7);
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); color: rgb(var(--leaf-ink)); }
.btn-ghost {
  background: rgb(var(--bg-raised));
  color: rgb(var(--ink));
  border-color: rgb(var(--line) / 0.6);
}
.btn-ghost:hover { border-color: rgb(var(--line)); background: rgb(var(--bg-inset) / 0.4); color: rgb(var(--ink)); }

/* footer */
footer {
  border-top: 1px solid rgb(var(--line) / 0.5);
  padding: 32px 0 64px;
  margin-top: 48px;
  font-size: 14px;
  color: rgb(var(--ink-subtle));
}
.foot-grid {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex; gap: 24px; flex-wrap: wrap;
  justify-content: space-between; align-items: center;
}
.foot-grid nav { display: flex; gap: 24px; flex-wrap: wrap; }
.foot-grid nav a { color: rgb(var(--ink-muted)); }
.foot-grid nav a:hover { color: rgb(var(--ink)); text-decoration: none; }
.foot-credit a { color: rgb(var(--ink-muted)); }
.foot-credit a:hover { color: rgb(var(--leaf)); text-decoration: none; }

/* docs sidebar layout */
.docs-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: clamp(32px, 5vw, 64px);
  padding: clamp(32px, 5vw, 64px) 0 64px;
}
@media (max-width: 880px) {
  .docs-layout { grid-template-columns: 1fr; }
}
.docs-nav {
  position: sticky;
  top: 80px;
  align-self: start;
  font-size: 14px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}
@media (max-width: 880px) {
  .docs-nav { position: static; margin-bottom: 24px; }
}
.docs-nav-section {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgb(var(--ink-subtle));
  margin: 24px 0 8px;
}
.docs-nav-section:first-child { margin-top: 0; }
.docs-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex; flex-direction: column;
}
.docs-nav-list a {
  display: block;
  padding: 6px 12px;
  border-radius: 8px;
  color: rgb(var(--ink-muted));
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -2px;
}
.docs-nav-list a:hover {
  color: rgb(var(--ink));
  background: rgb(var(--bg-sunken) / 0.6);
}
.docs-nav-list a[aria-current="page"] {
  color: rgb(var(--leaf));
  border-left-color: rgb(var(--leaf));
  background: rgb(var(--leaf) / 0.06);
  font-weight: 600;
}

/* docs index card grid */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 32px 0;
}
@media (max-width: 720px) {
  .docs-grid { grid-template-columns: 1fr; }
}
.docs-card {
  background: rgb(var(--bg-raised));
  border: 1px solid rgb(var(--line) / 0.7);
  border-radius: 16px;
  padding: 24px 26px;
  display: flex; flex-direction: column; gap: 10px;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.5);
}
.docs-card:hover {
  transform: translateY(-2px);
  border-color: rgb(var(--leaf) / 0.5);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.5), 0 10px 24px -12px rgb(var(--leaf) / 0.25);
  text-decoration: none;
}
.docs-card-icon { width: 28px; height: 28px; color: rgb(var(--leaf)); }
.docs-card-title {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
  color: rgb(var(--ink));
  letter-spacing: -0.01em;
}
.docs-card-desc {
  font-size: 14px;
  color: rgb(var(--ink-muted));
  line-height: 1.5;
}

/* prev/next pager */
.docs-pager {
  display: flex; justify-content: space-between; gap: 16px;
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid rgb(var(--line) / 0.5);
}
.docs-pager a {
  display: flex; flex-direction: column; gap: 4px;
  flex: 1;
  padding: 16px 20px;
  border: 1px solid rgb(var(--line) / 0.6);
  border-radius: 12px;
  text-decoration: none;
  color: rgb(var(--ink));
  transition: border-color 0.15s ease, background 0.15s ease;
}
.docs-pager a:hover {
  border-color: rgb(var(--leaf) / 0.5);
  background: rgb(var(--leaf) / 0.04);
  text-decoration: none;
}
.docs-pager .label {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgb(var(--ink-subtle));
}
.docs-pager .title { font-weight: 600; font-family: var(--display); font-size: 16px; }
.docs-pager .next { text-align: right; }

/* table of contents */
.toc {
  background: rgb(var(--bg-raised));
  border: 1px solid rgb(var(--line) / 0.6);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 24px 0 32px;
}
.toc-label {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: rgb(var(--ink-subtle));
  margin: 0 0 8px;
}
.toc ol { counter-reset: toc; padding: 0; margin: 0; list-style: none; }
.toc li { counter-increment: toc; padding: 4px 0 4px 28px; position: relative; }
.toc li::before {
  content: counter(toc, decimal-leading-zero);
  position: absolute; left: 0; top: 4px;
  font-family: var(--mono);
  font-size: 11px;
  color: rgb(var(--ink-subtle));
}
.toc a { color: rgb(var(--ink-muted)); }
.toc a:hover { color: rgb(var(--leaf)); text-decoration: none; }
