/* ============================================================
   extra.css  —  Gruvbox theme for MkDocs Material
   ============================================================ */

/* ── 1. FONT ─────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Martian+Mono:wght@300;400;600;700&display=swap');

/* ── 2. GRUVBOX LIGHT TOKENS ─────────────────────────────────── */
:root {
  --gb-bg: #fbf1c7;
  --gb-bg1: #ebdbb2;
  --gb-bg2: #d5c4a1;
  --gb-bg3: #bdae93;
  --gb-fg: #3c3836;
  --gb-fg2: #504945;
  --gb-accent: #9d0006;
  --gb-green: #79740e;
  --gb-yellow: #b57614;
  --gb-orange: #af3a03;
  --gb-blue: #076678;
  --gb-purple: #8f3f71;
  --gb-aqua: #427b58;
  --gb-border: #bdae93;
  --gb-tech: #8f3f71;
  --font-mono: 'Martian Mono', 'Courier New', monospace;
  /* Material font override */
  --md-text-font: 'Martian Mono', 'Courier New', monospace;
  --md-code-font: 'Martian Mono', 'Courier New', monospace;
}

/* ── 3. LIGHT SCHEME ─────────────────────────────────────────── */
[data-md-color-scheme="default"] {
  --md-default-bg-color: #fbf1c7;
  --md-default-fg-color: #3c3836;
  --md-default-fg-color--light: #504945;
  --md-default-fg-color--lighter: #7c6f64;
  --md-default-fg-color--lightest: #a89984;
  --md-primary-fg-color: #9d0006;
  --md-primary-fg-color--light: #cc241d;
  --md-primary-fg-color--dark: #6e0005;
  --md-primary-bg-color: #fbf1c7;
  --md-primary-bg-color--light: #ebdbb2;
  --md-accent-fg-color: #076678;
  --md-accent-fg-color--transparent: rgba(7, 102, 120, .1);
  --md-accent-bg-color: #fbf1c7;
  --md-code-bg-color: #ebdbb2;
  --md-code-fg-color: #3c3836;
  --md-code-hl-color: rgba(181, 118, 20, .3);
  --md-admonition-bg-color: #f2e5bc;
  --md-footer-bg-color: #ebdbb2;
  --md-footer-bg-color--dark: #d5c4a1;
  --md-footer-fg-color: #3c3836;
  --md-footer-fg-color--light: #504945;
  --md-footer-fg-color--lighter: #7c6f64;
  --md-typeset-a-color: #076678;
  --md-typeset-color: #3c3836;
  --md-typeset-mark-color: rgba(181, 118, 20, .4);
  --md-typeset-del-color: rgba(157, 0, 6, .15);
  --md-typeset-ins-color: rgba(121, 116, 14, .15);
  --md-typeset-table-color: rgba(60, 56, 54, .12);
  --md-typeset-table-color--light: rgba(60, 56, 54, .035);
  /* Gruvbox shorthand tokens */
  --bg: #fbf1c7;
  --bg1: #ebdbb2;
  --bg2: #d5c4a1;
  --bg3: #bdae93;
  --fg: #3c3836;
  --fg2: #504945;
  --accent: #9d0006;
  --green: #79740e;
  --yellow: #b57614;
  --orange: #af3a03;
  --blue: #076678;
  --purple: #8f3f71;
  --aqua: #427b58;
  --border: #bdae93;
  --tech-color: #8f3f71;
}

