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

/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --primary-color:  #CC785C;
  --primary-dark:   #B3664A;
  --primary-light:  #E09070;
  --secondary-color:#8B6B47;
  --text-dark:      #1A1A1A;
  --text-light:     #6B6B6B;
  --bg-light:       #FEFCF9;
  --bg-white:       #FFFFFF;
  --bg-card:        #F9F6F1;
  --border-color:   #E8E3DB;
  --shadow-sm:      0 2px 4px rgba(26,26,26,.04);
  --shadow:         0 4px 8px rgba(26,26,26,.06);
  --shadow-lg:      0 8px 24px rgba(26,26,26,.08);
  --radius-md:      12px;
  --radius-lg:      16px;
  --transition:     all 0.3s cubic-bezier(0.4,0,0.2,1);
}

html.dark-mode {
  --text-dark:    #E8E3DB;
  --text-light:   #A09080;
  --bg-light:     #1A1614;
  --bg-white:     #231F1D;
  --bg-card:      #2D2926;
  --border-color: #3D3733;
}

/* ── Base ───────────────────────────────────────────────────────────────── */
body {
  font-family: 'Atkinson Hyperlegible', system-ui, sans-serif;
  background: linear-gradient(135deg, var(--bg-light), var(--bg-card));
  color: var(--text-dark);
  min-height: 100vh;
  line-height: 1.6;
}

html.dark-mode body {
  background: linear-gradient(135deg, #1A1614 0%, #231F1D 50%, #2D2926 100%);
}

/* ── Grid overlay ───────────────────────────────────────────────────────── */
.page-grid-overlay {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(180,180,180,.15) 1px, transparent 1px),
    linear-gradient(90deg, rgba(180,180,180,.15) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
}

html.dark-mode .page-grid-overlay {
  background-image:
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.03) 1px, transparent 1px);
}

/* ── Particle canvases ──────────────────────────────────────────────────── */
.page-particles,
.star-particles {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  background: rgba(255,255,255,.8);
  padding: 1rem 2rem;
  box-shadow: 0 1px 0 0 var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

html.dark-mode header {
  background: rgba(35,31,29,.8);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.logo svg { width: 32px; height: 32px; }
.logo-light { display: block; }
.logo-dark  { display: none; }
html.dark-mode .logo-light { display: none; }
html.dark-mode .logo-dark  { display: block; }

.logo-text {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.main-links {
  display: flex;
  gap: 2rem;
  align-items: center;
  justify-self: center;
}

.main-links a {
  color: var(--text-dark);
  text-decoration: none;
  font-size: .95rem;
  transition: var(--transition);
}

.main-links a:hover { color: var(--primary-color); }

.main-links a[aria-current="page"] {
  color: var(--primary-color);
  font-weight: 700;
}

html.dark-mode .main-links a[aria-current="page"] {
  color: #e8e3db;
}

.nav-controls { justify-self: end; }

/* Theme toggle */
.theme-toggle {
  position: relative;
  width: 50px;
  height: 20px;
  background: #e8e3db;
  border: 1.5px solid var(--border-color);
  border-radius: 14px;
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
}

html.dark-mode .theme-toggle {
  background: var(--bg-card);
}

.theme-toggle:hover { border-color: var(--primary-color); }

.theme-toggle-inner {
  position: absolute;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  top: 1px;
  left: 2px;
  transition: var(--transition);
}

html.dark-mode .theme-toggle-inner { left: 29px; }

/* ── Blog hero ──────────────────────────────────────────────────────────── */
.blog-hero {
  position: relative;
  z-index: 1;
  padding: 5rem 2rem 3rem;
  text-align: center;
}

.blog-hero-inner {
  max-width: 640px;
  margin: 0 auto;
}

.blog-eyebrow {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--primary-color);
  margin-bottom: .75rem;
}

.blog-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 800;
  line-height: 1.1;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

html.dark-mode .blog-title {
  color: #e8e3db;
}

.blog-subtitle {
  color: var(--text-light);
  font-size: 1.1rem;
}

/* ── Post list ──────────────────────────────────────────────────────────── */
.post-list-section {
  position: relative;
  z-index: 1;
  padding: 0 2rem 6rem;
}

.post-list-container {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.post-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
  position: relative;
}

.post-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--primary-light);
}

.post-card-meta {
  font-size: .8rem;
  color: var(--primary-color);
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: .6rem;
}

.post-card-title {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: .75rem;
}

.post-card-title a {
  color: var(--text-dark);
  text-decoration: none;
  transition: var(--transition);
}

.post-card-title a::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
}

.post-card-title a:hover { color: var(--primary-color); }

.post-card-excerpt {
  color: var(--text-light);
  font-size: .95rem;
  margin-bottom: 1.25rem;
  line-height: 1.7;
}

