/* ==========================================================================
   Alignment — legal & support site
   Tokens lifted verbatim from the app's "Steady" design system
   (src/constants/Colors.tsx, docs/DESIGN_SYSTEM.md, upright-app-v2-*.html).
   Static CSS. No build step, no framework.
   ========================================================================== */

:root {
  /* Surfaces & ink */
  --bg: #F5F1EA;
  --surface: #FFFFFF;
  --ink: #171614;
  --soft-ink: #3A3733;
  --muted: #8B857A;
  --meta: #6E675C;          /* small text — muted fails AA at 14px on cream */
  --line: #E7E0D4;
  --line-2: #DBD2C2;

  /* Brand */
  --primary: #1F6E5C;
  --primary-d: #175546;
  --primary-soft: #E4EEEA;
  --accent: #E07A4F;
  --accent-soft: #F5DDCD;
  /* Text-weight terracotta. The app's #C25A30 is 3.36:1 on --accent-soft and
     4.38:1 on white — both fail AA for the small text that uses it. */
  --accent-ink: #9E4520;
  --sand: #EDE3CF;

  --link: #1F6E5C;
  --link-hover: #175546;

  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI",
    system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15140F;
    --surface: #1E1C17;
    --ink: #F2EDE3;
    --soft-ink: #D6CFC2;
    --muted: #9C958A;
    --meta: #B8B2A6;
    --line: #2E2B24;
    --line-2: #3A362D;
    --primary: #3E9A85;
    --primary-d: #2C8870;
    --primary-soft: #12241F;   /* darkened from the app's #1B3A33: 3.63:1 -> 4.75:1 */
    --accent: #E59570;
    --accent-soft: #3A2A22;
    --accent-ink: #E8A988;
    --sand: #2A2620;
    --link: #6FC3A8;        /* lighter than --primary: links must clear AA on --sand too */
    --link-hover: #9BDCC5;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 96px;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16.5px;
  font-weight: 500;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Header ------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-in {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 26px;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--ink);
  font-size: 16.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* The app's signature: a figure inside a tinted circle, reduced to its mark. */
.mark {
  width: 30px;
  height: 30px;
  border-radius: 99px;
  background: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 30px;
}

.mark svg { display: block; }

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

.nav a {
  color: var(--meta);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 8px 12px;
  border-radius: 99px;
  transition: color 180ms ease, background 180ms ease;
}

.nav a:hover { color: var(--primary); background: var(--primary-soft); }
.nav a[aria-current="page"] { color: var(--primary); background: var(--primary-soft); }

/* ---------- Layout ------------------------------------------------------ */

.doc {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 26px 96px;
}

.article { max-width: 700px; }

.masthead { padding: 54px 0 8px; max-width: 700px; }

/* Pages without a contents rail centre their single column. */
.doc.single > * { margin-left: auto; margin-right: auto; }

/* Legal pages carry their footer outside <main>; drop the duplicated gap.
   Falls back harmlessly to extra whitespace where :has() is unsupported. */
.doc:has(> .layout) { padding-bottom: 0; }

.kick {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
}

h1 {
  font-size: clamp(34px, 6vw, 44px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin: 14px 0 12px;
}

.lede {
  font-size: 18.5px;
  line-height: 1.55;
  color: var(--soft-ink);
  font-weight: 500;
}

.stamp {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--meta);
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
}

.stamp .dot {
  width: 5px; height: 5px; border-radius: 99px;
  background: var(--line-2); flex: 0 0 5px;
}

/* ---------- Sections ---------------------------------------------------- */

.article h2 {
  position: relative;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.16;
  margin: 44px 0 12px;
}

/* Numbered, rule-separated sections — legal documents only. */
.legal h2 {
  margin-top: 52px;
  padding-top: 30px;
  border-top: 1px solid var(--line);
}

.article h2 .num {
  display: inline-flex;
  width: 27px; height: 27px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0;
  align-items: center;
  justify-content: center;
  margin-right: 11px;
  vertical-align: 3px;
}

.article h3 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin: 30px 0 6px;
}

.article p { margin: 0 0 14px; color: var(--soft-ink); }
.article p strong, .article li strong { color: var(--ink); font-weight: 700; }

/* App list style: 7px terracotta square marker (upright-app-v2 .notepanel li). */
.article ul { list-style: none; margin: 0 0 16px; }

