/* Core Styles & Design System */

:root {
  /* Fonts */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;
  
  /* Layout Dimensions */
  --sidebar-w: 320px;
  --header-h: 60px;
  --content-max-w: 960px;
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;
  
  /* Base Transitions */
  --transition-speed: 0.3s;
  --transition-ease: cubic-bezier(0.4, 0, 0.2, 1);
  --transition-all: all var(--transition-speed) var(--transition-ease);

  /* Default Theme: Dark Mode */
  --bg-app: #0b111e;
  --bg-sidebar: rgba(20, 29, 47, 0.85);
  --bg-card: rgba(20, 29, 47, 0.45);
  --bg-card-hover: rgba(30, 41, 59, 0.6);
  --bg-input: #1e293b;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-hover: rgba(56, 189, 248, 0.4);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #38bdf8; /* sky-400 */
  --accent-secondary: #6366f1; /* indigo-500 */
  --accent-gradient: linear-gradient(135deg, #38bdf8, #6366f1);
  --accent-hover: #0ea5e9;
  
  --highlight-link: #f59e0b; /* Amber-500 */
  --highlight-hover: #fbbf24; /* Amber-400 */
  --text-orange: #f97316; /* Premium orange for dark mode */
  --timeline-line: #334155;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.2), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --glass-blur: blur(16px);
}

[data-theme="light"] {
  /* Light Theme Overrides */
  --bg-app: #f1f5f9; /* Slate-100 */
  --bg-sidebar: rgba(255, 255, 255, 0.9);
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-card-hover: rgba(255, 255, 255, 0.9);
  --bg-input: #ffffff;
  --border-color: rgba(15, 23, 42, 0.06);
  --border-color-hover: rgba(2, 132, 199, 0.4);
  
  --text-primary: #0f172a; /* Slate-900 */
  --text-secondary: #475569; /* Slate-600 */
  --text-muted: #94a3b8; /* Slate-400 */
  
  --accent-primary: #0284c7; /* sky-600 */
  --accent-secondary: #4f46e5; /* indigo-600 */
  --accent-gradient: linear-gradient(135deg, #0284c7, #4f46e5);
  --accent-hover: #0369a1;
  
  --highlight-link: #d97706; /* Amber-600 */
  --highlight-hover: #b45309; /* Amber-700 */
  --text-orange: #ea580c; /* Premium orange for light mode */
  --timeline-line: #cbd5e1;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -1px rgba(15, 23, 42, 0.02);
  --shadow-lg: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
}

/* CSS Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-app);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  transition: background-color var(--transition-speed) var(--transition-ease);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

h1 {
  font-size: 2.25rem;
  font-family: var(--font-serif);
  font-weight: 500;
}

h2 {
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.5rem;
  position: relative;
}

h2::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: var(--accent-gradient);
}

h3 {
  font-size: 1.25rem;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--accent-primary);
}

p {
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
}

a {
  color: var(--highlight-link);
  text-decoration: none;
  transition: var(--transition-all);
}

a:hover {
  color: var(--highlight-hover);
  text-decoration: underline;
}

ul, ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
  color: var(--text-secondary);
}

li {
  margin-bottom: 0.5rem;
}

hr {
  border: 0;
  height: 1px;
  background-color: var(--border-color);
  margin: 2rem 0;
}

/* Accessibility Skip Link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-gradient);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  z-index: 1000;
  transition: top var(--transition-speed) ease;
  font-weight: 500;
  text-decoration: none;
}

.skip-link:focus {
  top: 10px;
  outline: none;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.4);
}

/* Mobile Header */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-h);
  background-color: var(--bg-sidebar);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: var(--glass-blur);
  z-index: 90;
  padding: 0 1rem;
  align-items: center;
  justify-content: space-between;
}

.mobile-title {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 500;
}

.hamburger-btn {
  background: none;
  border: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  padding: 6px;
}

.hamburger-bar {
  display: block;
  width: 20px;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 1px;
  transition: var(--transition-all);
}

.hamburger-btn[aria-expanded="true"] .hamburger-bar:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

.hamburger-btn[aria-expanded="true"] .hamburger-bar:nth-child(2) {
  opacity: 0;
}

.hamburger-btn[aria-expanded="true"] .hamburger-bar:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Sidebar Drawer styling */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  backdrop-filter: var(--glass-blur);
  z-index: 100;
  transition: transform var(--transition-speed) var(--transition-ease), background-color var(--transition-speed);
}

.sidebar-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 2.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 2px;
}

/* Profile Card */
.profile-card {
  text-align: center;
  margin-bottom: 2rem;
}

.profile-avatar {
  width: 96px;
  height: 96px;
  margin: 0 auto 1.25rem;
  position: relative;
  transition: transform var(--transition-speed) ease;
}

.profile-avatar:hover {
  transform: scale(1.05);
}

.avatar-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15));
}

.profile-name {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.profile-title {
  font-size: 0.875rem;
  color: var(--accent-primary);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.profile-institution {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 0.25rem;
}

.profile-location {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Navigation Links in Sidebar */
.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.nav-link:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .nav-link:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

.nav-link.active {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .nav-link.active {
  background-color: rgba(0, 0, 0, 0.04);
}

.nav-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent-gradient);
  transform: scaleY(0);
  transition: transform var(--transition-speed) ease;
}

.nav-link.active::before {
  transform: scaleY(1);
}

.nav-icon {
  font-size: 1.125rem;
  opacity: 0.8;
}

/* Theme Toggle Button & Footer */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1.5rem;
}

.theme-toggle-btn, .theme-toggle-btn-mobile {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  font-weight: 500;
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition-all);
}

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

