/* Shared styles for Refit blog posts */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:              #f2f0ec;
  --surface:         #ffffff;
  --primary:         #059669;
  --primary-light:   #e8f5ef;
  --mint:            #3ECFA0;
  --text:            #2c2b28;
  --text-muted:      #696560;
  --border:          #e4e0da;
  --shadow:          0 1px 4px rgba(0,0,0,0.06);
  --card-bg:         #ffffff;
  --nav-bg:          rgba(242,240,236,0.85);
  --accent-glow:     rgba(5,150,105,0.06);
  --code-bg:         #f5f3ee;
  --cta-fg-on-primary: #ffffff;
  --cta-fg-on-mint:    #1a1a1a;
  --mint-hover:        #4fdcac;
}

html[data-theme="dark"] {
  --bg:              #1e1d1a;
  --surface:         #282724;
  --primary:         #2faa80;
  --primary-light:   #1a6b52;
  --mint:            #3ECFA0;
  --text:            #F1F5F9;
  --text-muted:      #8A93A8;
  --border:          rgba(255,255,255,0.07);
  --shadow:          0 2px 8px rgba(0,0,0,0.3);
  --card-bg:         #282724;
  --nav-bg:          rgba(30,29,26,0.85);
  --accent-glow:     rgba(47,170,128,0.10);
  --code-bg:         #1a1917;
  --cta-fg-on-primary: #ffffff;
  --cta-fg-on-mint:    #1a1a1a;
  --mint-hover:        #4fdcac;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Switzer', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
  line-height: 1.65;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 65% -5%,  rgba(62,207,160,0.08) 0%, transparent 65%),
    radial-gradient(ellipse 40% 35% at 5%  85%,  rgba(62,207,160,0.05) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}

.page {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Reading progress bar */
.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--primary), var(--mint));
  z-index: 200;
  transition: width 0.1s linear;
  pointer-events: none;
}

/* In-article table of contents */
.article-toc {
  margin: 0 0 40px;
  padding: 20px 24px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.article-toc-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Outfit', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.article-toc-label i { color: var(--primary); font-size: 14px; }
.article-toc ol {
  counter-reset: toc;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.article-toc li {
  counter-increment: toc;
  margin: 0;
}
.article-toc a {
  display: flex;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  text-decoration: none;
  padding: 4px 0;
  transition: color 0.15s;
}
.article-toc a::before {
  content: counter(toc, decimal-leading-zero);
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 11px;
  color: var(--text-muted);
  min-width: 24px;
  padding-top: 2px;
  letter-spacing: 0.05em;
}
.article-toc a:hover { color: var(--primary); }
.article-toc a.active { color: var(--primary); font-weight: 600; }

/* Navigation */
nav {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px clamp(20px, 4vw, 40px);
  border-bottom: 1px solid var(--border);
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  font-family: 'Outfit', sans-serif;
  font-size: 20px;
  letter-spacing: -0.02em;
  line-height: 1;
}
.logo-re { font-weight: 700; color: var(--primary); }
.logo-fit { font-weight: 400; color: var(--text); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 4px;
  transition: color 0.2s;
}
.nav-link:hover { color: var(--primary); }

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  background: var(--surface);
  color: var(--primary);
  font-size: 18px;
}
.theme-toggle:hover { background: var(--border); }

.nav-cta {
  gap: 6px;
  padding: 10px 24px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--cta-fg-on-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s;
}
.nav-cta:hover { background: var(--mint); border-color: var(--mint); }
.nav-cta i { font-size: 12px; }

/* Article layout */
.article-wrap {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: clamp(32px, 6vw, 64px) clamp(20px, 4vw, 32px) clamp(48px, 8vw, 80px);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 24px;
  transition: color 0.2s;
}
.back-link:hover { color: var(--primary); }
.back-link i { font-size: 12px; }

.article-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.article-meta-dot { opacity: 0.4; }

.article-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-glow);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

article h1 {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(32px, 5vw, 44px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 16px;
}

.article-lede {
  font-size: clamp(17px, 2.2vw, 20px);
  line-height: 1.55;
  color: var(--text-muted);
  margin-bottom: 40px;
  padding-left: 16px;
  border-left: 2px solid var(--primary);
  font-weight: 400;
}

.article-body {
  font-size: 17px;
  line-height: 1.8;
  color: var(--text);
}

.article-body p + p,
.article-body p + ul,
.article-body p + ol,
.article-body p + blockquote,
.article-body p + h2,
.article-body p + h3 { margin-top: 20px; }

.article-body h2 {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-top: 56px;
  margin-bottom: 14px;
  line-height: 1.3;
  scroll-margin-top: 80px;
}
.article-body h2::before {
  content: '';
  display: block;
  width: 32px;
  height: 2px;
  background: var(--primary);
  border-radius: 2px;
  margin-bottom: 18px;
  opacity: 0.9;
}

.article-body h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  margin-top: 32px;
  margin-bottom: 8px;
  scroll-margin-top: 80px;
}

