/* Updated color system with more refined palette and accent colors */
:root {
  /* Dark mode (default) */
  --bg: #0f0f12;
  --panel: #1a1a1f;
  --panel2: #23232a;
  --text: #e8e8ed;
  --muted: #a8a8b3;
  --accent-blue: #4a9eff;
  --accent-cyan: #00d9ff;
  --accent-emerald: #10b981;
  --hairline: rgba(255, 255, 255, 0.06);
}

/* Light mode theme variables */
html[data-theme="light"] {
  /* Updated to warm paper/cream tones instead of pure white */
  --bg: #f9f7f3;
  --panel: #f5f2ed;
  --panel2: #efe9e2;
  --text: #1a1a1e;
  --muted: #6b6b75;
  --accent-blue: #2563eb;
  --accent-cyan: #0891b2;
  --accent-emerald: #059669;
  --hairline: rgba(0, 0, 0, 0.06);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
  border-bottom: 1px solid rgba(74, 158, 255, 0.3);
  transition: all 0.2s ease;
  position: relative;
}

a:hover {
  border-bottom-color: rgba(74, 158, 255, 0.7);
}

/* Enhanced page layout with better max-width and padding */
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 56px 24px 80px;
}

/* Improved header styling and spacing */
.top {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 48px;
}

.id {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  flex: 1;
}

.badge {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--hairline);
  background: linear-gradient(135deg, rgba(74, 158, 255, 0.08), rgba(16, 185, 129, 0.04));
  flex: 0 0 auto;
  overflow: hidden;
}

.badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.header h1 {
  margin: 0;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.header .meta {
  margin-top: 12px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  max-width: 70ch;
}

/* Redesigned links section with better spacing and styling */
.links {
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.links a {
  color: var(--accent-blue);
  text-decoration: none;
  border-bottom: 1px solid rgba(74, 158, 255, 0.3);
  padding-bottom: 2px;
}

.links a:hover {
  border-bottom-color: var(--accent-blue);
}

/* Enhanced section titles with better visual hierarchy */
.section-title {
  margin: 40px 0 20px;
  font-size: 13px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

/* Added featured item styling for research interests */
.item--featured {
  border: 1px solid var(--accent-blue);
  background: linear-gradient(135deg, rgba(74, 158, 255, 0.05), rgba(16, 185, 129, 0.02));
}

.intro-text {
  font-size: 16px;
  line-height: 1.7;
  margin: 0 0 16px;
  color: var(--text);
}

.subheading {
  font-weight: 600;
  color: var(--text);
  margin-top: 16px;
}

.focus-list {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.7;
}

.focus-list li {
  margin: 0 0 8px;
}

.focus-list strong {
  color: var(--accent-cyan);
  font-weight: 600;
}

/* Improved grid layout responsiveness */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

/* Enhanced card styling with better borders and hover effects */
.card {
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: var(--panel2);
  overflow: hidden;
  transition: all 0.3s ease;
  position: relative;
}

.card:hover {
  border-color: var(--accent-blue);
  background: linear-gradient(135deg, var(--panel2), rgba(74, 158, 255, 0.03));
  transform: translateY(-2px);
  animation: colorBeam 1.5s ease-out;
}

html[data-theme="light"] .card:hover {
  animation: colorBeam 1.5s ease-out;
}

.card .media {
  height: 180px;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card img,
.card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card .cap {
  padding: 12px 14px;
  border-top: 1px solid var(--hairline);
  background: transparent;
}

.card .cap .title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin: 0;
}

.card .cap .sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.4;
}

.card .cap a {
  color: var(--accent-blue);
  border-bottom: 1px solid rgba(74, 158, 255, 0.3);
}

.card .cap a:hover {
  border-bottom-color: var(--accent-blue);
}

/* Improved list and item styling */
.list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 28px;
}

.item {
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.015), rgba(255, 255, 255, 0.005));
  transition: all 0.2s ease;
  position: relative;
}

.item:hover {
  border-color: var(--accent-blue);
  background: linear-gradient(135deg, rgba(74, 158, 255, 0.05), rgba(74, 158, 255, 0.02));
  animation: glow 2s ease-in-out infinite;
}

html[data-theme="light"] .item:hover {
  animation: glow 2s ease-in-out infinite;
}

.item .titleline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 8px;
}

.item .titleline .projtitle {
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.3px;
  font-size: 15px;
}

.item .titleline a {
  color: var(--accent-blue);
}

/* New badge styling for project types */
.badge-accent {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 217, 255, 0.3);
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(0, 217, 255, 0.05);
}

.item .hint {
  color: var(--muted);
  font-size: 13px;
}

.item .desc {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.item .desc p {
  margin: 0 0 12px;
}

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

.item .desc ul {
  margin: 8px 0;
  padding-left: 20px;
  list-style: none;
}

.item .desc li {
  margin: 0 0 8px;
  padding-left: 0;
}

.item .desc strong {
  color: var(--text);
  font-weight: 600;
}

/* Enhanced pill styling for keywords and tags */
.pillrow {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pill {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--hairline);
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  display: inline-block;
}

.pillrow a {
  font-size: 12px;
  color: var(--accent-blue);
}

/* Added teaching list styling */
.teaching-list {
  margin: 12px 0 0;
  padding-left: 20px;
  list-style: disc;
}

.teaching-list li {
  margin: 0 0 8px;
  color: var(--muted);
}

.teaching-list a {
  color: var(--accent-blue);
}

/* New resources section with grid layout */
.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.resource-card {
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.015), rgba(255, 255, 255, 0.005));
  transition: all 0.2s ease;
}

