/*
 * Design System — agreddy.com
 * Tokens: typography, spacing, radii, z-index, semantic colors (light/dark).
 * Theme resolution: data-resolved-theme (set by theme.js) + class fallbacks.
 */

@layer tokens {
  :root {
    color-scheme: light dark;

    /* Typographic families */
    --font-heading: 'Lora', 'Cambria', 'Georgia', serif;
    --font-body:
      'Aptos', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
      Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

    /* Spacing scale (4px base) */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 2.5rem;
    --space-3xl: 4rem;

    /* Border radii */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 999px;
    --radius-surface: var(--radius-md);
    --radius-control: var(--radius-sm);

    /* Z-index stack */
    --z-sticky: 100;
    --z-header: 1000;
    --z-skip: 1010;
    --z-modal: 9999;

    --transition: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  }

  /* Light theme (default) */
  :root,
  :root[data-resolved-theme='light'],
  :root.theme-light {
    --bg-base: #f7f8fa;
    --bg-surface: #ffffff;
    --bg-surface-hover: #eef1f5;
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;

    --text-primary: #0c1222;
    --text-secondary: #3d4a5c;
    --text-muted: #5c6b7f;

    --accent: #1a3478;
    --accent-hover: #254aa3;
    --accent-soft: #e8eef8;
    --accent-on-accent: #ffffff;

    --shadow-sm: 0 1px 3px rgba(12, 18, 34, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(12, 18, 34, 0.05), 0 2px 4px -1px rgba(12, 18, 34, 0.03);

    --header-bg: rgba(247, 248, 250, 0.85);

    --cat-research-bg: var(--accent-soft);
    --cat-research-color: var(--accent);
    --cat-web-bg: #e8eef8;
    --cat-web-color: #1a3478;
    --cat-tools-bg: #d9f3ef;
    --cat-tools-color: #065f46;
    --cat-professional-bg: #d9f3f0;
    --cat-professional-color: #0f5c55;
    --cat-education-bg: #fde8d8;
    --cat-education-color: #9a3412;
    --cat-leadership-bg: #ede9fe;
    --cat-leadership-color: #5b21b6;
    --cat-awards-bg: #fce7ef;
    --cat-awards-color: #9f1239;
    --cat-presentations-bg: #dbeafe;
    --cat-presentations-color: #1e40af;

    --modal-bg: rgba(255, 255, 255, 0.85);
    --modal-border: rgba(255, 255, 255, 0.4);
    --modal-header-bg: rgba(255, 255, 255, 0.35);
    --modal-close-bg: rgba(12, 18, 34, 0.05);
    --modal-shadow: 0 20px 50px rgba(12, 18, 34, 0.15);
  }

  /* Dark theme — explicit override or JS-resolved */
  :root[data-resolved-theme='dark'],
  :root.theme-dark {
    --bg-base: #12141a;
    --bg-surface: #1a1d26;
    --bg-surface-hover: #252a36;
    --border-color: #2e3440;
    --border-hover: #3d4454;

    --text-primary: #f2f4f8;
    --text-secondary: #c5ccd8;
    --text-muted: #9aa3b2;

    --accent: #6b9fff;
    --accent-hover: #8bb4ff;
    --accent-soft: #1e2a42;
    --accent-on-accent: #0c1222;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.4);

    --header-bg: rgba(18, 20, 26, 0.85);

    --cat-research-bg: var(--accent-soft);
    --cat-research-color: #c5d9ff;
    --cat-web-bg: #1e2a42;
    --cat-web-color: #8bb4ff;
    --cat-tools-bg: #1a2e28;
    --cat-tools-color: #6ee7b7;
    --cat-professional-bg: #1a2e2c;
    --cat-professional-color: #5eead4;
    --cat-education-bg: #2e2218;
    --cat-education-color: #fdba74;
    --cat-leadership-bg: #261e3a;
    --cat-leadership-color: #c4b5fd;
    --cat-awards-bg: #2e1a22;
    --cat-awards-color: #fda4af;
    --cat-presentations-bg: #1e2a4a;
    --cat-presentations-color: #93c5fd;

    --modal-bg: rgba(26, 29, 38, 0.85);
    --modal-border: rgba(255, 255, 255, 0.08);
    --modal-header-bg: rgba(26, 29, 38, 0.35);
    --modal-close-bg: rgba(255, 255, 255, 0.08);
    --modal-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  }

  /* Pre-JS fallback: device preference before theme.js sets data-resolved-theme */
  @media (prefers-color-scheme: dark) {
    :root:not(.theme-light):not(.theme-dark):not([data-resolved-theme]) {
      --bg-base: #12141a;
      --bg-surface: #1a1d26;
      --bg-surface-hover: #252a36;
      --border-color: #2e3440;
      --border-hover: #3d4454;

      --text-primary: #f2f4f8;
      --text-secondary: #c5ccd8;
      --text-muted: #9aa3b2;

      --accent: #6b9fff;
      --accent-hover: #8bb4ff;
      --accent-soft: #1e2a42;
      --accent-on-accent: #0c1222;

      --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
      --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.4);

      --header-bg: rgba(18, 20, 26, 0.85);

      --cat-research-bg: var(--accent-soft);
      --cat-research-color: #c5d9ff;
      --cat-web-bg: #1e2a42;
      --cat-web-color: #8bb4ff;
      --cat-tools-bg: #1a2e28;
      --cat-tools-color: #6ee7b7;
      --cat-professional-bg: #1a2e2c;
      --cat-professional-color: #5eead4;
      --cat-education-bg: #2e2218;
      --cat-education-color: #fdba74;
      --cat-leadership-bg: #261e3a;
      --cat-leadership-color: #c4b5fd;
      --cat-awards-bg: #2e1a22;
      --cat-awards-color: #fda4af;

      --modal-bg: rgba(26, 29, 38, 0.85);
      --modal-border: rgba(255, 255, 255, 0.08);
      --modal-header-bg: rgba(26, 29, 38, 0.35);
      --modal-close-bg: rgba(255, 255, 255, 0.08);
      --modal-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    }
  }
}

