/*
 * One stylesheet for all three pages.
 *
 * Shared rather than inlined per page, because the palette below is copied from the app's
 * `Theme.kt` and three copies of it would drift. Same origin, no CDN, no font file: the type is
 * whatever the reader's system already has, which is also the only stack that costs no request.
 *
 * ## The palette is the app's, one for one
 *
 * Light and dark follow the system setting, the way the app's two themes do. Every value here is
 * lifted from `app/src/main/kotlin/com/latchat/ui/theme/Theme.kt` so the site and the app are
 * recognisably one product.
 *
 * ## The visual idea is the latch
 *
 * The mark is two fans of waves facing each other with the emitter between them, which is the app
 * icon's geometry unchanged. Two halves that engage: that is what a latch is, and it is also what
 * this app does, phone to phone with nothing in the middle. The motif repeats as the bullet on
 * the limits list, reduced to the two facing arcs.
 */

:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --bg-sink: #eff3f8;      /* chatBottom */
  --surface-alt: #f6f8fb;
  --text: #14161a;
  --text-muted: #59626e;
  /*
   * The app's `textTertiary` is #8A939F, and it is 3.11 : 1 on white. That is fine in the app,
   * where it labels a caption beside a bubble somebody is already reading, and it is not fine
   * here, where it is running text at 0.92rem that a stranger reads once. Darkened until it
   * clears 4.5 : 1 on both the page and the cards: 5.02 and 4.72.
   */
  --text-dim: #67707c;
  --accent: #1f5fd0;       /* primary */
  --line: #c6ccd4;         /* outline */
  --line-soft: #e0e4e9;    /* outlineVariant */
  --warn: #9a6100;         /* warning */

  --measure: 34rem;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --bg-sink: #0b0e11;
    --surface-alt: #1e242c;
    --text: #eceff3;
    --text-muted: #9aa4b0;
    /* Same deviation, same reason. 5.65 on the page, 4.71 on a card. */
    --text-dim: #848e9b;
    --accent: #5b9bff;
    --line: #39424d;
    --line-soft: #262c34;
    --warn: #e0a33e;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------------------------------------------------------------- language switch, no script */

/*
 * A checkbox and a label, which is the whole mechanism: unchecked shows the page's default
 * language, checked shows the other one.
 *
 * It is CSS rather than JavaScript because `/j` may not have a script at all: the invitation rides
 * in the URL fragment precisely so that no server ever sees it, and the promise that the page
 * cannot read it is worth more when there is nothing on the page that could. What `/` does with
 * five lines of script, this does with a sibling selector, and `/j` keeps the stricter rule.
 *
 * ## Which language is the default is a property of the page
 *
 * `/` and `/privacy` default to Indonesian in the markup and a script ticks the box when the
 * browser asks for anything else, so what a reader actually sees is their own language. The
 * default there is only what shows when that script does not run.
 *
 * **`/j` has no script and therefore no way to ask**, so its default is what every reader gets
 * until they press the switch. It carries `en-first` on its wrapper and opens in English: the
 * reader of that page was sent a link by somebody who may be anywhere, and an unread instruction
 * about not sending the numbers with the link is the one failure on this site that costs
 * something. English is the wider net when there is nothing to detect with.
 *
 * The pairs below are written out rather than expressed as an inversion, because a rule that
 * silently swaps two languages is worth being able to read straight down the page.
 */
/*
 * The box is hidden from the eye and NOT from the keyboard. `hidden`, which is what this used
 * first, takes the input out of the tab order, and a `<label>` is not focusable either - so the
 * only control on the page would have been reachable with a mouse and with nothing else. Clipped
 * rather than hidden, it still takes focus and still toggles on Space, and the focus ring is drawn
 * on the label below.
 */
#lang {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* Unchecked: the page's default language, and a switch offering the other one. */
.page:not(.en-first) .lang-en,
.page.en-first .lang-id { display: none; }

.page:not(.en-first) .switch-when-en,
.page.en-first .switch-when-id { display: none; }

/* Checked: every one of those swaps. */
#lang:checked ~ .page:not(.en-first) .lang-id,
#lang:checked ~ .page.en-first .lang-en { display: none; }

#lang:checked ~ .page:not(.en-first) .lang-en,
#lang:checked ~ .page.en-first .lang-id { display: revert; }

#lang:checked ~ .page:not(.en-first) .switch-when-id,
#lang:checked ~ .page.en-first .switch-when-en { display: none; }

#lang:checked ~ .page:not(.en-first) .switch-when-en,
#lang:checked ~ .page.en-first .switch-when-id { display: inline; }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.1rem 1.25rem 0;
}

