@import url('https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@300;400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #FDFCFB;
  --text:       #1C1917;
  --body:       #44403C;
  --muted:      #78716C;
  --faint:      #A8A29E;
  --accent:     #B45309;
  --accent-bg:  #FEF3C7;
  --border:     #E7E5E4;
  --surface:    #F5F5F4;
  --sidebar-w:  210px;
}

html { font-size: 16px; }

body {
  font-family: 'Lexend Deca', -apple-system, sans-serif;
  font-weight: 300;
  line-height: 1.75;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
strong { font-weight: 500; }
em { font-style: italic; }

/* ── Site Shell ───────────────────────────────────────── */
.site {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  padding: 2.5rem 1.5rem 3rem;
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  margin-bottom: 2.5rem;
}

.sidebar-brand a {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.2px;
  line-height: 1.3;
  display: block;
}

.sidebar-brand a:hover { color: var(--accent); }

/* Nav */
.sidebar-nav { flex: 1; }

.sidebar-nav ul {
  list-style: none;
}

.sidebar-nav > ul > li {
  margin-bottom: 0.1rem;
}

.sidebar-nav a {
  display: block;
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--muted);
  padding: 0.3rem 0;
  transition: color 0.15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  color: var(--text);
}

.sidebar-nav a.active {
  font-weight: 500;
}

/* Writing dropdown via <details> */
.sidebar-nav details {
  margin-bottom: 0.1rem;
}

.sidebar-nav details summary {
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--muted);
  padding: 0.3rem 0;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: color 0.15s;
}

.sidebar-nav details summary::-webkit-details-marker { display: none; }

.sidebar-nav details summary::after {
  content: '›';
  font-size: 1rem;
  transition: transform 0.2s;
  color: var(--faint);
  margin-left: 4px;
}

.sidebar-nav details[open] summary::after {
  transform: rotate(90deg);
}

.sidebar-nav details summary:hover { color: var(--text); }
.sidebar-nav details[open] summary { color: var(--text); font-weight: 500; }

.sidebar-nav .sub-nav {
  padding: 0.25rem 0 0.5rem 0.75rem;
  border-left: 1px solid var(--border);
  margin-left: 2px;
}

.sidebar-nav .sub-nav li {
  margin-bottom: 0;
}

.sidebar-nav .sub-nav a {
  font-size: 0.82rem;
  color: var(--faint);
  padding: 0.2rem 0;
}

.sidebar-nav .sub-nav a:hover { color: var(--text); }

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding-top: 2rem;
  font-size: 0.75rem;
  color: var(--faint);
  line-height: 1.5;
}

/* ── Main Content ─────────────────────────────────────── */
.main {
  flex: 1;
  padding: 3rem 4rem 5rem;
  max-width: 720px;
}

/* ── Homepage ─────────────────────────────────────────── */
.home-intro {
  margin-bottom: 3rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.home-intro p {
  font-size: 1rem;
  color: var(--body);
  line-height: 1.8;
  margin-bottom: 0.9rem;
}

.home-intro p:last-child { margin-bottom: 0; }

.home-intro a { color: var(--accent); }
.home-intro a:hover { text-decoration: underline; }

.section-label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 1.25rem;
}

/* ── Post List ────────────────────────────────────────── */
.post-list { list-style: none; }

.post-list li {
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 0 1.25rem;
  align-items: baseline;
}

.post-list li:first-child { border-top: 1px solid var(--border); }

.post-list .post-date {
  font-size: 0.78rem;
  color: var(--faint);
  white-space: nowrap;
  padding-top: 2px;
}

.post-list .post-info {}

.post-list .post-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 0.2rem;
  display: block;
}

.post-list .post-title:hover { color: var(--accent); }

.post-list .post-excerpt {
  font-size: 0.83rem;
  color: var(--muted);
  line-height: 1.55;
}

/* ── Tags ─────────────────────────────────────────────── */
.tag {
  display: inline-block;
  font-size: 0.67rem;
  font-weight: 400;
  padding: 1px 7px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

.tag-finance      { background: #ECFDF5; color: #065F46; }
.tag-investing    { background: #EFF6FF; color: #1E40AF; }
.tag-productivity { background: #FEF3C7; color: #92400E; }
.tag-notes        { background: var(--surface); color: var(--muted); }

/* ── Page / Post Header ───────────────────────────────── */
.page-header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.page-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 500;
  letter-spacing: -0.4px;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 0.75rem;
}

.post-byline {
  font-size: 0.8rem;
  color: var(--faint);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* ── Post Body ────────────────────────────────────────── */
.post-body { color: var(--body); }

.post-body p { font-size: 0.95rem; line-height: 1.85; margin-bottom: 1.2rem; }
.post-body h2 { font-size: 1.15rem; font-weight: 500; color: var(--text); margin: 2rem 0 0.75rem; }
.post-body h3 { font-size: 1rem; font-weight: 500; color: var(--text); margin: 1.5rem 0 0.5rem; }
.post-body ul, .post-body ol { margin: 0.75rem 0 1.2rem 1.5rem; }
.post-body li { font-size: 0.95rem; line-height: 1.75; margin-bottom: 0.35rem; }

.post-body blockquote {
  border-left: 3px solid var(--accent);
  background: var(--accent-bg);
  padding: 0.85rem 1.1rem;
  margin: 1.5rem 0;
  border-radius: 0 4px 4px 0;
}
.post-body blockquote p { color: #78350F; margin-bottom: 0; }

.post-body code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82em;
  background: var(--surface);
  padding: 2px 5px;
  border-radius: 3px;
}

.post-body pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  overflow-x: auto;
}

.post-body pre code { background: none; padding: 0; font-size: 0.85rem; }
.post-body a { color: var(--accent); }
.post-body a:hover { text-decoration: underline; }
.post-body img { max-width: 100%; border-radius: 4px; margin: 1rem 0; }

/* Post nav */
.post-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}
.post-nav a { color: var(--muted); }
.post-nav a:hover { color: var(--accent); }
.post-nav .next { text-align: right; }

/* ── Page body (library, newsletter, about) ───────────── */
.page-body p { font-size: 0.95rem; color: var(--body); line-height: 1.85; margin-bottom: 1.1rem; }
.page-body h2 { font-size: 1.1rem; font-weight: 500; color: var(--text); margin: 2rem 0 0.75rem; }
.page-body h3 { font-size: 0.95rem; font-weight: 500; color: var(--text); margin: 1.5rem 0 0.5rem; }
.page-body ul, .page-body ol { margin: 0.75rem 0 1.1rem 1.5rem; }
.page-body li { font-size: 0.95rem; color: var(--body); line-height: 1.75; margin-bottom: 0.35rem; }
.page-body a { color: var(--accent); }
.page-body a:hover { text-decoration: underline; }

/* ── Library cards ────────────────────────────────────── */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
  margin: 1.5rem 0;
}

.book-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
  font-size: 0.85rem;
}

.book-card .book-title { font-weight: 500; color: var(--text); margin-bottom: 0.25rem; }
.book-card .book-author { color: var(--muted); font-size: 0.8rem; }

/* ── Mobile ───────────────────────────────────────────── */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text);
}

@media (max-width: 700px) {
  .mobile-toggle { display: block; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    background: var(--bg);
    box-shadow: 2px 0 12px rgba(0,0,0,0.08);
  }

  .sidebar.open { transform: translateX(0); }

  .main {
    padding: 4rem 1.5rem 4rem;
    max-width: 100%;
  }
}
