/*
 * The Biology of Business - Global Styles
 * Inspired by Medium's readability and Financial Times' editorial elegance
 *
 * IMPORTANT: This is the SINGLE SOURCE OF TRUTH for all site-wide CSS.
 * Do NOT create duplicate CSS files (e.g., in src/styles/).
 * The site loads this file directly via <link> in BaseLayout.astro.
 * All style changes should be made here.
 */

/* Google Fonts - loaded in BaseLayout.astro */
/* Libre Baskerville for body (elegant, readable serif)
   Source Sans 3 for UI elements (clean, modern sans)
   Playfair Display for headings (editorial, sophisticated) */

:root {
  /* Paper-like color palette inspired by FT */
  --color-bg: #fff8f0;
  --color-bg-alt: #ffffff;
  --color-bg-cream: #fdf6e9;
  --color-text: #1a1a1a;
  --color-text-muted: #5c5c5c;
  --color-text-light: #8a8a8a;
  --color-primary: #990f3d;
  --color-primary-dark: #7d0d32;
  --color-primary-light: #c83c5e;
  --color-accent: #0d7680;
  --color-border: #e0d5c7;
  --color-border-light: #ebe3d7;
  --color-tag-bg: #f3ebe0;
  --color-highlight: #fff1d0;
  --color-accent-light: #e6f4f5;
  --color-selection: #c8e6e9;

  /* Typography */
  --font-serif: 'Libre Baskerville', 'Georgia', 'Times New Roman', serif;
  --font-sans: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Playfair Display', 'Georgia', serif;

  /* Spacing */
  --max-width: 720px;
  --max-width-wide: 1140px;
  --reading-width: 680px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Custom text selection styling - teal to distinguish from gold term highlights */
::selection {
  background: var(--color-selection);
  color: var(--color-text);
}

::-moz-selection {
  background: var(--color-selection);
  color: var(--color-text);
}

html {
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-padding-top: 5rem; /* Account for sticky header when scrolling to anchors */
}

body {
  font-family: var(--font-serif);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
}

/* Links */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* Focus styles for accessibility */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

a:focus:not(:focus-visible) {
  outline: none;
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Layout */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container-wide {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container-reading {
  max-width: var(--reading-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Site Header (navigation) */
.site-header {
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.site-header nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.site-header .logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.site-header .logo:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.site-header .nav-links {
  display: flex;
  gap: 1.75rem;
  list-style: none;
  font-family: var(--font-sans);
}

.site-header .nav-links a {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.site-header .nav-links a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.site-header .nav-links a.nav-advisory {
  color: var(--color-primary);
  font-weight: 600;
}

/* Dropdown navigation */
.site-header .nav-links .has-dropdown {
  position: relative;
}

.site-header .nav-links .dropdown-trigger {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 0.25rem 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.site-header .nav-links .dropdown-trigger::after {
  content: '▾';
  font-size: 0.6rem;
  transition: transform 0.2s ease;
}

.site-header .nav-links .has-dropdown:hover .dropdown-trigger::after {
  transform: rotate(180deg);
}

.site-header .nav-links .dropdown-trigger:hover {
  color: var(--color-primary);
}

.site-header .nav-links .dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.5rem 0;
  min-width: 140px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  margin-top: 0.5rem;
  list-style: none;
}

.site-header .nav-links .has-dropdown:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
}

.site-header .nav-links .dropdown-menu li {
  margin: 0;
}

.site-header .nav-links .dropdown-menu a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--color-text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: normal;
}

.site-header .nav-links .dropdown-menu a:hover {
  background: var(--color-bg);
  color: var(--color-primary);
  text-decoration: none;
}

/* Main content */
main {
  padding: 3rem 0;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-text);
}

/* Entity page */
.entity-header {
  margin-bottom: 2.5rem;
}

.entity-type {
  font-family: var(--font-sans);
  text-transform: uppercase;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
}

.entity-title {
  font-family: var(--font-display);
  font-size: 2.75rem;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
}

.entity-about {
  font-size: 1.15rem;
  line-height: 1.85;
  color: var(--color-text);
}

.entity-about p {
  margin-bottom: 1.25rem;
}

/* Sections */
.section {
  margin-top: 3.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--color-border);
}

.section-title {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
}

/* Business summary / Key insight sections */
.business-summary,
.when-to-use {
  background: var(--color-bg-cream);
  border-left: 3px solid var(--color-primary);
  border-radius: 0 4px 4px 0;
  padding: 1.5rem 2rem;
  margin-top: 2.5rem;
  border-top: none;
  padding-top: 1.5rem;
}

.business-summary p,
.when-to-use p {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--color-text);
  margin: 0;
}

/* Key findings list */
.key-findings {
  margin-top: 2.5rem;
}

.findings-list {
  list-style: none;
  padding: 0;
}

.findings-list li {
  position: relative;
  padding-left: 1.5rem;
  margin-bottom: 1rem;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--color-text);
}

.findings-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6rem;
  width: 6px;
  height: 6px;
  background: var(--color-primary);
  border-radius: 50%;
}

