:root {
  --cra-blue:    #313796;
  --cra-red:     #BA0D45;
  --cra-yellow:  #FEFBE4;
  --cra-green: #347767;
  --cra-light-grey: #E0E0E0;
  --cra-grey: #CCCCCC;
  --cra-dark-grey: #333333;
  --cra-black: #000000;
  --cra-purple: #88245A;
  --cra-callout-body-bg: #F9FAFB;
}

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&display=swap');

body {
  font-family: 'Montserrat', sans-serif;
  color: #333;
  line-height: 1.8;
  background-color: #fafafa;
}

/* ── 1. LOGO CENTERING ── */
nav.navbar {
  height: 115px !important;
  border-bottom: 1px solid #eaeaea !important;
  position: relative;
}

.navbar-brand-container {
  position: absolute !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  top: 15px;
}

.navbar-brand img {
  max-height: 85px !important;
  width: auto !important;
}

/* ── 2. NATIVE QUARTO BANNER RE-SKIN ── */
.quarto-title-banner {
  background: linear-gradient(135deg, var(--cra-blue) 0%, #1a1e5e 100%) !important;
  padding: 4rem 2rem !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  position: relative !important;
}

/* Replace the solid red border with the taulbee-line.png image */
.quarto-title-banner::after {
  content: "";
  display: block;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 8px; /* matches the old 8px red border thickness */
  background-image: url('taulbee-line.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.quarto-title-banner * {
  grid-column: 1 / -1 !important;
  text-align: center !important;
}

.quarto-title-banner .title {
  color: #ffffff !important;
  font-size: 2.8rem !important;
  font-weight: 700 !important;
  margin: 0 auto !important;
}

.quarto-title-banner .subtitle {
  color: #ffffff !important;
  font-weight: 600 !important;
  font-size: 1.2rem !important;
  margin-top: 15px !important;
}

/* ── 3. SIDEBAR STYLING (THE YELLOW BOX) ── */
#quarto-sidebar {
  background-color: var(--cra-yellow) !important;
  padding: 1.2rem !important;
  border-radius: 8px !important;
  border-left: 4px solid var(--cra-blue) !important;
  margin-top: 2rem !important;
  height: fit-content !important;
  min-height: 0 !important;
  display: block !important; /* Forces items to stack naturally */
}

/* The "Contents" Title */
#quarto-sidebar::before {
  content: "Contents";
  display: block;
  font-family: 'Montserrat', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--cra-black) !important;
  margin-bottom: 8px !important; /* Tightened from 12px */
  border-bottom: 1px solid rgba(49, 55, 150, 0.1);
  padding-bottom: 5px;
}

/* This is the container for the Home and Methods links */
.sidebar-menu-container {
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
}

.sidebar-item {
  padding: 0 !important;
  margin: 0 !important;
  display: block !important;
}

.sidebar-link {
  color: #444 !important;
  font-weight: 600 !important;
  font-size: 0.88rem !important;
  padding: 2px 0 !important; /* Very tight vertical spacing */
  background: none !important;
  display: block !important;
  border: none !important;
}

.sidebar-link.active, .sidebar-link:hover {
  color: var(--cra-red) !important;
  text-decoration: underline !important;
}

/* ── 4. CONTENT & HEADERS ── */
h1 { 
  color: var(--cra-black) !important; 
  font-size: 2.8rem !important; 
  font-weight: 700 !important;
}

h2 { 
  color: var(--cra-blue) !important; 
  margin-top: 4rem !important;
  padding-top: 30px !important; /* Space so the text doesn't touch the image */
  font-size: 2.2rem !important; 
  font-weight: 700 !important;
  
  /* Clear any old borders */
  border-bottom: none !important; 
  border-top: none !important;
  
  /* Set relative positioning so we can pin the image to the top */
  position: relative !important; 
}

/* Float the image directly above the text */
h2::before {
  content: "";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 6px; /* Change this number to make the line thicker or thinner! */
  
  /* --- INSERT YOUR ASSET HERE --- */
  background-image: url('taulbee-line.png'); /* Update this with your exact file name/path */
  background-size: cover; /* Stretches the image across the whole container */
  background-position: center;
  background-repeat: no-repeat;
}

/* --- OVERRIDE: Remove the line for any header tagged with {.no-line} --- */
section.no-line h2::before {
  content: none !important; /* Completely deletes the image asset */
  display: none !important;
}

