/* ═══════════════════════════════════════════════════════
   CODING-SIMPLIFIED — Global Stylesheet
   ═══════════════════════════════════════════════════════ */

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

:root {
  --primary: #2563EB;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --accent: #10B981;
  --accent-light: #d1fae5;
  --bg: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-code: #f1f5f9;
  --bg-hover: #f1f5f9;
  --bg-nav: rgba(255,255,255,0.96);
  --text: #0f172a;
  --text-sec: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
}

[data-theme="dark"] {
  --primary-light: #1e3a5f;
  --accent-light: #065f46;
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #1e293b;
  --bg-code: #0d1117;
  --bg-hover: #334155;
  --bg-nav: rgba(15,23,42,0.96);
  --text: #e2e8f0;
  --text-sec: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.6; transition: background 0.3s, color 0.3s;
}
::selection { background: var(--primary); color: #fff; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Progress Bar ── */
#progress-bar {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  z-index: 9999; transition: width 80ms linear;
}

/* ── Navbar ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-nav); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.navbar-inner {
  max-width: 1440px; margin: 0 auto;
  padding: 0 20px; display: flex; align-items: center;
  height: 56px; gap: 14px;
}
.logo {
  font-family: 'Outfit', sans-serif; font-weight: 800; font-size: 19px;
  display: flex; align-items: center; gap: 8px; white-space: nowrap;
  background: linear-gradient(135deg, #2563eb, #10b981);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.spacer { flex: 1; }
.search-trigger {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-hover);
  color: var(--text-sec); cursor: pointer; font-size: 13px;
  flex: 1; max-width: 300px; transition: 0.2s;
}
.search-trigger:hover { border-color: var(--primary); color: var(--text); }
.search-trigger kbd {
  margin-left: auto; font-size: 10px; padding: 2px 6px;
  border-radius: 4px; border: 1px solid var(--border);
  background: var(--bg-card); font-family: inherit;
}
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px; flex-shrink: 0;
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
.icon-btn:hover { border-color: var(--primary); background: var(--primary-light); }
.menu-btn { display: none; }
@media(max-width:768px) {
  .menu-btn { display: flex; }
  .search-trigger { max-width: 160px; }
  .search-trigger .search-label { display: none; }
}

/* ── Language Nav ── */
.lang-nav { border-bottom: 1px solid var(--border); background: var(--bg-card); overflow: hidden; }
.lang-nav-scroll {
  max-width: 1440px; margin: 0 auto; display: flex;
  overflow-x: auto; scrollbar-width: none;
}
.lang-nav-scroll::-webkit-scrollbar { display: none; }
.lang-item {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; font-size: 13px; font-weight: 500;
  color: var(--text-sec); white-space: nowrap;
  border-bottom: 2.5px solid transparent; transition: 0.2s; flex-shrink: 0;
}
.lang-item:hover { color: var(--text); background: var(--bg-hover); }
.lang-item.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ── 3-Column Layout ── */
.layout {
  max-width: 1440px; margin: 0 auto;
  display: grid; grid-template-columns: 260px 1fr 230px;
  min-height: calc(100vh - 100px);
}
@media(max-width:1100px) { .layout { grid-template-columns: 260px 1fr; } .right-sidebar { display: none !important; } }
@media(max-width:768px) { .layout { grid-template-columns: 1fr; } }