/* Base Styles — targeted resets instead of global * (global resets break web components & cascade layers) */
body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
ul,
ol,
dl,
figure,
blockquote,
pre,
table {
  margin: 0;
  padding: 0;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  scrollbar-gutter: stable;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100dvh;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  transition:
    background-color var(--transition),
    color var(--transition);
  -webkit-font-smoothing: antialiased;
}

/* Container */
.container {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--space-xl);
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--accent-on-accent);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  z-index: var(--z-skip);
  transition: top var(--transition);
  font-weight: 500;
  text-decoration: none;
  font-size: 0.875rem;
}

.skip-link:focus {
  top: 15px;
  outline: 2px solid var(--accent);
}

/* Remove the first generic .top-bar — the second definition (below) takes precedence */
/* Header Utilities & Theme Switcher Button */
.top-header .top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 0;
  margin-bottom: 0;
}

.theme-toggle-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.theme-toggle-btn svg {
  width: 20px;
  height: 20px;
}

/* Toggle displays depending on theme */
.sun-icon {
  display: block;
}
.moon-icon {
  display: none;
}

:root.theme-dark .sun-icon {
  display: none;
}
:root.theme-dark .moon-icon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) .sun-icon {
    display: none;
  }
  :root:not(.theme-light) .moon-icon {
    display: block;
  }
}

/* Header styling (scope to not affect the top navigation sticky header) */
header:not(.top-header) {
  padding: 3rem 0 2.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
}

.header-accent {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  display: inline-block;
}

h1 {
  font-family: var(--font-heading);
  font-size: 2.75rem;
  font-weight: 400;
  line-height: 1.2;
  color: var(--text-primary);
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

.subtitle {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 680px;
  margin: 0 auto 2rem;
  font-weight: 400;
  line-height: 1.5;
}

/* Meta Pills */
.meta-pills {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.pill {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.85rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pill svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

/* Filter Bar styles — for legacy filter containers (landing page, etc.) */
.filter-container {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 2rem auto 0;
  max-width: 680px;
}

/* ─── CUSTOM ACADEMIC SITE LAYOUTS (MIGRATION) ─── */
main.container {
  flex: 1;
  padding-top: 1.5rem;
  padding-bottom: 2rem;
}

/* Visually hidden utility — accessible to screen readers, hidden visually.
   :focus-within / :active let focusable children (skip links, etc.) become visible. */
.sr-only:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 2rem;
}

/* Minimalist Uniform Project Card */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-surface);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition:
    transform var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
  box-shadow: var(--shadow-sm);
}

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

.card-header {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card-icon-wrapper {
  width: 2.25rem;
  height: 2.25rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.card-icon-wrapper svg {
  width: 100%;
  height: 100%;
  stroke-width: 1.5;
}

.card h2 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.25;
}

.card-body {
  flex-grow: 1;
}

.card p {
  color: var(--text-secondary);
  font-size: 0.925rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

/* Tech Tags */
.tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1.5rem;
}

.tech-tag {
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.725rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-family: var(--font-body);
}

/* Call to Action Button */
.card-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--accent);
  transition: color var(--transition);
}

.card-action:hover {
  color: var(--accent-hover);
}

.card-action svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.5;
  transition: transform var(--transition);
}

.card-action:hover svg {
  transform: translateX(3px);
}

/* Add Project Guide Card (Minimal Dotted Border) */
.card-add {
  border: 2px dashed var(--border-color);
  background: transparent;
  cursor: pointer;
  box-shadow: none;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 300px;
}