/* Medium-style pull quote */
.pull-quote {
  margin: 2.5rem 0;
  padding: 0;
  border: none;
  position: relative;
}

.pull-quote p {
  font-family: var(--font-display);
  font-size: 1.75rem;
  line-height: 1.4;
  font-weight: 400;
  font-style: italic;
  color: var(--color-text);
  text-align: center;
  margin: 0;
  padding: 2rem 0;
  border-top: 3px solid var(--color-text);
  border-bottom: 3px solid var(--color-text);
}

/* Entity metadata blocks */
.citation-meta,
.organism-meta,
.company-meta,
.mechanism-meta {
  margin-top: 1rem;
  font-family: var(--font-sans);
  color: var(--color-text-muted);
}

.citation-meta .authors {
  font-size: 1rem;
  margin-bottom: 0.35rem;
  color: var(--color-text);
}

.citation-meta .publication-info {
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.citation-meta .publication {
  font-style: italic;
}

.citation-meta .citation-links {
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

.citation-meta .citation-links a {
  color: var(--color-accent);
}

.citation-meta .separator,
.organism-meta .separator,
.company-meta .separator {
  color: var(--color-border);
  margin: 0 0.25rem;
}

.organism-meta .scientific-name {
  font-style: italic;
  font-size: 1.1rem;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.organism-meta .organism-info,
.company-meta .company-info {
  font-size: 0.9rem;
}

.mechanism-meta .mechanism-category {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-accent);
}

/* Framework steps */
.framework-steps {
  margin-top: 2.5rem;
}

.steps-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.step {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: 4px;
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
}

.step-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--color-primary);
  color: white;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: 50%;
  flex-shrink: 0;
}

.step-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--color-text);
}

.step-description {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-text);
  margin-bottom: 1.25rem;
}

.step-questions,
.step-outputs {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border-light);
}

.step-questions h4,
.step-outputs h4 {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.step-questions ul,
.step-outputs ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.step-questions li,
.step-outputs li {
  position: relative;
  padding-left: 1.25rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  color: var(--color-text);
}

.step-questions li::before {
  content: '?';
  position: absolute;
  left: 0;
  color: var(--color-primary);
  font-weight: 600;
}

.step-outputs li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--color-accent);
}

/* Notable traits */
.traits-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.75rem;
}

.traits-list li {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: 4px;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  color: var(--color-text);
}

/* Discovery story */
.discovery-content {
  background: var(--color-bg-cream);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 4px 4px 0;
  padding: 1.25rem 1.5rem;
}

.discovery-content .researcher {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
  margin-bottom: 0.5rem;
}

.discovery-content .significance {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--color-text);
  margin: 0;
}

/* Pivot history */
.pivots-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.pivot {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: 4px;
  padding: 1rem 1.25rem;
}

.pivot-year {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

.pivot-details {
  flex: 1;
}

.pivot-direction {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

.pivot-direction .arrow {
  margin: 0 0.5rem;
  color: var(--color-text-muted);
}

.pivot-outcome {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
}

.outcome-success {
  background: #d4edda;
  color: #155724;
}

.outcome-partial {
  background: #fff3cd;
  color: #856404;
}

.outcome-failure {
  background: #f8d7da;
  color: #721c24;
}

/* Key leaders */
.leaders-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.leader {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: 4px;
  padding: 1rem 1.25rem;
}

.leader-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-text);
  margin-bottom: 0.25rem;
}

.leader-role {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.leader-relevance {
  font-size: 0.9rem;
  color: var(--color-text);
  margin: 0;
  line-height: 1.5;
}

/* Cautionary notes */
.caution-list {
  list-style: none;
  padding: 0;
}

.caution-list li {
  position: relative;
  padding-left: 1.75rem;
  margin-bottom: 1rem;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--color-text);
}

.caution-list li::before {
  content: '⚠';
  position: absolute;
  left: 0;
  top: 0;
  font-size: 1rem;
}

/* Chapter contexts */
.chapter-contexts {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.chapter-context {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: 4px;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.chapter-context p {
  margin-bottom: 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.chapter-context a {
  font-weight: 500;
}

/* Enhanced "Used in chapters" for citations */
.used-in-chapters {
  background: linear-gradient(135deg, var(--color-bg-cream) 0%, #fff8f0 100%);
  border: 2px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem 2rem;
  margin-bottom: 2rem;
}

.used-in-chapters .section-title {
  color: var(--color-primary);
}

.used-in-intro {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
}

.chapter-contexts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.chapter-context-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  background: white;
  border: 1px solid var(--color-border-light);
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.chapter-context-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.context-text {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin: 0;
}

.context-link {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-primary);
}

@media (max-width: 640px) {
  .chapter-contexts-grid {
    grid-template-columns: 1fr;
  }

  .used-in-chapters {
    padding: 1.25rem 1.5rem;
  }
}

/* Related entities */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.related-item {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: 4px;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  transition: all 0.2s ease;
}

.related-item:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}

/* Tags */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  background: var(--color-tag-bg);
  padding: 0.3rem 0.85rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-family: var(--font-sans);
  color: var(--color-text-muted);
  font-weight: 500;
}

.tag.tag-link {
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.tag.tag-link:hover {
  background: var(--color-primary);
  color: white;
  text-decoration: none;
}

/* Index pages */
.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.entity-card {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: 4px;
  padding: 1.75rem;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.entity-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  text-decoration: none;
  transform: translateY(-2px);
}

.entity-card h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin-bottom: 0.6rem;
  color: var(--color-text);
}

.entity-card p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.6;
}

