/* ==========================================================================
   Vietnam Market Insights - Global Styles
   Documentation-style, typography-first design
   ========================================================================== */

/* CSS Custom Properties
   ========================================================================== */
:root {
  /* Colors - Neutral palette for calm, trustworthy feel */
  --color-bg: #fefefe;
  --color-bg-subtle: #f8f9fa;
  --color-text: #1a1a1a;
  --color-text-muted: #5a5a5a;
  --color-text-light: #8a8a8a;
  --color-border: #e5e5e5;
  --color-border-light: #f0f0f0;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;

  /* Typography - System font stack for reliability */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;

  /* Font sizes - Modular scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  /* Line heights */
  --leading-tight: 1.25;
  --leading-normal: 1.6;
  --leading-relaxed: 1.75;

  /* Spacing - Consistent rhythm */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Layout - single page width for balanced, consistent desktop layout */
  --page-width: 960px;
  --max-width: var(--page-width);
  --max-width-wide: var(--page-width);
  --header-height: 60px;
  --content-padding-x: 1.5rem;
}

/* Base Styles
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
}

/* Typography
   ========================================================================== */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--color-text);
}

h1 {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-6);
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--text-xl);
  margin-top: var(--space-10);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border-light);
}

h3 {
  font-size: var(--text-lg);
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
  color: var(--color-text-muted);
}

p {
  margin-bottom: var(--space-4);
}

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

a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

/* Lists */
ul,
ol {
  margin-bottom: var(--space-4);
  padding-left: var(--space-5);
}

li {
  margin-bottom: var(--space-2);
}

li::marker {
  color: var(--color-text-light);
}

/* Content Sections */
section {
  margin-bottom: var(--space-8);
}

/* Inline Code */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 0.15em 0.4em;
  background-color: var(--color-bg-subtle);
  border-radius: 3px;
  color: var(--color-text);
}

/* Preformatted text */
pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  padding: var(--space-4);
  background-color: var(--color-bg-subtle);
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

pre code {
  padding: 0;
  background: none;
}

/* Horizontal Rule */
hr {
  border: none;
  height: 1px;
  background-color: var(--color-border);
  margin: var(--space-8) 0;
}

/* Layout Components
   ========================================================================== */

/* Container - same width for all pages */
.container,
.container-wide,
.page-content {
  max-width: var(--page-width);
  margin: 0 auto;
  padding-left: var(--content-padding-x);
  padding-right: var(--content-padding-x);
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-bg);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  max-width: var(--page-width);
  margin: 0 auto;
  padding-left: var(--content-padding-x);
  padding-right: var(--content-padding-x);
}

.site-header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}

.site-header__brand:hover {
  color: var(--color-accent);
  text-decoration: none;
}

/* Navigation */
.site-nav {
  display: flex;
  gap: var(--space-6);
}

.site-nav a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--space-2) 0;
}

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

.site-nav a[aria-current="page"] {
  color: var(--color-text);
  font-weight: 500;
}

/* Main Content */
.main-content {
  min-height: calc(100vh - var(--header-height) - 80px);
  padding-top: var(--space-10);
  padding-bottom: var(--space-16);
}


/* Footer */
.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-8) 0;
}

.site-footer__inner {
  max-width: var(--page-width);
  margin: 0 auto;
  padding-left: var(--content-padding-x);
  padding-right: var(--content-padding-x);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-footer__text {
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

/* Topic List (Homepage)
   ========================================================================== */
.topic-list {
  list-style: none;
  padding: 0;
  margin: var(--space-6) 0;
}

.topic-list__item {
  border-bottom: 1px solid var(--color-border-light);
  padding: var(--space-4) 0;
  margin: 0;
}

/* Topic Grid (New Grid-based layout for better space utilization) */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space-6);
  margin: var(--space-8) 0;
}

.topic-card {
  display: flex;
  flex-direction: column;
  padding: var(--space-6);
  background: var(--color-bg);
  border: 1px solid var(--color-border-light);
  border-radius: 12px;
  text-decoration: none;
  transition: all 0.2s ease;
  height: 100%;
}

.topic-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
  transform: translateY(-2px);
  text-decoration: none;
}

.topic-card__title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topic-card__title::after {
  content: "→";
  font-weight: 400;
  opacity: 0.5;
  transition: transform 0.2s ease;
}

.topic-card:hover .topic-card__title::after {
  transform: translateX(4px);
  opacity: 1;
  color: var(--color-accent);
}