.card-add:hover {
  border-color: var(--border-hover);
  background: var(--bg-surface);
}

.card-add-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.card-add h2 {
  font-size: 1.25rem;
  color: var(--text-primary);
}

.card-add p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

/* Card Filtering Transition */
.card.filtered-out {
  display: none;
}

.card.filtered-in {
  animation: simpleFadeIn 0.2s ease-out forwards;
}

@keyframes simpleFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ─── PROFESSIONAL TABBED MODAL STYLES ─── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100dvw;
  height: 100dvh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
  overscroll-behavior: contain;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-surface);
  width: 90%;
  max-width: 720px;
  max-height: 80dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 2.5rem;
  box-shadow: var(--shadow-md);
  transform: scale(0.98);
  transition: transform var(--transition);
  overflow: hidden;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

/* Tabbed modal close button (within .modal-overlay) */
.modal-overlay .modal-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.75rem;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition);
}

.modal-overlay .modal-close:hover {
  color: var(--text-primary);
}

.modal-header {
  margin-bottom: 1.5rem;
}

.modal-accent {
  font-size: 0.725rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 0.25rem;
  display: inline-block;
}

.modal-header h2 {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 400;
  color: var(--text-primary);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.tab-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 0;
  cursor: pointer;
  transition:
    color var(--transition),
    background-color var(--transition),
    border-color var(--transition);
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

.tab-pane h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.tab-pane h4 {
  font-size: 0.875rem;
  font-weight: 600;
  margin: 1.25rem 0 0.4rem;
  color: var(--text-primary);
}

.tab-pane p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.tab-pane code {
  font-family: var(--font-mono);
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.8rem;
  color: var(--accent);
}

.tab-pane pre {
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-surface);
  padding: 1rem;
  overflow-x: auto;
  margin: 0.75rem 0;
}

.tab-pane pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.8rem;
  color: var(--text-primary);
}

/* Premium Responsive Footer Grid */
.site-footer {
  border-top: 1px solid var(--border-color);
  padding: 3rem 0 2rem 0;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-body);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr;
  gap: 2rem;
  text-align: left;
  margin-bottom: 2rem;
}

/* Footer heading — styled via class, no inline styles needed */
.footer-col-heading {
  font-family: var(--font-heading);
  color: var(--text-primary);
  font-size: 1rem;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.25rem;
  display: inline-block;
  margin-bottom: 1rem;
}

.footer-col p {
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 0;
}

.footer-col ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-col ul li {
  margin-bottom: 0.5rem;
}

.footer-col ul li a {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-col ul li a:hover {
  color: var(--accent);
}

.footer-col ul li a i {
  margin-right: 0.4rem;
  width: 14px;
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  padding-top: var(--space-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer-bottom p {
  margin: 0;
}

@media (max-width: 992px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 576px) {
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  .footer-bottom {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
}

/* Global Outline resets for accessibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  header {
    padding: 2rem 0;
  }
  h1 {
    font-size: 2.2rem;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .modal-content {
    padding: 1.5rem;
  }
  .modal-tabs {
    gap: 1rem;
  }
}

/* ─── CUSTOM ACADEMIC SITE LAYOUTS (MIGRATION) ─── */
/* NOTE: .top-bar & .nav-links are defined above in the Header Utilities section.
   This block provides academic-layout specific overrides. */
.nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem 2.25rem;
}
.nav-link {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition);
  font-family: var(--font-body);
  padding: 0.25rem 0;
}
.nav-link:hover {
  color: var(--text-primary);
}
.nav-link.active {
  color: var(--accent);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.25rem;
}

.academic-layout {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  margin-top: 0.5rem;
  margin-bottom: 5rem;
}
@media (min-width: 48em) {
  .academic-layout {
    flex-direction: row;
    align-items: flex-start;
  }
}

.academic-sidebar {
  width: 100%;
  flex-shrink: 0;
}
@media (min-width: 48em) {
  .academic-sidebar {
    width: 240px;
    position: sticky;
    top: 5rem; /* Adjusted sticky offset to not be covered by sticky navigation header */
    max-height: calc(100vh - 6.5rem);
    overflow-y: auto;
    padding-right: 0.5rem;
    scrollbar-width: thin;
  }
  .academic-sidebar::-webkit-scrollbar {
    width: 4px;
  }
  .academic-sidebar::-webkit-scrollbar-track {
    background: transparent;
  }
  .academic-sidebar::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 4px;
  }
}

.academic-content {
  flex-grow: 1;
  min-width: 0;
}

/* Sidebar Avatar & Bio Details */
.author-avatar-wrapper {
  margin-bottom: 1.5rem;
  text-align: center;
}
@media (min-width: 48em) {
  .author-avatar-wrapper {
    text-align: left;
  }
}
.author-avatar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 3px solid var(--border-color);
  object-fit: cover;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition);
}
.author-name {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 500;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}
.author-bio {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
  font-family: var(--font-body);
}
.author-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.author-links li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-family: var(--font-body);
}
.author-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition);
}
.author-links a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}
.author-links svg,
.author-links i {
  width: 16px;
  text-align: center;
  color: var(--text-muted);
}

