/* ===== Design tokens ===== */
:root {
  --bg: #ffffff;
  --bg-alt: #f6f6f4;
  --surface: #ffffff;         /* cards / dropdowns */
  --header-bg: rgba(255,255,255,.82);
  --ink: #14140f;
  --ink-soft: #55554d;
  --ink-faint: #8a8a80;
  --line: #e6e6e0;
  --accent: #c8503c;      /* warm terracotta */
  --accent-soft: #f3e4df;
  --shadow: rgba(20,20,15,.09);
  --max: 1120px;
  --pad: clamp(20px, 5vw, 64px);
  --radius: 14px;
  --font-jp: "Noto Sans JP", "Inter", system-ui, sans-serif;
  --font-en: "Inter", "Noto Sans JP", system-ui, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #141412;
  --bg-alt: #1e1e1b;
  --surface: #1c1c19;
  --header-bg: rgba(20,20,18,.82);
  --ink: #f2f1ec;
  --ink-soft: #bdbcb3;
  --ink-faint: #8a897f;
  --line: #302f2a;
  --accent: #e0715c;
  --accent-soft: #3a2420;
  --shadow: rgba(0,0,0,.45);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  font-family: var(--font-jp);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .3s ease, color .3s ease;
}
a { color: inherit; text-decoration: none; }
strong { color: var(--accent); font-weight: 600; }
.ext { font-size: .72em; vertical-align: super; opacity: .7; margin-left: 1px; }

/* ===== Header ===== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--pad);
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  gap: 20px;
}
.brand {
  display: flex; align-items: baseline; gap: 9px; white-space: nowrap;
  position: absolute; left: var(--pad); top: 50%;
  transform: translateY(-50%);
  opacity: 0; pointer-events: none;
  transition: opacity .35s ease;
}
.site-header.scrolled .brand { opacity: 1; pointer-events: auto; }
.brand-jp { font-weight: 700; font-size: 1.02rem; letter-spacing: .02em; }
.brand-en {
  font-family: var(--font-en);
  font-size: .72rem;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(14px, 1.8vw, 26px);
  font-size: .85rem;
  font-weight: 500;
}
.nav-links a {
  color: var(--ink-soft);
  position: relative;
  transition: color .2s;
  white-space: nowrap;
}
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0; bottom: -6px;
  width: 0; height: 2px;
  background: var(--accent);
  transition: width .25s ease;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a:hover::after { width: 100%; }
.nav-links a.active { color: var(--ink); }
.nav-links a.active::after { width: 100%; }

/* Dropdown nav (sakana-style) */
.nav-item { position: relative; display: inline-flex; align-items: center; }
.caret { font-size: .58em; margin-left: 5px; opacity: .55; }
.dropdown {
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  padding-top: 14px; /* hover bridge */
  opacity: 0; visibility: hidden;
  transition: opacity .18s ease;
  z-index: 60;
}
.nav-item:hover .dropdown,
.nav-item:focus-within .dropdown { opacity: 1; visibility: visible; }
.dropdown-inner {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 14px 34px var(--shadow);
  padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 200px;
}
.dropdown a {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .85rem;
  color: var(--ink-soft);
  white-space: nowrap;
}
.dropdown a::after { display: none; }
.dropdown a:hover { background: var(--bg-alt); color: var(--ink); }
.dropdown a.active { color: var(--accent); }

.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px; height: 40px;
  background: none; border: none; cursor: pointer;
}
.nav-toggle span {
  display: block; height: 2px; width: 22px;
  background: var(--ink); border-radius: 2px;
  transition: transform .3s, opacity .3s;
}

/* ===== Theme toggle ===== */
.theme-toggle {
  position: absolute;
  right: var(--pad);
  top: 50%;
  transform: translateY(-50%);
  width: 38px; height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.theme-toggle .icon-moon { display: block; fill: currentColor; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ===== Hero ===== */
.hero {
  min-height: calc(100vh - 66px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(48px, 10vw, 96px) var(--pad);
  text-align: center;
}
.hero-inner { max-width: 900px; }
.hero-name {
  font-size: clamp(3rem, 13vw, 8rem);
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.05;
}
.hero-reading {
  font-family: var(--font-en);
  font-size: clamp(.85rem, 2vw, 1.05rem);
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 22px;
  padding-left: .32em; /* offset last-letter tracking */
}
.hero-footer {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px var(--pad);
}
.hf-left {
  font-family: var(--font-en);
  font-size: .78rem;
  color: var(--ink-faint);
  letter-spacing: .02em;
}
.hf-social { display: flex; align-items: center; gap: 16px; }
.hf-social a {
  display: inline-flex;
  color: var(--ink-faint);
  transition: color .2s, transform .2s;
}
.hf-social a:hover { color: var(--accent); transform: translateY(-2px); }
.hf-social svg { width: 18px; height: 18px; fill: currentColor; }

/* ===== Sub-page layout ===== */
.page {
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(44px, 7vw, 84px) var(--pad) clamp(64px, 10vw, 112px);
}
.page-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: clamp(34px, 5vw, 52px);
  padding-bottom: 26px;
  border-bottom: 1px solid var(--line);
}
.page-num {
  font-family: var(--font-en);
  font-size: .85rem; font-weight: 600;
  letter-spacing: .12em;
  color: var(--accent);
}
.page-head h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 700;
  letter-spacing: .01em;
}

/* ===== Sections (legacy single-page blocks) ===== */
.section {
  padding: clamp(56px, 9vw, 104px) var(--pad);
}
.section > * { max-width: var(--max); margin-left: auto; margin-right: auto; }
.section.alt { background: var(--bg-alt); }
.section-head {
  display: flex; align-items: baseline; gap: 18px;
  margin-bottom: 44px;
}
.section-num {
  font-family: var(--font-en);
  font-size: .82rem; font-weight: 600;
  letter-spacing: .12em;
  color: var(--accent);
  padding-top: 6px;
}
.section-head h2 {
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: .01em;
}
.section-intro {
  font-size: clamp(1.02rem, 1.5vw, 1.15rem);
  color: var(--ink-soft);
  max-width: none;      /* 下の4カードと同じ幅に揃える */
  margin-bottom: 44px;
}

/* Prose (plain body text — About me) */
.prose { max-width: none; }   /* 見出し下の横線と同じ幅に */
.prose p {
  margin-bottom: 22px;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.4vw, 1.08rem);
}
.prose p:last-child { margin-bottom: 0; }

