:root {
  --bg: oklch(0.98 0.004 90);
  --text: oklch(0.22 0.01 260);
  --text-dim: oklch(0.45 0.01 260);
  --glass: oklch(1 0 0 / 0.45);
  --glass-border: oklch(1 0 0 / 0.6);
  --sheen: linear-gradient(135deg, oklch(1 0 0 / 0.55), oklch(1 0 0 / 0) 55%);
  --accent: oklch(0.55 0.14 250);
  --accent-soft: oklch(0.55 0.14 250 / 0.25);
  --chip-bg: oklch(0.45 0.01 260 / 0.10);
  --card-glow: oklch(0.62 0.15 250 / 0.34);
  --card-glow-edge: oklch(0.62 0.15 250 / 0);
  --blob1: oklch(0.75 0.10 250 / 0.45);
  --blob2: oklch(0.82 0.09 25 / 0.35);
  --shadow: 0 8px 24px oklch(0.4 0.02 260 / 0.10);
  --shadow-hover: 0 14px 34px oklch(0.4 0.02 260 / 0.16);
  --track: oklch(1 0 0 / 0.55);
  --band: oklch(0.17 0.012 260);
  --band-text: oklch(0.97 0.004 260);
  --band-dim: oklch(0.72 0.01 260);
  --band-accent: oklch(0.78 0.13 250);
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Segoe UI", "Yu Gothic", sans-serif;
}
:root[data-theme="dark"] {
  --bg: oklch(0.19 0.012 260);
  --text: oklch(0.96 0.005 260);
  --text-dim: oklch(0.75 0.01 260);
  --glass: oklch(0.30 0.02 260 / 0.45);
  --glass-border: oklch(1 0 0 / 0.10);
  --sheen: linear-gradient(135deg, oklch(1 0 0 / 0.10), oklch(1 0 0 / 0) 55%);
  --accent: oklch(0.72 0.13 250);
  --accent-soft: oklch(0.72 0.13 250 / 0.35);
  --chip-bg: oklch(1 0 0 / 0.10);
  --card-glow: oklch(1 0 0 / 0.18);
  --card-glow-edge: oklch(1 0 0 / 0);
  --blob1: oklch(0.55 0.14 250 / 0.35);
  --blob2: oklch(0.55 0.14 25 / 0.22);
  --shadow: 0 8px 24px oklch(0 0 0 / 0.38);
  --shadow-hover: 0 14px 34px oklch(0 0 0 / 0.5);
  --track: oklch(0.35 0.02 260 / 0.6);
  --band: oklch(0.11 0.008 260);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

html[data-lang="ja"] .en,
html[data-lang="en"] .ja { display: none; }

/* 日本語が語中で折り返されないよう、文節ごとの箱にして境界でだけ改行させる */
.hero-sub .ja > span,
.contact-note .ja > span { display: inline-block; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.6s ease, color 0.6s ease;
}

/* Film grain: 単色の広い面(黒帯・blob)のバンディングを消して質感を出す */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: 0.03;
  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='0.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
html[data-theme="dark"] body::after { opacity: 0.05; }

@keyframes blobDrift1 { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(40px,-30px,0) scale(1.08); } }
@keyframes blobDrift2 { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(-30px,25px,0) scale(1.05); } }
@keyframes bounceCue { 0%,100% { transform: translateY(0); opacity: 0.55; } 50% { transform: translateY(8px); opacity: 1; } }
@keyframes blobBreathe { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Header */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px clamp(20px, 5vw, 56px);
  background: var(--glass);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
}
.logo {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  display: inline-block;
  will-change: transform;
  transition: transform 0.3s cubic-bezier(.16,1,.3,1);
}
.nav { display: flex; align-items: center; gap: 20px; }
.nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s ease;
}
.nav-link:hover { color: var(--accent); }

@media (max-width: 640px) {
  .site-header { padding: 14px 16px; }
  .nav { gap: 12px; }
  .nav-link { font-size: 13px; }
  .theme-toggle { width: 32px; height: 32px; }
}