/* Markdown typography matching Lora / Aptos */
.academic-content h1,
.academic-content h2,
.academic-content h3 {
  font-family: var(--font-heading);
  font-weight: 400;
  color: var(--text-primary);
  margin-top: var(--space-xl);
  margin-bottom: 0.75rem;
  text-wrap: balance;
  scroll-margin-top: 5rem;
}
.academic-content h1 {
  font-size: 2.2rem;
}
.academic-content h2 {
  font-size: 1.8rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}
.academic-content h3 {
  font-size: 1.4rem;
}

.academic-content p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.65;
  margin-bottom: 1.25rem;
  font-family: var(--font-body);
  text-wrap: pretty;
}
.academic-content a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--transition);
}
.academic-content a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}
.academic-content ul,
.academic-content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.academic-content li {
  margin-bottom: 0.5rem;
}
.academic-content img {
  max-width: 100%;
  border-radius: var(--radius-surface);
  border: 1px solid var(--border-color);
  margin: 1.5rem 0;
  box-shadow: var(--shadow-sm);
}
.academic-content hr {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 2rem 0;
}

/* CV page embeds */
.cv-embed-container {
  margin-top: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-surface);
  background: var(--bg-surface);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}
.cv-embed-container embed {
  border-radius: 4px;
  border: 1px solid var(--border-color);
  height: 700px;
}

/* Detail page pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
  margin-top: 0.5rem;
}
.pagination--pager {
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  transition: color var(--transition);
}
.pagination--pager:hover {
  color: var(--accent-hover);
}

/* Custom Table styles for detail pages */
.academic-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
}
.academic-content th,
.academic-content td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}
.academic-content th {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  font-weight: 600;
}
.academic-content td {
  color: var(--text-secondary);
}

/* Dark Mode Cards and Filters Fix */
.projects-controls {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
  background: transparent;
}
@media (min-width: 48em) {
  .projects-controls {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}
.search-wrapper {
  position: relative;
  max-width: 320px;
  width: 100%;
}
.search-input {
  width: 100%;
  padding: 0.45rem 1rem 0.45rem 2.2rem;
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-control);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
}
.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.filter-btn {
  padding: 0.35rem 0.9rem;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-control);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition:
    color var(--transition),
    background-color var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
  font-weight: 600;
  font-family: var(--font-body);
}
.filter-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}
.filter-btn.active {
  background-color: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.project-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}
.project-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-surface);
  padding: 1rem 1.25rem;
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.project-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}
.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
  font-size: 0.75rem;
}
.card-category {
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-control);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}
.cat-research {
  background-color: var(--cat-research-bg);
  color: var(--cat-research-color);
}
.cat-web {
  background-color: var(--cat-web-bg);
  color: var(--cat-web-color);
}
.cat-tools {
  background-color: var(--cat-tools-bg);
  color: var(--cat-tools-color);
}
.cat-professional {
  background-color: var(--cat-professional-bg);
  color: var(--cat-professional-color);
}
.cat-education {
  background-color: var(--cat-education-bg);
  color: var(--cat-education-color);
}
.cat-leadership {
  background-color: var(--cat-leadership-bg);
  color: var(--cat-leadership-color);
}
.cat-awards {
  background-color: var(--cat-awards-bg);
  color: var(--cat-awards-color);
}
.cat-presentations {
  background-color: var(--cat-presentations-bg);
  color: var(--cat-presentations-color);
}

.card-venue {
  font-style: italic;
  color: var(--text-muted);
}
.project-card .project-title,
.project-card .experience-title,
.project-title,
.experience-title {
  margin: 0 0 0.4rem 0;
  font-size: 1.15rem;
  font-family: var(--font-heading);
  font-weight: 500;
  line-height: 1.3;
  color: var(--text-primary);
}
.project-card .project-title a,
.project-card .experience-title a,
.project-title a,
.experience-title a {
  color: var(--text-primary);
  text-decoration: none;
}
.project-card .project-title a:hover,
.project-card .experience-title a:hover,
.project-title a:hover,
.experience-title a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.project-excerpt {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  flex-grow: 1;
  line-height: 1.5;
  font-family: var(--font-body);
}
.project-tech {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.tech-tag {
  font-size: 0.7rem;
  background-color: var(--bg-base);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 500;
  font-family: var(--font-body);
}
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.6rem;
  margin-top: auto;
}

.card-actions--stretch {
  gap: var(--space-sm);
}

