:root {
  --bg: #f7f7f6;
  --fg: #111111;
  --sub: #6b6b6b;
  --line: #dddddb;
  --card: #ececea;
  --col: 140px;      /* About ラベル列 / Other Works 名前列の幅 */
  --col-gap: 40px;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-inout: cubic-bezier(.76, 0, .24, 1);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f0f0f;
  --fg: #f2f2f0;
  --sub: #9a9a98;
  --line: #2a2a2a;
  --card: #1a1a1a;
  color-scheme: dark;
}

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

/* ---------- 罫線 ----------
   線は背景のグラデーションで1px描く。--rule-a(0〜1)で線の濃さだけを変えられるので、
   テーマ切り替え時に「線がフェードで消える → 背景色が変わる → 線がフェードで出る」を JS が制御する */
@property --rule-a { syntax: '<number>'; inherits: true; initial-value: 1; }
:root {
  --rule-a: 1;
  /* ヘッダーのブラー上でも見えるUI用の線色(トグル枠・JA/EN の区切り) */
  --ui-line: color-mix(in srgb, var(--sub) 55%, var(--bg));
  transition: --rule-a .25s ease;
}
.rule-top,
.rule-bottom {
  background-image: linear-gradient(
    color-mix(in srgb, var(--line) calc(var(--rule-a) * 100%), transparent),
    color-mix(in srgb, var(--line) calc(var(--rule-a) * 100%), transparent));
  background-repeat: no-repeat;
  background-size: 100% 1px;
  background-origin: border-box;
}
.rule-top    { border-top: 1px solid transparent;    background-position: 0 0; }
.rule-bottom { border-bottom: 1px solid transparent; background-position: 0 100%; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  font-family: 'Helvetica Neue', Helvetica, Arial, 'Yu Gothic Medium', '游ゴシック Medium', YuGothic, '游ゴシック体', 'Yu Gothic', sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "palt";
  transition: background-color .3s, color .3s;
}

a { color: inherit; text-decoration: none; transition: opacity .2s; }
a:not(.has-roll, .work):hover { opacity: .6; }

h1, h2, h3, p, dl, dd { margin: 0; }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

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

.icon {
  width: 1.15em;
  height: 1.15em;
  fill: currentColor;
  flex: none;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 28px;
}

/* ---------- Header ---------- */

.header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 0;
}

/* プログレッシブブラー: ぼかしの強さが違う層を重ね、上ほど強く・下に行くほど弱く消えていく。
   画面幅いっぱいに敷くため fixed。最前面の <b> は背景色の薄いグラデーションで、写真の上でも文字を読みやすくする */
.header-blur {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 128px;
  z-index: -1;
  pointer-events: none;
}
.header-blur > * {
  position: absolute;
  inset: 0;
}
.header-blur > i {
  -webkit-backdrop-filter: blur(var(--b));
  backdrop-filter: blur(var(--b));
  /* どの層も一番上から消え始め、消えきる位置だけを段階的にずらす = 上端から下端までなだらかに弱まる */
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent var(--m));
  mask-image: linear-gradient(to bottom, #000, transparent var(--m));
}
.header-blur > i:nth-child(1) { --b: 1px;  --m: 100%; }
.header-blur > i:nth-child(2) { --b: 2px;  --m: 85%; }
.header-blur > i:nth-child(3) { --b: 4px;  --m: 70%; }
.header-blur > i:nth-child(4) { --b: 8px;  --m: 55%; }
.header-blur > i:nth-child(5) { --b: 16px; --m: 40%; }
.header-blur > b {
  background: var(--bg);
  opacity: .92;
  /* 上端ほぼ背景色 → 下端0 までなめらかに(ease-out 寄りの多段グラデで段差を出さない) */
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, rgba(0,0,0,.85) 25%, rgba(0,0,0,.6) 50%, rgba(0,0,0,.3) 75%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0,0,0,.85) 25%, rgba(0,0,0,.6) 50%, rgba(0,0,0,.3) 75%, transparent 100%);
  transition: background-color .3s;
}

.logo { display: block; color: var(--fg); }
.logo svg {
  display: block;
  width: 26px;
  height: 30px;
  fill: currentColor;
}

.controls {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 12px;
  letter-spacing: .02em;
}

/* Language switch */

.lang { display: flex; align-items: center; gap: 6px; }
/* トグル枠と同じ濃さ。テーマ切り替え時は罫線と同じフェード(--rule-a) */
.lang-sep { color: color-mix(in srgb, var(--ui-line) calc(var(--rule-a) * 100%), transparent); }
.lang-btn {
  color: var(--sub);
  padding: 4px 2px;
  transition: color .2s;
}
.lang-btn:hover { color: var(--fg); }
.lang-btn[aria-pressed="true"] { color: var(--fg); font-weight: 500; }

