/* ==========================================================================
   bpleon.com — stylesheet
   Clean finance / editorial aesthetic. Light + dark, fully responsive.
   Edit colors in :root below if you want a different palette.
   ========================================================================== */

:root {
  /* Palette — light */
  --bg:        #faf8f4;   /* warm off-white */
  --bg-soft:   #f3f0e9;
  --ink:       #1a1a1a;   /* near-black body text */
  --ink-soft:  #4a4a48;   /* secondary text */
  --muted:     #8a8a86;   /* tertiary / metadata */
  --rule:      #e6e2d8;   /* hairlines / borders */
  --accent:    #2a4365;   /* deep navy */
  --accent-2:  #7a3b2e;   /* burgundy, used sparingly */

  /* Type */
  --serif: "Newsreader", "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans:  "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Layout */
  --maxw-prose: 38rem;   /* ~640px reading width */
  --maxw-wide:  64rem;   /* project grid pages */
  --gutter:     1.25rem;

  /* Motion */
  --ease: cubic-bezier(.2,.7,.3,1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:       #0f0f10;
    --bg-soft:  #17171a;
    --ink:      #efeae0;
    --ink-soft: #b8b3a8;
    --muted:    #7a766e;
    --rule:     #2a2a2c;
    --accent:   #8fb3e8;
    --accent-2: #d49b8a;
  }
}

/* Reset-ish ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; height: auto; display: block; }
a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 3px;
  transition: text-decoration-color .2s var(--ease), color .2s var(--ease);
}
a:hover { text-decoration-color: var(--accent); color: var(--accent); }
ul, ol { padding-left: 1.1rem; }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

/* Typography ---------------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0 0 .6em;
  line-height: 1.15;
}
h1 { font-size: clamp(2rem, 4.2vw + 1rem, 3.4rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 1.8vw + .8rem, 2rem); margin-top: 2.2em; }
h3 { font-size: 1.25rem; margin-top: 1.8em; }
p  { margin: 0 0 1.1em; }

.eyebrow {
  font-family: var(--sans);
  font-size: .78rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1rem;
}
.lede {
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.5;
  color: var(--ink-soft);
  font-style: italic;
}
.muted { color: var(--muted); }
.small { font-size: .9rem; }

/* Ticker tape (TradingView, mounted via script.js) ------------------------- */
.ticker-wrap {
  border-bottom: 1px solid var(--rule);
  background: var(--bg-soft);
  min-height: 46px;
}
.ticker-wrap .tradingview-widget-container { width: 100%; }
.ticker-wrap iframe { display: block; }

/* Toolkit & Reports list --------------------------------------------------- */
.tool-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 3rem;
  border-top: 1px solid var(--rule);
  counter-reset: toolnum;
}
.tool-list li {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem;
  align-items: center;
}
.tool-list h3 {
  margin: 0 0 .25em;
  font-size: 1.15rem;
  font-family: var(--serif);
}
.tool-list p { margin: 0 0 .35em; color: var(--ink-soft); }
.tool-meta {
  color: var(--muted);
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}
.tool-actions { display: flex; gap: .5rem; flex-shrink: 0; }
@media (max-width: 600px) {
  .tool-list li { grid-template-columns: 1fr; gap: .75rem; }
}

/* Featured tool card (toolkit, links to dcf) ------------------------------- */
.featured-tool {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem;
  align-items: center;
  padding: 1.75rem 2rem;
  background: var(--accent);
  color: #fff;
  border-radius: 14px;
  margin: 1.25rem 0 2.5rem;
}
.featured-tool h3 {
  color: #fff;
  margin: 0 0 .35em;
  font-size: 1.4rem;
  font-family: var(--serif);
}
.featured-tool p { color: rgba(255,255,255,0.86); margin: 0; }
.featured-tool .btn {
  background: #fff;
  color: var(--accent);
  border-color: #fff;
  flex-shrink: 0;
}
.featured-tool .btn:hover {
  background: var(--bg-soft);
  color: var(--accent);
  border-color: var(--bg-soft);
}
@media (max-width: 600px) { .featured-tool { grid-template-columns: 1fr; } }

/* Now page ----------------------------------------------------------------- */
.now-block {
  padding: 1.75rem 2rem;
  background: var(--bg-soft);
  border-radius: 12px;
  margin: 1.5rem 0 2.5rem;
}
.now-block p:last-child { margin-bottom: 0; }
.now-date {
  color: var(--muted);
  font-size: .8rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin: 0 0 .85rem;
  font-variant-numeric: tabular-nums;
}
.now-archive { list-style: none; padding: 0; margin: 1.5rem 0 2.5rem; border-top: 1px solid var(--rule); }
.now-archive li { padding: 1.25rem 0; border-bottom: 1px solid var(--rule); }
.now-archive li p:last-child { margin-bottom: 0; }

