/* ==========================================================================
   Hitoshi Matsuyama — personal site
   Tokens → base → layout → components → sections → demos → utilities
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  --paper: #f2efe7;
  --paper-2: #e9e5da;
  --surface: #fbfaf6;
  --surface-2: #f5f2ea;
  --ink: #16150f;
  --ink-2: #3a382f;
  --muted: #6c685d;
  --line: rgb(22 21 15 / 0.12);
  --line-strong: rgb(22 21 15 / 0.24);
  --accent: #e2431e;
  --accent-ink: #b5320f;
  --accent-soft: rgb(226 67 30 / 0.11);
  --ok: #157a5b;
  --ok-soft: rgb(21 122 91 / 0.12);
  --err: #d63a2a;
  --err-soft: rgb(214 58 42 / 0.12);
  --warn: #d99a00;
  --warn-soft: rgb(230 170 0 / 0.2);
  --c-jump: #e2431e;
  --c-spin: #3157c9;
  --c-step: #b07f0c;
  --c-pcs: #8a857a;
  --shadow: 0 1px 0 rgb(22 21 15 / 0.04), 0 12px 32px -12px rgb(22 21 15 / 0.18);
  --shadow-lg: 0 30px 80px -20px rgb(22 21 15 / 0.35);
  --grain-opacity: 0.05;

  --f-sans: "Geist", "Zen Kaku Gothic New", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  --f-serif: "Instrument Serif", "Shippori Mincho", "Hiragino Mincho ProN", Georgia, serif;
  --f-mincho: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --f-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --gutter: clamp(16px, 4vw, 56px);
  --maxw: 1320px;
  --header-h: 64px;
  --radius: 14px;
  --radius-sm: 8px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e0e0c;
    --paper-2: #151512;
    --surface: #171714;
    --surface-2: #1d1d19;
    --ink: #eeeadf;
    --ink-2: #cbc6b9;
    --muted: #959084;
    --line: rgb(238 234 223 / 0.11);
    --line-strong: rgb(238 234 223 / 0.22);
    --accent: #ff6a3f;
    --accent-ink: #ff8a66;
    --accent-soft: rgb(255 106 63 / 0.14);
    --ok: #4fcb9d;
    --ok-soft: rgb(79 203 157 / 0.14);
    --err: #ff6b5a;
    --err-soft: rgb(255 107 90 / 0.16);
    --warn: #f2c14e;
    --warn-soft: rgb(242 193 78 / 0.18);
    --c-jump: #ff6a3f;
    --c-spin: #7f9cff;
    --c-step: #e4b74a;
    --c-pcs: #7c776c;
    --shadow: 0 1px 0 rgb(0 0 0 / 0.2), 0 12px 32px -12px rgb(0 0 0 / 0.6);
    --shadow-lg: 0 30px 80px -20px rgb(0 0 0 / 0.8);
    --grain-opacity: 0.07;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e0e0c;
  --paper-2: #151512;
  --surface: #171714;
  --surface-2: #1d1d19;
  --ink: #eeeadf;
  --ink-2: #cbc6b9;
  --muted: #959084;
  --line: rgb(238 234 223 / 0.11);
  --line-strong: rgb(238 234 223 / 0.22);
  --accent: #ff6a3f;
  --accent-ink: #ff8a66;
  --accent-soft: rgb(255 106 63 / 0.14);
  --ok: #4fcb9d;
  --ok-soft: rgb(79 203 157 / 0.14);
  --err: #ff6b5a;
  --err-soft: rgb(255 107 90 / 0.16);
  --warn: #f2c14e;
  --warn-soft: rgb(242 193 78 / 0.18);
  --c-jump: #ff6a3f;
  --c-spin: #7f9cff;
  --c-step: #e4b74a;
  --c-pcs: #7c776c;
  --shadow: 0 1px 0 rgb(0 0 0 / 0.2), 0 12px 32px -12px rgb(0 0 0 / 0.6);
  --shadow-lg: 0 30px 80px -20px rgb(0 0 0 / 0.8);
  --grain-opacity: 0.07;
  color-scheme: dark;
}

/* ---------- Language toggle ----------
   Paired elements carry lang="en" / lang="ja"; only the active one renders.
   Always-visible Japanese text (e.g. Japanese paper titles) uses lang="ja-JP",
   which the exact-match selectors below deliberately do not hide. */
