/* Custom theme styles for Coterie - Material for MkDocs */

/* ========================================
   SELF-HOSTED FONTS
   ======================================== */

/* Metamorphous - for H1 and main titles */
@font-face {
  font-family: 'Metamorphous';
  src: url('../assets/fonts/Metamorphous-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* IM Fell English SC - for H2, H3, H4 */
@font-face {
  font-family: 'IM Fell English SC';
  src: url('../assets/fonts/IMFellEnglishSC-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* IM Fell Great Primer (DW Pica SC) - for H5, H6 */
@font-face {
  font-family: 'IM Fell Great Primer';
  src: url('../assets/fonts/IMFellDWPicaSC-Regular.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* Merriweather Sans - body text (variable font) */
@font-face {
  font-family: 'Merriweather Sans';
  src: url('../assets/fonts/MerriweatherSans-VariableFont_wght.woff2') format('woff2-variations');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Merriweather Sans';
  src: url('../assets/fonts/MerriweatherSans-Italic-VariableFont_wght.woff2') format('woff2-variations');
  font-weight: 300 700;
  font-style: italic;
  font-display: swap;
}

/* ========================================
   ROOT VARIABLES - Material Theme Override
   ======================================== */

:root {
  /* Set custom fonts */
  --md-text-font: "Merriweather Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --md-code-font: "Roboto Mono", monospace;

  /* Font sizes */
  --md-text-font-size: 12pt;

  /* Transition timing - snappy but smooth */
  --transition-quick: 150ms ease-in-out;
  --transition-normal: 200ms ease-in-out;
  --transition-theme: 300ms ease-in-out;
  --transition-page: 250ms ease-in-out;
}

/* ========================================
   GOTHIC VAMPIRE COLOR SCHEME
   ======================================== */

/* Coterie Night Mode Color Palette:
   - Deep Crimson (#96031a): Header, primary accents
   - Carbon Black (#1b1b1e): Background
   - White (#fbfffe): Text
   - Dim Grey (#6d676e): Standout elements
   - Gold (#faa916): Links, active states
*/

[data-md-color-scheme="slate"] {
  /* Header - Deep Crimson */
  --md-primary-fg-color: #96031a;
  --md-primary-fg-color--light: #b5041f;
  --md-primary-fg-color--dark: #6d0212;

  /* Background - Carbon Black */
  --md-default-bg-color: #1b1b1e;
  --md-default-bg-color--light: #252528;
  --md-default-bg-color--lighter: #2f2f32;
  --md-default-bg-color--lightest: #39393c;

  /* Text - White */
  --md-default-fg-color: #fbfffe;
  --md-default-fg-color--light: #e0e0df;
  --md-default-fg-color--lighter: #c5c5c4;
  --md-default-fg-color--lightest: #aaaaaa;

  /* Accent/Links - Gold */
  --md-accent-fg-color: #faa916;
  --md-accent-fg-color--transparent: rgba(250, 169, 22, 0.1);

  /* Code blocks - Dim Grey background */
  --md-code-bg-color: #6d676e;
  --md-code-fg-color: #fbfffe;

  /* Standout elements - Dim Grey */
  --md-typeset-table-color: #6d676e;
}

/* Coterie Sunset Mode Color Palette:
   - Dried Blood (#903749): Header, primary accents
   - Twilight Blue (#2B2E4A): Background
   - White (#fbfffe): Text
   - Dusty Purp (#53354A): Standout elements
   - Blood Orange (#E84545): Links, active states
*/

[data-md-color-scheme="default"] {
  /* Header - Dried Blood */
  --md-primary-fg-color: #903749;
  --md-primary-fg-color--light: #a94256;
  --md-primary-fg-color--dark: #6d2837;

  /* Background - Twilight Blue */
  --md-default-bg-color: #2B2E4A;
  --md-default-bg-color--light: #353959;
  --md-default-bg-color--lighter: #3f4468;
  --md-default-bg-color--lightest: #494f77;

  /* Text - White */
  --md-default-fg-color: #fbfffe;
  --md-default-fg-color--light: #e0e0df;
  --md-default-fg-color--lighter: #c5c5c4;
  --md-default-fg-color--lightest: #aaaaaa;

  /* Accent/Links - Blood Orange */
  --md-accent-fg-color: #E84545;
  --md-accent-fg-color--transparent: rgba(232, 69, 69, 0.1);

  /* Code blocks - Dusty Purp background */
  --md-code-bg-color: #53354A;
  --md-code-fg-color: #fbfffe;

  /* Standout elements - Dusty Purp */
  --md-typeset-table-color: #53354A;
}

/* ========================================
   PAGE LOAD ANIMATIONS
   ======================================== */

/* Smooth fade-in for main content */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.md-content__inner {
  animation: fadeIn var(--transition-page) ease-out;
}

/* Smooth theme transition */
* {
  transition: background-color var(--transition-theme),
              color var(--transition-theme),
              border-color var(--transition-theme);
}

/* Override for elements that need different timing */
a, button, .md-nav__link, .md-footer__link {
  transition: all var(--transition-normal);
}

/* ========================================
   FULL-WIDTH HEADER
   ======================================== */

/* Remove header padding to extend to edges */
.md-header {
  padding-left: 0;
  padding-right: 0;
}

/* Ensure header inner content has appropriate spacing */
.md-header__inner {
  padding-left: 0.8rem;
  padding-right: 0.8rem;
}

/* Site title proper spacing */
.md-header__title {
  padding-left: 0;
}

/* ========================================
   TYPOGRAPHY HIERARCHY
   ======================================== */

/* Body text */
body {
  font-family: var(--md-text-font);
  font-size: var(--md-text-font-size);
}

/* H1 - Metamorphous with text shadow */
.md-content h1,
h1 {
  font-family: 'Metamorphous', serif;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

/* H2, H3, H4 - IM Fell English SC */
.md-content h2,
.md-content h3,
.md-content h4,
h2, h3, h4 {
  font-family: 'IM Fell English SC', serif;
}

/* H5, H6 - IM Fell Great Primer */
.md-content h5,
.md-content h6,
h5, h6 {
  font-family: 'IM Fell Great Primer', serif;
}

/* Page title in header */
.md-header__topic {
  font-family: 'Metamorphous', serif;
}

/* Site title */
.md-header__title {
  font-family: 'Metamorphous', serif;
}

/* ========================================
   NAVIGATION STYLING
   ======================================== */

/* Navigation tabs */
.md-tabs__link {
  font-family: 'Merriweather', serif;
  font-weight: 700;
  font-size: 1.05em;
}

/* Sidebar navigation */
.md-nav__title {
  font-family: 'Merriweather', serif;
  font-weight: 700;
}

.md-nav__link {
  font-family: 'Merriweather', serif;
}

/* Active navigation item */
.md-nav__link--active {
  font-weight: 700;
}

/* Smooth hover effects for navigation */
.md-nav__link {
  transition: color var(--transition-normal),
              padding-left var(--transition-normal),
              transform var(--transition-quick);
}

.md-nav__link:hover {
  padding-left: 0.3rem;
}

/* Navigation tabs hover effect */
.md-tabs__link {
  transition: background-color var(--transition-normal),
              color var(--transition-normal),
              transform var(--transition-quick);
}

.md-tabs__link:hover {
  transform: translateY(-2px);
}

/* Repository link */
.md-source {
  font-family: 'Metamorphous', serif;
}

/* ========================================
   TABLE OF CONTENTS (TOC)
   ======================================== */

.md-nav--secondary .md-nav__title {
  font-family: 'Merriweather', serif;
  font-size: 0.95em;
}

.md-nav--secondary .md-nav__link {
  font-family: 'Merriweather', serif;
  font-size: 0.95em;
}

/* ========================================
   SEARCH BAR
   ======================================== */

.md-search__input::placeholder {
  font-family: 'Metamorphous', serif;
  opacity: 0.8;
}

/* ========================================
   CONTENT WIDTH & LAYOUT
   ======================================== */

/* Material uses a different layout system, adjust container width */
.md-grid {
  max-width: 100rem; /* ~1600px, increased for wider layout */
}

.md-main__inner {
  margin-top: 0;
}

/* Content area - centered between sidebar and viewport */
.md-content {
  max-width: 75rem; /* ~1200px for optimal readability */
  margin-left: auto;
  margin-right: auto;
}

/* ========================================
   FOOTER STYLING
   ======================================== */

.md-footer {
  font-size: 0.75em;
  opacity: 1; /* Full opacity for footer navigation visibility */
}

/* Footer copyright - Hidden (attribution moved to Acknowledgments page) */
.md-footer-meta {
  display: none;
}

.md-footer__link {
  font-size: 0.9em;
}

/* Hide "Previous"/"Next" direction labels (keep page titles) */
.md-footer__direction {
  display: none;
}

/* Center page title vertically now that direction label is hidden */
.md-footer__title {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
}

/* Override Material's default spacing on the ellipsis element */
.md-footer__title .md-ellipsis {
  margin: 0;
  padding: 0;
  line-height: 1;
  /* Restore proper text truncation */
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Tablet: 640px - 1023px */
@media screen and (min-width: 640px) and (max-width: 1023px) {
  .md-content {
    max-width: 90%; /* Allow more width on tablets */
    margin-left: auto;
    margin-right: auto;
  }

  body {
    font-size: 11.5pt;
  }
}

/* Mobile: < 640px */
@media screen and (max-width: 639px) {
  .md-content {
    max-width: 100%; /* Full width on mobile */
    margin-left: 0;
    margin-right: 0;
  }

  body {
    font-size: 11pt;
  }

  .md-header__title {
    font-size: 1.5em;
  }

  /* Tables - Enable horizontal scroll on mobile */
  .md-typeset table:not([class]) {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 0.9em;
  }

  .md-typeset table:not([class]) thead th {
    font-size: 1em;
    padding: 0.7em 0.8em;
  }

  .md-typeset table:not([class]) td {
    padding: 0.6em 0.8em;
  }
}

/* Ultra-wide: >= 1920px */
@media screen and (min-width: 1920px) {
  .md-grid {
    max-width: 120rem; /* ~1920px */
  }

  .md-content {
    max-width: 90rem; /* Larger max width for ultra-wide */
    margin-left: auto;
    margin-right: auto;
  }
}

/* ========================================
   CODE BLOCKS & SYNTAX HIGHLIGHTING
   ======================================== */

code {
  font-family: var(--md-code-font);
}

.md-typeset code {
  font-family: var(--md-code-font);
}

/* ========================================
   ADDITIONAL MATERIAL CUSTOMIZATIONS
   ======================================== */

/* Admonitions (note, warning, etc.) */
.md-typeset .admonition {
  border-left: 4px solid;
  transition: transform var(--transition-quick),
              box-shadow var(--transition-normal);
}

.md-typeset .admonition:hover {
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Code blocks smooth transitions */
.md-typeset pre,
.md-typeset code {
  transition: background-color var(--transition-theme),
              color var(--transition-theme);
}

/* Links - Night Mode (Gold) with animated underline */
[data-md-color-scheme="slate"] .md-typeset a {
  color: #faa916;
  text-decoration: none;
  position: relative;
  transition: color var(--transition-normal);
}

[data-md-color-scheme="slate"] .md-typeset a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 0;
  height: 2px;
  background-color: #faa916;
  transition: width var(--transition-normal) ease-out;
}

[data-md-color-scheme="slate"] .md-typeset a:hover {
  color: #fbb647;
}

[data-md-color-scheme="slate"] .md-typeset a:hover::after {
  width: 100%;
}

[data-md-color-scheme="slate"] .md-typeset a:active,
[data-md-color-scheme="slate"] .md-nav__link--active {
  color: #faa916;
}

/* Tables - Night Mode (Professional Gothic Styling) */
[data-md-color-scheme="slate"] .md-typeset table:not([class]) {
  border: 1px solid rgba(150, 3, 26, 0.3);
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.5em auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  border-radius: 4px;
  width: 100%;
  max-width: 100%;
}

/* Table header - Metamorphous font with crimson background */
[data-md-color-scheme="slate"] .md-typeset table:not([class]) thead th {
  font-family: 'Metamorphous', serif;
  font-size: 1.1em;
  background-color: #96031a;
  color: #faa916;
  text-align: center;
  padding: 0.9em 1em;
  font-weight: normal;
  border-bottom: 2px solid #faa916;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Table body cells */
[data-md-color-scheme="slate"] .md-typeset table:not([class]) td {
  padding: 0.75em 1em;
  border-bottom: 1px solid rgba(109, 103, 110, 0.3);
  transition: background-color var(--transition-quick);
}

/* Alternating row colors */
[data-md-color-scheme="slate"] .md-typeset table:not([class]) tbody tr:nth-child(odd) {
  background-color: #1b1b1e;
}

[data-md-color-scheme="slate"] .md-typeset table:not([class]) tbody tr:nth-child(even) {
  background-color: #252528;
}

/* Hover effect */
[data-md-color-scheme="slate"] .md-typeset table:not([class]) tbody tr:hover {
  background-color: rgba(109, 103, 110, 0.2);
}

/* Remove border from last row */
[data-md-color-scheme="slate"] .md-typeset table:not([class]) tbody tr:last-child td {
  border-bottom: none;
}

/* Links - Sunset Mode (Blood Orange) with animated underline */
[data-md-color-scheme="default"] .md-typeset a {
  color: #E84545;
  text-decoration: none;
  position: relative;
  transition: color var(--transition-normal);
}

[data-md-color-scheme="default"] .md-typeset a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 0;
  height: 2px;
  background-color: #E84545;
  transition: width var(--transition-normal) ease-out;
}

[data-md-color-scheme="default"] .md-typeset a:hover {
  color: #ff6b6b;
}

[data-md-color-scheme="default"] .md-typeset a:hover::after {
  width: 100%;
}

[data-md-color-scheme="default"] .md-typeset a:active,
[data-md-color-scheme="default"] .md-nav__link--active {
  color: #E84545;
}

/* Tables - Sunset Mode (Professional Gothic Styling) */
[data-md-color-scheme="default"] .md-typeset table:not([class]) {
  border: 1px solid rgba(144, 55, 73, 0.3);
  border-collapse: separate;
  border-spacing: 0;
  margin: 1.5em auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  border-radius: 4px;
  width: 100%;
  max-width: 100%;
}

/* Table header - Metamorphous font with dried blood background */
[data-md-color-scheme="default"] .md-typeset table:not([class]) thead th {
  font-family: 'Metamorphous', serif;
  font-size: 1.1em;
  background-color: #903749;
  color: #E84545;
  text-align: center;
  padding: 0.9em 1em;
  font-weight: normal;
  border-bottom: 2px solid #E84545;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

/* Table body cells */
[data-md-color-scheme="default"] .md-typeset table:not([class]) td {
  padding: 0.75em 1em;
  border-bottom: 1px solid rgba(83, 53, 74, 0.3);
  transition: background-color var(--transition-quick);
}

/* Alternating row colors */
[data-md-color-scheme="default"] .md-typeset table:not([class]) tbody tr:nth-child(odd) {
  background-color: #2B2E4A;
}

[data-md-color-scheme="default"] .md-typeset table:not([class]) tbody tr:nth-child(even) {
  background-color: #353959;
}

/* Hover effect */
[data-md-color-scheme="default"] .md-typeset table:not([class]) tbody tr:hover {
  background-color: rgba(83, 53, 74, 0.2);
}

/* Remove border from last row */
[data-md-color-scheme="default"] .md-typeset table:not([class]) tbody tr:last-child td {
  border-bottom: none;
}

/* ========================================
   CUSTOM ADJUSTMENTS FOR MATERIAL
   ======================================== */

/* Ensure proper spacing */
.md-typeset h1 {
  margin: 0 0 1.25em;
}

.md-typeset h2 {
  margin: 1.6em 0 0.64em;
}

/* Adjust code block styling */
.md-typeset pre > code {
  background-color: var(--md-code-bg-color);
}

/* Navigation drawer for mobile */
.md-nav--primary .md-nav__title {
  background-color: var(--md-default-bg-color);
}

/* Search results */
.md-search-result__article {
  background-color: var(--md-default-bg-color--light);
}

/* Smooth search transitions */
.md-search__input {
  transition: border-color var(--transition-normal),
              box-shadow var(--transition-normal);
}

.md-search__input:focus {
  box-shadow: 0 0 0 3px var(--md-accent-fg-color--transparent);
}

/* ========================================
   GOTHIC VAMPIRE ENHANCEMENTS - NIGHT MODE
   ======================================== */

[data-md-color-scheme="slate"] .md-search__input {
  background-color: #1b1b1e;
  color: #fbfffe;
  border: 1px solid #96031a;
}

[data-md-color-scheme="slate"] .md-search__input::placeholder {
  color: rgba(251, 255, 254, 0.6);
}

[data-md-color-scheme="slate"] .md-search__input:focus {
  border-color: #faa916;
}

[data-md-color-scheme="slate"] .md-typeset code {
  background-color: #6d676e;
  color: #fbfffe;
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

[data-md-color-scheme="slate"] .md-typeset pre {
  background-color: #6d676e;
}

[data-md-color-scheme="slate"] .md-typeset pre > code {
  background-color: #6d676e;
  color: #fbfffe;
}

[data-md-color-scheme="slate"] .md-typeset .admonition {
  background-color: rgba(109, 103, 110, 0.2);
  border-left-color: #6d676e;
}

[data-md-color-scheme="slate"] .md-typeset .admonition-title {
  background-color: rgba(109, 103, 110, 0.4);
  border-left-color: #96031a;
}

[data-md-color-scheme="slate"] .md-footer {
  background-color: transparent;
  color: #6d676e;
}

[data-md-color-scheme="slate"] .md-footer-meta {
  background-color: transparent;
}

[data-md-color-scheme="slate"] .md-footer__link {
  color: #6d676e;
}

[data-md-color-scheme="slate"] .md-footer__link:hover {
  color: #faa916;
}

[data-md-color-scheme="slate"] ::-webkit-scrollbar {
  width: 10px;
  background: #1b1b1e;
}

[data-md-color-scheme="slate"] ::-webkit-scrollbar-thumb {
  background: #96031a;
  border-radius: 5px;
}

[data-md-color-scheme="slate"] ::-webkit-scrollbar-thumb:hover {
  background: #b5041f;
}

[data-md-color-scheme="slate"] .md-nav__title {
  background-color: rgba(109, 103, 110, 0.3);
}

[data-md-color-scheme="slate"] .md-nav__item--active > .md-nav__link {
  color: #faa916;
}

[data-md-color-scheme="slate"] .md-button {
  color: #faa916;
  border-color: #faa916;
}

[data-md-color-scheme="slate"] .md-button:hover {
  background-color: rgba(250, 169, 22, 0.1);
  border-color: #fbb647;
  color: #fbb647;
}

[data-md-color-scheme="slate"] .md-button--primary {
  background-color: #96031a;
  color: #fbfffe;
  border-color: #96031a;
}

[data-md-color-scheme="slate"] .md-button--primary:hover {
  background-color: #b5041f;
  border-color: #b5041f;
}

/* Footer navigation - Previous/Next buttons (Fixed width, accessible) */
[data-md-color-scheme="slate"] .md-footer__link {
  font-family: 'Metamorphous', serif;
  font-weight: normal;
  font-size: 1.1em;
  color: #faa916; /* Gold - 9.8:1 contrast ratio */
  background-color: rgba(150, 3, 26, 0.15); /* Subtle crimson glow */
  border: 1px solid rgba(150, 3, 26, 0.4); /* Crimson border */
  border-radius: 1.6rem;
  padding: 0.6rem 0.8rem; /* Reduced height, tighter spacing */
  transition: all 0.2s ease-in-out;

  /* Fixed width matching TOC sidebar */
  width: 12.1rem;
  display: flex;
  align-items: center; /* Vertically center all children */
  justify-content: space-between; /* Arrows on edges, text centered */
  text-align: center;
}

[data-md-color-scheme="slate"] .md-footer__link:hover {
  color: #faa916; /* Same color - maintains visibility */
  background-color: rgba(150, 3, 26, 0.35); /* Stronger crimson glow */
  border-color: #96031a; /* Solid crimson border */
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(250, 169, 22, 0.3); /* Gold glow shadow */
}

[data-md-color-scheme="slate"] .md-footer__title {
  font-family: 'Metamorphous', serif;
  font-size: 1.05em;
  color: #faa916; /* Gold text */
  flex: 1; /* Take available space for centering */
  padding: 0 0.4rem; /* Spacing between arrows and text */
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-md-color-scheme="slate"] .md-footer__title .md-ellipsis {
  margin: 0;
  padding: 0;
  line-height: 1;
  /* Restore proper text truncation */
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-md-color-scheme="slate"] .md-footer__button {
  transition: all 0.2s ease-in-out;
  flex-shrink: 0; /* Prevent arrow icons from shrinking */
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
}

[data-md-color-scheme="slate"] .md-footer__button:hover {
  transform: scale(1.2);
  filter: drop-shadow(0 0 10px rgba(250, 169, 22, 0.6));
}

/* ========================================
   GOTHIC VAMPIRE ENHANCEMENTS - SUNSET MODE
   ======================================== */

[data-md-color-scheme="default"] .md-search__input {
  background-color: #2B2E4A;
  color: #fbfffe;
  border: 1px solid #903749;
}

[data-md-color-scheme="default"] .md-search__input::placeholder {
  color: rgba(251, 255, 254, 0.6);
}

[data-md-color-scheme="default"] .md-search__input:focus {
  border-color: #E84545;
}

[data-md-color-scheme="default"] .md-typeset code {
  background-color: #53354A;
  color: #fbfffe;
  padding: 0.2em 0.4em;
  border-radius: 3px;
}

[data-md-color-scheme="default"] .md-typeset pre {
  background-color: #53354A;
}

[data-md-color-scheme="default"] .md-typeset pre > code {
  background-color: #53354A;
  color: #fbfffe;
}

[data-md-color-scheme="default"] .md-typeset .admonition {
  background-color: rgba(83, 53, 74, 0.2);
  border-left-color: #53354A;
}

[data-md-color-scheme="default"] .md-typeset .admonition-title {
  background-color: rgba(83, 53, 74, 0.4);
  border-left-color: #903749;
}

[data-md-color-scheme="default"] .md-footer {
  background-color: transparent;
  color: #53354A;
}

[data-md-color-scheme="default"] .md-footer-meta {
  background-color: transparent;
}

[data-md-color-scheme="default"] .md-footer__link {
  color: #53354A;
}

[data-md-color-scheme="default"] .md-footer__link:hover {
  color: #E84545;
}

[data-md-color-scheme="default"] ::-webkit-scrollbar {
  width: 10px;
  background: #2B2E4A;
}

[data-md-color-scheme="default"] ::-webkit-scrollbar-thumb {
  background: #903749;
  border-radius: 5px;
}

[data-md-color-scheme="default"] ::-webkit-scrollbar-thumb:hover {
  background: #a94256;
}

[data-md-color-scheme="default"] .md-nav__title {
  background-color: rgba(83, 53, 74, 0.3);
}

[data-md-color-scheme="default"] .md-nav__item--active > .md-nav__link {
  color: #E84545;
}

[data-md-color-scheme="default"] .md-button {
  color: #E84545;
  border-color: #E84545;
}

[data-md-color-scheme="default"] .md-button:hover {
  background-color: rgba(232, 69, 69, 0.1);
  border-color: #ff6b6b;
  color: #ff6b6b;
}

[data-md-color-scheme="default"] .md-button--primary {
  background-color: #903749;
  color: #fbfffe;
  border-color: #903749;
}

[data-md-color-scheme="default"] .md-button--primary:hover {
  background-color: #a94256;
  border-color: #a94256;
}

/* Footer navigation - Previous/Next buttons (Fixed width, accessible) */
[data-md-color-scheme="default"] .md-footer__link {
  font-family: 'Metamorphous', serif;
  font-weight: normal;
  font-size: 1.1em;
  color: #E84545; /* Blood orange - 4.2:1 contrast ratio */
  background-color: rgba(144, 55, 73, 0.15); /* Subtle dried blood glow */
  border: 1px solid rgba(144, 55, 73, 0.4); /* Dried blood border */
  border-radius: 1.6rem;
  padding: 0.6rem 0.8rem; /* Reduced height, tighter spacing */
  transition: all 0.2s ease-in-out;

  /* Fixed width matching TOC sidebar */
  width: 12.1rem;
  display: flex;
  align-items: center; /* Vertically center all children */
  justify-content: space-between; /* Arrows on edges, text centered */
  text-align: center;
}

[data-md-color-scheme="default"] .md-footer__link:hover {
  color: #E84545; /* Same color - maintains visibility */
  background-color: rgba(144, 55, 73, 0.35); /* Stronger dried blood glow */
  border-color: #903749; /* Solid dried blood border */
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(232, 69, 69, 0.3); /* Blood orange glow shadow */
}

[data-md-color-scheme="default"] .md-footer__title {
  font-family: 'Metamorphous', serif;
  font-size: 1.05em;
  color: #E84545; /* Blood orange text */
  flex: 1; /* Take available space for centering */
  padding: 0 0.4rem; /* Spacing between arrows and text */
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-md-color-scheme="default"] .md-footer__title .md-ellipsis {
  margin: 0;
  padding: 0;
  line-height: 1;
  /* Restore proper text truncation */
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-md-color-scheme="default"] .md-footer__button {
  transition: all 0.2s ease-in-out;
  flex-shrink: 0; /* Prevent arrow icons from shrinking */
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
}

[data-md-color-scheme="default"] .md-footer__button:hover {
  transform: scale(1.2);
  filter: drop-shadow(0 0 10px rgba(232, 69, 69, 0.6));
}

/* ========================================
   TERMINOLOGY TOGGLE - PREVENT FOUC
   ======================================== */

/* Prevent flash of VTM terms when in Generic mode */
/* Hide content until terminology mode is set */
body:not([data-terminology-mode]) .md-content,
body:not([data-terminology-mode]) .md-nav {
  opacity: 0.01;
  transition: opacity 0.15s ease-in;
}

body[data-terminology-mode] .md-content,
body[data-terminology-mode] .md-nav {
  opacity: 1;
}

/* ========================================
   PRINT STYLES (if needed)
   ======================================== */

@media print {
  body {
    font-size: 10pt;
  }

  .md-header,
  .md-footer,
  .md-nav {
    display: none;
  }
}

/* ========================================
   MOBILE RESPONSIVE DESIGN - FOOTER BUTTONS
   ======================================== */

/* Mobile (< 720px) - Icon-only footer buttons */
@media screen and (max-width: 719px) {
  .md-footer__inner {
    padding: 0.5rem;
  }

  [data-md-color-scheme="slate"] .md-footer__link,
  [data-md-color-scheme="default"] .md-footer__link {
    width: 3rem;
    height: 3rem;
    min-width: 3rem;
    padding: 0;
    border-radius: 1.6rem;
    display: flex;
    justify-content: center !important;
    align-items: center !important;
  }

  .md-footer__title {
    display: none !important;
  }

  .md-footer__button.md-icon {
    width: 3rem !important;
    height: 3rem !important;
    min-width: 3rem !important;
    min-height: 3rem !important;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
  }

  .md-footer__button svg {
    width: 1.5rem;
    height: 1.5rem;
    display: block;
    margin: auto;
  }

  [data-md-color-scheme="slate"] .md-footer__link:hover,
  [data-md-color-scheme="default"] .md-footer__link:hover {
    transform: translateY(-2px);
  }

  [data-md-color-scheme="slate"] .md-footer__button:hover,
  [data-md-color-scheme="default"] .md-footer__button:hover {
    transform: scale(1.15);
  }
}

/* Extra small mobile (< 480px) - minimum accessible size */
@media screen and (max-width: 479px) {
  .md-footer__inner {
    padding: 0.4rem;
  }

  [data-md-color-scheme="slate"] .md-footer__link,
  [data-md-color-scheme="default"] .md-footer__link {
    width: 2.75rem;
    height: 2.75rem;
    min-width: 2.75rem;
  }

  .md-footer__button svg {
    width: 1.25rem;
    height: 1.25rem;
    display: block;
    vertical-align: middle;
  }
}

/* ========================================
   MOBILE RESPONSIVE DESIGN - TERMINOLOGY TOGGLE
   ======================================== */

/* Mobile (< 720px) - Compact toggle */
@media screen and (max-width: 719px) {
  #coterie-terminology-toggle {
    gap: 0.3rem;
    margin-left: 0.5rem;
  }

  #coterie-terminology-toggle span {
    font-size: 0.75rem !important;
  }

  #coterie-terminology-toggle button svg {
    width: 18px !important;
    height: 18px !important;
  }
}

/* Extra small mobile (< 480px) - Ultra-compact */
@media screen and (max-width: 479px) {
  #coterie-terminology-toggle {
    gap: 0.25rem;
    margin-left: 0.3rem;
  }

  #coterie-terminology-toggle span {
    font-size: 0.7rem !important;
  }

  #coterie-terminology-toggle button svg {
    width: 16px !important;
    height: 16px !important;
  }
}

/* Mobile (< 720px) - Abbreviated label to save space */
@media screen and (max-width: 719px) {
  #coterie-terminology-toggle span:last-child {
    font-size: 0 !important;
  }

  #coterie-terminology-toggle span:last-child::after {
    content: 'G';
    font-size: 0.75rem;
    font-family: 'IM FELL English SC', serif;
    color: var(--md-default-fg-color);
  }
}

/* ========================================
   FLOATING FOOTER NAVIGATION
   ======================================== */

/* Make footer navigation float above content */
.md-footer__inner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  display: flex;
  justify-content: space-between;
  padding: 1rem;
  pointer-events: none;
  background: none;
}

/* Override Material's md-grid max-width for full-width footer */
.md-footer__inner.md-grid {
  max-width: none;
  width: 100%;
}

/* Re-enable pointer events on actual buttons */
.md-footer__link {
  pointer-events: auto;
}

/* Position Previous button (bottom-left) */
.md-footer__link--prev {
  margin-right: auto;
}

/* Position Next button (bottom-right) */
.md-footer__link--next {
  margin-left: auto;
}

/* Reduced transparency - more opaque backgrounds for visibility over TOC */
[data-md-color-scheme="slate"] .md-footer__link {
  background-color: rgba(150, 3, 26, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6),
              0 4px 20px rgba(0, 0, 0, 0.4),
              0 0 40px rgba(150, 3, 26, 0.3);
}

[data-md-color-scheme="slate"] .md-footer__link:hover {
  background-color: rgba(150, 3, 26, 0.95);
}

[data-md-color-scheme="default"] .md-footer__link {
  background-color: rgba(144, 55, 73, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5),
              0 4px 20px rgba(0, 0, 0, 0.3),
              0 0 40px rgba(144, 55, 73, 0.3);
}

[data-md-color-scheme="default"] .md-footer__link:hover {
  background-color: rgba(144, 55, 73, 0.95);
}

/* Keep original footer copyright section in normal flow */
.md-footer-meta {
  position: static;
  margin-top: 2rem;
}

/* ========================================
   BACK TO TOP BUTTON - Match Prev/Next Styling
   ======================================== */

/* Night Mode */
[data-md-color-scheme="slate"] .md-top {
  background-color: rgba(150, 3, 26, 0.85);
  color: #faa916;
  border: 1px solid rgba(150, 3, 26, 0.4);
  border-radius: 1.6rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6),
              0 4px 20px rgba(0, 0, 0, 0.4),
              0 0 40px rgba(150, 3, 26, 0.3);
  transition: all var(--transition-normal);
}

