/* ==========================================
   Next Harizon — Modern & Premium Theme (Zero JS)
   ========================================== */

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

/* ─── Default Theme Variables (Light Theme) ─── */
:root {
  --bg: #f8f9fc;
  --bg-card: #ffffff;
  --bg-hover: #f1f3f9;
  --text: #1a1f2c;
  --text-soft: #4a5468;
  --text-muted: #8a94a6;
  --accent: #d97706; /* Warm Amber */
  --accent-rgb: 217, 119, 6;
  --accent-glow: rgba(217, 119, 6, 0.05);
  --border: #e2e8f0;
  --border-subtle: #edf2f7;
  --border-focus: #cbd5e1;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 9999px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-serif: 'Playfair Display', Georgia, Cambria, serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}

/* ─── Dark Theme Overrides (Sibling Selector) ─── */
#theme-dark:checked ~ .page-wrapper {
  --bg: #07070a;
  --bg-card: #0d0e15;
  --bg-hover: #141622;
  --text: #f3f4f6;
  --text-soft: #9da4b4;
  --text-muted: #575e70;
  --accent: #f59e0b; /* Golden Amber */
  --accent-rgb: 245, 158, 11;
  --accent-glow: rgba(245, 158, 11, 0.06);
  --border: #181b28;
  --border-subtle: #11131c;
  --border-focus: #373b50;
}

/* ─── Sepia Theme Overrides (Sibling Selector) ─── */
#theme-sepia:checked ~ .page-wrapper {
  --bg: #f6efe2;
  --bg-card: #fdfaf3;
  --bg-hover: #f3edd8;
  --text: #433422;
  --text-soft: #63523f;
  --text-muted: #8e7c68;
  --accent: #b45309; /* Warm Brown Amber */
  --accent-rgb: 180, 83, 9;
  --accent-glow: rgba(180, 83, 9, 0.05);
  --border: #e6dac0;
  --border-subtle: #f0e6d2;
  --border-focus: #c8ba9d;
}

/* ─── Core Styles ─── */
html {
  scroll-behavior: smooth;
  background-color: var(--bg);
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.75;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

::selection {
  background: rgba(var(--accent-rgb), 0.2);
  color: inherit;
}

/* Hide theme radio inputs */
.theme-input, .filter-target {
  display: none !important;
}

/* Page wrapper that receives variables and animates */
.page-wrapper {
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* ─── Typography ─── */
h1, h2, h3, h4 {
  color: var(--text);
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

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

/* ─── Glass Header ─── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(var(--accent-rgb), 0.02);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  width: 100%;
}

.nav {
  width: 70%;
  max-width: 1200px;
  min-width: 320px;
  margin: 0 auto;
  padding: 1.25rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-family: var(--font-serif);
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--text);
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, var(--text) 40%, var(--text-soft) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-soft);
  position: relative;
  padding: 0.25rem 0;
}

.nav-links a:hover {
  color: var(--text);
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 0.2s ease;
}

.nav-links a:hover::after {
  width: 100%;
}

.nav-links a.active {
  color: var(--text);
}
.nav-links a.active::after {
  width: 100%;
}

/* ─── Hero Section ─── */
.hero {
  position: relative;
  text-align: center;
  padding: 8rem 0 5rem;
  background: radial-gradient(circle 600px at 50% -150px, var(--accent-glow), transparent);
}

.hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.hero h1 {
  font-size: clamp(2.75rem, 6vw, 4rem);
  font-weight: 800;
  margin-bottom: 0.75rem;
  letter-spacing: -0.04em;
  color: var(--text);
}

.hero .tagline {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  max-width: 480px;
  margin: 0 auto 0.75rem;
}

.hero .subtitle {
  font-size: 1.05rem;
  color: var(--text-soft);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ─── Main Sections ─── */
.section {
  width: 70%;
  max-width: 1200px;
  min-width: 320px;
  margin: 0 auto;
  padding: 4rem 0 6rem;
}

.section-label {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-label::after {
  content: '';
  height: 1px;
  flex: 1;
  background: var(--border-subtle);
}

/* ─── Category Filter Navigation (Pure CSS Hash Filter) ─── */
.category-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
}

.category-filter {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1.15rem;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-soft);
  transition: all 0.2s ease;
}

.category-filter:hover {
  color: var(--text);
  border-color: var(--border-focus);
  background: var(--bg-hover);
}

/* ─── Featured Post Card ─── */
.featured-post {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem;
  margin-bottom: 3rem;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
}

.featured-post:hover {
  transform: translateY(-4px);
  border-color: rgba(var(--accent-rgb), 0.4);
  box-shadow: 0 20px 40px -20px rgba(var(--accent-rgb), 0.15);
}

.featured-post .badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #fff;
  background: var(--accent);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
}

.featured-post h2 {
  font-size: 2rem;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

/* Make entire cards clickable */
.featured-post h2 a::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: pointer;
}

.featured-post h2 a:hover {
  color: var(--accent);
}

.featured-post p {
  color: var(--text-soft);
  font-size: 1.05rem;
  line-height: 1.65;
  margin-bottom: 1.75rem;
}

.featured-post .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}

.featured-post .meta time {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-feature-settings: 'tnum';
}

/* ─── Post Grid & Cards ─── */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
}

