/* ===== Synthetic Data Book — Professional Design System ===== */

/* ---- Google Fonts loaded in HTML: Inter + JetBrains Mono + Source Serif 4 ---- */

:root {
  /* Core palette */
  --bg: #ffffff;
  --bg-alt: #f8f9fc;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --text: #1a1a2e;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-sidebar: #cbd5e1;
  --text-sidebar-active: #ffffff;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #eef2ff;
  --accent-glow: rgba(79, 70, 229, 0.08);
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  /* Code */
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --code-header: #1e293b;
  --code-accent: #818cf8;

  /* Callouts */
  --callout-bg: #f0f9ff;
  --callout-border: #3b82f6;
  --callout-icon: #2563eb;
  --warning-bg: #fffbeb;
  --warning-border: #f59e0b;
  --warning-icon: #d97706;
  --success-bg: #f0fdf4;
  --success-border: #22c55e;

  /* Typography */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Source Serif 4', 'Georgia', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Layout */
  --sidebar-width: 290px;
  --max-content: 760px;
  --content-padding: 3.5rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 40px -10px rgba(0,0,0,0.1);

  /* Transitions */
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 17px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.78;
  display: flex;
  min-height: 100vh;
}

::selection {
  background: var(--accent-light);
  color: var(--accent);
}

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-sidebar);
  padding: 0;
  z-index: 100;
  transition: transform .3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

/* Scrollbar styling for sidebar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 4px; }

.sidebar-header {
  padding: 2rem 1.5rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar .book-title {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.sidebar .book-subtitle {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 0.25rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar nav {
  flex: 1;
  padding: 0.75rem 0;
}

.sidebar nav ul { list-style: none; }
.sidebar nav > ul > li { margin-bottom: 1px; }

.sidebar nav a {
  display: flex;
  align-items: center;
  padding: 0.55rem 1.5rem;
  text-decoration: none;
  color: var(--text-sidebar);
  font-size: 0.82rem;
  font-weight: 450;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  letter-spacing: 0.005em;
}

.sidebar nav a:hover {
  background: var(--bg-sidebar-hover);
  color: #e2e8f0;
  border-left-color: #475569;
}

.sidebar nav a.active {
  background: rgba(79, 70, 229, 0.15);
  color: #a5b4fc;
  font-weight: 600;
  border-left-color: var(--accent);
}

.sidebar-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 0.7rem;
  color: #475569;
}

/* Chapter number badges in sidebar */
.sidebar nav .ch-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  font-size: 0.7rem;
  font-weight: 600;
  color: #94a3b8;
  margin-right: 0.65rem;
  flex-shrink: 0;
}

.sidebar nav a.active .ch-num {
  background: rgba(79, 70, 229, 0.3);
  color: #c7d2fe;
}

/* ================================================================
   MAIN CONTENT
   ================================================================ */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: var(--content-padding) var(--content-padding) 6rem;
  max-width: calc(var(--max-content) + var(--content-padding) * 2);
  min-height: 100vh;
}

/* ================================================================
   TYPOGRAPHY
   ================================================================ */
h1 {
  font-family: var(--font-heading);
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin-bottom: 0.5rem;
  color: var(--text);
}

h1 .chapter-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

h2 {
  font-size: 1.45rem;
  font-weight: 700;
  margin-top: 3rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  letter-spacing: -0.02em;
}

h3 {
  font-size: 1.12rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.4rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

p {
  margin-bottom: 1.1rem;
  color: var(--text);
}

/* Reading body text in serif for long-form readability */
.chapter p,
.chapter li {
  font-family: var(--font-serif);
  font-size: 1.02rem;
  line-height: 1.82;
}

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

strong { font-weight: 650; }
em { font-style: italic; }

/* ---- Chapter Meta ---- */
.chapter-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}