.theme-icon {
  width: 16px;
  height: 16px;
}

.theme-toggle-btn-mobile {
  display: none;
  padding: 0.25rem;
  border: none;
}

/* Control visibility of theme elements */
[data-theme="dark"] .dark-only,
[data-theme="light"] .light-only {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

[data-theme="dark"] .light-only,
[data-theme="light"] .dark-only {
  display: none;
}

.contact-quick {
  text-align: center;
  font-size: 0.8125rem;
}

.contact-email {
  color: var(--text-secondary);
  font-weight: 500;
  text-decoration: underline;
}

.contact-email:hover {
  color: var(--accent-primary);
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 95;
}

/* Main Content Area */
.main-content {
  margin-left: var(--sidebar-w);
  flex-grow: 1;
  padding: 3.5rem 2.5rem;
  max-width: calc(var(--content-max-w) + var(--sidebar-w));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.content-section {
  display: none;
  animation: fadeIn 0.4s var(--transition-ease) forwards;
}

.content-section.active {
  display: block;
}

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

.section-content {
  width: 100%;
  max-width: var(--content-max-w);
  margin: 0 auto;
}

/* Card layout system (Premium modern tiles) */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  transition: var(--transition-all);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

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

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition-speed) ease;
}

.card:hover::before {
  opacity: 1;
}

.card-title {
  font-size: 1.125rem;
  margin-bottom: 0.75rem;
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Badge tags style */
.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  margin-top: 0.5rem;
}

.badge {
  background-color: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.15);
  border-radius: 50px;
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--accent-primary);
  display: inline-flex;
  align-items: center;
  transition: var(--transition-all);
}

[data-theme="light"] .badge {
  background-color: rgba(2, 132, 199, 0.06);
  border-color: rgba(2, 132, 199, 0.12);
}

.badge:hover {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #fff;
  text-decoration: none;
}

/* Specific component: Timeline */
.timeline {
  position: relative;
  padding-left: 2rem;
  margin: 1.5rem 0 2rem 0.5rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 2px;
  background-color: var(--timeline-line);
}

.timeline-item {
  position: relative;
  margin-bottom: 2rem;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -2rem;
  top: 0.375rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent-gradient);
  transform: translateX(-50%);
  box-shadow: 0 0 0 4px var(--bg-app);
  transition: transform var(--transition-speed) ease;
}

.timeline-item:hover .timeline-dot {
  transform: translateX(-50%) scale(1.3);
}

.timeline-date {
  font-size: 0.8125rem;
  color: var(--accent-primary);
  font-weight: 600;
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.timeline-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}

.timeline-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* Noscript & Fallback styles */
.noscript-warning {
  background-color: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin-bottom: 2rem;
  color: var(--highlight-link);
}

noscript .content-section {
  display: block !important;
  margin-bottom: 4rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 4rem;
}

noscript .content-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

noscript .nav-link {
  pointer-events: none;
  opacity: 0.6;
}

noscript .theme-toggle-btn, noscript .theme-toggle-btn-mobile {
  display: none !important;
}

/* Search bar styling */
.search-container {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  flex-grow: 1;
  min-width: 250px;
}

.search-input {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  transition: var(--transition-all);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.search-icon {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.filter-select {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem 2rem 0.75rem 1rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  min-width: 160px;
  transition: var(--transition-all);
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
  background-color: var(--bg-card);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 1rem;
}

/* Media Queries (Responsive Layout) */
@media (max-width: 1024px) {
  body {
    flex-direction: column;
    padding-top: var(--header-h);
  }
  
  .mobile-header {
    display: flex;
  }
  
  .theme-toggle-btn-mobile {
    display: flex;
  }
  
  .sidebar {
    transform: translateX(-100%);
    position: fixed;
    top: 0;
    bottom: 0;
    height: 100vh;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.4);
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .sidebar-overlay.active {
    display: block;
  }
  
  .main-content {
    margin-left: 0;
    padding: 2rem 1.5rem;
    max-width: 100%;
    min-height: calc(100vh - var(--header-h));
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 1.75rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  .card {
    padding: 1.25rem;
  }
  
  .search-container {
    flex-direction: column;
  }
  
  .filter-select {
    width: 100%;
  }
}

/* Accessibility: Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Publications & Presentations Titles Styling */
#resume-publications a, .pub-title {
  color: var(--text-orange);
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition-all);
}

#resume-publications a:hover {
  color: var(--highlight-hover);
  text-decoration: underline;
}

/* Print Stylesheet */
@media print {
  body {
    background: white;
    color: black;
    font-size: 12pt;
    padding: 0;
    margin: 0;
  }
  
  .sidebar, .mobile-header, .sidebar-overlay, .theme-toggle-btn, .search-container, .skip-link, noscript {
    display: none !important;
  }
  
  .main-content {
    margin: 0;
    padding: 0;
    max-width: 100%;
  }
  
  .content-section {
    display: none !important;
  }
  
  #resume.content-section {
    display: block !important;
    animation: none;
  }
  
  h2::after {
    display: none;
  }
  
  a {
    color: black;
    text-decoration: underline;
  }
  
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8rem;
    color: #444;
  }
  
  .card {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin-bottom: 2rem;
  }
  
  .timeline::before {
    background-color: #ccc;
  }
  
  .timeline-dot {
    background: #666;
    box-shadow: 0 0 0 4px white;
  }
}