section.no-line h2 {
  margin-top: 1.5rem !important; /* Shrinks the huge gap at the top of the page */
  padding-top: 0 !important;     /* Removes the padding we added for the image */
}

h3 { 
  color: var(--cra-red) !important; 
  font-weight: 700 !important; 
  margin-top: 1.5rem !important; 
  font-size: 1.5rem !important; 
}

h4 {
  color: var(--cra-dark-grey) !important;
  font-weight: 700 !important;
  font-size: 1rem !important; /* Sized perfectly between normal text and your h3 */
  margin-top: 2rem !important;   /* Gives it nice breathing room from the paragraph above */
  margin-bottom: 1rem !important;
}

h5 {
  color: var(--cra-dark-grey) !important;
  font-weight: 600 !important;
  font-style: italic !important;
  font-size: 0.95rem !important;
  margin-top: 1.5rem !important;
  margin-bottom: 0.75rem !important;
}

/* ── 5. TABLES & BUTTONS ── */
table {
  border-collapse: collapse !important;
  width: 100% !important;
  border-top: 6px solid var(--cra-red) !important; /* Full width red top */
  border-bottom: 4px solid var(--cra-blue) !important; /* Full width blue bottom */
  margin-top: 2rem;
  margin-bottom: 2rem;
  font-size: 0.85rem !important;
  line-height: 1.4 !important;
}

/* Flood the ENTIRE header block with CRA Yellow */
table thead th, 
table thead tr th {
  background-color: var(--cra-yellow) !important;
  padding: 10px 10px !important;
  color: black !important;
  border-bottom: none !important; /* Clears out default kable lines */
}

/* Add a single thin grey line at the very bottom of the yellow header */
table thead tr:last-child th {
  border-bottom: 2px solid var(--cra-blue) !important;
}

/* Clean up the body cells to be pure white */
table tbody td {
  padding: 12px 10px !important;
  background-color: white !important;
  border-bottom: 1px solid #eee;
}

/* Force the caption to the top since Quarto processing is turned off */
table caption {
  caption-side: top !important;
  color: var(--cra-dark-grey) !important; /* Matches your h2 headers */
  font-weight: 700 !important; 
  font-size: 1rem !important;
  text-align: center !important;
  padding-top: 10px !important;
  padding-bottom: 10px !important;
}

/* ── 6. CLEAN UP (REMOVING GHOST ELEMENTS) ── */

/* Completely hides the breadcrumbs/Contents text from the blue hero banner */
.quarto-title-meta, 
.quarto-breadcrumb, 
.breadcrumb-item, 
#quarto-breadcrumbs {
  display: none !important;
  visibility: hidden !important;
}

/* Removes Quarto's default sidebar toggle and extra spacing */
#quarto-sidebar-spacer, 
.quarto-sidebar-toggle, 
.sidebar-section-toggle {
  display: none !important;
}

.quarto-title-banner {
  position: relative !important;
  z-index: 1 !important;
}

.plotly.html-widget {
  border: 1px solid var(--cra-light-grey) !important;
  border-radius: 8px !important;
  background-color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(49, 55, 150, 0.08) !important;
  margin-top: 2rem !important;
  margin-bottom: 2rem !important;
  
  box-sizing: border-box !important; 
  width: 100% !important;            
  
  /* --- THE TARGETED FIX --- */
  overflow: hidden !important; /* Specifically kills the side-to-side scroll */
}


/* ── 7. TABSET STYLING ── */

/* Add a very subtle bottom track for the tabs to sit on */
.panel-tabset .nav-tabs {
  border-bottom: 2px solid #eaeaea !important; 
  margin-bottom: 0 !important; 
}

/* Default state for INACTIVE tabs */
.panel-tabset .nav-link {
  color: #555 !important;
  background-color: transparent !important; 
  
  /* Permanent thin grey border and rounded corners */
  border: 1px solid var(--cra-light-grey) !important; 
  border-radius: 8px 8px 0 0 !important; 
  
  font-weight: 500 !important;
  font-size: 0.75rem !important;
  padding: 5px 12px !important;
  margin-right: 4px !important; 
  transition: all 0.2s ease-in-out;
}

/* Hover effect for INACTIVE tabs */
.panel-tabset .nav-link:hover:not(.active) {
  background-color: var(--cra-light-grey) !important; /* Fills with light grey */
  color: var(--cra-black) !important;
}