/* ── 4. DARK SCHEME ──────────────────────────────────────────── */
[data-md-color-scheme="slate"] {
  --md-default-bg-color: #282828;
  --md-default-fg-color: #ebdbb2;
  --md-default-fg-color--light: #d5c4a1;
  --md-default-fg-color--lighter: #bdae93;
  --md-default-fg-color--lightest: #a89984;
  --md-primary-fg-color: #fb4934;
  --md-primary-fg-color--light: #fe8019;
  --md-primary-fg-color--dark: #cc241d;
  --md-primary-bg-color: #282828;
  --md-primary-bg-color--light: #3c3836;
  --md-accent-fg-color: #83a598;
  --md-accent-fg-color--transparent: rgba(131, 165, 152, .1);
  --md-accent-bg-color: #282828;
  --md-code-bg-color: #3c3836;
  --md-code-fg-color: #ebdbb2;
  --md-code-hl-color: rgba(250, 189, 47, .25);
  --md-admonition-bg-color: #32302f;
  --md-footer-bg-color: #3c3836;
  --md-footer-bg-color--dark: #282828;
  --md-footer-fg-color: #ebdbb2;
  --md-footer-fg-color--light: #d5c4a1;
  --md-footer-fg-color--lighter: #bdae93;
  --md-typeset-a-color: #83a598;
  --md-typeset-color: #ebdbb2;
  --md-typeset-mark-color: rgba(250, 189, 47, .3);
  --md-typeset-del-color: rgba(251, 73, 52, .15);
  --md-typeset-ins-color: rgba(184, 187, 38, .15);
  --md-typeset-table-color: rgba(235, 219, 178, .12);
  --md-typeset-table-color--light: rgba(235, 219, 178, .035);
  /* Gruvbox shorthand tokens */
  --bg: #282828;
  --bg1: #3c3836;
  --bg2: #504945;
  --bg3: #665c54;
  --fg: #ebdbb2;
  --fg2: #d5c4a1;
  --accent: #fb4934;
  --green: #b8bb26;
  --yellow: #fabd2f;
  --orange: #fe8019;
  --blue: #83a598;
  --purple: #d3869b;
  --aqua: #8ec07c;
  --border: #665c54;
  --tech-color: #d3869b;
}

/* ── 5. RESET & BASE ─────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.6;
  scroll-behavior: smooth;
  /* Prevent iOS font-size inflation on rotate */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ── FULL-SITE THEME ── */
body {
  background-color: var(--bg);
  color: var(--fg);
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* Make sure Material's own page wrapper also picks up the bg */
.md-main,
.md-content,
.md-container {
  background-color: var(--bg) !important;
  color: var(--fg) !important;
}

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

/* ── Hide Material's built-in chrome ──── */
.md-header {
  display: none !important;
}

.md-footer {
  display: none !important;
}

.md-sidebar--primary {
  display: none !important;
}

.md-content {
  margin-left: 0 !important;
}

.md-main__inner {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2.5%);
}

/* ── 6. HEADER ───────────────────────────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.2rem clamp(1rem, 3vw, 2.5%);
  border-bottom: 3px solid var(--border);
  margin-bottom: 2rem;
  flex-wrap: nowrap;
  max-width: 1300px;
  margin-left: auto;
  margin-right: auto;
  background-color: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
  /* Ensure sticky header bg covers content below on all browsers */
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.brand {
  font-weight: 700;
  font-size: clamp(0.95rem, 2vw, 1.25rem);
  letter-spacing: -0.5px;
  white-space: nowrap;
  text-transform: uppercase;
  color: var(--fg);
  text-decoration: none;
  flex-shrink: 0;
  margin-right: 0.5rem;
}

.brand:hover {
  opacity: 0.85;
  text-decoration: none;
}

/* ── 7. NAVIGATION ───────────────────────────────────────────── */
.main-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 1.5rem;
  flex-wrap: nowrap;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  /* allow flex shrink */
}

.nav-box {
  border: 2px solid var(--border);
  color: var(--fg);
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  font-size: clamp(0.78rem, 1.2vw, 0.9rem);
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  background: transparent;
  font-family: var(--font-mono);
  line-height: 1.4;
  transition: background-color 0.18s ease, color 0.18s ease, border-color 0.18s ease;
  /* Remove iOS tap flash */
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  /* Firefox: remove default button outline on click */
  -moz-appearance: none;
}

.nav-box:hover,
.nav-box:focus-visible {
  background-color: var(--fg);
  color: var(--bg);
  outline: 2px solid var(--fg);
  /* visible for keyboard users */
  outline-offset: 1px;
  text-decoration: none;
}

