/* ============================================
   NOTEBOOK.CSS - Jupyter-inspired UI theme
   ============================================
   Loaded only on notebook pages (homepage + list pages)
   NEVER loaded together with main.css
   ============================================ */

/* ============================================
   CSS VARIABLES
   ============================================ */

:root {
  /* Background colors */
  --bg-primary: #1e1e1e;
  --bg-secondary: #252526;
  --bg-cell: #2d2d2d;
  --bg-cell-hover: #323232;
  --bg-code-input: #1e1e1e;

  /* Text colors */
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --text-muted: #6a6a6a;
  --text-execution: #7c7c7c;

  /* Accent colors */
  --accent-blue: #4fc3f7;
  --accent-green: #81c784;
  --accent-orange: #ffb74d;
  --accent-purple: #b39ddb;
  --accent-yellow: #fff176;

  /* Border & UI */
  --border-color: #3c3c3c;
  --link-color: #ffcc00;
  --link-hover: #ffeb9b;
}

/* ============================================
   BASE STYLES
   ============================================ */

html {
  background: linear-gradient(#2a2a29, #1c1c1c);
  min-height: 100vh;
  box-sizing: border-box;
}

*, *:before, *:after {
  box-sizing: inherit;
}

body {
  margin: 0;
  padding: 0;
  padding-top: 40px; /* Override to account for fixed header */
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--text-primary);
  line-height: 1.6;
}

/* ============================================
   NOTEBOOK CONTAINER
   ============================================ */

.notebook {
  max-width: 55ch;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* ============================================
   CELL-BASED LAYOUT
   ============================================ */

.cell {
  margin-bottom: 8px;
  border-radius: 4px;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
}

.cell:hover {
  border-color: var(--border-color);
  border-left-color: var(--accent-blue);
}

.cell-content {
  display: flex;
  align-items: flex-start;
}

.cell-gutter {
  width: 70px;
  flex-shrink: 0;
  text-align: right;
  padding-right: 12px;
  padding-left: 6px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  color: var(--text-execution);
  user-select: none;
  padding-top: 12px;
}

.cell-gutter .bracket {
  color: var(--accent-blue);
}

.cell-body {
  flex: 1;
  padding: 10px 16px 10px 12px;
  min-width: 0;
}

/* ============================================
   CODE CELLS
   ============================================ */

.code-cell .cell-body {
  padding: 0;
}

.code-input {
  background: var(--bg-code-input);
  border-radius: 4px;
  padding: 12px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-x: auto;
  text-align: left;
}

/* Syntax highlighting */
.keyword {
  color: var(--accent-purple);
}

.function {
  color: var(--accent-yellow);
}

.string {
  color: var(--accent-green);
}

.variable {
  color: var(--accent-blue);
}

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

.number {
  color: var(--accent-green);
}

.operator {
  color: var(--text-secondary);
}

.builtin {
  color: var(--accent-blue);
}

/* ============================================
   MARKDOWN CELLS
   ============================================ */

.markdown-cell .cell-gutter {
  /* Empty gutter for markdown cells */
}

.markdown-cell .cell-body {
  padding: 12px 16px 12px 0;
  max-width: 55ch;
}

.markdown-cell h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 16px 0;
  color: var(--text-primary);
}

.markdown-cell h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 24px 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.markdown-cell h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 12px 0;
  color: var(--text-secondary);
}

.markdown-cell p {
  margin: 0 0 12px 0;
  font-size: 16px;
  line-height: 1.6;
}

.markdown-cell strong,
.markdown-cell b {
  color: var(--accent-orange);
  font-weight: 500;
}

.markdown-cell a {
  color: var(--link-color);
  text-decoration: none;
}

.markdown-cell a:hover {
  text-decoration: underline;
}

/* ============================================
   OUTPUT CELLS
   ============================================ */

.output-cell .cell-body {
  padding: 0 0 12px 8px;
}

/* ============================================
   DATAFRAME OUTPUT
   ============================================ */

.dataframe-output {
  overflow-x: auto;
}

.dataframe {
  border-collapse: collapse;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  width: 100%;
  margin: 8px 0;
}

.dataframe thead {
  background: var(--bg-secondary);
}

.dataframe th {
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
}

.dataframe td {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.dataframe td.index {
  color: var(--text-secondary);
  font-weight: 500;
}

.dataframe tbody tr:hover {
  background: var(--bg-cell);
}

/* ============================================
   NAVIGATION OUTPUT (Homepage)
   ============================================ */

.nav-output {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-cell);
  border: 1px solid var(--border-color);
  border-left: 3px solid transparent;
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.nav-link:hover {
  background: var(--bg-cell-hover);
  border-color: var(--border-color);
  border-left-color: var(--accent-blue);
}

.nav-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.nav-content {
  flex: 1;
  min-width: 0;
}

.nav-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link:hover .nav-title {
  color: var(--accent-blue);
}

.nav-arrow {
  opacity: 0.6;
  transition: all 0.2s ease;
}

.nav-link:hover .nav-arrow {
  opacity: 1;
  transform: translateX(4px);
}

.nav-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.nav-meta {
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* ============================================
   LIST CONTENT OUTPUT (List Pages)
   ============================================ */

.list-content {
  max-width: 55ch;
  font-size: 16px;
  line-height: 1.6;
  padding: 12px 0 12px 1px;
  text-align: left;
}

.list-content h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 24px 0;
  color: var(--text-primary);
}

.list-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 24px 0 12px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

.list-content h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 12px 0;
  color: var(--text-secondary);
}

.list-content h4 {
  font-size: 15px;
  font-weight: 500;
  margin: 16px 0 8px 0;
  color: var(--text-secondary);
}

.list-content p {
  margin: 8px 0;
  line-height: 1.6;
}

.list-content a {
  color: var(--link-color);
  text-decoration: none;
}

.list-content a:hover {
  text-decoration: underline;
  color: var(--link-hover);
}

.list-content ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.list-content li {
  margin: 6px 0;
}

/* ============================================
   WIDGET CELLS (Substack embed, etc.)
   ============================================ */

.widget-cell .cell-body {
  padding: 20px 0;
}

.widget-container {
  display: flex;
  justify-content: center;
  align-items: center;
}

.widget-container iframe {
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-secondary);
  width: 100%;
  max-width: 480px;
  height: 320px;
}

/* ============================================
   MOBILE RESPONSIVENESS
   ============================================ */

@media (max-width: 768px) {
  .notebook {
    max-width: 90%;
    padding: 20px 12px 40px;
  }

  .list-content,
  .markdown-cell .cell-body {
    max-width: 100%;
  }

  .list-content h1 {
    font-size: 28px;
  }

  .list-content h2 {
    font-size: 24px;
  }

  .list-content h3 {
    font-size: 20px;
  }

  .list-content h4 {
    font-size: 18px;
  }

  .list-content p {
    font-size: 16px;
  }
}

@media (max-width: 640px) {
  .cell-gutter {
    width: 66px;
    font-size: 10px;
    padding-right: 6px;
    padding-left: 6px;
  }

  .code-input {
    font-size: 13px;
  }

  .dataframe {
    font-size: 11px;
  }

  .dataframe th,
  .dataframe td {
    padding: 6px 8px;
  }

  .nav-link {
    padding: 10px 12px;
    gap: 12px;
  }

  .nav-icon {
    font-size: 20px;
  }

  .nav-title {
    font-size: 15px;
  }

  .nav-desc {
    font-size: 12px;
  }

  .nav-meta {
    font-size: 12px;
  }

  .widget-container iframe {
    max-width: 100%;
    height: 280px;
  }
}