.lang-toggle { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.lang-toggle button {
  appearance: none;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 4px 2px;
  opacity: 0.45;
  font-weight: 400;
  transition: opacity 0.2s ease;
}
.lang-toggle button[aria-pressed="true"] { opacity: 1; font-weight: 700; }
.lang-toggle .sep { opacity: 0.3; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--track);
  color: var(--text);
  cursor: pointer;
  padding: 0;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle svg {
  grid-area: 1 / 1;
  width: 18px; height: 18px; display: block;
  transition: opacity 0.55s ease, transform 0.85s cubic-bezier(.16,1,.3,1);
}
html[data-theme="light"] .icon-moon { opacity: 0; transform: rotate(-90deg) scale(0.5); pointer-events: none; }
html[data-theme="dark"] .icon-sun { opacity: 0; transform: rotate(90deg) scale(0.5); pointer-events: none; }

/* Theme switch: circular reveal via View Transitions */
::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-old(root) { z-index: 0; }
::view-transition-new(root) { z-index: 1; }

/* Fade wrapper for language switch */
.fade { transition: opacity 0.18s ease; }

/* Hero */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 120px 24px 60px;
  overflow: hidden;
}
.blob-wrap { position: absolute; will-change: transform; transition: opacity 0.6s ease; }
.blob-wrap-1 { top: -120px; left: -100px; }
.blob-wrap-2 { bottom: -140px; right: -100px; }
.blob-wrap.is-breathing { animation: blobBreathe 5s ease-in-out infinite; }
.blob-wrap-2.is-breathing { animation-duration: 6.5s; }
.blob { border-radius: 50%; }
.blob-1 {
  width: 520px; height: 520px;
  background: var(--blob1);
  filter: blur(80px);
  animation: blobDrift1 16s ease-in-out infinite alternate;
}
.blob-2 {
  width: 460px; height: 460px;
  background: var(--blob2);
  filter: blur(90px);
  animation: blobDrift2 18s ease-in-out infinite alternate;
}
.hero-inner { position: relative; }
.hero-title {
  font-size: clamp(48px, 9vw, 104px);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
}
.hero-sub {
  font-size: clamp(17px, 2.4vw, 22px);
  color: var(--text-dim);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.7;
}
.scroll-cue {
  position: absolute;
  bottom: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  animation: bounceCue 2.4s ease-in-out infinite;
}
.scroll-cue .bar { width: 1px; height: 28px; background: var(--text-dim); opacity: 0.5; }

/* Sections */
.section {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(60px, 10vw, 120px) clamp(20px, 5vw, 40px);
  scroll-margin-top: 72px;
}
.section-title {
  font-size: clamp(34px, 5vw, 56px);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.section-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-bottom: 48px;
}
.section-sub {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--text-dim);
}

/* Japanese headings need positive tracking to breathe */
html[data-lang="ja"] .card-title,
html[data-lang="ja"] .panel h2 { letter-spacing: 0.03em; }

