/* ========================================
   Modern Dark Theme Portfolio Stylesheet
   ======================================== */

:root {
  /* Light Theme Colors */
  --bg-light: #ffffff;
  --text-light: #1a1a1a;
  --primary-light: #1b3c59;
  --accent-light: #0077ff;
  --card-bg-light: #f8f9fa;
  --border-light: #e0e0e0;
  --hover-light: #f0f0f0;
  
  /* Dark Theme Colors */
  --bg-dark: #000000;
  --text-dark: #e6edf3;
  --primary-dark: #58a6ff;
  --accent-dark: #0070f3;
  --card-bg-dark: #0a0a0a;
  --border-dark: #1a1a1a;
  --hover-dark: #050505;
  
  /* Common Variables */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.2);
  --border-radius: 12px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Theme Toggle Button
   ======================================== */
.theme-toggle {
  position: fixed;
  top: 2rem;
  right: 2rem;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: none;
  background: var(--card-bg-dark);
  color: var(--primary-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  transition: var(--transition);
  font-size: 1.98rem;
}

.theme-toggle:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

body:not(.dark-theme) .theme-toggle {
  background: var(--card-bg-light);
  color: var(--primary-light);
}

/* Hide toggle button on touch devices (including when desktop layout is requested) */
@media (pointer: coarse) {
  .theme-toggle {
    display: none !important;
  }
}

/* ========================================
   Profile Image
   ======================================== */
.profile-image {
  position: absolute;
  top: 0.75rem;
  left: 2rem;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--primary-dark);
  box-shadow: var(--shadow-lg);
  z-index: 999;
  transition: var(--transition);
}

.profile-image:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(88, 166, 255, 0.4);
}

body:not(.dark-theme) .profile-image {
  border-color: var(--primary-light);
}

body:not(.dark-theme) .profile-image:hover {
  box-shadow: 0 8px 25px rgba(0, 119, 255, 0.3);
}

/* Desktop alignment: keep the profile image consistently anchored near the top-left on wide screens */
@media (min-width: 901px) {
  .profile-image {
    top: 0.25rem;
    left: 1.5rem;
    width: 182px;
    height: 182px;
  }
}

/* ========================================
   Base Styles
   ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 110%;
}

body {
  font-family: 'Inter', sans-serif;
  line-height: 1.53;
  background-color: var(--bg-dark);
  color: var(--text-dark);
  transition: background-color 0.3s ease, color 0.3s ease;
}

body:not(.dark-theme) {
  background-color: var(--bg-light);
  color: var(--text-light);
}

/* ========================================
   Typography
   ======================================== */
h1, h2, h3 {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  line-height: 1.3;
}

h2 {
  font-size: 1.7325rem;
  margin-bottom: 0.6rem;
  position: relative;
  padding-bottom: 0.4rem;
}

h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-dark), transparent);
  border-radius: 2px;
}

body:not(.dark-theme) h2::after {
  background: linear-gradient(90deg, var(--accent-light), transparent);
}

h3 {
  font-size: 1.21275rem;
  margin-bottom: 1rem;
  color: var(--primary-dark);
}

body:not(.dark-theme) h3 {
  color: var(--primary-light);
}

p {
  font-size: 0.8504409375rem;
  margin-bottom: 0.85rem;
}

strong {
  font-weight: 600;
}

/* Lists */
ul {
  margin: 1rem 0;
  padding-left: 1.5rem;
  list-style: disc;
}

ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
  list-style: decimal;
}

li {
  margin-bottom: 0.85rem;
  line-height: 1.62;
  font-size: 0.8504409375rem;
  opacity: 0.9;
}

body:not(.dark-theme) li {
  opacity: 0.85;
}

/* ========================================
   Header / Hero Section
   ======================================== */
