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

:root {
  --cream: #FDF6EC;
  --cream-dark: #F5ECDF;
  --ink: #1C1917;
  --ink-light: #44403C;
  --ink-muted: #78716C;
  --accent: #B45309;
  --accent-hover: #92400E;
  --border: #E7E0D6;
  --max-width: 720px;
  --font-body: 'Source Serif 4', 'Georgia', serif;
  --font-heading: 'Inter', 'Helvetica Neue', sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  background-color: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Typography ===== */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
}

h1 { font-size: 2.2rem; margin-bottom: 0.5rem; }
h2 { font-size: 1.5rem; margin-bottom: 0.4rem; }
h3 { font-size: 1.2rem; margin-bottom: 0.3rem; }

p {
  margin-bottom: 1.2rem;
  color: var(--ink-light);
}

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

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

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ===== Layout ===== */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===== Skip Link (Accessibility) ===== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--ink);
  color: var(--cream);
  padding: 0.5rem 1rem;
  border-radius: 0 0 4px 4px;
  z-index: 100;
  font-family: var(--font-heading);
  font-size: 0.85rem;
}

.skip-link:focus {
  top: 0;
  color: var(--cream);
}

/* ===== Header & Nav ===== */
.site-header {
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--border);
}

.site-header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.site-title:hover {
  color: var(--ink);
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: 1.8rem;
  align-items: center;
}

.site-nav a {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-muted);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.site-nav a:hover,
.site-nav a:focus {
  color: var(--ink);
  text-decoration: none;
}

.site-nav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
}

/* ===== Main Content ===== */
main {
  padding: 3rem 0;
  min-height: 60vh;
}

/* ===== Hero / Intro ===== */
.intro {
  margin-bottom: 3rem;
}

.intro p {
  font-size: 1.15rem;
  color: var(--ink-light);
  max-width: 600px;
}

/* ===== 3D Hero Section ===== */
.hero-section {
  padding: 3rem 0 2rem;
}

.hero-canvas-wrap {
  width: 100%;
  max-width: 720px;
  height: 400px;
  margin: 0 auto 2rem;
  position: relative;
}

#hero-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 8px;
}

.welcome-body-standalone {
  max-width: 600px;
  margin: 0 auto;
  animation: fadeInUp 0.8s ease-out 0.3s both;
}

.welcome-body-standalone p {
  font-size: 1.05rem;
  margin-bottom: 1rem;
}

/* ===== Animated Hero (Homepage) ===== */
.hero {
  padding: 4rem 0 3rem;
  text-align: center;
  margin-bottom: 2rem;
}

.hero h1 {
  font-size: 3rem;
  letter-spacing: -0.03em;
  animation: fadeInUp 0.8s ease-out;
}

.hero .subtitle {
  font-size: 1.25rem;
  color: var(--ink-muted);
  max-width: 520px;
  margin: 0.8rem auto 2rem;
  animation: fadeInUp 0.8s ease-out 0.15s both;
}

.hero .welcome-body {
  text-align: left;
  max-width: 600px;
  margin: 0 auto;
  animation: fadeInUp 0.8s ease-out 0.3s both;
}

.hero .welcome-body p {
  font-size: 1.05rem;
  margin-bottom: 1rem;
}

.hero .divider {
  width: 60px;
  height: 3px;
  background: var(--accent);
  border: none;
  margin: 2rem auto;
  border-radius: 2px;
  animation: fadeInUp 0.8s ease-out 0.3s both;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Content Note ===== */
.content-note {
  font-family: var(--font-heading);
  font-size: 0.82rem;
  color: var(--ink-muted);
  font-style: italic;
  margin-bottom: 1rem;
}

/* ===== Tag Variants ===== */
.tag--docs {
  color: #0369A1;
  background: rgba(3, 105, 161, 0.08);
}

/* ===== Section Headings ===== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.section-header h2 {
  margin-bottom: 0;
}

.section-header a {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 500;
}

/* ===== Article Cards ===== */
.article-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.8rem;
  margin-bottom: 3rem;
}

.article-item {
  padding-bottom: 1.8rem;
  border-bottom: 1px solid var(--border);
}

.article-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.article-item h3 {
  margin-bottom: 0.3rem;
}

.article-item h3 a {
  color: var(--ink);
  text-decoration: none;
}

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

.article-meta {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-bottom: 0.5rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}

.tag {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: rgba(180, 83, 9, 0.08);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
}

.article-item p {
  margin-bottom: 0;
  font-size: 0.95rem;
}

