/* ==============================
   Academic Website — Minimal Dark/Light
   ============================== */

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

:root {
  --bg:          #fafafa;
  --bg-alt:     #f0f0f0;
  --fg:         #1a1a1a;
  --fg-muted:   #555;
  --accent:     #2563eb;
  --accent-hover: #1d4ed8;
  --border:     #ddd;
  --card-bg:    #fff;
  --code-bg:    #f4f4f5;
  --dash-color: rgba(85,85,85,.45);

  --font-stack: "Source Sans 3", "Noto Sans JP", sans-serif;
  --font-mono:  "Source Code Pro", "SF Mono", "Fira Code", "Consolas", monospace;
  --max-width:  720px;
  --space:      1.5rem;
}

[data-theme="dark"] {
  --bg:          #111;
  --bg-alt:     #1a1a1a;
  --fg:         #e5e5e5;
  --fg-muted:   #999;
  --accent:     #60a5fa;
  --accent-hover: #93c5fd;
  --border:     #333;
  --card-bg:    #1a1a1a;
  --code-bg:    #1e1e20;
  --dash-color: rgba(153,153,153,.55);
}

/* --- Base --- */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
  font-size: 17px;
}

body {
  font-family: var(--font-stack);
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  text-autospace: normal;
  hyphens: auto;
  hyphenate-limit-chars: 8 3 3;
  transition: background .25s, color .25s;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color .2s;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* --- Navigation --- */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: baseline;
  gap: var(--space);
  padding: .6rem max(1.5rem, calc((100% - var(--max-width)) / 2 + 1.5rem));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-name {
  font-weight: 600;
  font-size: 1.15rem;
  white-space: nowrap;
  padding-top: 2px;
}

.nav-links {
  display: flex;
  gap: 1.2rem;
  flex: 1;
}

.nav-links a {
  font-size: .95rem;
  color: var(--fg-muted);
  font-weight: 500;
  white-space: nowrap;
}
.nav-links a:hover {
  color: var(--accent);
  text-decoration: none;
}

/* --- Nav buttons (theme toggle & hamburger) --- */
/* Visual base shared */
#menu-toggle,
#theme-toggle {
  font-family: inherit;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .35rem .55rem;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--fg-muted);
  transition: background .2s;
  align-items: center;
  justify-content: center;
  align-self: center;
}
#menu-toggle:hover,
#theme-toggle:hover {
  background: var(--bg-alt);
}
#theme-toggle {
  display: flex;
}
#menu-toggle .icon,
#theme-toggle .icon {
  width: 1.1em;
  height: 1.1em;
}
/* Show moon in light mode, sun in dark mode */
[data-theme="light"] .icon-moon { display: inline; }
[data-theme="light"] .icon-sun  { display: none; }
[data-theme="dark"]  .icon-moon { display: none; }
[data-theme="dark"]  .icon-sun  { display: inline; }

/* Hamburger: hidden on desktop */
#menu-toggle {
  display: none;
}
/* When open: hide hamburger, show X */
#menu-toggle .icon-menu { display: inline; }
#menu-toggle .icon-x    { display: none; }
#menu-toggle[aria-expanded="true"] .icon-menu { display: none; }
#menu-toggle[aria-expanded="true"] .icon-x    { display: inline; }

/* --- Main Content --- */
main {
  max-width: var(--max-width);
  margin: 4rem auto 0;
  padding: 0 1.5rem;
}

section {
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
}
section:last-of-type {
  border-bottom: none;
}

h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.4;
  margin-bottom: .3rem;
}

h2 {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  letter-spacing: -.01em;
  display: flex;
  align-items: center;
  gap: .5rem;
}
h2::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 1.2em;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 1.5rem 0 .6rem;
}

/* --- About Section --- */
.subtitle {
  font-size: 1.05rem;
  color: var(--fg-muted);
  margin-bottom: .2rem;
}
.affiliation {
  font-size: .95rem;
  color: var(--fg-muted);
  margin-bottom: .4rem;
}

.contact {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem 1.5rem;
  margin-bottom: .9rem;
  font-size: .92rem;
}
.contact a,
.inline-link {
  color: var(--fg);
  text-decoration: none;
  background-image: linear-gradient(90deg, var(--dash-color) 60%, transparent 60%);
  background-repeat: repeat-x;
  background-size: 5px 1px;
  background-position: 0 calc(100% - 2px);
  padding-bottom: 0;
  transition: color .2s;
}
.contact a:hover,
.inline-link:hover {
  color: var(--accent);
  text-decoration: none;
  background-image: linear-gradient(90deg, var(--accent) 60%, transparent 60%);
}

.contact .icon {
  height: 1.2em;
  vertical-align: -0.25em;
}

.research-areas {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: .7rem;
}
.tag {
  display: inline-block;
  padding: .2rem .65rem;
  font-size: .82rem;
  font-weight: 500;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--fg-muted);
}

.bio {
  color: var(--fg-muted);
  font-size: .95rem;
  line-height: 1.8;
}

/* --- Publications --- */
.pub-list, .talk-list {
  list-style: none;
}