/* Theme toggle: the knob is a moon that turns into a crescent in dark mode */

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-track {
  position: relative;
  width: 40px;
  height: 22px;
  /* ヘッダーのブラーの上でも埋もれないよう、通常の罫線より濃くする */
  border: 1px solid var(--ui-line);
  border-radius: 999px;
  transition: border-color .3s;
}
.theme-toggle:hover .theme-track { border-color: var(--fg); }

.theme-moon {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--fg);
  overflow: hidden;
  transition: transform .6s var(--ease-out), background-color .3s;
}

/* The "bite" that carves the crescent, painted in the page background colour */
.theme-moon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--bg);
  transform: translate(110%, -110%);
  transition: transform .6s var(--ease-out) .08s, background-color .3s;
}

.theme-toggle[aria-checked="true"] .theme-moon { transform: translateX(18px) rotate(-20deg); }
.theme-toggle[aria-checked="true"] .theme-moon::after { transform: translate(38%, -18%); }

.theme-label { min-width: 2.6em; text-align: left; }

/* ---------- Hero ---------- */

.hero {
  padding: 112px 0 96px;
  text-align: center;
}

.hero-name {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(32px, 9vw, 104px);
  font-weight: 500;
  letter-spacing: -.035em;
  line-height: .95;
  white-space: nowrap;
  /* 「Y」の左下が空くぶん右に寄って見えるので、視覚的な中心へ少し左に寄せる */
  position: relative;
  left: -.04em;
}

/* 1. Names slide up from behind a mask */
.mask {
  display: block;
  overflow: hidden;
  padding: .08em .04em .14em;
  margin: -.08em -.04em -.14em;
}
.mask-inner {
  display: block;
  transform: translateY(110%);
  animation: rise .7s var(--ease-out) .1s forwards;
}
.mask-inner--late { animation-delay: .17s; }

/* 2. Space between the names opens up, 3. avatar scales in from the centre */
.avatar {
  display: block;
  flex: none;
  width: 0;
  height: 1.2em;
  margin: 0 .1em;
  animation: open-gap .55s var(--ease-inout) .6s forwards;
}
.avatar img {
  display: block;
  width: 1.2em;
  height: 1.2em;
  margin-left: -.6em;
  position: relative;
  left: 50%;
  border-radius: 50%;
  object-fit: cover;
  transform: scale(0);
  animation: pop .6s var(--ease-out) .85s forwards;
}

@keyframes rise { to { transform: translateY(0); } }
@keyframes open-gap { to { width: 1.2em; } }
@keyframes pop { to { transform: scale(1); } }

.hero-role {
  margin-top: 28px;
  font-size: 14px;
  color: var(--sub);
  letter-spacing: .02em;
}

/* ---------- Intro ----------
   1. 名前だけが画面の天地中央でアニメーション
   2. 名前が本来の位置へスライド
   3. 他の要素が名前と同じ「マスクの下からせり上がる」動きで順に出る
      - テキストは JS で1行ずつに分割し、各行が自分の行の高さ分だけせり上がる
      - アイコンやボタンなどは、その要素自身の高さ分だけせり上がる */

:root.intro-center,
:root.intro-hide { overflow: hidden; }
html { scrollbar-gutter: stable; }

:root.intro-center .hero-name { transform: translateY(var(--intro-y, 0)); }
.hero-name.settling { transition: transform .8s var(--ease-inout); }

/* 罫線は演出中は隠し、出現時にフェードで出る */
:root.intro-hide { --rule-a: 0; }

:root.intro-hide :is(.logo, .controls, .hero-role, .label, .about-text, .timeline dt, .timeline dd, .links, .card, .work-title, .work-desc, .work-meta, .footer span, .peek) {
  opacity: 0;
}