.resource-card:hover {
  border-color: var(--accent-emerald);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(16, 185, 129, 0.02));
  animation: colorBeam 1.5s ease-out;
}

html[data-theme="light"] .resource-card:hover {
  animation: colorBeam 1.5s ease-out;
}

.resource-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.resource-card p {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--muted);
}

.resource-link {
  color: var(--accent-emerald);
  border-bottom: 1px solid rgba(16, 185, 129, 0.3);
  font-weight: 500;
}

.resource-link:hover {
  border-bottom-color: var(--accent-emerald);
}

/* Enhanced webring styling */
.webring {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}

.webring-link {
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--hairline);
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 12px;
  transition: all 0.2s ease;
}

.webring-link:hover {
  color: var(--text);
  border-color: var(--accent-blue);
  background: rgba(74, 158, 255, 0.05);
  box-shadow: 0 0 12px rgba(74, 158, 255, 0.15);
  animation: glow 1.5s ease-in-out;
}

.webring-home {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.webring-home:hover {
  color: var(--text);
  border-color: var(--hairline);
  background: rgba(255, 255, 255, 0.02);
}

.webring-home img {
  width: 16px;
  height: 16px;
  display: block;
  opacity: 0.9;
}

.webring--header {
  justify-content: flex-end;
  align-self: flex-start;
  margin-top: 4px;
}

/* Enhanced divider and footer styling */
.divider {
  border: none;
  border-top: 1px solid var(--hairline);
  margin: 40px 0;
}

.footer {
  margin-top: 32px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.footer a {
  color: var(--accent-blue);
  border-bottom: 1px solid rgba(74, 158, 255, 0.3);
}

.footer a:hover {
  border-bottom-color: var(--accent-blue);
}

/* Improved responsive design for mobile */
@media (max-width: 768px) {
  .theme-switcher {
    top: 16px;
    right: 16px;
  }

  .theme-btn {
    width: 36px;
    height: 36px;
  }

  .sun-icon,
  .moon-icon {
    width: 18px;
    height: 18px;
  }

  .page {
    padding: 40px 20px 60px;
  }

  .top {
    flex-direction: column;
    gap: 20px;
    margin-bottom: 32px;
  }

  .header h1 {
    font-size: 28px;
  }

  .webring--header {
    justify-content: flex-start;
    order: -1;
  }

  .grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
  }

  .resources-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .theme-switcher {
    top: 12px;
    right: 12px;
  }

  .page {
    padding: 28px 16px 48px;
  }

  .header h1 {
    font-size: 24px;
  }

  .header .meta {
    font-size: 13px;
  }

  .links {
    font-size: 13px;
    gap: 8px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card .media {
    height: 160px;
  }

  .item .titleline {
    flex-direction: column;
    gap: 6px;
  }

  .pillrow {
    gap: 6px;
  }

  .resources-grid {
    grid-template-columns: 1fr;
  }

  .section-title {
    margin: 28px 0 16px;
    font-size: 12px;
  }
}

/* Add theme switcher button styling */
.theme-switcher {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 1000;
}

.theme-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--hairline);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.theme-btn:hover {
  border-color: var(--accent-blue);
  background: linear-gradient(135deg, rgba(74, 158, 255, 0.1), rgba(0, 217, 255, 0.05));
  box-shadow: 0 0 20px rgba(74, 158, 255, 0.2), inset 0 0 20px rgba(74, 158, 255, 0.1);
  transform: scale(1.05);
}

.sun-icon,
.moon-icon {
  position: absolute;
  transition: all 0.3s ease;
  opacity: 1;
}

html[data-theme="dark"] .sun-icon {
  opacity: 0;
  transform: rotate(-180deg) scale(0);
}

html[data-theme="dark"] .moon-icon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

html[data-theme="light"] .sun-icon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

html[data-theme="light"] .moon-icon {
  opacity: 0;
  transform: rotate(180deg) scale(0);
}

/* Add color beam animation keyframes */
@keyframes colorBeam {
  0% {
    box-shadow: 0 0 0 0 rgba(74, 158, 255, 0.4), 0 0 0 0 rgba(0, 217, 255, 0.2);
  }
  50% {
    box-shadow: 0 0 20px 10px rgba(74, 158, 255, 0.2), 0 0 30px 15px rgba(0, 217, 255, 0.1);
  }
  100% {
    box-shadow: 0 0 40px 20px rgba(74, 158, 255, 0), 0 0 50px 25px rgba(0, 217, 255, 0);
  }
}

@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 5px rgba(74, 158, 255, 0.3), 0 0 10px rgba(0, 217, 255, 0.1);
  }
  50% {
    box-shadow: 0 0 15px rgba(74, 158, 255, 0.5), 0 0 20px rgba(0, 217, 255, 0.2);
  }
}
