/* ---------- type ----------
   The app's two faces, subset from app/src/main/res/font in the vendor-ledger
   repo. Both SIL OFL 1.1 — see fonts/OFL.txt. swap, so the policy is readable
   before the faces land. */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque-800.woff2") format("woff2");
  font-weight: 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/ibm-plex-sans-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("fonts/ibm-plex-sans-600.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}

/* ---------- tokens ----------
   Values are the app's, from ui/theme/Color.kt ("Grassfields regalia":
   indigo ndop cloth, harvest green, laterite earth, regalia gold).
   Kotlin name in the comment where one exists. */
:root {
  color-scheme: light dark;

  --paper:        #EDF1F4;  /* CraiePaper / nkaa_ivory */
  --surface:      #FFFFFF;
  --ink:          #16202E;  /* Ink */
  --ink-2:        #49545F;  /* onSurfaceVariant */
  --rule:         #C6CFD8;  /* outlineVariant */
  --rule-strong:  #9AA6B2;  /* outline */
  --rule-faint:   #DDE3EA;  /* surfaceVariant */
  --accent:        #20324F; /* IndigoRoyal — headings, labels, focus */
  --accent-link:   #176B4E; /* VertRecolte — primary actions */
  --accent-wash:   #DCE3EE; /* IndigoSoft — container fill */
  --accent-border: #B9C6DC;
  --warn:          #A23E2A; /* Laterite — error / money-out */
  --warn-wash:     #F2DFDA;
  --warn-border:   #DBB4A9;
  --chip-bg:       #DDE3EA;

  --display: "Bricolage Grotesque", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sans: "IBM Plex Sans", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --rhythm: 1.75rem;
  --measure: 46rem;
}

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

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

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

p { margin: 0 0 1rem; }
strong { font-weight: 600; }

a {
  color: var(--accent-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { text-decoration-thickness: 2px; }

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

code {
  font-family: var(--mono);
  font-size: .86em;
  background: var(--chip-bg);
  color: var(--ink);
  padding: .12em .3em;
  border-radius: 3px;
  overflow-wrap: break-word;
}

/* ---------- skip link ---------- */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
}
.skip:focus-visible {
  left: 0.75rem;
  top: 0.75rem;
  z-index: 5;
  background: var(--surface);
  color: var(--ink);
  padding: .6rem .9rem;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  font-size: .95rem;
}

/* ---------- masthead: the one signature ---------- */
.masthead {
  position: relative;
  border-bottom: 1px solid var(--rule-strong);
  padding-block: clamp(2.25rem, 1.5rem + 3vw, 3.5rem) clamp(1.75rem, 1.25rem + 2vw, 2.5rem);
  overflow: hidden;
}
/* ruled paper — the cahier these businesses keep books in */
.masthead::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(var(--rhythm) - 1px),
    var(--rule-faint) calc(var(--rhythm) - 1px),
    var(--rule-faint) var(--rhythm)
  );
  pointer-events: none;
}
.masthead > .wrap { position: relative; }

/* ---------- language ---------- */
.langs {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: 1.1rem;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.langs a { color: var(--ink-2); text-decoration: none; }
.langs a:hover { color: var(--accent-link); text-decoration: underline; }
.langs [aria-current="page"] { color: var(--accent); }
.langs .sep { color: var(--rule-strong); }

h1 {
  margin: 0 0 1.5rem;
  font-family: var(--display);
  font-size: clamp(2rem, 1.45rem + 2.4vw, 2.9rem);
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -0.022em;
  color: var(--accent);
}

/* meta block, set like the header of a statement */
.meta {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(6.5rem, max-content) 1fr;
  gap: .1rem 1rem;
  font-size: .95rem;
  align-items: baseline;
}
.meta dt {
  font-family: var(--sans);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-2);
  padding-top: .38em;
}
/* tnum — the app's tabularFigures(), so digits sit on a grid */
.meta dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  overflow-wrap: anywhere;
}

/* narrow phones: stack the stub so long values get the full column */
@media (max-width: 26rem) {
  .meta { grid-template-columns: 1fr; gap: 0; }
  .meta dt { padding-top: .85em; }
  .meta dt:first-of-type { padding-top: 0; }
}

/* ---------- main flow ---------- */
main { padding-block: clamp(2rem, 1.5rem + 2vw, 3rem) 1rem; }