/* DCF calculator ---------------------------------------------------------- */
.dcf-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.4fr);
  gap: 2rem;
  margin: 1.5rem 0 2rem;
  align-items: start;
}
@media (max-width: 760px) {
  .dcf-grid { grid-template-columns: 1fr; gap: 1.25rem; }
}
.dcf-form {
  background: var(--bg-soft);
  padding: 1.5rem;
  border-radius: 12px;
}
.dcf-form fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 1.25rem;
}
.dcf-form fieldset:last-child { margin-bottom: 0; }
.dcf-form legend {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 500;
  margin: 0 0 .75rem;
  padding: 0;
  letter-spacing: -0.01em;
}
.dcf-form label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 .55rem;
  font-size: .9rem;
}
.dcf-form label > span:first-child {
  color: var(--ink-soft);
  flex: 1;
}
.dcf-form input[type=number] {
  width: 8rem;
  padding: .4rem .6rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.dcf-form input[type=number]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.dcf-output {
  padding: 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--bg);
}
.dcf-output h3 {
  margin: 0 0 .35em;
  font-size: .95rem;
  font-family: var(--sans);
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  font-weight: 500;
}
.dcf-output h3:not(:first-of-type) { margin-top: 2rem; }
.dcf-headline {
  font-family: var(--serif);
  font-size: clamp(2.2rem, 5vw + 1rem, 3rem);
  font-weight: 600;
  margin: 0 0 .15em;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--accent);
}
.dcf-sub {
  color: var(--muted);
  font-size: .9rem;
  font-variant-numeric: tabular-nums;
  margin: 0 0 1rem;
}
.dcf-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: .9rem;
}
.dcf-table th,
.dcf-table td {
  padding: .45rem .5rem;
  text-align: right;
  border-bottom: 1px solid var(--rule);
}
.dcf-table th:first-child,
.dcf-table td:first-child {
  text-align: left;
  color: var(--ink-soft);
}
.dcf-table thead th {
  font-weight: 600;
  color: var(--ink);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  border-bottom-width: 2px;
}
.dcf-table tfoot td {
  font-weight: 600;
  border-bottom: 0;
  padding-top: .65rem;
  border-top: 1px solid var(--rule);
}
.dcf-table tfoot tr:first-child td { border-top: 2px solid var(--rule); }

/* DCF sensitivity heatmap */
.dcf-sens {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: .85rem;
  margin-top: 1rem;
  border: 1px solid var(--rule);
}
.dcf-sens th,
.dcf-sens td {
  padding: .5rem .55rem;
  text-align: center;
  border: 1px solid var(--rule);
}
.dcf-sens th {
  background: var(--bg-soft);
  color: var(--ink-soft);
  font-weight: 500;
  font-size: .8rem;
  letter-spacing: .04em;
}
.dcf-sens td.center-cell {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.dcf-sens td.up   { background: rgba(42, 67, 101, 0.07); color: var(--ink); }
.dcf-sens td.down { background: rgba(122, 59, 46, 0.06); color: var(--ink); }

.dcf-method {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--ink-soft);
  font-size: .92rem;
}
.dcf-method h2 { font-size: 1.1rem; margin: 0 0 .75em; }
.dcf-method code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  background: var(--bg-soft);
  padding: .1em .3em;
  border-radius: 3px;
}

/* Markets page ------------------------------------------------------------- */
.markets-section {
  margin: 2.5rem 0 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.markets-section:first-of-type { border-top: 0; padding-top: 0; }
.markets-section h2 {
  margin-top: 0;
  margin-bottom: .25em;
  font-size: 1.4rem;
}
.markets-section .markets-note {
  color: var(--muted);
  font-size: .9rem;
  margin: 0 0 1.25rem;
}
.markets-widget {
  border: 1px solid var(--rule);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg);
}

/* Header / nav -------------------------------------------------------------- */
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  max-width: var(--maxw-wide);
  margin: 0 auto;
  padding: 1.6rem var(--gutter) 1rem;
  border-bottom: 1px solid var(--rule);
}
.brand {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand:hover { color: var(--ink); text-decoration: none; }
.site-nav {
  display: flex;
  gap: 1.4rem;
  font-size: .95rem;
}
.site-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  position: relative;
}
.site-nav a:hover { color: var(--accent); }
.site-nav a[aria-current="page"] {
  color: var(--ink);
}
.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -.35em;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

/* Layout containers --------------------------------------------------------- */
main {
  max-width: var(--maxw-wide);
  margin: 0 auto;
  padding: 2.5rem var(--gutter) 4rem;
}
main.prose {
  max-width: var(--maxw-prose);
}
main.prose.wide {
  max-width: var(--maxw-wide);
}
main.prose.center {
  text-align: center;
}

.page-head { margin-bottom: 2.5rem; }

/* Hero ---------------------------------------------------------------------- */
.hero {
  padding: 1.5rem 0 2rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.5rem;
}
.hero h1 { max-width: 22ch; }
.hero .lede { max-width: 56ch; }
.hero-cta {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

/* Buttons ------------------------------------------------------------------- */
.btn {
  display: inline-block;
  padding: .65rem 1.05rem;
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
  border-radius: 999px;
  font-size: .95rem;
  font-weight: 500;
  border: 1px solid var(--ink);
  transition: transform .15s var(--ease), background .2s var(--ease), color .2s var(--ease);
}
.btn:hover { transform: translateY(-1px); background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule);
}
.btn-ghost:hover { background: var(--bg-soft); color: var(--ink); border-color: var(--ink); }

