/*
Theme Name: TechBlog
Theme URI:
Author: Custom
Description: A dark, minimalist theme inspired by iquilezles.org
Version: 2.0
License: GNU General Public License v2 or later
Text Domain: techblog
*/

/* ==================
   CSS Variables (Dark/Light Mode)
   ================== */
:root {
  --bg: #1e1e1e;
  --bg-secondary: #252525;
  --card-bg: #383838;
  --card-hover: #404040;
  --border: #2a2a2a;
  --border-light: #333333;
  --text: #d0d0d0;
  --text-white: #ffffff;
  --text-muted: #8a8a8a;
  --text-meta: #949494;
  --text-desc: #9a9a9a;
  --text-card-count: #a0a0a0;
  --text-link: #c0c0c0;
  --text-nav: #b0b0b0;
  --accent: #ff4040;
  --accent-hover: #cc3333;
  --code-bg: #2d2d2d;
  --pre-bg: #222222;
}

[data-theme="light"] {
  --bg: #f5f5f5;
  --bg-secondary: #e8e8e8;
  --card-bg: #ffffff;
  --card-hover: #f0f0f0;
  --border: #ddd;
  --border-light: #ccc;
  --text: #333333;
  --text-white: #111111;
  --text-muted: #666666;
  --text-meta: #555555;
  --text-desc: #666666;
  --text-card-count: #777777;
  --text-link: #444444;
  --text-nav: #555555;
  --accent: #e03030;
  --accent-hover: #c02020;
  --code-bg: #f0f0f0;
  --pre-bg: #f5f5f5;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  min-height: 100vh;
}

/* ==================
   Typography
   ================== */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-white);
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.5em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

p { margin-bottom: 1.2em; }

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

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

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

/* ==================
   Accessibility: Skip Link
   ================== */
.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.skip-link:focus {
  position: fixed;
  top: 8px;
  left: 8px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 4px;
  z-index: 9999;
  clip: auto;
  width: auto;
  height: auto;
  font-size: 0.875rem;
  font-weight: 600;
}

/* ==================
   Accessibility: Focus Visible
   ================== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
.card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ==================
   Layout
   ================== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ==================
   Header
   ================== */
#masthead {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-light);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

#masthead .header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.site-branding .site-title {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.site-branding .site-title a {
  color: var(--text-white);
}

.site-branding .site-description {
  font-size: 0.78rem;
  color: var(--text-desc);
  margin: 2px 0 0;
}

/* Navigation */
#site-navigation ul {
  list-style: none;
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}

#site-navigation ul li a {
  color: var(--text-nav);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.875rem;
  transition: background 0.2s, color 0.2s;
  display: block;
}

#site-navigation ul li a:hover,
#site-navigation ul li.current-menu-item > a,
#site-navigation ul li.current_page_item > a {
  background: var(--card-bg);
  color: var(--text-white);
}

/* Theme toggle button */
.theme-toggle {
  background: var(--card-bg);
  border: 1px solid var(--border-light);
  color: var(--text-nav);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.2s, color 0.2s;
}

.theme-toggle:hover {
  background: var(--accent);
  color: #fff;
}

/* Search in header */
.header-search .search-form {
  display: flex;
  gap: 6px;
}

.header-search .search-field {
  background: var(--card-bg);
  border: 1px solid #4a4a4a;
  color: var(--text);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  outline: none;
  width: 180px;
  transition: border-color 0.2s, width 0.2s;
}

.header-search .search-field:focus {
  border-color: var(--accent);
  width: 220px;
}

.header-search .search-field::placeholder {
  color: var(--text-muted);
}

.header-search .search-submit {
  background: var(--card-bg);
  color: var(--text-nav);
  border: 1px solid #4a4a4a;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.2s, color 0.2s;
}

.header-search .search-submit:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

/* ==================
   Hero Section
   ================== */
.hero {
  padding: 80px 0 64px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-size: 3rem;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

.hero .hero-description {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 auto;
}

/* ==================
   Cards & Grid
   ================== */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

@media (max-width: 1100px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 24px;
  transition: background 0.25s, transform 0.2s;
  display: block;
  color: var(--text);
}

.card:hover {
  background: var(--card-hover);
  color: var(--text);
  transform: translateY(-2px);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-white);
  margin-bottom: 10px;
  display: block;
}

.card-description {
  font-size: 0.85rem;
  color: var(--text-card-count);
  margin-bottom: 16px;
  line-height: 1.6;
}

.card-count {
  font-size: 0.78rem;
  color: var(--text-card-count);
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
}

/* ==================
   Section Titles
   ================== */
.section {
  padding: 56px 0;
}

.section + .section {
  border-top: 1px solid var(--border);
}

.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-meta);
  margin-bottom: 28px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ==================
   Post List (articles index)
   ================== */
.post-list {
  list-style: none;
}

.post-list-section {
  padding: 24px 0;
}

