/* Articles Blog Styling */

/* ============================================
   BASE STYLES & VARIABLES
   ============================================ */

:root {
  --bg: #10101f;
  --fg: #eaeaea;
  --dim: #bdbdbd;
  --line: #bdbdbd2d;
  --accent: #19ef83;
  --code-bg: #020202;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin !important;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 120px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
  height: 100%;
  width: 100%;
}

/* Custom Scrollbar Styles */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
  background: transparent;
}

::-webkit-scrollbar-track {
  background: transparent !important;
  background-color: transparent !important;
}

::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--accent) 80%, white);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  min-height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: 'League Spartan', sans-serif;
  letter-spacing: 0.02em;
  font-size: 0.9em;
  line-height: 1.6;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: -3;
}

/* CRT Scanlines */
.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  z-index: -1;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.03) 2px, rgba(255, 255, 255, 0.03) 3px);
}

/* ============================================
   LAYOUT (Index Page)
   ============================================ */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 24px;
  background: transparent;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* Page Header */
.page-header {
  padding: 0px 0px 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}

.headline {
  color: var(--dim);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.14em;
  margin-bottom: 12px;
}

h1 {
  font-family: 'League Spartan', sans-serif;
  font-size: 42px;
  margin: 10px 0 12px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 100%;
  color: #fff;
}

.sub {
  color: var(--dim);
  margin: 0;
  font-size: 16px;
}

/* Main Content */
.content {
  max-width: none;
}

/* ============================================
   SIDEBAR LAYOUT (Detail Page)
   ============================================ */

.articles-layout {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.article-content-wrapper {
  flex: 1;
  display: flex;
  gap: 24px;
  padding: 36px 24px;
  max-width: 1200px;
}

.article-main {
  flex: 1;
  min-width: 0;
}

/* Sidebar Navigation */
.articles-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.3);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
}

.articles-sidebar::-webkit-scrollbar {
  width: 6px;
}

.articles-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.articles-sidebar::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 3px;
}

/* Sidebar Components */
.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: rgba(16, 16, 31, 0.98);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.sidebar-header h2 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin: 0;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-direction: column;
  gap: 4px;
}

.sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--fg);
  transition: all 0.3s;
}

.sidebar-search {
  padding: 12px 16px 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.sidebar-search input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--fg);
  font-family: 'League Spartan', sans-serif;
  font-size: 13px;
  transition: all 0.2s;
}

.sidebar-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.5);
  box-shadow: 0 0 0 3px rgba(25, 239, 131, 0.1);
}

.sidebar-search input::placeholder {
  color: var(--dim);
  opacity: 0.7;
}

.sidebar-search .search-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  opacity: 0.4;
  pointer-events: none;
}

.sidebar-nav {
  display: flex;
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  flex-direction: column;
  flex-wrap: nowrap;
  align-content: flex-start;
  justify-content: flex-start;
  align-items: flex-start;
  width: 100%;
  gap: 0;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  padding: 8px 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  margin: 0 0 8px;
  user-select: none;
}

.nav-items {
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav-item {
  margin: 0;
}

.nav-link {
  display: block;
  padding: 8px 20px;
  color: var(--fg);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  line-height: 1.5;
}

.nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border-left-color: var(--accent);
}

.nav-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: linear-gradient(90deg, rgba(25, 239, 131, 0.15) 0%, rgba(25, 239, 131, 0) 100%);
  font-weight: 600;
  text-shadow: 0 0 10px rgba(25, 239, 131, 0.3);
}

/* Table of Contents Sidebar */
.toc-sidebar {
  width: 220px;
  flex-shrink: 0;
  padding: 36px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent) transparent;
}

/* TOC Actions (Copy Button) */
.toc-actions {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.toc-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg);
  font-family: 'League Spartan', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.toc-action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--accent);
  color: #fff;
}

.toc-action-btn .icon {
  font-size: 14px;
}

.toc-action-btn.success {
  background: rgba(25, 239, 131, 0.15);
  border-color: var(--accent);
  color: var(--accent);
}

