/* ================================================
   Creative Coding Tutorials — Stylesheet
   ================================================ */

:root {
  --bg: #0d0d14;
  --bg-card: #13131f;
  --bg-sidebar: #0f0f1a;
  --bg-code: #1a1a2e;
  --border: #1e1e30;
  --border-light: #2a2a40;
  --text: #e2e2f0;
  --text-muted: #8888aa;
  --text-dim: #555570;

  --accent: #7c6af7;
  --accent-glow: rgba(124, 106, 247, 0.15);
  --accent-hover: #9d8ff9;

  --starter: #22c55e;
  --beginner: #3b82f6;
  --intermediate: #f97316;
  --expert: #ef4444;

  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-width: 260px;
  --header-height: 56px;

  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ---- Reset & Base ---- */

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

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

img {
  max-width: 100%;
  height: auto;
}

/* ---- Header ---- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(13, 13, 20, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 32px;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.site-logo:hover {
  color: var(--text);
}

.logo-mark {
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}

.header-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.nav-link {
  padding: 6px 14px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: var(--bg-card);
}

.nav-link.active {
  color: var(--accent);
}

.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-muted);
  border-radius: 2px;
  transition: all 0.2s;
}

/* ---- Layout ---- */

.page-layout {
  display: flex;
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ---- Sidebar ---- */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  background: var(--bg-sidebar);
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

.sidebar-inner {
  padding: 16px 0 40px;
}

.sidebar-section {
  padding: 8px 16px 12px;
}

.sidebar-topic-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.sidebar-topic-title:hover {
  color: var(--text-muted);
}

.sidebar-group {
  margin-bottom: 2px;
}

.sidebar-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.sidebar-group-toggle:hover {
  color: var(--text);
  background: var(--border);
}

.chevron {
  width: 14px;
  height: 14px;
  margin-left: auto;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s;
}

.sidebar-group-toggle.open .chevron {
  transform: rotate(180deg);
}

.sidebar-list {
  list-style: none;
  display: none;
  padding-left: 16px;
  border-left: 1px solid var(--border);
  margin: 4px 16px 8px;
}

.sidebar-list.open {
  display: block;
}

.sidebar-list a {
  display: block;
  padding: 4px 8px;
  font-size: 13px;
  color: var(--text-muted);
  border-radius: 4px;
  transition: all 0.15s;
  line-height: 1.4;
}

.sidebar-list a:hover {
  color: var(--text);
  background: var(--accent-glow);
}

.sidebar-list a.active {
  color: var(--accent);
  background: var(--accent-glow);
}

/* ---- Level Badges ---- */

.level-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.level-starter  { background: rgba(34, 197, 94, 0.15);  color: var(--starter); }
.level-beginner { background: rgba(59, 130, 246, 0.15); color: var(--beginner); }
.level-intermediate { background: rgba(249, 115, 22, 0.15); color: var(--intermediate); }
.level-expert   { background: rgba(239, 68, 68, 0.15);  color: var(--expert); }

/* ---- Main Content ---- */

.main-content {
  flex: 1;
  min-width: 0;
  padding: 40px 48px;
  max-width: 860px;
}

.main-content.full-width {
  max-width: 100%;
  padding: 0;
}

/* ---- Homepage ---- */

.home-hero {
  padding: 80px 48px 60px;
  text-align: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(124,106,247,0.08) 0%, transparent 70%);
  border-bottom: 1px solid var(--border);
}

.home-hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 20px;
}

.home-hero h1 span {
  background: linear-gradient(135deg, #7c6af7, #a78bfa, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.home-hero p {
  font-size: 18px;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 40px;
}

.hero-topics {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.topic-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 24px 28px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 220px;
  transition: all 0.2s;
  text-align: left;
}

.topic-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--accent-glow);
  transform: translateY(-2px);
}

.topic-card .topic-icon {
  font-size: 32px;
  margin-bottom: 12px;
  line-height: 1;
}

.topic-card .topic-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--text);
  margin-bottom: 4px;
}

.topic-card .topic-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.home-levels {
  padding: 60px 48px;
  border-bottom: 1px solid var(--border);
}

.home-levels h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 28px;
  text-align: center;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: -0.01em;
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
}

.level-card {
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all 0.2s;
}

.level-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.level-card .level-name {
  font-size: 16px;
  font-weight: 600;
  margin: 12px 0 6px;
  color: var(--text);
}

.level-card .level-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.home-topics-section {
  padding: 60px 48px;
}

.home-topics-section h2 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 32px;
}

.topic-section-card {
  display: block;
  padding: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  transition: all 0.2s;
}

.topic-section-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 32px var(--accent-glow);
}

.topic-section-card .topic-section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.topic-section-card .topic-section-icon {
  font-size: 36px;
  line-height: 1;
}

.topic-section-card h3 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.topic-section-card p {
  color: var(--text-muted);
  margin-bottom: 20px;
  max-width: 600px;
}

.level-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- Tutorial Article ---- */

.tutorial-article {
  max-width: 720px;
}