.pub-item, .talk-item {
  padding: 1.2rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.pub-item:last-of-type,
.talk-item:last-of-type {
  border-bottom: none;
}

.pub-item:first-child, .talk-item:first-child {
  padding-top: 0;
}

.pub-title, .talk-title {
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1.5;
}
.pub-title-link,
.talk-title-link {
  color: inherit;
  text-decoration: none;
}
.pub-title-link:hover,
.talk-title-link:hover {
  color: var(--accent);
  text-decoration: none;
}
.talk-lang {
  font-size: .85em;
  font-weight: 400;
  color: var(--fg-muted);
}

.talk-title-en {
  display: block;
  font-weight: 400;
  font-size: .85em;
  color: var(--fg-muted);
  margin-top: .15em;
  padding-bottom: .15rem;
}



.pub-authors {
  font-size: .9rem;
  color: var(--fg-muted);
}

.pub-venue {
  font-size: .88rem;
  color: var(--fg-muted);
  font-style: italic;
}

.talk-event {
  font-size: .9rem;
  color: var(--fg-muted);
}
.talk-event a.inline-link {
  color: inherit;
}
.talk-event a.inline-link:hover {
  color: var(--accent);
}

.pub-links, .talk-links {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-top: .5rem;
}

.pub-btn-row, .talk-btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: .25em;
  padding: .35rem .7rem;
  font-size: .82rem;
  line-height: 1.3;
  min-height: 1.75rem;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--fg);
  transition: all .2s;
}
.btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  text-decoration: none;
}
.btn .icon {
  width: 1.2em;
  height: 1.2em;
  margin-right: .15em;
  color: var(--fg-muted);
}
.btn:hover .icon {
  color: #fff;
}

/* BibTeX Toggle */
.bibtex-btn {
  cursor: pointer;
}
.bibtex-btn--active {
  background: var(--bg-alt);
  border-color: var(--accent);
  color: var(--accent);
}

.bibtex-content {
  display: none;
  margin-top: .5rem;
  position: relative;
}
.bibtex-content.bibtex-open {
  display: block;
}

.bibtex-copy-btn {
  position: absolute;
  top: .4rem;
  right: .4rem;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  cursor: pointer;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--fg-muted);
  opacity: .65;
  transition: opacity .15s, color .15s;
}
.bibtex-copy-btn:hover {
  color: var(--fg);
  opacity: 1;
}
.bibtex-copy-btn .icon {
  width: 1em;
  height: 1em;
}

.bibtex-content pre {
  padding: .8rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: .8rem;
  line-height: 1.5;
  color: var(--fg);
}
.bibtex-content pre code {
  font-family: inherit;
}
 
/* --- CV --- */
.cv-list {
  list-style: none;
}
.cv-list li {
  display: flex;
  gap: .8rem;
  padding: .5rem 0;
  font-size: .93rem;
  line-height: 1.5;
}
.cv-list li:first-child {
  padding-top: 0;
}
#cv h3:first-of-type {
  margin-top: 0;
}
.cv-date {
  flex-shrink: 0;
  min-width: 9em;
  font-weight: 500;
  color: var(--accent);
  font-size: .88rem;
}
.cv-desc {
  color: var(--fg);
}
.cv-note {
  display: block;
  font-size: .8em;
  color: var(--fg-muted);
  font-style: italic;
}

/* --- Detail page meta (author, event) --- */
.pub-meta {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  margin-bottom: .5rem;
}

/* --- Footer --- */
footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  text-align: center;
  font-size: .85rem;
  color: var(--fg-muted);
}

/* --- Detail pages (pub & talk) --- */
.pub-detail { padding: 1.5rem 0; }
.pub-detail h1 {
  font-size: 1.5rem;
  line-height: 1.4;
  margin-bottom: .25rem;
}
.pub-detail .back-link,
.talk-detail .back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-size: .9rem;
  background-position: 0 calc(100% - 4px);
}

.talk-detail { padding: 1.5rem 0; }
.talk-detail h1 .talk-title-en {
  display: block;
  margin-top: .3rem;
}
.talk-detail h1 {
  font-size: 1.5rem;
  line-height: 1.4;
  margin-bottom: .25rem;
}

/* --- Abstract block (shared across pub & talk detail pages) --- */
.pub-abstract {
  margin: 1.5rem 0;
  line-height: 1.6;
  font-size: .95rem;
  color: var(--fg);
}
.pub-abstract p {
  margin: 1em 0;
  text-indent: 0;
}
.pub-abstract .katex {
  font-size: 1em;
}
.pub-abstract h3 {
  margin-bottom: .3rem;
}
.pub-abstract p:first-of-type {
  margin-top: 0;
}

/* --- Responsive --- */
@media (max-width: 500px) {
  .site-nav {
    padding: .6rem 1.5rem;
    flex-wrap: wrap;
    gap: .4rem;
  }
  /* Dropdown menu: fixed popup on mobile */
  .nav-links {
    position: fixed;
    top: 54px;
    right: 1.5rem;
    z-index: 200;
    flex-direction: column;
    align-items: flex-start;
    gap: .25rem;
    min-width: 130px;
    padding: .6rem .8rem .6rem 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
  }
  .nav-links.nav-open {
    opacity: 1;
    visibility: visible;
  }
  /* Hamburger visible on mobile */
  #menu-toggle {
    display: flex;
    order: 1;
  }
  #menu-toggle,
#theme-toggle {
    order: 2;
  }
  .nav-name {
    order: 0;
    margin-right: auto;
  }
  h1 { font-size: 1.7rem; }
  .cv-list li {
    flex-direction: column;
    gap: .1rem;
  }
  .cv-date { min-width: auto; }
}
