/* Custom styles for the Foreman book renderer. */

:root {
  --bg-page: #020617;
  --bg-card: #0f172a;
  --bg-elevated: #1e293b;
  --border: #1e293b;
  --border-light: #334155;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #22d3ee;
  --accent-dark: #06b6d4;
  --accent-glow: rgba(34, 211, 238, 0.15);
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4rem;
}

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Prose typography for chapter content */
.prose-foreman {
  font-size: 1.0625rem;
  line-height: 1.75;
  color: var(--text-primary);
}

.prose-foreman h1 {
  font-size: 2.25rem;
  font-weight: 800;
  margin-top: 0;
  margin-bottom: 1.5rem;
  line-height: 1.2;
  letter-spacing: -0.025em;
  color: #f1f5f9;
}

.prose-foreman h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: #f1f5f9;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.prose-foreman h3 {
  font-size: 1.375rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  line-height: 1.4;
  color: #e2e8f0;
}

.prose-foreman h4 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: #cbd5e1;
}

.prose-foreman p {
  margin-top: 0;
  margin-bottom: 1.25rem;
}

.prose-foreman strong {
  color: #f1f5f9;
  font-weight: 600;
}

.prose-foreman em {
  color: #cbd5e1;
  font-style: italic;
}

.prose-foreman a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(34, 211, 238, 0.3);
  text-underline-offset: 2px;
  transition: text-decoration-color 0.15s;
}

.prose-foreman a:hover {
  text-decoration-color: var(--accent);
}

.prose-foreman ul,
.prose-foreman ol {
  margin-top: 0;
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.prose-foreman li {
  margin-bottom: 0.5rem;
}

.prose-foreman ul > li {
  list-style: disc;
}

.prose-foreman ol > li {
  list-style: decimal;
}

.prose-foreman blockquote {
  border-left: 4px solid var(--accent);
  padding: 0.25rem 0 0.25rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
  background: var(--accent-glow);
  border-radius: 0 0.5rem 0.5rem 0;
}

.prose-foreman blockquote p {
  margin-bottom: 0.5rem;
}

.prose-foreman blockquote p:last-child {
  margin-bottom: 0;
}

.prose-foreman hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

.prose-foreman code {
  background: var(--bg-elevated);
  color: #fbbf24;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  font-size: 0.875em;
  font-weight: 500;
}

.prose-foreman pre {
  background: #0b1120;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  line-height: 1.6;
}

.prose-foreman pre code {
  background: transparent;
  color: var(--text-primary);
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

.prose-foreman table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9375rem;
}

.prose-foreman thead {
  border-bottom: 2px solid var(--border-light);
}

.prose-foreman th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  font-weight: 600;
  color: #cbd5e1;
}

.prose-foreman td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.prose-foreman tbody tr:last-child td {
  border-bottom: 0;
}

.prose-foreman img {
  max-width: 100%;
  border-radius: 0.5rem;
  margin: 1.5rem 0;
}

.prose-foreman .task-list-item {
  list-style: none;
  margin-left: -1.25rem;
}

.prose-foreman .task-list-item input {
  margin-right: 0.5rem;
}

/* Mermaid diagrams */
.mermaid-container {
  background: #0b1120;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  text-align: center;
}

.mermaid {
  background: transparent;
}

/* Code language label */
.code-block-wrapper {
  position: relative;
  margin: 1.5rem 0;
}

.code-block-wrapper pre {
  margin: 0;
}

.code-block-label {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  user-select: none;
}

/* Sidebar nav */
.nav-link {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: all 0.15s;
  border-left: 2px solid transparent;
}

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

.nav-link.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-left-color: var(--accent);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-page);
}

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

::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Selection */
::selection {
  background: var(--accent);
  color: #020617;
}

/* Reading progress */
#progress-bar {
  transition: width 0.1s linear;
}

/* Mobile menu overlay */
.sidebar-overlay {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

/* Print styles */
@media print {
  .no-print,
  header,
  aside,
  #progress-bar,
  .code-block-label {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .prose-foreman {
    color: black;
    max-width: 100%;
  }
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

#content {
  animation: fadeIn 0.3s ease-out;
}
