:root {
  --bg: #FFFFFF;
  --card: var(--bg);
  --text: #000000;
  --muted: #000000;
  --accent: #000000;
  --pub-title: #000000;
  --pub-venue: #000000;
  --footer-bg: #f9fafb;
  --footer-text: #000000;
  --footer-height: 72px;
  --lime-glow: rgba(209, 231, 221, 0.85);
}

html.dark {
  --bg: #111111;
  --card: var(--bg);
  --text: #FFFFFF;
  --muted: #FFFFFF;
  --accent: #FFFFFF;
  --pub-title: #FFFFFF;
  --pub-venue: #FFFFFF;
  --footer-bg: #1f2937;
  --footer-text: #FFFFFF;
  --lime-glow: rgba(143, 188, 143, 0.6);
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s;
  padding-bottom: calc(var(--footer-height) + 1rem);
}

#site-main {
  background: transparent;
  min-height: 100vh;
}

/* Header Styling */
#site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: var(--bg);
  transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
  box-shadow: 0 1px 3px rgba(0,0,0,0); /* Start transparent */
  padding-top: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid transparent; /* Start transparent */
}
#site-header.header-hidden {
  transform: translateY(-100%);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  border-bottom-color: rgba(0,0,0,0.05);
}
html.dark #site-header.header-hidden {
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  border-bottom-color: rgba(255,255,255,0.08);
}


.chinese-name {
  font-family: 'Noto Serif TC', serif;
  font-size: 1.05rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.nav-link > span {
  transition: text-shadow 0.3s ease;
}
.nav-link:hover > span {
  text-shadow: 0 0 10px var(--lime-glow);
}

#desktop-nav {
    margin-left: 2rem;
}

#about {
  min-height: calc(100vh - var(--header-height, 120px) - var(--footer-height, 72px));
}

/* Golden ratio layout */
@media (min-width: 768px) {
  .grid-golden {
    display: grid;
    grid-template-columns: 1fr 1.618fr;
    gap: 3rem;
  }
  .golden-main { grid-column: 2 / 3; }
  .golden-sidebar { grid-column: 1 / 2; }
}

#about .text-lg {
  line-height: 1.9;
}

/* FIX: Removed negative margins to align the box with the text */
.job-market-box {
    background-color: rgba(204, 0, 51, 0.05);
    border-left: 4px solid #CC0033;
    color: #CC0033;
    padding: 1.25rem 1.5rem;
    border-radius: 0.25rem;
    font-size: 0.9rem;
    line-height: 1.6;
}

html.dark .job-market-box {
    background-color: rgba(220, 38, 38, 0.15);
    border-left-color: #fca5a5;
    color: #fca5a5;
}

.expandable-content {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.5s ease-in-out, opacity 0.3s ease-in-out, margin-top 0.5s ease-in-out;
  margin-top: 0;
}
.expandable-content.expanded {
  max-height: 500px; /* Generic max-height */
  opacity: 1;
}

.link-style {
    color: #0F52BA;
    text-decoration: underline;
    text-decoration-color: rgba(15, 82, 186, 0.4);
    transition: text-decoration-color 0.2s ease;
}
.link-style:hover {
    text-decoration-color: rgba(15, 82, 186, 1);
}
html.dark .link-style {
    color: #89CFF0;
    text-decoration-color: rgba(137, 207, 240, 0.4);
}
html.dark .link-style:hover {
    text-decoration-color: rgba(137, 207, 240, 1);
}

#site-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  height: var(--footer-height);
  background: var(--footer-bg);
  color: var(--footer-text);
  transition: transform 0.3s ease-in-out;
}

#site-footer.footer-hidden {
    transform: translateY(100%);
}

html.dark #site-footer {
    border-top-color: #1f2937;
}

.pub-item { padding: 8px 0; }
.pub-top { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; }
.pub-title { color: #CC0033; font-weight: 600; text-decoration: none; }
.pub-venue { color: var(--pub-venue); font-weight: 700; margin-left: 0.4rem; font-size: 1rem; }
.pub-authors { color: var(--muted); margin-top: 0.25rem; font-size: 0.95rem; }
.pub-authors a { color: var(--muted); text-decoration: none; transition: transform 120ms ease, opacity 120ms ease; display: inline-block; margin-right: 0.35rem; }
.pub-authors a:hover { transform: scale(1.06); opacity: 0.7; }

/* Wabi-Sabi button hover effect */
#wabisabi-buttons button:hover {
  box-shadow: 2px 2px 0px 0px var(--text), 4px 4px 0px 0px rgba(0,0,0,0.1);
}
html.dark #wabisabi-buttons button:hover {
  box-shadow: 2px 2px 0px 0px var(--text), 4px 4px 0px 0px rgba(255,255,255,0.1);
}