.post-card:hover {
  transform: translateY(-4px);
  border-color: rgba(var(--accent-rgb), 0.35);
  background: var(--bg-hover);
  box-shadow: 0 16px 30px -15px rgba(0, 0, 0, 0.05);
}

.post-card time {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-feature-settings: 'tnum';
  margin-bottom: 0.75rem;
  display: block;
}

.post-card h2 {
  font-size: 1.35rem;
  margin-bottom: 0.75rem;
  line-height: 1.35;
  font-weight: 700;
}

.post-card h2 a::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  cursor: pointer;
}

.post-card h2 a:hover {
  color: var(--accent);
}

.post-card p {
  color: var(--text-soft);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  flex-grow: 1;
}

.post-card .tags,
.featured-post .tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 3; /* display above the clickable link overlay */
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid rgba(var(--accent-rgb), 0.15);
  color: var(--accent);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ─── CSS Target Filtering Logic ─── */
/* Default highlighting on index.html: highlight 'All Posts' pill */
.page-wrapper .filter-pill-all {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* When '#local-ai' target is active */
#local-ai:target ~ .page-wrapper .post-card:not(.cat-local-ai) { display: none !important; }
#local-ai:target ~ .page-wrapper .featured-post:not(.cat-local-ai) { display: none !important; }
#local-ai:target ~ .page-wrapper .filter-pill-local-ai {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
#local-ai:target ~ .page-wrapper .filter-pill-all {
  background: var(--bg-card);
  color: var(--text-soft);
  border-color: var(--border);
}

/* When '#minimalist-web' target is active */
#minimalist-web:target ~ .page-wrapper .post-card:not(.cat-minimalist-web) { display: none !important; }
#minimalist-web:target ~ .page-wrapper .featured-post:not(.cat-minimalist-web) { display: none !important; }
#minimalist-web:target ~ .page-wrapper .filter-pill-minimalist-web {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
#minimalist-web:target ~ .page-wrapper .filter-pill-all {
  background: var(--bg-card);
  color: var(--text-soft);
  border-color: var(--border);
}

/* When '#indie-craft' target is active */
#indie-craft:target ~ .page-wrapper .post-card:not(.cat-indie-craft) { display: none !important; }
#indie-craft:target ~ .page-wrapper .featured-post:not(.cat-indie-craft) { display: none !important; }
#indie-craft:target ~ .page-wrapper .filter-pill-indie-craft {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
#indie-craft:target ~ .page-wrapper .filter-pill-all {
  background: var(--bg-card);
  color: var(--text-soft);
  border-color: var(--border);
}

/* ─── Newsletter Form ─── */
.newsletter {
  width: 70%;
  max-width: 1200px;
  min-width: 320px;
  margin: 0 auto 6rem;
  padding: 3.5rem 2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.01);
}

.newsletter h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

.newsletter p {
  color: var(--text-soft);
  font-size: 0.95rem;
  margin-bottom: 1.75rem;
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}

