/* 論文誌風: セリフ体、Monokai由来の配色、左に固定した名前とナビ、右に本文
   --accent はリンク、--mark は現在ページの印と What's new の罫線 */

:root {
  --bg: #fbfaf3;
  --bg-side: #f2f1e6;
  --fg: #272822;
  --muted: #75715e;
  --accent: #0e8ba3;
  --mark: #e0246a;
  --rule: #dcdccf;
  --grain: 0.05;
  --serif: "Newsreader", "Shippori Mincho", Georgia, "Hiragino Mincho ProN",
    "Yu Mincho", YuMincho, "Noto Serif JP", serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #272822;
    --bg-side: #1e1f1a;
    --fg: #f8f8f2;
    --muted: #a29e88;
    --accent: #66d9ef;
    --mark: #f92672;
    --rule: #3e3d32;
    --grain: 0.07;
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.65;
  font-optical-sizing: auto;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
}

/* 紙の質感 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.3  0 0 0 0 0.25  0 0 0 0 0.2  0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* 骨格: 左 17rem の固定サイドバー、右は残り全幅 */
.wrap {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 17rem minmax(0, 1fr);
  min-height: 100vh;
}

header.site {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
  padding: 3.25rem 2rem 2.5rem;
  background: var(--bg-side);
  border-right: 1px solid var(--rule);
}

.site-name {
  display: block;
  font-size: 1.7rem;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
}

.site-kana {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  letter-spacing: 0.18em;
  color: var(--muted);
}

/* 名前の下の肩書きと所属 */
.site-tagline {
  margin: 1rem 0 0;
  font-size: 0.88rem;
  line-height: 1.5;
  font-style: italic;
  color: var(--muted);
}

nav {
  margin-top: 2.2rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--rule);
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

nav li { margin: 0; }

nav a {
  position: relative;
  display: inline-block;
  padding-left: 1.5rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

nav a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 0;
  height: 1px;
  background: var(--mark);
  transition: width 0.25s ease;
}

nav a:hover { color: var(--fg); }
nav a:hover::before { width: 0.6rem; }

nav a[aria-current="page"] { color: var(--fg); }
nav a[aria-current="page"]::before { width: 1rem; }

main {
  overflow-wrap: anywhere;
  padding: 3.6rem clamp(2rem, 5vw, 6rem) 4rem;
}

/* リンク: 本文と同じ黒に、細い下線だけ差し色 */
a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
  text-underline-offset: 0.2em;
  transition: text-decoration-color 0.2s ease;
}

a:hover { text-decoration-color: var(--accent); }

/* 見出し: h1 は大きな明朝、h2 は小さな大文字のラベルと右へ伸びる罫線 */
h1 {
  font-size: clamp(2rem, 3.2vw, 2.6rem);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin: 0 0 1.4rem;
}

h1 span[lang="ja"] {
  font-size: 0.6em;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-left: 0.4em;
}

h2 {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 2.8rem 0 1rem;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

h2::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

h2:lang(ja) {
  font-size: 0.92rem;
  letter-spacing: 0.12em;
  text-transform: none;
}

h3 {
  font-size: 1.05rem;
  font-weight: 500;
  margin: 1.6rem 0 0.5rem;
}

p { margin: 0 0 1rem; }

/* Home の名前の下に置く業績プロフィールへのリンク */
.profiles {
  margin-top: -0.4rem;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* 箇条書き */
ul, ol { padding-left: 1.5rem; margin: 0 0 1rem; }

li { margin-bottom: 0.4rem; }

li::marker {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.entries { padding-left: 2.1rem; }

.entries li {
  margin-bottom: 1.1rem;
  padding-left: 0.2rem;
}

/* Home の Interest と Keywords を広い画面では横に並べる */
.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  column-gap: 3.5rem;
}

.two-col section > h2 { margin-top: 2.8rem; }

/* What's new: 枠の中でスクロール */
.news {
  max-height: 16rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
  margin: 0 0 1rem;
  padding: 0.9rem 1.2rem 0.9rem 2.6rem;
  border-left: 2px solid var(--mark);
  background: color-mix(in srgb, var(--fg) 4%, transparent);
}

.news li { margin-bottom: 0.45rem; }

.news:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Research の Short bio: 引用の体裁 */
blockquote.bio {
  margin: 0 0 1rem;
  padding: 0.2rem 0 0.2rem 1.4rem;
  border-left: 2px solid var(--rule);
}

blockquote.bio p { margin: 0; }

/* Talks の直近の予定 */
.upcoming { border-left: 2px solid var(--mark); padding-left: 1.2rem; }

.muted, .note { color: var(--muted); }

.note { font-size: 0.9rem; }

.ovl { text-decoration: overline; }

/* 連絡先 */
dl.contact {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1.6rem;
  margin: 0;
}

dl.contact dt {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding-top: 0.3rem;
}

dl.contact dd { margin: 0; }

footer {
  grid-column: 2;
  margin: 0 clamp(2rem, 5vw, 6rem);
  padding: 1rem 0 2rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

/* 読み込み時に本文が下から静かに現れる */
@media (prefers-reduced-motion: no-preference) {
  main > * {
    animation: rise 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }
  main > :nth-child(2) { animation-delay: 0.06s; }
  main > :nth-child(3) { animation-delay: 0.12s; }
  main > :nth-child(4) { animation-delay: 0.18s; }
  main > :nth-child(5) { animation-delay: 0.24s; }
  main > :nth-child(6) { animation-delay: 0.3s; }
  main > :nth-child(n + 7) { animation-delay: 0.36s; }

  @keyframes rise {
    from { opacity: 0; transform: translateY(0.6rem); }
    to { opacity: 1; transform: none; }
  }
}

/* 狭い画面: サイドバーを上に畳み、ナビは横並び */
@media (max-width: 48rem) {
  .wrap { display: block; }

  header.site {
    position: static;
    min-height: 0;
    max-height: none;
    padding: 1.6rem 1.25rem 1.2rem;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .site-name { font-size: 1.45rem; }

  nav {
    margin-top: 1.1rem;
    padding-top: 0.9rem;
  }

  nav ul {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.3rem 1.4rem;
  }

  nav a { padding-left: 0; }
  nav a::before { display: none; }
  nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 0.3em; }

  main { padding: 2rem 1.25rem 2.5rem; }

  footer { margin: 0 1.25rem; }

  dl.contact { grid-template-columns: 1fr; gap: 0.15rem; }
  dl.contact dt { padding-top: 0.5rem; }
  dl.contact dd { margin-bottom: 0.3rem; }
}
