/* ============================================================
   1. DESIGN TOKENS (CSS VARIABLES)
   ============================================================ */
:root {
  /* Brand & Accent Colors */
  --color-primary: #8b5cf6;       /* Main Purple Accent */
  --color-primary-hover: #7c3aed; /* Slightly darker purple for hover */
  --color-link: #0066cc;          /* Base Link Blue */
  --color-link-hover: #004c9e;    /* Hover Link Blue */

  /* Neutral Surface Colors */
  --bg-topbar: #222222;
  --bg-dark-card: #333333;
  --bg-dark-dropdown: #444444;
  --border-dark: #444444;
  --border-muted: #333333;
  --border-light: #e5e5e5;

  /* Typography Colors */
  --text-light: #ffffff;
  --text-muted: #e0e0e0;
  --text-caption: #888888;
}

/* ============================================================
   2. GLOBAL RESETS & BASE STYLES
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0 !important;
  padding: 0 !important;
  overflow-x: hidden; /* Prevents horizontal scroll leaks */
}

/* ============================================================
   3. TYPOGRAPHY & INLINE LINKS
   ============================================================ */
section a:not(.site-btn) {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-color: rgba(0, 102, 204, 0.3);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  border-bottom: none !important;  /* Strip Jekyll theme defaults */
  font-weight: inherit !important; /* Prevent layout shift on hover */
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

section a:not(.site-btn):hover,
section a:not(.site-btn):focus {
  color: var(--color-link-hover) !important;
  text-decoration-color: var(--color-link-hover) !important;
  text-decoration-thickness: 2px;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* ============================================================
   4. TOP BAR & NAVIGATION BANNER
   ============================================================ */
.topbar {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  background-color: var(--bg-topbar) !important;
  color: var(--text-light);
  z-index: 9999 !important;
  border-bottom: 3px solid var(--color-primary);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  padding: 12px 0;
}

.topbar-content {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 15px;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.page-banner-title,
.page-banner-title a {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary) !important;
  white-space: nowrap;
}

.menu-toggle {
  display: none; /* Mobile only toggle */
  background: none;
  border: 1px solid var(--border-dark);
  color: var(--text-light);
  font-size: 1.4rem;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

/* Navigation Layout Containers */
.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.pub-button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0 24px 0;
}

/* ============================================================
   5. BUTTON COMPONENTS
   ============================================================ */
/* Base Button Class */
.site-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  border-radius: 8px !important;
  padding: 6px 14px !important;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none !important;
  white-space: nowrap !important;
  border: 1px solid transparent;
  transition: all 0.2s ease-in-out;
}

.site-btn:hover {
  transform: translateY(-1px);
}

/* Top Navigation Pills */
.nav-btn {
  background-color: var(--bg-dark-card);
  color: var(--text-muted) !important;
  border-color: var(--border-dark);
}

.nav-btn:hover,
.nav-btn.active {
  background-color: var(--color-primary);
  color: var(--text-light) !important;
  border-color: var(--color-primary);
}

.nav-btn.active {
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

/* Publication Buttons (Details & GitHub) */
.pub-btn-details,
.pub-btn-github {
  background-color: var(--border-dark);
  color: var(--text-light) !important;
  border-color: var(--border-dark);
}

.pub-btn-details:hover,
.pub-btn-github:hover {
  background-color: var(--color-primary);
  border-color: var(--border-dark);
  text-decoration: none !important;
}

/* ============================================================
   6. MAIN LAYOUT (DESKTOP GRID)
   ============================================================ */
.wrapper {
  margin-top: 90px !important;
  display: grid !important;
  grid-template-columns: 210px 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "header section"
    "header section"
    "footer footer";
  gap: 20px 40px;
  max-width: 860px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 20px;
}

.wrapper > header {
  grid-area: header;
  float: none !important;
  width: auto !important;
  position: static !important;
}

.wrapper > section {
  grid-area: section;
  float: none !important;
  width: auto !important;
  min-width: 0;
}

.wrapper > footer {
  grid-area: footer;
  float: none !important;
  width: 100% !important;
  position: static !important;
  margin-top: 30px;
  padding-top: 15px;
  border-top: 1px solid var(--border-light);
  clear: both !important;
}

/* ============================================================
   7. SIDEBAR & CONTACT LINKS
   ============================================================ */
.sidebar-contact ul {
  list-style-type: circle !important;
  padding-left: 20px !important;
  margin: 10px 0;
}

.sidebar-contact li {
  margin-bottom: 8px;
}

.contact-links-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contact-icon-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none !important;
  color: var(--color-link);
  transition: opacity 0.2s ease, color 0.2s ease;
}

.contact-icon-link:hover {
  color: var(--color-primary);
}

.contact-icon {
  width: 24px;
  height: 24px;
  display: inline-block;
  fill: currentColor;
  flex-shrink: 0;
}

/* Reusable Figure Component */
.site-figure {
  margin: 24px 0;
  text-align: center;
}

.site-figure img {
  width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.site-figure figcaption {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text-caption);
  font-style: italic;
  text-align: center;
}

.site-figure.align-left {
  float: left;
  margin: 0 20px 15px 0;
}

.site-figure.align-right {
  float: right;
  margin: 0 0 15px 20px;
}

/* ============================================================
   8. MOBILE RESPONSIVE MEDIA QUERIES
   ============================================================ */

/* Small Screens / Mobile Navigation Dropdown */
@media (max-width: 600px) {
  .menu-toggle {
    display: block;
  }

  .top-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-dark-dropdown);
    flex-direction: column;
    padding: 15px 20px;
    gap: 10px;
    border-bottom: 3px solid var(--color-primary);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
  }

  .top-nav.open {
    display: flex;
  }

  .nav-btn {
    width: 100%;
    text-align: center;
  }
}

/* Subpage Layout & Bottom Header Shift */
@media (max-width: 768px) {
  .wrapper {
    display: flex !important;
    flex-direction: column !important;
  }

  .wrapper section {
    order: 1 !important;
  }

  /* Move subpage header below main content */
  .wrapper header:has(.subpage-sidebar) {
    order: 2 !important;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-muted);
  }

  .wrapper footer {
    order: 3 !important;
  }

  /* Subpage Sidebar Icon Bar Modifications */
  .subpage-sidebar .desktop-only-bio,
  .subpage-sidebar .desktop-only-heading {
    display: none !important;
  }

  .subpage-sidebar .contact-links-container {
    flex-direction: row !important;
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
    margin: 5px 0 15px 0;
  }

  .subpage-sidebar .link-label {
    display: none !important;
  }

  .subpage-sidebar .contact-icon {
    width: 24px;
    height: 24px;
  }
}