/* ── Left Sidebar ── */
.sidebar {
  border-right: 1px solid var(--border); background: var(--bg-sidebar);
  padding: 16px 0; position: sticky; top: 56px;
  height: calc(100vh - 56px); overflow-y: auto;
}
@media(max-width:768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 280px; z-index: 200; padding-top: 60px;
    transform: translateX(-100%); transition: transform 0.3s ease;
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
}
.sidebar-label {
  padding: 0 16px 12px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted);
}
.sidebar-search { margin: 0 12px 12px; position: relative; }
.sidebar-search input {
  width: 100%; padding: 8px 12px 8px 32px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-hover); color: var(--text);
  font-size: 13px; outline: none; transition: 0.2s; font-family: inherit;
}
.sidebar-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.sidebar-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.group-title {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-sec); cursor: pointer; transition: 0.2s; user-select: none;
}
.group-title:hover { color: var(--text); background: var(--bg-hover); }
.group-title svg { transition: transform 0.2s; }
.group-title.collapsed svg { transform: rotate(-90deg); }
.topic-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 16px 7px 24px; font-size: 13.5px;
  color: var(--text-sec); transition: 0.15s;
  border-left: 2.5px solid transparent;
}
.topic-item:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.topic-item.active {
  color: var(--primary); border-left-color: var(--primary);
  background: var(--primary-light); font-weight: 600;
}
.topic-list { overflow: hidden; transition: max-height 0.3s ease; }
.topic-list.collapsed { max-height: 0 !important; }

/* ── Main Content ── */
.main-content { padding: 32px 44px 80px; max-width: 100%; overflow-x: hidden; }
@media(max-width:768px) { .main-content { padding: 20px 16px 60px; } }

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-muted); margin-bottom: 20px; flex-wrap: wrap;
}
.breadcrumb a { cursor: pointer; }

