/* Color scheme stolen from Sergey Karayev */

:root {
  --bkgd-multiplier: 200%;
  --font-weight: 300;
  --font-family: 'Source Sans Pro', 'Inter', 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue",
    "KaiTi", "楷體", STKaiti, "華文楷體",
    /*"FangSong", "放鬆", STFangSong, "華文放鬆", */
    sans-serif;
  --body-font-size: 16px;
  --card-padding-y: 28px;
  --card-padding-x: 42px;
  --color-bg: #f5f6fb;
  --color-card-bg: #ffffff;
  --color-text: #12131a;
  --color-muted: #63677b;
  --color-primary: #1c3ed0;
  --color-primary-hover: #142bbf;
  --color-primary-light: #e1e6ff;
  --color-nav-line: rgba(0, 0, 0, 0.15);
  --color-tag-green: #008000;
  --color-tag-purple: #800080;
  --color-tag-cyan: #33C1FF;
  --color-border: rgba(4, 15, 68, 0.08);
  --shadow-soft: 0 25px 60px rgba(14, 24, 63, 0.12);
  --shadow-card: 0 18px 40px rgba(9, 17, 45, 0.1);
}

[data-theme="dark"] {
  --color-bg: #12131a;
  --color-card-bg: #1c1d26;
  --color-text: #f5f6fb;
  --color-muted: #a0a4b8;
  --color-primary: #c4d9ff;
  --color-primary-hover: #e6f0ff;
  --color-primary-light: #2a2d45;
  --color-nav-line: rgba(255, 255, 255, 0.2);
  --color-tag-green: #4caf50;
  --color-tag-purple: #ce93d8;
  --color-tag-cyan: #4dd0e1;
  --color-border: rgba(255, 255, 255, 0.1);
  --shadow-soft: 0 25px 60px rgba(0, 0, 0, 0.3);
  --shadow-card: 0 18px 40px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] body {
  background-image: none; /* Hide the light tiger image in dark mode */
  background-color: var(--color-bg);
}

[data-theme="dark"] .hero-name-title,
[data-theme="dark"] h2,
[data-theme="dark"] h3 {
  color: var(--color-text);
}

[data-theme="dark"] .imgborder {
  border-color: var(--color-border);
  background: var(--color-card-bg);
}

/* Theme Toggle Button */
.theme-toggle {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-card-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  padding: 0;
}

