/* Custom styles for Python Programming for Data Analysis Book */
/* Styled to match bookdown/gitbook aesthetic with Python colors */
/* Layout is handled by Quarto's native book grid (docked left sidebar +
   right-margin table of contents). Only cosmetic styling lives here. */

/* ===== Center the layout on wide screens =====
   Cap the whole grid (sidebar + content + TOC) and center it so the
   leftover space is balanced on both sides instead of piling up on the
   right of large monitors. */
#quarto-content {
  max-width: 1500px;
  margin-inline: auto;
}

/* ===== Typography - Improved for UX ===== */
body {
  font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.15rem;
  line-height: 1.85;
  color: #333;
}

/* ===== Headers - Improved Sizing ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: normal;
  color: #333;
}

h1 {
  font-size: 2.2rem;
  border-bottom: 1px solid #eee;
  padding-bottom: 0.5rem;
  margin-top: 2rem;
}

h1.title {
  font-size: 2.6rem;
  font-weight: 700;
  border-bottom: none;
}

h2 {
  font-size: 1.75rem;
  margin-top: 2rem;
  padding-top: 1rem;
}

h3 {
  font-size: 1.4rem;
  color: #555;
}

h4 {
  font-size: 1.25rem;
}

h5, h6 {
  font-size: 1.1rem;
}

/* Section numbering - Gitbook style */
.header-section-number {
  padding-right: 0.2em;
  font-weight: 500;
}

.level1 .header-section-number,
h1 .header-section-number {
  display: inline-block;
  border-bottom: 3px solid #306998;
  padding-bottom: 2px;
}

/* ===== Code blocks - Improved Sizing ===== */
pre {
  background-color: #f7f7f7;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 1rem;
  overflow-x: auto;
  word-break: normal;
  word-wrap: normal;
  font-size: 1rem;
}

code {
  font-family: "Source Code Pro", SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 1rem;
}

pre code {
  white-space: inherit;
  font-size: 1rem;
}

/* Inline code */
p code, li code {
  background-color: #f7f7f7;
  padding: 0.2em 0.4em;
  border-radius: 3px;
  color: #c7254e;
  white-space: inherit;
  font-size: 1rem;
}

/* ===== Captions - Gitbook Style ===== */
p.caption,
.figure-caption,
figcaption {
  color: #777;
  margin-top: 10px;
  font-style: italic;
  font-size: 0.9em;
  text-align: center;
}

/* ===== Blockquotes - Gitbook Style ===== */
blockquote {
  border-left: 4px solid #FFD43B;
  padding-left: 1rem;
  margin-left: 0;
  color: #666;
}

blockquote > p:last-child {
  text-align: right;
}

blockquote > p:first-child {
  text-align: inherit;
}

.flushright {
  text-align: right;
}

/* ===== Strong text ===== */
strong {
  font-weight: 600;
}

/* ===== Callouts - Gitbook/Blogdown Style ===== */
.callout {
  border-radius: 3px;
  margin: 1.5rem 0;
}

.callout-title {
  font-weight: 600;
}

.callout-caution,
.callout-warning {
  border: 4px #FFD43B63;
  border-style: dashed solid;
  padding: 1em;
  margin: 1em 0;
  background-color: #FFF8E1;
  color: #856404;
}

.callout-tip {
  border-left: 4px solid #306998;
  background-color: #e8f4f8;
}

.callout-note {
  border-left: 4px solid #17a2b8;
  background-color: #e7f5ff;
}

.callout-important {
  border-left: 4px solid #dc3545;
  background-color: #fff5f5;
}

/* ===== Tables - Clean Style ===== */
table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
}

th, td {
  padding: 0.75rem;
  border: 1px solid #ddd;
  text-align: left;
}

th {
  background-color: #306998;
  color: white;
  font-weight: 600;
}

tr:nth-child(even) {
  background-color: #fafafa;
}

tr:hover {
  background-color: #f5f5f5;
}

/* ===== Links - Python Style ===== */
a {
  color: #306998;
  text-decoration: none;
}

a:hover {
  color: #FFD43B;
  text-decoration: underline;
}

/* ===== Sidebar - Improved Styling ===== */
.sidebar {
  background-color: #fafafa;
  border-right: 1px solid #e8e8e8;
}

/* Search bar at top of sidebar */
#quarto-sidebar .sidebar-search {
  order: -1;
  position: sticky;
  top: 0;
  background: #fafafa;
  padding: 1rem;
  margin: 0 -1rem 1rem -1rem;
  border-bottom: 1px solid #e8e8e8;
  z-index: 10;
}

