@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,600;0,700;1,400&display=swap');

:root {
  /* Light Editorial Theme (Default) */
  --bg-color: #fcfbf9;
  --bg-secondary: #f5f3ef;
  --card-bg: #ffffff;
  --card-hover: #faf9f6;
  --card-border: #e7e5e0;
  --text-primary: #1c1917;
  --text-secondary: #44403c;
  --text-muted: #78716c;
  --accent: #991b1b;
  --accent-hover: #b91c1c;
  --accent-rgb: 153, 27, 27;
  --accent-bg: rgba(153, 27, 27, 0.05);
  --border-color: #e7e5e0;
  
  --warning-bg: #fef2f2;
  --warning-border: #f87171;
  --warning-text: #991b1b;
  
  --nav-bg: rgba(252, 251, 249, 0.85);
  --border-radius-sm: 4px;
  --border-radius-md: 8px;
  --border-radius-lg: 16px;
  
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-code: 'SFMono-Regular', Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark Editorial Theme */
    --bg-color: #121214;
    --bg-secondary: #18181b;
    --card-bg: #1c1c1f;
    --card-hover: #222226;
    --card-border: #2d2d30;
    --text-primary: #f4f4f5;
    --text-secondary: #d4d4d8;
    --text-muted: #a1a1aa;
    --accent: #ef4444;
    --accent-hover: #f87171;
    --accent-rgb: 239, 68, 68;
    --accent-bg: rgba(239, 68, 68, 0.08);
    --border-color: #2d2d30;
    
    --warning-bg: rgba(239, 68, 68, 0.03);
    --warning-border: #ef4444;
    --warning-text: #f87171;
    
    --nav-bg: rgba(18, 18, 20, 0.85);
  }
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.8;
  background-color: var(--bg-color);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-color);
}
::-webkit-scrollbar-thumb {
  background: var(--card-border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

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

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

/* Sticky Header with Glassmorphism */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  width: 100%;
}

.header .grid-child {
  max-width: 1140px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.navbar-brand {
  display: flex;
  align-items: center;
}

.brand-logo img {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  transition: transform 0.25s ease;
}

.brand-logo:hover img {
  transform: scale(1.05);
}

.container-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.navbar {
  display: flex;
  gap: 20px;
  list-style: none;
}

.navbar li a {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
  padding: 6px 12px;
  border-radius: var(--border-radius-sm);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.navbar li a:hover {
  background-color: var(--accent-bg);
  color: var(--accent);
  text-decoration: none;
}

/* Language Selector styling */
.lang-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--card-border);
  padding: 4px;
  border-radius: var(--border-radius-sm);
}

.lang-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.15s ease;
}

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

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

/* Site Layout Grid */
.site-grid {
  max-width: 1140px;
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 40px;
  padding: 40px 24px;
  flex: 1;
}

/* Warning Banner callout */
.warning-banner {
  background: var(--warning-bg);
  border-left: 4px solid var(--warning-border);
  border-top: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 24px;
  margin-bottom: 30px;
}

.warning-label {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--warning-text);
  margin-bottom: 8px;
  display: block;
}

.warning-body {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* Search Bar styling */
.search-container {
  margin-bottom: 30px;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg);
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.95rem;
}

/* Category Quicklinks Scrollbar */
.category-quicklinks {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 25px;
  border-bottom: 1px solid var(--border-color);
  scrollbar-width: none;
}

.category-quicklinks::-webkit-scrollbar {
  display: none;
}

.category-link {
  white-space: nowrap;
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--border-radius-lg);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.category-link:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* Category Cards Grid */
.categories-grid {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.category-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 30px;
}

.category-card h2 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

.category-card h2 a {
  color: var(--text-primary);
}

.category-card h2 a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* Category "View all" link */
.category-view-all {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-color);
}