.topic-card__desc {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}

.topic-list__item:first-child {
  border-top: 1px solid var(--color-border-light);
}

.topic-list__link {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
  color: var(--color-text);
  text-decoration: none;
}

.topic-list__link:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.topic-list__title {
  font-weight: 500;
  min-width: 140px;
}

.topic-list__desc {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* Topic Page Components
   ========================================================================== */
.topic-meta {
  font-size: var(--text-sm);
  color: var(--color-text-light);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
}

/* Key characteristics list styling */
.characteristics-list {
  list-style: none;
  padding: 0;
}

.characteristics-list li {
  position: relative;
  padding-left: var(--space-4);
  margin-bottom: var(--space-3);
}

.characteristics-list li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--color-text-light);
}

/* Sources section */
.sources-list {
  font-size: var(--text-sm);
}

.sources-list li {
  margin-bottom: var(--space-2);
}

/* Utility Classes
   ========================================================================== */
.text-muted {
  color: var(--color-text-muted);
}

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

.text-small {
  font-size: var(--text-sm);
}

.lead {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-6);
}

/* ==========================================================================
   SEARCH COMPONENT STYLES - Enhanced
   ========================================================================== */

/* Search Trigger Button (in header) */
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.search-trigger:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-bg);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.search-trigger__icon {
  flex-shrink: 0;
}

.search-trigger__text {
  font-weight: 500;
}

.search-trigger__kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 0.25em 0.5em;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  margin-left: var(--space-1);
  color: var(--color-text-light);
  font-weight: 600;
}

/* ==========================================================================
   SEARCH COMPONENT STYLES - Robust Integration
   ========================================================================== */

/* Modal Container */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.search-modal.is-open {
  opacity: 1;
  visibility: visible;
}

.search-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.search-modal__container {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  margin: 0 var(--space-4);
  background: var(--color-bg);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(10px);
  transition: transform 0.2s ease;
}

.search-modal.is-open .search-modal__container {
  transform: translateY(0);
}

/* 
   Pagefind UI Customization 
   We use #search to ensure specificity but avoid !important where possible 
   to let Pagefind handle its internal mechanics.
*/
#search {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

#search .pagefind-ui {
  flex: 1;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden;
  /* Reset vars */
  --pagefind-ui-primary: var(--color-accent);
  --pagefind-ui-text: var(--color-text);
  --pagefind-ui-background: var(--color-bg);
  --pagefind-ui-border: var(--color-border-light);
  --pagefind-ui-tag: var(--color-bg-subtle);
  width: 100%;
}

/* Force form to take full width and sit at top */
#search .pagefind-ui form {
  display: flex !important;
  flex-direction: column !important;
  /* Some Pagefind versions nest inputs in a form */
  width: 100% !important;
}

/* Search Form Area */
#search .pagefind-ui__form {
  position: relative;
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border-light);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Pseudo-element for Search Icon - Positioned relative to the input container if possible, but form is easier */
#search .pagefind-ui__form::before {
  content: "";
  position: absolute;
  left: 2rem;
  top: 2.5rem;
  /* Fixed top: 1rem padding + 24px half-height */
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238a8a8a'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
  z-index: 2;
}

/* Ensure input looks good but doesn't break layout */
#search .pagefind-ui__search-input {
  width: 100%;
  font-size: var(--text-lg);
  padding: var(--space-3) var(--space-4) var(--space-3) 2.8rem;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-weight: 500;
  outline: none;
  transition: all 0.2s ease;
  height: 48px;
  /* Force height */
}

#search .pagefind-ui__search-input:focus {
  background: var(--color-bg);
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Clear Button Alignment */
#search .pagefind-ui__search-clear {
  position: absolute;
  right: 2rem;
  top: 2.5rem;
  /* Fixed top: 1rem padding + 24px half-height */
  transform: translateY(-50%);
  padding: 4px 8px;
  background: var(--color-bg-subtle);
  border-radius: 4px;
  font-size: 12px;
  height: auto;
  margin: 0;
  z-index: 2;
  cursor: pointer;
}

/* Results Drawer - Critical for scrolling */
#search .pagefind-ui__drawer {
  flex: 1 1 auto;
  /* Allow grow and shrink */
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0;
  min-height: 0;
  display: flex !important;
  /* Force flex to manage children */
  flex-direction: column;
}

/* Results Formatting */
#search .pagefind-ui__results-area {
  flex: 1 1 auto;
  padding: 0;
  display: block;
  /* Ensure it's not hidden */
}