.theme-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.theme-toggle svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}
* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  overflow-y: scroll;
  overflow-x: hidden;
}
[id] {
  scroll-margin-top: 140px;
}
body {
  background-image: url("../assets/tiger-very-light-flip-fade.png");
  background-repeat: no-repeat;
  background-position: top;
  background-attachment: fixed;
  background-size: var(--bkgd-multiplier);
  width: 100%;
  margin: 0;
  padding: 0;
  line-height: 1.65;
  color: var(--color-text);
  opacity: 0;
  transition: opacity 0.6s ease-in-out;
  overflow-x: hidden;
}
body.loaded {
  opacity: 1;
}
a {
  color: var(--color-primary);
  text-decoration: none;
}
a:focus,a:hover {
  color: var(--color-primary-hover);
  text-decoration: none;
}
body,td,th,tr,p,a {
  font-family: var(--font-family);
  font-size: var(--body-font-size);
  font-weight: var(--font-weight);
}
p,li {
  color: var(--color-text);
  margin-top: 0;
  margin-bottom: 1.1em;
}
li {
  line-height: 1.55;
}
ul {
  padding-left: 20px;
  margin-top: 0.05em;
  margin-bottom: 0.05em;
}
strong {
  font-family: var(--font-family);
  font-size: var(--body-font-size);
  font-weight: 400;
}
h2, h3 {
  font-family: var(--font-family);
  color: #0d0d0d;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-top: 0;
}
h2 {
  font-size: clamp(24px, 3vw, 30px);
  line-height: 1.2;
  margin-bottom: 18px;
}
h3 {
  font-size: clamp(18px, 2.5vw, 22px);
  line-height: 1.3;
  margin-top: 4px;
  margin-bottom: 4px;
}
.hero-name {
  font-weight: 600;
  font-size: clamp(20px, 2.3vw, 24px);
  margin: 6px 0 8px;
}
.hero-name a {
  color: #141414;
  font-size: inherit;
  font-weight: inherit;
  font-family: inherit;
}
.paper-title {
  font-family: var(--font-family);
  font-size: var(--body-font-size);
  font-weight: 500;
}
.hero-name-title {
  font-family: 'Inter', 'Source Sans Pro', var(--font-family);
  font-size: clamp(40px, 5vw, 62px);
  color: black;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.08;
  display: inline-block;
  margin-bottom: 16px;
}
.tab {
  margin-left: 40px;
}
.imgborder {
  border: 1px solid white;
  display: flex;
  justify-content: center;
  background: white;
}
.page-layout {
  width: 100%;
}
.content-column {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}
.page-container {
  width: 100%;
  padding: 60px 24px 120px;
}
.hero {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  align-items: center;
  background: var(--color-card-bg);
  border-radius: 32px;
  padding: 48px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 40px;
}
.link-row {
  font-size: 0.95rem;
  text-align: center;
  color: var(--color-muted);
  margin-bottom: 0.8em;
}
.link-row a {
  font-weight: 400;
}
.hero-heading {
  flex: 1 1 100%;
  text-align: center;
  margin-bottom: 12px;
}
.hero-text {
  flex: 1 1 360px;
}
.hero-photo {
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.profile-photo {
  width: 220px;
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: 18px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}
.section-card {
  width: 100%;
  border-radius: 28px;
  background: var(--color-card-bg);
  box-shadow: var(--shadow-card);
  margin-bottom: 32px;
  box-sizing: border-box;
  border: 1px solid var(--color-border);
}
section.section-card {
  padding: var(--card-padding-y) min(var(--card-padding-x), max(16px, 6vw));
}
section.section-card.accordion {
  padding: 0;
}
.accordion {
  padding: 0;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}
.accordion:hover {
  box-shadow: 0 20px 45px rgba(9, 17, 45, 0.12);
}
.accordion-toggle {
  width: 100%;
  background: transparent;
  border: none;
  border-radius: 28px;
  padding: var(--card-padding-y) var(--card-padding-x);
  text-align: left;
  font-family: var(--font-family);
  font-size: clamp(20px, 2.2vw, 26px);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--color-text);
  cursor: pointer;
  transition: border-radius 0.2s ease;
  position: relative;
}
.accordion-toggle[aria-expanded="true"] {
  border-radius: 28px 28px 0 0;
}
.accordion-toggle:focus-visible {
  outline: 3px solid var(--color-primary-light);
  outline-offset: 4px;
}
.accordion-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: transform 0.3s ease, background-color 0.2s ease;
  flex-shrink: 0;
}
.accordion-toggle:hover .accordion-icon {
  background: var(--color-primary);
  color: white;
}
.accordion-toggle[aria-expanded="true"] .accordion-icon {
  transform: rotate(180deg);
}
.accordion-panel {
  padding: var(--card-padding-y) min(var(--card-padding-x), max(16px, 6vw));
  border-top: 1px solid var(--color-border);
  overflow: hidden;
  transition: max-height 0.3s ease-out, opacity 0.3s ease-out, padding 0.3s ease-out;
  max-height: 5000px;
  opacity: 1;
}
.accordion-panel[hidden] {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top: none;
}
.featured-section .section-content {
  display: flex;
  flex-direction: column;
  gap: 28px;
  max-width: 100%;
  margin: 0 auto;
  width: 100%;
}
.section-card.featured-section {
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}
.featured-section .accordion-panel {
  padding: 30px min(32px, max(16px, 6vw)) 34px;
}
.tweet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  width: 100%;
}
.tweet-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tweet-card h3 {
  text-align: center;
}
.tweet-card h3 a {
  font-size: inherit;
  font-weight: inherit;
  font-family: inherit;
  line-height: inherit;
}
.tweet-embed {
  width: 100%;
  max-width: 100%;
  margin: 0;
  border-radius: 0;
  overflow: visible;
  box-shadow: none;
  display: flex;
  justify-content: center;
  background: transparent;
  padding: 0;
  min-height: 400px;
  position: relative;
}
.tweet-embed blockquote,
.tweet-embed iframe {
  margin: 0 !important;
  width: 100% !important;
  max-width: 560px !important;
  flex: 0 1 560px;
}
/* Loading skeleton for tweets */
.tweet-embed::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  height: 400px;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.06) 0%,
    rgba(0, 0, 0, 0.08) 50%,
    rgba(0, 0, 0, 0.06) 100%
  );
  background-size: 200% 100%;
  border-radius: 12px;
  animation: shimmer 1.5s infinite;
  z-index: 1;
}
.tweet-embed.loaded::before {
  display: none;
}
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}
/* Fade-in animation for sections */
.section-card,
.hero {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.section-card.fade-in,
.hero.fade-in {
  opacity: 1;
  transform: translateY(0);
}
.section-card .section-content {
  margin-bottom: 12px;
  padding-top: 6px;
}
.section-card .section-content > :first-child {
  margin-top: 0;
}
.section-card .section-content > :last-child {
  margin-bottom: 0;
}
.table-card {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.table-card td {
  padding: var(--card-padding-y) var(--card-padding-x);
}
.publication-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.past-publications {
  padding: 36px;
}
.hero-entry {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 30px;
  align-items: flex-start;
}
.hero-entry:last-of-type {
  margin-bottom: 0;
}
.hero-text {
  flex: 1 1 320px;
}
.hero-image {
  flex: 0 0 220px;
  text-align: center;
}
.hero-image img {
  width: 100%;
  max-width: 220px;
  border-radius: 12px;
}
.site-footer {
  margin-top: 48px;
  text-align: right;
  font-size: 13px;
  color: #5b5b5b;
}
.site-footer a {
  color: inherit;
}
@media (max-width: 768px) {
  .hero {
    padding: 32px;
    flex-direction: column;
  }
  .hero-heading {
    order: 0;
  }
  .hero-photo {
    order: 1;
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 12px 0;
  }
  .hero-text {
    order: 2;
  }
  .profile-photo {
    width: 160px;
  }
  .section-card {
    border-radius: 22px;
  }
  .publication-table tr {
    display: block;
    margin-bottom: 28px;
  }
  .publication-table tr:last-of-type {
    margin-bottom: 0;
  }
  .publication-table td {
    display: block;
    width: 100% !important;
  }
  .publication-table td:first-child {
    margin-bottom: 14px;
  }
  .imgborder img {
    max-width: 240px;
    margin: 0 auto;
    display: block;
  }
  .page-layout {
    flex-direction: column;
  }
  .content-column {
    flex: 1 1 auto;
    max-width: 100%;
  }
  .tweet-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .tweet-card {
    padding: 0;
    width: 100%;
  }
  .tweet-embed blockquote,
  .tweet-embed iframe {
    max-width: 100% !important;
    flex: 1 1 100%;
  }
}
/* Extra small screens - tighter padding */
@media (max-width: 400px) {
  .hero {
    padding: 24px 20px;
  }
  .section-card {
    border-radius: 18px;
  }
  .profile-photo {
    width: 140px;
  }
  h2 {
    font-size: 22px;
  }
  .hero-name-title {
    font-size: 36px;
  }
}
.hobby-image {
  width: 100%;
  height: 500px; /* Fixed height for uniformity */
  object-fit: cover; /* Crop to fill */
  object-position: center;
  border-radius: 12px;
  cursor: zoom-in;
  transition: transform 0.2s ease;
}
.hobby-image:hover {
  transform: scale(1.01);
}

@media (max-width: 768px) {
  .hobby-image {
    height: 300px; /* Smaller height on mobile */
  }
}

/* Back to top button */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity 0.3s ease, transform 0.2s ease;
  opacity: 0;
}
.back-to-top.visible {
  display: flex;
  opacity: 1;
}
.back-to-top:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 50px rgba(9, 17, 45, 0.15);
}
.back-to-top:active {
  transform: translateY(0);
}
@media (min-width: 769px) {
  .back-to-top {
    display: none !important;
  }
}