.chapter-meta .badge {
  background: var(--accent-light);
  color: var(--accent);
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.72rem;
  font-family: var(--font-body);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.chapter-meta .reading-time {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-left: 0.5rem;
  font-family: var(--font-body);
}

/* ================================================================
   CALLOUTS
   ================================================================ */
.callout {
  border-left: 4px solid var(--callout-border);
  background: var(--callout-bg);
  padding: 1.15rem 1.35rem;
  border-radius: 0 10px 10px 0;
  margin: 1.5rem 0;
  font-size: 0.92rem;
  position: relative;
}

.callout::before {
  content: "i";
  position: absolute;
  left: -0.7rem;
  top: 1.15rem;
  width: 1.35rem;
  height: 1.35rem;
  background: var(--callout-border);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  font-style: italic;
  font-family: var(--font-serif);
}

.callout strong {
  display: block;
  margin-bottom: 0.3rem;
  font-family: var(--font-body);
  color: var(--callout-icon);
  font-size: 0.85rem;
  letter-spacing: 0.01em;
}

.callout p:last-child { margin-bottom: 0; }

.callout.warning {
  border-left-color: var(--warning-border);
  background: var(--warning-bg);
}
.callout.warning::before {
  content: "!";
  background: var(--warning-border);
  font-style: normal;
}
.callout.warning strong {
  color: var(--warning-icon);
}

.callout.success {
  border-left-color: var(--success-border);
  background: var(--success-bg);
}
.callout.success::before {
  content: "✓";
  background: var(--success-border);
  font-style: normal;
  font-size: 0.65rem;
}

/* ================================================================
   CODE BLOCKS
   ================================================================ */
pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 1.4rem 1.6rem;
  border-radius: 12px;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.82rem;
  line-height: 1.65;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255,255,255,0.05);
  position: relative;
}

pre::before {
  content: attr(data-lang);
  position: absolute;
  top: 0.65rem;
  right: 0.85rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  font-family: var(--font-body);
  font-weight: 500;
}

pre code {
  font-family: var(--font-mono);
  font-weight: 400;
}

code:not(pre code) {
  background: var(--bg-alt);
  padding: 0.15rem 0.45rem;
  border-radius: 5px;
  font-size: 0.86em;
  font-family: var(--font-mono);
  color: var(--accent);
  border: 1px solid var(--border-light);
}

/* Code copy button */
.code-wrapper {
  position: relative;
}
.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  color: #94a3b8;
  font-size: 0.7rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: all var(--transition);
  z-index: 2;
}
.copy-btn:hover {
  background: rgba(255,255,255,0.15);
  color: #e2e8f0;
}

/* ================================================================
   TABLES
   ================================================================ */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.88rem;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

th, td {
  text-align: left;
  padding: 0.75rem 1rem;
}

th {
  font-weight: 600;
  background: var(--bg-alt);
  color: var(--text);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
}

td {
  border-bottom: 1px solid var(--border-light);
}

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

tr:hover td {
  background: var(--accent-glow);
}

/* ---- Lists inside content ---- */
.main ul, .main ol {
  margin: 0.5rem 0 1.2rem 1.5rem;
}
.main li {
  margin-bottom: 0.4rem;
}
.main li::marker {
  color: var(--accent);
}

/* ================================================================
   FIGURES
   ================================================================ */
figure {
  margin: 2rem 0;
  text-align: center;
  background: var(--bg-alt);
  border-radius: 12px;
  padding: 1.5rem;
  border: 1px solid var(--border-light);
}

figure img {
  max-width: 100%;
  border-radius: 8px;
  transition: transform var(--transition);
}

figure img:hover {
  transform: scale(1.01);
}

figcaption {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
  font-style: italic;
  font-family: var(--font-serif);
}

/* ================================================================
   CHAPTER NAVIGATION (prev / next)
   ================================================================ */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  gap: 1rem;
}

.chapter-nav a {
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: all var(--transition);
  font-family: var(--font-body);
}

.chapter-nav a:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

/* ================================================================
   INLINE CITATIONS
   ================================================================ */