/* ===== Video Cards ===== */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.video-card {
  background: var(--cream-dark);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.video-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.video-card-thumb {
  aspect-ratio: 16 / 9;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.video-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-card-body {
  padding: 1rem;
}

.video-card-body h3 {
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

.video-card-body h3 a {
  color: var(--ink);
}

.video-card-body h3 a:hover {
  color: var(--accent);
}

.video-card-body p {
  font-size: 0.85rem;
  margin-bottom: 0;
  color: var(--ink-muted);
}

/* ===== Article Page ===== */
.article-header {
  margin-bottom: 2rem;
}

.article-header h1 {
  margin-bottom: 0.5rem;
}

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

.article-content h2 {
  margin-top: 2.5rem;
  margin-bottom: 0.8rem;
}

.article-content h3 {
  margin-top: 2rem;
  margin-bottom: 0.6rem;
}

.article-content ul,
.article-content ol {
  margin-bottom: 1.2rem;
  padding-left: 1.5rem;
  color: var(--ink-light);
}

.article-content li {
  margin-bottom: 0.4rem;
}

.article-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1.2rem;
  margin: 1.5rem 0;
  color: var(--ink-muted);
  font-style: italic;
}

.article-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--cream-dark);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

.article-content pre {
  background: var(--ink);
  color: var(--cream);
  padding: 1.2rem;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

.article-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 1.5rem 0;
}

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

.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-footer p {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-bottom: 0;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
}

.footer-links a {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.footer-links a:hover {
  color: var(--ink);
}

/* ===== Course Styles ===== */
.breadcrumb {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-bottom: 1.5rem;
}

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

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

.breadcrumb span {
  margin: 0 0.4rem;
}

.course-card {
  background: var(--cream-dark);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.course-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.course-card h3 {
  margin-bottom: 0.4rem;
}

.course-card h3 a {
  color: var(--ink);
}

.course-card h3 a:hover {
  color: var(--accent);
}

.course-card .course-meta {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-bottom: 0.6rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.course-card p {
  font-size: 0.95rem;
  margin-bottom: 0;
}

.lesson-list {
  list-style: none;
  counter-reset: lesson;
  margin-bottom: 2rem;
}

.lesson-list li {
  counter-increment: lesson;
  padding: 0.8rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
}

.lesson-list li:last-child {
  border-bottom: none;
}

.lesson-list li::before {
  content: counter(lesson, decimal-leading-zero);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
  min-width: 1.5rem;
}

.lesson-list a {
  color: var(--ink);
  font-weight: 500;
}

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

.lesson-list .lesson-time {
  font-family: var(--font-heading);
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-left: auto;
}

.lesson-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-heading);
  font-size: 0.9rem;
}

.lesson-nav a {
  color: var(--ink-muted);
}

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

.tag--course {
  color: #047857;
  background: rgba(4, 120, 87, 0.08);
}

.callout {
  border-left: 3px solid var(--accent);
  padding: 0.8rem 1.2rem;
  margin: 1.5rem 0;
  background: var(--cream-dark);
  border-radius: 0 4px 4px 0;
}

.callout--tip { border-left-color: #0369A1; }
.callout--warning { border-left-color: #DC2626; }
.callout--key { border-left-color: var(--accent); }

.callout p {
  margin-bottom: 0;
  font-size: 0.95rem;
}

.exercise {
  background: var(--cream-dark);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.exercise h3 {
  font-size: 1rem;
  margin-bottom: 0.8rem;
  color: var(--accent);
}

details {
  margin: 1rem 0;
}

summary {
  cursor: pointer;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
  padding: 0.5rem 0;
}

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

details[open] summary {
  margin-bottom: 0.5rem;
}

/* ===== Horizontal Scroll Row (Homepage) ===== */
.scroll-row {
  display: flex;
  gap: 1.2rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.5rem;
  margin-bottom: 2.5rem;
}

.scroll-row::-webkit-scrollbar {
  height: 6px;
}

.scroll-row::-webkit-scrollbar-track {
  background: var(--cream-dark);
  border-radius: 3px;
}

.scroll-row::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.scroll-row::-webkit-scrollbar-thumb:hover {
  background: var(--ink-muted);
}

.scroll-card {
  flex: 0 0 340px;
  scroll-snap-align: start;
}

.scroll-row .course-card {
  margin-bottom: 0;
}

.article-card {
  background: var(--cream-dark);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.article-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.article-card h3 {
  margin-bottom: 0.3rem;
}

.article-card h3 a {
  color: var(--ink);
  text-decoration: none;
}

.article-card h3 a:hover {
  color: var(--accent);
}

.article-card p {
  font-size: 0.95rem;
  margin-bottom: 0;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  html {
    font-size: 16px;
  }

  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.8rem;
  }

  .site-nav {
    gap: 1.2rem;
  }

  h1 {
    font-size: 1.8rem;
  }

  .hero-canvas-wrap {
    height: 280px;
  }

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

  .site-footer .container {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-header {
    flex-direction: column;
    gap: 0.3rem;
  }
}

/* ===== Print ===== */
@media print {
  body {
    background: white;
    color: black;
  }

  .site-header,
  .site-footer,
  .skip-link {
    display: none;
  }
}
