/* ==========================================================================
   TORCA — identity stylesheet
   One structural idea: the line item. A term on the left, a fact on the
   right, a hairline between rows. Groups hold rows. Nothing is a card.
   ========================================================================== */

/* ---------- Typefaces (self-hosted, OFL) ---------------------------------- */
@font-face {
  font-family: "Literata";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/Literata.woff2") format("woff2");
}
@font-face {
  font-family: "Literata";
  font-style: italic;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/Literata-Italic.woff2") format("woff2");
}
@font-face {
  font-family: "DM Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/DMMono-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "DM Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("fonts/DMMono-Medium.woff2") format("woff2");
}

/* ---------- Tokens -------------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* Palette — five values, each with one job. */
  --paper:    #F5F3EE;  /* the ground everything sits on */
  --sheet:    #FFFFFF;  /* a grouped block: a sheet laid on the paper */
  --ink:      #1C1A17;  /* text, the thread, filled dots */
  --graphite: #6B665E;  /* secondary text, keys, captions, anything pending */
  --madder:   #9B3B2E;  /* one meaning only: "you can act on this" */

  /* Derived, not palette. */
  --hair: rgba(28, 26, 23, 0.14);
  --hair-strong: rgba(28, 26, 23, 0.28);
  --madder-ink: #7E2F24;

  --serif: "Literata", Georgia, "Times New Roman", serif;
  --mono: "DM Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --gutter: clamp(20px, 5vw, 40px);
  --radius: 12px;
  --measure: 34em;
  --content-max: 44rem;
  --shell-max: 72rem;
  --margin-col: 13rem;
  --col-gap: 4rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:    #161412;
    --sheet:    #1F1C19;
    --ink:      #EDE9E1;
    --graphite: #A39D93;
    --madder:   #D67A67;
    --hair: rgba(237, 233, 225, 0.14);
    --hair-strong: rgba(237, 233, 225, 0.30);
    --madder-ink: #E8907F;
  }
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.55;
  font-optical-sizing: auto;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, p, dl, dd, ol, ul, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }
img, svg { max-width: 100%; display: block; }
strong { font-weight: 600; }
em { font-style: italic; }

a {
  color: var(--madder);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  text-decoration-color: color-mix(in srgb, var(--madder) 45%, transparent);
  transition: text-decoration-color 160ms ease;
}
a:hover { text-decoration-color: currentColor; }

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

::selection { background: color-mix(in srgb, var(--madder) 22%, transparent); }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  padding: 0.6rem 0.9rem;
  background: var(--sheet);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.8125rem;
  border-radius: 8px;
  z-index: 10;
}
.skip:focus { top: 0.75rem; }