.nav-arrow {
  font-size: 0.65rem;
  line-height: 1;
  display: inline-block;
  transition: transform 0.2s ease;
  pointer-events: none;
}

/* ── DROPDOWN ─────────────────────────────────────────────────── */
.nav-dropdown {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  margin-top: 4px;
  left: 0;
  z-index: 200;
  min-width: 220px;
  background-color: var(--bg);
  border: 2px solid var(--border);
  list-style: none;
  padding: 0;
  margin: 4px 0 0 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
  pointer-events: none;
  /* Safari needs explicit background when sticky header is behind */
  -webkit-overflow-scrolling: touch;
}

/* Bridge gap so mouse can travel from button to menu */
.dropdown-menu::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 0;
  width: 100%;
  height: 10px;
  background: transparent;
}

.nav-dropdown:hover>.dropdown-menu,
.nav-dropdown:focus-within>.dropdown-menu,
.nav-dropdown.open>.dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s;
}

.nav-dropdown:hover>.nav-box .nav-arrow,
.nav-dropdown.open>.nav-box .nav-arrow {
  transform: rotate(180deg);
}

.dropdown-menu li {
  border-bottom: 1px solid var(--border);
}

.dropdown-menu li:last-child {
  border-bottom: none;
}

.dropdown-menu a {
  display: block;
  padding: 0.55rem 1rem;
  color: var(--fg);
  font-weight: 500;
  font-size: 0.88rem;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font-mono);
  background-color: var(--bg);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.dropdown-menu a:hover,
.dropdown-menu a:focus-visible {
  background-color: var(--fg);
  color: var(--bg);
  outline: none;
}

/* ── 8. CONTROLS ─────────────────────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  margin-left: auto;
}

.ctrl-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  text-decoration: none;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease,
    transform 0.18s ease, border-color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.ctrl-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  pointer-events: none;
}

.ctrl-btn:hover,
.ctrl-btn:focus-visible {
  background-color: var(--fg);
  color: var(--bg);
  transform: translateY(-2px);
  outline: none;
}

/* ── 9. THEME TOGGLE ────────────────────────────────────── */
.theme-toggle {
  width: 56px;
  height: 28px;
  background-color: var(--border);
  border: none;
  border-radius: 28px;
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px;
  transition: background-color 0.3s ease;
  overflow: hidden;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle::before {
  content: "🌙";
  font-size: 13px;
  line-height: 1;
  z-index: 1;
}

.theme-toggle::after {
  content: "🌞";
  font-size: 13px;
  line-height: 1;
  z-index: 1;
}

.toggle-circle {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background-color: var(--bg);
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  /* Force GPU layer for smooth animation on all browsers */
  will-change: transform;
}

[data-md-color-scheme="slate"] .toggle-circle {
  transform: translateX(27px);
}

/* ── 10. CONTENT AREA ────────────────────────────────────────── */
.md-content__inner {
  padding: 1.5rem 0 3rem;
  /* comfortable reading width, but not pinned on large screens */
  max-width: min(900px, 100%);
}

/* ── SUPPRESS the auto-generated "HOME" h1 on the index page ── */
/* Material injects an h1 from the page title front-matter.
   We use `hide: navigation` + a <p class="intro-title"> instead. */
.md-typeset h1:first-child {
  display: none;
}

/* ── 11. INTRO HEADER ────────────────────────────────────────── */
.intro-header {
  margin-bottom: 1.2rem;
}

/* Daemon sits inline to the right of the caption text.
   Use flex so it stays on the same line and wraps gracefully. */
.intro-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  /* wraps on narrow screens */
  gap: 0.5rem;
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  font-weight: 700;
  line-height: 1.35;
  color: var(--fg);
  margin: 0 0 0.5rem;
  text-transform: none;
  font-family: var(--font-mono);
}

.daemon-icon {
  /* inline with text, does NOT push onto next line */
  display: inline-block;
  flex-shrink: 0;
  width: clamp(1.6rem, 3vw, 2.2rem);
  height: clamp(1.6rem, 3vw, 2.2rem);
  vertical-align: middle;
  animation: radiate 2s infinite ease-in-out;
}