/* Search */
.search-container {
  margin-bottom: 2rem;
}

#search {
  width: 100%;
  padding: 1rem 1.25rem;
  font-size: 1rem;
  font-family: var(--font-sans);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg-alt);
  box-shadow: var(--shadow-sm);
}

#search:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(153, 15, 61, 0.1);
}

/* Footer */
footer {
  margin-top: 5rem;
  padding: 2.5rem 0;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-cream);
}

footer .container {
  text-align: center;
}

footer p {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

footer .version {
  font-size: 0.75rem;
  color: var(--color-text-light);
  font-family: var(--font-sans);
}

footer .copyright {
  font-weight: 600;
  margin-top: 1rem;
  color: var(--color-text);
}

footer .legal {
  font-size: 0.7rem;
  max-width: 550px;
  margin: 0.75rem auto 0;
  line-height: 1.6;
  color: var(--color-text-light);
}

/* Chapter content - Medium-inspired reading experience */
.chapter-content {
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 32px;
  color: #242424;
}

/* Hide the first h1 from markdown - redundant with styled chapter header */
.chapter-content .content h1:first-of-type {
  display: none;
}

.chapter-content h1 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  margin-top: 0;
  letter-spacing: -0.02em;
}

/* H2 - Part Headers (Full-width, prominent, editorial style) */
.chapter-content h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 4rem;
  margin-bottom: 2rem;
  padding: 1.5rem 0;
  letter-spacing: -0.02em;
  color: var(--color-text);
  border-top: 3px solid var(--color-primary);
  border-bottom: 1px solid var(--color-border);
  position: relative;
}

/* Part headers get special treatment - wider, bolder */
.chapter-content h2:has(+ p),
.chapter-content h2:first-of-type {
  background: linear-gradient(135deg, var(--color-bg-cream) 0%, var(--color-bg) 100%);
  margin-left: -1.5rem;
  margin-right: -1.5rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* H3 - Section Headers (Fun, distinctive, breaking up the page) */
.chapter-content h3 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 3rem;
  margin-bottom: 1.25rem;
  padding-top: 1.5rem;
  padding-bottom: 0.5rem;
  color: var(--color-text);
  position: relative;
  letter-spacing: -0.01em;
}

/* Decorative accent line for H3 */
.chapter-content h3::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 3rem;
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  border-radius: 2px;
}

/* Subheading with colon (like "Before You Apply This Framework:") - extra spacing */
.chapter-content p strong:only-child {
  display: block;
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

/* Stage-specific guidance styling - definition list style */
.chapter-content p strong:first-child:not(:only-child) {
  display: inline;
  font-weight: 700;
}

/* Better separation for bold titles followed by descriptions (stage guidance pattern) */
.chapter-content p:has(> strong:first-child) + p:has(> strong:first-child) {
  margin-top: 0.5rem;
}

/* Stage-specific guidance container - consecutive definition-style paragraphs */
.chapter-content .guidance-block {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: 6px;
  padding: 1.5rem 1.75rem;
  margin: 1.5rem 0 2.5rem;
}

.chapter-content .guidance-block p {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border-light);
}

.chapter-content .guidance-block p:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.chapter-content .guidance-term {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-text);
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
}

.chapter-content .guidance-separator {
  display: none;
}

.chapter-content p {
  margin-bottom: 2rem;
}

/* Definition-style paragraphs: bold term followed by description */
/* These are common in framework sections like "Stage-specific guidance" */
.chapter-content p > strong:first-child {
  color: var(--color-text);
  letter-spacing: -0.01em;
}

/* Add visual separation between consecutive definition paragraphs */
.chapter-content p + p > strong:first-child {
  padding-top: 0.25rem;
}

.chapter-content blockquote {
  border-left: 3px solid var(--color-primary);
  padding-left: 1.75rem;
  margin: 2rem 0;
  font-style: italic;
  color: var(--color-text-muted);
  font-size: 1.15rem;
}

/* Multiple paragraphs within a blockquote */
.chapter-content blockquote p {
  margin-bottom: 1rem;
}

.chapter-content blockquote p:last-child {
  margin-bottom: 0;
}

/* Adjacent blockquotes - collapse margins and create continuous border */
.chapter-content blockquote + blockquote {
  margin-top: -1.5rem;
  padding-top: 0;
}

/* Remove excessive gaps from para-breaks inside/around blockquotes */
.chapter-content blockquote + .para-break {
  height: 1rem;
}

