/*
Theme Name: IT HomeLab
Theme URI: https://ithomelab.online
Author: Graeme
Author URI: https://ithomelab.online
Description: A dark-mode WordPress theme for homelab, Raspberry Pi, AI and automation content.
Version: 1.0
Requires at least: 6.4
Tested up to: 6.7
Requires PHP: 8.0
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: ithomelab
Tags: dark, blog, custom-menu, featured-images, threaded-comments
*/

/* =========================================================
   CSS CUSTOM PROPERTIES
   ========================================================= */
:root {
  --bg:          #0d1117;
  --bg2:         #161b22;
  --bg3:         #1c2128;
  --border:      #30363d;
  --accent:      #00d4aa;
  --accent2:     #3b82f6;
  --warn:        #f59e0b;
  --danger:      #ef4444;
  --text:        #e6edf3;
  --text-muted:  #8b949e;
  --radius:      8px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Sora', sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

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

a:hover {
  color: #00ffcc;
}

ul, ol {
  padding-left: 1.5rem;
}

/* =========================================================
   TYPOGRAPHY
   ========================================================= */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Sora', sans-serif;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 0.75rem;
}

h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: clamp(1.15rem, 2.5vw, 1.5rem); }
h4 { font-size: 1.15rem; }

h2 {
  position: relative;
  padding-left: 1rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
}

h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
}

p {
  margin-bottom: 1.25rem;
}

strong { color: var(--text); font-weight: 700; }
em { font-style: italic; }

/* =========================================================
   NAVIGATION
   ========================================================= */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.site-logo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text) !important;
  text-decoration: none;
}

.site-logo span {
  color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-links li a,
.tab-btn {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
  border: 1px solid transparent;
}

.nav-links li a:hover,
.tab-btn:hover,
.nav-links li.current-menu-item > a,
.nav-links li.current_page_item > a {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border);
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px;
}

.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.hamburger.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger.active span:nth-child(2) {
  opacity: 0;
}
.hamburger.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem 1.5rem;
    gap: 0.25rem;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links li {
    width: 100%;
  }

  .nav-links li a {
    display: block;
    width: 100%;
  }
}

/* =========================================================
   LAYOUT WRAPPERS
   ========================================================= */
.site-main {
  min-height: calc(100vh - 60px - 120px);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.content-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* =========================================================
   HERO SECTION (Archive / Index)
   ========================================================= */
.hero {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 3.5rem 1.5rem 3rem;
  text-align: center;
}

.hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin-bottom: 0.75rem;
}

.hero h1 span {
  color: var(--accent);
}

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

/* =========================================================
   BLOG CARD GRID
   ========================================================= */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

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

.post-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.2s ease, transform 0.2s ease;
  text-decoration: none;
  color: inherit;
}

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

.post-card .card-tag {
  align-self: flex-start;
}

.post-card h2 {
  font-size: 1.15rem;
  margin: 0;
  padding: 0;
  color: var(--text);
}

.post-card h2::before {
  display: none;
}

.post-card .card-excerpt {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.6;
  flex: 1;
  margin: 0;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}

.card-read-more {
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 600;
}

/* =========================================================
   TAG BADGES
   ========================================================= */
.tag-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
  background: rgba(0, 212, 170, 0.12);
  color: var(--accent);
  border: 1px solid rgba(0, 212, 170, 0.3);
}

.tag-badge.tag-warn {
  background: rgba(245, 158, 11, 0.12);
  color: var(--warn);
  border-color: rgba(245, 158, 11, 0.3);
}

.tag-badge.tag-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}

.tag-badge.tag-info {
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent2);
  border-color: rgba(59, 130, 246, 0.3);
}

/* =========================================================
   POST META BAR
   ========================================================= */
.post-meta-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.post-meta-bar .tag-badge {
  margin-right: 0.25rem;
}

.post-meta-bar .meta-sep {
  color: var(--border);
}

/* =========================================================
   SINGLE POST
   ========================================================= */
.post-title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin-bottom: 0.5rem;
  padding-left: 0;
}

.post-title::before {
  display: none;
}

.post-subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  line-height: 1.6;
}

.post-content {
  margin-top: 2rem;
}

.post-content p,
.post-content li {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
}

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

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

/* =========================================================
   CODE BLOCKS
   ========================================================= */
pre {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
}

.code-block {
  position: relative;
  margin: 1.5rem 0;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}

.code-block .copy-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: all 0.2s;
}

.code-block .copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.code-block .copy-btn.copied {
  border-color: var(--accent);
  color: var(--accent);
}

.code-block pre {
  border-radius: 0 0 var(--radius) var(--radius);
  margin: 0;
}

pre code,
.code-block code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.7;
  color: #79c0ff;
  display: block;
  padding: 1.25rem;
  white-space: pre;
}

/* Inline code */
p code,
li code,
td code,
h3 code,
h4 code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875em;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  color: #79c0ff;
}

/* =========================================================
   CALLOUT BLOCKS
   ========================================================= */
.callout {
  border-radius: var(--radius);
  border-left: 4px solid;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}

.callout-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.callout-icon {
  font-size: 1rem;
}