.lead {
  font-size: 1.15rem;
  line-height: 1.55;
  margin-bottom: 1.75rem;
}

/* the thesis: reassurance, stated once, up front */
.summary {
  background: var(--accent-wash);
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  padding: 1.15rem 1.25rem;
  margin: 0 0 2.5rem;
}
.summary p { margin: 0; }
.summary .tag {
  display: block;
  font-family: var(--sans);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .5rem;
}

/* the one paragraph with real consequences behind it */
.warning {
  background: var(--warn-wash);
  border: 1px solid var(--warn-border);
  border-radius: 10px;
  padding: 1.15rem 1.25rem;
  margin: 1.5rem 0;
}
.warning p { margin: 0; }
.warning .tag {
  display: block;
  font-family: var(--sans);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--warn);
  margin-bottom: .5rem;
}

/* ---------- contents ---------- */
.toc {
  margin: 0 0 3rem;
  border-top: 1px solid var(--rule-strong);
  border-bottom: 1px solid var(--rule-strong);
  padding-block: 1rem;
}
.toc h2 {
  margin: 0 0 .5rem;
  font-family: var(--sans);
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-2);
  border: 0;
  padding: 0;
}
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0 1.5rem;
}
.toc li { margin: 0; display: flex; }
.toc a {
  display: flex;
  align-items: center;
  width: 100%;
  padding: .5rem 0;
  min-height: 2.75rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  font-size: .95rem;
  line-height: 1.35;
}
.toc a:hover { color: var(--accent-link); }

/* ---------- sections ---------- */
section + section { margin-top: 2.75rem; }

h2 {
  margin: 0 0 1rem;
  padding-top: .9rem;
  border-top: 1px solid var(--rule);
  font-family: var(--display);
  font-size: clamp(1.3rem, 1.15rem + .55vw, 1.55rem);
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--accent);
  scroll-margin-top: 1.25rem;
}
/* h3 stays in the body face, matching the app's titleMedium */
h3 {
  margin: 2rem 0 .75rem;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  scroll-margin-top: 1.25rem;
}

:target > h2,
:target > h3 { box-shadow: -.75rem 0 0 -.6875rem var(--accent); }

ul { margin: 0 0 1rem; padding-left: 1.15rem; }
li { margin: .45rem 0; }

/* the copy already leads each of these with its own negation — surface it */
.negations { list-style: none; padding-left: 0; }
.negations li {
  margin: 0;
  padding: .85rem 0;
  border-bottom: 1px solid var(--rule);
}
.negations li:first-child { border-top: 1px solid var(--rule); }
.negations li:last-child { border-bottom: 0; }
.negations li > strong:first-child {
  display: block;
  font-family: var(--sans);
  font-size: .73rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .2rem;
}

/* ---------- footer ---------- */
footer {
  margin-top: 3rem;
  border-top: 1px solid var(--rule-strong);
  padding-block: 1.5rem 4rem;
  font-size: .95rem;
  color: var(--ink-2);
}

/* ---------- motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ---------- print ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .skip, .toc { display: none; }
  .masthead { border-bottom: 1pt solid #000; }
  .masthead::before { display: none; }
  .summary, .warning { border: 1pt solid #666; background: none; }
  h2, h3 { break-after: avoid; }
  li, p { break-inside: avoid; }
  a { color: #000; }
  main a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .85em; }
}

/* ---------- dark ---------- */
/* Tokens only, and last in the sheet, so no component rule can outrank it. */
@media (prefers-color-scheme: dark) {
  :root {
    --paper:        #0E141C;  /* DarkColors.background */
    --surface:      #161E28;  /* DarkColors.surface */
    --ink:          #E3E7EC;  /* onBackground */
    --ink-2:        #BFC8D4;  /* onSurfaceVariant */
    --rule:         #3C4654;  /* outlineVariant */
    --rule-strong:  #55616F;
    --rule-faint:   #1A2230;
    --accent:        #AEC0E0; /* DarkColors.primary */
    --accent-link:   #4F9E7E; /* VertLight — DarkColors.secondary */
    --accent-wash:   #273A5A; /* secondaryContainer */
    --accent-border: #3A5178;
    --warn:          #E89580; /* DarkColors.error */
    --warn-wash:     #2E1712;
    --warn-border:   #5A2E22;
    --chip-bg:       #202A36;
  }
}