@keyframes radiate {
  0% {
    filter: drop-shadow(0 0 2px var(--accent));
    transform: scale(1);
  }

  50% {
    filter: drop-shadow(0 0 12px var(--accent));
    transform: scale(1.2);
  }

  100% {
    filter: drop-shadow(0 0 2px var(--accent));
    transform: scale(1);
  }
}

/* ── 12. TYPOGRAPHY ──────────────────────────────────────────── */
.md-typeset {
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--fg);
}

.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
  font-family: var(--font-mono);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--fg);
  line-height: 1.3;
}

/* Suppress Material's coloured underline on h1 */
.md-typeset h1 {
  color: var(--fg);
  border-bottom: none;
}

.md-typeset a {
  color: var(--blue);
  font-weight: 600;
  text-decoration: none;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.md-typeset a:hover {
  text-decoration: underline;
  opacity: 0.85;
}

.md-typeset p {
  font-size: 1.05rem;
  margin-bottom: 1.4rem;
  text-align: justify;
  line-height: 1.7;
  /* hyphens need a lang attribute on <html> to work reliably */
  hyphens: auto;
  overflow-wrap: break-word;
  word-break: break-word;
  /* fallback for Safari < 15 */
}

/* ── 13. PROFILE PIC ─────────────────────────────────────────── */
.profile-pic {
  float: left;
  width: clamp(110px, 15vw, 150px);
  height: auto;
  margin: 0.5rem 1.5rem 1rem 0;
  border-radius: 3px;
  /* Light mode: invert so the B&W photo looks like a chalk sketch */
  filter: invert(1) contrast(1.1);
  transition: filter 0.3s ease;
}

/* Dark mode: show original photo */
[data-md-color-scheme="slate"] .profile-pic {
  filter: none;
}

/* ── 14. DASHED RULE ─────────────────────────────────────────── */
.dashed-rule {
  clear: both;
  height: 0;
  border: none;
  border-top: 2px dashed var(--border);
  margin: 2.5rem 0;
  /* Ensure the dashes actually render in all browsers */
  overflow: visible;
}

/* ── 15. SECTION HEADINGS ────────────────────────────────────── */
.section-heading {
  font-size: clamp(1.1rem, 2vw, 1.3rem);
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1.2rem;
  padding-bottom: 0.4rem;
  border-bottom: 3px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-transform: uppercase;
  color: var(--fg);
}

/* ── 16. BOOK CARDS ──────────────────────────────────────────── */
.reading-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 1.2rem;
  margin-bottom: 2.5rem;
}

.book-card {
  border: 2px solid var(--border);
  padding: 1.1rem;
  background-color: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.book-card:hover {
  border-color: var(--blue);
  transform: translateY(-3px);
}

.book-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
}

.book-author {
  font-style: italic;
  font-size: 0.88rem;
  opacity: 0.75;
  margin-bottom: 0.4rem;
}

.book-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.3rem 0 0.6rem;
}

.book-blurb {
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0;
  text-align: left;
}

/* ── 17. RANDOM FEED / DIE ───────────────────────────────────── */
.random-feed-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-bottom: 1rem;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.die-btn {
  width: 38px;
  height: 38px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--bg1);
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0;
  font-family: var(--font-mono);
  /* Prevent iOS double-tap zoom on the button */
  touch-action: manipulation;
}

.die-btn:hover {
  border-color: var(--purple);
  transform: rotate(15deg) scale(1.1);
}

.die-btn.rolling {
  animation: die-roll 0.5s ease;
}

@keyframes die-roll {
  0% {
    transform: rotate(0deg) scale(1);
  }

  25% {
    transform: rotate(90deg) scale(1.15);
  }

  50% {
    transform: rotate(180deg) scale(0.9);
  }

  75% {
    transform: rotate(270deg) scale(1.1);
  }

  100% {
    transform: rotate(360deg) scale(1);
  }
}

.random-feed-label {
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.random-feed-card {
  border: 2px solid var(--border);
  padding: 1.1rem;
  background-color: var(--bg);
  margin-bottom: 2.5rem;
  transition: border-color 0.2s ease;
}

.random-feed-card:hover {
  border-color: var(--purple);
}

.random-feed-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.4rem;
  color: var(--accent);
}

