/* The Investing Historian: Dusk, for the web. One dark look on purpose. */
@font-face { font-family: 'Unbounded'; font-style: normal; font-weight: 200 900; font-display: swap;
  src: url(/assets/fonts/unbounded-latin.woff2) format('woff2'); }
@font-face { font-family: 'Geist'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(/assets/fonts/geist-latin.woff2) format('woff2'); }

:root {
  color-scheme: dark;
  --ink: #0E100F; --ink-2: #15171A; --ink-3: #1C1F22;
  --night: #17162B; --dusk: #2E2B57; --violet: #4A4589; --lavender: #8C7CEB; --haze: #B7AEEE;
  --moss: #3A6552; --meadow: #6F9A5C; --fern: #A6C98A; --sage: #B8C8AF; --mist: #DFE4E1;
  --butter: #F2E6A0; --slate: #8E9C98;
  --line: rgba(223, 228, 225, .12); --line-2: rgba(223, 228, 225, .22);
  --display: 'Unbounded', 'Arial Black', system-ui, sans-serif;
  --text: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gutter: 16px; --max: 1120px; --r: 22px;
  --ease: cubic-bezier(.16, 1, .3, 1);
}
@media (min-width: 720px) { :root { --gutter: 32px; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--ink); color: var(--mist);
  font: 500 17px/1.6 var(--text); overflow-x: hidden;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
img, svg { max-width: 100%; display: block; }
a { color: inherit; text-decoration-color: rgba(223, 228, 225, .35); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--mist); }
:focus-visible { outline: 2px solid var(--mist); outline-offset: 3px; border-radius: 6px; }
::selection { background: var(--violet); color: var(--mist); }