/* Wabi-Sabi photo border */
#portrait-container {
  position: relative;
  overflow: visible;
}

#portrait-container::before {
  content: '';
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' fill='none' stroke='%23000' stroke-width='1.5'%3E%3Cpath d='M1 1 L99 1 L99 99 L1 99 Z' /%3E%3C/svg%3E") no-repeat;
  background-size: 100% 100%;
  opacity: 0.2;
  z-index: -1;
}

html.dark #portrait-container::before {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' fill='none' stroke='%23fff' stroke-width='1.5'%3E%3Cpath d='M1 1 L99 1 L99 99 L1 99 Z' /%3E%3C/svg%3E") no-repeat;
  background-size: 100% 100%;
}

/* Nav icon styling */
.nav-icon {
  display: none;
  margin-left: 0.5rem;
  transition: transform 0.2s ease-in-out;
  font-size: 1.1em;
}

.nav-link:hover .nav-icon {
  display: inline-block;
  transform: scale(1.2);
}

.nav-link:hover {
  opacity: 1.0;
}

.nav-icon svg {
  display: none;
}

/* Japanese Color Palette Hover Effects */
.nav-link#nav-about:hover { color: #4a7c59; }
.nav-link#nav-pubs:hover { color: #f94c4c; }
.nav-link#nav-recognitions:hover { color: #3b5998; }
.nav-link#nav-music:hover { color: #5c628f; }
.nav-link#nav-cv:hover { color: #a0522d; } /* Sienna */

html.dark .nav-link#nav-about:hover { color: #8FBC8F; }
html.dark .nav-link#nav-pubs:hover { color: #ff8c8c; }
html.dark .nav-link#nav-recognitions:hover { color: #8b9dc3; }
html.dark .nav-link#nav-music:hover { color: #a5a9c0; }
html.dark .nav-link#nav-cv:hover { color: #c88a65; } /* Lighter Sienna */

/* Job market link styling */
.job-market-link {
    display: inline-block;
    color: #CC0033;
    font-size: 0.9rem;
    line-height: 1.6;
    text-decoration: underline;
    text-underline-offset: 4px;
    text-decoration-color: rgba(204, 0, 51, 0.5);
    transition: text-decoration-color 0.2s ease, opacity 0.2s ease;
}

.job-market-link:hover {
    opacity: 0.85;
    text-decoration-color: rgba(204, 0, 51, 1);
    transform: translateY(-2px) scale(1.03);
}

.exit-icon {
    font-size: 1.1em;
    margin-left: 0.2em;
    transition: transform 0.2s ease-in-out;
}

.job-market-link:hover .exit-icon {
    transform: translate(2px, -2px);
}

.job-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
}

/* Dark-mode fix for expandable "read more" box: subtle, high-contrast but gentle */
html.dark #expand-content > div {
  background-color: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.06);
  color: #e5e7eb;
}

/* Hello rotation subtle animation */
#hello-rotate {
  display: inline-block;
  will-change: transform, opacity, letter-spacing;
  transition: transform 700ms cubic-bezier(.22,.9,.35,1), opacity 700ms ease, letter-spacing 700ms ease;
}
#hello-rotate.animate-out {
  opacity: 0;
  transform: translateY(-6px) scale(0.985);
  letter-spacing: 0.18em;
}
#hello-rotate.animate-in {
  opacity: 1;
  transform: translateY(0) scale(1);
  letter-spacing: normal;
}

/* Contact card */
#contact-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  margin: 0;
  border: 1px solid rgba(0,0,0,0.06);
  padding: 0.75rem 0.6rem 0.5rem;
  border-radius: 0.375rem;
  background: rgba(0,0,0,0.02);
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
  min-height: 60px;
}
#contact-card .contact-label {
    font-size: 0.9rem;
    opacity: 0.7;
    margin-bottom: 0.5rem;
}
html.dark #contact-card {
  border-color: rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
}
.contact-btn {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 0.95rem;
}
.contact-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.08);
  border-radius: 0.25rem;
}
#contact-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 18px rgba(0,0,0,0.06), 0 0 15px var(--lime-glow);
}
html.dark #contact-card:hover {
  box-shadow: 0 6px 18px rgba(255,255,255,0.03), 0 0 15px var(--lime-glow);
}

/* Copied tooltip */
.contact-tooltip {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
  font-size: 0.8rem;
  color: #065f46;
  pointer-events: none;
  visibility: hidden;
  background: #d1fae5;
  padding: 2px 8px;
  border-radius: 0.25rem;
}
html.dark .contact-tooltip { color: #86efac; background: #064e3b; }
.contact-tooltip.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  visibility: visible;
}

