/* ─── Placid · design system ─────────────────────────────────────── */
/* Quiet luxury · Geist + Instrument Serif · cream + forest + clay   */

@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600;700&family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500;600&family=Instrument+Serif:ital@0;1&display=swap");

:root {
  /* surfaces — cream paper, never pure white */
  --bg:           #f7f6f1;
  --paper:        #fbfaf5;        /* cards sit on slightly lighter paper */
  --surface:      #efece2;        /* table heads, tonal areas */
  --surface-2:    #e8e4d5;        /* deeper tonal */
  --border:       #d8d2c0;
  --border-soft:  #e4dfce;
  --border-hair:  #ede9d9;        /* near-invisible rules */

  /* ink — deep forest green base */
  --ink:          #1a2e22;
  --ink-2:        #4d5a51;
  --ink-3:        #8b8f83;
  --ink-4:        #b3b5a8;

  /* accents */
  --forest:       #1a2e22;
  --sage:         #3a5a44;
  --sage-tint:    #e5ebdf;
  --clay:         #b87149;        /* warm rust — the "alert" color */
  --clay-tint:    #f3e4d6;
  --gold:         #b69244;        /* secondary accent */
  --gold-tint:    #efe7cf;

  /* semantic states */
  --pos:          var(--sage);
  --pos-bg:       var(--sage-tint);
  --att:          var(--gold);
  --att-bg:       var(--gold-tint);
  --neg:          var(--clay);
  --neg-bg:       var(--clay-tint);
  --info:         #4a6b7c;
  --info-bg:      #e2e8eb;

  /* type stacks */
  --sans:    "Geist", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --mono:    "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --display: "Instrument Serif", "Cormorant Garamond", "Times New Roman", serif;
  --brand:   "Cinzel", "Trajan Pro", "Cormorant Garamond", "Times New Roman", serif;

  /* spacing scale */
  --gutter: 20px;
  --pad-card: 22px;
  --r-item: 4px;
  --r-card: 6px;
  --r-pill: 999px;

  /* shadows — minimal, paper-like */
  --shadow-1: 0 1px 0 rgba(26,46,34,0.04);
  --shadow-2: 0 1px 2px rgba(26,46,34,0.06), 0 8px 24px rgba(26,46,34,0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "ss02", "cv11";
}

body { min-height: 100vh; }

button { font-family: inherit; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }

/* ── type system ─────────────────────────────────────────────────── */

.t-display {
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1.04;
  letter-spacing: -0.028em;
  color: var(--ink);
  margin: 0;
}
.t-display em { font-style: italic; font-weight: 500; letter-spacing: -0.025em; }

.t-h1 {
  font-family: var(--sans);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.022em;
  line-height: 1.1;
  color: var(--ink);
  margin: 0;
}
.t-h2 {
  font-family: var(--sans);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.018em;
  line-height: 1.2;
  color: var(--ink);
  margin: 0;
}
.t-h3 {
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.012em;
  line-height: 1.25;
  color: var(--ink);
  margin: 0;
}
.t-page {
  font-family: var(--sans);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.024em;
  line-height: 1.12;
  color: var(--ink);
  margin: 0;
}
.t-page em {
  font-style: italic;
  font-weight: 500;
  color: var(--ink);
}

.t-section {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0;
}

.t-body { font-size: 14px; font-weight: 400; color: var(--ink); }
.t-body-lg { font-size: 16px; line-height: 1.55; color: var(--ink); }
.t-muted { color: var(--ink-2); }
.t-label { color: var(--ink-3); }

.tag, .cap {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.mono { font-family: var(--mono); font-feature-settings: "tnum"; }
.tnum { font-variant-numeric: tabular-nums; }
.num {
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum","lnum","ss01";
  letter-spacing: -0.01em;
}
.num-mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── app shell ───────────────────────────────────────────────────── */

.app {
  width: 100%;
  min-height: 100vh;
  background: var(--bg);
}

.app-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  padding: 18px 32px 0;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
}
.app-body {
  padding: 32px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  max-width: 1480px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .app-header { padding: 14px 18px 0; }
  .app-body { padding: 20px; gap: 20px; }
}

/* ── tabs ────────────────────────────────────────────────────────── */
.tabbar {
  display: flex;
  gap: 2px;
  margin-top: 18px;
  border-bottom: 0;
}
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-3);
  cursor: pointer;
  border-bottom: 1.5px solid transparent;
  margin-bottom: -1px;
  font-family: var(--sans);
  letter-spacing: -0.005em;
  transition: color 140ms ease;
}
.tab:hover { color: var(--ink-2); }
.tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ── card ────────────────────────────────────────────────────────── */
.card {
  background: var(--paper);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-card);
  overflow: hidden;
}
.card.tonal { background: var(--surface); }
.card.flush { padding: 0; }
.card .card-head {
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--border-hair);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.card .card-head .t-section { color: var(--ink-3); }
.card .card-body { padding: 22px; }

/* hero card — the editorial moment */
.hero-card {
  background: var(--paper);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-card);
  padding: 36px 36px 32px;
  position: relative;
}
.hero-card.dark {
  background: var(--forest);
  color: var(--paper);
  border-color: var(--forest);
}
.hero-card.dark .t-section { color: rgba(247,246,241,0.6); }
.hero-card.dark .t-muted { color: rgba(247,246,241,0.7); }