/* Cards */
.grid { display: grid; gap: 24px; }
.grid-apps { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-web { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.card {
  position: relative;
  overflow: hidden;
  border-radius: 0;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  transition: transform 0.5s cubic-bezier(.16,1,.3,1), box-shadow 0.5s ease;
}
.card:hover { transform: translateY(-8px); box-shadow: var(--shadow-hover); }
.card.is-tilting { transition: transform 0.12s ease, box-shadow 0.5s ease; }
.sheen {
  position: absolute;
  inset: 0;
  background: var(--sheen);
  pointer-events: none;
}
.sheen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(280px circle at var(--mx, 50%) var(--my, 50%), var(--card-glow), var(--card-glow-edge) 62%);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.card:hover .sheen::after { opacity: 1; }

.app-card {
  padding: 28px;
  min-height: 190px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.card-head { position: relative; display: flex; align-items: center; gap: 12px; }
.app-icon {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 22.37%;
  border: 1px solid var(--glass-border);
  transition: transform 0.4s cubic-bezier(.34,1.56,.64,1);
}
.card:hover .app-icon { transform: scale(1.08) rotate(-3deg); }
.card-body { position: relative; display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 0; }
.card-title { font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.card-sub { font-size: 14px; color: var(--text-dim); line-height: 1.6; }
/* 見出しは押せる。地色のままだと分からないので、控えめな下線を常時出しておく */
.card-title a, .web-title a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-decoration-color: color-mix(in oklab, var(--accent), transparent 40%);
  text-underline-offset: 4px;
  transition: text-decoration-color 0.25s ease;
}
.card-title a:hover, .web-title a:hover { text-decoration-color: var(--accent); }
.card-title a:focus-visible, .web-title a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.card-meta {
  position: relative;
  width: fit-content;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}
/* リンクのメタだけ色を持たせる。ドメイン名や「近日公開」はラベルのままにする */
a.card-meta {
  color: var(--accent);
  text-decoration: none;
}
a.card-meta::after {
  content: "↗";
  display: inline-block;
  margin-left: 4px;
  font-size: 12px;
  transition: transform 0.25s ease;
}
a.card-meta:hover { text-decoration: underline; text-underline-offset: 4px; }
a.card-meta:hover::after { transform: translate(2px, -2px); }
a.card-meta:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* App card screenshot filmstrip */
.app-card .card-body { order: 1; }
.app-card .card-strip { order: 2; }
.app-card .card-meta { order: 3; }
.card-strip {
  position: relative;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border) transparent;
}
.card-strip::-webkit-scrollbar { height: 6px; }
.card-strip::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 999px; }
.strip-item {
  flex: 0 0 auto;
  width: 100px;
  aspect-ratio: 1284 / 2778;
  padding: 0;
  border: 1px solid var(--glass-border);
  border-radius: 0;
  overflow: hidden;
  background: var(--sheen);
  scroll-snap-align: start;
}
.strip-item img { display: block; width: 100%; height: 100%; object-fit: cover; }

.web-card { padding: 32px; display: flex; flex-direction: column; gap: 12px; }
.web-card .card-meta { margin-top: auto; }
.web-label {
  position: relative;
  width: fit-content;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--chip-bg);
  padding: 4px 10px;
  border-radius: 0;
}
.web-title { position: relative; font-size: 22px; font-weight: 700; letter-spacing: 0.02em; }
.web-desc { position: relative; font-size: 15px; color: var(--text-dim); line-height: 1.7; margin-bottom: 4px; }

/* Closing band: contact, copyright */
.closing {
  background: var(--band);
  color: var(--band-text);
  scroll-margin-top: 72px;
}
.closing-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(40px, 5vw, 64px) clamp(20px, 5vw, 40px) clamp(28px, 4vw, 40px);
}