/* Vertical Navigation Styles */
.vertical-nav {
  position: fixed;
  top: 10vh;
  height: 80vh;
  right: 40px;
  width: 120px; /* Width for the labels */
  z-index: 100;
  pointer-events: none;
}

/* Connecting dotted line */
.vertical-nav::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0; /* Align line to the right */
  width: 1px;
  border-left: 2px dotted var(--color-nav-line);
  z-index: -1;
}

.nav-item {
  position: absolute;
  right: 0; /* Align items to the dotted line */
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  cursor: pointer;
  pointer-events: auto;
  height: 20px;
  padding-right: 15px; /* Space between text and line */
}

/* Small tick mark on the line */
.nav-item::after {
  content: '';
  position: absolute;
  right: -4px; /* Center on the dotted line */
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background-color: #fff;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.nav-item:hover::after {
  border-color: var(--color-primary);
  background-color: var(--color-primary);
}

.nav-item.active::after {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  transform: translateY(-50%) scale(1.2);
}

.nav-label {
  white-space: nowrap;
  font-size: 13px;
  font-weight: 400;
  color: var(--color-muted);
  transition: all 0.3s ease;
}

.nav-item:hover .nav-label {
  color: var(--color-primary);
  transform: translateX(-5px);
}

.nav-item.active .nav-label {
  color: var(--color-primary);
  font-weight: 600;
  transform: translateX(-5px);
}