html[data-lang="en"] [lang="ja"],
html[data-lang="ja"] [lang="en"] { display: none !important; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}
body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}
html[data-lang="ja"] body { line-height: 1.85; letter-spacing: 0.02em; font-feature-settings: "palt" 1; }
:lang(ja), [lang="ja-JP"] { word-break: auto-phrase; line-break: strict; }

/* Paper grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}
:root[data-theme="dark"] body::before { mix-blend-mode: screen; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body::before { mix-blend-mode: screen; } }

img, svg, canvas, video { display: block; max-width: 100%; }
[hidden] { display: none !important; }
img { height: auto; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
ol, ul { list-style: none; padding: 0; }
em { font-style: italic; }
b, strong { font-weight: 600; }
::selection { background: var(--accent); color: #fff; }

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

.mono { font-family: var(--f-mono); font-size: 0.78rem; letter-spacing: 0.02em; font-weight: 400; }
.small { font-size: 0.72rem; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico {
  width: 1.1em; height: 1.1em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}

.skip-link {
  position: fixed; left: 16px; top: -60px; z-index: 300;
  background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px;
  text-decoration: none; transition: top 0.2s var(--ease);
}
.skip-link:focus { top: 12px; }

/* ---------- Header ---------- */
.site-header {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: var(--header-h);
  transition: background-color 0.3s var(--ease), border-color 0.3s var(--ease), backdrop-filter 0.3s;
  border-bottom: 1px solid transparent;
}
.site-header.is-elevated {
  background: color-mix(in srgb, var(--paper) 78%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom-color: var(--line);
}
.header-inner {
  height: 100%;
  max-width: calc(var(--maxw) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 500; letter-spacing: -0.01em; }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--ink); color: var(--paper);
  font-family: var(--f-serif); font-size: 1.05rem; font-style: italic; letter-spacing: -0.02em;
  transition: transform 0.5s var(--ease-out), background-color 0.3s;
}
.brand:hover .brand-mark { transform: rotate(-12deg) scale(1.06); background: var(--accent); }
.brand-name { font-size: 0.95rem; white-space: nowrap; }

.nav { margin-left: auto; }
.nav ul { display: flex; gap: 4px; }
.nav a {
  position: relative; display: flex; align-items: baseline; gap: 6px;
  padding: 8px 12px; border-radius: 999px;
  text-decoration: none; font-size: 0.9rem; color: var(--ink-2);
  transition: color 0.2s, background-color 0.2s;
}
.nav a:hover { color: var(--ink); background: var(--line); }
.nav a[aria-current="true"] { color: var(--ink); }
.nav a[aria-current="true"]::after {
  content: ""; position: absolute; left: 50%; bottom: 2px; width: 4px; height: 4px; margin-left: -2px;
  border-radius: 50%; background: var(--accent);
}
.nav-num { font-family: var(--f-mono); font-size: 0.65rem; color: var(--muted); }

.header-tools { display: flex; align-items: center; gap: 8px; }
.cmdk-btn {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 8px 0 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--muted); font-size: 0.85rem;
  transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}
.cmdk-btn:hover { color: var(--ink); border-color: var(--ink); }
.kbd {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface);
  font-family: var(--f-mono); font-size: 0.68rem; color: var(--muted); line-height: 1;
}

.seg {
  display: inline-flex; padding: 3px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface);
}
.seg button {
  height: 28px; padding: 0 12px; border-radius: 999px; font-size: 0.78rem; font-weight: 500;
  color: var(--muted); transition: background-color 0.25s var(--ease), color 0.25s;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button:not([aria-pressed="true"]):hover { color: var(--ink); }

.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line-strong); transition: border-color 0.2s, transform 0.4s var(--ease-out);
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn .ico { width: 18px; height: 18px; }
.ico-moon { display: none; }
:root[data-theme="dark"] .ico-sun { display: none; }
:root[data-theme="dark"] .ico-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ico-sun { display: none; }
  :root:not([data-theme="light"]) .ico-moon { display: block; }
}
[data-toggle-theme]:active { transform: rotate(40deg); }