header.hero {
  background: linear-gradient(135deg, #000000 0%, #0a0a0a 50%, #000000 100%);
  color: var(--text-dark);
  text-align: center;
  padding: 1.2rem 2rem;
  position: relative;
  overflow: hidden;
}

body:not(.dark-theme) header.hero {
  background: linear-gradient(135deg, #0077ff 0%, #1b3c59 50%, #0077ff 100%);
  color: white;
}

header.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="grid" width="100" height="100" patternUnits="userSpaceOnUse"><path d="M 100 0 L 0 0 0 100" fill="none" stroke="rgba(88,166,255,0.1)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
  opacity: 0.3;
  animation: moveGrid 20s linear infinite;
}

@keyframes moveGrid {
  0% { transform: translate(0, 0); }
  100% { transform: translate(100px, 100px); }
}

header h1 {
  font-size: 3.031875rem;
  margin-bottom: 0.25rem;
  position: relative;
  z-index: 1;
  text-shadow: 0 4px 20px rgba(88, 166, 255, 0.3);
}

body:not(.dark-theme) header h1 {
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.subtitle {
  font-size: 1.126125rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
  opacity: 0.9;
  position: relative;
  z-index: 1;
}

header nav {
  display: flex;
  justify-content: center;
  gap: 1.05rem;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

header nav a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  padding: 0.56rem 1.05rem;
  border-radius: 8px;
  border: 2px solid rgba(88, 166, 255, 0.3);
  background: rgba(88, 166, 255, 0.1);
  transition: var(--transition);
  backdrop-filter: blur(10px);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

body:not(.dark-theme) header nav a {
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.15);
}

header nav a:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(88, 166, 255, 0.4);
}

body:not(.dark-theme) header nav a:hover {
  background: white;
  color: var(--primary-light);
  border-color: white;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

/* ========================================
   Main Content
   ======================================== */
main {
  max-width: 1291.059px;
  margin: 0 auto;
  padding: 0.8rem 2rem;
}

section {
  margin-bottom: 2.55rem;
}

/* Two-column layout for projects and publications */
#projects, #publications {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.56rem;
}

/* Research Projects boxes - wider columns for long titles */
#projects {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-content: start;
  gap: 1.15rem;
  align-items: stretch;
}

/* Reduce width of Publications & Articles boxes to match Research Projects */
#publications {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-content: start;
  gap: 1rem;
  align-items: stretch;
}

#projects h2,
#publications h2 {
  grid-column: 1 / -1;
}

/* Keep About section single column */
#about {
  grid-template-columns: 1fr;
  display: block;
}

/* About section font size increase */
#about h2 {
  font-size: 1.68698376rem;
  margin-bottom: 0.4rem;
}

#about p {
  font-size: 0.9742331214rem;
  margin-bottom: 0.4rem;
}

/* ========================================
   Cards / Articles
   ======================================== */
article {
  background: var(--card-bg-dark);
  border: 1px solid var(--border-dark);
  padding: 0.75rem;
  border-radius: var(--border-radius);
  margin-bottom: 0.6rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

body:not(.dark-theme) article {
  background: var(--card-bg-light);
  border: 1px solid var(--border-light);
}

article::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent-dark), var(--primary-dark));
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

body:not(.dark-theme) article::before {
  background: linear-gradient(180deg, var(--accent-light), var(--primary-light));
}

article:hover::before {
  transform: scaleY(1);
}

article:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-dark);
}

body:not(.dark-theme) article:hover {
  border-color: var(--accent-light);
}

article h3 {
  margin-bottom: 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Override for projects section with reduced height */
#projects article h3 {
  margin-bottom: 0.2803878rem;
  font-size: 1.17478210224375rem;
}

article p {
  opacity: 0.9;
  line-height: 1.62;
}

body:not(.dark-theme) article p {
  opacity: 0.85;
}

article li {
  opacity: 0.9;
  line-height: 1.62;
  font-size: 0.952875rem;
}

body:not(.dark-theme) article li {
  opacity: 0.85;
}

#projects article li {
  font-size: 0.72968218125rem;
}

#publications article li {
  font-size: 0.78040875rem;
}

/* Projects boxes - wider for long titles */
#projects article {
  padding: 0.7295805rem;
  margin-bottom: 0.486387rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

#publications article {
  padding: 1.5rem;
  margin-bottom: 1rem;
  width: 85%;
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

#publications article h3 {
  margin-bottom: 0.7rem;
  font-size: 0.945945rem;
}

#projects article p {
  font-size: 0.729678324375rem;
  margin-bottom: 0.57222rem;
}

#publications article p {
  font-size: 0.780404625rem;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  display: inline-block;
  background: linear-gradient(135deg, var(--accent-dark), var(--primary-dark));
  color: white;
  text-decoration: none;
  padding: 0.68rem 1.275rem;
  border-radius: 8px;
  margin-top: 0.85rem;
  font-weight: 600;
  transition: var(--transition);
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}

/* Match button style - ensure buttons align at bottom */
#projects article .btn,
#publications article .btn {
  margin-top: auto;
  width: auto;
  max-width: none;
  min-width: 130px;
  align-self: flex-start;
  white-space: nowrap;
}

body:not(.dark-theme) .btn {
  background: linear-gradient(135deg, var(--accent-light), var(--primary-light));
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
  width: 300px;
  height: 300px;
}