.category-view-all a {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.category-view-all a:hover {
  text-decoration: underline;
}

.category-articles {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.category-articles li {
  position: relative;
  padding-left: 20px;
  font-size: 0.95rem;
}

.category-articles li::before {
  content: '▪';
  position: absolute;
  left: 4px;
  color: var(--text-muted);
  font-size: 0.7rem;
  top: 1px;
}

.category-articles li a {
  color: var(--text-secondary);
}

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

.external-links-section {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px dashed var(--border-color);
}

.external-links-section p {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.external-links-section ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.external-links-section ul li a {
  font-size: 0.85rem;
  color: var(--accent);
}

.external-links-section ul li a::after {
  content: ' ↗';
  font-size: 0.7rem;
}

/* Sidebar Layout */
.sidebar-right {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.sidebar-right .card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 24px;
}

.sidebar-right .card-header {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 6px;
  margin-bottom: 16px;
}

.sidebar-right ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-right ul li {
  font-size: 0.85rem;
  line-height: 1.4;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-right ul li:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.sidebar-right ul li a {
  color: var(--text-secondary);
}

.sidebar-right ul li a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* Single Article Reading View */
.article-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 0;
}

.page-header {
  margin-bottom: 40px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 24px;
}

.page-header h1 {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 2.4rem;
  line-height: 1.25;
  color: var(--text-primary);
  margin-bottom: 16px;
  letter-spacing: -0.5px;
}

.article-info {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.article-info time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.article-info time::before {
  content: '📅';
}

.article-tags {
  display: inline-flex;
  gap: 6px;
}

.tag-badge {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
}

/* Article Prose */
.com-content-article__body {
  font-size: 1.08rem;
  line-height: 1.8;
  color: var(--text-primary);
}

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

.com-content-article__body h2 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  font-weight: 700;
  margin: 1.8em 0 0.8em;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 6px;
}

.com-content-article__body h3 {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-weight: 700;
  margin: 1.5em 0 0.8em;
  color: var(--text-primary);
}

.com-content-article__body blockquote {
  border-left: 3px solid var(--accent);
  background: var(--bg-secondary);
  padding: 20px 24px;
  margin: 24px 0;
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
  font-style: italic;
  color: var(--text-secondary);
}

.com-content-article__body blockquote p {
  margin-bottom: 0;
}

.com-content-article__body ul, 
.com-content-article__body ol {
  margin: 20px 0 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.com-content-article__body table {
  width: 100%;
  border-collapse: collapse;
  margin: 30px 0;
  font-size: 0.9rem;
}

.com-content-article__body th,
.com-content-article__body td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.com-content-article__body th {
  background: var(--bg-secondary);
  font-weight: 600;
  color: var(--text-primary);
}

.com-content-article__body tr:hover {
  background: rgba(0,0,0,0.01);
}

/* Code block styling */
.com-content-article__body code {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 2px 5px;
  border-radius: var(--border-radius-sm);
  font-family: var(--font-code);
  font-size: 0.85rem;
}

/* Warnings and callouts */
.article-warning {
  border-left: 3px solid var(--warning-border);
  background: var(--warning-bg);
  padding: 20px;
  margin: 45px 0 20px 0;
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

.article-warning .warning-label {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* CC0 Licensing Box */
.cc0-callout {
  margin-top: 50px;
  padding: 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: var(--border-radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 16px;
}

.cc0-image {
  flex-shrink: 0;
}

/* Global Footer */
.footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  margin-top: 60px;
  padding: 30px 24px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.footer .grid-child {
  max-width: 1140px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-nav {
  display: flex;
  gap: 20px;
  list-style: none;
}

/* Back to Top floating button */
.back-to-top-link {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--accent);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 99;
}

.back-to-top-link.visible {
  opacity: 0.85;
  pointer-events: auto;
}

.back-to-top-link:hover {
  opacity: 1;
  transform: translateY(-2px);
  color: white;
}

/* Localized listing page tags */
.tag-page-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 24px;
}

.tag-page-list li {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 16px 20px;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.tag-page-list li:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}

.tag-page-list li a {
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
}

.tag-page-list li a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* Responsive constraints */
@media (max-width: 992px) {
  .site-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 16px;
  }
  
  .header .grid-child {
    flex-direction: column;
    gap: 12px;
    padding: 12px 20px;
  }
  
  .container-nav {
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }
  
  .navbar {
    width: 100%;
    justify-content: center;
    gap: 15px;
  }
  
  .site-grid {
    padding: 24px 16px;
  }
  
  .page-header h1 {
    font-size: 1.85rem;
  }
  
  .footer .grid-child {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  
  .cc0-callout {
    flex-direction: column;
    text-align: center;
  }
}

/* ─── Breadcrumb Navigation ──────────────────────────────────────── */
.breadcrumbs {
  max-width: 1140px;
  margin: 0 auto;
  padding: 12px 24px 0;
  width: 100%;
}

.breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.breadcrumb-item {
  display: inline-flex;
  align-items: center;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: '/';
  margin-right: 8px;
  color: var(--text-muted);
  font-size: 0.7rem;
}

.breadcrumb-item a {
  color: var(--text-muted);
}

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

.breadcrumb-item:last-child a {
  color: var(--text-secondary);
  pointer-events: none;
}

/* ─── Post Date in Sidebar & Lists ───────────────────────────────── */
.post-date {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-right .card ul li .post-date {
  margin-top: 1px;
}

.tag-page-list li .post-date {
  display: inline;
  font-size: 0.8rem;
}

.tag-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ─── Table of Contents ──────────────────────────────────────────── */
.toc-wrapper {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 20px 24px;
  margin-bottom: 40px;
}

.toc {
  font-size: 0.9rem;
}

.toc-title {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
}

.toc-list li {
  padding: 2px 0;
}

.toc-lvl-3 {
  padding-left: 20px !important;
}

.toc-list li a {
  color: var(--text-secondary);
  font-size: 0.88rem;
  border-bottom: 1px dotted transparent;
}

.toc-list li a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
  text-decoration: none;
}

/* Anchor links on headings */
.toc-anchor {
  opacity: 0;
  font-size: 0.75rem;
  margin-left: 6px;
  color: var(--text-muted);
  transition: opacity 0.15s ease;
}

.com-content-article__body h2:hover .toc-anchor,
.com-content-article__body h3:hover .toc-anchor {
  opacity: 1;
}

.com-content-article__body h2 .toc-anchor:hover,
.com-content-article__body h3 .toc-anchor:hover {
  color: var(--accent);
}

/* ─── Related Articles ───────────────────────────────────────────── */
.related-articles {
  margin-top: 50px;
  padding: 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
}

.related-articles h3 {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--text-primary);
  margin-bottom: 16px;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 8px;
}

.related-articles ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.related-articles ul li {
  padding: 8px 12px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--border-radius-sm);
  transition: border-color 0.2s ease;
}

.related-articles ul li:hover {
  border-color: var(--accent);
}

.related-articles ul li a {
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 500;
}

.related-articles ul li a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ─── TLDR box always visible ────────────────────────────────────── */
.tldr-box {
  background: var(--bg-secondary);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
  padding: 20px 24px;
  margin-bottom: 40px;
}

.tldr-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tldr-content {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* Hidden post during search filtration */
.hidden-post {
  display: none !important;
}