/* About */
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(28px, 5vw, 64px); }
.about-lead .big {
  font-size: clamp(1.3rem, 2.6vw, 1.9rem);
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: .01em;
}
.about-text p { color: var(--ink-soft); margin-bottom: 18px; }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 9px; margin-top: 22px; }
.chips li {
  font-size: .8rem;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-soft);
  background: var(--surface);
}

/* Timeline */
.timeline { list-style: none; position: relative; }
.timeline::before {
  content: ""; position: absolute;
  left: 118px; top: 8px; bottom: 8px;
  width: 1px; background: var(--line);
}
.timeline li { display: grid; grid-template-columns: 118px 1fr; gap: 34px; padding: 20px 0; position: relative; }
.tl-year {
  font-family: var(--font-en);
  font-weight: 600; font-size: .95rem;
  color: var(--ink); text-align: right;
  padding-right: 4px; padding-top: 2px;
}
.tl-body { position: relative; padding-left: 30px; }
.tl-body::before {
  content: ""; position: absolute;
  left: -8px; top: 9px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--bg-alt);
}
.tl-body h3 { font-size: 1.08rem; font-weight: 600; margin-bottom: 6px; }
.tl-body p { color: var(--ink-soft); font-size: .95rem; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 26px;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.card:hover { transform: translateY(-4px); box-shadow: 0 14px 30px var(--shadow); border-color: var(--ink-faint); }
.card h3 { font-size: 1.12rem; font-weight: 600; margin-bottom: 10px; }
.card p { color: var(--ink-soft); font-size: .93rem; margin-bottom: 16px; }
.card-tag {
  display: inline-block;
  font-family: var(--font-en);
  font-size: .72rem; letter-spacing: .06em;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 11px; border-radius: 999px;
}
.research-links { margin-top: 34px; color: var(--ink-soft); font-size: .95rem; }
.research-links a { color: var(--accent); font-weight: 600; }
.research-links a:hover { text-decoration: underline; }

/* Activities */
.activities { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.activity {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 30px 28px;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.activity:hover { transform: translateY(-4px); box-shadow: 0 14px 30px var(--shadow); border-color: var(--accent); }
.activity h3 { font-size: 1.15rem; font-weight: 600; margin-bottom: 6px; }
.activity .role {
  font-family: var(--font-en);
  font-size: .76rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin-bottom: 12px;
}
.activity p:last-child { color: var(--ink-soft); font-size: .93rem; }

/* ===== Footer (sakana-style minimal bar) ===== */
.site-footer {
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px var(--pad);
}

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .nav-inner { justify-content: flex-start; }
  .brand { position: static; transform: none; opacity: 1; pointer-events: auto; }
  .nav-toggle { display: flex; position: absolute; right: var(--pad); top: 50%; transform: translateY(-50%); }
  .theme-toggle { right: calc(var(--pad) + 50px); }
  .nav-links {
    position: fixed;
    top: 66px; left: 0; right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 8px var(--pad) 20px;
    transform: translateY(-8px);
    opacity: 0; pointer-events: none;
    transition: opacity .22s, transform .22s;
    max-height: calc(100vh - 66px);
    overflow-y: auto;
  }
  .nav-links.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
  .nav-links a { width: 100%; padding: 13px 0; border-bottom: 1px solid var(--line); font-size: .95rem; }
  .nav-links a::after { display: none; }
  /* Dropdowns become static, indented lists on mobile */
  .nav-item { display: block; width: 100%; }
  .caret { display: none; }
  .dropdown {
    position: static; transform: none;
    opacity: 1; visibility: visible;
    padding-top: 0;
  }
  .dropdown-inner {
    background: transparent; border: none; box-shadow: none;
    padding: 0 0 0 16px; min-width: 0; gap: 0;
  }
  .dropdown a {
    width: 100%; padding: 12px 0; border-radius: 0;
    border-bottom: 1px solid var(--line);
    font-size: .9rem;
  }
  .about-grid { grid-template-columns: 1fr; }
  .cards, .activities { grid-template-columns: 1fr; }
  .timeline::before { display: none; }
  .timeline li { grid-template-columns: 1fr; gap: 4px; padding: 14px 0; }
  .tl-year { text-align: left; color: var(--accent); font-size: .82rem; letter-spacing: .1em; }
  .tl-body { padding-left: 0; }
  .tl-body::before { display: none; }
}
