/* ========== Article Page Styles ========== */
/* Editorial style matching the homepage design */

/* ========== Minimalist Loading Screen ========== */
#splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: #f4f4f5;
  /* matches body background */
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.8s;
}

#splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-bar-container {
  width: 240px;
  height: 4px;
  background-color: rgba(0, 0, 0, 0.08);
  /* light subtle background */
  border-radius: 3px;
  overflow: hidden;
}

.loading-bar {
  width: 0%;
  height: 100%;
  background-color: #1d1d1f;
  /* minimalist black */
  border-radius: 3px;
  transition: width 0.3s ease-out;
}

:root {
  --bg-primary: #f4f4f5;
  --bg-secondary: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #6b6b6b;
  --text-muted: #86868b;
  --accent: #0b57d0;
  --accent-light: #d3e3fd;
  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  --radius: 24px;
  --radius-sm: 12px;
  --radius-full: 999px;
  --font-display: 'DM Serif Display', serif;
  --font-body: 'Google Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-width: 720px;
}

* {
  box-sizing: border-box;
}

html {
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* IE/Edge */
}

/* Lenis Recommended Styles */
html.lenis,
html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-stopped {
  overflow: hidden;
}

.lenis.lenis-scrolling iframe {
  pointer-events: none;
}

html::-webkit-scrollbar {
  display: none;
  /* Chrome/Safari/Webkit */
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  transition: 0.5s;
}

.no-scroll {
  overflow: hidden !important;
}

body.is-loaded .article-title {
  opacity: 1;
}

.article-title {
  opacity: 0;
  transition: 0.5s;
}

/* ========== Navigation ========== */
nav {
  display: flex;
  justify-content: center;
  align-items: center;
}

.navbar {
  background-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow: hidden;
  border-radius: 999px;
  padding: 4px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: fixed;
  top: 16px;
  z-index: 10086;
  max-width: 95%;
  transition: all 0.3s cubic-bezier(0.68, -0.21, 0.265, 1.21);
}

.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #1d1d1f;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: 8px;
  outline: none;
}

.nav-links {
  display: flex;
  align-items: center;
}

.nav-category {
  display: none;
}

.navbar img {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  margin-right: 4px;
  flex-shrink: 0;
}

.navbar a {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1d1d1f;
  text-align: center;
  padding: 6px 12px;
  text-decoration: none;
  transition: 0.3s cubic-bezier(0.68, -0.21, 0.265, 1.21);
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.navbar a i {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 0;
  opacity: 0;
  margin-right: 0;
  transform: translateX(-10px) scale(0.5);
  transition: 0.3s cubic-bezier(0.68, -0.21, 0.265, 1.21);
  font-size: 1rem;
  overflow: hidden;
  white-space: nowrap;
}

.navbar a:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: #1d1d1f;
  padding: 6px 16px;
}

.navbar a:hover i {
  width: 1.2rem;
  opacity: 1;
  margin-right: 6px;
  transform: translateX(0) scale(1);
}

.navbar a:active {
  background-color: rgba(0, 0, 0, 0.1);
  color: #1d1d1f;
  scale: 0.95;
}

/* ========== Article Container ========== */
.article-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 120px 24px 80px;
}

/* ========== Article Header ========== */
.article-header {
  margin-bottom: 4rem;
  text-align: center;
}

.article-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.15;
  margin: 0 0 1.5rem;
  letter-spacing: -1px;
}

.article-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.article-meta time {
  font-family: var(--font-display);
  color: var(--text-primary);
}

.article-meta .category {
  background-color: var(--accent-light);
  color: var(--accent);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.article-meta .read-time::before {
  content: '·';
  margin-right: 1rem;
  color: var(--border);
}

/* ========== Article Content (Markdown Styles) ========== */
.article-content {
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

.article-content>* {
  margin-bottom: 1.5rem;
}

/* Headings */
.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4,
.article-content h5,
.article-content h6 {
  font-family: var(--font-display);
  color: var(--text-primary);
  margin-top: 3rem;
  margin-bottom: 1rem;
  line-height: 1.3;
  letter-spacing: -0.5px;
}

.article-content h1 {
  font-size: 2rem;
  margin-top: 0;
}

.article-content h2 {
  font-size: 1.75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.article-content h3 {
  font-size: 1.5rem;
}

.article-content h4 {
  font-size: 1.25rem;
}

.article-content h5,
.article-content h6 {
  font-size: 1.1rem;
}

/* Paragraphs */
.article-content p {
  margin-bottom: 1.5rem;
}

/* Links */
.article-content a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s;
}

.article-content a:hover {
  border-bottom-color: var(--accent);
}

/* Emphasis */
.article-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.article-content em {
  font-style: italic;
}

.article-content del {
  text-decoration: line-through;
  opacity: 0.6;
}

/* Lists */
.article-content ul,
.article-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1.5rem;
}

.article-content ul {
  list-style: none;
  padding-left: 0;
}

.article-content ul li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.article-content ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.75rem;
  width: 6px;
  height: 6px;
  background-color: var(--accent);
  border-radius: 50%;
}