.read-more {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .875rem;
  font-weight: 700;
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition);
  position: relative;
  z-index: 1;
}

.read-more:hover { color: var(--primary-dark); gap: .5rem; }

.no-posts {
  text-align: center;
  color: var(--text-light);
  padding: 4rem 0;
}

/* ── Post article ───────────────────────────────────────────────────────── */
.post-hero {
  position: relative;
  z-index: 1;
  padding: 4rem 2rem 2.5rem;
  text-align: center;
}

.post-hero-inner {
  max-width: 860px;
  margin: 0 auto;
}

.post-date {
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--primary-color);
  margin-bottom: .75rem;
}

.post-heading {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: clamp(1.75rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  color: var(--text-dark);
  margin-bottom: 1rem;
}

.post-description {
  color: var(--text-light);
  font-size: 1.1rem;
  line-height: 1.7;
}

/* Article body */
.post-body-section {
  position: relative;
  z-index: 1;
  padding: 0 2rem 6rem;
}

.post-body-container {
  max-width: 860px;
  margin: 0 auto;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 3rem;
  box-shadow: var(--shadow);
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .875rem;
  font-weight: 700;
  color: var(--primary-color);
  text-decoration: none;
  margin-bottom: 2.5rem;
  transition: var(--transition);
}

.back-link:hover { color: var(--primary-dark); gap: .5rem; }

/* Prose – rendered markdown */
.prose { font-size: 1.25rem; line-height: 1.9; color: var(--text-dark); }

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  font-family: 'Source Serif 4', Georgia, serif;
  color: var(--text-dark);
  line-height: 1.3;
  margin: 2rem 0 .75rem;
}

.prose h1 { font-size: 2.4rem; }
.prose h2 { font-size: 1.9rem; border-bottom: 1px solid var(--border-color); padding-bottom: .4rem; }
.prose h3 { font-size: 1.55rem; }
.prose h4 { font-size: 1.25rem; }

.prose p { margin-bottom: 1.25rem; }

.prose a {
  color: var(--primary-color);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.prose a:hover { color: var(--primary-dark); }

.prose strong { font-weight: 700; }
.prose em     { font-style: italic; }

.prose ul,
.prose ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.prose li { margin-bottom: .4rem; }

.prose blockquote {
  border-left: 3px solid var(--primary-color);
  padding: .5rem 0 .5rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-light);
  font-style: italic;
}

.prose code {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: .875em;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: .15em .4em;
}

.prose pre {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: .875rem;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2.5rem 0;
}

.prose img {
  max-width: 100%;
  border-radius: var(--radius-md);
  display: block;
  margin: 1.5rem 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.25rem;
  font-size: .9rem;
}

.prose th,
.prose td {
  border: 1px solid var(--border-color);
  padding: .6rem .9rem;
  text-align: left;
}

.prose th {
  background: var(--bg-card);
  font-weight: 700;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border-color);
  padding: 2rem;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.footer-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
}

.footer-logo svg { width: 22px; height: 22px; }
.footer-logo .logo-light { display: block; }
.footer-logo .logo-dark  { display: none; }
html.dark-mode .footer-logo .logo-light { display: none; }
html.dark-mode .footer-logo .logo-dark  { display: block; }

.footer-logo-text {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 700;
  font-size: 1rem;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links a {
  font-size: .85rem;
  color: var(--text-light);
  text-decoration: none;
  transition: var(--transition);
}

.footer-links a:hover { color: var(--primary-color); }

.footer-text {
  font-size: .8rem;
  color: var(--text-light);
  line-height: 1.6;
}

.footer-biokoder {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 700;
  transition: var(--transition);
}

.footer-biokoder:hover { color: var(--primary-dark); }

/* ── Back to top ────────────────────────────────────────────────────────── */
#backToTop {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  border: none;
  background: var(--bg-white);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

#backToTop.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#backToTop svg {
  position: absolute;
  top: 0; left: 0;
  width: 48px; height: 48px;
  transform: rotate(-90deg);
}

.btt-track {
  fill: none;
  stroke: var(--border-color);
  stroke-width: 2.5;
}

.btt-progress {
  fill: none;
  stroke: var(--primary-color);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition: stroke-dashoffset 0.1s linear;
}

.btt-arrow {
  font-size: 1rem;
  color: var(--primary-color);
  line-height: 1;
  position: relative;
  z-index: 1;
}

#backToTop:hover { box-shadow: 0 6px 20px rgba(204,120,92,0.3); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  header { padding: 1rem; }
  .main-links { display: none; }

  .blog-hero,
  .post-hero { padding: 3rem 1.25rem 2rem; }

  .post-list-section,
  .post-body-section { padding: 0 1.25rem 4rem; }

  .post-body-container { padding: 1.75rem 1.25rem; }

  .footer-inner { flex-direction: column; text-align: center; }
}