/* ---------- Shell --------------------------------------------------------- */
.shell {
  max-width: var(--shell-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* ---------- Header: wordmark + thread ------------------------------------- */
.top {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding-block: 1.25rem;
  min-height: 4rem;
}

.wordmark {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.0625rem;
  letter-spacing: 0.22em;
  text-indent: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  line-height: 1;
  padding-block: 0.875rem; /* 45px target */
  white-space: nowrap;
}
.wordmark:hover { text-decoration: none; }

.thread {
  flex: 1 1 auto;
  height: 1px;
  background: var(--ink);
  transform-origin: left center;
  animation: spin-out 900ms cubic-bezier(0.2, 0.7, 0.15, 1) both;
}
@keyframes spin-out {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

.top-link {
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  padding-block: 0.8rem; /* 44px target */
  text-decoration: none;
}
.top-link:hover { text-decoration: underline; }

/* ---------- Sections: margin column + content column ---------------------- */
.section {
  padding-block: clamp(3.5rem, 9vw, 6.5rem);
}
.section + .section { padding-top: 0; }

.section-cap {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--graphite);
  margin-bottom: 1.25rem;
}
.section-note {
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--graphite);
  margin-top: 0;
  margin-bottom: 1.5rem;
  max-width: 14rem;
}
@media (min-width: 900px) {
  .section-note { margin-top: 0.75rem; margin-bottom: 0; }
}

.content { max-width: var(--content-max); }

@media (min-width: 900px) {
  .section {
    display: grid;
    grid-template-columns: var(--margin-col) minmax(0, 1fr);
    column-gap: var(--col-gap);
    align-items: start;
  }
  .section-margin {
    position: sticky;
    top: 2rem;
  }
  .section-cap { margin-bottom: 0.5rem; }
}

/* ---------- Type ---------------------------------------------------------- */
.h1 {
  font-size: clamp(2.5rem, 8.5vw, 4.25rem);
  font-weight: 500;
  line-height: 1.02;
  letter-spacing: -0.015em;
  max-width: 12ch;
}
.h2 {
  font-size: clamp(1.75rem, 4.2vw, 2.375rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.01em;
  max-width: 20ch;
  margin-bottom: 1rem;
  text-wrap: balance; /* no one-word last lines; ignored where unsupported */
}
.h3 {
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.25;
}
.lede {
  font-size: clamp(1.125rem, 2.4vw, 1.375rem);
  line-height: 1.4;
  max-width: var(--measure);
}
.prose { max-width: var(--measure); }
.prose p + p { margin-top: 1em; }

/* The one sentence a section ends on. A short length of thread precedes it —
   the same line the header spins out from the wordmark. */
.after { margin-top: 1.5rem; max-width: var(--measure); }
.after.em { font-size: 1.25rem; line-height: 1.35; margin-top: 1.75rem; }
.after.em::before {
  content: "";
  display: block;
  width: 2.5rem;
  height: 1px;
  background: var(--ink);
  margin-bottom: 1rem;
}

.figure {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.figure small {
  font-size: 0.5em;
  font-weight: 400;
  color: var(--graphite);
  letter-spacing: 0;
  margin-left: 0.15em;
}

.mono {
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
}
.muted { color: var(--graphite); }

/* ---------- Hero ---------------------------------------------------------- */
.hero { padding-top: clamp(3rem, 10vw, 7.5rem); }
.hero .lede { margin-top: 1.5rem; }
.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.75rem;
  margin-top: 2.25rem;
}
.hero-margin { display: none; }
@media (min-width: 900px) {
  .hero-margin { display: block; }
}

/* ---------- Button: the one primary action -------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0 1.4rem;
  background: var(--madder);
  color: #FFFFFF;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.0625rem;
  text-decoration: none;
  border-radius: 10px;
  transition: background-color 160ms ease, transform 160ms ease;
}
.btn:hover { background: var(--madder-ink); text-decoration: none; }
.btn:active { transform: translateY(1px); }
@media (prefers-color-scheme: dark) {
  .btn { color: #161412; }
}

.link-quiet {
  color: var(--ink);
  text-decoration-color: var(--hair-strong);
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
}
.link-quiet:hover { text-decoration-color: var(--ink); }

/* ---------- Group: a sheet holding line items ----------------------------- */
.group {
  background: var(--sheet);
  border-radius: var(--radius);
  overflow: hidden;
}
/* Spacing between a section's text and its first sheet lives here, not inline. */
.content > .group,
.content > .ledger,
.content > .situations { margin-top: 1.75rem; }
.group + .group { margin-top: 1.25rem; }
.group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  padding: 1.25rem 1.25rem 1.1rem;
  flex-wrap: wrap;
}
.group-head .meta { color: var(--graphite); margin-top: 0.25rem; }

/* Line items */
.rows { margin: 0; }
.row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.25rem 1.25rem;
  padding: 0.875rem 1.25rem;
  border-top: 1px solid var(--hair);
  min-height: 2.75rem;
}
.group > .rows:first-child > .row:first-child { border-top: 0; }

.row dt {
  font-family: var(--mono);
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
  color: var(--graphite);
  padding-top: 0.1rem;
}
.row dd { margin: 0; }
.row dd p + p { margin-top: 0.35em; }

@media (min-width: 400px) {
  .row { grid-template-columns: minmax(6rem, 30%) minmax(0, 1fr); }
  .row dt { padding-top: 0.2rem; }
}

/* Bare rows: the same line items, laid on the paper without a sheet.
   Used once, for the situations — they are the reader's, not ours, so they
   are not grouped as one of our blocks. Set a step larger, to be recognised. */
.rows.bare .row {
  padding-inline: 0;
  padding-block: 1rem;
}
.rows.bare .row:last-child { border-bottom: 1px solid var(--hair); }
.rows.bare .row dd {
  font-size: 1.125rem;
  line-height: 1.45;
  max-width: var(--measure);
}
@media (min-width: 400px) {
  .rows.bare .row { grid-template-columns: minmax(6rem, 9.5rem) minmax(0, 1fr); }
  .rows.bare .row dt { padding-top: 0.3rem; }
}

