/*
 * Slippage — the paper ledger.
 *
 * The product is *paper* trading, so the page is paper: a ruled ledger sheet, ink-black
 * type, serif headings, monospace figures, hairline rules instead of cards. There is no
 * icon rail and no sidebar; the tape runs across the sheet the way a market tape does.
 *
 * "Ink" is the same ledger after dark. Both are defined as variables on :root so every
 * rule below is written once.
 */

:root {
  --paper: #f2efe7;
  --sheet: #faf8f3;
  --ink: #17181b;
  --ink-soft: #4a4d55;
  --ink-faint: #82858e;
  --rule: #d9d3c5;
  --rule-hard: #b3ab99;
  --pos: #14713f;
  --neg: #a81f2c;
  /* The brand green is #C1FF72. At full strength it is unreadable on cream, so paper
     uses a deepened version of the same hue and ink uses the green itself. */
  --mark: #52801c;
  --wash: rgba(23, 24, 27, 0.035);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sheet-width: 1140px;
}

:root[data-theme='ink'] {
  --paper: #0c0d10;
  --sheet: #121317;
  --ink: #e9e5db;
  --ink-soft: #a9a89f;
  --ink-faint: #6f7178;
  --rule: #262830;
  --rule-hard: #3b3e49;
  --pos: #4bbd7f;
  --neg: #e4606d;
  --mark: #c1ff72;
  --wash: rgba(233, 229, 219, 0.04);
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ------------------------------- masthead -------------------------------- */

.masthead {
  border-bottom: 3px double var(--rule-hard);
  background: var(--sheet);
}
.masthead-inner {
  max-width: var(--sheet-width);
  margin: 0 auto;
  padding: 22px 24px 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.wordmark { display: block; }
.wordmark img { display: block; height: 62px; width: auto; margin-left: -4px; }
/* Exactly one of the two lockups is ever in the layout. */
.wordmark .on-ink { display: none; }
:root[data-theme='ink'] .wordmark .on-paper { display: none; }
:root[data-theme='ink'] .wordmark .on-ink { display: block; }
.tagline {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  max-width: 46ch;
}
.tagline strong { color: var(--ink); font-weight: 600; }

.masthead-right { display: flex; align-items: center; gap: 12px; }
.edition { text-align: right; margin-right: 4px; }
.edition-line {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.edition-sub { display: block; font-size: 11px; color: var(--ink-faint); font-family: var(--mono); }

.ghost-btn {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 7px 13px;
  border: 1px solid var(--rule-hard);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  border-radius: 0;
}
.ghost-btn:hover { background: var(--wash); }
.ghost-btn.solid { background: var(--ink); color: var(--sheet); border-color: var(--ink); }
.ghost-btn.solid:hover { opacity: 0.86; }

/* --------------------------------- tabs ---------------------------------- */

.tabs {
  max-width: var(--sheet-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 26px;
  border-bottom: 1px solid var(--rule);
  overflow-x: auto;
}
.tabs a {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding: 13px 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--ink); }

/* -------------------------------- sheet ---------------------------------- */

.sheet {
  max-width: var(--sheet-width);
  margin: 0 auto;
  padding: 4px 24px 56px;
}

.block { margin-top: 34px; }
.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 7px;
}
.block-head h2 {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.block-note { font-size: 12px; color: var(--ink-faint); max-width: 62ch; margin: 8px 0 0; }

/* --------------------------------- rail ---------------------------------- */
/* Season totals, set as a ledger footing: figures divided by rules, not boxed in cards. */

.footing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  border-top: 3px double var(--rule-hard);
  border-bottom: 3px double var(--rule-hard);
  margin-top: 26px;
}
/* Figures sit clear of their divider rule on both sides; the outer two stay flush with
   the sheet margin so the block's edges line up with the tables above and below it. */
.footing div { padding: 14px 20px; border-right: 1px solid var(--rule); }
.footing div:first-child { padding-left: 0; }
.footing div:last-child { border-right: 0; padding-right: 0; }
.footing dt {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.footing dd {
  margin: 5px 0 0;
  font-family: var(--mono);
  font-size: 26px;
  letter-spacing: -0.03em;
}
.footing small { display: block; font-family: var(--sans); font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }

/* -------------------------------- controls -------------------------------- */

.filters { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.choices { display: flex; gap: 2px; }
.choices button {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  padding: 4px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--ink-faint);
  cursor: pointer;
}
.choices button:hover { color: var(--ink); }
.choices button.active { color: var(--ink); border-bottom-color: var(--mark); }

.find {
  border: 0;
  border-bottom: 1px solid var(--rule-hard);
  background: transparent;
  padding: 5px 2px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  min-width: 190px;
}
.find:focus { outline: none; border-bottom-color: var(--ink); }
.find::placeholder { color: var(--ink-faint); }

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

table { width: 100%; border-collapse: collapse; }
thead th {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  font-weight: 400;
  text-align: left;
  padding: 9px 10px 7px 0;
  border-bottom: 1px solid var(--rule-hard);
  white-space: nowrap;
}
tbody td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--rule); vertical-align: baseline; }
tbody tr:hover { background: var(--wash); }
/* Right-aligned figures sit flush with the sheet's right edge, so the gutter that keeps
   them off the previous column has to come from the left. Without it a narrow viewport
   runs one header straight into the next. */
/* A plain column following a right-aligned one has no gutter of its own — its text sits
   flush against the figure before it, which is how "REALIZED" and "LEADER" ran together
   into one word. */
.fig + td,
.fig + th { padding-left: 18px; }

td.fig, th.fig {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-right: 0;
  padding-left: 18px;
}
td.line {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-faint);
  width: 34px;
  padding-right: 14px;
}
td.line.lead { color: var(--mark); }