.bar .wordmark {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 620;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.bar .wordmark svg { width: 22px; height: 22px; color: var(--accent); }

.switch {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--text-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.8rem;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.switch:hover { color: var(--text); border-color: var(--text-dim); }
#lang:focus-visible ~ * .switch { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------------------------------ layout */

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

section { margin: 3.25rem 0 0; }

h1 {
  font-size: 2.6rem;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 0.4rem;
  font-weight: 660;
}

h2 {
  font-size: 1.28rem;
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 0 0 0.5rem;
  font-weight: 620;
}

h3 { font-size: 1rem; margin: 0 0 0.2rem; font-weight: 620; }

p { margin: 0.7rem 0; }

a { color: var(--accent); }

.eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0 0 0.9rem;
  font-weight: 600;
}

.lede { font-size: 1.12rem; color: var(--text-muted); margin: 0.5rem 0 0; }
.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); font-size: 0.92rem; }

/* -------------------------------------------------------------------------------------- hero */

.hero {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-sink) 100%);
  padding: 2.5rem 0 3rem;
  border-bottom: 1px solid var(--line-soft);
}

.hero .inner { max-width: var(--measure); margin: 0 auto; padding: 0 1.25rem; }

.hero .mark { width: 76px; height: 76px; color: var(--accent); margin: 0 0 1.4rem; display: block; }

.tagline {
  font-size: 1.45rem;
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-weight: 560;
  color: var(--accent);
  margin: 0 0 0.9rem;
}

.chip {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--text-muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  margin-top: 1.4rem;
}

/* ------------------------------------------------------------------------------------- cards */

.claim {
  border: 1px solid var(--line-soft);
  background: var(--surface-alt);
  border-radius: var(--radius);
  padding: 1.3rem 1.35rem;
  margin: 1rem 0;
}

.claim h2 { margin-bottom: 0.35rem; }
.claim p:last-child { margin-bottom: 0; }

.because {
  color: var(--text-muted);
  border-left: 2px solid var(--accent);
  padding-left: 0.9rem;
  margin-top: 0.9rem;
}

/* ------------------------------------------------------------------------------------- steps */

.steps { counter-reset: step; margin: 1rem 0 0; padding: 0; list-style: none; }

.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  gap: 0.9rem;
  padding: 0.95rem 0;
  border-top: 1px solid var(--line-soft);
}

.steps li::before {
  content: "0" counter(step);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 640;
  font-size: 0.95rem;
  padding-top: 0.08rem;
}

.steps p { margin: 0.2rem 0 0; color: var(--text-muted); }

/* ------------------------------------------------------------------------------------ limits */

.limits { list-style: none; margin: 1rem 0 0; padding: 0; }

.limits li {
  position: relative;
  padding: 0 0 0 1.4rem;
  margin: 0.65rem 0;
  color: var(--text-muted);
}

/* The mark again, reduced to the two facing arcs. */
.limits li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 8px;
  height: 8px;
  border-left: 2px solid var(--warn);
  border-right: 2px solid var(--warn);
  border-radius: 3px;
}

.limits strong { color: var(--text); font-weight: 600; }

/* ------------------------------------------------------------------------------------- rules */

.rule { border: 0; height: 1px; background: var(--line-soft); margin: 3.25rem 0 0; }

/* ------------------------------------------------------------------------------------- notes */

.note {
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--accent);
  background: var(--surface-alt);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.2rem;
  color: var(--text-muted);
}

.note strong { color: var(--text); }

/* ------------------------------------------------------------------------------------ footer */

footer {
  border-top: 1px solid var(--line-soft);
  margin-top: 3.5rem;
  padding: 1.6rem 1.25rem 3rem;
}

footer .inner {
  max-width: var(--measure);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.4rem;
  align-items: baseline;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* -------------------------------------------------------------------------- the policy pages */

.policy h2 { margin-top: 2.4rem; }
.policy h2:first-of-type { margin-top: 1rem; }

.policy table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.95rem; }

.policy th, .policy td {
  text-align: left;
  vertical-align: top;
  padding: 0.55rem 0.7rem 0.55rem 0;
  border-bottom: 1px solid var(--line-soft);
}

.policy th { color: var(--text-dim); font-weight: 600; }
.policy td { color: var(--text-muted); }

.policy ul { padding-left: 1.1rem; color: var(--text-muted); }
.policy li { margin: 0.4rem 0; }

@media (max-width: 420px) {
  h1 { font-size: 2.1rem; }
  .tagline { font-size: 1.25rem; }
  body { font-size: 16px; }
}

/* ---------------------------------------------------- no inline style attributes on any page */

/*
 * These five rules exist so that no element on this site carries a `style=` attribute. An inline
 * style attribute needs `style-src 'unsafe-inline'`, and the point of a static site for a privacy
 * product is that its Content-Security-Policy can be read in one line and believed.
 */
.note p:first-child { margin-top: 0; }
.note p:last-child { margin-bottom: 0; }
main > section:first-of-type { margin-top: 2.2rem; }
main.policy h1, main.invite h1 { font-size: 2.1rem; }
.closing { margin-top: 1.6rem; }

/*
 * `/how` is the one page with a third level of heading: every section there is a claim, then how it
 * works, then what a reader can check, then what it does not establish. Those subheads follow
 * paragraphs rather than opening a section, so unlike an h3 in a list they need air above them.
 */
.policy h3 { margin-top: 1.7rem; }