.article-content ol {
  list-style: decimal;
  padding-left: 1.5rem;
}

.article-content ol li {
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

/* Blockquotes */
.article-content blockquote {
  margin: 2rem 0;
  padding: 1.5rem 2rem;
  background-color: rgba(11, 87, 208, 0.05);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
}

.article-content blockquote p {
  margin: 0;
  color: var(--text-primary);
}

.article-content blockquote p::before {
  content: '"';
  font-size: 2rem;
  line-height: 0;
  vertical-align: -0.5rem;
  margin-right: 0.25rem;
  color: var(--accent);
  opacity: 0.5;
}

/* Code Blocks */
.code-block-wrapper {
  position: relative;
  margin: 2rem 0;
  border-radius: 12px;
  overflow: hidden;
  background-color: #121212;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background-color: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.code-file-name {
  color: #a1a1aa;
  font-size: 0.85rem;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
  font-weight: 500;
}

.code-block-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-btn {
  background: none;
  border: none;
  color: #a1a1aa;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.action-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.action-btn.copied {
  color: #10b981;
}

.action-btn svg {
  width: 16px;
  height: 16px;
}

.code-block {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  background-color: transparent;
}

.code-block code {
  color: #e2e2e2;
  background: transparent;
  padding: 0;
  border-radius: 0;
}

/* Syntax Highlighting Tokens */
.token.comment {
  color: #676e95;
  font-style: italic;
}

.token.string {
  color: #c3e88d;
}

.token.keyword {
  color: #c792ea;
  font-weight: 600;
}

.token.boolean {
  color: #ff5370;
}

.token.function {
  color: #82aaff;
}

.token.builtin {
  color: #f78c6c;
}

.token.number {
  color: #f78c6c;
}

.token.operator {
  color: #89ddff;
}

/* HTML/XML Tokens */
.token.tag {
  color: #ff5370;
}

.token.attr-name {
  color: #c792ea;
}

.token.attr-value {
  color: #c3e88d;
}

/* CSS Tokens */
.token.selector {
  color: #ffcb6b;
}

.token.property {
  color: #82aaff;
}

.token.value {
  color: #c3e88d;
}

.token.color {
  color: #f78c6c;
}

/* Python/Bash Tokens */
.token.variable {
  color: #ffcb6b;
}

/* JSON Tokens */
.token.punctuation {
  color: #89ddff;
}

/* SQL Tokens */
.token.statement {
  color: #c792ea;
  font-weight: 600;
}

/* Inline Code */
.inline-code {
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', monospace;
  font-size: 0.85em;
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

/* Action Buttons handled in code-block-actions */

/* Images */
.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 2rem 0;
  display: block;
  cursor: zoom-in;
  transition: transform 0.3s;
}

.article-content img:hover {
  transform: scale(1.01);
}

/* Horizontal Rule */
.article-content hr {
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border), transparent);
  margin: 3rem 0;
}

/* ========== Article Footer ========== */
.article-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.article-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  text-decoration: none;
  border-radius: var(--radius-full);
  font-weight: 500;
  transition: all 0.3s;
  box-shadow: var(--shadow);
}

.back-btn:hover {
  transform: translateX(-4px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}

.share-btn {
  width: 48px;
  height: 48px;
  border: none;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.3s;
  box-shadow: var(--shadow);
}

.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
}

/* ========== Loading & Error States ========== */
.article-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 4rem;
  color: var(--text-muted);
  font-size: 1rem;
}

.article-error {
  text-align: center;
  padding: 4rem 2rem;
}

.article-error i {
  font-size: 3rem;
  color: #ff3b30;
  margin-bottom: 1rem;
}

.article-error p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.back-link {
  display: inline-block;
  padding: 12px 24px;
  background-color: var(--accent);
  color: white;
  text-decoration: none;
  border-radius: var(--radius-full);
  font-weight: 500;
  transition: all 0.3s;
}