.card-actions--stretch .card-btn {
  flex: 1;
  justify-content: center;
}
.card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-control);
  text-decoration: none !important;
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  line-height: 1.4;
  transition:
    background-color var(--transition),
    color var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
}
.btn-github {
  background-color: var(--text-primary);
  color: var(--bg-surface) !important;
}
.btn-github:hover {
  background-color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}
.btn-demo {
  background-color: var(--accent);
  color: var(--accent-on-accent) !important;
}
.btn-demo:hover {
  background-color: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}
.btn-pdf {
  background-color: #f43f5e;
  color: #fff !important;
}
.btn-pdf:hover {
  background-color: #e11d48;
  box-shadow: var(--shadow-sm);
}
.btn-detail {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color);
}
.btn-detail:hover {
  background-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

/* Spotlight cursor card highlight (interactive glow) */
.spotlight-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: radial-gradient(
    250px circle at var(--mouse-x, 0px) var(--mouse-y, 0px),
    var(--accent),
    transparent 80%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.spotlight-card:hover::before {
  opacity: 1;
}

/* Fix first-child spacing mismatch between sidebar and content */
.academic-content > *:first-child,
.academic-content > section > *:first-child,
.academic-content > div > *:first-child,
.academic-content > section > *:first-child > *:first-child {
  margin-top: 0 !important;
}

/* Premium Filter & Sorting Controls Styles */
.controls-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  width: 100%;
}
.select-wrapper {
  position: relative;
  display: inline-block;
}
.custom-select {
  padding: 0.4rem 2rem 0.4rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-control);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition:
    color var(--transition),
    background-color var(--transition),
    border-color var(--transition);
  font-family: var(--font-body);
}
.custom-select:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background-color: var(--bg-surface-hover);
  box-shadow: var(--shadow-sm);
}
.custom-select:focus {
  border-color: var(--accent);
}
.custom-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.select-icon {
  position: absolute;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.75rem;
  pointer-events: none;
}

/* Sticky Header with Glassmorphism */
.top-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition:
    background-color var(--transition),
    border-color var(--transition);
  padding: 0 !important;
  text-align: left !important;
}

/* Options contrast override inside dropdown filter lists */
.custom-select option {
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

/* Mobile Responsiveness Overrides for centered Container & Sticky Headers */
@media (max-width: 768px) {
  .nav-links {
    gap: 0.6rem 1.5rem;
  }
  .nav-link {
    font-size: 0.85rem;
  }
  .container {
    padding: 0 1rem;
  }
}
@media (max-width: 480px) {
  .nav-links {
    gap: 0.6rem 1.25rem;
  }
  .nav-link {
    font-size: 0.825rem;
  }
  .theme-toggle-btn {
    padding: 0.4rem;
  }
  .theme-toggle-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* Sleek Horizontal Document Rows */
.document-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 2rem;
}

.document-row {
  display: flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-surface);
  padding: 1.25rem 1.5rem;
  gap: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition:
    transform var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
}

.document-row:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.doc-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-surface);
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
  font-size: 1.5rem;
}

.doc-info {
  flex-grow: 1;
  min-width: 0;
}

.document-row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.document-row-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--text-primary);
  margin: 0 0 0.25rem 0 !important;
}

.document-row-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

.document-row-actions {
  display: flex;
  gap: 0.75rem;
  flex-shrink: 0;
}

.doc-row-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-control);
  cursor: pointer;
  transition:
    color var(--transition),
    background-color var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
  text-decoration: none !important;
  font-family: var(--font-body);
  white-space: nowrap;
  text-align: center;
}

.doc-row-btn.btn-primary {
  background: var(--accent);
  color: var(--accent-on-accent) !important;
  border: 1px solid var(--accent);
}

.doc-row-btn.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-on-accent) !important;
  box-shadow: var(--shadow-sm);
}

.doc-row-btn.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.doc-row-btn.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.site-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.65rem;
  padding: 0.55rem 1rem;
  color: var(--accent-on-accent) !important;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-decoration: none !important;
  transition:
    color var(--transition),
    background-color var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
}

.site-action-btn:hover {
  color: var(--accent-on-accent) !important;
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}