#quarto-sidebar input[type="search"],
#quarto-sidebar input[type="text"],
#quarto-sidebar .aa-Input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 0.95rem;
  background: #fff;
}

#quarto-sidebar input[type="search"]:focus,
#quarto-sidebar .aa-Input:focus {
  outline: none;
  border-color: #306998;
  box-shadow: 0 0 0 2px rgba(48, 105, 152, 0.2);
}

.sidebar nav[role=doc-toc] > h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #333;
}

.sidebar nav[role=doc-toc] ul li a {
  font-size: 0.95rem;
  padding: 0.4rem 0;
  color: #364149;
}

.sidebar nav[role=doc-toc] ul li a:hover {
  color: #306998;
}

.sidebar .chapter-number {
  color: #b4b4b4;
}

/* Sidebar navigation items - single spacing (compact) */
#quarto-sidebar .sidebar-item a {
  font-size: 0.95rem;
  padding: 0.1rem 0.75rem;
}

#quarto-sidebar .sidebar-item-section .sidebar-item a {
  font-size: 0.9rem;
}

/* Single spacing between chapters */
#quarto-sidebar .sidebar-item {
  margin-top: 0;
  margin-bottom: 0;
}

/* Small separation before each Part heading */
#quarto-sidebar .sidebar-item-section {
  margin-top: 0.15rem;
}

/* ===== Exercise Sections ===== */
.exercise {
  background-color: #e8f4f8;
  border-left: 4px solid #306998;
  padding: 1rem;
  margin: 1rem 0;
  border-radius: 0 3px 3px 0;
}

/* ===== Solution Blocks ===== */
details {
  background-color: #f7f7f7;
  border: 1px solid #ddd;
  border-radius: 3px;
  padding: 0.5rem 1rem;
  margin: 1rem 0;
}

details summary {
  cursor: pointer;
  font-weight: 600;
  color: #333;
}

details[open] summary {
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #ddd;
  padding-bottom: 0.5rem;
}

/* ===== Right TOC Styling ===== */
#TOC,
nav#TOC,
#quarto-margin-sidebar {
  padding: 10px 0;
}

#TOC ul,
nav#TOC ul {
  list-style: none;
  padding-left: 0;
}

#TOC ul ul,
nav#TOC ul ul {
  padding-left: 0.8rem;
}

#TOC li,
nav#TOC li {
  padding: 1px 0;
}

#TOC a,
nav#TOC a,
#quarto-sidebar a {
  color: #364149;
  display: block;
  font-size: 0.9rem;
}

/* Let sidebar chapter titles wrap so the full text is always visible */
#quarto-sidebar .sidebar-item-text,
#quarto-sidebar .menu-text,
#quarto-sidebar .sidebar-title {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.15;
}

#TOC a:hover,
nav#TOC a:hover {
  color: #306998;
  text-decoration: none;
}

#TOC li.active > a,
nav#TOC li.active > a {
  color: #306998;
  font-weight: 600;
}

#quarto-margin-sidebar .toc-actions {
  font-size: 0.85rem;
}

#toc-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* ===== Page Navigation - Hidden ===== */
.page-navigation {
  display: none;
}

/* ===== Print Styles ===== */
@media print {
  .sidebar,
  #quarto-sidebar,
  #scroll-top-btn,
  .quarto-search,
  nav,
  .page-navigation {
    display: none !important;
  }

  #quarto-content {
    margin-left: 0 !important;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
  }

  h1 { font-size: 20pt; }
  h2 { font-size: 16pt; }
  h3 { font-size: 14pt; }

  pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 10pt;
    border: 1px solid #ccc;
    padding: 10px;
  }

  a[href^="http"]:after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }

  .callout {
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }
}

/* ===== Responsive Design ===== */
/* Mobile navigation is handled natively by Quarto (top hamburger +
   offcanvas sidebar). We only enlarge the floating scroll-top button
   for easier tapping. */
@media (max-width: 991px) {
  #scroll-top-btn {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    font-size: 1.6rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  }
}

@media (max-width: 768px) {
  table {
    font-size: 0.85rem;
    display: block;
    overflow-x: auto;
  }

  th, td {
    padding: 0.5rem;
  }

  pre {
    font-size: 0.85rem;
  }

  body {
    font-size: 1rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.4rem;
  }

  h3 {
    font-size: 1.2rem;
  }
}