#search .pagefind-ui__result {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border-light);
  border-radius: 0;
  margin: 0;
}

#search .pagefind-ui__result:hover {
  background: var(--color-bg-subtle);
}

#search .pagefind-ui__result-link {
  color: var(--color-accent);
  font-weight: 600;
  text-decoration: none;
}

#search .pagefind-ui__result-excerpt {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
}

#search .pagefind-ui__message {
  padding: var(--space-8);
  text-align: center;
  color: var(--color-text-muted);
}

/* Footer Shortcuts */
.search-modal__footer {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-5);
  background: var(--color-bg-subtle);
  border-top: 1px solid var(--color-border-light);
}

.search-shortcuts {
  display: flex;
  gap: var(--space-4);
  font-size: 0.75rem;
  color: var(--color-text-light);
}

.search-shortcuts kbd {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  padding: 1px 4px;
  border-radius: 4px;
  font-family: var(--font-mono);
  margin-right: 4px;
}

/* Loading Spinner */
.search-loading {
  padding: var(--space-12);
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--color-text-muted);
}

.search-loading__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border-light);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: var(--space-3);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ==========================================================================
   HOMEPAGE ENHANCEMENTS
   ========================================================================== */

/* Hero Section */
.hero {
  text-align: center;
  padding: var(--space-12) 0;
  margin-bottom: var(--space-8);
  border-bottom: 1px solid var(--color-border-light);
}

.hero__title {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-4);
}

.hero__subtitle {
  font-size: var(--text-xl);
  color: var(--color-text-muted);
  max-width: 600px;
  margin: 0 auto var(--space-6);
  line-height: var(--leading-relaxed);
}

.hero__actions {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
}

.hero__search-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: var(--text-base);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  min-width: 280px;
  justify-content: center;
}

.hero__search-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.hero__search-btn kbd {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.2em 0.5em;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  margin-left: auto;
}

/* Stats Section */
.stats-section {
  margin-bottom: var(--space-12);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
}

.stat-card {
  text-align: center;
  padding: var(--space-6);
  background: var(--color-bg-subtle);
  border-radius: 8px;
}

.stat-card__value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
  margin-bottom: var(--space-2);
}

.stat-card__label {
  display: block;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

.stat-card__desc {
  display: block;
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

/* What's New Section */
.whats-new {
  background: var(--color-bg-subtle);
  padding: var(--space-6);
  border-radius: 8px;
  margin-bottom: var(--space-12);
}

.whats-new__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}

.whats-new__header h2 {
  margin: 0;
  border-bottom: none;
}

.whats-new__link {
  font-size: var(--text-sm);
}

.update-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.update-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border-light);
}

.update-item:last-child {
  border-bottom: none;
}

.update-item__date {
  font-size: var(--text-sm);
  color: var(--color-text-light);
  min-width: 100px;
  font-family: var(--font-mono);
}

.update-item__topic {
  font-weight: 500;
  min-width: 100px;
}

.update-item__change {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* How to Use Section */
.how-to-use {
  margin-bottom: var(--space-12);
}

.how-to-use__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-6);
  margin-top: var(--space-6);
}

.how-to-use__item {
  padding: var(--space-4);
  background: var(--color-bg-subtle);
  border-radius: 8px;
}