.random-feed-text {
  font-size: 0.9rem;
  margin: 0;
  text-align: left;
}

#random-feed-items {
  display: none;
  margin-top: 0.6rem;
}

.random-post-item {
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.92rem;
  line-height: 1.5;
}

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

.random-post-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--aqua);
  margin-right: 0.3rem;
}

/* ── 18. FOOTER ──────────────────────────────────────────────── */
.site-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 3.5rem;
  padding: 1.5rem clamp(1rem, 3vw, 2.5%) 2rem;
  border-top: 3px solid var(--border);
  font-size: 0.85rem;
  font-weight: 500;
  max-width: 1300px;
  margin-left: auto;
  margin-right: auto;
  background-color: var(--bg);
  font-family: var(--font-mono);
  color: var(--fg);
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.footer-center {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  justify-content: center;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* CC badge */
.footer-license-link {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--fg);
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.footer-license-link:hover {
  opacity: 0.75;
}

.cc-icons {
  display: flex;
  gap: 3px;
}

.cc-icon {
  border: 1.5px solid currentColor;
  border-radius: 50%;
  width: 21px;
  height: 21px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 800;
  line-height: 1;
  /* Ensure circles stay round on all browsers */
  flex-shrink: 0;
}

/* "Built with" label */
.footer-built-label {
  color: var(--fg2);
  white-space: nowrap;
}

/* MkDocs Material link */
.footer-tech-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--tech-color);
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s ease;
}

.footer-tech-item:hover {
  opacity: 0.75;
}

