/* ============================================================
   GENERAL TABLE + QUARTO STYLING
   ============================================================ */

/* Alternative rows in Bootstrap-styled tables are gray */

.table tr:nth-child(even) {
  background-color: #f5f5f5;
}

/* For Quarto code output blocks (including Pandas tables) */

.cell-output,
.cell-output-stdout,
.cell-output-stderr,
.cell-output-display {
  background-color: #f5f5f5 !important; /* Light gray background */
  padding: 0.5em 1em;
  border-radius: 5px;
  margin-bottom: 1em;
  max-width: 100%;
  overflow-x: auto;
}

/* Strip the gray box from cell outputs that contain a table —
   the table's own scroll container handles border + shadow */

.cell-output-display:has(table) {
  background-color: transparent !important;
  padding: 0 !important;
  border-radius: 0;
  box-shadow: none;
}

/* ============================================================
   FOOTER
   ============================================================ */

footer.footer .nav-footer {
  display: block !important;
  max-width: 100vw;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  background: #f8f9fa;
  border-top: 1px solid #eee;
  text-align: left;
  padding: 1em 0.5em 1em 1.5em;
  box-sizing: border-box;
}

footer.footer .nav-footer-center {
  max-width: 100vw !important;
  padding: 0.5em;
  margin-left: 1em;
  margin-right: 1em;
  display: block !important;
  float: none !important;
  font-size: 1em;
  text-align: left;
}

footer.footer .nav-footer-left,
footer.footer .nav-footer-right {
  display: none !important;
}

/* ============================================================
   NAVBAR (HARVARD CRIMSON THEME)
   ============================================================ */

/* Harvard Crimson: #A51C30 */

.navbar,
.navbar-dark {
  background-color: #a51c30 !important;
}

/* Navbar items and hover/focus states */

.navbar .nav-link,
.navbar .navbar-brand {
  color: #fff !important;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus {
  color: #ffd700 !important; /* gold/yellow hover */
}

/* If navbar is light by default, also force text to white */

.navbar-light .navbar-nav .nav-link,
.navbar-light .navbar-brand {
  color: #fff !important;
}

/* ============================================================
   IMAGES & TITLE BLOCK
   ============================================================ */

/* Center images that are direct children of main content / Quarto figures */

main img,
.quarto-figure img {
  display: block;
  margin-left: auto;
  margin-right: auto;
  margin-top: 1em;
  margin-bottom: 1em;
}

/* Remove box styling from title block */

.quarto-title-block {
  background: none !important;
  box-shadow: none !important;
  border: none !important;
  padding: 0 !important;
  margin-bottom: 1em !important;
  text-align: left !important;
}

/* Hide author, affiliation, date, subtitle, etc. */

.quarto-title-author,
.quarto-title-affiliation,
.quarto-title-date,
.quarto-title-subtitle,
.quarto-title-lang,
.quarto-title-abstract,
.quarto-title-meta,
#quarto-article-details {
  display: none !important;
}

/* Make sure images aren't larger than window size */

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Hide breadcrumbs */

.quarto-breadcrumbs,
.quarto-page-breadcrumbs {
  display: none !important;
}

/* ============================================================
   TABSETS
   ============================================================ */

.panel-tabset {
  border: 1px solid #e0e0e0; /* lighter outline */
  border-radius: 8px;
  padding: 0.75em 1em;
  margin-top: 1.5em;
  margin-bottom: 2em;
  background: #fafafa;
  box-shadow: 0px 2px 5px rgba(0,0,0,0.1); /* soft shadow */
}

/* Tab bar */

.panel-tabset .nav-tabs {
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 0.75em;
}

/* Tab labels: shorter, rounded, crimson */

.panel-tabset .nav-tabs .nav-link {
  padding: 0.25em 0.75em; /* shorter tabs */
  border-radius: 6px 6px 0 0; /* rounded top */
  border: 1px solid #a51c30 !important;
  border-bottom: none !important;
  background-color: #a51c30 !important; /* crimson */
  color: #fff !important;
  margin-right: 4px;
}

/* Active tab: lighter background but still crimson-themed */

.panel-tabset .nav-tabs .nav-link.active {
  background-color: #fff !important;
  color: #a51c30 !important;
  font-weight: 600;
  border-color: #a51c30 !important;
  border-bottom: 1px solid #fff !important; /* blends smoothly */
}

/* Inner content box */

.panel-tabset .tab-content {
  border: 1px solid #e0e0e0; /* softer border */
  border-radius: 6px;
  padding: 1em;
  background: #fff;
}

/* Ensure tabsets use the full content width */

.panel-tabset {
  width: 100%;
}

/* Remove Quarto's built-in max-width constraints inside tab content */

.panel-tabset .tab-content,
.panel-tabset .tab-pane {
  max-width: 100%;
  width: 100%;
}

/* ============================================================
   TABLES: AESTHETICS
   ============================================================ */