.how-to-use__item h3 {
  margin-top: 0;
  font-size: var(--text-base);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.how-to-use__item p {
  margin-bottom: 0;
  font-size: var(--text-sm);
}

/* Methodology Section */
.methodology {
  padding: var(--space-8) 0;
  border-top: 1px solid var(--color-border);
  max-width: 680px;
}

.methodology h2 {
  font-size: var(--text-xl);
  margin-top: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.methodology p {
  color: var(--color-text-muted);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
}

.methodology a {
  color: var(--color-accent);
  text-decoration: none;
}

.methodology a:hover {
  text-decoration: underline;
}

.methodology__link {
  display: inline-block;
  margin-top: var(--space-4);
  font-size: var(--text-sm);
}

/* Mission Quote */
.mission {
  text-align: center;
  padding: var(--space-8) 0;
  border-top: 1px solid var(--color-border);
}

.mission__quote {
  font-style: italic;
  color: var(--color-text-muted);
  font-size: var(--text-lg);
  margin-bottom: var(--space-4);
  border-left: none;
  padding: 0;
}

.mission__quote p {
  margin: 0;
}

.mission__link {
  font-size: var(--text-sm);
}

/* ==========================================================================
   TOPIC LAYOUT ENHANCEMENTS
   ========================================================================== */

/* FAQ Section */
.faq-section {
  margin-top: var(--space-12);
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-border);
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.faq-item {
  background: var(--color-bg-subtle);
  border-radius: 8px;
  overflow: hidden;
}

.faq-question {
  padding: var(--space-4);
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: '+';
  font-size: 1.2rem;
  color: var(--color-text-light);
}

.faq-item[open] .faq-question::after {
  content: '−';
}

.faq-answer {
  padding: 0 var(--space-4) var(--space-4);
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* Related Topics */
.related-topics {
  margin-top: var(--space-12);
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-border);
}

.related-topics__list {
  list-style: none;
  padding: 0;
  margin: var(--space-4) 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-4);
}

.related-topics__item {
  margin: 0;
}

.related-topics__link {
  display: block;
  padding: var(--space-4);
  background: var(--color-bg-subtle);
  border-radius: 8px;
  text-decoration: none;
  color: var(--color-text);
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.related-topics__link:hover {
  border-color: var(--color-accent);
  text-decoration: none;
}

.related-topics__title {
  display: block;
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.related-topics__desc {
  display: block;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

/* Page Actions (Share & Cite) */
.page-actions {
  margin-top: var(--space-12);
  padding: var(--space-8);
  background: var(--color-bg-subtle);
  border-radius: 8px;
}

.page-actions h2 {
  margin-top: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.page-actions__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
  margin-top: var(--space-4);
}

/* Share Buttons */
.share-buttons {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.share-buttons__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  margin-right: var(--space-2);
}

.share-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  transition: all 0.15s ease;
}

.share-button:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  text-decoration: none;
}

.share-button.is-copied {
  color: #22c55e;
  border-color: #22c55e;
}

/* Cite Section */
.cite-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cite-button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  align-self: flex-start;
}

.cite-button:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.cite-button.is-copied {
  color: #22c55e;
  border-color: #22c55e;
}

.cite-format {
  font-size: var(--text-sm);
}

.cite-format summary {
  cursor: pointer;
  color: var(--color-accent);
}

.cite-formats {
  margin-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.cite-format__item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.cite-format__label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cite-format__code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  background: var(--color-bg);
  padding: var(--space-3);
  border-radius: 4px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ==========================================================================
   GLOSSARY PAGE STYLES
   ========================================================================== */

.glossary-page {
  max-width: var(--max-width);
}

.glossary-header {
  margin-bottom: var(--space-8);
}

.glossary-intro {
  color: var(--color-text-muted);
  font-size: var(--text-lg);
  margin-top: var(--space-3);
}

/* Alphabetical Navigation */
.glossary-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-6);
  padding: var(--space-4);
  background: var(--color-bg-subtle);
  border-radius: 8px;
}

.glossary-nav__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  text-decoration: none;
  transition: all 0.15s ease;
}

.glossary-nav__link:hover {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
  text-decoration: none;
}

/* Category Filters */
.glossary-filters {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--color-border);
}

.glossary-filters__label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
}

.glossary-filters__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.filter-tag {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-tag:hover,
.filter-tag.is-active {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}

/* Glossary Sections */
.glossary-section {
  margin-bottom: var(--space-10);
}

.glossary-section__letter {
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--color-accent);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 2px solid var(--color-accent);
  display: inline-block;
}

.glossary-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.glossary-item {
  padding: var(--space-4);
  background: var(--color-bg-subtle);
  border-radius: 8px;
}

