/* ============================================
   Learn Linux — Complete Redesign
   Technology Channel
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Palette: warm neutral + teal accent */
  --bg: #fafaf9;
  --bg-elevated: #ffffff;
  --bg-muted: #f5f5f4;
  --text: #1c1917;
  --text-muted: #57534e;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-soft: #ccfbf1;
  --border: #e7e5e4;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.1);
  --topbar-h: 64px;
  --sidebar-w: 272px;
  --content-max: 720px;
  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;
  --hero-illus: rgba(28, 25, 23, 0.12);
  --focus-ring: 2px solid var(--accent);
  --focus-offset: 2px;
}

body.dark {
  --bg: #18181b;
  --bg-elevated: #27272a;
  --bg-muted: #3f3f46;
  --text: #fafaf9;
  --text-muted: #a1a1aa;
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-soft: #134e4a;
  --border: #3f3f46;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --hero-illus: rgba(255, 255, 255, 0.15);
}

/* Dark theme: logo is white, keep it visible (no invert) */
body.dark .topnav__tagline-icon {
  filter: none;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 24px);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Focus visible for accessibility */
:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
}

a:focus-visible,
button:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-sm);
}

/* ===== TOP NAV ===== */
.topnav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  box-shadow: 0 1px 0 rgba(0,0,0,0.05);
}

body.dark .topnav {
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}

.topnav__logo {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-decoration: none;
  color: inherit;
  transition: opacity var(--transition);
}

.topnav__logo:hover {
  opacity: 0.88;
}

.topnav__logo-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--text);
}

.topnav__tagline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
}

.topnav__tagline-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
  /* Logo is white/transparent: show dark in light theme */
  filter: invert(1);
}

.topnav__links {
  display: flex;
  align-items: center;
  gap: 2px;
  list-style: none;
}

.topnav__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topnav__links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}

.topnav__links a:hover {
  background: var(--bg-muted);
  color: var(--text);
}

.topnav__links a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

body.dark .topnav__links a.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-toggle,
.menu-toggle {
  background: var(--bg-muted);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition), transform 0.15s ease;
}

.theme-toggle:hover,
.menu-toggle:hover {
  background: var(--border);
  color: var(--text);
}

.theme-toggle:active,
.menu-toggle:active {
  transform: scale(0.96);
}

.theme-toggle svg,
.menu-toggle svg {
  width: 20px;
  height: 20px;
}

.menu-toggle {
  display: none;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  overflow-y: auto;
  z-index: 100;
}

.sidebar__title {
  font-family: 'Outfit', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 20px 10px;
  margin-bottom: 4px;
  margin-top: 8px;
}

.sidebar__title:first-child {
  margin-top: 0;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  border-left: 3px solid transparent;
  margin: 0 8px;
  border-radius: var(--radius-sm);
}

.sidebar__link:hover {
  color: var(--text);
  background: var(--bg-muted);
}

.sidebar__link.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.sidebar__link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.9;
  color: inherit;
  fill: none;
  stroke: currentColor;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

/* ===== PROGRESS BAR ===== */
.progress-bar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border);
  z-index: 1001;
}

.progress-bar__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 100%);
  transition: width 0.15s ease;
}

/* ===== MAIN CONTENT ===== */
.main {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  padding: 40px 48px 96px;
}

.content {
  max-width: var(--content-max);
  margin: 0 auto;
}

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

h1 {
  font-size: clamp(1.875rem, 4.5vw, 2.5rem);
  margin-bottom: 16px;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 1.5rem;
  margin-top: 2.75rem;
  margin-bottom: 1rem;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
  letter-spacing: -0.02em;
}

h2:first-of-type {
  margin-top: 0;
}

h3 {
  font-size: 1.2rem;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

p {
  margin-bottom: 1.125rem;
}

ul, ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.4rem;
}

li::marker {
  color: var(--accent);
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875em;
  padding: 0.25em 0.5em;
  background: var(--bg-muted);
  border-radius: 6px;
  color: var(--text);
  border: 1px solid var(--border);
}

pre {
  margin: 0;
  overflow-x: auto;
}

pre code {
  padding: 0;
  background: none;
  font-size: 0.85rem;
}

/* ===== HERO ===== */
.hero {
  margin-bottom: 2.75rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.hero__badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 8px 14px;
  border-radius: 999px;
  margin-bottom: 20px;
}

.hero p {
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 58ch;
}

.hero__illustration {
  margin-top: 24px;
  max-width: 200px;
}

.hero__illustration svg {
  width: 100%;
  height: auto;
  opacity: 0.9;
}

.hero__illustration svg path,
.hero__illustration svg ellipse {
  fill: var(--hero-illus);
  opacity: 1;
}

/* ===== CODE BLOCK ===== */
.code-block {
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1.25rem 0;
  box-shadow: var(--shadow);
}

