/* ==========================================================================
   Lagrange Engineering — Ghost theme
   Matches lagrangeengineering.ro: dark-first, dashed borders, mono accents,
   industrial green. Light + dark via prefers-color-scheme.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --fg: #0e0e10;
  --muted: #71717a;
  --muted-2: #a1a1aa;
  --border: #e4e4e7;
  --border-dashed: #d4d4d8;
  --card: #ffffff;
  --card-hover: #fafafa;
  --primary: #15846a;
  --primary-fg: #ffffff;
  --code-bg: #f4f4f5;
  --radius: 10px;
  --maxw: 1180px;
  --maxw-prose: 720px;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.site-wrap { display: flex; flex-direction: column; min-height: 100vh; }
.site-main { flex: 1 0 auto; padding: 48px 0 80px; }

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px dashed var(--border-dashed);
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
}
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  padding-bottom: 18px;
}

/* Shared mono header links — same treatment both sides for balance */
.header-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color .2s;
}
.header-link:hover { color: var(--primary); }
.back-arrow { font-size: 15px; transition: transform .2s; }
.back-to-site:hover .back-arrow { transform: translateX(-3px); }

.site-right { display: flex; align-items: center; gap: 18px; }
.header-divider { width: 1px; height: 22px; background: var(--border-dashed); }
.site-brand { display: inline-flex; align-items: center; }
.site-logo { height: 50px; width: auto; }

@media (max-width: 640px) {
  .back-label { display: none; }
  .site-right { gap: 14px; }
  .site-logo { height: 38px; }
}

/* ---------- Page head ---------- */
.page-head { padding: 32px 0 48px; }
.page-head-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--primary);
}
.page-head-title {
  font-size: clamp(2rem, 5vw, 3.25rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 12px 0 0;
  line-height: 1.05;
}
.page-head-title .accent { color: var(--primary); }
.page-head-desc { margin: 16px 0 0; max-width: 620px; color: var(--muted); font-size: 1.05rem; }

/* ---------- Post grid ---------- */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border-dashed);
  border: 1px dashed var(--border-dashed);
}
@media (max-width: 900px) { .post-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .post-grid { grid-template-columns: 1fr; } }

.post-card { background: var(--bg); transition: background .2s; }
.post-card:hover { background: var(--card-hover); }
.post-card-link { display: block; padding: 16px; height: 100%; }

.post-card-image-wrap {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--code-bg);
  margin-bottom: 16px;
}
.post-card-image { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.post-card:hover .post-card-image { transform: scale(1.05); }
.post-card-image-fallback { width: 100%; height: 100%; background: radial-gradient(circle at center, color-mix(in srgb, var(--primary) 15%, transparent), transparent 70%); }

/* Corner brackets on images */
.bracket { position: absolute; width: 12px; height: 12px; border-color: var(--muted-2); opacity: .45; }
.bracket.tl { top: 6px; left: 6px; border-top: 1px solid; border-left: 1px solid; }
.bracket.tr { top: 6px; right: 6px; border-top: 1px solid; border-right: 1px solid; }
.bracket.bl { bottom: 6px; left: 6px; border-bottom: 1px solid; border-left: 1px solid; }
.bracket.br { bottom: 6px; right: 6px; border-bottom: 1px solid; border-right: 1px solid; }

.post-card-meta,
.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted-2);
  margin-bottom: 10px;
}
.post-card-meta .sep, .post-meta .sep { color: var(--border-dashed); }
.post-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.post-card:hover .post-card-title { color: var(--primary); }
.post-card-excerpt {
  margin: 0;
  font-size: .9rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }

.tag-pill {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 500;
  color: var(--muted);
  border: 1px dashed var(--border-dashed);
  padding: 3px 8px;
  transition: color .2s, border-color .2s;
}
a.tag-pill:hover { color: var(--primary); border-color: var(--primary); }