.glossary-item__term {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.glossary-item__category {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 0.2em 0.6em;
  background: var(--color-accent);
  color: white;
  border-radius: 4px;
}

.glossary-item__definition p {
  margin-bottom: var(--space-3);
  color: var(--color-text-muted);
}

.glossary-item__related {
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

.glossary-item__related a {
  color: var(--color-accent);
}

/* ==========================================================================
   CHANGELOG PAGE STYLES
   ========================================================================== */

.changelog-page {
  max-width: var(--max-width);
}

.changelog-header {
  margin-bottom: var(--space-8);
}

.changelog-intro {
  color: var(--color-text-muted);
  font-size: var(--text-lg);
  margin-top: var(--space-3);
}

.changelog-legend {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-6);
  padding: var(--space-4);
  background: var(--color-bg-subtle);
  border-radius: 8px;
  font-size: var(--text-sm);
}

.legend-label {
  font-weight: 500;
  color: var(--color-text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Timeline */
.changelog-timeline {
  position: relative;
}

.changelog-year {
  margin-bottom: var(--space-10);
}

.changelog-year__title {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-3);
  border-bottom: 2px solid var(--color-border);
}

.changelog-entries {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.changelog-entry {
  display: flex;
  gap: var(--space-4);
}

.changelog-entry__marker {
  flex-shrink: 0;
  width: 40px;
  display: flex;
  justify-content: center;
  padding-top: var(--space-2);
}

.changelog-entry__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--color-bg);
  box-shadow: 0 0 0 2px var(--color-border);
}

.changelog-entry__content {
  flex: 1;
  padding: var(--space-5);
  background: var(--color-bg-subtle);
  border-radius: 8px;
}

.changelog-entry__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.changelog-entry__date {
  font-size: var(--text-sm);
  color: var(--color-text-light);
  font-family: var(--font-mono);
}

.changelog-entry__badge {
  font-size: var(--text-xs);
  font-weight: 500;
  padding: 0.2em 0.6em;
  border-radius: 4px;
}

.changelog-entry__title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 0 0 var(--space-3);
}

.changelog-entry__changes {
  list-style: disc;
  padding-left: var(--space-5);
  margin: 0;
}

.changelog-entry__changes li {
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.changelog-rss {
  margin-top: var(--space-10);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

/* ==========================================================================
   CANONICAL PAGE STYLES
   ========================================================================== */

/* Utility Bar Positioning */
.utility-bar {
  position: fixed;
  top: 80px;
  right: 2rem;
  display: flex;
  gap: 0.5rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  z-index: 100;
}

.utility-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.utility-btn:hover {
  color: var(--color-accent);
  background: var(--color-bg-subtle);
}

.utility-label {
  display: none;
}

/* Anchor Links - Pilcrow visibility on hover */
.anchor-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: 0.5rem;
  color: var(--color-text-light);
  text-decoration: none;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
  vertical-align: middle;
  font-size: 1rem;
  line-height: 1;
}

.anchor-link:hover {
  color: var(--color-accent);
  background: var(--color-bg-subtle);
  text-decoration: none;
}

h2:hover .anchor-link,
h3:hover .anchor-link {
  opacity: 1;
}

/* Print Styles for Canonical Pages */
@media print {

  .utility-bar,
  .section-index,
  .anchor-link,
  .mobile-section-nav {
    display: none !important;
  }

  .canonical-page {
    grid-template-columns: 1fr !important;
    padding: 0 !important;
    max-width: none !important;
  }

  .page-content {
    order: 1 !important;
  }

  .reference-article {
    max-width: none !important;
  }

  .sources-details {
    border: 1px solid #ccc;
    break-inside: avoid;
  }

  .data-table {
    break-inside: avoid;
  }
}

/* Section Index Sticky Behavior */
.section-index {
  position: sticky;
  top: 100px;
  width: 200px;
  font-size: 0.875rem;
  line-height: 1.5;
}

.section-index__title {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  padding-left: 0.75rem;
}

.section-index__list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 2px solid var(--color-border-light);
}

.section-index__item {
  margin: 0;
}

.section-index__item.active {
  border-left: 2px solid var(--color-accent);
  margin-left: -2px;
}

.section-index__link {
  display: block;
  padding: 0.5rem 0.75rem;
  color: var(--color-text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  margin-left: -2px;
  transition: color 0.15s ease;
}

.section-index__link:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.section-index__item.active .section-index__link {
  color: var(--color-accent);
  font-weight: 500;
}

/* Content Sections */
.content-section {
  scroll-margin-top: 80px;
}

/* Data Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
}

.data-table thead {
  background: var(--color-bg-subtle);
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--color-text);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text-muted);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--color-bg-subtle);
}

/* Table caption/note styling */
.table-note {
  font-size: 0.75rem;
  color: var(--color-text-light);
  margin-top: 0.5rem;
  font-style: italic;
}

/* Related Topics Cards */
.related-topics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.related-topic-card {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 1.25rem;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.related-topic-card:hover {
  border-color: var(--color-accent);
  background: var(--color-bg);
  text-decoration: none;
}

.related-topic-title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--color-accent);
}

.related-topic-desc {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Sources Section */
.sources-details {
  margin-top: 1rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
}

.sources-summary {
  padding: 1rem 1.25rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--color-text);
  background: var(--color-bg-subtle);
  list-style: none;
  user-select: none;
}