#projects article .btn:hover::before,
#publications article .btn:hover::before {
  width: 217.8px;
  height: 217.8px;
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(88, 166, 255, 0.4);
}

body:not(.dark-theme) .btn:hover {
  box-shadow: 0 8px 25px rgba(0, 119, 255, 0.3);
}

.btn {
  position: relative;
  z-index: 1;
}

/* ========================================
   Footer
   ======================================== */
footer {
  text-align: center;
  background: var(--card-bg-dark);
  border-top: 1px solid var(--border-dark);
  color: var(--text-dark);
  padding: 1.05rem 1rem;
  margin-top: 1.4rem;
}

body:not(.dark-theme) footer {
  background: var(--primary-light);
  border-top: none;
  color: white;
}

footer p {
  margin: 0.5rem 0;
  opacity: 0.9;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 1100px) {
  header.hero {
    padding-top: 5.5rem;
  }
  
  .profile-image {
    top: 0.75rem;
    left: 1.25rem;
    width: 150px;
    height: 150px;
  }
}

@media (max-width: 768px) {
  header.hero {
    padding-top: 6.5rem;
  }
  
  header h1 {
    font-size: 2.0625rem;
  }
  
  .subtitle {
    font-size: 0.9075rem;
  }
  
  header nav {
    gap: 0.8rem;
  }
  
  header nav a {
    padding: 0.6rem 1rem;
    font-size: 0.7425rem;
  }
  
  main {
    padding: 2rem 1rem;
  }
  
  h2 {
    font-size: 1.32rem;
  }
  
  #about h2 {
    font-size: 1.4281344rem;
  }
  
  #about p {
    font-size: 0.824747616rem;
  }
  
  .theme-toggle {
    display: none !important;
  }
  
  .profile-image {
    top: 0.5rem;
    left: 1rem;
    width: 120px;
    height: 120px;
  }
  
  article {
    padding: 1.5rem;
  }
  
  /* Stack columns on tablet */
  #projects, #publications {
    grid-template-columns: 1fr;
    gap: 1.05rem;
  }
  
  /* Reduced size for projects and publications boxes on tablet */
  #projects article,
  #publications article {
    padding: 1.05rem;
  }
}

@media (max-width: 480px) {
  header.hero {
    padding: 6rem 1.5rem 3rem;
  }
  
  header h1 {
    font-size: 1.65rem;
  }
  
  .subtitle {
    font-size: 0.825rem;
  }
  
  header nav {
    flex-direction: column;
    gap: 0.5rem;
  }
  
  header nav a {
    width: 100%;
    justify-content: center;
  }
  
  #about h2 {
    font-size: 1.191212rem;
  }
  
  #about p {
    font-size: 0.68728968rem;
  }
  
  .profile-image {
    top: 1rem;
    left: 0.6rem;
    width: 74px;
    height: 74px;
    border-width: 3px;
  }
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(88, 166, 255, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(88, 166, 255, 0.6);
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* Section animations */
section {
  animation: fadeIn 0.8s ease forwards;
}

#about {
  animation: slideInLeft 0.8s ease forwards;
}

#projects {
  animation: fadeIn 1s ease forwards;
}

#publications {
  animation: fadeIn 1.2s ease forwards;
}

/* Article animations */
article {
  animation: fadeIn 0.6s ease forwards;
}

article:nth-child(1) {
  animation-delay: 0.1s;
}

article:nth-child(2) {
  animation-delay: 0.2s;
}

article:nth-child(3) {
  animation-delay: 0.3s;
}

article:nth-child(4) {
  animation-delay: 0.4s;
}

/* Header animations */
header.hero h1 {
  animation: fadeIn 0.8s ease forwards;
}

header.hero .subtitle {
  animation: fadeIn 1s ease forwards;
}

header.hero nav {
  animation: fadeIn 1.2s ease forwards;
}

/* Button animations - enhance existing hover */
.btn:hover {
  animation: glow 2s ease-in-out infinite;
}

/* Theme toggle animation */
.theme-toggle {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.theme-toggle:hover {
  transform: scale(1.1) rotate(15deg);
  animation: pulse 1s ease-in-out infinite;
}

/* ========================================
   Accessibility
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus styles for keyboard navigation */
a:focus,
button:focus {
  outline: 2px solid var(--accent-dark);
  outline-offset: 2px;
}

body:not(.dark-theme) a:focus,
body:not(.dark-theme) button:focus {
  outline-color: var(--accent-light);
}

/* Print styles */
@media print {
  .theme-toggle {
    display: none;
  }
  
  header.hero {
    background: white;
    color: black;
  }
  
  body {
    background: white;
    color: black;
  }
}