/*
 * site.css: styles for the homepage (index.html).
 * The project subpages still use assets/css/main.css; leave that file alone.
 *
 * Themes: no data-theme attribute = follow the OS (prefers-color-scheme).
 * data-theme="light" / "dark" on <html> forces a theme (set by assets/js/theme.js).
 *
 * Text size: data-text-size="large" / "larger" on <html> scales the page text via
 * --text-scale. The top bar and the Display panel keep a fixed size on purpose.
 */

/* ---------- Text size ---------- */
:root {
  --text-scale: 1;
}

:root[data-text-size="large"] {
  --text-scale: 1.125;
}

:root[data-text-size="larger"] {
  --text-scale: 1.25;
}

/* ---------- Color tokens ---------- */
:root {
  --bg: #fbfbfa;
  --text: #1d1d1f;
  --muted: #5f6368;
  --border: #e6e6e3;
  --accent: #1f5fbf;
  --accent-soft: #eaf1fb;
  --thumb-bg: #ffffff; /* thumbnails are transparent PNGs; keep them on white in both themes */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131416;
    --text: #e8e8e6;
    --muted: #a0a4ab;
    --border: #2a2c30;
    --accent: #8ab4f8;
    --accent-soft: #1c2a40;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #131416;
  --text: #e8e8e6;
  --muted: #a0a4ab;
  --border: #2a2c30;
  --accent: #8ab4f8;
  --accent-soft: #1c2a40;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  /* Keep anchor targets clear of the sticky top bar. */
  scroll-padding-top: 72px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: calc(16.5px * var(--text-scale));
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

p {
  margin: 0 0 1em;
}

a {
  color: var(--accent);
  text-decoration: none;
  text-underline-offset: 2px;
}

a:hover,
a:focus-visible {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

strong,
b {
  font-weight: 600;
}

img {
  max-width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  z-index: 30;
}

.skip-link:focus {
  top: 12px;
}

/* ---------- Top bar (section links + Display) ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  font-size: 14px; /* fixed: the bar doesn't follow the Text size setting */
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px;
}

.section-nav {
  flex: 1;
  min-width: 0;
}

/* Scrolls sideways if the links don't fit (phones). */
.section-nav ul {
  position: relative;
  display: flex;
  gap: 8px;
  margin: 0 -5px;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: none;
}

.section-nav ul::-webkit-scrollbar {
  display: none;
}

/* Set by nav.js when the links don't fit: fade the right edge as a scroll hint. */
.section-nav ul.is-overflowing {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
}

.section-nav ul.is-overflowing li:last-child {
  padding-right: 22px;
}

.section-nav a {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  padding: 14px 5px;
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}

/* Reserves the semibold width so the row doesn't shift when the active link changes. */
.section-nav a::before {
  content: attr(data-label);
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-weight: 600;
}

.section-nav a:hover,
.section-nav a:focus-visible {
  color: var(--accent);
  text-decoration: none;
}

.section-nav a:focus-visible {
  outline-offset: -2px;
}

.section-nav a[aria-current="location"] {
  color: var(--accent);
  font-weight: 600;
}

.section-nav a[aria-current="location"]::after {
  content: "";
  position: absolute;
  left: 5px;
  bottom: 7px;
  width: 28px;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}

/* ---------- Page layout ---------- */
.page {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 24px 48px;
}

section {
  margin-top: 52px;
}

h1,
h2,
h3,
h4 {
  font-weight: 600;
  line-height: 1.3;
  margin: 0;
}

.section-title {
  font-size: calc(20px * var(--text-scale));
  padding-bottom: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.year {
  font-size: calc(15px * var(--text-scale));
  color: var(--muted);
  margin: 28px 0 14px;
}

.section-title + .year {
  margin-top: 0;
}

/* ---------- Header ---------- */
.intro {
  display: flex;
  align-items: center;
  gap: 28px;
}

/* Crops images/avatar.jpg (420x575 portrait) to head and shoulders.
   If you replace the photo, adjust the width and margins below. */
/* Photo size: matches the height of the name + role + email + icon block on desktop. */
.avatar {
  --avatar-size: 136px;
  flex: none;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--border);
}

.avatar img {
  display: block;
  /* crop scales with the circle (tuned at 120px: 180px wide, -13px top, -39px left) */
  width: calc(var(--avatar-size) * 1.5);
  max-width: none;
  height: auto;
  margin: calc(var(--avatar-size) * -0.1083) 0 0 calc(var(--avatar-size) * -0.325);
}

.name {
  font-size: calc(30px * var(--text-scale));
  letter-spacing: -0.01em;
}

.role {
  margin: 2px 0 0;
  color: var(--muted);
}

.email {
  margin: 0 0 14px;
  font-size: calc(15px * var(--text-scale));
}

/* Round icon buttons (CV, Email, Scholar, ...) */
.icon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.icon-row a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
}

.icon-row a:hover,
.icon-row a:focus-visible {
  text-decoration: none;
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent-soft);
}

.icon-row a:focus-visible {
  border-radius: 50%;
}

/* Academicons glyphs are drawn smaller than Font Awesome ones; even them out. */
.icon-row .ai {
  font-size: 22px;
}

.icon-row .secondary {
  color: var(--muted);
}

.icon-row .gap {
  margin-left: 8px;
}

/* ---------- Display (theme) popover ---------- */
.display {
  position: relative;
  flex: none;
}