@media (max-width: 1200px) {
  .vertical-nav {
    display: none;
  }
}

/* Mobile Navigation Styles */
.mobile-nav-toggle {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 48px;
  height: 48px;
  background: var(--color-card-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  box-shadow: var(--shadow-card);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  cursor: pointer;
  transition: transform 0.2s ease;
  font-size: 24px;
}

.mobile-nav-toggle:active {
  transform: scale(0.95);
}

.mobile-nav-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--color-card-bg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 20px;
}

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

.mobile-nav-item {
  font-size: 24px;
  font-weight: 500;
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
}

.mobile-nav-item:hover {
  color: var(--color-primary);
}

@media (max-width: 1200px) {
  .mobile-nav-toggle {
    display: flex;
  }
}

/* Lightbox Styles */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.lightbox-content {
  max-width: 90%;
  max-height: 90%;
  border-radius: 4px;
  box-shadow: 0 5px 30px rgba(0,0,0,0.5);
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

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

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  color: white;
  font-size: 40px;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 10px;
  line-height: 1;
  z-index: 2001;
}

.lightbox-close:hover {
  color: var(--color-primary-light);
}

/* Lightbox Navigation */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-size: 40px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  padding: 20px 15px;
  line-height: 1;
  z-index: 2001;
  transition: background-color 0.2s ease;
  border-radius: 4px;
}

.lightbox-nav:hover {
  background-color: rgba(0, 0, 0, 0.6);
  color: var(--color-primary-light);
}

.lightbox-prev {
  left: 20px;
}

.lightbox-next {
  right: 20px;
}

/* Lightbox Caption */
.lightbox-caption {
  position: absolute;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 18px;
  font-weight: 400;
  background: rgba(0, 0, 0, 0.6);
  padding: 10px 20px;
  border-radius: 30px;
  z-index: 2001;
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(4px);
  letter-spacing: 0.5px;
}

/* Helper classes for colored tags */
.tag-green { color: var(--color-tag-green); }
.tag-purple { color: var(--color-tag-purple); }
.tag-cyan { color: var(--color-tag-cyan); }

/* Gallery Carousel */
.gallery-carousel {
  position: relative;
  width: 100%;
  height: 500px; /* Fixed height for consistency */
  overflow: hidden;
  margin: 0 auto;
  background-color: #000;
  border-radius: 12px;
}

.carousel-track {
  position: relative;
  width: 100%;
  height: 100%;
}

.carousel-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.8s ease-in-out;
  z-index: 1;
}

.carousel-slide.active {
  opacity: 1;
  z-index: 2;
}

.carousel-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.carousel-caption {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: 24px;
  font-weight: 300;
  background: rgba(0, 0, 0, 0.5);
  padding: 12px 24px;
  border-radius: 30px;
  backdrop-filter: blur(4px);
  text-align: center;
  z-index: 3;
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}

.carousel-caption a {
  color: white;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.5);
  transition: border-color 0.2s ease;
  font-size: inherit;
  font-family: inherit;
}

.carousel-caption a:hover {
  border-color: white;
}

.carousel-indicators {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 10;
}

.carousel-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid white;
  background: transparent;
  cursor: pointer;
  padding: 0;
  transition: background 0.3s ease;
}

.carousel-indicator.active {
  background: white;
}

/* Carousel Navigation (Arrows) */
.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-size: 40px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.2);
  border: none;
  padding: 10px 15px;
  line-height: 1;
  z-index: 10;
  transition: background-color 0.2s ease, color 0.2s ease;
  border-radius: 4px;
}

.carousel-nav:hover {
  background-color: rgba(0, 0, 0, 0.5);
  color: var(--color-primary-light);
}

.carousel-prev {
  left: 10px;
}

.carousel-next {
  right: 10px;
}

@media (max-width: 768px) {
  .gallery-carousel {
    height: 300px;
  }
}
