/* ==========================================================================
   SyntaxSutra — Public Site Styles (v2)
   Design concept: "threads of code wisdom" — an ink-navy manuscript meets a
   syntax-highlighted editor. Fraunces carries editorial weight, Inter carries
   body text, JetBrains Mono marks labels and code — the same three-voice
   system a real code editor + book would use together.
   ========================================================================== */

:root {
  /* Surfaces — layered, not flat: each step up is a shade lighter */
  --bg:            #0A0E1A;
  --bg-elevated:   #0F1424;
  --surface:       #141A2E;
  --surface-hover: #1A2138;
  --border:        #232B48;
  --border-strong: #303B60;

  /* Text */
  --text:          #F1F3F8;
  --text-secondary:#A8B0C8;
  --text-tertiary: #6B7494;

  /* Brand */
  --accent:        #F0A83E;
  --accent-soft:   #FFC266;
  --accent-dim:    rgba(240,168,62,0.13);
  --thread:        #5FCDBA;
  --danger:        #F0715F;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'JetBrains Mono', 'SFMono-Regular', monospace;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --max-width: 720px;
  --wide-width: 1080px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,0.24);
  --shadow-md: 0 8px 28px rgba(0,0,0,0.32);
  --shadow-glow: 0 0 0 1px rgba(240,168,62,0.25), 0 8px 24px rgba(240,168,62,0.08);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(240,168,62,0.06), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(95,205,186,0.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.container { max-width: var(--wide-width); margin: 0 auto; padding: 0 24px; }

a { color: var(--accent-soft); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { color: var(--accent); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--thread);
  letter-spacing: 0.03em;
  margin: 0 0 10px;
  display: block;
}
.eyebrow a { color: var(--thread); }
.eyebrow a:hover { color: var(--accent-soft); }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.18; color: var(--text); letter-spacing: -0.01em; }

/* ---------- Reading progress bar (post pages only) ---------- */
#reading-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--thread));
  z-index: 1000; transition: width 0.1s linear;
}
body:not(.has-progress-bar) #reading-progress { display: none; }

/* ---------- Cookie banner ---------- */
.cookie-banner {
  position: fixed; bottom: 16px; left: 16px; right: 16px; z-index: 999;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 18px 22px; display: flex; flex-wrap: wrap; gap: 14px;
  align-items: center; justify-content: space-between;
  box-shadow: var(--shadow-md);
  max-width: 760px; margin: 0 auto;
}
.cookie-banner p { margin: 0; font-size: 0.88rem; color: var(--text-secondary); max-width: 560px; }
.cookie-banner a { color: var(--accent); text-decoration: underline; }
.cookie-actions { display: flex; gap: 10px; flex-shrink: 0; }

.btn {
  font-family: var(--font-body); font-weight: 600; font-size: 0.9rem;
  padding: 11px 20px; border-radius: 8px; border: none; cursor: pointer;
  display: inline-block; transition: all 0.15s var(--ease);
}
.btn-accent { background: var(--accent); color: #1a1204; }
.btn-accent:hover { background: var(--accent-soft); color: #1a1204; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-strong); }
.btn-ghost:hover { color: var(--text); border-color: var(--text-tertiary); background: var(--surface-hover); }
.btn-block { width: 100%; text-align: center; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(10,14,26,0.85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s var(--ease);
}
.site-header.scrolled { border-bottom-color: var(--border); }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; max-width: var(--wide-width); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--accent), #c77a1f);
  color: #1a1204; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
  flex-shrink: 0;
}
.brand-word { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; color: var(--text); }
.brand-accent { color: var(--accent); }

.main-nav { display: flex; gap: 8px; align-items: center; }
.main-nav a {
  color: var(--text-secondary); font-size: 0.92rem; font-weight: 500;
  padding: 8px 14px; border-radius: 7px; transition: all 0.15s var(--ease);
}
.main-nav a:hover { color: var(--text); background: var(--surface-hover); }
.ext-arrow { font-size: 0.75em; opacity: 0.6; }

.nav-toggle {
  display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer;
  padding: 8px; z-index: 200;
}
.nav-toggle span { width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: all 0.25s var(--ease); }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Hero ---------- */
.hero { position: relative; padding: 80px 0 40px; overflow: hidden; }
.hero-inner { position: relative; max-width: 700px; }
.hero h1 { font-size: clamp(2.4rem, 5.5vw, 3.6rem); margin: 0 0 20px; }
.hero-sub { color: var(--text-secondary); font-size: 1.12rem; max-width: 600px; margin: 0 0 28px; }
.hero-stats { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; color: var(--text-tertiary); font-family: var(--font-mono); }
.hero-stats strong { color: var(--accent-soft); }
.stat-divider { opacity: 0.5; }

/* ---------- Category filter rail ---------- */
.category-rail { border-bottom: 1px solid var(--border); padding: 4px 0 20px; margin-bottom: 8px; }
.category-rail-inner { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.category-rail-inner::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; font-size: 0.86rem; font-weight: 500; color: var(--text-secondary);
  padding: 8px 16px; border-radius: 100px; border: 1px solid var(--border);
  background: var(--surface); transition: all 0.15s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip-active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent-soft); }