/* metric tile */
.tile {
  background: var(--paper);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-card);
  padding: 22px 24px 20px;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
  text-align: left;
  font-family: var(--sans);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 172px;
}
.tile:hover {
  border-color: var(--border);
  background: color-mix(in srgb, var(--paper) 70%, var(--surface) 30%);
}
.tile-num {
  font-family: var(--sans);
  font-size: 38px;
  font-weight: 500;
  letter-spacing: -0.025em;
  color: var(--ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tile-sub {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.5;
}
.tile-foot {
  margin-top: auto;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── chip ────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 8px;
  border-radius: var(--r-pill);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--border-soft);
  white-space: nowrap;
}
.chip.pos  { background: var(--pos-bg);  color: #2d4933; border-color: transparent; }
.chip.neg  { background: var(--neg-bg);  color: #7a4528; border-color: transparent; }
.chip.att  { background: var(--att-bg);  color: #76612d; border-color: transparent; }
.chip.info { background: var(--info-bg); color: #2d4350; border-color: transparent; }
.chip.solid {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.chip .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.7; }

/* ── buttons ─────────────────────────────────────────────────────── */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
  font: 500 13.5px/1 var(--sans);
  letter-spacing: -0.005em;
  height: 36px;
  padding: 0 16px;
  border-radius: var(--r-item);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 140ms ease, border-color 140ms ease;
}
.btn:hover { background: var(--surface); border-color: var(--border); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 12.5px; }
.btn.lg { height: 44px; padding: 0 22px; font-size: 14px; }
.btn.primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn.primary:hover { background: #243d2e; border-color: #243d2e; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface); }
.btn.link {
  border: 0;
  background: transparent;
  padding: 0;
  height: auto;
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}
.btn.link:hover { text-decoration-color: var(--ink); }

/* ── inputs ──────────────────────────────────────────────────────── */
.input {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--paper);
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-item);
  font: 400 14px/1 var(--sans);
  color: var(--ink);
  width: 100%;
  transition: border-color 140ms ease;
}
.input:focus { outline: 0; border-color: var(--ink); }
.input::placeholder { color: var(--ink-3); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ── slider ──────────────────────────────────────────────────────── */
.slider {
  appearance: none;
  width: 100%;
  height: 32px;
  background: transparent;
  cursor: pointer;
}
.slider::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--border);
  border-radius: 1px;
}
.slider::-moz-range-track {
  height: 2px;
  background: var(--border);
  border-radius: 1px;
}
.slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--ink);
  margin-top: -7px;
  cursor: grab;
  transition: transform 120ms ease;
}
.slider::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.15); }
.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--ink);
  cursor: grab;
}

/* ── tables ──────────────────────────────────────────────────────── */
table.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.t th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
  white-space: nowrap;
}
table.t td {
  padding: 14px;
  border-bottom: 1px solid var(--border-hair);
  vertical-align: middle;
}
table.t tr:last-child td { border-bottom: 0; }
table.t tr.row-clickable { cursor: pointer; }
table.t tr.row-clickable:hover { background: color-mix(in srgb, var(--surface) 50%, transparent); }
table.t td.r, table.t th.r { text-align: right; }
table.t td.num { font-family: var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -0.005em; }

/* ── bars ────────────────────────────────────────────────────────── */
.bar-track {
  height: 6px;
  background: var(--surface);
  border-radius: 3px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--ink);
  transition: width 360ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bar-fill.pos { background: var(--sage); }
.bar-fill.neg { background: var(--clay); }
.bar-fill.att { background: var(--gold); }
.bar-fill.info { background: var(--info); }

/* ── log ─────────────────────────────────────────────────────────── */
.log { display: flex; flex-direction: column; }
.log-row {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 20px;
  align-items: baseline;
  padding: 14px 22px;
  border-top: 1px solid var(--border-hair);
  font-size: 13.5px;
}
.log-row:first-child { border-top: 0; }
.log-row .ts {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
}
.log-row .body { color: var(--ink); }
.log-row .delta {
  font-family: var(--sans);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
  color: var(--ink-2);
}

/* ── modal ───────────────────────────────────────────────────────── */
.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(26,46,34,0.34);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  z-index: 100;
  animation: fade-in 160ms ease both;
}
.modal {
  background: var(--paper);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-card);
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow: auto;
  box-shadow: var(--shadow-2);
  animation: pop 200ms cubic-bezier(0.2,0.8,0.2,1) both;
}
.modal-head {
  padding: 22px 24px 14px;
  border-bottom: 1px solid var(--border-hair);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.modal-body { padding: 22px 24px; }
.modal-foot {
  padding: 16px 24px;
  border-top: 1px solid var(--border-hair);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface);
}

@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.985) } to { opacity: 1; transform: none } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: none } }

.fade-in { animation: fade-in 240ms ease both; }
.rise-in { animation: rise 460ms cubic-bezier(0.2,0.8,0.2,1) both; }

/* stagger helper */
.stagger > * { animation: rise 520ms cubic-bezier(0.2,0.8,0.2,1) both; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 180ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; }

/* ── utility ─────────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 6px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--ink-2); }
.label { color: var(--ink-3); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gutter); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gutter); }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gutter); }
.grid-5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--gutter); }

@media (max-width: 980px) {
  .grid-3, .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: minmax(0, 1fr); }
}

/* heatmap cell */
.heat-cell {
  aspect-ratio: 1 / 1;
  border-radius: 2px;
  background: var(--surface);
}

/* divider with label */
.section-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 8px 0 4px;
}
.section-divider::before,
.section-divider::after {
  content: "";
  height: 1px;
  background: var(--border-soft);
  flex: 1;
}
.section-divider > .t-section { color: var(--ink-3); }

/* dotted underline pulled-quote style for editorial moments */
.quoted {
  font-family: var(--sans);
  font-style: normal;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  letter-spacing: -0.005em;
}