.display-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.display-toggle:hover,
.display-toggle[aria-expanded="true"] {
  color: var(--text);
  border-color: var(--muted);
}

.display-toggle .aa {
  font-weight: 600;
  color: var(--text);
}

.display-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 252px;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  z-index: 5;
}

.display-panel[hidden] {
  display: none;
}

.display-panel fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.display-panel fieldset + fieldset {
  margin-top: 14px;
}

.display-panel legend {
  padding: 0;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
}

.segmented {
  display: flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.segmented input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
}

.segmented label {
  flex: 1;
  padding: 5px 0;
  border-radius: 6px;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}

.segmented label:hover {
  color: var(--text);
}

.segmented input:checked + label {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.segmented input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.display-note {
  margin: 8px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

/* ---------- Publications ---------- */
.pub-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.pub {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 18px;
  align-items: start;
  margin-bottom: 24px;
}

.pub:target,
.pub-compact:target {
  background: var(--accent-soft);
  box-shadow: 0 0 0 10px var(--accent-soft);
  border-radius: 6px;
}

.pub-thumb {
  display: block;
  width: 128px;
  height: 96px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--thumb-bg);
}

/* Placeholder tile for papers without an image.
   To use a real image, replace the <div class="pub-thumb pub-thumb--placeholder">
   with <img class="pub-thumb" src="images/pubs/....png" alt="..."> */
.pub-thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  line-height: 1.25;
}

.pub-title {
  font-size: calc(16.5px * var(--text-scale));
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 3px;
}

.pub-title a {
  color: inherit;
}

.pub-title a:hover,
.pub-title a:focus-visible {
  color: var(--accent);
}

.pub-authors,
.pub-venue,
.pub-summary,
.pub-note {
  margin: 0 0 3px;
}

.pub-authors {
  font-size: calc(15px * var(--text-scale));
}

.pub-authors strong {
  font-weight: 600;
}

.pub-venue {
  font-size: calc(14.5px * var(--text-scale));
  color: var(--muted);
}

.venue-pill {
  display: inline-block;
  margin-right: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: calc(12px * var(--text-scale));
  font-weight: 600;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: 1px;
}

/* Award label (e.g. "Best Explainability Award"): bold text, no colored background */
.pub-award {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 4px;
  color: var(--text);
  font-size: calc(13px * var(--text-scale));
  font-weight: 600;
  line-height: 1.6;
}


.pub-note {
  font-size: calc(13px * var(--text-scale));
  color: var(--muted);
}

.pub-summary {
  margin-top: 6px;
  font-size: calc(15px * var(--text-scale));
  color: var(--muted);
}

.pub-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.pub-links a {
  display: inline-block;
  padding: 1px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: calc(13px * var(--text-scale));
  font-weight: 600;
  line-height: 1.7;
}

.pub-links a:hover,
.pub-links a:focus-visible {
  text-decoration: none;
  border-color: var(--accent);
}

/* Selected publications: larger entries */
.pub--selected {
  grid-template-columns: 200px 1fr;
  gap: 22px;
  margin-bottom: 32px;
}

.pub--selected .pub-thumb {
  width: 200px;
  height: 150px;
}

.pub--selected .pub-thumb--placeholder {
  font-size: 18px;
}

.pub--selected .pub-title {
  font-size: calc(17.5px * var(--text-scale));
}

/* Compact entries (preprints, domestic, thesis) */
.pub-compact {
  margin-bottom: 16px;
}

.pub-compact .pub-title {
  font-size: calc(15.5px * var(--text-scale));
}

.pub-compact .pub-authors {
  font-size: calc(14.5px * var(--text-scale));
}

/* Inline link pills after a line of text (compact entries, talks) */
span.pub-links {
  display: inline-flex;
  margin: 0 0 0 4px;
  vertical-align: 1px;
}

span.pub-links a {
  font-size: calc(12px * var(--text-scale));
  padding: 0 8px;
}

/* Fireworks emoji before the interns call-out (decorative) */
.hanabi {
  margin-right: 6px;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 1.15em;
  line-height: 1;
}

/* Summary citations */
.cite {
  white-space: nowrap;
}

/* ---------- Talks ---------- */
.plain-list {
  margin: 0;
  padding-left: 1.2em;
}

.plain-list li {
  margin-bottom: 10px;
  padding-left: 2px;
}

.plain-list li::marker {
  color: var(--muted);
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 64px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: calc(14px * var(--text-scale));
  color: var(--muted);
}

/* ---------- Small screens ---------- */
@media (max-width: 600px) {
  .page {
    padding: 28px 16px 40px;
  }

  .topbar-inner {
    padding: 0 16px;
    gap: 8px;
  }

  /* Button shows just "Aa"; "Display" stays as its accessible name. */
  .display-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }

  .intro {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .avatar {
    --avatar-size: 120px;
  }

  .name {
    font-size: calc(27px * var(--text-scale));
  }

  section {
    margin-top: 44px;
  }

  /* Regular entries: smaller thumbnail beside the text */
  .pub {
    grid-template-columns: 96px 1fr;
    gap: 14px;
  }

  .pub .pub-thumb {
    width: 96px;
    height: 72px;
  }

  .pub-thumb--placeholder {
    font-size: 12.5px;
  }

  /* Selected entries: full-width thumbnail above the text */
  .pub--selected {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .pub--selected .pub-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
  }
}