.site-action-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.section-kicker {
  margin: 0 0 var(--space-xs) 0;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-width: 768px) {
  /* Main Layout Spacing on Mobile */
  .academic-layout {
    gap: 1.5rem;
    margin-bottom: 3rem;
  }

  /* Redesigned Glassmorphic Sidebar Card on Mobile */
  .author-avatar-wrapper {
    display: grid;
    grid-template-areas:
      'avatar name'
      'bio bio'
      'links links';
    grid-template-columns: 70px 1fr;
    gap: 1rem;
    text-align: left;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-surface);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 0.5rem;
  }

  .author-avatar {
    grid-area: avatar;
    width: 70px;
    height: 70px;
    border-width: 2px;
    margin: 0;
  }

  .author-name {
    grid-area: name;
    font-size: 1.25rem;
    margin: 0;
    align-self: center;
  }

  .author-bio {
    grid-area: bio;
    font-size: 0.825rem;
    margin: 0.25rem 0 0.5rem 0;
    line-height: 1.4;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
  }

  .author-links {
    grid-area: links;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    margin-top: 0.25rem;
  }

  .author-links li {
    font-size: 0.8rem;
  }

  /* Redesigned Sleek Grid Document Rows on Mobile */
  .document-row {
    display: grid;
    grid-template-areas:
      'icon info'
      'actions actions';
    grid-template-columns: auto 1fr;
    gap: 1rem;
    padding: 1.25rem;
    align-items: start;
  }

  .doc-icon-wrapper {
    grid-area: icon;
    width: 42px;
    height: 42px;
    font-size: 1.25rem;
    align-self: start;
  }

  .doc-info {
    grid-area: info;
  }

  .document-row-title {
    font-size: 1.05rem;
    margin-bottom: 0.2rem !important;
  }

  .document-row-description {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    font-size: 0.8rem;
    line-height: 1.35;
  }

  .document-row-actions {
    grid-area: actions;
    width: 100%;
    display: flex;
    gap: 0.75rem;
    margin-top: 0.25rem;
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
  }

  .doc-row-btn {
    flex: 1;
    justify-content: center;
    padding: 0.55rem 0.75rem;
    font-size: 0.8rem;
  }
}

/* Glassmorphic Document Modal — native <dialog> with ::backdrop */
.document-modal {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  z-index: var(--z-modal);
  overscroll-behavior: contain;
}

/* Layout & sizing: only apply when dialog is open (showModal).
   Setting display:flex unconditionally would override the native
   browser `display:none` on `<dialog>` elements that are not open. */
dialog[open].document-modal {
  width: 100dvw;
  height: 100dvh;
  max-width: 100dvw;
  max-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.document-modal::backdrop {
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.modal-window {
  position: relative;
  width: 95dvw;
  height: 95dvh;
  max-width: 95dvw;
  max-height: 95dvh;
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: var(--radius-surface);
  box-shadow: var(--modal-shadow);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  display: flex;
  flex-direction: column;
  contain: layout style paint;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.document-modal[open] .modal-window {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  min-height: 4.5rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--modal-header-bg);
}

.modal-header h2 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--text-primary);
  margin: 0;
}

.modal-header .section-kicker {
  margin-bottom: 0.15rem;
  font-size: 0.68rem;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.modal-open-link {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.35rem 0.75rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-control);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
}

.modal-open-link:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
}

/* Document modal close button */
.document-modal .modal-close {
  background: var(--modal-close-bg);
  border: 1px solid transparent;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-control);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition:
    color var(--transition),
    background-color var(--transition),
    border-color var(--transition);
  font-size: 1rem;
  padding: 0;
}

.document-modal .modal-close:hover {
  background: var(--accent);
  color: var(--accent-on-accent);
}

.modal-body {
  flex: 1;
  padding: 0; /* Maximize document view space */
  background: transparent;
  position: relative;
}

.modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #ffffff;
}

@media (max-width: 768px) {
  dialog[open].document-modal {
    align-items: stretch;
  }

  .modal-window {
    width: 100dvw;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
  }

  .modal-header {
    align-items: flex-start;
    flex-direction: column;
    min-height: auto;
  }

  .modal-actions {
    width: 100%;
    justify-content: space-between;
  }
}

/* ==========================================================================
   Premium 3-State Theme Slider System
   ========================================================================== */
/* Reserving exact layout dimensions for theme slider to prevent CLS layout shift */
.theme-toggle-btn {
  width: 96px;
  height: 34px;
  border-radius: 20px;
  background: transparent;
  border: 1px solid transparent;
  opacity: 0;
  pointer-events: none;
  box-sizing: border-box;
}

.theme-slider {
  display: inline-flex;
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 3px;
  position: relative;
  user-select: none;
  transition:
    color var(--transition),
    background-color var(--transition),
    border-color var(--transition);
}

.theme-slider-track {
  display: flex;
  position: relative;
  align-items: center;
}

.theme-slider-thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  background: var(--bg-surface);
  border-radius: 50%;
  box-shadow:
    var(--shadow-sm),
    0 0 0 1px rgba(0, 0, 0, 0.05);
  transition:
    transform var(--transition),
    background-color var(--transition);
  z-index: 1;
}

/* Precise positioning translations for 28px thumb on 28px buttons with 2px margins */
:root[data-active-theme='light'] .theme-slider-thumb {
  transform: translateX(0px);
}
:root[data-active-theme='device'] .theme-slider-thumb {
  transform: translateX(32px);
}
:root[data-active-theme='dark'] .theme-slider-thumb {
  transform: translateX(64px);
}

