/* Time in the Market — rolling-period returns for stocks against bonds.
 * Shared Money-app tokens: green for stocks, copper for the comparison. */
:root {
  --paper: #f4f1e8; --card: #fbf9f3; --ink: #1d2420; --ink-2: #4c5650;
  --ink-3: #87908a; --rule: rgba(29,36,32,.18); --rule-soft: rgba(29,36,32,.09);
  --accent: #2f5d46;
  --accent-2: #b0662a;
  --serif: "Fraunces", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --wash: rgba(29,36,32,.05);
  --side-w: 330px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-padding-top: calc(var(--appnav-h, 0px) + 20px); }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  max-width: 1600px;
  margin: 0 auto;
}
.side {
  position: sticky;
  top: var(--appnav-h, 0px);
  height: calc(100vh - var(--appnav-h, 0px));
  height: calc(100dvh - var(--appnav-h, 0px));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  border-right: 1px solid var(--rule-soft);
}
.side-inner { padding: 1.25rem 1.2rem 1.5rem 1.35rem; }

.kicker, .side-h, .fig-k {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.wordmark {
  margin-top: 0.3rem;
  font-family: var(--serif);
  font-weight: 600;
  font-size: 2.3rem;
  line-height: 1.02;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 96;
}
.wordmark em { font-style: italic; color: var(--accent); }
.lede { margin-top: 0.7rem; font-size: 15px; color: var(--ink-2); }
.lede b { color: var(--ink); font-weight: 600; }

.ctl { margin-top: 1rem; }
.seg { display: flex; margin-top: 0.35rem; border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; background: var(--card); }
.seg button { flex: 1; font-size: 0.82rem; font-weight: 500; padding: 0.38rem 0.4rem; border: 0; background: transparent; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button:hover { background: var(--wash); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.hz { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 3px; margin-top: 0.35rem; }
.hz button {
  font-family: var(--mono); font-size: 0.8rem; padding: 0.32rem 0; border: 1px solid var(--rule);
  border-radius: 4px; background: var(--card); cursor: pointer;
}
.hz button:hover { background: var(--wash); }
.hz button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

.readout { margin-top: 1.1rem; padding-top: 0.8rem; border-top: 1px solid var(--rule-soft); }
.readout p { font-size: 15px; margin-top: 0.35rem; color: var(--ink-2); }
.readout b { color: var(--ink); font-weight: 600; }
.readout .big { font-family: var(--serif); font-size: 1.55rem; font-weight: 600; color: var(--ink); line-height: 1.15; margin-top: 0.25rem; }
.readout .big em { font-style: normal; color: var(--accent); }
.stat-grid { display: grid; grid-template-columns: auto 1fr 1fr; gap: 0.15rem 0.6rem; margin-top: 0.6rem; font-size: 0.85rem; }
.stat-grid .h { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.stat-grid .n { font-family: var(--mono); text-align: right; }
.stat-grid .s { color: var(--accent); }
.stat-grid .c { color: var(--accent-2); }
.stat-grid .yr { display: block; font-size: 0.7rem; color: var(--ink-3); }

.note { margin-top: 1rem; font-size: 0.86rem; color: var(--ink-2); background: var(--card); border: 1px solid var(--rule-soft); border-radius: 6px; padding: 0.55rem 0.7rem; }
.note b { color: var(--ink); }
.side-foot { margin-top: 1rem; font-size: 0.85rem; color: var(--ink-3); }

/* ---------- charts ---------- */
.main { min-width: 0; padding: 0.9rem 1.1rem 1rem; display: flex; flex-direction: column; gap: 0.8rem; }
.fig { background: var(--card); border: 1px solid var(--rule-soft); border-radius: 8px; padding: 0.7rem 0.8rem 0.5rem; min-width: 0; }
.fig-cap { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.7rem; font-size: 0.95rem; font-weight: 600; }
.fig-cap .fig-k { font-weight: 500; }
.legend { margin-left: auto; display: flex; gap: 0.9rem; font-size: 0.8rem; font-weight: 400; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 0.3rem; vertical-align: -1px; }
.plot { position: relative; width: 100%; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.fig-funnel .plot { height: clamp(400px, calc(58vh - 50px), 640px); }
.fig-strip .plot { height: clamp(220px, calc(30vh - 40px), 380px); }
.plot svg.fill { height: 100%; }
.strip-read { font-size: 0.85rem; color: var(--ink-2); min-height: 1.4em; padding: 0.2rem 0 0.1rem; }

svg text { font-family: var(--mono); font-size: 11px; fill: var(--ink-3); }
svg .ax-zero { stroke: var(--ink); stroke-width: 1; }
svg .grid { stroke: var(--rule-soft); stroke-width: 1; }
svg .col-hit { fill: transparent; cursor: pointer; }
svg .col-sel { fill: rgba(47,93,70,.08); }
svg .col-hov { fill: var(--wash); }
svg .xl { fill: var(--ink-2); font-size: 12px; }
svg .xl.sel { fill: var(--accent); font-weight: 500; }
svg .row-l { fill: var(--ink-2); font-family: var(--sans); font-size: 12px; }
svg .pct { font-size: 12px; fill: var(--ink); }
svg .ann { font-size: 10.5px; }
svg .strip:focus { outline: none; }
svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- tooltip ---------- */
.tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--ink); color: var(--paper);
  font-size: 0.82rem; line-height: 1.45;
  padding: 0.45rem 0.6rem; border-radius: 6px; max-width: 280px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.tip b { font-weight: 600; }
.tip .m { font-family: var(--mono); }
.tip .s { color: #9fd0b5; }
.tip .c { color: #f0b47e; }

/* ---------- prose ---------- */
.prose { max-width: 760px; margin: 0 auto; padding: 1.6rem 1.2rem 0.4rem; }
.prose h2 { font-family: var(--serif); font-weight: 600; font-size: 1.45rem; margin: 0.6rem 0 0.5rem; }
.prose p, .prose li { font-size: 16px; color: var(--ink-2); }
.prose p + p { margin-top: 0.7rem; }
.prose b { color: var(--ink); }
.prose ul { padding-left: 1.2rem; display: grid; gap: 0.45rem; }
.prose table { border-collapse: collapse; margin: 0.8rem 0; font-size: 0.9rem; width: 100%; }
.prose th, .prose td { text-align: right; padding: 0.25rem 0.5rem; border-bottom: 1px solid var(--rule-soft); font-family: var(--mono); font-size: 0.85rem; }
.prose th:first-child, .prose td:first-child { text-align: left; }
.prose th { font-weight: 500; color: var(--ink-3); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
.table-wrap { overflow-x: auto; }
.sources { padding-bottom: 3rem; }
.disclaimer { margin-top: 0.9rem; font-style: italic; }
.changelog { list-style: none; padding-left: 0 !important; }
.changelog time { font-family: var(--mono); font-size: 0.8rem; color: var(--ink-3); margin-right: 0.6rem; }
code { font-family: var(--mono); font-size: 0.88em; }

/* ---------- narrow ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; overflow: visible; border-right: 0; border-bottom: 1px solid var(--rule-soft); }
  .side-inner { padding: 1rem 16px 1.1rem; }
  .main { padding: 0.8rem 10px 1rem; }
  .fig { padding: 0.6rem 0.5rem 0.4rem; }
  .fig-funnel .plot { height: 470px; }
  .fig-strip .plot { height: 290px; }
  .legend { margin-left: 0; width: 100%; }
  .prose { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: no-preference) {
  .seg button, .hz button { transition: background-color .12s; }
}