.cite {
  color: var(--accent);
  font-size: 0.82em;
  text-decoration: none;
  cursor: pointer;
  vertical-align: super;
  line-height: 0;
  font-weight: 600;
  font-family: var(--font-body);
  transition: color var(--transition);
}
.cite:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.cite-inline {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.cite-inline:hover { text-decoration: underline; }

/* ================================================================
   REFERENCES SECTION
   ================================================================ */
.references {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 2px solid var(--border);
}
.references h2 {
  border-bottom: none;
  margin-bottom: 1.25rem;
  font-size: 1.3rem;
}
.references ol {
  list-style: none;
  counter-reset: ref-counter;
  padding-left: 0;
  margin-left: 0;
}
.references ol li {
  counter-increment: ref-counter;
  position: relative;
  padding-left: 2.8rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  line-height: 1.7;
  color: var(--text);
  font-family: var(--font-body);
}
.references ol li::before {
  content: "[" counter(ref-counter) "]";
  position: absolute;
  left: 0;
  font-weight: 700;
  color: var(--accent);
  font-size: 0.82rem;
  font-family: var(--font-mono);
}
.references ol li .ref-authors { font-weight: 600; }
.references ol li .ref-title { font-style: italic; color: var(--text); }
.references ol li .ref-venue { color: var(--text-muted); }
.references ol li .ref-doi {
  font-size: 0.78rem;
  color: var(--accent);
  word-break: break-all;
}

/* ================================================================
   LANDING PAGE
   ================================================================ */
.hero {
  text-align: center;
  padding: 3rem 0 2.5rem;
}

.hero h1 {
  font-size: 3rem;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-bottom: 0.75rem;
}

.hero .subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 400;
  max-width: 500px;
  margin: 0 auto 1rem;
}

.hero .authors-line {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  margin: 0;
  text-transform: uppercase;
}

.hero-divider {
  width: 60px;
  height: 3px;
  background: var(--accent);
  border-radius: 999px;
  margin: 2.5rem auto;
}

.book-cover-section {
  display: flex;
  justify-content: center;
  margin: 0 auto 2.5rem;
}

.book-cover-link {
  display: block;
  width: min(100%, 380px);
  border-radius: 8px;
  box-shadow: var(--shadow-xl);
  background: #020617;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.16);
}

.book-cover-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 26px 54px -18px rgba(15, 23, 42, 0.32);
  text-decoration: none;
}

.book-cover-link img {
  display: block;
  width: 100%;
  height: auto;
}

/* Info boxes on landing page */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}

.info-box {
  padding: 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: var(--bg-alt);
}

.info-box h3 {
  font-size: 0.85rem;
  margin-top: 0;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.info-box p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0;
  line-height: 1.6;
}

/* CTA button */
.cta-section {
  text-align: center;
  margin: 2.5rem 0 1rem;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: white;
  padding: 0.85rem 2rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  text-decoration: none;
  transition: all var(--transition);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
  transform: translateY(-1px);
  text-decoration: none;
  color: white;
}

/* ================================================================
   PROGRESS BAR (top of page)
   ================================================================ */
.reading-progress {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 99;
}

.reading-progress .bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #818cf8);
  width: 0%;
  transition: width 0.1s linear;
  border-radius: 0 2px 2px 0;
}

/* ================================================================
   SCROLL TO TOP
   ================================================================ */
.scroll-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: all var(--transition);
  z-index: 90;
}

.scroll-top.visible {
  opacity: 1;
  transform: translateY(0);
}

.scroll-top:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-xl);
}

/* ================================================================
   HAMBURGER (mobile)
   ================================================================ */
.menu-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--bg-sidebar);
  color: #fff;
  border: none;
  border-radius: 10px;
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all var(--transition);
}

.menu-toggle:hover {
  background: var(--bg-sidebar-hover);
}

/* Overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  backdrop-filter: blur(4px);
}
.sidebar-overlay.active {
  display: block;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }
  .sidebar.open { transform: translateX(0); }

  .main {
    margin-left: 0;
    padding: 2rem 1.25rem 4rem;
  }

  .menu-toggle { display: flex; align-items: center; justify-content: center; }

  .reading-progress { left: 0; }

  .hero h1 { font-size: 2.2rem; }

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

  h1 { font-size: 1.9rem; }
  h2 { font-size: 1.3rem; }
}

@media (max-width: 500px) {
  .hero h1 { font-size: 1.8rem; }
  pre { font-size: 0.78rem; padding: 1rem 1.2rem; }
}

/* ================================================================
   PRINT STYLES
   ================================================================ */
@media print {
  .sidebar, .menu-toggle, .scroll-top, .reading-progress, .chapter-nav { display: none !important; }
  .main { margin-left: 0; max-width: 100%; padding: 1rem; }
  body { font-size: 11pt; }
  pre { border: 1px solid #ccc; box-shadow: none; }
  a { color: var(--text); text-decoration: underline; }
}
