/* ==========================================================================
   SyntaxSutra — Design tokens
   Concept: ancient sutra (a concise, memorable thread of teaching) meets
   the terminal/editor world developers actually live in. Warm paper ink
   on a deep ink-blue page, serif for the "teaching" voice, mono for the
   "code" voice, amber for the sutra thread that runs through every post.
   ========================================================================== */

:root {
  --bg:        #12141C;
  --bg-alt:    #191B26;
  --bg-card:   #1D2030;
  --border:    #2A2D3D;
  --text:      #EDE9DE;
  --text-dim:  #9C9AA8;
  --text-faint:#83819A;
  --amber:     #E8A33D;
  --teal:      #5FB3A3;
  --violet:    #8B7FD6;

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

  --radius: 3px;
  --max-width: 760px;
  --wide-width: 1080px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

img { max-width: 100%; display: block; }

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

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

/* ---------- Breadcrumbs ---------- */

.breadcrumbs {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 18px;
}
.breadcrumbs a { color: var(--text-faint); }
.breadcrumbs a:hover { color: var(--amber); text-decoration: none; }
.breadcrumbs span[aria-current] { color: var(--text-dim); }

/* ---------- Ad slot ---------- */

.ad-slot {
  margin: 40px 0;
  padding: 16px 0;
  border-top: 1px dashed var(--border);
  border-bottom: 1px dashed var(--border);
}
.ad-slot-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
  text-align: center;
}

/* ---------- Cookie consent ---------- */

.cookie-consent {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px 20px;
  z-index: 200;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.cookie-consent p {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 14px;
  line-height: 1.5;
}
.cookie-consent-actions { display: flex; gap: 10px; }
.cookie-consent-actions button {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
}
.cookie-consent-actions button#cookie-accept {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--bg);
  font-weight: 600;
}

/* ---------- Reading progress ---------- */

#reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: var(--amber);
  z-index: 100;
  transition: width 0.1s ease-out;
}

/* ---------- Header ---------- */

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 22px 0;
  position: sticky;
  top: 0;
  background: rgba(18, 20, 28, 0.92);
  backdrop-filter: blur(8px);
  z-index: 50;
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.logo {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.logo:hover { text-decoration: none; color: var(--amber); }
.logo .dot { color: var(--amber); }

.site-nav { display: flex; gap: 28px; align-items: center; }
.site-nav a {
  font-family: var(--font-mono);
  font-size: 13px;
  text-transform: lowercase;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.site-nav a:hover { color: var(--amber); text-decoration: none; }

.nav-search input {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 999px;
  width: 130px;
  transition: width 0.2s ease;
}
.nav-search input:focus { width: 190px; outline: none; border-color: var(--amber); }

/* ---------- Newsletter ---------- */

.newsletter {
  border-top: 1px solid var(--border);
  padding: 56px 0;
  background: var(--bg-alt);
  margin-top: 40px;
}
.newsletter-copy {
  color: var(--text-dim);
  max-width: 46ch;
  margin: 0 0 22px;
}
.newsletter-form {
  display: flex;
  gap: 10px;
  max-width: 420px;
}
.newsletter-form input {
  flex: 1;
  padding: 11px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
}
.newsletter-form input:focus { outline: none; border-color: var(--amber); }
.newsletter-form button {
  padding: 11px 20px;
  background: var(--amber);
  border: none;
  color: var(--bg);
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}
.newsletter-form button:hover { opacity: 0.9; }
.newsletter-msg {
  color: var(--teal);
  font-family: var(--font-mono);
  font-size: 13px;
  margin-top: 14px;
}

/* ---------- Featured image ---------- */

.post-featured-img {
  width: 100%;
  aspect-ratio: 16/8;
  object-fit: cover;
  border-radius: var(--radius);
  margin: 0 0 40px;
  border: 1px solid var(--border);
}

/* ---------- Share buttons ---------- */

.share-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 28px 0 0;
  margin-top: 28px;
  border-top: 1px solid var(--border);
}
.share-row .label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
}
.share-row a {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 999px;
}
.share-row a:hover { color: var(--amber); border-color: var(--amber); text-decoration: none; }

/* ---------- Search page ---------- */

.search-hint {
  font-family: var(--font-mono);
  color: var(--text-faint);
  font-size: 14px;
  margin-bottom: 30px;
}
mark {
  background: var(--amber);
  color: var(--bg);
  padding: 0 2px;
  border-radius: 2px;
}

/* ---------- Hero ---------- */