[data-md-color-scheme="slate"] .md-top:hover {
  background-color: rgba(150, 3, 26, 0.95);
  box-shadow: 0 4px 12px rgba(250, 169, 22, 0.3);
}

/* Sunset Mode */
[data-md-color-scheme="default"] .md-top {
  background-color: rgba(144, 55, 73, 0.85);
  color: #E84545;
  border: 1px solid rgba(144, 55, 73, 0.4);
  border-radius: 1.6rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5),
              0 4px 20px rgba(0, 0, 0, 0.3),
              0 0 40px rgba(144, 55, 73, 0.3);
  transition: all var(--transition-normal);
}

[data-md-color-scheme="default"] .md-top:hover {
  background-color: rgba(144, 55, 73, 0.95);
  box-shadow: 0 4px 12px rgba(232, 69, 69, 0.3);
}

/* Ensure main content doesn't get hidden behind floating buttons */
.md-main {
  padding-bottom: 5rem;
}

/* Improved focus visibility for accessibility */
.md-footer__link:focus-visible {
  outline: 3px solid var(--md-accent-fg-color);
  outline-offset: 4px;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .md-footer__link,
  .md-footer__button {
    transition: none;
    transform: none !important;
  }

  .md-footer__link:hover {
    transform: none;
  }

  .md-footer__button:hover {
    transform: none;
    filter: none;
  }
}

/* Mobile responsive adjustments for floating buttons */
@media screen and (max-width: 719px) {
  .md-footer__inner {
    padding: 0.5rem;
  }

  [data-md-color-scheme="slate"] .md-footer__link,
  [data-md-color-scheme="default"] .md-footer__link {
    margin-bottom: 40px;
  }

  .md-main {
    padding-bottom: calc(3rem + 40px + 1rem);
  }
}

@media screen and (max-width: 479px) {
  .md-footer__inner {
    padding: 0.4rem;
  }

  [data-md-color-scheme="slate"] .md-footer__link,
  [data-md-color-scheme="default"] .md-footer__link {
    margin-bottom: 35px;
  }

  .md-main {
    padding-bottom: calc(2.75rem + 35px + 1rem);
  }
}