.post-list-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--bg-secondary);
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.post-list-item:last-child {
  border-bottom: none;
}

.post-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 86px;
}

.post-title-link {
  font-size: 0.95rem;
  color: var(--text-link);
  transition: color 0.2s;
  flex: 1;
  min-width: 0;
}

.post-title-link:hover {
  color: var(--accent);
}

.post-excerpt {
  width: 100%;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding-left: 102px;
}

.post-new-badge {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  padding: 2px 6px;
  border: 1px solid #ff404066;
  border-radius: 4px;
}

.empty-message {
  padding: 40px 0;
  color: var(--text-muted);
}

/* ==================
   Breadcrumbs
   ================== */
.breadcrumbs {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 16px 0 0;
}

.breadcrumbs a {
  color: var(--text-meta);
  transition: color 0.2s;
}

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

.breadcrumb-sep {
  margin: 0 8px;
  color: var(--text-muted);
}

.breadcrumb-current {
  color: var(--text-meta);
}

/* ==================
   Archive / Category view
   ================== */
.archive-header {
  padding: 56px 0 36px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

.archive-header h1 {
  font-size: 2rem;
  margin-bottom: 8px;
}

.archive-description {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ==================
   Single Post
   ================== */
.post-wrapper {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 32px;
}

.post-header {
  padding: 64px 0 40px;
}

.post-header h1 {
  font-size: 2.4rem;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 20px;
}

.post-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-meta);
}

.post-meta-date {
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
}

.post-meta-author {
  color: var(--text-meta);
}

.post-meta-reading-time {
  color: var(--text-muted);
}

.post-meta-cat a {
  color: var(--text-muted);
  background: var(--card-bg);
  padding: 3px 10px;
  border-radius: 4px;
  transition: background 0.2s, color 0.2s;
}

.post-meta-cat a:hover {
  background: var(--accent);
  color: #ffffff;
}

/* Post content typography */
.post-content {
  padding: 8px 0 64px;
  font-size: 1rem;
  line-height: 1.8;
}

.post-content p {
  margin-bottom: 1.5em;
}

.post-content h2 {
  font-size: 1.4rem;
  margin-top: 2.5em;
  margin-bottom: 0.75em;
  padding-top: 1em;
  border-top: 1px solid var(--border);
}

.post-content h3 {
  font-size: 1.15rem;
  margin-top: 1.8em;
  margin-bottom: 0.5em;
}

.post-content h4 {
  font-size: 1rem;
  margin-top: 1.5em;
  margin-bottom: 0.5em;
  color: var(--text-nav);
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 28px 0;
  display: block;
}

.post-content figure {
  margin: 28px 0;
}

.post-content figcaption {
  font-size: 0.82rem;
  color: var(--text-meta);
  text-align: center;
  margin-top: 10px;
}

.post-content a {
  color: var(--text-nav);
  text-decoration: underline;
  text-decoration-color: #444444;
}

.post-content a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.post-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 20px;
  margin: 24px 0;
  color: var(--text-card-count);
  font-style: italic;
}

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

.post-content li {
  margin-bottom: 0.5em;
}

.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5em;
  font-size: 0.9rem;
}

.post-content th,
.post-content td {
  border: 1px solid var(--border-light);
  padding: 8px 14px;
  text-align: left;
}

.post-content th {
  background: var(--card-bg);
  color: var(--text-white);
  font-weight: 600;
}

.post-content tr:nth-child(even) td {
  background: var(--bg-secondary);
}

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

/* Responsive tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1.5em;
}

.table-responsive table {
  margin-bottom: 0;
}

/* Code */
code {
  font-family: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', 'Courier New', monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  color: #e0e0e0;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #3a3a3a;
}

pre {
  background: var(--pre-bg) !important;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 20px 24px;
  overflow-x: auto;
  margin: 24px 0;
  line-height: 1.6;
}

pre code {
  background: none !important;
  padding: 0;
  border: none;
  border-radius: 0;
  font-size: 0.875rem;
  color: #e0e0e0;
}

/* ==================
   Table of Contents
   ================== */
.toc {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 24px 28px;
  margin-bottom: 32px;
  border: 1px solid var(--border-light);
}

.toc-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-meta);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc li {
  margin-bottom: 6px;
}

.toc li a {
  font-size: 0.88rem;
  color: var(--text-link);
  transition: color 0.2s;
}

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

.toc .toc-level-3 {
  padding-left: 16px;
}

.toc .toc-level-3 a {
  font-size: 0.82rem;
}

/* ==================
   Tags
   ================== */
