/* 
 * MML Minimalist Theme
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* --- Light Theme (Default) --- */
  --bg-canvas: #ffffff;
  --bg-surface: #ffffff;
  --bg-surface-hover: #f5f5f5;
  --text-primary: #000000;
  --text-secondary: #444444;
  --text-tertiary: #888888;
  --accent-primary: #000000; /* Minimalist accent is also black or dark grey */
  --border-color: #e5e5e5;
  
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-speed: 0.3s;
}

[data-theme="dark"] {
  /* --- Dark Theme --- */
  --bg-canvas: #000000;
  --bg-surface: #000000;
  --bg-surface-hover: #1a1a1a;
  --text-primary: #ffffff;
  --text-secondary: #bbbbbb;
  --text-tertiary: #666666;
  --accent-primary: #ffffff;
  --border-color: #333333;
}

/* --- GLOBAL RESET & BASE --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none !important; transition: opacity 0.2s ease; }
a:hover { opacity: 0.7; }

/* --- APP STRUCTURE --- */
.app-container {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 24px;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 2;
}

/* --- HEADER --- */
.navbar {
  width: 100%;
  height: 80px;
  display: flex;
  justify-content: flex-start; /* Left align for cleaner look */
  align-items: center;
  flex-shrink: 0;
}

.nav-links { display: flex; gap: 32px; }
.nav-link {
  font-size: 0.9rem; font-weight: 500; 
  color: var(--text-secondary);
}
.nav-link:hover, .nav-link.active { color: var(--text-primary); }

/* --- THEME TOGGLE (Top Right) --- */
.theme-toggle-btn {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--bg-canvas); /* Prevent see-through */
}

.theme-toggle-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--text-primary);
}

/* --- HERO SECTION --- */
.hero {
  min-height: 30vh;
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* Left align minimalist */
  justify-content: center;
  text-align: left;
  width: 100%;
  margin-bottom: 60px;
  padding-top: 40px;
}

.main-title {
  font-size: clamp(2.5rem, 5vw, 4rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.tagline {
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 600px;
  font-weight: 400;
}

/* --- FEATURE GRID --- */
.features-container { width: 100%; margin-bottom: 100px; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  width: 100%;
}

.feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px; /* Sharper corners */
  padding: 32px;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.feature-card:hover {
  border-color: var(--text-primary);
}

.card-icon {
  margin-bottom: 20px;
  color: var(--text-primary);
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: flex-start;
}
.card-icon i { width: 24px; height: 24px; }

.card-content h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.card-content p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
  flex: 1;
}

.link-arrow {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-primary);
}
.link-arrow i { width: 14px; height: 14px; transition: transform 0.2s ease; }
.feature-card:hover .link-arrow i { transform: translateX(4px); }

/* --- LIST ITEMS (Blog, etc) --- */
.stacked-list {
  display: flex; flex-direction: column; gap: 16px;
  max-width: 800px; margin: 0 auto 80px;
}

.list-item {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.2s ease;
}

.list-item:hover { border-color: var(--text-primary); }

.item-content { display: flex; align-items: center; gap: 20px; flex: 1; }
.item-title { font-size: 1.2rem; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; display: block; }
.item-desc { font-size: 0.9rem; color: var(--text-secondary); }

/* --- FOOTER --- */
footer {
  width: 100%;
  padding: 40px 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

/* --- SIDEBAR LAYOUT (For Learn) --- */
.sidebar-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 40px;
  width: 100%;
  position: relative;
  transition: all 0.3s ease;
}

.sidebar-layout.collapsed {
  grid-template-columns: 0px 1fr;
  gap: 0;
}

.sidebar {
  position: sticky;
  top: 20px;
  height: calc(100vh - 40px);
  overflow-y: auto;
  border-right: 1px solid var(--border-color);
  padding-right: 20px;
  transition: all 0.3s ease;
}

.sidebar-layout.collapsed .sidebar {
  padding-right: 0;
  border-right: none;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.sidebar-header {
  margin-bottom: 24px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-tertiary);
  letter-spacing: 0.05em;
  display: flex; justify-content: space-between; align-items: center;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.sidebar-link:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  font-weight: 600;
}

.group-title {
  padding: 8px 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
}
.group-title:hover { opacity: 0.7; }
.group-children { padding-left: 12px; border-left: 1px solid var(--border-color); margin-left: 4px; display: flex; flex-direction: column; gap: 2px; }

.sidebar-group.collapsed .group-children { display: none; }
.sidebar-group.collapsed .group-arrow { transform: rotate(-90deg); }
.group-arrow { width: 14px; height: 14px; transition: transform 0.2s ease; }

.sidebar-toggle-btn {
  background: transparent; border: 1px solid var(--border-color);
  width: 32px; height: 32px; border-radius: 4px; display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); cursor: pointer;
}
.sidebar-toggle-btn:hover { border-color: var(--text-primary); color: var(--text-primary); }

.breadcrumb-bar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 32px; color: var(--text-tertiary); font-size: 0.9rem;
}
.breadcrumb-bar a:hover { color: var(--text-primary); }

.mobile-toc-toggle {
    display: none;
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--bg-surface); border: 1px solid var(--border-color);
    padding: 10px 20px; border-radius: 20px; z-index: 1000;
    font-weight: 600; align-items: center; gap: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* --- MARKDOWN / CONTENT --- */
