:root {
  --bg: #faf8f4;
  --bg-raised: #ffffff;
  --text: #16181d;
  --text-muted: #5b6169;
  --border: #e7e2d9;
  --accent: #4338ca;
  --accent-contrast: #ffffff;
  --badge-newsletter-bg: #eceafd;
  --badge-newsletter-text: #4338ca;
  --badge-article-bg: #fdeee0;
  --badge-article-text: #b4530a;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: Charter, "Iowan Old Style", "Georgia", "Times New Roman", serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14151a;
    --bg-raised: #1c1e24;
    --text: #ecebe8;
    --text-muted: #9b9fa8;
    --border: #2c2f37;
    --accent: #a5a0f7;
    --accent-contrast: #14151a;
    --badge-newsletter-bg: #2a2860;
    --badge-newsletter-text: #c9c5ff;
    --badge-article-bg: #4a2f14;
    --badge-article-text: #ffc98f;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
}
img { max-width: 100%; display: block; }
a { color: inherit; }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 18px 0;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { text-decoration: none; color: var(--text); }
.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.15;
}
.site-nav { display: flex; gap: 20px; flex-wrap: wrap; }
.site-nav a {
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-muted);
}
.site-nav a:hover { color: var(--accent); }

/* Intro / hero */
.intro { padding: 56px 20px 32px; }
.intro .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 10px;
}
.intro h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin: 0 0 14px;
  letter-spacing: -0.02em;
}
.intro .lead {
  font-family: var(--serif);
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: 640px;
  margin: 0;
}

/* Post grid / cards */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 28px;
  padding: 24px 20px 56px;
}
.card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.08);
}
.card-media {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--border);
  overflow: hidden;
}
.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-media-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  font-size: 2.6rem;
  font-weight: 700;
  color: var(--accent);
  background: linear-gradient(135deg, var(--badge-newsletter-bg), var(--bg-raised));
  text-transform: uppercase;
}
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.card-media .badge {
  position: absolute;
  top: 12px;
  left: 12px;
}
.badge-newsletter { background: var(--badge-newsletter-bg); color: var(--badge-newsletter-text); }
.badge-article { background: var(--badge-article-bg); color: var(--badge-article-text); }
.card-body { padding: 16px 18px 20px; flex: 1; display: flex; flex-direction: column; }
.card-body time {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}
.card-body h2 {
  font-size: 1.15rem;
  line-height: 1.3;
  margin: 8px 0 8px;
}
.card-body p {
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 12px 20px 64px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.pagination a {
  text-decoration: none;
  font-weight: 600;
  color: var(--accent);
}

/* Post page */
.post-hero {
  width: 100%;
  max-height: 460px;
  overflow: hidden;
  background: var(--border);
}
.post-hero-img {
  width: 100%;
  height: 100%;
  max-height: 460px;
  object-fit: cover;
}
.post { padding: 36px 20px 64px; max-width: 760px; }
.post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.post-meta time { color: var(--text-muted); font-size: 0.9rem; font-weight: 600; }
.post-title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 28px;
}
.post-body {
  font-family: var(--serif);
  font-size: 1.15rem;
  line-height: 1.7;
}
.post-body p { margin: 0 0 22px; }
.post-body h3 {
  font-family: var(--sans);
  font-size: 1.3rem;
  margin: 40px 0 16px;
  line-height: 1.3;
}
.post-body h2 {
  font-family: var(--sans);
  font-size: 1.5rem;
  margin: 44px 0 16px;
}
.post-body blockquote {
  margin: 28px 0;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--accent);
  font-style: italic;
  color: var(--text-muted);
}
.post-body ul, .post-body ol { padding-left: 1.3em; margin: 0 0 22px; }
.post-body li { margin-bottom: 8px; }
.post-body img {
  border-radius: 10px;
  margin: 8px 0;
}
.post-body em { display: inline-block; }
.post-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}
.post-body iframe {
  display: block;
  margin: 28px 0;
  border-radius: 10px;
}
.post-body a { color: var(--accent); text-decoration-thickness: 1px; }

/* Recovered link-preview embeds (LinkedIn's own embed iframe can't render
   off-domain, so these replace it with a native card to the real source) */
.embed-card {
  display: flex;
  align-items: stretch;
  gap: 16px;
  margin: 28px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  background: var(--bg-raised);
  font-family: var(--sans);
  transition: border-color 0.15s ease;
}
.embed-card:hover { border-color: var(--accent); }
.embed-card img {
  width: 160px;
  min-width: 160px;
  height: auto;
  object-fit: cover;
  margin: 0;
  border-radius: 0;
}
.embed-card-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 14px 18px 14px 0;
  min-width: 0;
}
.embed-card-body strong {
  font-size: 1rem;
  line-height: 1.3;
}
.embed-card-body span {
  font-size: 0.88rem;
  color: var(--text-muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.embed-card-body em {
  font-style: normal;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
}
.embed-card-plain {
  padding: 14px 18px;
  font-weight: 600;
  color: var(--accent);
}
@media (max-width: 480px) {
  .embed-card img { width: 96px; min-width: 96px; }
}
.post-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.post-source {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 20px;
}
.post-source a { color: var(--accent); }
.btn {
  display: inline-block;
  text-decoration: none;
  font-weight: 600;
  color: var(--accent-contrast);
  background: var(--accent);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.92rem;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0 48px;
  color: var(--text-muted);
  font-size: 0.88rem;
}
.footer-inner p { margin: 0 0 14px; max-width: 640px; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { text-decoration: none; color: var(--text-muted); font-weight: 600; }
.footer-links a:hover { color: var(--accent); }
