/* ============================
   Theme variables
   ============================ */

/* Base (light) theme variables */
:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --text: #111111;
  --muted-text: #4b5563;

  --surface: #f6f7f9;
  --border: #e5e7eb;

  /* Light mode links */
  --link: #0b57d0;
  --link-hover: #063a8c;

  --header-bg: #ffffff;
  --header-text: #111111;

  --btn-bg: #f3f4f6;
  --btn-text: #111111;
  --btn-border: #d1d5db;

  --shadow: rgba(0, 0, 0, 0.08);
}

/* Dark theme overrides (UGA-focused) */
html[data-theme="dark"] {
  /* Backgrounds */
  --bg: #121212;
  --surface: #1a1a1a;
  --border: #2a2a2a;

  /* Text */
  --text: #f5f5f5;
  --muted-text: #b3b3b3;

  /* Links: UGA red */
  --link: #ba0c2f;
  --link-hover: #e63946;

  /* Header */
  --header-bg: #121212;
  --header-text: #f5f5f5;

  /* Buttons */
  --btn-bg: #1a1a1a;
  --btn-text: #f5f5f5;
  --btn-border: #333333;

  /* Shadows */
  --shadow: rgba(0, 0, 0, 0.5);
}

/* ============================
   Apply variables globally
   ============================ */

body {
  background: var(--bg);
  color: var(--text);
}

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

a { color: var(--link); }
a:hover { color: var(--link-hover); }

pre, code, .highlight {
  background: var(--surface);
  border: 1px solid var(--border);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
}

.page-content, .post-content {
  color: var(--text);
}

/* ============================
   Theme toggle button
   ============================ */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 42px;
  height: 36px;

  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--btn-border);
  box-shadow: 0 1px 10px var(--shadow);

  cursor: pointer;
  user-select: none;

  -webkit-tap-highlight-color: transparent;
}

.theme-toggle__icon {
  display: inline-flex;
  align-items: center;
}

.icon-sun { display: none; }
.icon-moon { display: inline-block; }

html[data-theme="dark"] .icon-sun { display: inline-block; }
html[data-theme="dark"] .icon-moon { display: none; }

.theme-toggle--floating {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
}

/* ============================
   Header/nav text in dark mode
   Keep header readable, but do not globally rewrite all .page-link everywhere.
   ============================ */

html[data-theme="dark"] .site-header,
html[data-theme="dark"] .site-header a,
html[data-theme="dark"] .site-title {
  color: var(--header-text);
}

html[data-theme="dark"] .site-header .page-link {
  color: var(--header-text);
}

html[data-theme="dark"] .site-header .page-link:hover,
html[data-theme="dark"] .site-title:hover {
  color: var(--link-hover);
}

/* Optional: subtle UGA accent line in header (dark mode) */
html[data-theme="dark"] .site-header {
  border-bottom: 1px solid rgba(186, 12, 47, 0.25);
}

/* ============================
   Minima mobile nav overlay + MathJax stacking
   - Fix overlay stacking so MathJax cannot appear above menu
   - Fix light-mode transparency by styling trigger panel in all themes
   ============================ */

.site-header,
.site-nav {
  position: relative;
  z-index: 10000;
}

/* Hamburger button styling (all themes) + iOS cleanup */
.site-nav .menu-icon {
  color: var(--header-text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;

  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
}

.site-nav .menu-icon:focus,
.site-nav .menu-icon:focus-visible,
.site-nav .menu-icon:active {
  outline: none;
  box-shadow: none;
}

/* Ensure hamburger SVG inherits currentColor */
.site-nav .menu-icon svg,
.site-nav .menu-icon svg * {
  fill: currentColor !important;
  stroke: currentColor !important;
}

/* Mobile dropdown behavior */
@media screen and (max-width: 600px) {
  .site-nav {
    position: relative;
    z-index: 10001;
  }

  .site-nav .trigger {
    position: absolute;
    right: 0;
    top: 44px;
    z-index: 10002;

    /* Panel styling for BOTH themes (fixes light-mode transparency) */
    background: var(--header-bg);
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px var(--shadow);
    border-radius: 12px;
    padding: 10px 12px;
    min-width: 80px;
  }

  .site-nav .trigger a.page-link {
    display: block;
    padding: 10px 8px;
    text-decoration: none;
  }
}

/* Extra hardening: keep MathJax from creating higher stacking contexts */
mjx-container {
  position: relative;
  z-index: 0;
}

/* ============================
   UGA dark-mode link readability (global)
   ============================ */

html[data-theme="dark"] a {
  text-decoration: underline;
  text-decoration-color: rgba(186, 12, 47, 0.5);
  text-underline-offset: 0.18em;
}

html[data-theme="dark"] a:hover {
  text-decoration-color: rgba(230, 57, 70, 0.85);
}

/* ============================
   Force UGA red for CONTENT links only (not header/nav)
   ============================ */

html[data-theme="dark"] main a,
html[data-theme="dark"] .page-content a,
html[data-theme="dark"] .post-content a {
  color: var(--link) !important;
}

html[data-theme="dark"] main a:hover,
html[data-theme="dark"] .page-content a:hover,
html[data-theme="dark"] .post-content a:hover {
  color: var(--link-hover) !important;
}

/* ============================
   Final hamburger cleanup (dark mode)
   ============================ */

html[data-theme="dark"] .site-nav .menu-icon {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
  outline: none !important;
  filter: none !important;
}

/* Minima uses a <label class="menu-icon"> — hit that explicitly */
html[data-theme="dark"] .site-nav label.menu-icon {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
  outline: none !important;
}

/* iOS highlight/glow suppression */
html[data-theme="dark"] .site-nav .menu-icon:focus,
html[data-theme="dark"] .site-nav .menu-icon:focus-visible,
html[data-theme="dark"] .site-nav .menu-icon:active {
  outline: none !important;
  box-shadow: none !important;
}