.article-body ul,
.article-body ol { padding-left: 24px; }
.article-body li { margin-bottom: 8px; }
.article-body li::marker { color: var(--primary); }

.article-body strong { color: var(--text); font-weight: 700; }
.article-body em {
  font-style: normal;
  color: var(--primary);
  font-weight: 500;
}

.article-body a {
  color: var(--primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.article-body a:hover { color: var(--mint); }

.article-body blockquote {
  position: relative;
  background: var(--accent-glow);
  border-left: 3px solid var(--primary);
  border-radius: 0 12px 12px 0;
  padding: 20px 24px 20px 28px;
  color: var(--text);
  font-style: normal;
  margin: 28px 0;
  font-size: 16px;
  line-height: 1.65;
}
.article-body blockquote::before {
  content: '"';
  position: absolute;
  top: -6px;
  left: 14px;
  font-family: 'Outfit', serif;
  font-size: 48px;
  font-weight: 800;
  color: var(--primary);
  opacity: 0.3;
  line-height: 1;
  pointer-events: none;
}
.article-body blockquote p { margin: 0; }
.article-body blockquote p + p { margin-top: 12px; }

.article-body code {
  background: rgba(5, 150, 105, 0.08);
  border: 1px solid rgba(5, 150, 105, 0.18);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.88em;
  color: var(--primary);
}
html[data-theme="dark"] .article-body code {
  background: rgba(62, 207, 160, 0.10);
  border-color: rgba(62, 207, 160, 0.22);
  color: var(--mint);
}

.article-body pre {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  margin: 24px 0;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.6;
}
.article-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  border-radius: 0;
  color: var(--text);
  font-size: inherit;
  white-space: pre;
}
.article-body pre code.language-sql,
.article-body pre code.language-js,
.article-body pre code.language-ts,
.article-body pre code.language-bash {
  display: block;
}

.pre-wrap {
  position: relative;
  margin: 24px 0;
}
.pre-wrap pre { margin: 0; }
.pre-lang {
  position: absolute;
  top: 10px;
  right: 12px;
  font-family: 'Switzer', sans-serif;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: var(--bg);
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  pointer-events: none;
}
.pre-copy {
  position: absolute;
  top: 10px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s;
}
.pre-wrap:hover .pre-copy { opacity: 1; }
.pre-wrap.has-lang .pre-copy { top: 40px; }
.pre-copy:hover { color: var(--primary); border-color: var(--primary); }
.pre-copy.copied { color: var(--primary); border-color: var(--primary); }
.pre-copy i { font-size: 11px; }

.article-body hr {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 48px auto;
  max-width: 200px;
  position: relative;
}
.article-body hr::after {
  content: '·  ·  ·';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg);
  padding: 0 16px;
  color: var(--text-muted);
  font-size: 14px;
  letter-spacing: 0.4em;
}

.callout {
  background: var(--accent-glow);
  border: 1px solid rgba(62,207,160,0.2);
  border-radius: 12px;
  padding: 20px 24px;
  margin: 32px 0;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.callout i {
  font-size: 22px;
  color: var(--primary);
  flex-shrink: 0;
  margin-top: 2px;
}
.callout p { margin: 0; font-size: 16px; line-height: 1.6; }

/* Article footer - next/prev + CTA */
.article-foot {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.article-cta {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: clamp(24px, 4vw, 32px);
  text-align: center;
}
.article-cta h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.article-cta p {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.article-cta .btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--mint);
  color: var(--cta-fg-on-mint);
  text-decoration: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s;
}
.article-cta .btn:hover { background: var(--mint-hover); }

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 32px;
}
.post-nav a {
  display: block;
  padding: 18px 20px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, transform 0.2s;
}
.post-nav a:hover { border-color: rgba(62,207,160,0.3); transform: translateY(-2px); }
.post-nav span {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.post-nav strong {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}
.post-nav .next { text-align: right; }
.post-nav .placeholder { visibility: hidden; }

footer {
  border-top: 1px solid var(--border);
  padding: 24px clamp(20px, 4vw, 40px);
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}
footer a { color: var(--text-muted); text-decoration: none; transition: color 0.2s; }
footer a:hover { color: var(--mint); }
.footer-left { display: flex; align-items: center; gap: 20px; }

@media (max-width: 768px) {
  .nav-link { display: none; }
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .next { text-align: left; }
  footer { flex-direction: column; text-align: center; gap: 12px; }
  .footer-left { flex-direction: column; gap: 8px; }
  .article-body { font-size: 16px; line-height: 1.75; }
  .article-lede { font-size: 17px; }
}