.menu-btn { display: none; }
.menu-btn .ico-close { display: none; }
.menu-btn[aria-expanded="true"] .ico-open { display: none; }
.menu-btn[aria-expanded="true"] .ico-close { display: block; }

.scroll-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; pointer-events: none; }
.scroll-progress span {
  display: block; height: 100%; width: 100%; background: var(--accent);
  transform-origin: 0 50%; transform: scaleX(var(--p, 0));
}

.mobile-menu {
  position: fixed; inset: var(--header-h) 0 0 0; z-index: 49;
  background: var(--paper); padding: 24px var(--gutter);
  animation: menu-in 0.35s var(--ease-out);
}
.mobile-menu a {
  display: flex; align-items: baseline; gap: 14px; padding: 14px 0;
  border-bottom: 1px solid var(--line); text-decoration: none;
  font-family: var(--f-serif); font-size: 2.4rem; line-height: 1.1;
}
html[data-lang="ja"] .mobile-menu a { font-family: var(--f-mincho); font-size: 1.9rem; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-8px); } }

/* ---------- Buttons & small components ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  height: 48px; padding: 0 22px; border-radius: 999px;
  border: 1px solid var(--line-strong); text-decoration: none; font-weight: 500; font-size: 0.95rem;
  transition: transform 0.3s var(--ease-out), background-color 0.2s, border-color 0.2s, color 0.2s;
}
.btn:hover { border-color: var(--ink); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-lg { height: 56px; padding: 0 24px; font-size: 1rem; }
.btn-sub { opacity: 0.6; font-size: 0.68rem; }
.btn .ico { width: 18px; height: 18px; }

.tag {
  display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 999px;
  border: 1px solid var(--line-strong); font-size: 0.75rem; color: var(--ink-2); white-space: nowrap;
}
.venue {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 10px; border-radius: 6px;
  background: var(--ink); color: var(--paper); font-family: var(--f-mono); font-size: 0.72rem; font-weight: 500;
  letter-spacing: 0.02em; white-space: nowrap;
}
.venue-hot { background: var(--accent); color: #fff; }
.venue-jp { background: transparent; color: var(--ink-2); border: 1px solid var(--line-strong); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 0.66rem; letter-spacing: 0.06em;
}
.pill-live { background: var(--accent-soft); color: var(--accent); }
.pill-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.link-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line-strong); text-decoration: none; font-size: 0.85rem;
  transition: border-color 0.2s, background-color 0.2s;
}
.link-btn:hover { border-color: var(--ink); background: var(--surface); }
.link-btn .ico { width: 14px; height: 14px; transition: transform 0.3s var(--ease-out); }
.link-btn:hover .ico { transform: translate(2px, -2px); }
.link-btn.is-disabled { color: var(--muted); border-style: dashed; cursor: default; }
.link-btn.is-disabled:hover { background: none; border-color: var(--line-strong); }

.mini-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: 6px;
  border: 1px solid var(--line); font-family: var(--f-mono); font-size: 0.7rem; text-decoration: none; color: var(--ink-2);
  transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}
.mini-btn:hover { border-color: var(--ink); color: var(--ink); }
.mini-btn .ico { width: 12px; height: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips li {
  padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  font-size: 0.82rem; color: var(--ink-2);
}

/* ---------- Reveal ---------- */
.js [data-reveal] {
  opacity: 0; transform: translateY(18px);
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out);
  transition-delay: var(--d, 0ms);
}
.js [data-reveal].is-in { opacity: 1; transform: none; }

/* ---------- Layout ---------- */
.section, .hero {
  max-width: calc(var(--maxw) + 2 * var(--gutter));
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}
.section { padding-top: clamp(72px, 8vw, 120px); }

