/* assets/css/style.css */

/* === Font Faces === */
@font-face {
  font-family: 'Operator Mono';
  src: url('../fonts/OperatorMono-Book.woff2') format('woff2'),
       url('../fonts/OperatorMono-Book.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Operator Mono';
  src: url('../fonts/OperatorMono-BookItalic.woff2') format('woff2'),
       url('../fonts/OperatorMono-BookItalic.otf') format('opentype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: 'Operator Mono';
  src: url('../fonts/OperatorMono-Medium.woff2') format('woff2'),
       url('../fonts/OperatorMono-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* === CSS Custom Properties: Dark (default) === */
:root {
  --bg: #1a1209;
  --surface: #2e2218;
  --border: #3d2e1f;
  --text-primary: #e8d5c4;
  --text-secondary: #8b7355;
  --text-muted: #6b5744;
  --accent: #c4753b;
  --accent-hover: #d4854b;
  --code-bg: #2c1810;
  --code-header-bg: #2e2218;
  --card-shadow: rgba(0, 0, 0, 0.2);
  --featured-gradient-start: #2e2218;
  --featured-gradient-end: #1a1209;
}

/* === Light Mode === */
[data-theme="light"] {
  --bg: #fdf6ee;
  --surface: #f5ebe0;
  --border: #ecdcc8;
  --text-primary: #2c1810;
  --text-secondary: #6b5744;
  --text-muted: #a0896e;
  --accent: #c4753b;
  --accent-hover: #b5652b;
  --code-bg: #2c1810;
  --code-header-bg: #3d3228;
  --card-shadow: rgba(120, 80, 40, 0.08);
  --featured-gradient-start: #2c1810;
  --featured-gradient-end: #1a1209;
}

/* Light mode code blocks toggled to latte */
[data-theme="light"] .code-block[data-code-theme="latte"] {
  --code-bg: #f5ebe0;
  --code-header-bg: #ecdcc8;
}

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

body {
  font-family: 'Open Sans', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Montserrat', sans-serif;
  line-height: 1.3;
}

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

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

/* === Nav === */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  max-width: 1200px;
  margin: 0 auto;
}
.nav-logo {
  font-family: 'Montserrat', sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  text-decoration: none;
}
.nav-right { display: flex; align-items: center; gap: 20px; }
.nav-links { display: flex; gap: 20px; font-size: 14px; }
.nav-links a { color: var(--text-secondary); font-weight: 500; }
.nav-links a:hover { color: var(--text-primary); }
.nav-links .rss-link { color: var(--accent); }

/* Theme toggle */
.theme-toggle {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; font-size: 16px; color: var(--text-muted);
}
.theme-toggle-track {
  width: 40px; height: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  position: relative;
  transition: background 0.3s;
}
.theme-toggle-thumb {
  width: 18px; height: 18px;
  background: var(--accent);
  border-radius: 50%;
  position: absolute; top: 1px; left: 1px;
  transition: transform 0.3s;
}
[data-theme="light"] .theme-toggle-thumb { transform: translateX(18px); }

/* === Category Tabs === */
.category-tabs {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.cat-tab {
  font-family: 'Montserrat', sans-serif;
  font-size: 12px; font-weight: 600;
  padding: 6px 14px; border-radius: 8px;
  cursor: pointer; border: 1px solid var(--border);
  background: transparent; color: var(--text-secondary);
  transition: all 0.2s;
}
.cat-tab:hover { border-color: var(--accent); color: var(--accent); }
.cat-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* === Featured Post === */
.featured-post {
  background: linear-gradient(135deg, var(--featured-gradient-start), var(--featured-gradient-end));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  margin-bottom: 24px;
}
.featured-label {
  font-family: 'Montserrat', sans-serif;
  font-size: 10px; font-weight: 700;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--accent); margin-bottom: 10px;
}
.featured-post .post-title {
  font-size: 22px; font-weight: 700;
  color: #e8d5c4;
  margin-bottom: 8px;
}
.featured-post .post-title a { color: #e8d5c4; }
.featured-post .post-excerpt { font-size: 14px; color: #8b7355; line-height: 1.6; }

/* === Post List === */
.post-list { list-style: none; }
.post-list-item {
  display: flex; gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.post-list-item .info { flex: 1; }
.post-list-item .post-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 15px; font-weight: 600;
  margin-bottom: 4px;
}
.post-list-item .post-title a { color: var(--text-primary); }
.post-list-item .post-title a:hover { color: var(--accent); }
.post-list-item .post-meta {
  font-size: 12px; color: var(--text-muted);
}
.post-list-item .thumb {
  width: 64px; height: 48px;
  border-radius: 8px; flex-shrink: 0;
  background: var(--surface);
  object-fit: cover;
}

/* === Content Container === */
.content-wrap { max-width: 720px; margin: 0 auto; padding: 48px 24px; }

/* === Single Post === */
.post-badges { display: flex; gap: 8px; margin-bottom: 14px; }
.badge {
  font-family: 'Montserrat', sans-serif;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase;
  padding: 3px 10px; border-radius: 4px;
}
.badge-primary { background: var(--accent); color: #fff; }
.badge-secondary { background: var(--surface); color: var(--accent); }

.post-header .post-title {
  font-size: 34px; font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 14px;
}
.post-byline {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--text-muted);
  margin-bottom: 28px;
}
.post-byline .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: 'Montserrat', sans-serif;
  font-weight: 700; font-size: 12px;
}
.post-byline .author-name { font-weight: 600; color: var(--text-secondary); }

.post-featured-image {
  width: 100%; border-radius: 14px;
  margin-bottom: 36px;
  box-shadow: 0 4px 20px var(--card-shadow);
}

/* === Article Body === */
.article-body { font-size: 16px; line-height: 1.85; color: var(--text-primary); }
.article-body p { margin-bottom: 18px; }
.article-body h2 { font-size: 24px; font-weight: 700; margin: 36px 0 14px; }
.article-body h3 { font-size: 20px; font-weight: 600; margin: 28px 0 12px; }
.article-body strong { color: var(--text-primary); }
.article-body ul, .article-body ol { margin: 0 0 18px 24px; }
.article-body li { margin-bottom: 6px; }
.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 20px; margin: 24px 0;
  background: var(--surface); border-radius: 0 8px 8px 0;
  font-style: italic; color: var(--text-secondary);
}
.article-body img {
  border-radius: 10px;
  margin: 24px 0;
}
.article-body a { color: var(--accent); text-decoration: underline; }

/* Inline code */
.article-body code:not(pre code) {
  font-family: 'Operator Mono', monospace;
  background: var(--code-bg);
  color: #e8a87c;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}
[data-theme="light"] .article-body code:not(pre code) {
  background: var(--surface);
  color: #b5532e;
  border: 1px solid var(--border);
}

/* === Code Blocks === */
.code-block {
  border-radius: 12px;
  overflow: hidden;
  margin: 24px 0;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px var(--card-shadow);
}
.code-block .code-header {
  background: var(--code-header-bg);
  padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.code-dots { display: flex; gap: 6px; }
.code-dots span { width: 10px; height: 10px; border-radius: 50%; }
.code-dot-red { background: #e85d4a; }
.code-dot-yellow { background: #d4a843; }
.code-dot-green { background: #5a7a2e; }
.code-header-right { display: flex; align-items: center; gap: 12px; }
.code-lang {
  font-family: 'Montserrat', sans-serif;
  font-size: 10px; font-weight: 600;
  letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-muted);
}
.code-copy-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 12px;
  padding: 2px 6px; border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}
.code-copy-btn:hover { color: var(--accent); background: rgba(196, 117, 59, 0.1); }
.code-theme-toggle {
  background: none; border: 1px solid var(--text-muted); cursor: pointer;
  color: var(--text-muted); font-size: 10px;
  width: 18px; height: 18px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
}
[data-theme="light"] .code-theme-toggle { display: flex; }

.code-block pre {
  background: var(--code-bg);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 0;
  transition: background 0.3s;
}
.code-block pre code {
  font-family: 'Operator Mono', monospace;
  font-size: 14px;
  line-height: 1.7;
  color: #e8d5c4;
}

/* === Tags Section === */
.tags-section {
  border-top: 1px solid var(--border);
  padding: 24px 0; margin-top: 24px;
}
.tags-label {
  font-family: 'Montserrat', sans-serif;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: var(--text-muted); margin-bottom: 12px;
}
.tags-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-pill {
  font-size: 12px; color: var(--text-secondary);
  background: var(--surface); padding: 5px 12px;
  border-radius: 6px; font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
.tag-pill:hover { background: var(--accent); color: #fff; }

/* === Author Bio === */
.author-bio {
  background: var(--surface);
  border-radius: 14px; padding: 22px;
  display: flex; gap: 18px; align-items: center;
  margin: 32px 0; border: 1px solid var(--border);
}
.author-bio .avatar-lg {
  width: 56px; height: 56px;
  border-radius: 50%; flex-shrink: 0;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: 'Montserrat', sans-serif;
  font-weight: 700; font-size: 18px;
}
.author-bio .author-name {
  font-family: 'Montserrat', sans-serif;
  font-size: 15px; font-weight: 700; color: var(--text-primary);
}
.author-bio .author-desc {
  font-size: 13px; color: var(--text-muted); margin-top: 4px; line-height: 1.5;
}

/* === Related Posts === */
.related-section {
  background: var(--surface);
  padding: 44px 24px;
}
.related-inner { max-width: 720px; margin: 0 auto; }
.related-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 20px; font-weight: 800;
  color: var(--text-primary); margin-bottom: 6px;
}
.related-subtitle { font-size: 13px; color: var(--text-muted); margin-bottom: 22px; }
.related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.related-card {
  background: var(--bg);
  border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px var(--card-shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
}
.related-card:hover { transform: translateY(-3px); box-shadow: 0 6px 20px var(--card-shadow); }
.related-card .card-img { height: 100px; background: var(--surface); object-fit: cover; width: 100%; }
.related-card .card-body { padding: 14px; }
.related-card .card-cat {
  font-family: 'Montserrat', sans-serif;
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--accent); margin-bottom: 5px;
}
.related-card .card-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 13px; font-weight: 700;
  color: var(--text-primary); line-height: 1.4;
}
.related-card .card-date { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* === Prev/Next === */
.prev-next {
  display: flex; justify-content: space-between;
  max-width: 720px; margin: 0 auto; padding: 24px;
}
.prev-next a {
  color: var(--text-secondary); font-size: 13px; font-weight: 500;
  text-decoration: none;
}
.prev-next a:hover { color: var(--accent); }
.prev-next .link-title { color: var(--text-primary); font-weight: 600; }

/* === Pagination === */
.pagination {
  display: flex; justify-content: center; gap: 8px;
  padding: 32px 0;
}
.pagination a, .pagination span {
  font-family: 'Montserrat', sans-serif;
  font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.pagination a:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current { background: var(--accent); color: #fff; border-color: var(--accent); }

/* === Footer === */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 32px; text-align: center;
  font-size: 12px; color: var(--text-muted);
}

/* === Tags Index Page === */
.tags-cloud { display: flex; flex-wrap: wrap; gap: 10px; }
.tags-cloud .tag-pill { font-size: 14px; padding: 8px 16px; }
.tags-cloud .tag-count { font-size: 11px; color: var(--text-muted); margin-left: 4px; }

/* === 404 === */
.error-page {
  text-align: center; padding: 80px 24px;
}
.error-page h1 { font-size: 72px; color: var(--accent); margin-bottom: 12px; }
.error-page p { font-size: 18px; color: var(--text-secondary); }

/* === Responsive === */
@media (max-width: 768px) {
  .nav { padding: 14px 16px; }
  .content-wrap { padding: 32px 16px; }
  .post-header .post-title { font-size: 26px; }
  .related-grid { grid-template-columns: 1fr; }
  .prev-next { flex-direction: column; gap: 12px; }
  .featured-post { padding: 20px; }
}