.article-title {
  font-family: 'Outfit', sans-serif; font-size: 32px;
  font-weight: 800; line-height: 1.2; margin-bottom: 12px;
}
@media(max-width:768px) { .article-title { font-size: 24px; } }
.article-meta {
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap; font-size: 13px; color: var(--text-sec); margin-bottom: 32px;
}
.meta-item { display: flex; align-items: center; gap: 5px; }
.badge { padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.badge-beginner { background: #d1fae5; color: #065f46; }
.badge-intermediate { background: #fef3c7; color: #92400e; }
.badge-advanced { background: #fce7f3; color: #9d174d; }

/* ── Article Typography ── */
.article-body h2 {
  font-family: 'Outfit', sans-serif; font-size: 24px; font-weight: 700;
  margin: 40px 0 16px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border); scroll-margin-top: 80px;
}
.article-body h3 {
  font-family: 'Outfit', sans-serif; font-size: 18px; font-weight: 600;
  margin: 28px 0 12px;
}
.article-body p { line-height: 1.8; margin-bottom: 16px; font-size: 15.5px; }
.article-body ul, .article-body ol { margin: 0 0 16px 24px; line-height: 1.8; font-size: 15.5px; }
.article-body li { margin-bottom: 4px; }
.article-body code:not(pre code) {
  font-family: 'JetBrains Mono', monospace; font-size: 13.5px;
  padding: 2px 6px; border-radius: 4px;
  background: var(--bg-code); color: #c084fc;
}
.article-body strong { font-weight: 600; }

/* ── Code Blocks ── */
.code-block { margin: 20px 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); position: relative; }
.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; font-size: 12px; font-weight: 600; color: var(--text-sec);
  background: var(--bg-hover);
}
[data-theme="dark"] .code-header { background: #161b22; }
.copy-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px; border: none; border-radius: 5px;
  background: transparent; color: var(--text-sec);
  cursor: pointer; font-size: 12px; font-family: inherit; transition: 0.2s;
}
.copy-btn:hover { background: var(--bg-card); color: var(--text); }
.copy-btn.copied { color: var(--accent); }
.code-block pre {
  margin: 0; padding: 16px 20px; background: var(--bg-code);
  overflow-x: auto; font-family: 'JetBrains Mono', monospace;
  font-size: 13px; line-height: 1.65; color: var(--text);
}

/* Syntax colors */
.hl-kw  { color: #d73a49; font-weight: 500; }
.hl-str { color: #032f62; }
.hl-cmt { color: #6a737d; font-style: italic; }
.hl-num { color: #005cc5; }
.hl-fn  { color: #6f42c1; }
.hl-ann { color: #6f42c1; }
[data-theme="dark"] .hl-kw  { color: #ff7b72; }
[data-theme="dark"] .hl-str { color: #a5d6ff; }
[data-theme="dark"] .hl-cmt { color: #8b949e; }
[data-theme="dark"] .hl-num { color: #79c0ff; }
[data-theme="dark"] .hl-fn  { color: #d2a8ff; }
[data-theme="dark"] .hl-ann { color: #d2a8ff; }

/* ── Output Blocks ── */
.output-block { margin: 20px 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--accent); }
.output-header { padding: 8px 16px; background: var(--accent-light); font-size: 12px; font-weight: 600; color: var(--accent); }
.output-block pre {
  margin: 0; padding: 16px 20px; background: var(--bg-code);
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  line-height: 1.65; overflow-x: auto; color: var(--text);
}

/* ── Callouts ── */
.callout {
  padding: 14px 18px; border-radius: 8px; margin: 20px 0;
  font-size: 14px; line-height: 1.7; border-left: 4px solid;
}
.callout-info { background: var(--primary-light); border-color: var(--primary); }
[data-theme="light"] .callout-info { background: #eff6ff; }
.callout-warning { border-color: #f59e0b; }
[data-theme="light"] .callout-warning { background: #fffbeb; }
[data-theme="dark"] .callout-warning { background: rgba(245,158,11,0.1); }
.callout-success { border-color: var(--accent); background: var(--accent-light); }

/* ── Feature Grid ── */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin: 20px 0; }
.feature-card {
  padding: 18px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg-card); transition: 0.2s;
}
.feature-card:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.feature-card strong { display: block; margin-bottom: 6px; font-size: 15px; }
.feature-card p { font-size: 13px; color: var(--text-sec); line-height: 1.5; margin: 0; }

/* ── Timeline ── */
.timeline { margin: 20px 0; padding-left: 24px; border-left: 2px solid var(--primary); }
.timeline-item { padding: 8px 0 8px 16px; position: relative; font-size: 14px; }
.timeline-item::before {
  content: ''; position: absolute; left: -29px; top: 14px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary); border: 2px solid var(--bg);
}
.timeline-item .year { font-weight: 700; color: var(--primary); margin-right: 8px; }

/* ── Quiz ── */
.quiz-item {
  padding: 18px; border: 1px solid var(--border);
  border-radius: 10px; margin-bottom: 14px; background: var(--bg-card);
}
.quiz-item p { margin-bottom: 10px; }
.quiz-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.quiz-option {
  padding: 8px 12px; border-radius: 6px; border: 1px solid var(--border);
  cursor: pointer; font-size: 14px; transition: 0.2s; display: flex; align-items: center; gap: 8px;
}
.quiz-option:hover { background: var(--bg-hover); border-color: var(--primary); }
.quiz-option input { accent-color: var(--primary); }
.quiz-answer {
  padding: 10px 14px; border-radius: 6px;
  background: var(--accent-light); font-size: 13px; color: var(--accent); display: none;
}
.quiz-answer.show { display: block; }

/* ── Prev/Next Nav ── */
.nav-buttons {
  display: flex; justify-content: space-between;
  margin-top: 48px; padding-top: 24px;
  border-top: 1px solid var(--border); gap: 16px;
}
.nav-btn {
  display: flex; flex-direction: column; padding: 14px 20px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-card); transition: 0.2s; min-width: 0; flex: 1; max-width: 48%;
}
.nav-btn:hover { border-color: var(--primary); box-shadow: var(--shadow); text-decoration: none; }
.nav-btn.next { text-align: right; margin-left: auto; }
.nav-btn-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 4px; }
.nav-btn-title { font-size: 14px; font-weight: 600; color: var(--primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Right Sidebar ── */
.right-sidebar {
  border-left: 1px solid var(--border); padding: 24px 16px;
  position: sticky; top: 56px; height: calc(100vh - 56px);
  overflow-y: auto; font-size: 13px;
}
.right-sidebar h4 {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 12px;
}
.toc-item {
  display: block; padding: 5px 0 5px 10px; color: var(--text-sec);
  transition: 0.2s; border-left: 2px solid transparent; margin-bottom: 2px;
}
.toc-item:hover { color: var(--primary); border-left-color: var(--primary); text-decoration: none; }
.rs-section { margin-bottom: 28px; }
.popular-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 0; color: var(--text-sec); cursor: pointer; transition: 0.2s;
}
.popular-item:hover { color: var(--primary); }
.ad-placeholder {
  padding: 40px 16px; border: 1px dashed var(--border);
  border-radius: 8px; text-align: center; color: var(--text-muted); font-size: 12px;
}

/* ── Search Modal ── */
.search-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 500; display: none; align-items: flex-start;
  justify-content: center; padding-top: 12vh; backdrop-filter: blur(4px);
}
.search-overlay.open { display: flex; }
.search-modal {
  background: var(--bg-card); border-radius: 14px;
  width: 90%; max-width: 560px; box-shadow: var(--shadow-lg);
  overflow: hidden; border: 1px solid var(--border);
}
.search-modal-input {
  width: 100%; padding: 16px 20px 16px 48px;
  border: none; background: transparent; font-size: 16px;
  color: var(--text); outline: none; font-family: inherit;
}
.search-results { max-height: 360px; overflow-y: auto; border-top: 1px solid var(--border); }
.search-result {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; cursor: pointer; transition: 0.15s;
}
.search-result:hover { background: var(--bg-hover); }
.search-empty { padding: 32px 20px; text-align: center; color: var(--text-muted); }

.mobile-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 199; display: none; }
.mobile-overlay.show { display: block; }

/* ── Landing ── */
.landing-hero { text-align: center; padding: 70px 20px 40px; }
.landing-hero h1 {
  font-family: 'Outfit', sans-serif; font-size: 44px; font-weight: 800;
  margin-bottom: 16px; line-height: 1.15;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
@media(max-width:768px) { .landing-hero h1 { font-size: 28px; } }
.landing-hero p { font-size: 18px; color: var(--text-sec); max-width: 600px; margin: 0 auto 36px; line-height: 1.7; }
.lang-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px; max-width: 1000px; margin: 0 auto; padding: 0 20px 80px;
}
.lang-card {
  padding: 22px 16px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--bg-card); cursor: pointer; transition: 0.25s; text-align: center;
}
.lang-card:hover { border-color: var(--primary); transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.lang-card-icon { font-size: 34px; margin-bottom: 8px; }
.lang-card-name { font-weight: 600; font-size: 15px; }

/* ── Footer ── */
.footer { background: var(--bg-card); border-top: 1px solid var(--border); padding: 40px 20px 24px; }
.footer-inner {
  max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 32px;
}
.footer-col h5 { font-family: 'Outfit', sans-serif; font-weight: 700; margin-bottom: 14px; font-size: 14px; }
.footer-col a { display: block; color: var(--text-sec); font-size: 13px; padding: 3px 0; transition: 0.2s; }
.footer-col a:hover { color: var(--primary); text-decoration: none; }
.footer-bottom {
  max-width: 1200px; margin: 24px auto 0; padding-top: 20px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-muted);
}
.footer-social { display: flex; gap: 14px; }
.footer-social a { color: var(--text-muted); transition: 0.2s; }
.footer-social a:hover { color: var(--primary); }

/* ── Back to Top ── */
#back-to-top {
  position: fixed; bottom: 24px; right: 24px;
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  cursor: pointer; display: none; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(37,99,235,0.4); transition: 0.3s; z-index: 50;
}
#back-to-top.show { display: flex; }
#back-to-top:hover { transform: translateY(-2px); }

/* ── Print ── */
@media print {
  .navbar, .lang-nav, .sidebar, .right-sidebar, .footer,
  #back-to-top, #progress-bar, .nav-buttons, .mobile-overlay,
  .search-overlay { display: none !important; }
  .layout { grid-template-columns: 1fr !important; }
}