.sec-head {
  position: relative;
  display: grid; grid-template-columns: 64px 1fr minmax(0, 360px); align-items: end; gap: 24px;
  padding-top: 20px; margin-bottom: clamp(40px, 6vw, 80px);
}
.sec-head::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px; background: var(--ink);
  transform-origin: 0 50%; transform: scaleX(0); transition: transform 1.4s var(--ease-out) 0.1s;
}
.sec-head.is-in::before, html:not(.js) .sec-head::before { transform: scaleX(1); }
.sec-num { align-self: start; color: var(--accent); font-size: 0.85rem; padding-top: 0.6em; }
.sec-head h2 {
  font-family: var(--f-serif); font-weight: 400; font-size: clamp(2.6rem, 6.4vw, 5.6rem);
  line-height: 0.95; letter-spacing: -0.02em;
}
html[data-lang="ja"] .sec-head h2 { font-family: var(--f-mincho); font-weight: 500; font-size: clamp(2.1rem, 5vw, 4.2rem); letter-spacing: 0.02em; line-height: 1.15; }
.sec-aside { color: var(--muted); font-size: 0.95rem; text-wrap: pretty; }

/* ==========================================================================
   HERO
   ========================================================================== */
.hero {
  position: relative;
  min-height: min(100svh, 880px);
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  align-items: center;
  column-gap: clamp(32px, 6vw, 96px);
  padding-top: calc(var(--header-h) + 40px);
  padding-bottom: 56px;
}
.hero-copy { position: relative; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.72rem;
}
.eyebrow::before { content: ""; width: 28px; height: 1px; background: var(--accent); }
html[data-lang="ja"] .eyebrow { letter-spacing: 0.08em; }

.hero-name {
  margin-top: 18px;
  font-family: var(--f-serif); font-weight: 400;
  font-size: clamp(3.2rem, 6.8vw, 6.4rem);
  line-height: 0.9; letter-spacing: -0.03em;
}
.hero-name .line { display: block; }
.hero-name em { font-style: italic; color: var(--accent); padding-right: 0.06em; }
.hero-name .ja-name { font-family: var(--f-mincho); font-weight: 500; letter-spacing: 0.04em; line-height: 1; font-size: 0.9em; }
.name-gap { display: inline-block; width: 0.28em; }

.hero-alt { position: absolute; top: 44px; right: calc(100% + 10px); }
.tate {
  writing-mode: vertical-rl; font-family: var(--f-mincho); font-size: 1rem; letter-spacing: 0.5em; color: var(--muted);
}
.tate-latin { font-family: var(--f-mono); font-size: 0.66rem; letter-spacing: 0.3em; text-transform: uppercase; }

.lede {
  margin-top: 30px; max-width: 32ch;
  font-size: clamp(1.2rem, 1.8vw, 1.55rem); line-height: 1.42; color: var(--ink); text-wrap: pretty;
}
.lede em { font-family: var(--f-serif); font-size: 1.12em; color: var(--accent-ink); }
.lede-sub { margin-top: 14px; max-width: 50ch; color: var(--muted); font-size: 0.98rem; text-wrap: pretty; }
html[data-lang="ja"] .lede { max-width: 26em; font-size: clamp(1.1rem, 1.6vw, 1.35rem); line-height: 1.8; }
html[data-lang="ja"] .lede em { font-family: var(--f-mincho); font-style: normal; font-size: 1.04em; font-weight: 600; color: var(--ink); background: linear-gradient(transparent 62%, var(--accent-soft) 62%); }

.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.hero-cta .ico { transition: transform 0.4s var(--ease-out); }
.hero-cta .btn-primary:hover .ico { transform: translateY(3px); }

.now-chip {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 28px;
  padding: 8px 14px 8px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); text-decoration: none; font-size: 0.85rem; color: var(--ink-2);
  transition: border-color 0.2s, transform 0.3s var(--ease-out);
}
.now-chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.now-chip b { color: var(--ink); }
.now-chip .ico { width: 14px; height: 14px; color: var(--muted); }
.now-label { color: var(--accent); font-weight: 500; font-size: 0.68rem; }
.pulse { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--accent);
  animation: pulse 2s var(--ease-out) infinite;
}
@keyframes pulse { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(3.2); opacity: 0; } }

.hero-portrait { position: relative; margin: 0; justify-self: center; width: min(100%, 260px); }
.hero-portrait img { position: relative; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 50%; box-shadow: var(--shadow-lg); }
.hero-portrait::before, .hero-portrait::after {
  content: ""; position: absolute; left: -16px; right: -16px; top: -16px; aspect-ratio: 1; border-radius: 50%; pointer-events: none;
}
.hero-portrait::before { border: 1px solid var(--line-strong); }
.hero-portrait::after { border: 1.5px solid transparent; border-top-color: var(--accent); animation: orbit 14s linear infinite; }
@keyframes orbit { to { transform: rotate(360deg); } }