.tech-logo {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* Social icons */
.social-link {
  color: var(--fg);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  text-decoration: none;
  transition: opacity 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.social-link svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.social-link:hover {
  opacity: 0.75;
  transform: translateY(-2px);
  color: var(--accent);
}

/* ── 19. MATERIAL COMPONENT OVERRIDES ───────────────────────── */

/* Search */
.md-search__form {
  background-color: var(--bg1) !important;
  border: 1.5px solid var(--border) !important;
  border-radius: 3px !important;
}

.md-search__input {
  color: var(--fg) !important;
  font-family: var(--font-mono) !important;
}

.md-search__input::placeholder {
  color: var(--fg2) !important;
}

.md-search-result {
  background-color: var(--bg) !important;
}

.md-search-result__meta {
  background-color: var(--bg1) !important;
  color: var(--fg2) !important;
}

.md-search-result__link:hover {
  background-color: var(--bg2) !important;
}

.md-search-result__title {
  color: var(--fg) !important;
  font-family: var(--font-mono) !important;
}

.md-search-result__teaser {
  color: var(--fg2) !important;
  font-family: var(--font-mono) !important;
}

/* ToC (right sidebar) */
.md-sidebar--secondary {
  background-color: var(--bg) !important;
}

.md-nav__title {
  color: var(--fg2) !important;
  font-family: var(--font-mono) !important;
}

.md-nav__link {
  color: var(--fg2) !important;
  font-family: var(--font-mono) !important;
  font-size: 0.82rem !important;
}

.md-nav__link:hover,
.md-nav__link--active {
  color: var(--accent) !important;
}

/* Code blocks */
.md-typeset code {
  background-color: var(--bg1) !important;
  color: var(--orange) !important;
  border-radius: 2px;
  font-family: var(--font-mono) !important;
  /* Prevent iOS font-size inflation inside code */
  font-size: 0.9em !important;
}

.md-typeset pre>code {
  background-color: var(--bg1) !important;
  color: var(--fg) !important;
  font-size: 0.88rem !important;
}

.highlight {
  background-color: var(--bg1) !important;
  border: 1px solid var(--border) !important;
  /* Horizontal scroll for long code lines on mobile */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Admonitions */
.md-typeset .admonition,
.md-typeset details {
  border-left-color: var(--accent) !important;
  background-color: var(--bg1) !important;
  font-family: var(--font-mono) !important;
  color: var(--fg) !important;
}

.md-typeset .admonition-title,
.md-typeset summary {
  font-family: var(--font-mono) !important;
  color: var(--fg) !important;
  background-color: var(--bg2) !important;
}

/* Tables */
.md-typeset table:not([class]) {
  border: 2px solid var(--border) !important;
  font-family: var(--font-mono) !important;
  color: var(--fg) !important;
  /* Horizontal scroll on small screens */
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.md-typeset table:not([class]) th {
  background-color: var(--bg1) !important;
  color: var(--fg) !important;
  border-bottom: 2px solid var(--border) !important;
}

.md-typeset table:not([class]) td {
  color: var(--fg) !important;
}

.md-typeset table:not([class]) tr:hover {
  background-color: var(--bg1) !important;
}

/* Back-to-top */
.md-top {
  background-color: var(--bg1) !important;
  color: var(--fg) !important;
  border: 2px solid var(--border) !important;
  border-radius: 4px !important;
  font-family: var(--font-mono) !important;
}

.md-top:hover {
  background-color: var(--fg) !important;
  color: var(--bg) !important;
}

/* Progress bar */
.md-progress {
  background-color: var(--accent) !important;
}

/* ── 20. KATEX / LATEX ───────────────────────────────────────── */
/* Make KaTeX match the Gruvbox palette */
.katex {
  font-size: 1.05em;
  color: var(--fg);
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5rem 0;
}

/* Dark-mode: KaTeX uses inline styles for some colours — override the
   most common black text so it's readable on dark background */
[data-md-color-scheme="slate"] .katex .mord,
[data-md-color-scheme="slate"] .katex .mop,
[data-md-color-scheme="slate"] .katex .mrel,
[data-md-color-scheme="slate"] .katex .mbin,
[data-md-color-scheme="slate"] .katex .mopen,
[data-md-color-scheme="slate"] .katex .mclose,
[data-md-color-scheme="slate"] .katex .mpunct {
  color: var(--fg);
}

/* ── 21. RESPONSIVE ──────────────────────────────────────────── */

/* ── Large desktop / wide monitors (≥ 1400px) ── */
@media (min-width: 1400px) {
  html {
    font-size: 17px;
  }

  .md-main__inner {
    padding: 0 3rem;
  }
}

/* ── Tablet landscape / small laptop (≤ 1100px) ── */
@media (max-width: 1100px) {
  .site-header {
    flex-wrap: wrap;
    padding: 1rem;
  }

  .main-nav {
    flex-wrap: wrap;
    order: 3;
    width: 100%;
    justify-content: flex-start;
    padding-right: 0;
  }

  .controls {
    margin-left: auto;
  }
}

/* ── Tablet portrait / large phone landscape (≤ 768px) ── */
@media (max-width: 768px) {
  .site-header {
    gap: 0.75rem;
    margin-bottom: 1.5rem;
  }

  .brand {
    font-size: 1rem;
  }

  .main-nav {
    gap: 0.4rem;
    justify-content: center;
  }

  .nav-box {
    font-size: 0.8rem;
    padding: 0.3rem 0.5rem;
  }

  .dropdown-menu {
    min-width: 180px;
  }

  .profile-pic {
    float: none;
    display: block;
    margin: 0 auto 1.2rem;
    width: clamp(100px, 30vw, 130px);
  }

  .intro-title {
    font-size: clamp(1rem, 3.5vw, 1.25rem);
    justify-content: center;
  }

  .md-typeset p {
    text-align: left;
  }

  /* justified text is hard to read on narrow screens */
  .book-blurb,
  .random-feed-text {
    text-align: left;
  }

  .site-footer {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.2rem;
  }

  .footer-left,
  .footer-center,
  .footer-right {
    justify-content: center;
    width: 100%;
  }
}

/* ── Phone portrait (≤ 480px) — also covers most Android/iOS phones ── */
@media (max-width: 480px) {
  html {
    font-size: 15px;
  }

  .brand {
    font-size: 0.95rem;
    white-space: normal;
    line-height: 1.2;
  }

  /* Stack nav vertically */
  .main-nav {
    flex-direction: column;
    width: 100%;
    gap: 0;
  }

  .nav-dropdown {
    width: 100%;
  }

  .nav-box {
    width: 100%;
    justify-content: space-between;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0;
  }

  /* Mobile accordion dropdowns */
  .dropdown-menu {
    position: static !important;
    opacity: 1 !important;
    visibility: hidden;
    transform: none !important;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, visibility 0s linear 0.3s;
    border: none !important;
    border-left: 3px solid var(--border) !important;
    border-radius: 0 !important;
    min-width: unset !important;
    pointer-events: none;
    box-shadow: none !important;
  }

  .nav-dropdown.open>.dropdown-menu {
    visibility: visible;
    max-height: 700px;
    pointer-events: auto;
    transition: max-height 0.3s ease, visibility 0s;
  }

  .dropdown-menu a {
    padding: 0.5rem 1.2rem;
    font-size: 0.88rem;
  }

  .controls {
    margin-left: 0;
    justify-content: flex-end;
    width: 100%;
    order: 2;
  }

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

  .daemon-icon {
    width: 1.5rem;
    height: 1.5rem;
  }

  /* Footer: stack tightly */
  .site-footer {
    gap: 0.8rem;
    padding: 1rem;
  }
}

/* ── Very small phones (≤ 360px, e.g. budget Androids) ── */
@media (max-width: 360px) {
  html {
    font-size: 14px;
  }

  .nav-box {
    font-size: 0.85rem;
    padding: 0.45rem 0.6rem;
  }

  .brand {
    font-size: 0.88rem;
  }

  .intro-title {
    font-size: 0.95rem;
  }
}

/* ── Reduced motion (accessibility) ─────────────────────────── */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ── High-contrast mode (Windows / forced-colors) ───────────── */
@media (forced-colors: active) {

  .nav-box,
  .ctrl-btn,
  .book-card,
  .dropdown-menu {
    border-color: ButtonText !important;
  }

  .toggle-circle {
    background-color: ButtonFace !important;
  }
}

/* ── Print ───────────────────────────────────────────────────── */
@media print {

  .site-header,
  .site-footer,
  .controls,
  .random-feed-header,
  .random-feed-card {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
  }

  .md-typeset a {
    color: black !important;
    text-decoration: underline !important;
  }
}

/* =========================================================
   Cat Paws — ambient walking animation
   ========================================================= */

.cat-paw-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  /* behind text, above background */
  overflow: hidden;
  isolation: isolate;
}

/* Single paw print */
.cat-paw {
  position: absolute;
  width: clamp(18px, 2.2vw, 28px);
  height: clamp(18px, 2.2vw, 28px);
  color: var(--cat-paw-color);
  opacity: 0;
  /* fade in quickly then fade out */
  animation: catPawFade 2.5s ease-out forwards;
  will-change: opacity, transform;
}

.cat-paw svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  /* Slight softness so it doesn't look harsh */
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

/* Inverted theme colors:
   Light mode → dark paw (so visible on light bg)
   Dark mode  → light paw (so visible on dark bg)   */
[data-md-color-scheme="default"] {
  --cat-paw-color: rgba(60, 60, 60, 0.30);
}

[data-md-color-scheme="slate"] {
  --cat-paw-color: rgba(235, 235, 235, 0.30);
}

/* Mobile: smaller & more subtle */
@media (max-width: 768px) {
  .cat-paw {
    width: clamp(14px, 3.5vw, 22px);
    height: clamp(14px, 3.5vw, 22px);
  }

  [data-md-color-scheme="default"] {
    --cat-paw-color: rgba(60, 60, 60, 0.20);
  }

  [data-md-color-scheme="slate"] {
    --cat-paw-color: rgba(235, 235, 235, 0.20);
  }
}

/* Fade out keyframes */
@keyframes catPawFade {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }

  15% {
    opacity: var(--cat-paw-opacity, 0.35);
    transform: translate(-50%, -50%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .cat-paw-container {
    display: none;
  }
}