.toc-sidebar::-webkit-scrollbar {
  width: 4px;
}

.toc-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.toc-sidebar::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 2px;
}

.toc-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--dim);
  margin: 0 0 16px;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-item {
  margin: 0 0 8px;
}

.toc-link {
  display: block;
  color: var(--dim);
  text-decoration: none;
  font-size: 12px;
  line-height: 1.4;
  padding: 4px 0 4px 12px;
  border-left: 2px solid transparent;
  transition: all 0.2s;
}

.toc-link:hover {
  color: #fff;
  border-left-color: var(--line);
}

.toc-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.toc-link.level-1 {
  font-weight: 700;
  color: var(--fg);
}

.toc-link.level-2 {
  font-weight: 700;
  padding-left: 12px;
}

.toc-link.level-3 {
  padding-left: 24px;
  font-size: 11px;
}

.toc-link code {
  font-family: 'Fira Code', monospace;
  font-size: 0.9em;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 4px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ============================================
   MARKDOWN CONTENT
   ============================================ */

.markdown-content {
  max-width: 628px;
  width: 100%;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  font-family: 'League Spartan', sans-serif;
  margin: 32px 0 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  position: relative;
}

.markdown-content h1 {
  font-size: 36px;
  margin-top: 0;
}

.markdown-content h2 {
  font-size: 28px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.markdown-content h3 {
  font-size: 22px;
}

.markdown-content h4 {
  font-size: 18px;
}

.markdown-content h5 {
  font-size: 16px;
}

.markdown-content h6 {
  font-size: 14px;
}

.markdown-content p {
  margin: 0 0 16px;
  color: var(--fg);
}

.markdown-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.markdown-content a:hover {
  border-bottom-color: var(--accent);
}

.markdown-content ul,
.markdown-content ol {
  margin: 16px 0;
  padding-left: 24px;
}

.markdown-content li {
  margin: 8px 0;
  color: var(--fg);
}

.markdown-content code {
  background: transparent !important;
  padding: 3px 6px;
  border-radius: 3px;
  font-family: 'Fira Code', monospace;
  font-size: 0.9em;
  color: var(--accent);
  border: 1px solid var(--line);
}

.markdown-content pre {
  background: transparent !important;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
}

.markdown-content pre code {
  background: none;
  padding: 0;
  border: none;
  color: inherit;
}

code[class*='language-'],
pre[class*='language-'] {
  background: transparent !important;
}

.markdown-content blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 16px;
  margin: 16px 0;
  color: var(--dim);
  font-style: italic;
}

a.heading-anchor {
  padding-left: 8px;
  font-size: 0.75em;
}

.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  border: 1px solid var(--line);
}

.markdown-content th,
.markdown-content td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.markdown-content th {
  background: rgba(0, 0, 0, 0.3);
  font-weight: 700;
  color: #fff;
}

.markdown-content img {
  max-width: 100%;
  height: auto;
  /* border: 1px solid var(--line); */
  border-radius: 6px;
  margin: 16px 0;
}

.markdown-content hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 32px 0;
}

/* ============================================
   COMPONENTS
   ============================================ */

/* Header Actions */
.header-actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.rss-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: all 0.2s;
}

.rss-link:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Search and Filter Controls */
.articles-controls {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  align-items: center;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 300px;
}

.search-box input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg);
  font-family: 'League Spartan', sans-serif;
  font-size: 14px;
  transition: all 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.3);
}

.search-box input::placeholder {
  color: var(--dim);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  opacity: 0.5;
}

.filter-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.sort-dropdown select {
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg);
  font-family: 'League Spartan', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.sort-dropdown select:hover {
  border-color: var(--accent);
}

.sort-dropdown select:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-clear {
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg);
  font-family: 'League Spartan', sans-serif;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn-clear:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-clear:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Tags Container */
.tags-container {
  margin-bottom: 24px;
  padding: 16px;
  background: rgba(0, 0, 0, 0.1);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tags-container.empty {
  display: none;
}

.tags-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  margin-right: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 16px;
  font-size: 12px;
  color: var(--fg);
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tag.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  font-weight: 600;
}