/* Closing band: infinite marquee */
.marquee {
  overflow: hidden;
  padding: clamp(28px, 4vw, 40px) 0 0;
  user-select: none;
}
.marquee-track {
  display: flex;
  width: max-content;
  animation: marquee 60s linear infinite;
}
.marquee-track span {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.22em;
  line-height: 1.4;
  white-space: pre;
  color: var(--band-dim);
  opacity: 0.4;
}
@keyframes marquee { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .marquee-track { animation: none; } }
.closing .section-title { color: var(--band-text); margin-bottom: 14px; }
.contact-note { font-size: 16px; color: var(--band-dim); max-width: 560px; line-height: 1.7; margin-bottom: 20px; }
.contact-links { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.contact-link { font-size: 16px; font-weight: 700; color: var(--band-accent); text-decoration: none; }
.contact-link:hover { text-decoration: underline; }

footer { padding: clamp(48px, 7vw, 72px) 0 0; font-size: 13px; color: var(--band-dim); }

/* 404 */
.notfound {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 120px 24px 60px;
  overflow: hidden;
}
.notfound-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  text-align: center;
}
.nf-tile {
  width: clamp(160px, 30vw, 240px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 22.37%;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-hover);
  font-size: clamp(52px, 10vw, 82px);
  font-weight: 800;
  letter-spacing: -0.02em;
  transform: rotate(-4deg);
  animation: tileDrop 1.5s both;
}
@keyframes tileDrop {
  0% { transform: translateY(-120vh) rotate(-14deg); animation-timing-function: cubic-bezier(.6,0,.9,.4); }
  42% { transform: translateY(0) rotate(-4deg); animation-timing-function: cubic-bezier(.1,.7,.3,1); }
  60% { transform: translateY(-56px) rotate(-8deg); animation-timing-function: cubic-bezier(.6,0,.9,.4); }
  76% { transform: translateY(0) rotate(-4deg); animation-timing-function: cubic-bezier(.1,.7,.3,1); }
  88% { transform: translateY(-18px) rotate(-6deg); animation-timing-function: cubic-bezier(.6,0,.9,.4); }
  100% { transform: translateY(0) rotate(-4deg); }
}
.nf-text { font-size: 16px; color: var(--text-dim); line-height: 1.8; }
.nf-back { font-size: 16px; font-weight: 700; color: var(--accent); text-decoration: none; }
.nf-back:hover { text-decoration: underline; }

/* About page */
.about-hero {
  position: relative;
  overflow: hidden;
  padding: clamp(140px, 20vh, 220px) clamp(20px, 5vw, 40px) clamp(40px, 6vw, 72px);
  max-width: 900px;
  margin: 0 auto;
}
.about-hero .section-head { margin-bottom: 22px; }
.about-lead { font-size: clamp(16px, 2vw, 19px); color: var(--text-dim); line-height: 1.9; max-width: 720px; }

.prose {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 40px) clamp(80px, 10vw, 120px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.panel {
  position: relative;
  overflow: hidden;
  border-radius: 0;
  scroll-margin-top: 88px;
  padding: clamp(28px, 4vw, 40px);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
}
.panel > * { position: relative; }
.panel h2 {
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 20px;
}
.panel h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 22px 0 8px;
}
.panel h3:first-of-type { margin-top: 0; }
.panel p { font-size: 15px; color: var(--text-dim); line-height: 1.9; margin-bottom: 12px; }
.panel p:last-child { margin-bottom: 0; }
.panel strong { color: var(--text); font-weight: 700; }
.panel ul { list-style: none; display: flex; flex-direction: column; gap: 12px; margin: 4px 0 0; }
.panel li { font-size: 15px; color: var(--text-dim); line-height: 1.6; padding-left: 18px; position: relative; }
.panel li::before {
  content: "";
  position: absolute;
  left: 0; top: 9px;
  width: 6px; height: 6px;
  background: var(--text-dim);
  opacity: 0.5;
}
.panel a { color: var(--accent); text-decoration: none; font-weight: 600; }
.panel a:hover { text-decoration: underline; }

.skills-panel { padding: 32px; }
.skills-title { position: relative; font-size: 20px; font-weight: 700; margin-bottom: 18px; }
.skills-list { position: relative; list-style: none; display: flex; flex-direction: column; gap: 14px; }
.skills-list li { font-size: 15px; color: var(--text-dim); line-height: 1.6; padding-left: 18px; position: relative; }
.skills-list li::before {
  content: "";
  position: absolute;
  left: 0; top: 9px;
  width: 6px; height: 6px;
  background: var(--text-dim);
  opacity: 0.5;
}

/* Easter-egg confetti */
.confetti-piece {
  position: fixed;
  top: 0; left: 0;
  width: 9px; height: 14px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 9999;
  will-change: transform, opacity;
}

/* Scroll reveal */
[data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s cubic-bezier(.16,1,.3,1), transform 0.7s cubic-bezier(.16,1,.3,1);
}
[data-reveal].in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  [data-reveal] { opacity: 1; transform: none; }
}