/* An emphasised line item: the one sentence in a group that carries weight */
.row-emph {
  display: block;
  border-top: 1px solid var(--hair);
  padding: 1.25rem 1.25rem 1.35rem;
  font-size: 1.25rem;
  line-height: 1.35;
  font-weight: 500;
}
.row-emph .why {
  display: block;
  font-size: 1rem;
  font-weight: 400;
  color: var(--graphite);
  margin-top: 0.35rem;
}

/* Rows that are links (iOS disclosure rows) */
.row-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.25rem;
  border-top: 1px solid var(--hair);
  min-height: 3.25rem;
  color: var(--ink);
  text-decoration: none;
  transition: background-color 120ms ease;
}
.row-link:first-child { border-top: 0; }
.row-link:hover { background: color-mix(in srgb, var(--ink) 4%, var(--sheet)); text-decoration: none; }
.row-link .k { font-family: var(--mono); font-size: 0.8125rem; color: var(--graphite); }
.row-link .v { display: block; }
.row-link .chev {
  flex: 0 0 auto;
  width: 0.55rem; height: 0.55rem;
  border-right: 1.5px solid var(--graphite);
  border-bottom: 1.5px solid var(--graphite);
  transform: rotate(-45deg);
  margin-right: 0.25rem;
}
.row-link.is-pending { color: var(--graphite); }
.row-link.is-pending .v { text-decoration: none; }

/* Counted list inside a group (the missing 30 percent, the refusals):
   five things, numbered because the count is part of the point. */
.lines { counter-reset: line; }
.lines > li {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: 1rem;
  padding: 0.95rem 1.25rem;
  border-top: 1px solid var(--hair);
  align-items: baseline;
}
.lines > li:first-child { border-top: 0; }
.lines > li::before {
  counter-increment: line;
  content: counter(line, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--graphite);
}
.lines.plain > li { grid-template-columns: 1fr; }
.lines.plain > li::before { content: none; }

/* ---------- Status dots --------------------------------------------------- */
.dot {
  display: inline-block;
  width: 0.55rem; height: 0.55rem;
  border-radius: 50%;
  background: var(--ink);
  vertical-align: 0.05em;
  margin-right: 0.5rem;
}
.dot.hollow {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--graphite);
}

/* ---------- Ledger (proof) — markup is commented out until one real row ---- */
.ledger {
  background: var(--sheet);
  border-radius: var(--radius);
  overflow: hidden;
}
.ledger-head { display: none; }
.entry {
  padding: 1.1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--hair);
}
.entry:first-child { border-top: 0; }
.entry.is-pending { color: var(--graphite); }
.entry.is-pending + .entry.is-pending { border-top-style: dashed; }

.e-date {
  font-family: var(--mono);
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.tag {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--graphite);
}
.e-title {
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.3;
  margin-top: 0.4rem;
  color: inherit;
}
.e-facts { margin-top: 0.75rem; display: grid; gap: 0.35rem; }
.e-facts .f { display: grid; grid-template-columns: minmax(6rem, 30%) minmax(0, 1fr); gap: 1rem; }
.e-facts .k { font-family: var(--mono); font-size: 0.8125rem; color: var(--graphite); }

@media (min-width: 900px) {
  .ledger-head, .entry {
    display: grid;
    grid-template-columns: 7rem minmax(0, 1.7fr) minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, 0.9fr);
    column-gap: 1.5rem;
    align-items: start;
  }
  .ledger-head {
    padding: 0.85rem 1.25rem;
    font-family: var(--mono);
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--graphite);
  }
  .entry { padding: 1.1rem 1.25rem; }
  .e-date { display: block; }
  .e-date .tag { display: block; margin-top: 0.35rem; }
  .e-title { margin-top: 0; font-size: 1.0625rem; }
  .e-facts { display: contents; }
  .e-facts .f { display: block; }
  .e-facts .k {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
  }
}

.ledger-note {
  margin-top: 1rem;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--graphite);
  max-width: 40em;
}

/* ---------- Footer -------------------------------------------------------- */
.foot {
  padding-block: 2.5rem 3rem;
  border-top: 1px solid var(--hair);
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  color: var(--graphite);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 2.5rem;
  justify-content: space-between;
}
.foot a { color: inherit; }

/* ---------- Motion, print ------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .thread { animation: none; }
  .btn, a { transition: none; }
}

@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .btn, .top-link, .skip { display: none; }
  .group, .ledger { background: transparent; border-radius: 0; }
  .row, .row-link, .entry, .lines > li { border-top-color: #bbb; }
  .section { break-inside: avoid; }
  a { color: #000; }
}