/* Shared by the canvas demo in the ballroom case study */
.dancer-canvas { width: 100%; height: 100%; touch-action: pan-y; cursor: grab; }
.dancer-canvas.is-dragging { cursor: grabbing; }
.hud-btn {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink);
  transition: border-color 0.2s;
}
.hud-btn:hover { border-color: var(--ink); }
.hud-btn .ico { width: 14px; height: 14px; }
.hud-btn .ico-play { display: none; }
.hud-btn[aria-pressed="true"] .ico-play { display: block; }
.hud-btn[aria-pressed="true"] .ico-pause { display: none; }

/* ==========================================================================
   WORK — case studies
   ========================================================================== */
.case {
  display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(32px, 5vw, 80px);
  align-items: start;
  padding-block: clamp(48px, 6vw, 88px);
  border-top: 1px solid var(--line);
}
.case:first-of-type { border-top: 0; padding-top: 0; }
.case-flip { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.case-flip .case-meta { order: 2; }
.case-flip .case-demo { order: 1; }
.case-meta { position: sticky; top: calc(var(--header-h) + 24px); }
.case-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.case-title {
  margin-top: 20px; font-family: var(--f-serif); font-weight: 400;
  font-size: clamp(3rem, 5.6vw, 5rem); line-height: 0.95; letter-spacing: -0.025em;
}
.case-title-long { font-size: clamp(2.2rem, 3.8vw, 3.4rem); line-height: 1.02; text-wrap: balance; }
.case-kicker { margin-top: 14px; font-size: 1.1rem; color: var(--ink-2); line-height: 1.45; text-wrap: pretty; }
.pa-list { margin-top: 28px; display: grid; gap: 18px; }
.pa-list > div { display: grid; grid-template-columns: 96px 1fr; gap: 16px; }
.pa-list dt { font-family: var(--f-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); padding-top: 0.35em; }
html[data-lang="ja"] .pa-list dt { letter-spacing: 0.04em; }
.pa-list dd { font-size: 0.95rem; color: var(--ink-2); text-wrap: pretty; }
.metrics {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; margin-top: 28px;
  background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.metrics li { background: var(--paper); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.metrics b { font-family: var(--f-serif); font-weight: 400; font-size: 1.9rem; line-height: 1.05; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.metrics span { font-size: 0.78rem; color: var(--muted); }
.case-credit { margin-top: 24px; font-size: 0.88rem; color: var(--muted); }
.case-credit .mono { display: inline-block; margin-top: 6px; }
.case-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }

.demo-note { margin-top: 10px; color: var(--muted); font-size: 0.68rem; }

/* Window chrome shared by demos */
.window {
  position: relative;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.win-bar {
  display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
}
.win-title { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.win-bar .spacer { flex: 1; }
.noscript { padding: 24px; color: var(--muted); }

/* ---------- DocuDebug (figures from the project page) ---------- */
.dd-figure, .dd-video { margin: 0; }
.dd-figure a { display: block; padding: clamp(10px, 2vw, 20px); border-radius: var(--radius); background: #fff; border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg); transition: transform 0.4s var(--ease-out); }
.dd-figure a:hover { transform: translateY(-2px); }
.dd-figure img { width: 100%; }
.dd-figure figcaption { margin-top: 14px; font-size: 0.88rem; color: var(--ink-2); text-wrap: pretty; }
.dd-video { margin-top: 24px; }
.dd-video video { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius); background: #000; border: 1px solid var(--line-strong); }
.dd-video figcaption { margin-top: 8px; color: var(--muted); }
.dd-more { margin-top: 16px; font-size: 0.9rem; }
.dd-more a { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-weight: 500; text-underline-offset: 0.25em; }
.dd-more a:hover { color: var(--accent); }
.dd-more .ico { width: 14px; height: 14px; }

/* ---------- IRIS (Fig. 3 re-creation) ---------- */
.iris-layers { display: flex; flex-wrap: wrap; gap: 4px; margin-left: auto; }
.iris-layers .fchip { height: 26px; padding: 0 10px; font-size: 0.72rem; }
.iris-layers .fchip:disabled { cursor: default; }
.iris-fig { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 20px; align-items: start; padding: 18px; }
.t-transition { --seg: #ffffff; }
.t-jump { --seg: #e6007e; }
.t-step { --seg: #5ad13b; }
.t-spin { --seg: #0b7dc1; }
.iris-frame { position: relative; border: 2px solid #111; border-bottom: 0; background: #1d2430; }
.iris-frame svg { width: 100%; height: auto; }
.trail { fill: none; stroke: var(--seg); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.trail.t-transition { stroke: #6f7d8c; stroke-width: 1.4; opacity: 0.6; }
.trail.t-plain { stroke: #44505f; stroke-width: 1.4; opacity: 0.6; }
.iris-now {
  position: absolute; top: 8px; left: 8px; display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px;
  border-radius: 999px; background: rgb(0 0 0 / 0.66); color: #fff; font: 500 0.66rem var(--f-mono);
}
.iris-now::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--seg); box-shadow: 0 0 0 1px #fff; }
.iris-seek { position: relative; border-inline: 2px solid #111; background: #fff; }
.iris-tl { position: relative; height: 20px; }
.iris-tl i { position: absolute; top: 0; bottom: 0; background: var(--seg); }
.no-seg .iris-tl, .no-seg .iris-legend { display: none; }
.iris-prog { position: relative; height: 6px; background: #b9b9b9; }
.iris-prog i { position: absolute; left: 0; top: 0; bottom: 0; background: #0b7dc1; }
.iris-prog b { position: absolute; top: 50%; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; background: #0b7dc1; }
.iris-seek input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.iris-seek:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.iris-ctrl { display: flex; align-items: center; justify-content: space-between; padding: 4px 10px; background: #111; color: #fff; border: 2px solid #111; border-top: 0; }
.iris-ctrl button { display: grid; place-items: center; width: 30px; height: 30px; color: #fff; }
.iris-ctrl .ico { width: 16px; height: 16px; }
.iris-ctrl .mono { font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.iris-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 0.78rem; color: var(--ink-2); }
.iris-legend li { display: inline-flex; align-items: center; gap: 6px; }
.iris-legend i { width: 14px; height: 14px; border-radius: 50%; background: var(--seg); border: 1.5px solid var(--ink); }

.iris-sheet { font-size: 0.8rem; color: var(--ink); }
.sheet-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.sheet-name { font-size: 0.98rem; }
.sheet-score { padding: 3px 10px; border: 1.5px solid var(--ink); font-size: 0.95rem; white-space: nowrap; }
.sheet-score b { font-weight: 700; }
.iris-sheet table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.iris-sheet th { padding: 3px 4px; border-top: 2px solid var(--ink); border-bottom: 1.5px solid var(--ink); font-weight: 400; text-align: left; white-space: nowrap; }
.iris-sheet tr.h th { padding-top: 4px; }
.iris-sheet td { padding: 2px 4px; }
.iris-sheet .r { text-align: right; }
.iris-sheet .num { width: 1.8em; }
.iris-sheet .ai { color: var(--c-spin); }
.iris-sheet sup { font-size: 0.6em; }
.iris-sheet tr.sum td { padding-bottom: 8px; font-weight: 700; }
.iris-sheet tr.sum td.r { border-top: 1.5px solid var(--ink); }

/* ---------- Fusion (ballroom) demo ---------- */
.window-dark { background: var(--surface); }
.fusion { position: relative; aspect-ratio: 4 / 3; }
.fusion .dancer-canvas { position: absolute; inset: 0; }
.fusion-pred {
  position: absolute; top: 14px; left: 14px; display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid var(--line); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.fusion-pred b { font-family: var(--f-serif); font-weight: 400; font-size: 1.6rem; line-height: 1.05; }
html[data-lang="ja"] .fusion-pred b { font-family: var(--f-sans); font-weight: 500; font-size: 1.15rem; }
.fusion-cap { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.fusion-pred .mono:last-child { color: var(--accent); }
.fusion-toggle { position: absolute; top: 14px; right: 14px; }

.media-grid { margin-top: 20px; }
.media { position: relative; margin: 0; border-radius: 10px; overflow: hidden; background: var(--paper-2); border: 1px solid var(--line); }
.media img { width: 100%; height: 100%; object-fit: cover; }
.media figcaption {
  position: absolute; left: 8px; bottom: 8px; padding: 4px 8px; border-radius: 6px;
  background: rgb(0 0 0 / 0.66); color: #fff; font-size: 0.62rem;
}
.yt { aspect-ratio: 16 / 9; }
.yt-btn { position: absolute; inset: 0; display: block; width: 100%; text-align: left; }
.yt-btn img { position: absolute; inset: 0; transition: transform 0.6s var(--ease-out), filter 0.4s; filter: saturate(0.85); }
.yt-btn:hover img { transform: scale(1.04); filter: saturate(1); }
.yt-play {
  position: absolute; top: 50%; left: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: #fff; box-shadow: 0 8px 24px rgb(0 0 0 / 0.35);
  transition: transform 0.3s var(--ease-out);
}
.yt-btn:hover .yt-play { transform: scale(1.1); }
.yt-play .ico { width: 18px; height: 18px; margin-left: 2px; }
.yt-title {
  position: absolute; left: 8px; right: 8px; bottom: 8px; width: fit-content; max-width: calc(100% - 16px);
  padding: 4px 8px; border-radius: 6px; background: rgb(0 0 0 / 0.7);
  color: #fff; font-size: 0.66rem; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.yt-title .mono { opacity: 0.7; font-size: 0.6rem; margin-left: 4px; }
.yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ==========================================================================
   PUBLICATIONS
   ========================================================================== */
.pub-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fchip {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); font-size: 0.85rem; color: var(--ink-2);
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.fchip:hover { border-color: var(--ink); }
.fchip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.fcount { font-family: var(--f-mono); font-size: 0.68rem; opacity: 0.6; }
.pub-status { margin-top: 14px; color: var(--muted); min-height: 1.2em; }

.pubs { margin-top: 18px; border-top: 1px solid var(--ink); }
.pub {
  position: relative; display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 8px 24px;
  padding: 22px 0; border-bottom: 1px solid var(--line);
  transition: background-color 0.3s;
}
.pub[hidden] { display: none; }
.pub::before {
  content: ""; position: absolute; left: -16px; right: -16px; top: 0; bottom: 0; border-radius: 10px;
  background: var(--surface); opacity: 0; z-index: -1; transition: opacity 0.25s;
}
.pub:hover::before { opacity: 1; }
.pub-year { padding-top: 0.25em; color: var(--muted); font-size: 0.8rem; }
.pub:not(.is-year-first) .pub-year { visibility: hidden; }
.pub-title { font-size: 1.08rem; font-weight: 500; line-height: 1.35; letter-spacing: -0.005em; text-wrap: pretty; }
.pub-title a { text-decoration: none; background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size 0.4s var(--ease-out); }
.pub-title a:hover { background-size: 100% 1px; }
.pub.is-featured .pub-title::before {
  content: "★"; display: inline-block; margin-right: 8px; color: var(--accent); font-size: 0.8em; transform: translateY(-1px);
}
.pub-authors { margin-top: 6px; font-size: 0.86rem; color: var(--muted); }
.pub-authors b { color: var(--ink); font-weight: 600; }
.pub-venue { margin-top: 2px; font-size: 0.86rem; color: var(--muted); }
.pub-flag { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); font-size: 0.72rem; font-style: normal; }
.pub-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 12px; }
.pub-actions { display: flex; gap: 6px; opacity: 0.55; transition: opacity 0.2s; }
.pub:hover .pub-actions, .pub:focus-within .pub-actions { opacity: 1; }

/* ==========================================================================
   CV
   ========================================================================== */
.cv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 6vw, 96px); }
.cv-h { color: var(--muted); text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.7rem; font-weight: 400; padding-bottom: 12px; border-bottom: 1px solid var(--ink); }
.cv-h:not(:first-child) { margin-top: 48px; }
.timeline li { position: relative; display: grid; grid-template-columns: 112px 1fr; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.timeline .tl-when { color: var(--muted); padding-top: 0.3em; }
.timeline .is-current .tl-when { color: var(--accent); }
.timeline .is-current .tl-when::before { content: ""; display: inline-block; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }
.timeline h4 { font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; }
.timeline p { font-size: 0.9rem; color: var(--ink-2); margin-top: 2px; }
.award-list li { display: grid; grid-template-columns: 56px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; color: var(--ink-2); }
.award-list b { color: var(--ink); }
.award-year { color: var(--muted); padding-top: 0.25em; }
.skills > div { display: grid; grid-template-columns: 112px 1fr; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.skills dt { color: var(--muted); }
.skills dd { color: var(--ink-2); }

/* ==========================================================================
   CONTACT & FOOTER
   ========================================================================== */
.contact { padding-bottom: clamp(80px, 10vw, 140px); }
.contact .sec-head { grid-template-columns: 64px 1fr; margin-bottom: 32px; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 10px; }
[data-email].is-copied { background: var(--ok); border-color: var(--ok); color: #fff; }

.site-footer { border-top: 1px solid var(--line); }
.footer-inner {
  max-width: calc(var(--maxw) + 2 * var(--gutter)); margin: 0 auto; padding: 24px var(--gutter) calc(24px + env(safe-area-inset-bottom));
  font-size: 0.82rem; color: var(--muted);
}

/* ==========================================================================
   TOAST
   ========================================================================== */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 200;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px;
  background: var(--ink); color: var(--paper); font-size: 0.88rem; box-shadow: var(--shadow-lg);
  transition: opacity 0.3s var(--ease-out), transform 0.4s var(--ease-out);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast .ico { color: var(--ok); width: 16px; height: 16px; }

/* ==========================================================================
   VIEW TRANSITIONS (language / theme switch)
   ========================================================================== */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.35s; animation-timing-function: var(--ease); }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1180px) {
  .nav-num { display: none; }
  .nav a { padding: 8px 10px; }
}

@media (max-width: 1040px) {
  .case, .case-flip { grid-template-columns: minmax(0, 1fr); }
  .case-flip .case-meta, .case-flip .case-demo { order: 0; }
  .case-meta { position: static; }
  .sec-head { grid-template-columns: 48px 1fr; }
  .sec-head .sec-aside { grid-column: 2; }
}

@media (max-width: 900px) {
  :root { --header-h: 58px; }
  .nav { display: none; }
  .menu-btn { display: grid; }
  .brand-name { display: none; }
  .header-tools { margin-left: auto; }

  .hero { grid-template-columns: minmax(0, 1fr); min-height: 0; padding-top: calc(var(--header-h) + 32px); }
  .hero-portrait { grid-row: 1; justify-self: start; width: 168px; margin: 16px 0 36px 16px; }
  .hero-alt { display: none; }
  .cv-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .iris-fig { grid-template-columns: 1fr; padding: 14px; }
  .iris-layers { margin-left: 0; }
  .win-bar { height: auto; min-height: 44px; flex-wrap: wrap; padding-block: 8px; }
  .pub { grid-template-columns: 1fr; gap: 6px; }
  .pub-year { display: none; }
  .pub-side { flex-direction: row-reverse; align-items: center; justify-content: space-between; }
  .pub-actions { opacity: 1; }
  .pub::before { left: -8px; right: -8px; }
  .sec-head { grid-template-columns: 1fr; gap: 10px; }
  .sec-head .sec-aside { grid-column: 1; }
  .sec-num { padding-top: 0; }
  .pa-list > div { grid-template-columns: 1fr; gap: 2px; }
  .timeline li, .skills > div { grid-template-columns: 1fr; gap: 4px; }
  .fusion { aspect-ratio: 1 / 1; }
  .fusion-pred b { font-size: 1.25rem; }
}

@media (max-width: 420px) {
  .lang-switch button { padding: 0 9px; }
  .btn-lg { width: 100%; justify-content: center; }
  .contact-actions { width: 100%; }
}

/* ==========================================================================
   MOTION PREFERENCES & PRINT
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .js [data-reveal] { opacity: 1; transform: none; }
}

@media print {
  body::before, .site-header, .case-demo, .toast, .pub-toolbar, .pub-actions { display: none !important; }
  .hero { min-height: 0; }
  .js [data-reveal] { opacity: 1; transform: none; }
  .case { grid-template-columns: 1fr; }
  .section { padding-top: 48px; }
}