.chapter-content .para-break + blockquote {
  margin-top: 1.5rem;
}

/* ============================================
   COMPELLING LIST STYLES
   ============================================ */

/* List header - text that introduces a list (e.g., "Supporting evidence:") */
.chapter-content .list-header {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 0.75rem;
  margin-top: 1.5rem;
  letter-spacing: -0.01em;
}

.chapter-content .list-header strong {
  font-style: italic;
  font-weight: 600;
}

/* Remove para-break before lists when preceded by a list-header */
.chapter-content .list-header + ul,
.chapter-content .list-header + ol {
  margin-top: 0;
}

.chapter-content ul, .chapter-content ol {
  margin-bottom: 2rem;
  padding-left: 0;
  list-style: none;
}

.chapter-content li {
  margin-bottom: 1rem;
  padding-left: 2.25rem;
  position: relative;
  line-height: 1.7;
}

/* Standard unordered list - distinctive diamond markers */
.chapter-content ul.standard-list {
  background: linear-gradient(to right, var(--color-bg-cream) 0%, transparent 100%);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 6px 6px 0;
  padding: 1.25rem 1.5rem 1.25rem 0.5rem;
  margin: 1.5rem 0 2rem;
}

.chapter-content ul.standard-list li {
  padding-left: 2rem;
  margin-bottom: 0.85rem;
}

.chapter-content ul.standard-list li:last-child {
  margin-bottom: 0;
}

.chapter-content ul.standard-list li::before {
  content: "";
  position: absolute;
  left: 0.25rem;
  top: 0.55rem;
  width: 8px;
  height: 8px;
  background: var(--color-accent);
  transform: rotate(45deg);
  border-radius: 1px;
}

/* ============================================
   CRITERIA LIST - Success/Warning items with icons
   ============================================ */
.chapter-content ul.criteria-list {
  margin: 1.5rem 0 2rem;
  background: linear-gradient(135deg, var(--color-bg-alt) 0%, var(--color-bg-cream) 100%);
  border: 1px solid var(--color-border-light);
  border-radius: 8px;
  padding: 1.5rem 1.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.chapter-content ul.criteria-list li {
  padding-left: 2.5rem;
  margin-bottom: 1rem;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.chapter-content ul.criteria-list li:last-child {
  margin-bottom: 0;
}

.chapter-content ul.criteria-list li.list-item-success::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  width: 1.75rem;
  height: 1.75rem;
  background: linear-gradient(135deg, var(--color-accent) 0%, #0a5f67 100%);
  color: white;
  font-weight: bold;
  font-size: 0.9rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(13, 118, 128, 0.25);
}

.chapter-content ul.criteria-list li.list-item-warning::before {
  content: "✗";
  position: absolute;
  left: 0;
  top: 0;
  width: 1.75rem;
  height: 1.75rem;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
  font-weight: bold;
  font-size: 0.9rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(153, 15, 61, 0.25);
}

.chapter-content strong {
  font-weight: 700;
  color: var(--color-text);
}

.chapter-content em {
  font-style: italic;
}

.chapter-content hr {
  margin: 3rem auto;
  border: none;
  width: 100px;
  height: 1px;
  background: var(--color-border);
}

.chapter-content a {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

/* Exception for share buttons - no underline decoration */
.chapter-content a.share-btn,
.chapter-content .share-insight a,
.chapter-content .share-buttons a {
  text-decoration: none;
  text-decoration-thickness: 0;
}

/* ============================================
   Tables in chapter content - Medium/FT Style
   Beautiful, full-width responsive tables
   ============================================ */

.chapter-content .table-wrapper {
  /* Break out of container for full-width effect */
  margin: 3rem -1rem;
  padding: 0 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;

  /* Subtle background to distinguish table area */
  background: linear-gradient(180deg, var(--color-bg-alt) 0%, transparent 100%);
  border-radius: 8px;
}

/* On larger screens, break out even more for dramatic effect */
@media (min-width: 768px) {
  .chapter-content .table-wrapper {
    margin-left: -2rem;
    margin-right: -2rem;
    padding: 1.5rem 2rem;
  }
}

@media (min-width: 1024px) {
  .chapter-content .table-wrapper {
    /* Break out to ~80% of viewport on large screens */
    margin-left: calc(-10vw + 1rem);
    margin-right: calc(-10vw + 1rem);
    padding: 1.5rem calc(10vw - 1rem);
    max-width: calc(100% + 20vw - 2rem);
  }
}

.chapter-content table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.6;
  background: var(--color-bg-alt);
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.04),
    0 4px 12px rgba(0, 0, 0, 0.06);
}

/* Table header - FT style with strong visual hierarchy */
.chapter-content thead {
  background: linear-gradient(180deg, var(--color-bg-cream) 0%, #f5ebe0 100%);
}

.chapter-content thead tr {
  border-bottom: 2px solid var(--color-primary);
}

.chapter-content th {
  text-align: left;
  font-weight: 700;
  padding: 1rem 1.25rem;
  color: var(--color-text);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  position: relative;
}

/* First column header - slightly different treatment */
.chapter-content th:first-child {
  border-top-left-radius: 8px;
}

.chapter-content th:last-child {
  border-top-right-radius: 8px;
}

/* Subtle dividers between header columns */
.chapter-content th:not(:last-child)::after {
  content: '';
  position: absolute;
  right: 0;
  top: 25%;
  height: 50%;
  width: 1px;
  background: var(--color-border);
}

/* Table body */
.chapter-content tbody {
  background: var(--color-bg-alt);
}

.chapter-content td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text);
  vertical-align: top;
  font-size: 0.9rem;
  line-height: 1.6;
}