.code-block__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.code-block__dots {
  display: flex;
  gap: 6px;
}

.code-block__dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}

.code-block__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: auto;
}

.code-block__copy {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.code-block__copy:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.code-block pre {
  padding: 18px 22px;
}

.code-block .prompt {
  color: var(--accent);
  user-select: none;
}

.code-block .command {
  color: var(--text);
}

.code-block .flag {
  color: #b45309;
}

body.dark .code-block .flag {
  color: #fcd34d;
}

.code-block .path {
  color: #059669;
}

body.dark .code-block .path {
  color: #34d399;
}

.code-block .string {
  color: #dc2626;
}

body.dark .code-block .string {
  color: #f87171;
}

.code-block .comment {
  color: var(--text-muted);
  font-style: italic;
}

/* ===== OUTPUT BLOCK ===== */
.output-block {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin: 0 0 1.25rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-muted);
  box-shadow: var(--shadow);
}

.output-block__label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 8px;
}

/* ===== INFO BOX ===== */
.info-box {
  display: flex;
  gap: 16px;
  padding: 20px 22px;
  margin: 1.5rem 0;
  background: var(--bg-muted);
  border-radius: var(--radius);
  border-left: 4px solid var(--border);
}

.info-box svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.info-box p {
  margin: 0;
  font-size: 0.95rem;
}

.info-box--tip {
  border-left-color: var(--accent);
}

.info-box--tip svg {
  color: var(--accent);
}

.info-box--note {
  border-left-color: #3b82f6;
}

.info-box--note svg {
  color: #3b82f6;
}

/* ===== TABLE ===== */
.table-wrapper {
  overflow-x: auto;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th, td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-muted);
  color: var(--text);
}

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

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover td {
  background: var(--bg-muted);
}

/* ===== TRY IT / PRACTICE ===== */
.try-it {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 1rem 0;
  box-shadow: var(--shadow);
}

.try-it__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--accent);
  margin-bottom: 10px;
}

.try-it__title svg {
  width: 20px;
  height: 20px;
}

.try-it p {
  margin-bottom: 0.5rem;
}

.try-it-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ===== QUIZ ===== */
.quiz-list {
  margin: 1.5rem 0;
}

.quiz-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 26px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.quiz-question {
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.quiz-options {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}

.quiz-options li {
  padding: 12px 16px;
  margin-bottom: 8px;
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  border: 2px solid transparent;
}

.quiz-options li:hover {
  background: var(--border);
}

.quiz-options li:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

.quiz-options li.correct {
  background: #dcfce7;
  border-color: #16a34a;
  color: #166534;
}

body.dark .quiz-options li.correct {
  background: #14532d;
  border-color: #22c55e;
  color: #86efac;
}

.quiz-options li.wrong {
  background: #fee2e2;
  border-color: #dc2626;
  color: #991b1b;
}

body.dark .quiz-options li.wrong {
  background: #450a0a;
  border-color: #ef4444;
  color: #fca5a5;
}

.quiz-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.quiz-item.revealed .quiz-options li {
  pointer-events: none;
}

/* ===== PAGE NAV ===== */
.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 20px;
  margin-top: 3.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.page-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  transition: border-color var(--transition), color var(--transition), box-shadow var(--transition);
  max-width: 300px;
  box-shadow: var(--shadow);
}

.page-nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow-md);
}

.page-nav__label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.page-nav a svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.page-nav a:first-of-type {
  flex-direction: row-reverse;
}

/* ===== FOOTER ===== */
.footer {
  margin-left: var(--sidebar-w);
  padding: 28px 48px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

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

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

/* ===== IMAGES ===== */
.svg-visual {
  margin: 1.25rem 0;
}

.svg-visual img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
    width: min(320px, 85vw);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
    background: rgba(0,0,0,0.5);
  }

  .main {
    margin-left: 0;
    padding: 28px 24px 72px;
  }

  .footer {
    margin-left: 0;
    padding: 24px;
  }

  .topnav__links {
    display: none;
  }

  .menu-toggle {
    display: flex;
  }
}

@media (max-width: 640px) {
  .topnav {
    padding: 0 16px;
  }

  .topnav__logo-title {
    font-size: 1.1rem;
  }

  .topnav__tagline {
    font-size: 0.7rem;
  }

  .main {
    padding: 24px 20px 64px;
  }

  .content {
    padding: 0 4px;
  }

  .page-nav {
    flex-direction: column;
    align-items: stretch;
    margin-top: 2.5rem;
    padding-top: 2rem;
  }

  .page-nav a {
    max-width: none;
  }

  .footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 20px;
  }
}

/* ===== ANIMATE IN ===== */
.animate-in {
  animation: fadeIn 0.5s ease forwards;
}

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