/*
  Bookdown GitBook — Elegant CSS Theme
  Author: ChatGPT
  Usage: save as style.css and reference in _output.yml under bookdown::gitbook

  Palette & variables
  ------------------------------------------------------------------ */
:root {
  --bg: #ffffff;
  --text: #1f2937;         /* slate-800 */
  --muted: #6b7280;        /* gray-500 */
  --primary: #2563eb;      /* blue-600 */
  --primary-700: #1d4ed8;  /* blue-700 */
  --accent: #14b8a6;       /* teal-500 */
  --link: var(--primary);
  --border: #e5e7eb;       /* gray-200 */
  --code-bg: #0b1021;      /* deep navy */
  --code-text: #e5e7eb;    /* light gray */
  --inline-code-bg: #f3f4f6; /* gray-100 */
  --highlight: #fff8e1;    /* soft yellow */
  --kbd-bg: #111827;       /* gray-900 */
  --kbd-text: #f9fafb;     /* gray-50 */

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 10px 25px rgba(0,0,0,0.08);
  --shadow-sm: 0 4px 12px rgba(0,0,0,0.06);
  --line: 1.6;
}

/* Typography & base -------------------------------------------------- */
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: var(--line);
  font-feature-settings: "liga" 1, "calt" 1;
  text-rendering: optimizeLegibility;
}


/*
╔═════════════════════════════════════════════════════════════════════════════════════════════════╗
╠═════════════════════════════════════════════════════════════════════════════════════════════════╣
║ font-family definitions                                                                         ║
╠═════════════════════════════════════════════════════════════════════════════════════════════════╣
╚═════════════════════════════════════════════════════════════════════════════════════════════════╝
*/

body 
	{ font-family: "Palatino Linotype", "Palatino", "Century Schoolbook", "Baskerville", "Nimbus Roman No9 L", "Times", "Times New Roman",  serif; 
	}

h1, h2, h3, h4, h5, h6
	{ font-family: "Trebuchet MS", "Futura", "Segoe UI", "Dejavu Sans", "Bitstream Vera Sans", 
				   sans-serif; 
	}

h1.chapterNumber
	{ font-family: "Century Gothic", "Futura", "Arial Narrow", "Dejavu Sans", 
				   sans-serif; 
	}

a, code, pre, span.url
	{ font-family: "Consolas", "Monaco", "Lucida Console", "Lucida Sans Typewriter", "Liberation Mono", 
				   monospace; 
	  word-wrap: break-word;
	  word-break: break-word;
	}








.book .book-body .page-wrapper .page-inner { max-width: 860px; }

p { font-size: 1.05rem; }
strong { color: #111827; }
em { color: #111827; }

/* Headings ----------------------------------------------------------- */
.page-inner h1,
.page-inner h2,
.page-inner h3,
.page-inner h4 {
  position: relative;
  scroll-margin-top: 100px;
}

.page-inner h1 { font-size: 2rem; margin-top: 2rem; }
.page-inner h2 { font-size: 1.6rem; margin-top: 1.75rem; }
.page-inner h3 { font-size: 1.3rem; margin-top: 1.4rem; }
.page-inner h4 { font-size: 1.1rem; margin-top: 1.1rem; }

.page-inner h1,
.page-inner h2 { border-bottom: 1px solid var(--border); padding-bottom: .35rem; }

/* Fancy heading anchors (show on hover) */
.page-inner h1:hover .anchor,
.page-inner h2:hover .anchor,
.page-inner h3:hover .anchor,
.page-inner h4:hover .anchor { opacity: 1; }

.page-inner .anchor {
  opacity: 0;
  transition: opacity .2s ease;
  margin-left: .5rem;
  text-decoration: none !important;
}

/* Links -------------------------------------------------------------- */
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--primary-700); }

/* Summary sidebar ---------------------------------------------------- */
.book .book-summary {
  background: #f9fafb;
  border-right: 1px solid var(--border);
}

