/* Family Ledger: the website, set like the app. One stylesheet, no scripts, nothing fetched from elsewhere.
   Colours are the app's own (app/ios/Design/tokens.json): lamp shade green ground with pale ink, and a ledger paper twin. */

@font-face {
  font-family: "Fraunces";
  src: url("/fonts/Fraunces.woff") format("woff");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Fraunces";
  src: url("/fonts/Fraunces-Italic.woff") format("woff");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Josefin Sans";
  src: url("/fonts/JosefinSans.ttf") format("truetype");
  font-weight: 100 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "DM Mono";
  src: url("/fonts/DMMono-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "DM Mono";
  src: url("/fonts/DMMono-Medium.woff") format("woff");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark light;

  --ground: #163220;
  --ground-lift: #1d3f29;
  --ground-corner: #112a1a;
  --ink: #d4e6b8;
  --ink-muted: #d4e6b8b8;
  --ink-soft: #d4e6b8cc;
  --ink-faint: #d4e6b854;
  --wash: #d4e6b81f;
  --grain: #d4e6b8;

  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --label: "Josefin Sans", "Gill Sans", "Trebuchet MS", sans-serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --measure: 62ch;
  --margin: clamp(1.25rem, 6vw, 2rem);
  --grid: 0.5rem;
}

@media (prefers-color-scheme: light) {
  :root {
    --ground: #e6eedc;
    --ground-lift: #f0f2df;
    --ground-corner: #dce4d3;
    --ink: #163220;
    --ink-muted: #163220b8;
    --ink-soft: #163220cc;
    --ink-faint: #1632208c;
    --wash: #1632201a;
    --grain: #163220;
  }
}

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

html {
  background: var(--ground);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 1rem;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-variation-settings: "SOFT" 75, "WONK" 0;
  font-weight: 400;
  font-size: clamp(1.0625rem, 0.98rem + 0.4vw, 1.3125rem);
  line-height: 1.4;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

/* The ground: lamp light from above, and a faint felt. Light and surface, never an illustration. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    url("data:image/svg+xml,%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.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E"),
    radial-gradient(ellipse 140% 70% at 50% -10%, var(--ground-lift) 0%, var(--ground) 55%, var(--ground-corner) 100%);
  background-blend-mode: soft-light, normal;
  background-color: var(--ground);
}
@media (prefers-reduced-transparency: reduce), (prefers-contrast: more) {
  body::before {
    background-image: none;
  }
}

/* ---------- Skip link and focus ---------- */

.skip {
  position: absolute;
  left: var(--margin);
  top: 0;
  transform: translateY(-120%);
  padding: 0.75rem 1rem;
  background: var(--ink);
  color: var(--ground);
  font-family: var(--label);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  z-index: 10;
}
.skip:focus {
  transform: translateY(0.5rem);
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 1px;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: var(--ink-muted);
}
a:hover {
  text-decoration-thickness: 2px;
  text-decoration-color: currentColor;
}

/* ---------- Page frame ---------- */

.frame {
  width: 100%;
  max-width: calc(var(--measure) + 2 * var(--margin));
  margin: 0 auto;
  padding: 0 var(--margin);
}

.masthead {
  padding-top: 1.25rem;
}
.masthead .frame:first-child {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
}

.wordmark {
  font-style: italic;
  font-weight: 500;
  font-size: 1.1875rem;
  font-variation-settings: "SOFT" 50, "WONK" 0;
  text-decoration: none;
  display: inline-block;
  padding: 0.5rem 0;
}
.wordmark:hover {
  text-decoration: underline;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  align-items: center;
}
.nav li {
  display: flex;
  margin: 0;
}
.nav a {
  display: inline-block;
  padding: 0.75rem 0;
  min-height: 44px;
  font-family: var(--label);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-muted);
}
.nav a:hover,
.nav a[aria-current="page"] {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 0.5em;
  text-decoration-thickness: 1px;
}

/* The page header: a thick rule, a thin rule, two points between (tokens rule/thick, rule/thin, rule/gap). */
.double {
  display: block;
  width: 100%;
  height: 5px;
  margin: 0;
  border: 0;
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

main {
  flex: 1 0 auto;
  padding-bottom: 4rem;
}

h1,
h2,
h3 {
  font-weight: 500;
  margin: 0;
  text-wrap: balance;
}

/* Page title (the place): italic voice, tight line */
h1 {
  font-style: italic;
  font-variation-settings: "SOFT" 50, "WONK" 0;
  font-size: clamp(2.25rem, 1.7rem + 2.6vw, 3.5rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin-top: 2rem;
}

h2 {
  font-variation-settings: "SOFT" 50, "WONK" 0;
  font-size: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
  line-height: 1.15;
  margin-top: 3rem;
}
h3 {
  font-style: italic;
  font-variation-settings: "SOFT" 50, "WONK" 0;
  font-size: clamp(1.125rem, 1.05rem + 0.4vw, 1.3125rem);
  line-height: 1.2;
  margin-top: 2rem;
}
h2 + *,
h3 + * {
  margin-top: 0.75rem;
}

p,
ul,
ol,
dl {
  margin: 1rem 0 0;
  max-width: var(--measure);
}
ul,
ol {
  padding-left: 1.4em;
}
li + li {
  margin-top: 0.5rem;
}
li::marker {
  color: var(--ink-muted);
}

.lede {
  margin-top: 2rem;
  max-width: 34ch;
  font-size: clamp(1.1875rem, 1.05rem + 0.8vw, 1.5rem);
  line-height: 1.4;
}

.title-home {
  font-size: clamp(3rem, 2rem + 6vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  margin-top: 2.5rem;
}

/* Small caps labels: Josefin Sans, letterspaced, muted */
.label,
.kicker {
  font-family: var(--label);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 3rem 0 0;
  line-height: 1.4;
}
.label + * {
  margin-top: 0.75rem;
}

.note {
  font-style: italic;
  font-variation-settings: "SOFT" 50, "WONK" 0;
  color: var(--ink-soft);
  font-size: 0.9em;
}

/* Figures and addresses */
code,
.mono {
  font-family: var(--mono);
  font-size: 0.84em;
  font-variation-settings: normal;
  letter-spacing: 0;
}

/* ---------- Leader dots: name ..... figure ---------- */

.ledger {
  margin-top: 1rem;
  padding: 0;
}
.ledger .line {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.55rem 0;
}
.ledger dt {
  order: 1;
  margin: 0;
  font-weight: 500;
  font-variation-settings: "SOFT" 50, "WONK" 0;
  font-size: 1.1em;
}
.ledger dd {
  order: 3;
  margin: 0;
  text-align: right;
  font-style: italic;
  font-variation-settings: "SOFT" 50, "WONK" 0;
}
.ledger .line::after {
  content: "";
  order: 2;
  flex: 1 1 1rem;
  min-width: 1rem;
  height: 0.2em;
  align-self: baseline;
  background: radial-gradient(circle at center, var(--ink-muted) 0.75px, transparent 1.25px) 0 50% / 6px 100% repeat-x;
  opacity: 0.9;
}
@media (max-width: 30rem) {
  .ledger .line {
    flex-wrap: wrap;
    gap: 0 0.5rem;
  }
  .ledger .line::after {
    display: none;
  }
  .ledger dd {
    flex-basis: 100%;
    text-align: left;
    order: 2;
    color: var(--ink-soft);
  }
}

/* The answer rule: a hairline broken by a diamond. Once, on the home page. */
.answer {
  position: relative;
  height: 1px;
  margin: 3rem 0 0;
  border: 0;
  background: linear-gradient(to right, var(--ink) calc(50% - 14px), transparent calc(50% - 14px), transparent calc(50% + 14px), var(--ink) calc(50% + 14px));
  max-width: var(--measure);
}
.answer::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 9px;
  border: 1px solid var(--ink);
  transform: translate(-50%, -50%) rotate(45deg);
}

/* The fist: the Clerk's mark, never beside a number */
.fist {
  display: grid;
  grid-template-columns: 1.75em 1fr;
  align-items: baseline;
  margin-top: 2rem;
  max-width: var(--measure);
}
.fist::before {
  content: "\261E\FE0E";
  font-family: "Zapf Dingbats", "Apple Symbols", "Segoe UI Symbol", sans-serif;
  font-style: normal;
  color: var(--ink);
}
.fist p {
  margin: 0;
}

/* ---------- Draft banner, confirm markers ---------- */

.draft {
  margin-top: 1.5rem;
  max-width: var(--measure);
  padding: 1rem 1.25rem;
  background: var(--wash);
  border-top: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}
.draft strong {
  display: block;
  font-family: var(--label);
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  line-height: 1.5;
}
.draft p {
  margin-top: 0.5rem;
  font-size: 0.9em;
}

.confirm {
  font-family: var(--mono);
  font-size: 0.78em;
  line-height: 1.55;
  padding: 0.05em 0.35em;
  background: var(--wash);
  border-bottom: 1px dashed var(--ink);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  overflow-wrap: anywhere;
}

/* ---------- Contents list and definition tables ---------- */

.toc {
  margin-top: 2rem;
  max-width: var(--measure);
}
.toc ol {
  columns: 2 16rem;
  column-gap: 2rem;
  margin: 0.75rem 0 0;
  padding-left: 1.6em;
  font-size: 0.9em;
}
.toc li {
  break-inside: avoid;
  margin-top: 0.25rem;
}

.facts {
  margin-top: 1rem;
}
.facts dt {
  margin-top: 1.25rem;
  font-weight: 500;
  font-variation-settings: "SOFT" 50, "WONK" 0;
}
.facts dd {
  margin: 0.25rem 0 0;
}

details {
  margin-top: 0;
  max-width: var(--measure);
  border-top: 1px solid var(--ink-faint);
}
details:last-of-type {
  border-bottom: 1px solid var(--ink-faint);
}
summary {
  cursor: pointer;
  list-style: none;
  padding: 0.9rem 2rem 0.9rem 0;
  min-height: 44px;
  position: relative;
  font-weight: 500;
  font-variation-settings: "SOFT" 50, "WONK" 0;
  font-size: 1.1em;
}
summary::-webkit-details-marker {
  display: none;
}
summary::after {
  content: "+";
  position: absolute;
  right: 0.25rem;
  top: 0.8rem;
  font-family: var(--mono);
  color: var(--ink-muted);
}
details[open] > summary::after {
  content: "\2212";
}
details > :not(summary) {
  margin-bottom: 1rem;
}

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

.colophon {
  padding: 0 0 3rem;
  font-size: 0.875rem;
}
.colophon .double {
  margin-bottom: 1.25rem;
  /* Mirrored: the heavy rule sits on the outside of the page frame */
  border-top-width: 1px;
  border-bottom-width: 2px;
}
.colophon p {
  margin: 0.5rem 0 0;
  color: var(--ink-muted);
}
.colophon .nav {
  margin-top: 0.25rem;
}
.colophon .nav a {
  padding: 0.5rem 0;
  min-height: 44px;
}

@media (max-width: 22.5rem) {
  .nav {
    gap: 0 1rem;
  }
}

@media print {
  html,
  body {
    background: #fff;
    color: #000;
  }
  body::before {
    display: none;
  }
  :root {
    --ink: #000;
    --ink-muted: #333;
    --ink-soft: #222;
    --wash: #eee;
  }
  .skip,
  .nav {
    display: none;
  }
}

/* Home: one title only (no masthead wordmark); the body sits centred in the viewport when it fits */
.home .masthead .frame:first-child { justify-content: flex-end; }
.home-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.home-main .title-home { margin-top: 0; }

/* The footer's smaller type shrank its ch-based frame; keep every frame the same width */
.colophon { font-size: inherit; }
.colophon p, .colophon .nav { font-size: 0.875rem; }
/* Home: every paragraph wraps to one column, the width of the opening line */
.home-main > p { max-width: 30rem; }
.home-main > .lede { max-width: 30rem; }
.note-fist { margin-top: 1rem; }
.note-fist { grid-template-columns: auto 1fr; column-gap: 0.55em; align-items: center; }
.note-fist::before { font-size: 1.9em; line-height: 1; transform: translateY(0); }
.home-main.long { padding-top: 3rem; padding-bottom: 4rem; }
.home-main.long .title-home { margin-bottom: 0.5rem; }
.signature { font-style: italic; margin-top: 1.5rem; }