/* First column - often labels, make them stand out */
.chapter-content td:first-child {
  font-weight: 600;
  color: var(--color-text);
  background: rgba(253, 246, 233, 0.5);
}

/* Alternating row colors for better readability */
.chapter-content tbody tr:nth-child(even) {
  background: rgba(253, 246, 233, 0.3);
}

/* Hover effect */
.chapter-content tbody tr:hover {
  background: var(--color-highlight);
  transition: background 0.15s ease;
}

/* Last row - clean bottom edge */
.chapter-content tbody tr:last-child td {
  border-bottom: none;
}

.chapter-content tbody tr:last-child td:first-child {
  border-bottom-left-radius: 8px;
}

.chapter-content tbody tr:last-child td:last-child {
  border-bottom-right-radius: 8px;
}

/* Handle bold text in tables - often used for row headers */
.chapter-content td strong {
  color: var(--color-text);
  font-weight: 700;
}

/* Handle emphasis in tables */
.chapter-content td em {
  color: var(--color-text-muted);
  font-style: italic;
}

/* Links in tables */
.chapter-content td a {
  color: var(--color-primary);
  text-decoration: none;
}

.chapter-content td a:hover {
  text-decoration: underline;
}

/* Table caption if present */
.chapter-content table caption {
  caption-side: bottom;
  padding: 1rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  text-align: left;
  font-style: italic;
}

/* Responsive table behavior for narrow screens */
@media (max-width: 640px) {
  .chapter-content .table-wrapper {
    margin: 2rem -1.5rem;
    padding: 0.75rem;
    border-radius: 0;
  }

  .chapter-content table {
    font-size: 0.8rem;
    border-radius: 6px;
  }

  .chapter-content th {
    padding: 0.75rem 0.75rem;
    font-size: 0.7rem;
  }

  .chapter-content td {
    padding: 0.75rem 0.75rem;
    font-size: 0.85rem;
  }

  /* Allow first column to wrap on mobile */
  .chapter-content td:first-child {
    min-width: 100px;
    white-space: normal;
  }
}

/* Extra wide tables - ensure horizontal scroll works well */
.chapter-content .table-wrapper::-webkit-scrollbar {
  height: 8px;
}

.chapter-content .table-wrapper::-webkit-scrollbar-track {
  background: var(--color-border-light);
  border-radius: 4px;
}

.chapter-content .table-wrapper::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

.chapter-content .table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* Scroll shadow indicators - show when table is scrollable */
.chapter-content .table-wrapper {
  /* Gradient shadows on edges when scrollable */
  background:
    /* Shadow covers */
    linear-gradient(to right, var(--color-bg-alt) 30%, transparent),
    linear-gradient(to right, transparent, var(--color-bg-alt) 70%) 100% 0,
    /* Shadows */
    radial-gradient(farthest-side at 0 50%, rgba(0,0,0,0.12), transparent),
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,0.12), transparent) 100% 0;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

/* Sticky first column for wide tables - keeps context while scrolling */
@media (max-width: 768px) {
  .chapter-content table {
    /* Enable sticky positioning context */
    position: relative;
  }

  .chapter-content th:first-child,
  .chapter-content td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    /* Ensure background covers scrolled content */
    background: var(--color-bg-cream);
    /* Subtle right border to separate from scrolling content */
    box-shadow: 2px 0 4px rgba(0,0,0,0.05);
  }

  .chapter-content td:first-child {
    background: #faf6f0;
  }

  .chapter-content tbody tr:nth-child(even) td:first-child {
    background: #f8f3ec;
  }

  .chapter-content tbody tr:hover td:first-child {
    background: var(--color-highlight);
  }
}

/* Table title styling - paragraphs ending with "table:" before tables */
.chapter-content p:has(+ .table-wrapper),
.chapter-content p + .table-wrapper {
  /* Style paragraphs that precede tables as pseudo-captions */
}

.chapter-content .table-wrapper + p:first-of-type em {
  /* Style notes that follow tables */
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Sticky header for long tables */
.chapter-content thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  /* Ensure header has solid background when sticky */
  background: var(--color-bg-cream);
}