/* The ACTIVE tab styling (The Hero Tab) */
.panel-tabset .nav-link.active,
.panel-tabset .nav-link.active:hover {
  background-color: var(--cra-yellow) !important;
  font-weight: 700 !important; 
  color: var(--cra-black) !important;
  
  /* The custom brand borders applied ONLY to the active tab */
  border-top: 3px solid var(--cra-red) !important;
  border-bottom: 2px solid var(--cra-blue) !important;
  border-left: 3px solid var(--cra-red) !important;
  border-right: 3px solid var(--cra-red) !important;
  
  /* Matches the rounded corners */
  border-radius: 8px 8px 0 0 !important; 
  
  position: relative !important;
  z-index: 2 !important; 
}
/* Remove the default grey box around the actual tab content */
.panel-tabset .tab-content,
.panel-tabset .tab-pane {
  border: none !important;
  box-shadow: none !important;
  background-color: transparent !important;
  padding-top: 5px !important; /* Keeps your breathing room above the chart */
}

/* Remove the plot's top AND bottom margins ONLY when it's inside a tabset */
.panel-tabset .plotly.html-widget {
  margin-top: 0 !important; 
  margin-bottom: 0 !important; /* Cuts the gap under the white box */
}

/* Tighten up the bottom of the entire tabset container */
.panel-tabset {
  margin-bottom: 0.5rem !important; 
}

/* ── 8. QUARTO CALLOUT STYLING (SLEEK EDITORIAL DESIGN) ── */

/* 1. Hide the stubborn default green Quarto icon */
div.callout .callout-icon-container {
  display: none !important;
}

/* 2. Base container: seamless white, soft shadow, bold red edge */
div.callout {
  border: 1px solid #EAEAEA !important;
  border-left: 5px solid var(--cra-blue) !important; 
  border-radius: 6px !important;
  background-color: var(--cra-yellow) !important;
  margin: 2.5rem 0 !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04) !important;
}

/* 3. Header: invisible background, merged with the body */
div.callout .callout-header {
  background-color: transparent !important;
  border-bottom: none !important;
  padding: 25px 25px 5px 25px !important; /* Extra padding for breathing room */
}

/* 4. Title: CRA Blue and slightly larger */
div.callout .callout-title-container {
  color: var(--cra-blue) !important;
  font-family: 'Montserrat', sans-serif !important;
  font-weight: 700 !important;
  font-size: 1.25rem !important;
}

/* 5. Body: Aligned and breathable */
div.callout .callout-body-container {
  padding: 5px 25px 25px 25px !important;
  font-size: 0.95rem !important;
  color: var(--cra-dark-grey) !important;
  line-height: 1.7 !important;
}

/* 6. Link styling */
div.callout .callout-body-container a {
  color: var(--cra-red) !important;
  font-weight: 600 !important;
  text-decoration: none !important;
  border-bottom: 2px solid transparent !important;
  transition: border-color 0.2s ease-in-out;
}

div.callout .callout-body-container a:hover {
  border-color: var(--cra-blue) !important;
}

/* Style the sub-items in the yellow box */
.sidebar-section-items .sidebar-item {
  padding-left: 12px !important;
  margin-top: 4px !important;
  border-left: 1px solid rgba(49, 55, 150, 0.2); /* Very faint line to show nesting */
}

.sidebar-section-items .sidebar-link {
  font-size: 0.82rem !important; /* Slightly smaller text */
  font-weight: 500 !important;
  color: #666 !important;
  line-height: 1.2 !important;
}

/* Highlight the active sub-section in Red */
.sidebar-section-items .sidebar-link.active {
  color: var(--cra-red) !important;
  font-weight: 700 !important;
  border-left: 2px solid var(--cra-red) !important;
  padding-left: 8px !important;
  margin-left: -1px;
}

/* --- Per-table "Download as an Excel" button (see scripts/xlsx-download.js) --- */
.cra-xlsx-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 0.4rem 0 0 0;
}
.cra-xlsx-download {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  font-family: Montserrat, sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: #ffffff;
  background-color: var(--cra-red);
  border: 1px solid var(--cra-red);
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease;
}
.cra-xlsx-download:hover {
  background-color: var(--cra-purple);
  border-color: var(--cra-purple);
  color: #ffffff;
}
.cra-xlsx-download:focus {
  outline: 2px solid var(--cra-blue);
  outline-offset: 2px;
}
.cra-xlsx-download::before {
  content: "⬇";
  font-size: 0.9rem;
  line-height: 1;
}