/* Alternating row shading */

table tr:nth-child(even) { background-color: #f5f5f5; }
table tr:nth-child(odd)  { background-color: #ffffff; }

/* Hover row highlight */
table tbody tr:hover { background-color: #fdf0f2; }

/* Cell padding and borders */

table th,
table td {
  padding: 0.55em 0.75em;
  border: 1px solid #e5e5e5;
  text-align: left;
}

/* Table base.
   border-collapse: collapse (not separate) is required for
   position: sticky on thead th to work correctly.
   border-radius and box-shadow are applied to the scroll
   containers below instead of the table element itself. */

table {
  border-collapse: collapse;
  border-spacing: 0;
  background: #fff;
}

/* Crimson sticky header.
   box-shadow replaces border-bottom because border-collapse: collapse
   causes cell borders on sticky elements to visually disappear mid-scroll. */

table thead th {
  background-color: #a51c30 !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: inset 0 -2px 0 #8b1628;
}

/* ============================================================
   TABLE CAPTIONS
   ============================================================ */

.quarto-float-caption,
[id*="-caption-"] {
  text-align: left !important;
  margin-bottom: 0.5em;
}

/* ============================================================
   FIGURES
   ============================================================ */

/*
  Do NOT apply flex to figure.quarto-float-tbl — that is the wrapper
  Quarto uses for captioned tables, and flex on it breaks left-scroll.
*/

.quarto-figure:not(.quarto-float-tbl),
.figure,
figure:not(.quarto-float-tbl) {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  text-align: center !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

.quarto-figure img,
.figure img {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.quarto-figure .figure-caption,
.figure .figure-caption,
figure figcaption {
  text-align: left !important;
  align-self: flex-start !important;
}

.quarto-figure .figure-caption,
.figure .figure-caption {
  max-width: 100% !important;
}

.column .quarto-figure .figure-caption,
.column .figure .figure-caption {
  text-align: center !important;
  align-self: center !important;
}

/* ============================================================
   COLUMNS LAYOUT
   ============================================================ */

.columns {
  display: flex !important;
  align-items: stretch !important;
}

.columns .column {
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
}

/* ============================================================
   TABLE LAYOUT: SCROLLING + NO SQUASHING
   ============================================================ */

/*
  Changes from previous version:
  ─ white-space: nowrap replaces normal + overflow-wrap + word-break
                        PRIMARY fix for the squashed/crushed look
  ─ max-height + overflow-y: auto on containers → vertical scroll
    like kableExtra's scroll_box
  ─ border-radius + box-shadow moved from table → scroll containers
    (they must live on the scroll container, not the table, for
    sticky headers to work)
*/

/* 1. Neutralise Quarto's inline colgroup percentages */

col {
  width: auto !important;
}

/* 2. Size table to content — each column gets exactly what it needs */

table {
  table-layout: auto !important;
  width: max-content;
}

/* 3. Cell text: nowrap is the primary fix for squashing */

table th,
table td {
  white-space: nowrap;
  min-width: 60px;
}

/* 4. Scroll containers for Quarto captioned tables (#tbl-*)
      Structure:
        div.cell-output-display       <- transparent (overridden above)
          div.quarto-float            <- display:block
            figure.quarto-float-tbl  <- display:block (NOT flex)
              figcaption
              div[aria-describedby]  <- scroll box + border lives here
                table                <- margins zeroed; width:max-content */

div.quarto-float:has(figure.quarto-float-tbl) {
  display: block !important;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

figure.quarto-float-tbl {
  display: block !important;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 0;
}

figure.quarto-float-tbl > div[aria-describedby] {
  display: block;
  width: 100%;
  max-height: 450px;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  box-shadow: 0px 2px 5px rgba(0,0,0,0.08);
}

figure.quarto-float-tbl > div[aria-describedby] > table {
  margin-left: 0;
  margin-right: 0;
}

/* 5. Scroll container for Pandas DataFrames (bare cell output) */

.cell-output-display:has(table.dataframe) {
  max-height: 450px;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  box-shadow: 0px 2px 5px rgba(0,0,0,0.08);
}

.cell-output-display table.dataframe,
.cell-output-display > div > table.dataframe {
  width: auto !important;
  max-width: none !important;
  display: table !important;
  margin-left: 0;
  margin-right: 0;
}

/* ============================================================
   Error message handling
   ============================================================ */

/* Make long error messages scroll instead of stretching the page */
.cell-output-stderr pre,
.cell-output-stdout pre,
.cell-output pre,
pre.error {
  max-height: 300px;   /* adjust as you like */
  overflow-y: auto;    /* vertical scrollbar */
  overflow-x: auto;    /* horizontal scrollbar if needed */
  white-space: pre;    /* keep original formatting */
  border: 1px solid #ddd;
  padding: 0.5em;
  background-color: #f8f8f8;
}