.newsletter-form {
  display: flex;
  gap: 0.75rem;
  max-width: 420px;
  margin: 0 auto;
}

.newsletter-form input {
  flex: 1;
  padding: 0.8rem 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.newsletter-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

.newsletter-form input::placeholder {
  color: var(--text-muted);
}

/* ─── Footer & Theme Selector ─── */
.footer {
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card);
  padding: 4rem 0;
  width: 100%;
  margin-top: auto;
}

.footer-container {
  width: 70%;
  max-width: 1200px;
  min-width: 320px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.footer .nav-links {
  justify-content: center;
}

.footer p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.theme-selector {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--bg);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
}

.theme-btn {
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.theme-btn:hover {
  color: var(--text);
}

/* Highlight corresponding footer theme buttons based on check inputs */
#theme-light:checked ~ .page-wrapper .theme-btn-light,
#theme-dark:checked ~ .page-wrapper .theme-btn-dark,
#theme-sepia:checked ~ .page-wrapper .theme-btn-sepia {
  background: var(--accent);
  color: #fff;
}

/* ─── Article Page Details ─── */
.article {
  width: 70%;
  max-width: 1200px;
  min-width: 320px;
  margin: 0 auto;
  padding: 5rem 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 2.5rem;
  transition: transform 0.2s ease, color 0.2s ease;
}

.back-link:hover {
  color: var(--accent);
  transform: translateX(-4px);
}

.article-header {
  margin-bottom: 3.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-subtle);
}

.article-header time {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-feature-settings: 'tnum';
  display: block;
  margin-bottom: 0.75rem;
}

.article-header h1 {
  font-size: clamp(2.25rem, 5vw, 3.25rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
}

.article-header .desc {
  color: var(--text-soft);
  font-size: 1.15rem;
  line-height: 1.6;
}

.article-body {
  font-size: 1.075rem;
  line-height: 1.9;
  color: var(--text-soft);
  max-width: 800px; /* Limit text reading line length for ideal readability */
}

.article-body p {
  margin-bottom: 1.5rem;
}

.article-body h2 {
  font-size: 1.75rem;
  margin-top: 3.5rem;
  margin-bottom: 1.25rem;
  font-weight: 700;
}

.article-body h3 {
  font-size: 1.35rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  font-weight: 700;
}

.article-body strong {
  color: var(--text);
  font-weight: 600;
}

.article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1.5px;
  text-decoration-color: rgba(var(--accent-rgb), 0.25);
  transition: all 0.2s ease;
}

.article-body a:hover {
  color: var(--text);
  text-decoration-color: var(--accent);
}

.article-body ul,
.article-body ol {
  margin: 1.5rem 0;
  padding-left: 1.75rem;
}

.article-body li {
  margin: 0.6rem 0;
}

.article-body pre {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  overflow-x: auto;
  margin: 2rem 0;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.02);
}

.article-body code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.article-body :not(pre) > code {
  background: rgba(var(--accent-rgb), 0.05);
  border: 1px solid rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: var(--font-mono);
}

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.5rem 0 0.5rem 1.5rem;
  margin: 2rem 0;
  color: var(--text-soft);
  font-style: italic;
  background: linear-gradient(90deg, var(--bg-hover), transparent);
}

.article-body blockquote p {
  margin-bottom: 0;
}

.article-body hr {
  border: none;
  height: 1px;
  background: var(--border-subtle);
  margin: 3.5rem 0;
}

.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  font-size: 0.95rem;
}

.article-body th, .article-body td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.article-body th {
  color: var(--text);
  font-weight: 600;
  background: var(--bg-hover);
}

/* ─── Responsive Adjustments ─── */
@media (max-width: 1024px) {
  .nav, .section, .newsletter, .article, .footer-container {
    width: 90%;
  }
}

@media (max-width: 768px) {
  .hero {
    padding: 6rem 0 4rem;
  }

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

  .featured-post {
    padding: 2rem;
  }

  .featured-post h2 {
    font-size: 1.6rem;
  }

  .newsletter {
    padding: 2.5rem 1.5rem;
    width: 100%;
  }

  .newsletter-form {
    flex-direction: column;
  }

  .article {
    padding: 3rem 0;
  }
}