.article ul li {
  position: relative;
  padding: 5px 0 5px 22px;
  color: var(--soft-ink);
}

.article ul li::before {
  content: "";
  position: absolute;
  left: 0; top: 15px;
  width: 7px; height: 7px;
  border-radius: 2px;
  background: var(--accent);
}

.article ol { margin: 0 0 16px 20px; }
.article ol li { padding: 5px 0 5px 4px; color: var(--soft-ink); }

a {
  color: var(--link);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

a:hover { color: var(--link-hover); }

:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 3px;
  border-radius: 9px;
}

/* ---------- Cards ------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px 24px;
  margin: 22px 0;
}

.card > :last-child { margin-bottom: 0; }
.card p { color: var(--soft-ink); }

.card.soft { background: var(--primary-soft); border-color: transparent; }
.card.warm { background: var(--accent-soft); border-color: transparent; }
.card.sand { background: var(--sand); border-color: transparent; }

.card-kick {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  display: block;
  margin-bottom: 9px;
}

.card.warm .card-kick { color: var(--accent-ink); }

/* ---------- Scan-privacy diagram (the page's signature element) ---------- */

.flow {
  display: grid;
  grid-template-columns: 1fr 0.78fr;
  align-items: stretch;
  margin: 24px 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  overflow: hidden;
}

.flow-side { padding: 20px 22px; }
.flow-side.device { background: var(--primary-soft); }

/* The dashed rule is the point of the diagram: nothing but numbers crosses it. */
.flow-side.cloud { border-left: 2px dashed var(--accent); }

.flow-label {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 14px;
}

.flow-side.cloud .flow-label { color: var(--meta); }

.flow-step {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 7px 0;
}

.flow-bead {
  width: 9px; height: 9px;
  border-radius: 99px;
  background: var(--primary);
  flex: 0 0 9px;
  margin-top: 8px;
}

.flow-side.cloud .flow-bead { background: var(--muted); }

.flow-step b {
  display: block;
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
  line-height: 1.35;
}

.flow-step span {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--meta);
  line-height: 1.45;
}

.flow-note {
  grid-column: 1 / -1;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-top: 1px solid var(--line);
  padding: 12px 20px;
  text-align: center;
  margin: 0;
}

@media (max-width: 660px) {
  .flow { grid-template-columns: 1fr; }
  .flow-side.cloud {
    border-left: 0;
    border-top: 2px dashed var(--accent);
  }
}

/* ---------- Tables ------------------------------------------------------ */

/* tabindex="0" in the HTML makes these scrollable regions keyboard-reachable. */
.tbl { overflow-x: auto; margin: 20px 0; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  min-width: 460px;
}

th, td {
  text-align: left;
  vertical-align: top;
  padding: 12px 16px 12px 0;
  border-bottom: 1px solid var(--line);
  line-height: 1.5;
}

th {
  color: var(--primary);
  font-weight: 800;
  font-size: 11.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-bottom-color: var(--line-2);
  padding-bottom: 9px;
}

td { color: var(--soft-ink); }
td:first-child { color: var(--ink); font-weight: 700; }
tr:last-child td { border-bottom: 0; }

/* ---------- Contents rail ----------------------------------------------- */

.layout { display: block; }

.col { min-width: 0; }

.rail { display: none; }

.toc-m { margin: 30px 0 6px; }

.toc-m summary {
  cursor: pointer;
  list-style: none;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  padding: 13px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.toc-m summary::-webkit-details-marker { display: none; }

/* Chevron drawn from borders — no glyph the font might not have, and nothing
   for a screen reader to announce as part of the summary's name. */
.toc-m summary::after {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 180ms ease;
}

.toc-m[open] summary::after { transform: rotate(-135deg) translateY(1px); }

.toc-m ol {
  margin: 12px 0 0 0;
  padding: 4px 6px;
  list-style: none;
  counter-reset: toc;
}

.toc-m ol li { counter-increment: toc; padding: 0; }

.toc-m ol a {
  display: block;
  padding: 8px 12px;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--soft-ink);
  text-decoration: none;
  border-radius: 13px;
}

.toc-m ol a::before {
  content: counter(toc) ".";
  color: var(--primary);
  font-weight: 800;
  margin-right: 8px;
}