.name { font-weight: 600; }
.name .handle { font-family: var(--mono); font-size: 13px; font-weight: 500; }
.sub { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }
.unit { color: var(--ink-faint); font-size: 11px; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.flat { color: var(--ink-faint); }

.chip {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid var(--rule-hard);
  padding: 1px 5px;
  color: var(--ink-faint);
}
.chip.graduated { color: var(--pos); border-color: var(--pos); }

/* split bar for buy/sell pressure — a figure, drawn */
.split { display: inline-flex; width: 84px; height: 7px; border: 1px solid var(--rule-hard); }
.split i { display: block; height: 100%; }
.split i.b { background: var(--pos); }
.split i.s { background: var(--neg); opacity: 0.75; }

/* ---------------------------------- tape list ------------------------------ */

.entries { border-top: 1px solid var(--rule-hard); }
.entry {
  display: grid;
  grid-template-columns: 88px 1fr auto;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  align-items: baseline;
}
.entry-time { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }
.entry-text { min-width: 0; }
.entry-fig { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.entry.fresh { animation: ink-in 1.6s ease-out; }
@keyframes ink-in { from { background: rgba(180, 128, 31, 0.16); } to { background: transparent; } }

/* ---------------------------------- atlas ---------------------------------- */

.atlas { position: relative; margin-top: 18px; }
#map { width: 100%; display: block; }
#map path.land { fill: var(--wash); stroke: var(--rule-hard); stroke-width: 0.5; }
#map path.frame { fill: none; stroke: var(--rule); }
#map circle.mark {
  fill: var(--mark);
  fill-opacity: 0.42;
  stroke: var(--ink);
  stroke-width: 0.7;
  cursor: pointer;
}
#map circle.mark:hover { fill-opacity: 0.75; }
/* A country carrying a net loss is drawn in the loss colour, not merely smaller. */
#map circle.mark.down { fill: var(--neg); }
#map text.pin {
  font-family: var(--mono);
  font-size: 8.5px;
  fill: var(--ink);
  text-anchor: middle;
  pointer-events: none;
}

.atlas-tip {
  position: absolute;
  pointer-events: none;
  background: var(--sheet);
  border: 1px solid var(--ink);
  padding: 8px 11px;
  font-size: 12px;
  min-width: 160px;
  transform: translate(-50%, calc(-100% - 12px));
  z-index: 4;
}
.atlas-tip .tip-head { font-weight: 600; margin-bottom: 4px; }
.atlas-tip .tip-row { display: flex; justify-content: space-between; gap: 16px; font-family: var(--mono); font-size: 11px; color: var(--ink-soft); }

.key { display: flex; align-items: center; gap: 16px; font-family: var(--mono); font-size: 10.5px; color: var(--ink-faint); padding-top: 10px; }
.key svg { overflow: visible; }
.key circle { fill: var(--mark); fill-opacity: 0.42; stroke: var(--ink); stroke-width: 0.7; }

/* --------------------------------- statement ------------------------------- */

.statement-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  border-bottom: 3px double var(--rule-hard);
  padding-bottom: 12px;
  margin-top: 28px;
}
.statement-head h2 { font-family: var(--serif); font-size: 30px; margin: 0; font-weight: 600; }
.statement-figure { margin-left: auto; text-align: right; font-family: var(--mono); font-size: 28px; }

/* ----------------------------------- misc ---------------------------------- */

.aside {
  border-left: 2px solid var(--rule-hard);
  padding: 2px 0 2px 14px;
  margin: 16px 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  max-width: 74ch;
}
.hollow { padding: 26px 0; color: var(--ink-faint); font-family: var(--mono); font-size: 12px; }

.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 40px; }
.primer { gap: 32px; margin-top: 18px; }
.primer p { margin: 0; font-size: 13px; color: var(--ink-soft); }
.primer b { color: var(--ink); }

.colophon {
  max-width: var(--sheet-width);
  margin: 0 auto;
  padding: 20px 24px 48px;
  border-top: 1px solid var(--rule);
  color: var(--ink-faint);
  font-size: 11.5px;
}
.colophon p { margin: 6px 0; max-width: 78ch; }
.colophon a { text-decoration: underline; text-underline-offset: 3px; }

@media (max-width: 720px) {
  .wordmark img { height: 38px; }
  .masthead-inner { padding: 16px; }
  .sheet, .tabs, .colophon { padding-left: 16px; padding-right: 16px; }
  .entry { grid-template-columns: 1fr auto; }
  .entry-time { display: none; }
  thead th:nth-child(n + 5), tbody td:nth-child(n + 5) { display: none; }
}