/* 行ごとのマスク(名前の .mask と同じ仕組み) */
.ln {
  display: block;
  overflow: hidden;
  padding: .12em 0 .2em;
  margin: -.12em 0 -.2em;
}
.ln-i { display: block; white-space: nowrap; }
:root.reveal .ln-i {
  animation: line-rise .8s var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes line-rise { from { transform: translateY(110%); } }

/* テキスト以外: 要素自身を下げつつ clip-path で元の位置に窓を固定 */
:root.reveal .r-rise {
  animation: mask-rise .8s var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes mask-rise {
  from { transform: translateY(100%); clip-path: inset(-100% -8px 100% -8px); }
  to   { transform: translateY(0);    clip-path: inset(0 -8px 0 -8px); }
}

/* 大きなカードとうさぎは浮き上がりながらフェード */
:root.reveal .r-fade {
  animation: soft-rise .9s var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes soft-rise { from { transform: translateY(32px); opacity: 0; } }

/* ---------- Hover: マスクロール ----------
   出現時と同じマスク表現。ホバーで中身が上に抜け、同じものが下から入ってくる(JSで複製)
   SNSアイコンは対象外(通常の透過ホバー) */

.roll {
  position: relative;
  display: inline-flex;
  vertical-align: top;
  overflow: hidden;
  padding: .04em 0;
  margin: -.04em 0;
}
.roll-track {
  position: relative;
  display: inline-flex;
}
.roll-a,
.roll-b { display: inline-flex; align-items: center; }
.roll-b {
  position: absolute;
  top: calc(100% + .06em);   /* 抜ける文字と入ってくる文字の間隔。静止時はマスク外に隠れる */
  left: 0;
}
/* ホバー(またはキーボードフォーカス)で一度発火したら最後まで流れる。
   途中で離れても止まらず、終わったら瞬時に元へ(中身は同じなので戻りは見えない) */
.is-rolling .roll-track { animation: roll .6s var(--ease-out); }
@keyframes roll { to { transform: translateY(calc(-100% - .06em)); } }

/* ---------- Sections ---------- */

.label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.about {
  display: flex;
  flex-wrap: wrap;
  gap: 40px var(--col-gap);
  padding: 72px 0;
}
.about .label { flex: 0 0 var(--col); }

.about-body {
  flex: 1 1 400px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.about-text { font-size: 16px; line-height: 2; text-wrap: pretty; }
:root[lang="en"] .about-text { line-height: 1.8; }

.timeline { font-size: 14px; }
.timeline-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  padding: 14px 0;
}
.timeline dt { color: var(--sub); }
/* 年号(欧文)と和文はフォントのメトリクスが違うので、日本語のときはベースラインで揃える */
:root[lang="ja"] .timeline-row { align-items: baseline; }

/* 日本語テキストだけ字間を広げる(英語表示・欧文のままの肩書きには影響させない) */
:root[lang="ja"] [data-i18n]:not(.hero-role) { letter-spacing: .04em; word-break: auto-phrase; }

.links { display: flex; align-items: center; gap: 28px; }

.sns {
  display: block;
  padding: 4px;
  margin: -4px;
}
.sns svg {
  display: block;
  width: 20px;
  height: 20px;
  fill: currentColor;
}
/* note のロゴは面積が大きく重く見えるので少し小さく */
.sns[aria-label="note"] svg { width: 16px; height: 16px; margin: 2px; }

.work-meta .icon { color: var(--sub); }

.featured {
  padding: 72px 0;
  container-type: inline-size;   /* カードは画面幅ではなく自分の幅で縦組みに切り替える */
}
.featured .label { margin-bottom: 40px; }

.card {
  --pad: clamp(24px, 5vw, 56px);
  background: var(--card);
  border-radius: 24px;
  padding: var(--pad) var(--pad) 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
  gap: 40px;
  overflow: hidden;
  transition: background-color .3s;
}

/* 左: アプリ情報(端末の高さに対して天地中央) / 右: 端末がカードの下端から立ち上がる */
.card-head {
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 32px;
  padding-bottom: var(--pad);
}

.device {
  display: block;
  align-self: end;
  width: 100%;
  height: auto;
}

.app { display: flex; align-items: center; gap: 20px; }
.app-icon {
  display: block;
  width: 84px;
  height: 84px;
  border-radius: 22px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .06);
}
.app-name {
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 500;
  letter-spacing: -.03em;
  line-height: 1;
}
.app-desc { margin-top: 10px; font-size: 15px; color: var(--sub); }

.cta {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--fg);
  color: var(--bg);
  padding: 14px 20px 14px 24px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
}

.works { padding: 72px 0; }
.works .label { margin-bottom: 32px; }

.work {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 28px 0;
}
/* ホバー背景: ポインタが入ってきた側(上/下)から伸び、出ていく側へ縮む。向きは JS が data-dir で指定 */
.work::before {
  content: "";
  position: absolute;
  inset: 0 -16px;
  z-index: -1;
  background: var(--card);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform .5s var(--ease-out), background-color .3s;
}
.work[data-dir="bottom"]::before { transform-origin: bottom; }
@media (hover: hover) and (pointer: fine) {
  .work.is-hover::before { transform: scaleY(1); }
}
/* 名前の列幅を About のラベル列と揃え、キャプションの左端を全行で一致させる */
.work-main { display: grid; grid-template-columns: var(--col) minmax(0, 1fr); align-items: center; gap: 12px var(--col-gap); }
.work-title { display: flex; align-items: center; gap: 12px; }
.work-icon {
  display: block;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
}
.work-name { font-size: clamp(22px, 3vw, 28px); font-weight: 500; letter-spacing: -.02em; }
.work-desc { font-size: 14px; color: var(--sub); }
.work-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--sub); }

