/* PermTrack Blog — standalone stylesheet (served at /blog.css, stable URL) */

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

/* ── CSS Variables ─────────────────────────────────────────────────── */
:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --border:   #2a2d3a;
  --accent:   #4f8ef7;
  --accent2:  #34d399;
  --warn:     #f87171;
  --text:     #e2e8f0;
  --muted:    #64748b;
  --radius:   8px;
  --font:     'Inter', system-ui, sans-serif;
  --sidebar-w: 220px;
  --topbar-h:  52px;
}

[data-theme="light"] {
  --bg:      #f4f6fb;
  --surface: #ffffff;
  --border:  #dde1ea;
  --accent:  #2563eb;
  --accent2: #059669;
  --warn:    #dc2626;
  --text:    #1e293b;
  --muted:   #64748b;
}

/* ── Base ──────────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

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

/* ── Layout ────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ── Topbar (mobile) ───────────────────────────────────────────────── */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 200;
}
.topbar-logo {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.hamburger {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  padding: 4px 10px;
  cursor: pointer;
  line-height: 1.4;
}

/* ── Overlay ───────────────────────────────────────────────────────── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 150;
}
.overlay.show { display: block; }

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 160;
  transition: transform .25s ease;
  overflow: hidden;
}

.sidebar-logo {
  flex-shrink: 0;
  padding: 20px 20px 24px;
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}
.sidebar-logo span {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
  display: block;
  margin-top: 2px;
}

nav {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--muted);
  font-size: 13px;
  transition: color .15s, background .15s;
  border-left: 3px solid transparent;
  text-decoration: none;
}
nav a:hover  { color: var(--text); background: rgba(255,255,255,.04); text-decoration: none; }
nav a.active { color: var(--text); border-left-color: var(--accent); background: rgba(79,142,247,.08); }

.nav-label {
  display: block;
  padding: 16px 20px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: .55;
  pointer-events: none;
  user-select: none;
}

/* ── Theme toggle ──────────────────────────────────────────────────── */
.theme-toggle {
  flex-shrink: 0;
  margin: 8px 20px 16px;
  display: flex;
  align-items: center;
  background: var(--border);
  border-radius: 20px;
  padding: 2px;
  cursor: pointer;
  border: none;
  width: calc(100% - 40px);
}
.theme-toggle-option {
  flex: 1;
  padding: 3px 0;
  border-radius: 14px;
  font-size: 11px;
  text-align: center;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.theme-toggle-option.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}

/* ── Main area ─────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}
.blog-main {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Site footer ───────────────────────────────────────────────────── */
.site-footer {
  flex-shrink: 0;
  padding: 6px 24px 4px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  border-top: 1px solid var(--border);
}
.site-footer a { color: var(--muted); text-decoration: underline; }
.site-footer a:hover { color: var(--text); }

/* ══════════════════════════════════════════════════════════════════
   BLOG POST PAGE
══════════════════════════════════════════════════════════════════ */

.blog-post-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Sticky post header — always visible */
.blog-post-top {
  flex-shrink: 0;
  max-width: 760px;
  padding: 12px 24px 0;
  background: var(--bg);
}

/* Scrollable article body */
.blog-post-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  max-width: 760px;
  padding: 0 24px 48px;
}

/* Back link */
.back-link {
  display: inline-block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
  text-decoration: none;
  transition: color .15s;
}
.back-link:hover { color: var(--accent); text-decoration: none; }

/* Post header */
.post-header { margin-bottom: 8px; }

.post-header-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.post-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.3px;
  color: var(--text);
  margin-bottom: 6px;
}

.post-author-inline {
  opacity: 0.55;
}

.post-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

/* ── Markdown Content ──────────────────────────────────────────────── */
.blog-content {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
}

.blog-content h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 40px 0 16px;
  color: var(--text);
  letter-spacing: -0.2px;
}

.blog-content h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 32px 0 12px;
  color: var(--text);
}

.blog-content h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 24px 0 8px;
  color: var(--text);
}

.blog-content p {
  margin-bottom: 18px;
}

.blog-content p:last-child { margin-bottom: 0; }

.blog-content ul,
.blog-content ol {
  padding-left: 24px;
  margin-bottom: 18px;
}

.blog-content li {
  margin-bottom: 6px;
  line-height: 1.7;
}

.blog-content strong { color: var(--text); font-weight: 600; }

.blog-content em { color: var(--muted); font-style: italic; }

.blog-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .15s;
}
.blog-content a:hover {
  border-bottom-color: var(--accent);
  text-decoration: none;
}

.blog-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* Tables — match app table design */
.blog-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.blog-content thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface);
}

.blog-content tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.blog-content tbody tr:last-child { border-bottom: none; }
.blog-content tbody tr:hover { background: rgba(255,255,255,.03); }
.blog-content tbody td { padding: 10px 14px; }

/* Blockquote */
.blog-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 20px;
  margin: 24px 0;
  background: var(--surface);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--muted);
}

/* Inline code */
.blog-content code {
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
}

/* Code blocks */
.blog-content pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  overflow-x: auto;
  margin: 24px 0;
}
.blog-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
}

/* ══════════════════════════════════════════════════════════════════
   BLOG INDEX PAGE
══════════════════════════════════════════════════════════════════ */

.blog-index-wrapper {
  max-width: 760px;
  padding: 32px 24px 48px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.blog-index-wrapper h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.page-sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 28px;
}

/* Featured card */
.featured-card {
  display: block;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 32px;
  text-decoration: none;
  transition: border-left-color .15s, box-shadow .15s;
}
.featured-card:hover {
  border-left-color: var(--accent2);
  box-shadow: 0 4px 20px rgba(0,0,0,.08);
  text-decoration: none;
}

.featured-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  margin-bottom: 10px;
}

.featured-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 8px;
  letter-spacing: -0.2px;
}

.featured-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.featured-excerpt {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

/* Post cards grid */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.post-card {
  display: block;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
.post-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
  text-decoration: none;
}

.post-card-meta {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.post-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 8px;
}

.post-card-excerpt {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}

/* Related posts */
.related-posts {
  margin-top: 48px;
}

.related-posts h2 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE (≤ 768px)
══════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .topbar { display: flex; }

  .sidebar {
    transform: translateX(100%);
    top: var(--topbar-h);
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border);
    bottom: 0;
    width: min(var(--sidebar-w), 100vw);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-logo { display: none; }

  .main {
    margin-left: 0;
    padding-top: var(--topbar-h);
  }

  .blog-post-wrapper {
    padding: 20px 16px 48px;
  }

  .blog-index-wrapper {
    padding: 20px 16px 48px;
  }

  .post-title { font-size: 22px; }

  .blog-content { font-size: 15px; }
  .blog-content h2 { font-size: 18px; margin-top: 32px; }
  .blog-content h3 { font-size: 15px; }

  .posts-grid { grid-template-columns: 1fr; }

  .site-footer { max-width: none; padding: 16px; }
}