.callout-body {
  font-size: 0.95rem;
  line-height: 1.7;
}

.callout-body p:last-child { margin-bottom: 0; }

/* Warn */
.callout.callout-warn {
  background: rgba(245, 158, 11, 0.08);
  border-color: var(--warn);
}
.callout.callout-warn .callout-header { color: var(--warn); }

/* Danger */
.callout.callout-danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: var(--danger);
}
.callout.callout-danger .callout-header { color: var(--danger); }

/* Info */
.callout.callout-info {
  background: rgba(59, 130, 246, 0.08);
  border-color: var(--accent2);
}
.callout.callout-info .callout-header { color: var(--accent2); }

/* Tip */
.callout.callout-tip {
  background: rgba(0, 212, 170, 0.08);
  border-color: var(--accent);
}
.callout.callout-tip .callout-header { color: var(--accent); }

/* =========================================================
   STEP BLOCKS
   ========================================================= */
.step-block {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.step-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  background: var(--accent);
  color: #0d1117;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  font-weight: 700;
  border-radius: 50%;
}

.step-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
}

.step-body {
  font-size: 0.95rem;
  line-height: 1.7;
}

.step-body p:last-child { margin-bottom: 0; }

/* =========================================================
   REQUIREMENTS GRID
   ========================================================= */
.requirements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.req-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.req-card .req-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.req-card .req-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
}

.req-card .req-detail {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* =========================================================
   VIDEO EMBED
   ========================================================= */
.video-embed {
  margin: 2rem 0;
}

.video-embed-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.video-ratio {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg3);
}

.video-ratio iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* =========================================================
   CONCLUSION BOX
   ========================================================= */
.conclusion-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  margin: 3rem 0 2rem;
}

.conclusion-box h3 {
  color: var(--accent);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
}

.conclusion-box p {
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0;
}

/* =========================================================
   CTA STRIP
   ========================================================= */
.cta-strip {
  background: linear-gradient(135deg, rgba(0,212,170,0.08) 0%, rgba(59,130,246,0.08) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin: 2rem 0;
  text-align: center;
}

.cta-strip h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.cta-strip p {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #0d1117;
  font-weight: 700;
  font-size: 0.925rem;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
}

.cta-btn:hover {
  background: #00ffcc;
  color: #0d1117;
  transform: translateY(-1px);
}

/* =========================================================
   RELATED POSTS GRID
   ========================================================= */
.related-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.related-section h2 {
  margin-bottom: 1.5rem;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

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

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

.related-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.related-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  color: inherit;
}

.related-card .tag-badge {
  align-self: flex-start;
}

.related-card h3 {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.4;
  margin: 0;
}

.related-card .card-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: auto;
}

/* =========================================================
   ANALYSIS CARDS
   ========================================================= */
.analysis-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0;
}

.analysis-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.analysis-card .card-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.analysis-card .card-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
}

.analysis-card .card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* =========================================================
   ARCHIVE HEADER
   ========================================================= */
.archive-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 2.5rem 1.5rem;
  text-align: center;
}

.archive-header h1 {
  margin-bottom: 0.5rem;
}

.archive-header p {
  color: var(--text-muted);
  margin: 0;
}

/* =========================================================
   PAGINATION
   ========================================================= */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  padding: 2rem 1.5rem;
}

.pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text-muted);
  font-size: 0.875rem;
  text-decoration: none;
  transition: all 0.2s;
}

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

/* =========================================================
   FOOTER
   ========================================================= */
.site-footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.site-footer a {
  color: var(--text-muted);
  transition: color 0.2s;
}

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

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
  padding: 0;
}

/* =========================================================
   404 PAGE
   ========================================================= */
.not-found-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 3rem 1.5rem;
}

.not-found-wrap .error-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(5rem, 15vw, 10rem);
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 1rem;
  opacity: 0.8;
}

.not-found-wrap h1 {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  margin-bottom: 1rem;
}

.not-found-wrap p {
  color: var(--text-muted);
  max-width: 480px;
  margin-bottom: 2rem;
}

/* =========================================================
   PAGE TEMPLATE
   ========================================================= */
.page-content {
  max-width: 860px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.page-content .entry-title {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

/* =========================================================
   SIDEBAR / WIDGETS
   ========================================================= */
.widget {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.widget-title {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

/* =========================================================
   SCROLL TO TOP
   ========================================================= */
#scroll-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 42px;
  height: 42px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 500;
}

#scroll-top:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#scroll-top.visible {
  display: flex;
}

/* =========================================================
   GUTENBERG EDITOR OVERRIDES
   ========================================================= */
.wp-block-image img {
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.wp-block-quote {
  border-left: 3px solid var(--accent);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-style: italic;
}

.wp-block-separator {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.wp-block-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.wp-block-table th,
.wp-block-table td {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  text-align: left;
}

.wp-block-table th {
  background: var(--bg3);
  font-weight: 700;
  color: var(--text);
}

.wp-block-table td {
  color: var(--text-muted);
}

/* =========================================================
   UTILITY
   ========================================================= */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border-width: 0;
}