.reading-content { width: 100%; max-width: 750px; margin: 0 auto; }

.article-header { border-bottom: 1px solid var(--border-color); padding-bottom: 24px; margin-bottom: 32px; }
.article-title { font-size: 2.5rem; font-weight: 800; line-height: 1.2; letter-spacing: -0.02em; }

.markdown-body { 
  line-height: 1.7; 
  color: var(--text-secondary); 
  font-size: 1.05rem; 
}

.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { 
  color: var(--text-primary); 
  margin-top: 2em; margin-bottom: 1em; 
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.markdown-body h1 { font-size: 2rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.3em; }
.markdown-body h2 { font-size: 1.6rem; }
.markdown-body h3 { font-size: 1.3rem; }

.markdown-body p { margin-bottom: 1.5em; }

.markdown-body a { 
  border-bottom: 1px solid var(--border-color); 
  color: var(--text-primary); 
  font-weight: 500;
}
.markdown-body a:hover { border-bottom-color: var(--text-primary); background: var(--bg-surface-hover); }

.markdown-body ul, .markdown-body ol { margin-bottom: 1.5em; padding-left: 1.5em; }
.markdown-body li { margin-bottom: 0.5em; }

.markdown-body blockquote {
  border-left: 3px solid var(--text-primary);
  padding-left: 1em;
  margin-left: 0;
  margin-bottom: 1.5em;
  color: var(--text-tertiary);
  font-style: italic;
}

.markdown-body img { max-width: 100%; border-radius: 4px; margin: 1.5em 0; display: block; }

.markdown-body pre {
  background: var(--bg-surface-hover);
  padding: 16px;
  border-radius: 6px;
  overflow-x: auto;
  margin-bottom: 1.5em;
  border: 1px solid var(--border-color);
}

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-surface-hover);
  padding: 2px 4px;
  border-radius: 3px;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
  color: var(--text-primary);
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5em;
}
.markdown-body th, .markdown-body td {
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    text-align: left;
}
.markdown-body th { background: var(--bg-surface-hover); font-weight: 600; }

/* Page Footer in Article */
.page-footer {
    display: flex; justify-content: space-between; margin-top: 60px; padding-top: 20px; border-top: 1px solid var(--border-color);
}
.footer-link { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 0.9rem; }

/* Responsive */
@media (max-width: 1024px) {
  .sidebar-layout { grid-template-columns: 1fr; }
  .sidebar-layout.collapsed { grid-template-columns: 1fr; }
  .sidebar {
      position: fixed; top: 0; left: 0; bottom: 0; width: 280px; z-index: 2000;
      background: var(--bg-surface); padding: 24px; border-right: 1px solid var(--border-color);
      transform: translateX(-100%);
  }
  .sidebar.show { transform: translateX(0); }
  .mobile-toc-toggle { display: flex; }
  .sidebar-toggle-btn { display: none; } /* Hide desktop toggle */
}

@media (max-width: 768px) {
  .navbar { justify-content: center; }
  .theme-toggle-btn { top: 20px; right: 20px; padding: 6px 12px; }
  .hero { text-align: center; align-items: center; }
  .nav-links { gap: 20px; }
  .main-title { font-size: 2.5rem; }
}

/* --- PRINT STYLES (PDF Export) --- */
@media print {
    @page {
        margin: 2cm;
    }

    /* Hide all UI elements */
    .navbar, 
    .theme-toggle-btn, 
    .sidebar, 
    .mobile-toc-toggle, 
    .sidebar-toggle-btn, 
    .breadcrumb-bar, 
    .page-footer,
    footer,
    .controls-floating,
    #toc-toggle,
    .print-hide { 
        display: none !important; 
    }

    /* Reset Layout for Print */
    body, html { 
        background-color: #ffffff !important; 
        color: #000000 !important; 
        height: auto !important;
        overflow: visible !important;
    }

    .app-container { 
        max-width: 100% !important; 
        width: 100% !important; 
        margin: 0 !important; 
        padding: 0 !important; 
    }

    .sidebar-layout { 
        display: block !important; 
        width: 100% !important; 
        grid-template-columns: 1fr !important;
        gap: 0 !important;
    }

    .reading-content { 
        max-width: 100% !important; 
        width: 100% !important; 
        margin: 0 !important; 
    }

    /* Markdown Specifics for Print */
    .markdown-body {
        font-size: 12pt !important;
        line-height: 1.5 !important;
        color: #000000 !important;
    }

    .markdown-body a {
        text-decoration: none !important;
        color: #000000 !important;
        border-bottom: none !important;
    }
    
    /* Optional: Show URL after links */
    /* .markdown-body a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.8em; opacity: 0.7; } */

    .markdown-body h1, .markdown-body h2 {
        page-break-after: avoid;
        color: #000000 !important;
        border-color: #000000 !important;
    }

    .markdown-body pre, .markdown-body code {
        background-color: #f5f5f5 !important;
        border: 1px solid #ddd !important;
        white-space: pre-wrap !important; /* Wrap long code lines */
    }
    
    .article-header {
        margin-bottom: 20px !important;
        padding-bottom: 10px !important;
        border-bottom: 2px solid #000 !important;
    }

    .article-title {
        font-size: 24pt !important;
        color: #000000 !important;
    }

    /* Break pages nicely */
    .markdown-body h1, .markdown-body h2 {
        margin-top: 2em;
    }
}