/* ---------- Post section / grid ---------- */
.post-section { max-width: var(--wide-width); padding: 24px 24px 90px; }
.page-header { max-width: var(--wide-width); padding: 56px 24px 8px; margin: 0 auto; }
.page-header h1 { font-size: 2.2rem; margin: 0; }

/* Featured card (first post on homepage) */
.featured-card {
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 0; align-items: stretch;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; margin: 24px 0 48px; transition: all 0.25s var(--ease);
}
.featured-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.featured-thumb { position: relative; min-height: 280px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.featured-thumb img { width: 100%; height: 100%; object-fit: cover; }
.featured-badge {
  position: absolute; top: 16px; left: 16px; background: rgba(10,14,26,0.75); backdrop-filter: blur(4px);
  color: var(--accent-soft); font-family: var(--font-mono); font-size: 0.72rem; padding: 5px 12px;
  border-radius: 100px; border: 1px solid rgba(240,168,62,0.3);
}
.featured-body { padding: 40px; display: flex; flex-direction: column; justify-content: center; }
.featured-body h2 { font-size: clamp(1.5rem, 2.5vw, 1.9rem); margin: 0 0 14px; color: var(--text); }
.featured-card:hover .featured-body h2 { color: var(--accent-soft); }

/* Standard grid */
.post-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.post-card {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; transition: all 0.2s var(--ease);
}
.post-card:hover { border-color: var(--border-strong); transform: translateY(-3px); box-shadow: var(--shadow-md); }
.post-card-thumb { position: relative; height: 160px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.post-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-monogram { font-family: var(--font-display); font-size: 2.4rem; font-weight: 700; color: rgba(255,255,255,0.85); }
.thumb-monogram-lg { font-size: 3.5rem; }
.post-card-body { padding: 22px; flex: 1; display: flex; flex-direction: column; }
.post-card-body h2 { font-size: 1.15rem; margin: 4px 0 10px; color: var(--text); transition: color 0.15s var(--ease); }
.post-card:hover .post-card-body h2 { color: var(--accent-soft); }
.post-excerpt { color: var(--text-secondary); font-size: 0.92rem; margin: 0 0 14px; flex: 1; }
.read-more { font-family: var(--font-mono); font-size: 0.82rem; color: var(--thread); margin-top: auto; }

.section-title { font-size: 1.4rem; margin: 4px 0 20px; }
.related-section { padding: 40px 24px 90px; border-top: 1px solid var(--border); margin-top: 20px; }

.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 44px; }
.page-indicator { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 0.85rem; }
.empty-state { color: var(--text-secondary); padding: 60px 0; text-align: center; }
.filter-note { color: var(--text-tertiary); margin-bottom: 24px; }

/* ---------- Single post ---------- */
.single-post { max-width: var(--max-width); padding: 48px 24px 70px; }
.single-post h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); margin: 8px 0 14px; }
.post-meta { color: var(--text-tertiary); font-size: 0.9rem; margin-bottom: 32px; font-family: var(--font-mono); }
.post-featured-image { width: 100%; height: auto; aspect-ratio: 2/1; object-fit: cover; border-radius: var(--radius); margin-bottom: 36px; border: 1px solid var(--border); }
.post-featured-placeholder { display: flex; align-items: center; justify-content: center; }