.hero {
  padding: 72px 0 56px;
  border-bottom: 1px solid var(--border);
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--teal);
  letter-spacing: 0.04em;
  margin: 0 0 18px;
}
.hero-eyebrow::before { content: "/* "; color: var(--text-faint); }
.hero-eyebrow::after { content: " */"; color: var(--text-faint); }

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(36px, 5.5vw, 58px);
  line-height: 1.08;
  font-weight: 600;
  margin: 0 0 22px;
  max-width: 14ch;
  letter-spacing: -0.01em;
}
.hero h1 em {
  font-style: italic;
  color: var(--amber);
}

.hero-sub {
  font-size: 18px;
  color: var(--text-dim);
  max-width: 52ch;
  margin: 0 0 0;
}

/* ---------- Section labels ---------- */

.section-label {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
  text-transform: lowercase;
  letter-spacing: 0.03em;
  margin: 0 0 24px;
  padding-top: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- Post grid / cards ---------- */

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 40px;
}

.post-card {
  background: var(--bg);
  padding: 28px;
  display: flex;
  flex-direction: column;
  transition: background 0.15s ease;
}
.post-card:hover { background: var(--bg-card); }

.post-card .cat {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  margin: 0 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.post-card .cat .swatch {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
}

.post-card h2 {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.3;
  font-weight: 600;
  margin: 0 0 12px;
}
.post-card h2 a { color: var(--text); }
.post-card h2 a:hover { color: var(--amber); text-decoration: none; }

.post-card p.excerpt {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 18px;
  flex-grow: 1;
}

.post-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  display: flex;
  gap: 14px;
}

/* ---------- Single post ---------- */

.post-header { padding: 56px 0 0; }

.post-header .cat {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--teal);
  margin-bottom: 16px;
  display: block;
}

.post-header h1 {
  font-family: var(--font-display);
  font-size: clamp(30px, 4.5vw, 46px);
  line-height: 1.15;
  font-weight: 600;
  margin: 0 0 20px;
  letter-spacing: -0.01em;
}

.post-header .post-meta { margin-bottom: 40px; }

.sutra-block {
  border-left: 3px solid var(--amber);
  background: var(--bg-alt);
  padding: 26px 28px;
  margin: 0 0 44px;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.sutra-block .label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 10px;
}
.sutra-block p {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 21px;
  line-height: 1.5;
  color: var(--text);
  margin: 0;
}

.post-body { padding-bottom: 64px; }
.post-body p { margin: 0 0 22px; color: var(--text); }
.post-body h3 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  margin: 40px 0 16px;
  color: var(--text);
}
.post-body pre {
  background: #0D0F16;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  overflow-x: auto;
  margin: 0 0 26px;
}
.post-body code {
  font-family: var(--font-mono);
  font-size: 14px;
}
.post-body p code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--amber);
}
.post-body pre code { color: #C9D1D9; background: none; padding: 0; }

/* ---------- Related / footer ---------- */

.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin: 0 0 60px;
}
.related-card {
  border: 1px solid var(--border);
  padding: 20px;
  border-radius: var(--radius);
}
.related-card .cat { font-family: var(--font-mono); font-size: 11px; color: var(--teal); }
.related-card h3 {
  font-family: var(--font-display);
  font-size: 17px;
  margin: 8px 0 0;
}
.related-card h3 a { color: var(--text); }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 40px 0;
  margin-top: 40px;
}
.site-footer .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
.site-footer p {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-faint);
  margin: 0;
}
.site-footer a { color: var(--text-dim); }

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 20px 0 60px;
  font-family: var(--font-mono);
  font-size: 14px;
}
.pagination a, .pagination span {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
}
.pagination a:hover { border-color: var(--amber); color: var(--amber); text-decoration: none; }
.pagination .current { background: var(--amber); color: var(--bg); border-color: var(--amber); }

/* ---------- Category pills ---------- */

.cat-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 40px;
}
.cat-pill {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
}
.cat-pill:hover, .cat-pill.active {
  border-color: var(--amber);
  color: var(--amber);
  text-decoration: none;
}

/* ---------- Empty state ---------- */

.empty-state {
  padding: 60px 0;
  text-align: center;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  .site-header .wrap { flex-wrap: wrap; row-gap: 12px; }
  .site-nav { gap: 16px; flex-wrap: wrap; row-gap: 10px; width: 100%; }
  .nav-search { flex: 1 1 100%; order: 3; }
  .nav-search input { width: 100%; }
  .nav-search input:focus { width: 100%; }
  .hero { padding: 48px 0 40px; }
  .sutra-block p { font-size: 18px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .post-card { transition: none; }
}