.back-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(11, 87, 208, 0.3);
}

/* ========== Image Lightbox ========== */
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.image-lightbox.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
}

.lightbox-img {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  transform: scale(0.9);
  transition: transform 0.3s;
}

.image-lightbox.active .lightbox-img {
  transform: scale(1);
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border: none;
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: all 0.3s;
}

.lightbox-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* ========== Custom Cursor ========== */
html.custom-cursor,
html.custom-cursor * {
  cursor: none !important;
}

#cursor-dot {
  position: fixed;
  top: 0;
  left: 0;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  mix-blend-mode: difference;
  pointer-events: none;
  z-index: 99999;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, width 0.2s ease, height 0.2s ease;
}

#cursor-dot.hover {
  width: 64px;
  height: 64px;
}

#cursor-dot .cursor-arrow {
  display: none;
  font-size: 20px;
}

#cursor-dot.hover .cursor-arrow {
  display: var(--fa-display, inline-block);
}

#cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  border: 1.5px solid #fff;
  border-radius: 50%;
  mix-blend-mode: difference;
  opacity: 0.45;
  pointer-events: none;
  z-index: 99998;
  transform: translate(-50%, -50%);
  transition: width 0.2s ease, height 0.2s ease, border-color 0.2s ease, opacity 0.15s ease;
}

#cursor-ring.hover {
  opacity: 0;
}

#cursor-ring.clicking {
  width: 20px;
  height: 20px;
}

#cursor-dot.hidden,
#cursor-ring.hidden {
  opacity: 0;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .article-container {
    padding: 100px 20px 60px;
  }

  .article-title {
    font-size: 2rem;
  }

  .article-content {
    font-size: 1rem;
  }

  .code-block {
    padding: 1rem;
    font-size: 0.8rem;
  }

  .article-actions {
    flex-direction: row;
  }

  .back-btn {
    flex: 1;
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .navbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 0;
    border-radius: 0;
    width: 100%;
    max-width: 100%;
    top: 0;
    left: 0;
    box-sizing: border-box;
    background-color: rgba(255, 255, 255, 0.8);
    transition: height 0.6s cubic-bezier(0.16, 1, 0.3, 1),
      background-color 0.4s ease,
      backdrop-filter 0.4s ease;
  }

  .navbar.menu-open {
    background-color: #ffffff;
    height: 100vh;
    align-items: flex-start;
    justify-content: flex-start;
    overflow-y: auto;
    backdrop-filter: blur(20px);
  }

  .nav-header {
    width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
  }

  .mobile-menu-btn {
    display: block;
    font-size: 1.5rem;
  }

  .nav-links {
    flex-direction: column;
    width: 100%;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding: 0 20px;
    box-sizing: border-box;
    align-items: flex-start !important;
    margin-top: 0;
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .navbar.menu-open .nav-links {
    max-height: 100vh;
    opacity: 1;
    margin-top: 20px;
  }

  .nav-category {
    display: block;
    font-size: 0.8rem;
    color: #86868b;
    margin-bottom: 24px;
    font-weight: 500;
    text-transform: capitalize;
    text-align: left !important;
    width: 100%;
  }

  .navbar a {
    width: 100% !important;
    justify-content: flex-start !important;
    text-align: left !important;
    padding: 8px 0 !important;
    font-size: 2rem !important;
    font-weight: 600 !important;
    color: #1d1d1f !important;
    opacity: 0;
    transform: translateY(8px);
    background: none !important;
    border-radius: 0;
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
      transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .navbar a i {
    display: none;
  }

  .navbar.menu-open a {
    opacity: 1;
    transform: translateY(0);
  }

  .navbar.menu-open a:nth-child(2) {
    transition-delay: 0.2s;
  }

  .navbar.menu-open a:nth-child(3) {
    transition-delay: 0.26s;
  }

  .navbar.menu-open a:nth-child(4) {
    transition-delay: 0.32s;
  }

  .navbar.menu-open a:nth-child(5) {
    transition-delay: 0.38s;
  }

  .navbar.menu-open a:nth-child(6) {
    transition-delay: 0.44s;
  }
}

@media (max-width: 480px) {
  .navbar {
    top: 0;
  }
}

@keyframes menuFadeIn {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 480px) {
  .article-header {
    margin-bottom: 2.5rem;
  }

  .article-meta {
    font-size: 0.8rem;
  }

  .article-content h2 {
    font-size: 1.5rem;
  }

  .article-content h3 {
    font-size: 1.25rem;
  }
}