/* Mobile scroll hint - subtle animation on first table */
@media (max-width: 768px) {
  .chapter-content .table-wrapper:first-of-type::after {
    content: '← Scroll →';
    display: block;
    text-align: center;
    font-size: 0.7rem;
    color: var(--color-text-muted);
    padding: 0.5rem;
    opacity: 0.7;
    animation: fadeOut 3s ease-in-out forwards;
    animation-delay: 2s;
  }

  @keyframes fadeOut {
    from { opacity: 0.7; }
    to { opacity: 0; height: 0; padding: 0; }
  }
}

/* Enhanced bold first cell styling - for tables with row headers */
.chapter-content td:first-child strong,
.chapter-content td:first-child b {
  display: block;
  font-size: 0.95em;
  margin-bottom: 0.25rem;
}

/* Better handling of multi-line cells */
.chapter-content td {
  hyphens: auto;
  word-break: break-word;
}

/* Numeric columns - right align */
.chapter-content td:last-child:not(:first-child) {
  font-variant-numeric: tabular-nums;
}

/* Print styles for tables */
@media print {
  .chapter-content .table-wrapper {
    margin: 1rem 0;
    padding: 0;
    background: none;
    overflow: visible;
  }

  .chapter-content table {
    box-shadow: none;
    border: 1px solid #ccc;
  }

  .chapter-content th,
  .chapter-content td {
    border: 1px solid #ccc;
  }
}

/* Code blocks */
.chapter-content pre {
  background: #1e1e1e;
  border-radius: 6px;
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.chapter-content pre code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #d4d4d4;
  background: none;
  padding: 0;
  border-radius: 0;
}

/* Inline code */
.chapter-content code.inline-code,
.chapter-content code:not([class]) {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85em;
  background: var(--color-tag-bg);
  color: var(--color-primary);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  word-break: break-word;
}

/* Strikethrough */
.chapter-content del {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

/* Images and figures */
.chapter-content .image-figure {
  margin: 2.5rem 0;
  text-align: center;
}

.chapter-content .image-figure img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: var(--shadow-md);
}

.chapter-content .image-figure figcaption {
  margin-top: 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-style: italic;
}

/* Task lists */
.chapter-content ul.task-list {
  list-style: none;
  padding-left: 0;
}

.chapter-content ul.task-list li.task-item {
  position: relative;
  padding-left: 2rem;
  margin-bottom: 0.5rem;
}

.chapter-content ul.task-list li.task-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.35rem;
  width: 1.1rem;
  height: 1.1rem;
  border: 2px solid var(--color-border);
  border-radius: 3px;
  background: var(--color-bg-alt);
}

.chapter-content ul.task-list li.task-checked::before {
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.chapter-content ul.task-list li.task-checked::after {
  content: '✓';
  position: absolute;
  left: 0.25rem;
  top: 0.15rem;
  color: white;
  font-size: 0.85rem;
  font-weight: bold;
}

.chapter-content ul.task-list li.task-checked {
  color: var(--color-text-muted);
}

/* ============================================
   ORDERED LIST - Compelling numbered style
   ============================================ */
.chapter-content ol.ordered-list {
  list-style: none;
  padding-left: 0;
  counter-reset: ordered-counter;
  margin: 1.5rem 0 2rem;
}

.chapter-content ol.ordered-list li {
  position: relative;
  padding-left: 3.5rem;
  margin-bottom: 1.25rem;
  counter-increment: ordered-counter;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.chapter-content ol.ordered-list li:last-child {
  margin-bottom: 0;
}

/* Large circular number badge */
.chapter-content ol.ordered-list li::before {
  content: counter(ordered-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 2rem;
  height: 2rem;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(153, 15, 61, 0.2);
}

/* Connecting line between ordered list items */
.chapter-content ol.ordered-list li:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 0.95rem;
  top: 2.25rem;
  bottom: -0.5rem;
  width: 2px;
  background: linear-gradient(to bottom, var(--color-primary-light), transparent);
  opacity: 0.3;
}

/* Nested lists */
.chapter-content ul ul,
.chapter-content ol ol,
.chapter-content ul ol,
.chapter-content ol ul {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  margin-left: 1.5rem;
}

/* Footnotes */
.chapter-content .footnote-ref {
  font-size: 0.75em;
  vertical-align: super;
  line-height: 0;
}

.chapter-content .footnote-ref a {
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 600;
}

.chapter-content .footnote-ref a:hover {
  text-decoration: underline;
}

.chapter-content section.footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.chapter-content section.footnotes hr {
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: 200px;
  margin-left: 0;
}

.chapter-content .footnotes-list {
  list-style: none;
  padding-left: 0;
  counter-reset: footnote-counter;
}

.chapter-content .footnote-item {
  position: relative;
  padding-left: 2rem;
  margin-bottom: 0.75rem;
  counter-increment: footnote-counter;
}

.chapter-content .footnote-item::before {
  content: counter(footnote-counter) ".";
  position: absolute;
  left: 0;
  font-weight: 600;
  color: var(--color-text-muted);
}

.chapter-content .footnote-item p {
  margin: 0;
  display: inline;
}

.chapter-content .footnote-backref {
  color: var(--color-accent);
  text-decoration: none;
  margin-left: 0.5rem;
  font-size: 0.85em;
}

.chapter-content .footnote-backref:hover {
  text-decoration: underline;
}

/* ============================================
   Share Insight Widget Styles (inline in chapter content)
   Fixes underscore artifacts and ensures clean icon display
   ============================================ */
.chapter-content .share-insight {
  background: var(--insight-bg);
  border: 2px solid var(--insight-border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  position: relative;
}

.chapter-content .share-insight .insight-label {
  position: absolute;
  top: -0.6rem;
  left: 1rem;
  background: var(--insight-label);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
}

.chapter-content .share-insight .insight-text {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--color-text);
  margin: 0.5rem 0 0 0;
}

.chapter-content .share-insight .share-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  flex-wrap: wrap;
  /* Prevent any text-decoration from leaking */
  text-decoration: none;
}

.chapter-content .share-insight .share-label {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  /* Ensure no underline on label */
  text-decoration: none;
}

.chapter-content .share-insight .share-buttons {
  display: flex;
  gap: 0.5rem;
  /* Reset any inherited text styling */
  font-size: 0;
  line-height: 0;
}

/* Share button links - explicitly remove all text decoration and underscores */
.chapter-content .share-insight .share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  text-decoration: none !important;
  border-bottom: none !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* Remove any underscore/underline artifacts from icon links */
.chapter-content .share-insight .share-btn::before,
.chapter-content .share-insight .share-btn::after {
  display: none;
}

.chapter-content .share-insight .share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  text-decoration: none !important;
}