.book .book-summary .book-search { padding: 0.75rem 1rem; }
.book .book-summary .book-search input,
.book .book-header .input-search input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  font-size: .95rem;
  transition: box-shadow .2s ease, border-color .2s ease;
}

.book .book-summary .book-search input:focus,
.book .book-header .input-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37,99,235,0.15); }

.book .book-summary ul.summary {
  padding: .75rem 0 1.5rem 0;
}
.book .book-summary ul.summary li a { color: #374151; border-radius: 10px; padding: .4rem .75rem; display: block; }
.book .book-summary ul.summary li a:hover { background: #eef2ff; color: var(--primary-700); }
.book .book-summary ul.summary li.active > a { background: #e0e7ff; color: var(--primary-700); font-weight: 600; }

/* Page header & navigation ------------------------------------------ */
.book .book-header { border-bottom: 1px solid var(--border); background: #ffffffe6; backdrop-filter: saturate(180%) blur(6px); }
.book .navigation { border-top: 1px dashed var(--border); margin-top: 2rem; padding-top: 1rem; }
.book .navigation a { border: 1px solid var(--border); padding: .6rem .9rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); background: white; }
.book .navigation a:hover { border-color: var(--primary); }

/* Figures & captions ------------------------------------------------- */
.figure, figure { margin: 1.25rem auto; text-align: center; }
img { border-radius: var(--radius); box-shadow: var(--shadow); }
figcaption, .caption { color: var(--muted); font-size: .9rem; margin-top: .4rem; }

/* Tables ------------------------------------------------------------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 1rem 0; box-shadow: var(--shadow-sm); border-radius: var(--radius); overflow: hidden; }
th, td { padding: .75rem .9rem; border-bottom: 1px solid var(--border); }
th { text-align: left; background: #f3f4f6; font-weight: 700; }
tr:nth-child(even) td { background: #fbfbfd; }
tr:hover td { background: #f8fafc; }

/* Code blocks -------------------------------------------------------- */
pre, code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

/* Inline code */
:not(pre) > code {
  background: var(--inline-code-bg);
  color: #1f2937;
  padding: .15rem .35rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* Block code (pandoc & highlight.js friendly) */
pre, pre code, .sourceCode, .sourceCode pre {
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius);
}

pre, .sourceCode pre { padding: 1rem 1.1rem; overflow: auto; box-shadow: var(--shadow-sm); }

/* Line numbers (if enabled) */
pre.numberSource code > span { display: inline-block; min-width: 2.25em; padding-right: .75em; color: #94a3b8; border-right: 1px solid rgba(255,255,255,.08); margin-right: .75em; }

/* Syntax accents (works with pandoc classes) */
code span.kw { color: #93c5fd; }
code span.st { color: #fde68a; }
code span.dv, code span.bn, code span.fl { color: #a7f3d0; }
code span.ch, code span.sc { color: #fbcfe8; }
code span.cf { color: #c7d2fe; font-weight: 600; }
code span.fu { color: #bef264; }
code span.op { color: #e5e7eb; }

/* Blockquotes & callouts -------------------------------------------- */
blockquote {
  margin: 1.25rem 0;
  padding: 1rem 1.25rem 1rem 1.1rem;
  border-left: 6px solid var(--accent);
  background: linear-gradient(180deg, #ecfeff, #ffffff);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
blockquote p { margin: 0.2rem 0; }

/* Admonition-like boxes using custom classes ------------------------ */
/* Use: <div class="admonition note"> ... */
.admonition {
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-left: 6px solid var(--primary);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}
.admonition.note { border-left-color: var(--primary); }
.admonition.tip { border-left-color: #22c55e; }
.admonition.warning { border-left-color: #f59e0b; }
.admonition.caution { border-left-color: #ef4444; }
.admonition .admonition-title { font-weight: 700; margin-bottom: .35rem; color: #111827; }

/* Lists -------------------------------------------------------------- */
ul, ol { padding-left: 1.2rem; }
ul li { margin: .35rem 0; }
ol li { margin: .3rem 0; }

/* Footnotes ---------------------------------------------------------- */
.footnotes { border-top: 1px dashed var(--border); margin-top: 2rem; padding-top: 1rem; }
.footnote-ref { font-size: .85rem; }

/* Tips inline badge -------------------------------------------------- */
.badge {
  display: inline-block;
  font-size: .75rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f9fafb;
  color: #111827;
}

/* KBD keyboard shortcuts -------------------------------------------- */
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: var(--kbd-bg);
  color: var(--kbd-text);
  padding: .15rem .35rem;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.2);
  font-size: .8rem;
}

/* Inline alerts (success/info/warn/error) --------------------------- */
.mark { background: var(--highlight); padding: .1rem .25rem; border-radius: 4px; }
.alert { padding: .75rem .9rem; border-radius: var(--radius-sm); border: 1px solid var(--border); margin: 1rem 0; }
.alert.success { background: #ecfdf5; border-color: #a7f3d0; }
.alert.info    { background: #eff6ff; border-color: #bfdbfe; }
.alert.warn    { background: #fffbeb; border-color: #fde68a; }
.alert.error   { background: #fef2f2; border-color: #fecaca; }

/* MathJax tweaks ----------------------------------------------------- */
.MathJax_Display { overflow-x: auto; padding: .5rem .75rem; border-radius: var(--radius-sm); background: #fbfbfd; }

/* Search results highlight ------------------------------------------ */
mark.search-highlight { background: #fde68a; padding: 0 .15rem; border-radius: 4px; }

/* HR ----------------------------------------------------------------- */
hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

/* Buttons/links in content ------------------------------------------ */
.btn {
  display: inline-block;
  padding: .55rem .9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: white;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.btn:hover { border-color: var(--primary); text-decoration: none; }

/* TOC inside page (if used) ----------------------------------------- */
.toc { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem; background: #fff; box-shadow: var(--shadow-sm); }
.toc ul { margin: 0; }
.toc a { color: #374151; }
.toc a:hover { color: var(--primary-700); }

/* Code captions from knitr ------------------------------------------ */
div.sourceCode + p.caption, pre + p.caption { text-align: center; color: var(--muted); font-size: .9rem; margin-top: .35rem; }

/* Images with fig.cap ------------------------------------------------ */
.figure > img, figure > img { width: 100%; height: auto; }

/* Pagination arrows (prev/next) ------------------------------------- */
.book .navigation .pull-left:before, .book .navigation .pull-right:after { opacity: .85; }

/* Small utilities ---------------------------------------------------- */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: .25rem !important; }
.mt-2 { margin-top: .5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }

/* Dark mode ---------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;          /* slate-950 */
    --text: #e5e7eb;        /* gray-200 */
    --muted: #9ca3af;       /* gray-400 */
    --border: #1f2937;      /* slate-800 */
    --inline-code-bg: #111827;
    --link: #60a5fa;
  }
  body { background: var(--bg); color: var(--text); }
  .book .book-summary { background: #0f172a; border-right-color: var(--border); }
  .book .book-summary ul.summary li a { color: #cbd5e1; }
  .book .book-summary ul.summary li a:hover { background: #0b1225; }
  th { background: #0f172a; color: #e5e7eb; }
  tr:nth-child(even) td { background: #0a0f1f; }
  tr:hover td { background: #0d1426; }
  .toc { background: #0b1225; }
  .book .book-header { background: rgba(2,6,23,.85); border-bottom-color: var(--border); }
}

/* Print styles ------------------------------------------------------- */
@media print {
  .book .book-summary,
  .book .book-header,
  .navigation { display: none !important; }
  .page-inner { max-width: none !important; }
  a { color: #000; text-decoration: none; }
  img { box-shadow: none; }
  pre, .sourceCode pre { box-shadow: none; }
}

/* End ---------------------------------------------------------------- */