/* Sections ------------------------------------------------------------------ */
.section { margin: 3rem 0; }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--rule);
}
.section-head h2 { margin: 0; font-size: 1.25rem; }
.more {
  font-size: .9rem;
  color: var(--muted);
  text-decoration: none;
}
.more:hover { color: var(--accent); }

/* Project list (homepage teasers) ------------------------------------------- */
.project-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.project h3 { margin: 0 0 .25em; font-size: 1.15rem; }
.project h3 a { text-decoration: none; }
.project-meta { color: var(--muted); font-size: .85rem; margin: 0 0 .5rem; }
.project p:last-child { color: var(--ink-soft); }

/* Project cards (full page) ------------------------------------------------- */
.project-card {
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--rule);
}
.project-card:last-of-type { border-bottom: 0; }
.project-card h2 { margin: 0 0 .25em; }
.project-card h2 a { text-decoration: none; }

/* Writing list (homepage teasers) ------------------------------------------- */
.writing-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.writing-list li {
  border-bottom: 1px solid var(--rule);
}
.writing-list li:last-child { border-bottom: 0; }
.writing-list a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: .9rem 0;
  text-decoration: none;
}
.writing-list .post-title {
  font-family: var(--serif);
  font-size: 1.05rem;
}
.writing-list .post-date { color: var(--muted); font-size: .85rem; white-space: nowrap; }

/* Writing index (full page) ------------------------------------------------- */
.writing-index {
  list-style: none;
  padding: 0;
  margin: 2rem 0 3rem;
}
.writing-index li { margin: 0; padding: 0; border-bottom: 1px solid var(--rule); }
.writing-index li:last-child { border-bottom: 0; }
.writing-index .post {
  display: block;
  padding: 1.5rem 0;
  text-decoration: none;
  color: inherit;
}
.writing-index .post time {
  display: block;
  font-size: .8rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .35rem;
}
.writing-index .post h2 {
  font-size: 1.4rem;
  margin: 0 0 .35rem;
}
.writing-index .post p { color: var(--ink-soft); margin: 0; }
.writing-index .post:hover h2 { color: var(--accent); }

/* CV / about ---------------------------------------------------------------- */
.cv {
  list-style: none;
  padding: 0;
  margin: 1rem 0 2rem;
  border-top: 1px solid var(--rule);
}
.cv li {
  display: flex;
  gap: 1.25rem;
  padding: .8rem 0;
  border-bottom: 1px solid var(--rule);
}
.cv-when {
  flex: 0 0 9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: .9rem;
  letter-spacing: .04em;
}
.cv-what { color: var(--ink); }

/* Contact list -------------------------------------------------------------- */
.contact-list {
  list-style: none;
  padding: 0;
  margin: 2rem 0;
  border-top: 1px solid var(--rule);
}
.contact-list li {
  display: flex;
  gap: 1.25rem;
  padding: .9rem 0;
  border-bottom: 1px solid var(--rule);
  align-items: baseline;
}
.contact-label {
  flex: 0 0 6rem;
  color: var(--muted);
  font-size: .85rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* Subscribe ----------------------------------------------------------------- */
.subscribe {
  margin-top: 3rem;
  padding: 2rem;
  background: var(--bg-soft);
  border-radius: 14px;
}
.subscribe h2 { margin-top: 0; }
.subscribe-fallback { font-size: .9rem; color: var(--muted); margin: .75rem 0 0; }

/* Footer -------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--rule);
  margin-top: 4rem;
}
.footer-inner {
  max-width: var(--maxw-wide);
  margin: 0 auto;
  padding: 1.5rem var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: .9rem;
  color: var(--muted);
}
.copy { margin: 0; }
.social {
  list-style: none;
  display: flex;
  gap: 1.25rem;
  padding: 0;
  margin: 0;
}
.social a { color: var(--ink-soft); text-decoration: none; }
.social a:hover { color: var(--accent); }

/* Selection / focus --------------------------------------------------------- */
::selection { background: var(--accent); color: #fff; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* Responsive ---------------------------------------------------------------- */
@media (max-width: 560px) {
  .site-header { padding-top: 1.1rem; }
  .site-nav { gap: 1rem; font-size: .9rem; }
  .footer-inner { flex-direction: column; align-items: flex-start; }
  .cv li, .contact-list li { flex-direction: column; gap: .15rem; }
  .cv-when, .contact-label { flex: 0 0 auto; }
  .subscribe { padding: 1.25rem; }
}

/* Print --------------------------------------------------------------------- */
@media print {
  .site-header, .site-footer, .hero-cta, .more, .subscribe { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; text-decoration: underline; }
}
