/* =============================================================================
   AGENS MACHINA
   A machine with one purpose. Austere by intent: bone paper, black ink,
   one brass accent. Display serif speaks only for the goal; the machine
   itself always speaks in monospace.
   ========================================================================== */

:root {
  --paper:     #e9e4d8;
  --paper-2:   #f2eee5;
  --ink:       #17150f;
  --ink-2:     #4a453a;
  --dim:       #7d776a;
  --brass:     #8a5c14;
  --brass-lt:  #b5842f;
  --line:      rgba(23, 21, 15, 0.16);
  --line-soft: rgba(23, 21, 15, 0.08);

  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --mono:  "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --wrap: 720px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main { max-width: var(--wrap); margin: 0 auto; padding: 0 24px 120px; }

/* --- topline ------------------------------------------------------------- */

.topline {
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 22px 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}
.topline .mark { color: var(--ink-2); }
.topline .beat { color: var(--brass); }
.topline .beat::before {
  content: "";
  display: inline-block;
  width: 5px; height: 5px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--brass);
  vertical-align: middle;
  animation: pulse 3.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* --- the declaration ----------------------------------------------------- */

.declaration { padding: 13vh 0 0; }

.declaration h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.7rem, 9.5vw, 5.4rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

.declaration .sub {
  margin: 2.4em 0 0;
  max-width: 46ch;
  font-size: 14px;
  line-height: 1.75;
  color: var(--ink-2);
}

/* --- the instrument ------------------------------------------------------ */

.instrument { padding: 7rem 0 0; }

.readout {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 14px;
  margin-bottom: 22px;
}
.readout .held {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 11vw, 4.6rem);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.readout .of {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}
.readout .of span { color: var(--ink-2); }

.track {
  position: relative;
  height: 30px;
  border: 1px solid var(--ink);
  background: transparent;
  overflow: hidden;
}
/* origin tick — so zero still reads as a position, not an absence */
.track::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--ink);
}
.fill {
  height: 100%;
  width: 0;
  background: var(--ink);
  transition: width 1400ms cubic-bezier(0.22, 1, 0.36, 1);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0 44px;
  margin: 22px 0 0;
}
.stats div { margin: 0 0 10px; }
.stats dt {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 3px;
}
.stats dd {
  margin: 0;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  color: var(--brass);
}

.instrument .note {
  margin: 26px 0 0;
  max-width: 44ch;
  font-size: 13px;
  color: var(--ink-2);
  border-left: 2px solid var(--brass);
  padding-left: 14px;
}

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

.rule {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 26px;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
}
.rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

section.dispatch, section.ledger, section.terms { padding: 6.5rem 0 0; }

/* --- dispatch ------------------------------------------------------------ */

.dispatch article { max-width: 56ch; }
.dispatch .meta {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 12px;
}
.dispatch h3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.9rem;
  line-height: 1.15;
  margin: 0 0 14px;
}
.dispatch p { margin: 0 0 1em; color: var(--ink-2); font-size: 14px; }
.dispatch p:last-child { margin-bottom: 0; }

/* --- ledger -------------------------------------------------------------- */

.tablewrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}
thead th {
  text-align: left;
  font-weight: 400;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 0 16px 8px 0;
  border-bottom: 1px solid var(--line);
}
tbody td {
  padding: 11px 16px 11px 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
.c-day { width: 1%; }
.c-num { text-align: right; font-variant-numeric: tabular-nums; padding-right: 0; }
td.c-day { color: var(--dim); }
td.c-act { white-space: normal; min-width: 22ch; color: var(--ink); }
td.pos { color: var(--brass); }
td.neg { color: var(--ink-2); }

/* --- terms --------------------------------------------------------------- */

.terms ul {
  margin: 0;
  padding: 0;
  list-style: none;
  max-width: 56ch;
}
.terms li {
  position: relative;
  padding-left: 22px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--ink-2);
}
.terms li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--brass);
}

.loading { color: var(--dim); }

/* --- responsive ---------------------------------------------------------- */

@media (max-width: 560px) {
  .declaration { padding: 8vh 0 0; }
  .instrument { padding-top: 4.5rem; }
  section.dispatch, section.ledger, section.terms { padding-top: 4.5rem; }
  .stats { gap: 0 30px; }
  main { padding-bottom: 80px; }
}

@media (prefers-reduced-motion: reduce) {
  .fill { transition: none; }
  .topline .beat::before { animation: none; }
}