.post-tags {
  padding: 16px 0 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.post-tags-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.post-tags a {
  display: inline-block;
  background: var(--card-bg);
  color: var(--text-meta);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  transition: background 0.2s, color 0.2s;
}

.post-tags a:hover {
  background: var(--accent);
  color: #fff;
}

/* ==================
   Share Buttons
   ================== */
.share-buttons {
  padding: 24px 0;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.share-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.share-btn {
  display: inline-block;
  background: var(--card-bg);
  color: var(--text-meta);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.78rem;
  transition: background 0.2s, color 0.2s;
}

.share-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ==================
   Related Posts
   ================== */
.related-posts {
  padding: 32px 0;
  border-top: 1px solid var(--border);
}

.related-posts .section-title {
  font-size: 0.75rem;
}

/* ==================
   Post Navigation
   ================== */
.post-navigation {
  padding: 32px 0 64px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  border-top: 1px solid var(--border);
}

.post-nav-prev,
.post-nav-next {
  padding: 16px 20px;
  background: var(--card-bg);
  border-radius: 8px;
  transition: background 0.2s;
}

.post-nav-next {
  text-align: right;
}

.post-nav-prev:hover,
.post-nav-next:hover {
  background: var(--card-hover);
}

.post-nav-label {
  font-size: 0.72rem;
  color: var(--text-meta);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.post-nav-title {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.4;
}

/* ==================
   Footer
   ================== */
#colophon {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding: 32px 0;
  text-align: center;
}

.footer-widgets {
  display: flex;
  gap: 32px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 24px;
  text-align: left;
}

.footer-widgets .widget {
  flex: 1;
  min-width: 200px;
  max-width: 300px;
}

.footer-widgets .widget-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-meta);
  margin-bottom: 12px;
}

.site-info {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.site-info a {
  color: var(--text-desc);
}

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

.footer-tagline {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
  font-style: italic;
}

/* ==================
   Search Results
   ================== */
.search-form-large {
  display: flex;
  gap: 8px;
  margin-top: 24px;
}

.search-form-large .search-field {
  background: var(--card-bg);
  border: 1px solid #4a4a4a;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 0.95rem;
  outline: none;
  flex: 1;
  transition: border-color 0.2s;
}

.search-form-large .search-field:focus {
  border-color: var(--accent);
}

.search-form-large .search-field::placeholder {
  color: var(--text-muted);
}

.search-form-large .search-submit {
  background: var(--accent);
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.2s;
}

.search-form-large .search-submit:hover {
  background: var(--accent-hover);
}

/* ==================
   404 Page
   ================== */
.not-found-section {
  padding: 100px 0;
  text-align: center;
}

.not-found-code {
  font-size: 7rem;
  font-weight: 800;
  color: #2d2d2d;
  line-height: 1;
  display: block;
  margin-bottom: 16px;
}

.not-found-section h2 {
  font-size: 1.5rem;
  margin-bottom: 12px;
}

.not-found-section p {
  color: var(--text-desc);
  margin-bottom: 32px;
}

.btn {
  display: inline-block;
  background: var(--card-bg);
  color: var(--text);
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: background 0.2s, color 0.2s;
}

.btn:hover {
  background: var(--accent);
  color: #ffffff;
}

/* ==================
   Pagination
   ================== */
.pagination {
  padding: 32px 0 16px;
  display: flex;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pagination .page-numbers {
  padding: 8px 14px;
  background: var(--card-bg);
  border-radius: 6px;
  color: var(--text-link);
  font-size: 0.875rem;
  transition: background 0.2s, color 0.2s;
  display: inline-block;
}

.pagination .page-numbers:hover,
.pagination .page-numbers.current {
  background: var(--accent);
  color: #ffffff;
}

/* ==================
   Utilities
   ================== */
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0 !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* ==================
   Print Stylesheet
   ================== */
@media print {
  body {
    background: #fff;
    color: #000;
  }

  #masthead,
  #colophon,
  .post-navigation,
  .share-buttons,
  .related-posts,
  .toc,
  .breadcrumbs,
  .post-tags,
  .header-search,
  .theme-toggle,
  .pagination {
    display: none;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  pre {
    background: #f5f5f5 !important;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }

  .post-wrapper {
    max-width: 100%;
    padding: 0;
  }

  .post-header {
    padding-top: 0;
  }

  h1, h2, h3, h4, h5, h6 {
    color: #000;
    page-break-after: avoid;
  }
}

/* ==================
   Responsive
   ================== */
@media (max-width: 900px) {
  .post-wrapper {
    padding: 0 20px;
  }

  .post-header h1 {
    font-size: 1.8rem;
  }

  .post-navigation {
    grid-template-columns: 1fr;
  }

  .post-excerpt {
    padding-left: 0;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }

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

  #masthead .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .header-search {
    width: 100%;
  }

  .header-search .search-form {
    width: 100%;
  }

  .header-search .search-field {
    width: 100%;
  }

  .share-buttons {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .post-list-item {
    flex-wrap: wrap;
    gap: 4px;
  }

  .post-date {
    min-width: auto;
  }

  .post-excerpt {
    padding-left: 0;
  }
}