.chapter-content .share-insight .share-btn svg {
  display: block;
}

.chapter-content .share-insight .share-x {
  background: #000;
  color: #fff;
}

.chapter-content .share-insight .share-linkedin {
  background: #0077b5;
  color: #fff;
}

.chapter-content .share-insight .share-whatsapp {
  background: #25d366;
  color: #fff;
}

.chapter-content .share-insight .share-sms {
  background: #34c759;
  color: #fff;
}

.chapter-content .share-insight .share-email {
  background: #ea4335;
  color: #fff;
}

/* Mobile responsiveness for share widgets */
@media (max-width: 480px) {
  .chapter-content .share-insight .share-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .chapter-content .share-insight .share-buttons {
    width: 100%;
    justify-content: flex-start;
  }
}

/* Books listing */
.book-card {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border-light);
  border-radius: 4px;
  padding: 2rem;
  margin-bottom: 1.75rem;
  box-shadow: var(--shadow-sm);
}

.book-card h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin-bottom: 0.85rem;
  letter-spacing: -0.01em;
}

.book-card h2 a {
  color: var(--color-text);
}

.book-card h2 a:hover {
  color: var(--color-primary);
  text-decoration: none;
}

.book-card p {
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
  line-height: 1.7;
}

.chapters-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-family: var(--font-sans);
}

.chapters-list a {
  font-size: 0.9rem;
}

/* Chapter navigation */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 3.5rem;
  padding: 1.75rem 0;
  border-top: 1px solid var(--color-border);
  font-family: var(--font-sans);
}

.chapter-nav a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-muted);
  max-width: 45%;
}

.chapter-nav a:hover {
  color: var(--color-primary);
}

.chapter-nav .prev {
  text-align: left;
}

.chapter-nav .next {
  text-align: right;
}