.theme-slider-btn {
  position: relative;
  background: transparent;
  border: none;
  width: 28px;
  height: 28px;
  padding: 0;
  margin: 0 2px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color var(--transition);
  z-index: 2;
}

.theme-slider-btn:first-of-type {
  margin-left: 0;
}
.theme-slider-btn:last-of-type {
  margin-right: 0;
}

.theme-slider-btn:hover {
  color: var(--text-primary);
}

.theme-slider-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  transition: transform var(--transition);
}

.theme-slider-btn:hover svg {
  transform: scale(1.1);
}

/* Active theme icon coloring */
:root[data-active-theme='light'] .theme-slider-btn[data-theme='light'],
:root[data-active-theme='device'] .theme-slider-btn[data-theme='device'],
:root[data-active-theme='dark'] .theme-slider-btn[data-theme='dark'] {
  color: var(--accent);
}

/* ==========================================================================
   Premium Page Transition System
   ========================================================================== */
body {
  opacity: 0;
  transition: opacity 0.22s ease-in-out;
}

body.page-loaded {
  opacity: 1;
}

/* ==========================================================================
   Mobile Responsive Refinements
   ========================================================================== */

/* Responsive Sidebar Visibility */
@media (max-width: 47.99em) {
  /* Hide only the academic bio avatar wrapper on all pages except the homepage on mobile, keeping TOC visible */
  body:not(.home-page) .academic-sidebar .author-avatar-wrapper {
    display: none !important;
  }

  /* Both filter controls and TOC are wrapped in .mobile-sticky-wrapper on mobile */
  body:not(.home-page) .mobile-sticky-wrapper,
  body:not(.home-page) #tocContainer {
    position: sticky;
    top: 4.25rem;
    z-index: var(--z-sticky);
  }

  /* All TOC containers get these mobile spacing overrides */
  body:not(.home-page) .toc-container {
    margin-top: 1rem !important;
    margin-bottom: 1.5rem !important;
    width: auto !important;
  }
  body:not(.home-page) #tocNav {
    max-height: 50vh;
    overflow-y: auto;
    scrollbar-width: thin;
    margin-top: 0.75rem;
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
  }
  body:not(.home-page) .toc-list {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem 1.5rem !important;
    padding-right: 0.5rem; /* space for scrollbar if ToC overflows */
  }
  body:not(.home-page) .toc-nested-list {
    margin-bottom: 0 !important;
  }
  /* On mobile, before JS initializes, keep the TOC collapsed to avoid layout shift/flashing */
  .toc-toggle-btn:not([data-initialized='true']) + #tocNav,
  .toc-toggle-btn:not([data-initialized='true']) + #filterNav {
    display: none !important;
  }
  .toc-toggle-btn:not([data-initialized='true']) .toc-toggle-icon {
    transform: rotate(-90deg);
  }
}

/* Mobile Header & Theme Slider Adjustments */
@media (max-width: 47.99em) {
  /* Hide the theme toggle slider in the sticky header on mobile screens */
  .top-header #theme-toggle,
  .top-header .theme-slider {
    display: none !important;
  }

  /* Center-align navigation link row in mobile header */
  .top-bar {
    justify-content: center !important;
    padding: 1rem 0;
  }

  /* Center the footer layout elements on mobile screens */
  .footer-bottom {
    flex-direction: column !important;
    gap: 1.25rem;
    text-align: center;
  }
}

/* Desktop Footer Theme Toggle Adjustments */
@media (min-width: 48em) {
  /* Hide the theme toggle slider in the footer on desktop screens */
  .site-footer #theme-toggle-footer,
  .site-footer .theme-slider[id='theme-toggle-footer'] {
    display: none !important;
  }
}

/* ─── Reduced Motion: Respect user preference ─── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  body {
    transition: none !important;
  }
}

/* ─── Premium Vertical Timeline for Experience Page ─── */
.experience-timeline,
.project-timeline {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-left: 2rem;
}

.experience-timeline::before,
.project-timeline::before {
  content: '';
  position: absolute;
  left: 0.8rem;
  top: 1rem;
  bottom: 1rem;
  width: 2px;
  background-color: var(--border-color);
  transition: background-color var(--transition);
}

.timeline-card {
  position: relative;
  overflow: visible !important;
  content-visibility: auto;
  contain-intrinsic-size: auto 120px;
}

.timeline-card::after {
  content: '';
  position: absolute;
  left: -1.6rem;
  top: 1.5rem;
  width: 0.8rem;
  height: 0.8rem;
  border-radius: 50%;
  background-color: var(--bg-surface);
  border: 2px solid var(--border-color);
  transition:
    border-color var(--transition),
    background-color var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
  z-index: 2;
}

