/* ── CSS custom properties (light defaults) ────────────────── */
:root {
  --cr-body-bg:          #f4f5f7;
  --cr-body-color:       #1a1a2e;
  --cr-card-bg:          #ffffff;
  --cr-card-shadow:      rgba(0,0,0,.06);
  --cr-card-hover-shadow:rgba(0,0,0,.14);
  --cr-article-color:    #2d2d2d;
  --cr-blockquote-bg:    #f8f9fa;
  --cr-blockquote-color: #555555;
  --cr-code-bg:          #f1f3f5;
  --cr-code-color:       inherit;
  --cr-placeholder-bg:   #e9ecef;
  --cr-scrollbar-thumb:  #dee2e6;
  --cr-pill-bg:          #e9ecef;
  --cr-pill-color:       #212529;
  --cr-pill-border:      #dee2e6;
  --cr-source-bg:        #f8f9fa;
}

[data-bs-theme="dark"] {
  --cr-body-bg:          #0d1117;
  --cr-body-color:       #c9d1d9;
  --cr-card-bg:          #161b22;
  --cr-card-shadow:      rgba(0,0,0,.3);
  --cr-card-hover-shadow:rgba(0,0,0,.55);
  --cr-article-color:    #cdd1d8;
  --cr-blockquote-bg:    #1e2530;
  --cr-blockquote-color: #9ca3af;
  --cr-code-bg:          #1e2530;
  --cr-code-color:       #e5c07b;
  --cr-placeholder-bg:   #21262d;
  --cr-scrollbar-thumb:  #444d56;
  --cr-pill-bg:          #21262d;
  --cr-pill-color:       #c9d1d9;
  --cr-pill-border:      #30363d;
  --cr-source-bg:        #1e2530;
}

/* ── Base ──────────────────────────────────────────────────── */
html { font-size: 15px; scroll-behavior: smooth; }
@media (min-width: 768px) { html { font-size: 16px; } }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--cr-body-bg);
  color: var(--cr-body-color);
}

/* ── Typography helpers ────────────────────────────────────── */
.fw-black { font-weight: 900; }
.text-white-75 { color: rgba(255,255,255,.75); }
.text-white-50 { color: rgba(255,255,255,.5); }
.lh-sm { line-height: 1.3; }

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar { font-size: .8rem; letter-spacing: .01em; }

#theme-toggle { font-size: .95rem; opacity: .85; transition: opacity .15s; }
#theme-toggle:hover { opacity: 1; }

/* ── Site branding ─────────────────────────────────────────── */
.site-name {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: -.03em;
}
.site-name-sm { font-size: 1.1rem; letter-spacing: -.02em; }

/* ── Sticky nav ────────────────────────────────────────────── */
.navbar.sticky-top { z-index: 1020; }

/* ── Hero section ──────────────────────────────────────────── */
.hero-section {
  min-height: 380px;
  background-color: #1a1a2e;
  background-size: cover;
  background-position: center;
  position: relative;
}
@media (min-width: 768px)  { .hero-section { min-height: 480px; } }
@media (min-width: 1200px) { .hero-section { min-height: 540px; } }

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,.05) 0%,
    rgba(0,0,0,.55) 50%,
    rgba(0,0,0,.85) 100%
  );
  border-radius: inherit;
}

/* ── Article cards ─────────────────────────────────────────── */
.article-card {
  transition: transform .18s ease, box-shadow .18s ease;
  background: var(--cr-card-bg);
  box-shadow: 0 2px 8px var(--cr-card-shadow);
}
.article-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px var(--cr-card-hover-shadow) !important;
}

.article-thumb {
  height: 180px;
  object-fit: cover;
  transition: transform .3s ease;
}
.article-card:hover .article-thumb { transform: scale(1.03); }

.article-thumb-placeholder {
  height: 180px;
  background-color: var(--cr-placeholder-bg);
}

.article-hero-img {
  max-height: 460px;
  object-fit: cover;
}

.topic-badge {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .25em .6em;
  border-radius: .25rem;
  display: inline-block;
  width: fit-content;
  position: relative;
  z-index: 1;
}

/* ── Topic pills ───────────────────────────────────────────── */
.topic-pill {
  font-size: .78rem;
  padding: .35em .8em;
  background-color: var(--cr-pill-bg) !important;
  color: var(--cr-pill-color) !important;
  border-color: var(--cr-pill-border) !important;
  transition: background .15s, color .15s;
}
.topic-pill:hover,
.topic-pill.active {
  background-color: var(--bs-primary) !important;
  color: #fff !important;
  border-color: var(--bs-primary) !important;
}

.topic-pill-lg {
  font-size: .85rem;
  padding: .45em 1em;
  background-color: var(--cr-pill-bg) !important;
  color: var(--cr-pill-color) !important;
  border-color: var(--cr-pill-border) !important;
  transition: background .15s, color .15s;
}
.topic-pill-lg:hover {
  background-color: var(--bs-primary) !important;
  color: #fff !important;
  border-color: var(--bs-primary) !important;
}

/* ── Sticky sidebar ────────────────────────────────────────── */
.sticky-sidebar {
  position: sticky;
  top: calc(56px + 1rem);
}

/* ── Article body typography ───────────────────────────────── */
.article-body {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--cr-article-color);
}
.article-body h2 { font-size: 1.5rem; font-weight: 700; margin-top: 2rem; margin-bottom: .75rem; }
.article-body h3 { font-size: 1.25rem; font-weight: 600; margin-top: 1.75rem; margin-bottom: .6rem; }
.article-body p  { margin-bottom: 1.15rem; }
.article-body ul,
.article-body ol { padding-left: 1.5rem; margin-bottom: 1.15rem; }
.article-body li { margin-bottom: .35rem; }
.article-body blockquote {
  border-left: 4px solid var(--bs-primary);
  padding: .6rem 1.2rem;
  margin: 1.5rem 0;
  background: var(--cr-blockquote-bg);
  border-radius: 0 .5rem .5rem 0;
  font-style: italic;
  color: var(--cr-blockquote-color);
}
.article-body img    { max-width: 100%; height: auto; border-radius: .5rem; margin: 1rem 0; }
.article-body a      { color: var(--bs-primary); }
.article-body a:hover{ text-decoration: none; }
.article-body strong { font-weight: 700; }
.article-body code {
  background: var(--cr-code-bg);
  color: var(--cr-code-color);
  padding: .1em .35em;
  border-radius: .25rem;
  font-size: .9em;
}

/* ── Source attribution ────────────────────────────────────── */
.source-attribution {
  font-size: .85rem;
  background-color: var(--cr-source-bg) !important;
}
.source-attribution a { word-break: break-all; }

/* ── Topics strip ──────────────────────────────────────────── */
.topics-strip { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.topics-strip::-webkit-scrollbar       { height: 4px; }
.topics-strip::-webkit-scrollbar-thumb { background: var(--cr-scrollbar-thumb); border-radius: 2px; }

/* ── Footer ────────────────────────────────────────────────── */
footer .tracking-wide { letter-spacing: .08em; }

/* ── Responsive tweaks ─────────────────────────────────────── */
@media (max-width: 575px) {
  .hero-section  { min-height: 280px; }
  .site-name     { font-size: 1.8rem; }
  .sticky-sidebar{ position: static; }
}

/* ── Focus ring ────────────────────────────────────────────── */
.btn:focus-visible, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 .2rem rgba(13, 110, 253, .35);
  outline: none;
}