/* Version badge */
.version-badge {
  display: inline-block;
  background: var(--color-tag-bg);
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* New badge */
.new-badge {
  display: inline-block;
  background: var(--color-accent);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* Last updated */
.last-updated {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  color: var(--color-text-light);
  margin-top: 0.5rem;
}

/* Breadcrumb */
.breadcrumb {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-text-light);
  margin-bottom: 2rem;
}

.breadcrumb a {
  color: var(--color-text-light);
}

.breadcrumb a:hover {
  color: var(--color-primary);
}

.breadcrumb span {
  margin: 0 0.5rem;
  color: var(--color-border);
}

/* Copyright box */
.copyright-box {
  background: var(--color-bg-cream);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1.75rem;
  margin-top: 3rem;
  font-family: var(--font-sans);
}

.copyright-box p:first-child {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

.copyright-box p:last-child {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.65;
}

/* Responsive */
@media (max-width: 768px) {
  html {
    font-size: 16px;
  }

  .entity-title {
    font-size: 2rem;
  }

  .chapter-content h1 {
    font-size: 1.85rem;
  }

  .chapter-content h2 {
    font-size: 1.4rem;
    margin-left: -1rem;
    margin-right: -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .chapter-content h3 {
    font-size: 1.2rem;
  }

  /* Responsive list styles */
  .chapter-content ul.standard-list {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
    padding: 1rem 1.25rem 1rem 0.25rem;
  }

  .chapter-content ol.ordered-list li {
    padding-left: 3rem;
  }

  .chapter-content ol.ordered-list li::before {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.8rem;
  }

  .chapter-content ol.ordered-list li:not(:last-child)::after {
    left: 0.8rem;
  }

  .chapter-content ul.criteria-list {
    padding: 1.25rem 1.25rem;
  }

  .chapter-content ul.criteria-list li {
    padding-left: 2.25rem;
  }

  .chapter-content ul.criteria-list li.list-item-success::before,
  .chapter-content ul.criteria-list li.list-item-warning::before {
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.8rem;
  }

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

  .site-header nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .site-header .nav-links {
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
  }

  .chapter-nav {
    flex-direction: column;
    gap: 1rem;
  }

  .chapter-nav a {
    max-width: 100%;
    text-align: center;
  }
}

/* Mobile touch target improvements for narrow viewports */
@media (max-width: 480px) {
  .site-header .nav-links {
    gap: 0.75rem 1.25rem;
  }

  .site-header .nav-links a,
  .site-header .nav-links .dropdown-trigger {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.25rem;
  }

  .site-header .nav-links .dropdown-menu a {
    min-height: 44px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
  }

  /* Ensure related items have proper touch targets */
  .related-item {
    min-height: 48px;
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
  }

  /* Chapter navigation touch targets */
  .chapter-nav a {
    min-height: 60px;
    padding: 1rem;
  }
}

/* TL;DR Box - shared styling for chapter and entity pages */
.tldr-box {
  background: linear-gradient(135deg, var(--color-bg-cream) 0%, #fff8f0 100%);
  border: 2px solid var(--color-primary);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin: 0 0 2rem 0;
  position: relative;
}

.tldr-label {
  position: absolute;
  top: -0.6rem;
  left: 1rem;
  background: var(--color-primary);
  color: white;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.6rem;
  border-radius: 3px;
}

.tldr-text {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--color-text);
  margin: 0.5rem 0 0 0;
}

/* Ultra-narrow viewport fixes (Galaxy Fold, etc.) */
@media (max-width: 320px) {
  .site-header .nav-links {
    gap: 0.5rem 1rem;
    font-size: 0.8rem;
  }

  .site-header .nav-links a,
  .site-header .nav-links .dropdown-trigger {
    font-size: 0.75rem;
  }

  .container, .container-wide {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .chapter-title {
    font-size: 1.5rem;
  }

  .tldr-box {
    padding: 1rem;
  }

  .tldr-text {
    font-size: 0.95rem;
  }
}

/* Sidebar layout */
main.with-sidebar {
  padding: 2rem 0;
}

.main-content-wrapper {
  display: flex;
  gap: 2.5rem;
  align-items: flex-start;
}

.main-content {
  flex: 1;
  min-width: 0;
  max-width: 680px;
}


/* Responsive sidebar layout */
@media (max-width: 1140px) {
  .main-content-wrapper {
    gap: 2rem;
  }

  .main-content {
    max-width: 600px;
  }
}

@media (max-width: 1024px) {
  .main-content-wrapper {
    flex-direction: column;
  }

  .main-content {
    max-width: 100%;
  }
}

/* Print styles */
@media print {
  header, footer, .chapter-nav, .breadcrumb, .sidebar {
    display: none;
  }

  body {
    background: white;
    font-size: 12pt;
  }

  .chapter-content {
    max-width: 100%;
  }

  .main-content-wrapper {
    display: block;
  }
}

/* ============================================
   Fallback table styles for any table on site
   (Entity pages, framework pages, etc.)
   ============================================ */

article table,
.entity-about table,
.section table,
.container table:not(.chapter-content table) {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  line-height: 1.6;
  background: var(--color-bg-alt);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.06);
  margin: 2rem 0;
}

article thead,
.entity-about thead,
.section thead,
.container table:not(.chapter-content table) thead {
  background: linear-gradient(180deg, var(--color-bg-cream) 0%, #f5ebe0 100%);
  border-bottom: 2px solid var(--color-primary);
}

article th,
.entity-about th,
.section th,
.container table:not(.chapter-content table) th {
  text-align: left;
  font-weight: 700;
  padding: 1rem 1.25rem;
  color: var(--color-text);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

article td,
.entity-about td,
.section td,
.container table:not(.chapter-content table) td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text);
  vertical-align: top;
}

article td:first-child,
.entity-about td:first-child,
.section td:first-child,
.container table:not(.chapter-content table) td:first-child {
  font-weight: 600;
  background: rgba(253, 246, 233, 0.5);
}

article tbody tr:nth-child(even),
.entity-about tbody tr:nth-child(even),
.section tbody tr:nth-child(even),
.container table:not(.chapter-content table) tbody tr:nth-child(even) {
  background: rgba(253, 246, 233, 0.3);
}

article tbody tr:hover,
.entity-about tbody tr:hover,
.section tbody tr:hover,
.container table:not(.chapter-content table) tbody tr:hover {
  background: var(--color-highlight);
}

article tbody tr:last-child td,
.entity-about tbody tr:last-child td,
.section tbody tr:last-child td,
.container table:not(.chapter-content table) tbody tr:last-child td {
  border-bottom: none;
}