.tutorial-header {
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.tutorial-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}

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

.breadcrumb-sep {
  color: var(--text-dim);
}

.article-num {
  color: var(--text-dim);
  font-size: 12px;
}

.tutorial-title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 12px;
}

.tutorial-description {
  font-size: 17px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 16px;
}

.tutorial-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-muted);
}

.tag-time {
  color: var(--text-dim);
}

/* ---- Tutorial Body (Markdown) ---- */

.tutorial-body {
  line-height: 1.75;
}

.tutorial-body h2 {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 40px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.tutorial-body h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 28px 0 12px;
  color: var(--text);
}

.tutorial-body h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 20px 0 8px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 12px;
}

.tutorial-body p {
  margin-bottom: 16px;
  color: var(--text);
}

.tutorial-body ul,
.tutorial-body ol {
  margin: 0 0 16px 20px;
  color: var(--text);
}

.tutorial-body li {
  margin-bottom: 6px;
}

.tutorial-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.tutorial-body em {
  color: var(--text-muted);
}

.tutorial-body blockquote {
  border-left: 3px solid var(--accent);
  padding: 12px 20px;
  margin: 24px 0;
  background: var(--accent-glow);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
  font-style: italic;
}

.tutorial-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  color: #c4b5fd;
}

.tutorial-body pre {
  margin: 24px 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.tutorial-body pre code {
  display: block;
  padding: 20px 24px;
  background: var(--bg-code);
  border: none;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.6;
  overflow-x: auto;
}

/* Rouge syntax highlighting */
.highlight { background: var(--bg-code); }
.highlight .c, .highlight .c1, .highlight .cm { color: #6b7fa3; font-style: italic; }
.highlight .k, .highlight .kd { color: #c084fc; }
.highlight .s, .highlight .s1, .highlight .s2 { color: #86efac; }
.highlight .mi, .highlight .mf { color: #67e8f9; }
.highlight .nf, .highlight .nx { color: #60a5fa; }
.highlight .p { color: #94a3b8; }
.highlight .n, .highlight .na { color: var(--text); }
.highlight .o { color: #f472b6; }
.highlight .kc { color: #fb923c; }
.highlight .nb { color: #a78bfa; }

.tutorial-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14px;
}

.tutorial-body th {
  background: var(--bg-code);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.tutorial-body td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.tutorial-body tr:last-child td {
  border-bottom: none;
}

/* Callout boxes */
.tutorial-body .callout {
  padding: 16px 20px;
  border-radius: var(--radius);
  margin: 24px 0;
  border: 1px solid;
}

.tutorial-body .callout-info {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

.tutorial-body .callout-tip {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.3);
  color: #86efac;
}

.tutorial-body .callout-warning {
  background: rgba(249, 115, 22, 0.08);
  border-color: rgba(249, 115, 22, 0.3);
  color: #fdba74;
}

/* ---- Tutorial Navigation ---- */

.tutorial-footer {
  margin-top: 60px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.tutorial-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.tutorial-nav-btn {
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s;
  color: var(--text);
}

.tutorial-nav-btn:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--text);
}

.tutorial-nav-btn.next {
  text-align: right;
}

.nav-direction {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  display: block;
}

.nav-title {
  font-size: 14px;
  font-weight: 500;
  display: block;
}

/* ---- Section Index Pages ---- */

.section-header {
  margin-bottom: 48px;
}

.section-header h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 12px;
}

.section-header p {
  font-size: 17px;
  color: var(--text-muted);
  max-width: 580px;
}

.level-section {
  margin-bottom: 48px;
}

.level-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.level-section-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.level-section-header a {
  font-size: 13px;
  color: var(--text-dim);
  margin-left: auto;
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.article-card {
  display: flex;
  flex-direction: column;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.18s;
  color: var(--text);
}

.article-card:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
  transform: translateY(-1px);
  color: var(--text);
}

.article-card .article-num {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.article-card .article-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text);
  flex: 1;
}

.article-card .article-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

.article-card--soon {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.article-card--soon em {
  font-style: italic;
  font-size: 11px;
  color: var(--text-dim);
}

/* ---- Footer ---- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
}

.site-footer p {
  margin: 4px 0;
  font-size: 13px;
  color: var(--text-dim);
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.footer-inner p {
  font-size: 13px;
  color: var(--text-dim);
}

/* ---- Responsive ---- */

@media (max-width: 900px) {
  .sidebar {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    height: calc(100vh - var(--header-height));
    z-index: 90;
    width: var(--sidebar-width);
  }

  .sidebar.open {
    display: block;
  }

  .menu-toggle {
    display: flex;
  }

  .main-content {
    padding: 28px 24px;
  }

  .home-hero,
  .home-levels,
  .home-topics-section {
    padding-left: 24px;
    padding-right: 24px;
  }

  .levels-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .tutorial-nav {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .header-inner {
    padding: 0 16px;
  }

  .hero-topics {
    flex-direction: column;
    align-items: stretch;
  }

  .topic-card {
    width: 100%;
  }

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