.tag-count {
  opacity: 0.6;
  font-size: 11px;
}

.tag.active .tag-count {
  opacity: 0.8;
}

/* Results Info */
.results-info {
  margin-bottom: 16px;
  color: var(--dim);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Articles Grid */
.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin-bottom: 48px;
}

/* Article Card */
.article-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.article-card:hover {
  border-color: var(--line);
  /* transform: translateY(-4px); */
  box-shadow: 0 8px 24px rgba(25, 239, 131, 0.1);
}

.article-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.article-date,
.article-read-time {
  display: flex;
  align-items: center;
  gap: 4px;
}

.article-title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
}

.article-title a {
  color: #fff;
  text-decoration: none;
  transition: color 0.2s;
}

.article-title a:hover {
  color: var(--accent);
}

.article-author {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--dim);
}

.article-description {
  margin: 0 0 16px;
  color: var(--fg);
  line-height: 1.6;
  flex-grow: 1;
}

.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.article-tags .tag {
  cursor: default;
  font-size: 11px;
  padding: 4px 10px;
}

.article-tags .tag:hover {
  border-color: var(--line);
  color: var(--fg);
}

.read-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: gap 0.2s;
}

.read-more:hover {
  gap: 10px;
}

/* Article Detail Styles */
.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: transform 0.2s;
}

.back-link:hover {
  transform: translateX(-4px);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--dim);
}

.empty-state h3 {
  font-size: 24px;
  margin-bottom: 12px;
  color: #fff;
}

.empty-state p {
  font-size: 14px;
}

/* Loading State */
.loading-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--dim);
}

.loading-spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive Design */
@media (max-width: 1024px) {
  .articles-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
  }

  .toc-sidebar {
    display: none;
  }
  .articles-layout {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .articles-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    min-width: 100%;
  }

  .filter-controls {
    width: 100%;
    justify-content: space-between;
  }

  .sort-dropdown select {
    flex: 1;
  }

  .articles-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .article-card {
    padding: 20px;
  }

  .article-title {
    font-size: 18px;
  }

  /* From index.html */
  .container {
    padding: 16px;
  }

  h1 {
    font-size: 32px;
  }

  .page-header {
    padding: 24px 0 16px;
    margin-bottom: 24px;
  }

  /* Sidebar Layout */
  .articles-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.3);
  }

  .articles-sidebar.open {
    left: 0;
  }

  .sidebar-toggle {
    display: flex;
  }

  .articles-layout {
    flex-direction: column;
  }

  .article-content-wrapper {
    padding: 24px 16px;
  }

  /* Mobile sidebar overlay */
  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999;
  }

  .sidebar-overlay.active {
    display: block;
  }
}

@media (max-width: 480px) {
  .article-meta {
    flex-direction: column;
    gap: 4px;
  }

  .tags-container {
    padding: 12px;
  }

  .tag {
    font-size: 11px;
    padding: 5px 10px;
  }
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.article-card {
  animation: fadeIn 0.3s ease-out;
}

/* Print Styles */
@media print {
  .articles-controls,
  .tags-container,
  .results-info,
  .read-more {
    display: none;
  }

  .article-card {
    break-inside: avoid;
    border: 1px solid #000;
    box-shadow: none;
  }

  /* From index.html */
  body {
    color: #10101f;
    background: #fff;
  }
  .scanlines {
    display: none;
  }
  .container {
    max-width: none;
    padding: 0;
  }

  .articles-sidebar,
  .toc-sidebar,
  .sidebar-toggle {
    display: none;
  }
  .article-content-wrapper {
    padding: 0;
  }
}

/* ============================================
   KEYBOARD SHORTCUT INDICATOR
   ============================================ */

.kbd {
  display: inline-block;
  padding: 3px 6px;
  font-family: 'Fira Code', monospace;
  font-size: 11px;
  line-height: 1;
  color: var(--fg);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.search-shortcut {
  position: absolute;
  right: 32px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--dim);
  pointer-events: none;
}