.timeline-card:hover::after {
  border-color: var(--accent);
  background-color: var(--accent);
  transform: scale(1.25);
  box-shadow: 0 0 8px var(--accent);
}

/* Timeline Year Header on the left connector line */
.timeline-year {
  position: relative;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
  z-index: 2;
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.timeline-year::before {
  content: '';
  position: absolute;
  left: -1.55rem; /* Center = left + width/2 = -1.55 + 0.35 = -1.2rem */
  top: 50%;
  transform: translateY(-50%);
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background-color: var(--accent);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 0 2px var(--accent);
  z-index: 3;
}

.timeline-year::after {
  content: '';
  flex-grow: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border-color), transparent);
}

/* Dynamic Table of Contents Sidebar Widget */
.toc-container {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-surface);
  padding: 0.6rem 1rem;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

/* Stacked TOC containers (filters + TOC) in sidebar */
.toc-container + .toc-container {
  margin-top: 0.75rem;
}

/* Sidebar context: narrow filter controls to fit 240px column */
.academic-sidebar .projects-controls {
  gap: 0.5rem !important;
}

.academic-sidebar .filter-pills {
  gap: 0.35rem;
}

.academic-sidebar .filter-btn {
  font-size: 0.78rem;
  padding: 0.25rem 0.65rem;
}

.academic-sidebar .search-wrapper {
  max-width: 100%;
}

.academic-sidebar .select-wrapper {
  width: 100%;
}

.academic-sidebar .custom-select {
  width: 100%;
  font-size: 0.8rem;
  padding: 0.35rem 1.8rem 0.35rem 0.6rem;
}
.toc-container .toc-title {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  margin: 0 !important;
  line-height: 1.2 !important;
}
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toc-item {
  font-size: 0.8rem;
  font-family: var(--font-body);
}
.toc-link {
  color: var(--text-secondary);
  text-decoration: none;
  transition:
    color var(--transition),
    padding-left var(--transition);
  display: inline-block;
  line-height: 1.4;
}
.toc-link:hover {
  color: var(--accent);
  padding-left: 4px;
}
.toc-year-header {
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--accent);
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  font-family: var(--font-heading);
  text-decoration: none;
  display: inline-block;
}
.toc-year-header:hover {
  color: var(--accent-hover);
}
.toc-nested-list {
  list-style: none;
  padding-left: 0.75rem;
  margin: 0.25rem 0 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-left: 1px solid var(--border-color);
}

/* Collapsible Table of Contents Trigger */
.toc-toggle-btn {
  background: none;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font-family: inherit;
  transition: margin-bottom var(--transition);
}
.toc-toggle-btn[aria-expanded='true'] {
  margin-bottom: 0.6rem;
}
.toc-toggle-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}
.toc-toggle-btn:hover .toc-title,
.toc-toggle-btn:hover .toc-toggle-icon {
  color: var(--accent);
}
.toc-toggle-icon {
  font-size: 0.8rem;
  color: var(--text-muted);
  transition:
    transform var(--transition),
    color var(--transition);
  line-height: 1;
  display: inline-flex;
  align-items: center;
}
.toc-toggle-btn[aria-expanded='false'] .toc-toggle-icon {
  transform: rotate(-90deg);
}
.toc-toggle-btn[aria-expanded='false'] + #tocNav,
.toc-toggle-btn[aria-expanded='false'] + #filterNav {
  display: none !important;
}

/* ─── Catalog page utilities ─── */
.page-intro-title {
  font-family: var(--font-heading);
  margin-bottom: var(--space-sm);
}

.page-intro-lead {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-2xl);
}

.timeline-section {
  margin-top: var(--space-lg);
}

.availability-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.availability-calendar-frame {
  display: block;
  width: 100%;
  height: min(800px, 78dvh);
  min-height: 560px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-surface);
  box-shadow: var(--shadow-sm);
}

@media (max-width: 768px) {
  .availability-actions .site-action-btn {
    flex: 1 1 100%;
    justify-content: center;
  }

  .availability-calendar-frame {
    height: 680px;
    min-height: 520px;
  }
}

.projects-controls--stacked {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-md);
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-md);
  align-items: center;
  width: 100%;
}

.controls-row--bordered {
  border-top: 1px solid var(--border-color);
  padding-top: var(--space-md);
}

.card-org-context {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: var(--space-sm);
  font-family: var(--font-body);
  font-weight: 500;
  line-height: 1.4;
}

.academic-content [id],
.timeline-card[id] {
  scroll-margin-top: 5rem;
}

button,
.nav-link,
.filter-btn,
.card-action,
.doc-row-btn,
.theme-slider-btn,
.toc-toggle-btn,
.toc-link {
  touch-action: manipulation;
}