.wrap { width: 100%; max-width: calc(var(--max) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--mist); color: var(--ink); padding: 8px 14px; border-radius: 12px; z-index: 10; font-weight: 700; }
.skip:focus { left: 8px; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- type ---------- */
h1, h2, h3, .display { font-family: var(--display); font-weight: 800; letter-spacing: -.03em; line-height: 1.08; margin: 0; }
h1 { font-size: clamp(34px, 7vw, 68px); }
h2 { font-size: clamp(26px, 4.4vw, 42px); }
h3 { font-size: clamp(18px, 2.2vw, 22px); font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
p { margin: 0 0 1em; }
.lede { font-size: clamp(18px, 2.2vw, 21px); color: var(--mist); max-width: 40em; line-height: 1.55; }
.label {
  font: 700 12px/1.3 var(--text); text-transform: uppercase; letter-spacing: .2em; color: var(--sage);
}
.muted { color: var(--sage); }
.small { font-size: 14px; line-height: 1.55; }
.num { font-family: var(--display); font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

/* ---------- header / footer ---------- */
.site-head { position: relative; z-index: 3; }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; padding-top: 18px; padding-bottom: 18px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 700 15px/1.05 var(--display); letter-spacing: -.02em; }
.brand img { width: 26px; height: 26px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin: 0 -10px; }
.nav a { text-decoration: none; font: 600 14px/1 var(--text); color: var(--sage); padding: 10px; border-radius: 999px; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--mist); }
.nav a[aria-current="page"] { background: rgba(223, 228, 225, .07); }

.site-foot { border-top: 1px solid var(--line); margin-top: 96px; padding: 40px 0 48px; color: var(--sage); }
.foot-grid { display: grid; gap: 28px; }
@media (min-width: 760px) { .foot-grid { grid-template-columns: 1.4fr 1fr 1fr; } }
.site-foot ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.site-foot a { text-decoration: none; color: var(--mist); }
.site-foot a:hover { text-decoration: underline; }
.foot-note { font-size: 14px; line-height: 1.6; max-width: 34em; }
.foot-legal { margin-top: 28px; font-size: 13px; }

/* ---------- buttons, chips, inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px;
  border-radius: 999px; border: 1.5px solid var(--line-2); background: transparent; color: var(--mist);
  font: 700 15px/1 var(--text); text-decoration: none; cursor: pointer;
  transition: transform .2s var(--ease), background-color .2s var(--ease), border-color .2s var(--ease);
}
.btn:hover { border-color: var(--mist); }
.btn:active { transform: scale(.97); }
.btn-mist { background: var(--mist); color: var(--ink); border-color: var(--mist); }
.btn-mist:hover { background: #fff; }
.btn-butter { background: var(--butter); color: var(--ink); border-color: var(--butter); }
.btn-butter:hover { background: #f6edb8; border-color: #f6edb8; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.field { display: grid; gap: 8px; min-width: 0; }
.field > span, .field legend { font: 700 12px/1.3 var(--text); text-transform: uppercase; letter-spacing: .18em; color: var(--sage); padding: 0; }
fieldset.field { border: 0; margin: 0; padding: 0; }
.input, select.input {
  width: 100%; min-height: 50px; padding: 0 14px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--ink-2); color: var(--mist); font: 600 17px/1 var(--text); font-variant-numeric: tabular-nums;
  appearance: none; -webkit-appearance: none;
}
select.input {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23B8C8AF' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
.input:hover { border-color: var(--line-2); }
.input:focus { outline: none; border-color: var(--mist); }
.money { position: relative; }
.money::before { content: '$'; position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--sage); font: 600 17px/1 var(--text); pointer-events: none; }
.money .input { padding-left: 28px; }
.suffix { position: relative; }
.suffix::after { content: attr(data-suffix); position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--sage); font: 600 15px/1 var(--text); pointer-events: none; }
.suffix .input { padding-right: 56px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.chip span {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 22px;
  border: 1.5px solid var(--line); color: var(--sage); font: 600 15px/1 var(--text); user-select: none;
  transition: border-color .2s var(--ease), color .2s var(--ease), background-color .2s var(--ease);
}
.chip span i { width: 10px; height: 10px; border-radius: 50%; background: currentColor; opacity: .35; }
.chip input:checked + span { color: var(--mist); border-color: var(--line-2); background: rgba(223, 228, 225, .06); }
.chip input:checked + span i { opacity: 1; }
.chip input:focus-visible + span { outline: 2px solid var(--mist); outline-offset: 2px; }
.chip:hover span { border-color: var(--line-2); }

.seg { display: inline-flex; padding: 4px; border-radius: 999px; border: 1.5px solid var(--line); gap: 2px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: inline-flex; align-items: center; min-height: 38px; padding: 0 16px; border-radius: 999px; color: var(--sage); font: 600 14px/1 var(--text); }
.seg input:checked + span { background: var(--mist); color: var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--mist); outline-offset: 2px; }

/* ---------- sections ---------- */
section { position: relative; }
.section { padding-top: 88px; }
.section-head { display: grid; gap: 14px; margin-bottom: 32px; max-width: 46em; }
.grid-3 { display: grid; gap: 16px; }
@media (min-width: 760px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.card {
  display: grid; gap: 10px; align-content: start; padding: 24px; border-radius: var(--r); background: var(--ink-2);
  border: 1px solid var(--line); text-decoration: none; transition: border-color .25s var(--ease), transform .25s var(--ease);
}
a.card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.card p { margin: 0; color: var(--sage); font-size: 15px; }
.card .go { font: 700 14px/1 var(--text); color: var(--mist); margin-top: 6px; }

/* ---------- hero with landscape ---------- */
.hero { position: relative; overflow: hidden; isolation: isolate; }
.hero .sky { position: absolute; inset: 0; z-index: -2; background: linear-gradient(180deg, var(--ink) 0%, var(--night) 26%, var(--dusk) 58%, #3d3a73 72%, var(--ink) 100%); }
.hero .sky::after {
  content: ''; position: absolute; inset: 0; opacity: .5;
  background-image: radial-gradient(rgba(183, 174, 238, .14) 1px, transparent 1.4px);
  background-size: 6px 6px;
  -webkit-mask-image: linear-gradient(180deg, transparent 10%, #000 85%); mask-image: linear-gradient(180deg, transparent 10%, #000 85%);
}
.hero .land { position: absolute; left: 0; right: 0; bottom: -2px; z-index: -1; height: clamp(170px, 30vw, 400px); }
.hero .land svg { width: 100%; height: 100%; }
.hero-inner { padding: 72px 0 calc(clamp(170px, 30vw, 400px) - 20px); display: grid; gap: 22px; max-width: 46em; }
.hero h1 { max-width: 13em; }
.hero .lede { color: var(--mist); }
.hero-note { color: var(--sage); font-size: 14px; }

/* ---------- episodes ---------- */
.episodes { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .episodes { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .episodes { grid-template-columns: repeat(5, 1fr); } }
.ep { display: grid; gap: 12px; align-content: start; text-decoration: none; }
.ep .door {
  position: relative; aspect-ratio: 4 / 5; border-radius: 999px 999px 18px 18px; overflow: hidden;
  border: 2px solid rgba(223, 228, 225, .55); background: linear-gradient(180deg, var(--night), var(--dusk) 75%, #3d3a73);
}
@media (max-width: 639px) { .ep .door { aspect-ratio: 16 / 10; border-radius: 160px 160px 18px 18px; } }
.ep .door svg { position: absolute; inset: auto 0 0 0; width: 100%; height: 72%; }
.ep .soon { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); white-space: nowrap; }
.ep h3 { font-size: 16px; line-height: 1.25; }
.ep .fact { color: var(--sage); font-size: 14px; line-height: 1.5; margin: 0; }
.ep .go { font: 700 14px/1 var(--text); }
a.ep:hover .door { border-color: var(--mist); }

/* ---------- facts strip ---------- */
.facts { display: grid; gap: 1px; background: var(--line); border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); }
@media (min-width: 760px) { .facts { grid-template-columns: repeat(3, 1fr); } }
.facts > div { background: var(--ink); padding: 24px; display: grid; gap: 6px; align-content: start; }
.facts .num { font-size: clamp(30px, 4vw, 44px); line-height: 1; }

/* ---------- calculator layout ---------- */
.page-head { padding: 40px 0 28px; display: grid; gap: 14px; max-width: 48em; }
.calc { display: grid; gap: 24px; }
@media (min-width: 1000px) { .calc { grid-template-columns: 340px minmax(0, 1fr); align-items: start; } .calc .controls { position: sticky; top: 16px; } }
.controls { display: grid; gap: 18px; padding: 22px; border-radius: var(--r); background: var(--ink-2); border: 1px solid var(--line); }
.controls .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.results { display: grid; gap: 22px; min-width: 0; }
.sentence { font: 600 clamp(19px, 2.4vw, 24px)/1.45 var(--text); margin: 0; max-width: 34em; }
.sentence b { font-weight: 800; }
.big { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .big { grid-template-columns: 1fr 1fr; } }
.big > div { display: grid; gap: 6px; align-content: start; }
.big .num { font-size: clamp(36px, 6vw, 60px); line-height: 1; }
.big .accent { color: var(--butter); }
.stats { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; grid-template-columns: 1fr 1fr; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stats > div { background: var(--ink); padding: 16px; display: grid; gap: 6px; align-content: start; min-width: 0; }
.stats .num { font-size: clamp(20px, 2.6vw, 26px); line-height: 1.05; }
.stats .sub { font-size: 13px; color: var(--sage); line-height: 1.4; }
.gain { color: var(--fern); }
.loss { color: var(--haze); }

.panel { padding: 20px; border-radius: var(--r); background: var(--ink-2); border: 1px solid var(--line); display: grid; gap: 14px; min-width: 0; }
@media (max-width: 559px) { .panel { padding: 16px 12px; } }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--sage); margin: 0; padding: 0; list-style: none; }
.legend i { display: inline-block; width: 18px; height: 4px; border-radius: 4px; vertical-align: middle; margin-right: 6px; }
.legend i.dash { background-image: linear-gradient(90deg, currentColor 40%, transparent 40%); background-size: 8px 4px; }

.chart { position: relative; width: 100%; min-width: 0; outline-offset: 4px; border-radius: 8px; touch-action: pan-y; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .tick { fill: var(--sage); font: 600 11px/1 var(--text); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.chart .endval { font: 800 13px/1 var(--display); letter-spacing: -.02em; }
.chart .endname { fill: var(--sage); font: 600 10px/1 var(--text); text-transform: uppercase; letter-spacing: .12em; }
.tip {
  position: absolute; pointer-events: none; z-index: 2; min-width: 150px; max-width: 240px; padding: 10px 12px; border-radius: 14px;
  background: rgba(14, 16, 15, .92); border: 1px solid var(--line-2); font-size: 13px; line-height: 1.35;
}
.tip-h { font: 700 11px/1.3 var(--text); text-transform: uppercase; letter-spacing: .16em; color: var(--sage); margin-bottom: 6px; }
.tip-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; }
.tip-row i { width: 8px; height: 8px; border-radius: 50%; }
.tip-row b { font-variant-numeric: tabular-nums; }
.chart-note { font-size: 13px; color: var(--sage); margin: 0; }

.disclosure { font-size: 14px; line-height: 1.6; color: var(--sage); border-left: 2px solid var(--line-2); padding: 2px 0 2px 16px; margin: 0; }
.disclosure strong { color: var(--mist); font-weight: 700; }
.source { font: 600 11px/1.6 var(--text); text-transform: uppercase; letter-spacing: .16em; color: var(--sage); margin: 0; }
.source a { color: var(--sage); }
.status { min-height: 1.4em; font-size: 14px; color: var(--sage); }

/* tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 14px; border: 1px solid var(--line); max-width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { font: 700 11px/1.3 var(--text); text-transform: uppercase; letter-spacing: .1em; color: var(--sage); background: var(--ink-2); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
td .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; }
details { border-radius: 14px; }
details > summary { cursor: pointer; font-weight: 700; padding: 12px 0; list-style: none; display: inline-flex; align-items: center; gap: 10px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: '+'; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line-2); font: 700 15px/1 var(--text); }
details[open] > summary::before { content: '\2212'; }
.scroll-table { max-height: 460px; overflow: auto; }

/* prose pages */
.prose { max-width: 46em; }
.prose h2 { font-size: clamp(22px, 3.2vw, 30px); margin: 56px 0 16px; }
.prose h3 { margin: 32px 0 10px; }
.prose p, .prose li { color: #cfd6d2; }
.prose ul { padding-left: 1.2em; margin: 0 0 1em; }
.prose li { margin-bottom: .4em; }
.prose strong { color: var(--mist); }
.defs { display: grid; gap: 1px; background: var(--line); border-radius: 18px; overflow: hidden; border: 1px solid var(--line); margin: 16px 0 24px; }
.defs > div { background: var(--ink); padding: 16px 18px; display: grid; gap: 4px; }
@media (min-width: 700px) { .defs > div { grid-template-columns: 200px 1fr; gap: 20px; } }
.defs dt { font-weight: 700; color: var(--mist); }
.defs dd { margin: 0; color: #cfd6d2; font-size: 15px; }
.defs code { font-size: 13px; color: var(--sage); }
.toc { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; padding: 0; list-style: none; }
.toc a { display: inline-flex; min-height: 40px; align-items: center; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--line); text-decoration: none; font-weight: 600; font-size: 14px; color: var(--sage); }
.toc a:hover { color: var(--mist); border-color: var(--line-2); }

/* soft entrance, only when motion is welcome */
@media (prefers-reduced-motion: no-preference) {
  .rise { animation: rise .9s var(--ease) both; }
  .rise-2 { animation-delay: .08s; } .rise-3 { animation-delay: .16s; } .rise-4 { animation-delay: .24s; }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
  .fade-swap { transition: opacity .3s var(--ease); }
}
.calm-404 { padding: 64px 0 24px; display: grid; gap: 18px; max-width: 40em; }
