/* ==========================================================================
   Qlibr /dev — Engineering Blog Theme
   Design system from qlibr.com: dark-first, orange accent, Inter font
   ========================================================================== */

/* --- Design Tokens --- */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  --max-width: 720px;
  --radius: 12px;
  --radius-sm: 6px;
  --accent: #ff5c00;
  --accent-hover: #ff7a33;
  --transition: 0.3s ease;
}

[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-panel: #1a1a1a;
  --text: #ffffff;
  --text-muted: #999999;
  --border: #2a2a2a;
  --border-hover: #3a3a3a;
  --code-bg: #141414;
  --tag-bg: #1f1f1f;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-panel: #f3f3f3;
  --text: #0a0a0a;
  --text-muted: #666666;
  --border: #dddddd;
  --border-hover: #cccccc;
  --code-bg: #f5f5f5;
  --tag-bg: #e8e8e8;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  transition: background var(--transition), color var(--transition);
}

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

a:hover {
  color: var(--accent-hover);
}

img {
  max-width: 100%;
  height: auto;
}

/* --- Layout --- */
.site-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* --- Header --- */
.site-header {
  border-bottom: 1px solid var(--border);
  transition: border-color var(--transition);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
}

.site-logo {
  width: 36px;
  height: 36px;
}

.site-name {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.site-dev {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--bg-panel);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.site-nav {
  display: flex;
  gap: 1rem;
}

.nav-link {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  transition: border-color 0.2s ease, color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* --- Hero (Homepage) --- */
.hero {
  padding: 3rem 0 2.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
  transition: border-color var(--transition);
}

.hero h1 {
  font-size: 2.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 0.5rem;
}

.hero .subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.hero .description {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* --- Post Cards --- */
.post-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.post-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.2s ease, transform 0.2s ease, background var(--transition);
}

.post-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.post-card-link {
  display: block;
  padding: 1.5rem;
  color: var(--text);
  text-decoration: none;
}

.post-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.post-card-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.post-card-summary {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 0.75rem;
}

.post-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* --- Tags --- */
.tag {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--tag-bg);
  padding: 0.2rem 0.6rem;
  border-radius: 30px;
  border: 1px solid var(--border);
  transition: border-color 0.2s ease, color 0.2s ease, background var(--transition);
  text-decoration: none;
}

.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- Single Post --- */
.post-header {
  padding: 2.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
  transition: border-color var(--transition);
}

.post-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.post-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.post-summary {
  font-size: 1.1rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 1rem;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* --- Post Content (Prose) --- */
.post-content {
  font-size: 1rem;
  line-height: 1.8;
}

.post-content h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.02em;
}

.post-content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}

.post-content p {
  margin-bottom: 1.25rem;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.post-content li {
  margin-bottom: 0.35rem;
}

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  background: var(--bg-panel);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.post-content strong {
  font-weight: 600;
}

.post-content em {
  font-style: italic;
}

.post-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* --- Code --- */
.post-content code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.post-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Hugo highlight wrapper */
.highlight {
  margin: 1.5rem 0;
}

.highlight pre {
  margin: 0;
}

/* --- Tables --- */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

.post-content th,
.post-content td {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  text-align: left;
}

.post-content th {
  font-weight: 600;
  background: var(--bg-panel);
}

/* --- Post Footer --- */
.post-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.back-link {
  font-size: 0.9rem;
  font-weight: 500;
}

/* --- Page Header (Tag/List pages) --- */
.page-header {
  padding: 2rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.8rem;
  font-weight: 600;
}

/* --- Pagination --- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

.page-num {
  color: var(--text-muted);
}

/* --- Footer --- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: auto;
  transition: border-color var(--transition);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer-links {
  margin-top: 0.5rem;
}

.footer-links a {
  color: var(--text-muted);
}

.footer-links a:hover {
  color: var(--accent);
}

.sep {
  color: var(--border);
  margin: 0 0.3rem;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .header-inner {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .hero h1 {
    font-size: 1.8rem;
  }

  .post-title {
    font-size: 1.5rem;
  }

  main {
    padding: 1.5rem 1rem;
  }
}