@media (min-width: 1040px) {
  .layout {
    display: grid;
    grid-template-columns: 216px minmax(0, 700px);
    gap: 56px;
    align-items: start;
    justify-content: center;
  }

  .toc-m { display: none; }

  .rail {
    display: block;
    position: sticky;
    top: 96px;
    padding-top: 60px;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
  }

  .rail .rail-kick {
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--meta);
    padding: 0 12px 10px;
  }

  .rail ol { list-style: none; counter-reset: toc; }
  .rail li { counter-increment: toc; }

  .rail a {
    display: block;
    padding: 7px 12px;
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--meta);
    text-decoration: none;
    border-radius: 9px;
    transition: color 180ms ease, background 180ms ease;
  }

  .rail a::before {
    content: counter(toc);
    display: inline-block;
    width: 20px;
    color: var(--meta);
    font-weight: 800;
  }

  .rail a:hover { color: var(--ink); }

  .rail a.on {
    color: var(--primary);
    background: var(--primary-soft);
  }

  .rail a.on::before { color: var(--primary); }

  /* Section numerals hang in the margin on wide screens. */
  .article h2 .num {
    position: absolute;
    left: -50px;
    top: 33px;
    margin-right: 0;
    vertical-align: baseline;
  }
}

/* ---------- Buttons & pills --------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 0 26px;
  border-radius: 99px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-decoration: none;
  transition: background 180ms ease;
}

.btn:hover { background: var(--primary-d); color: #fff; }

.btn.ghost {
  background: var(--surface);
  color: var(--ink);
  border: 1.5px solid var(--line-2);
}

.btn.ghost:hover { background: var(--surface); border-color: var(--primary); color: var(--primary); }

/* Dark mode lightens --primary, so a white label drops to 3.41:1. Ink on teal instead. */
@media (prefers-color-scheme: dark) {
  .btn, .btn:hover { color: #0E1D19; }
}

.btnrow { display: flex; flex-wrap: wrap; gap: 11px; margin: 22px 0; }

/* Unfilled placeholder — search the folder for "TODO" before publishing. */
.todo {
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: 1px 8px;
  border-radius: 9px;
  font-weight: 800;
  font-size: 0.94em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ---------- Landing ----------------------------------------------------- */

.hero { padding: 62px 0 4px; max-width: 700px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin: 30px 0;
  max-width: 700px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px 22px;
  text-decoration: none;
  display: block;
  transition: border-color 180ms ease, transform 180ms ease;
}

.tile:hover { border-color: var(--primary); transform: translateY(-2px); }

.tile b {
  display: block;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 3px;
}

.tile span {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--meta);
  line-height: 1.5;
}

/* ---------- Footer ------------------------------------------------------ */

/* Legal pages put the footer outside <main> so it is a real contentinfo landmark;
   this re-aligns it with the article column instead of the page. */
.foot-wrap { max-width: 1160px; margin: 0 auto; padding: 0 26px; }

@media (min-width: 1040px) {
  .foot-wrap {
    display: grid;
    grid-template-columns: 216px minmax(0, 700px);
    gap: 56px;
    justify-content: center;
  }
  .foot-wrap .foot { grid-column: 2; }
}

.foot {
  border-top: 1px solid var(--line);
  margin-top: 72px;
  padding: 26px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: center;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--meta);
  max-width: 700px;
}

.foot a { color: var(--meta); text-decoration: none; }
.foot a:hover { color: var(--primary); }
.foot .rights { font-weight: 500; flex-basis: 100%; margin-top: 4px; }

/* ---------- Small screens ----------------------------------------------- */

@media (max-width: 560px) {
  body { font-size: 16px; }
  .doc { padding-left: 22px; padding-right: 22px; }
  .topbar-in { padding: 0 22px; min-height: 62px; }
  .nav a { padding: 8px 10px; font-size: 13px; white-space: nowrap; }
  /* "Delete account" wraps to two lines and doubles the header height here.
     It stays reachable from every footer and from Privacy §10. */
  .nav a.opt-out { display: none; }
  .article h2 { font-size: 21.5px; }
  .legal h2 { margin-top: 42px; }
  .lede { font-size: 17px; }
  .card { padding: 19px 20px; border-radius: 18px; }
  .stamp .dot { display: none; }
}