.post-content { font-size: 1.09rem; color: var(--text); }
.post-content h2 { margin: 2.2em 0 0.6em; font-size: 1.55rem; }
.post-content h3 { margin: 1.8em 0 0.5em; font-size: 1.2rem; }
.post-content p { margin: 1.15em 0; color: var(--text); }
.post-content img { max-width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.post-content pre {
  background: var(--bg-elevated); border: 1px solid var(--border); padding: 20px;
  border-radius: var(--radius); overflow-x: auto; position: relative; margin: 1.6em 0;
}
.post-content code { font-family: var(--font-mono); background: var(--surface); padding: 2px 7px; border-radius: 5px; font-size: 0.88em; color: var(--accent-soft); }
.post-content pre code { background: none; padding: 0; color: var(--text-secondary); }
.post-content blockquote { border-left: 3px solid var(--accent); margin: 1.6em 0; padding: 0.4em 1.4em; color: var(--text-secondary); font-style: italic; }
.post-content ul, .post-content ol { padding-left: 1.5em; }
.post-content li { margin: 0.4em 0; }
.post-content a { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(240,168,62,0.4); }
.post-content a:hover { text-decoration-color: var(--accent); }
.post-content strong { color: var(--text); }

.post-cta { margin-top: 52px; padding: 24px; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); }
.post-cta p { margin: 0; color: var(--text-secondary); }
.post-cta a { color: var(--accent-soft); font-weight: 600; }

/* ---------- Static pages ---------- */
.static-page { max-width: var(--max-width); padding: 56px 24px 90px; }
.static-page h1 { font-size: 2.2rem; margin: 8px 0 24px; }
.static-page p, .static-page ul { color: var(--text-secondary); font-size: 1.02rem; }
.legal-page h2 { font-size: 1.3rem; margin-top: 2em; color: var(--text); }
.legal-page h3 { font-size: 1.05rem; margin-top: 1.5em; color: var(--text); }
.legal-page ul { padding-left: 1.4em; }
.legal-page li { margin: 0.4em 0; }

.email-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px; margin: 28px 0; text-align: center;
  transition: all 0.2s var(--ease);
}
.email-card:hover { border-color: var(--accent); box-shadow: var(--shadow-glow); }
.email-address { display: block; font-family: var(--font-mono); font-size: 1.35rem; color: var(--accent-soft); margin-top: 8px; }
.contact-note { font-size: 0.9rem; }

.error-page { text-align: center; padding: 110px 24px; max-width: 480px; }
.error-page h1 { font-size: 2rem; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 48px; padding: 60px 0 0; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 48px; justify-content: space-between; max-width: var(--wide-width); padding-bottom: 44px; }
.footer-brand { max-width: 320px; }
.footer-brand .brand { margin-bottom: 12px; }
.footer-brand p { color: var(--text-tertiary); font-size: 0.9rem; }
.footer-links { display: flex; gap: 56px; }
.footer-links h4 { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 14px; }
.footer-links a { display: block; color: var(--text-secondary); margin-bottom: 9px; font-size: 0.92rem; }
.footer-links a:hover { color: var(--text); }
.footer-bottom { border-top: 1px solid var(--border); padding: 22px 24px; max-width: var(--wide-width); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.footer-bottom p { color: var(--text-tertiary); font-size: 0.85rem; margin: 0; }
.footer-bottom a { color: var(--text-tertiary); text-decoration: underline; }
.back-to-top { font-size: 0.85rem; color: var(--text-tertiary); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .post-grid { grid-template-columns: repeat(2, 1fr); }
  .featured-card { grid-template-columns: 1fr; }
  .featured-thumb { min-height: 220px; }
}

@media (max-width: 720px) {
  .main-nav {
    display: none;
  }
  .main-nav.open {
    display: flex; flex-direction: column; position: fixed; inset: 0; top: 65px;
    background: var(--bg); padding: 32px 24px; gap: 4px; z-index: 150;
    animation: navSlideIn 0.2s var(--ease);
  }
  .main-nav.open a { font-size: 1.1rem; padding: 14px; border-bottom: 1px solid var(--border); border-radius: 0; }
  .nav-toggle { display: flex; }
  .post-grid { grid-template-columns: 1fr; }
  .hero { padding: 56px 0 32px; }
  .featured-body { padding: 28px; }
  .footer-links { gap: 32px; }
}

@keyframes navSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