/* ---------- Finale: フッター行に耳がかかるように、うさぎが下端から覗く ---------- */

.finale {
  --rw: clamp(160px, 30vw, 340px);              /* うさぎの幅 */
  --rh: calc(var(--rw) * 663.04 / 578.68);      /* SVGの縦横比 */
  position: relative;
  overflow: hidden;                             /* ページ下端でうさぎを見切れさせる */
}

.footer {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  padding-top: 32px;
  padding-bottom: 32px;
  font-size: 12px;
  color: var(--sub);
  line-height: 1.6;
}
.footer span:last-child { text-align: right; }
.footer .sp { display: none; }

.peek {
  display: flex;
  justify-content: center;
  height: calc(var(--rh) * .62);                /* 目の下で見切れる位置 */
  margin-top: calc(var(--rw) * -.1);            /* 耳先をフッター行に少し被せる */
}

.rabbit {
  display: block;
  flex: none;
  width: var(--rw);
  height: var(--rh);
  /* パララックス: --p(0→1)はスクロール量に応じてJSが更新。下端からせり上がる */
  transform: translateY(calc((1 - var(--p, 1)) * 55%));
  will-change: transform;
}
.rabbit-line { fill: var(--fg); transition: fill .3s; }

/* 横並びで左列が窮屈になる幅(約680px未満)では縦組み:
   ロゴ → アプリ名 → 注釈 → ボタン の順に中央揃え。ロゴは小さく */
@container (max-width: 680px) {
  .card { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .card-head { align-items: center; text-align: center; gap: 24px; padding-bottom: 0; }
  .app { flex-direction: column; gap: 14px; }
  .app-icon { width: 32px; height: 32px; border-radius: 8px; }   /* Other Works のアイコンと揃える */
  .app-desc { margin-top: 8px; }
  .device { justify-self: center; width: min(78%, 300px); }
}

/* ---------- Squircle (対応ブラウザのみ。非対応なら通常の角丸のまま) ---------- */
/* スーパー楕円は同じ半径だと角が小さく見えるので、値を大きめにとる */

@supports (corner-shape: squircle) {
  .app-icon  { border-radius: 38px; corner-shape: squircle; }
  @container (max-width: 680px) { .app-icon { border-radius: 14px; } }
  .card      { border-radius: clamp(44px, 7vw, 54px); corner-shape: squircle; }
  .work-icon { border-radius: 14px; corner-shape: squircle; }
}

/* ---------- Small screens ---------- */

@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  .hero { padding: 88px 0 72px; }
  /* 名前+アイコンの総幅は約7.5em。余白込みで画面幅に収まるよう 1/8.2 で算出し、PC側(9vw)と繋がるよう上限を設ける */
  .hero-name { font-size: min(calc((100vw - 32px) / 8.2), 54px); }
  .hero-role { margin-top: 20px; font-size: 12px; }
  .controls { gap: 14px; }
  .timeline-row { grid-template-columns: 64px 1fr; }
  /* スマホでは About の手動改行・文節改行をやめて自然に流す */
  .about-text br { display: none; }
  .work-main { grid-template-columns: minmax(0, 1fr); }
  /* 耳とぶつからないよう、フッターの文字を左右に2行で寄せる */
  .footer .sp { display: inline; }
  /* うさぎはパララックスせず、見えたら一度だけひょこっと出る(JS が .is-visible を付与) */
  .rabbit { transform: translateY(45%); transition: transform 1s var(--ease-out); }
  .finale.is-visible .rabbit { transform: none; }
  :root[lang="ja"] .about-text { word-break: normal; }
}

@media (prefers-reduced-motion: reduce) {
  .mask-inner, .avatar, .avatar img { animation-duration: .01s; animation-delay: 0s; }
  .theme-moon, .theme-moon::after, .work::before, .rabbit { transition-duration: .01s; }
  :root { transition-duration: .01s; }
}