/* Scroll-margin for anchor links */
#publications-divider, #recognitions-divider, #music-divider {
  scroll-margin-top: 4rem;
}

/* Recognitions Section */
.recognitions-heading {
  font-family: 'Crimson Text', serif;
  font-size: 1.25rem;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  margin-top: 2rem;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}
.recognitions-heading:first-of-type {
  margin-top: 0;
}
html.dark .recognitions-heading {
  border-bottom-color: rgba(255,255,255,0.1);
}
.recognitions-list {
  list-style: none;
  padding-left: 0;
}
.recognition-item {
  padding: 0.5rem 0;
}
.animate-on-scroll {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.animate-on-scroll.is-visible {
  opacity: 1;
  transform: translateY(0);
}


/* Music divider */
.music-divider-wrapper {
  position: relative;
  height: 60px;
  margin: 0;
}
.composer-icons {
  position: relative;
  width: 100%;
  height: 100%;
}
.composer-icon {
  position: absolute;
  height: 36px;
  width: 36px;
  opacity: 0.7;
  border-radius: 50%;
  object-fit: cover;
  background-color: rgba(128,128,128,0.1);
  transition: transform 0.2s ease, opacity 0.2s ease, filter 0.3s ease;
}
.composer-icon:hover {
  transform: scale(1.5) translate(-33%, -33%);
  opacity: 1;
  z-index: 5;
  filter: drop-shadow(0 0 5px var(--lime-glow));
}
.clef-stack {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    color: var(--muted);
    opacity: 0.6;
    font-size: 24px;
    line-height: 0.8;
    font-family: serif;
}
.staff-line {
    position: absolute;
    left: 40px;
    right: 0;
    height: 1px;
    background: currentColor;
    opacity: 0.2;
}
.staff-line-top { top: 2px; }
.staff-line-bottom { bottom: 2px; }
html.dark .composer-icon, html.dark .clef-stack, html.dark .staff-line {
    opacity: 0.6;
}

/* Margarita Theme: Dividers */
.animatable-divider {
  position: relative;
}
.animatable-divider .salt-path {
  stroke-opacity: 0.25;
  transition: stroke-opacity 0.5s ease-out;
}
.animatable-divider.is-animating .salt-path {
  stroke-opacity: 0.1;
}
.lime-icon {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  opacity: 0;
  transition: left 0.5s ease-out, top 0.5s ease-out, opacity 0.5s ease-out;
}

/* New Music Player Styles */
.music-item {
  /* This is just a container now, no alignment here */
}
.music-meta {
  font-size: 0.9rem;
  color: var(--muted);
  opacity: 0.8;
  margin-top: 0.25rem;
  margin-bottom: 1rem;
}
.music-meta .meta-line-2 {
  opacity: 0.7;
  font-size: 0.85rem;
  margin-top: 0.25rem;
}
.centered-player-content {
  max-width: 640px;
  margin: 1rem auto 0;
}
.player-box {
  width: 100%;
  background: rgba(0,0,0,0.02);
  border: 1px solid rgba(0,0,0,0.05);
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
}
html.dark .player-box {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.1);
}
.vinyl-play-btn {
  position: relative;
  width: 52px;
  height: 52px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.vinyl-icon {
  width: 100%;
  height: 100%;
  color: var(--text);
  opacity: 0.7;
  transition: opacity 0.2s ease;
}
.vinyl-play-btn:hover .vinyl-icon {
  opacity: 1;
}
.vinyl-rotating .vinyl-icon {
  animation: spin 2s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.play-pause-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--bg);
  font-size: 20px;
  pointer-events: none;
}
.progress-bar-container {
  cursor: pointer;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0,0,0,0.06);
}
html.dark .progress-bar-container {
  background: rgba(255,255,255,0.06);
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--text);
  border-radius: 999px;
}
.music-expand-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.music-notes-content p {
  text-align: justify;
}

/* Margarita Theme Details: Footer */
#margarita-icon {
  color: var(--muted);
  opacity: 0.6;
}
#margarita-icon img {
  width: 1.1rem;
  height: 1.1rem;
  vertical-align: -0.2em;
}
#margarita-icon:hover {
  opacity: 1;
}
#margarita-icon:hover img {
  animation: cheers 0.6s ease-in-out;
}
@keyframes cheers {
  0% { transform: rotate(0deg); }
  33% { transform: rotate(-15deg); }
  66% { transform: rotate(10deg); }
  100% { transform: rotate(0deg); }
}

/* Headings */
h2 {
  font-size: 2rem;
}
/* Small responsiveness */
@media (max-width: 768px) {
  #contact-card { width: 80%; }
  .music-divider-line { width: 30%; }
  h2 { font-size: 1.75rem; }
}