/* ---------- Single post ---------- */
.post { max-width: var(--maxw-prose); }
.post-header { padding: 16px 0 28px; }
.post-meta { font-size: 11px; margin-bottom: 18px; }
.post-meta-tag { color: var(--primary); }
.post-title {
  font-size: clamp(1.9rem, 4.5vw, 2.9rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.08;
  margin: 0;
}
.post-subtitle { margin: 16px 0 0; font-size: 1.2rem; color: var(--muted); line-height: 1.5; }

.post-feature-image {
  position: relative;
  margin: 0 0 40px;
  overflow: hidden;
  border-radius: var(--radius);
}
.post-feature-image img { width: 100%; }

/* ---------- Prose / gh-content ---------- */
.gh-content { font-size: 1.08rem; line-height: 1.75; }
.gh-content > * + * { margin-top: 1.5em; }
.gh-content h2, .gh-content h3, .gh-content h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-top: 2em;
  margin-bottom: 0.6em;
}
.gh-content h2 { font-size: 1.6rem; }
.gh-content h3 { font-size: 1.3rem; }
.gh-content h4 { font-size: 1.1rem; }
.gh-content a { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.gh-content a:hover { text-decoration-thickness: 2px; }
.gh-content strong { font-weight: 600; }
.gh-content ul, .gh-content ol { padding-left: 1.4em; }
.gh-content li + li { margin-top: 0.4em; }
.gh-content img { border-radius: var(--radius); margin-left: auto; margin-right: auto; }
.gh-content figcaption {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 10px;
}
.gh-content blockquote {
  margin: 1.5em 0;
  padding: 4px 0 4px 20px;
  border-left: 2px dashed var(--primary);
  color: var(--muted);
  font-style: italic;
}
.gh-content hr { border: none; border-top: 1px dashed var(--border-dashed); margin: 2.5em 0; }
.gh-content code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
}
.gh-content pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  background: var(--code-bg);
  border: 1px dashed var(--border-dashed);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
}
.gh-content pre code { background: none; border: none; padding: 0; font-size: inherit; }
.gh-content table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.gh-content th, .gh-content td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.gh-content th { font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }

/* Koenig cards */
.kg-card { margin-top: 1.5em; }
.kg-width-wide { width: min(110%, 100vw); margin-left: 50%; transform: translateX(-50%); max-width: 1000px; }
.kg-width-full { width: 100vw; margin-left: 50%; transform: translateX(-50%); border-radius: 0; }
.kg-embed-card, .kg-gallery-card { display: flex; justify-content: center; }
.kg-bookmark-card a { text-decoration: none; }
.kg-bookmark-container {
  display: flex;
  border: 1px dashed var(--border-dashed);
  border-radius: var(--radius);
  overflow: hidden;
  color: var(--fg);
}
.kg-bookmark-content { padding: 18px 20px; }
.kg-bookmark-title { font-weight: 600; }
.kg-bookmark-description { color: var(--muted); font-size: 0.9rem; margin-top: 6px; }

/* ---------- Post footer ---------- */
.post-footer {
  margin-top: 48px;
  padding-top: 28px;
  border-top: 1px dashed var(--border-dashed);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.post-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.back-to-blog {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--primary);
  align-self: flex-start;
}
.back-to-blog:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 48px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.pagination a {
  color: var(--fg);
  border: 1px dashed var(--border-dashed);
  border-radius: var(--radius);
  padding: 8px 16px;
  transition: color .2s, border-color .2s;
}
.pagination a:hover { color: var(--primary); border-color: var(--primary); border-style: solid; }
.pagination .page-number { color: var(--muted); }

/* ---------- Empty / error ---------- */
.empty-state { color: var(--muted); text-align: center; padding: 80px 0; }
.error-page { text-align: center; padding: 100px 24px; }
.error-code { font-family: var(--font-mono); font-size: 14px; color: var(--primary); letter-spacing: 0.2em; }
.error-title { font-size: 2rem; font-weight: 600; margin: 12px 0 28px; letter-spacing: -0.02em; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px dashed var(--border-dashed); flex-shrink: 0; }
.site-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 24px;
  padding-bottom: 24px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.footer-link:hover { color: var(--primary); }