.sources-summary:hover {
  background: var(--color-bg);
}

.sources-summary::-webkit-details-marker {
  display: none;
}

.sources-summary::after {
  content: '▼';
  float: right;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.sources-details[open] .sources-summary::after {
  content: '▲';
}

.sources-content {
  padding: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.sources-content h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

.sources-content h3:first-child {
  margin-top: 0;
}

.sources-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.source-item {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border-light);
}

.source-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--color-accent);
  text-decoration: none;
  font-weight: 500;
}

.source-link:hover {
  text-decoration: underline;
}

.source-description {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.limitations-list {
  list-style: disc;
  padding-left: 1.25rem;
  margin: 0;
}

.limitations-list li {
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.methodology-link {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border-light);
}

.methodology-link a {
  color: var(--color-accent);
  font-size: 0.875rem;
}

.last-reviewed {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.8125rem;
  color: var(--color-text-light);
}

.last-reviewed .separator {
  margin: 0 0.5rem;
  color: var(--color-border);
}

.last-reviewed a {
  color: var(--color-text-muted);
}

.last-reviewed a:hover {
  color: var(--color-accent);
}

/* Canonical Page Layout Adjustments */
@media (max-width: 1280px) {
  .utility-bar {
    right: 1rem;
  }
}

@media (max-width: 1024px) {
  .utility-bar {
    position: static;
    margin-bottom: 2rem;
    align-self: flex-start;
  }

  .section-index {
    width: 160px;
  }
}

@media (max-width: 768px) {
  .utility-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    justify-content: center;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 0.75rem;
    background: var(--color-bg);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  }

  .utility-btn {
    flex-direction: column;
    padding: 0.5rem 1rem;
    gap: 0.25rem;
  }

  .utility-label {
    display: block;
    font-size: 0.6875rem;
  }

  .section-index {
    display: none;
  }

  .mobile-section-nav {
    display: block;
    margin-bottom: 2rem;
  }

  .section-dropdown {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    color: var(--color-text);
    cursor: pointer;
  }

  .anchor-link {
    display: none;
  }

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

  .data-table {
    font-size: 0.8125rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.625rem 0.75rem;
  }
}

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

.site-footer__left {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.site-footer__nav {
  display: flex;
  gap: var(--space-4);
}

.site-footer__nav a {
  font-size: var(--text-sm);
  color: var(--color-text-light);
}

.site-footer__nav a:hover {
  color: var(--color-accent);
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 640px) {
  :root {
    --text-3xl: 1.5rem;
    --text-2xl: 1.375rem;
  }

  .site-header__inner {
    flex-direction: column;
    height: auto;
    padding: var(--space-3) var(--space-4);
    gap: var(--space-3);
  }

  .site-nav {
    gap: var(--space-4);
    flex-wrap: wrap;
    justify-content: center;
  }

  .search-trigger {
    display: none;
    /* Hide search button on mobile, use Cmd+K instead */
  }

  .main-content {
    padding-top: var(--space-6);
  }

  .topic-list__link {
    flex-direction: column;
    gap: var(--space-1);
  }

  .site-footer__inner {
    flex-direction: column;
    gap: var(--space-3);
    text-align: center;
  }

  .site-footer__left {
    align-items: center;
  }

  /* Mobile Stats Grid */
  .stats-grid {
    grid-template-columns: 1fr;
  }

  /* Mobile How to Use */
  .how-to-use__grid {
    grid-template-columns: 1fr;
  }

  /* Mobile Page Actions */
  .page-actions__grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  /* Mobile Share Buttons */
  .share-buttons {
    flex-wrap: wrap;
  }

  /* Mobile Glossary */
  .glossary-nav {
    gap: var(--space-1);
  }

  .glossary-nav__link {
    width: 28px;
    height: 28px;
    font-size: var(--text-xs);
  }

  .glossary-filters {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Mobile Changelog */
  .changelog-entry__marker {
    width: 24px;
  }

  .changelog-legend {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  /* Mobile Hero */
  .hero__title {
    font-size: 1.75rem;
  }

  .hero__subtitle {
    font-size: var(--text-base);
  }

  .hero__search-btn {
    min-width: auto;
    width: 100%;
  }

  /* Mobile Update List */
  .update-item {
    flex-direction: column;
    gap: var(--space-1);
  }

  .update-item__date {
    min-width: auto;
  }
}