/* ==========================================================================
   karupas ポートフォリオ — Quiet Craft & Interactive Experience
   色: グラファイトの地 + 緑青（パティナ）のアクセント。3D のキーライトだけ暖色
   ========================================================================== */

:root {
  --bg: #191b20;          /* ページの地 */
  --bg-deep: #131519;     /* ヒーローの奥、フッター */
  --surface: #20232a;     /* タイルの面 */
  --surface-2: #272b33;
  --line: #2f333b;
  --line-strong: #444a55;
  --text: #ece9e3;        /* 紙のような白 */
  --muted: #9b9fa8;
  --accent: #a9cbb7;      /* 緑青（パティナ） */
  --accent-ink: #14201a;  /* アクセントの上に置く文字 */
  --warm: #e8bd8f;        /* キーライトの色（3D とフォールバックだけで使う） */

  --gutter: clamp(16px, 5vw, 96px);   /* 画面の左右の余白。全セクションでそろえる */
  --section-space: clamp(96px, 16vw, 200px);
  --radius-l: 20px;
  --radius-s: 10px;

  /* 動きの手触り。ゆっくり止まるイージングを全体で共有する */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  --font-display: "Bricolage Grotesque", "Zen Kaku Gothic New", system-ui, sans-serif;
  --font-body: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP",
               "BIZ UDPGothic", Meiryo, system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px; /* 固定ヘッダーの下に見出しが隠れないようにする */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 clamp(15px, 0.35vw + 14px, 17px)/1.9 var(--font-body);
  letter-spacing: 0.02em;
  line-break: strict;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; }

a { color: var(--accent); text-underline-offset: 0.25em; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 6px;
}
main:focus { outline: none; } /* スキップリンクで移動したときの枠は出さない */

::selection { background: var(--accent); color: var(--accent-ink); }

.skip-link {
  position: fixed;
  left: 16px;
  top: -64px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius-s);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
  transition: top 0.3s var(--ease-out);
}
.skip-link:focus { top: 16px; }

.wrap {
  max-width: 1440px;
  margin: 0 auto;
}

/* ---------- ヘッダー（すりガラス） ---------- */
.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px var(--gutter);
  transition: background-color 0.5s var(--ease-out), border-color 0.5s var(--ease-out);
  border-bottom: 1px solid transparent;
}
/* 少しスクロールしたら、すりガラスの帯を出す（js/main.js が is-scrolled を付ける） */
.site-header.is-scrolled {
  background: rgba(25, 27, 32, 0.62);
  border-bottom-color: rgba(255, 255, 255, 0.06);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
}
.site-header__brand {
  color: var(--text);
  font: 500 20px/1 var(--font-display);
  letter-spacing: -0.01em;
  text-decoration: none;
}
.site-header__nav {
  position: relative;
  isolation: isolate; /* 光の帯（z-index: -1）を、ナビの中だけで後ろに回す */
  display: flex;
  gap: 2px;
}
/* いま読んでいるセクションの後ろに敷く、ほのかな光の帯。セクションが変わると横へ滑る */
.site-header__marker {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: -1;
  width: 0;
  border-radius: 999px;
  background: rgba(169, 203, 183, 0.1);
  box-shadow: inset 0 0 0 1px rgba(169, 203, 183, 0.22);
  opacity: 0;
  transition:
    transform 0.6s var(--ease-out),
    width 0.6s var(--ease-out),
    opacity 0.4s var(--ease-out);
  pointer-events: none;
}
.site-header__nav.has-current .site-header__marker { opacity: 1; }
.site-header__nav a {
  position: relative;
  padding: 10px clamp(8px, 1.4vw, 16px);
  color: var(--muted);
  font: 400 15px/1 var(--font-display);
  text-decoration: none;
  transition: color 0.3s var(--ease-out);
}
/* 下線は左から伸びる（ホバーしたとき）。いま見ているセクションは、文字の色と光の帯で示す */
.site-header__nav a::after {
  content: "";
  position: absolute;
  left: clamp(8px, 1.4vw, 16px);
  right: clamp(8px, 1.4vw, 16px);
  bottom: 4px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s var(--ease-out);
}
.site-header__nav a:hover { color: var(--text); }
.site-header__nav a[aria-current="true"] { color: var(--accent); }
.site-header__nav a:hover::after { transform: scaleX(1); }
.site-header__nav a[aria-current="true"]::after { transform: scaleX(0); }

/* ---------- ボタン ---------- */
.button {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  min-height: 52px;
  padding: 15px 26px 13px;
  overflow: hidden;
  isolation: isolate;
  border-radius: 999px;
  font: 500 16px/1.4 var(--font-display);
  letter-spacing: 0;
  text-decoration: none;
  transition: color 0.45s var(--ease-out), border-color 0.45s var(--ease-out), transform 0.45s var(--ease-out);
}
.button__sub {
  font: 400 12px/1.4 var(--font-body);
  opacity: 0.72;
}
/* 塗りは下から満ちていく */
.button::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  transform: translateY(101%);
  transition: transform 0.5s var(--ease-out);
}
.button:hover::before { transform: translateY(0); }
.button:active { transform: scale(0.97); }

.button--solid {
  background: var(--accent);
  color: var(--accent-ink);
}
.button--solid::before { background: var(--text); }

.button--ghost {
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: rgba(25, 27, 32, 0.35);
}
.button--ghost::before { background: var(--text); }
.button--ghost:hover { color: var(--bg); border-color: var(--text); }

.button--large {
  min-height: 60px;
  padding: 18px 34px 16px;
  font-size: 17px;
}

/* ---------- ヒーロー ---------- */
.hero {
  position: relative;
  display: grid;
  align-items: end;
  min-height: max(100svh, 600px);
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 70% 40%, #22252c 0%, var(--bg) 55%, var(--bg-deep) 100%);
}
.hero__scene {
  position: absolute;
  inset: 0;
}
.hero__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1.6s var(--ease-out);
}
.hero.is-3d .hero__canvas { opacity: 1; }

/* WebGL が使えないとき（と、3D が準備できるまで）の、CSS で描いた光の玉 */
.hero__fallback {
  position: absolute;
  inset: 0;
  transition: opacity 1.2s var(--ease-out);
}
.hero.is-3d .hero__fallback { opacity: 0; }
.hero__orb {
  position: absolute;
  left: 50%;
  top: 30%;
  width: min(72vw, 420px);
  aspect-ratio: 1;
  border-radius: 46% 54% 52% 48% / 50% 46% 54% 50%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 34% 30%, rgba(255, 236, 214, 0.9) 0%, rgba(232, 189, 143, 0.55) 14%, transparent 42%),
    radial-gradient(circle at 78% 82%, rgba(143, 182, 255, 0.4) 0%, transparent 38%),
    radial-gradient(circle at 50% 50%, #3a3d45 0%, #24272e 62%, #1b1d22 100%);
  box-shadow:
    0 60px 120px -40px rgba(0, 0, 0, 0.7),
    0 0 160px -20px rgba(232, 189, 143, 0.18);
  animation: orb-breathe 14s var(--ease-in-out) infinite alternate;
}
@keyframes orb-breathe {
  to { border-radius: 54% 46% 48% 52% / 46% 54% 46% 54%; transform: translate(-50%, -52%) rotate(8deg); }
}
/* 文字が乗る下側を、地の色へなじませる幕 */
.hero__scene::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 40%, rgba(19, 21, 25, 0.75) 78%, var(--bg) 100%);
}

.hero__text {
  position: relative;
  z-index: 2;
  display: grid;
  gap: clamp(14px, 2vw, 24px);
  padding: 120px var(--gutter) clamp(72px, 10vw, 112px);
  pointer-events: none; /* 3D のポインター操作を邪魔しない。ボタンだけ触れるようにする */
}
.hero__text > * { margin: 0; }
.hero__actions { pointer-events: auto; }

.hero__role {
  color: var(--accent);
  font: 400 clamp(14px, 1.2vw, 17px)/1.4 var(--font-display);
  letter-spacing: 0.01em;
}
.hero__title {
  margin-left: -0.05em; /* 大きな k の左の余白を、ほかの行の左端にそろえる */
  font: 300 clamp(76px, 19vw, 280px)/0.82 var(--font-display);
  font-variation-settings: "opsz" 96;
  letter-spacing: -0.055em;
}
.hero__lead {
  max-width: 34em;
  font-size: clamp(18px, 1.9vw, 26px);
  font-weight: 500;
  line-height: 1.7;
  letter-spacing: 0.04em;
}
.hero__lead span { display: inline-block; } /* 文節の途中で折り返さない */
.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: clamp(4px, 1vw, 12px);
}

/* 操作のヒント（3D が動いたときだけ出す） */
.hero__hint {
  position: absolute;
  z-index: 2;
  right: var(--gutter);
  bottom: clamp(72px, 10vw, 112px);
  display: none;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  writing-mode: vertical-rl;
  letter-spacing: 0.12em;
}
.hero.is-3d .hero__hint:not([hidden]) {
  display: flex;
  animation: hint-in 1.2s var(--ease-out) 0.6s both;
}
/* 操作したら（またはスクロールしたら）、静かに消える（js/main.js が is-leaving を付ける） */
.hero.is-3d .hero__hint.is-leaving {
  animation: hint-out 0.9s var(--ease-out) both;
}
@keyframes hint-in {
  from { opacity: 0; transform: translateY(10px); }
}
@keyframes hint-out {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px); filter: blur(4px); }
}
@media (max-width: 599px) {
  /* スマホでは縦書きをやめ、ボタンの下に横書きで置く */
  .hero__hint {
    bottom: 26px;
    left: 0;
    right: 0;
    justify-content: center;
    writing-mode: horizontal-tb;
    letter-spacing: 0.06em;
  }
}
.hero__hint-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warm);
  box-shadow: 0 0 12px var(--warm);
}

/* 読み込み時の、ただ一度の登場 */
.js .hero__role,
.js .hero__title,
.js .hero__lead,
.js .hero__actions {
  opacity: 0;
  transform: translateY(24px);
  animation: hero-in 1.4s var(--ease-out) forwards;
}
.js .hero__title { animation-delay: 0.1s; }
.js .hero__lead { animation-delay: 0.35s; }
.js .hero__actions { animation-delay: 0.5s; }
@keyframes hero-in {
  to { opacity: 1; transform: none; }
}

@media (min-width: 900px) {
  .hero__orb {
    left: 68%;
    top: 44%;
    width: min(40vw, 560px);
  }
  .hero__scene::after {
    background:
      linear-gradient(90deg, rgba(19, 21, 25, 0.55) 0%, transparent 50%),
      linear-gradient(180deg, transparent 60%, var(--bg) 100%);
  }
}

/* ---------- セクション共通 ---------- */
.section {
  padding: var(--section-space) var(--gutter) 0;
}
.section--contact { padding-bottom: var(--section-space); }

.section__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 20px;
  margin-bottom: clamp(48px, 7vw, 96px);
}
.section__title {
  margin: 0;
  font: 300 clamp(56px, 10vw, 148px)/0.9 var(--font-display);
  font-variation-settings: "opsz" 96;
  letter-spacing: -0.045em;
}
.section__sub {
  margin: 0;
  color: var(--muted);
  font-size: clamp(14px, 1.2vw, 16px);
  letter-spacing: 0.12em;
}

/* スクロールで現れる（js/main.js が is-visible を付ける）。JS が無ければ最初から見える */
.js .reveal {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity 1.1s var(--ease-out), transform 1.1s var(--ease-out), border-color 0.6s var(--ease-out);
  transition-delay: var(--reveal-delay, 0s);
}
.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ---------- Works ---------- */
.works {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr));
  gap: clamp(56px, 6vw, 88px) clamp(24px, 3vw, 48px);
  margin: 0;
  padding: 0;
  list-style: none;
}
.works__status {
  margin: 24px 0 0;
  color: var(--muted);
}
.works__status:empty { display: none; }

.work {
  position: relative; /* 見出しのボタンの押せる範囲を、カード全体に広げる基準 */
  display: flex;
  flex-direction: column;
  gap: 22px;
  cursor: pointer;
}
/* 2 列のとき、右の列を少し下げてリズムをつける */
@media (min-width: 1000px) {
  .work:nth-child(even) { margin-top: clamp(48px, 8vw, 120px); }
}

.work__shot {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: var(--radius-l);
  background: var(--surface);
}
.work__shot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.001);
  transition: transform 1.2s var(--ease-out), filter 1.2s var(--ease-out);
  filter: saturate(0.88);
}
/* 縁取りは内側に重ねる（画像の上に乗るので、角まできれいに光る） */
.work__shot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  transition: box-shadow 0.6s var(--ease-out);
  pointer-events: none;
}
.work:hover .work__shot img,
.work:focus-within .work__shot img {
  transform: scale(1.045);
  filter: saturate(1);
}
.work:hover .work__shot::after,
.work:focus-within .work__shot::after {
  box-shadow: inset 0 0 0 1px var(--accent);
}
/* ホバーで画像の上に浮かぶ「詳しく見る」 */
.work__view {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 14px 24px 12px;
  border-radius: 999px;
  background: rgba(19, 21, 25, 0.66);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  color: var(--text);
  font: 500 15px/1.2 var(--font-display);
  opacity: 0;
  transform: translate(-50%, -40%);
  transition: opacity 0.5s var(--ease-out), transform 0.6s var(--ease-out);
  pointer-events: none;
}
.work__view small {
  color: var(--muted);
  font: 400 11px/1.4 var(--font-body);
  letter-spacing: 0.08em;
}
.work:hover .work__view,
.work:has(.work__open:focus-visible) .work__view {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.work__body {
  display: grid;
  gap: 12px;
  max-width: 40em;
}
.work__body > * { margin: 0; }
.work__title {
  font-size: clamp(22px, 2.2vw, 30px);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.04em;
}
/* 自主制作の表記（Concept Work）。見出しの上に小さく添える */
.work__label {
  color: var(--accent);
  font: 400 13px/1.6 var(--font-display);
  letter-spacing: 0.04em;
}
.work__summary { color: var(--muted); }

/* 見出しの中のボタン。見た目は見出しのまま、押せる範囲（::after）をカード全体に広げる */
.work__open {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}
.work__open::after {
  content: "";
  position: absolute;
  inset: -12px;
  z-index: 1;
  border-radius: calc(var(--radius-l) + 8px);
}
.work__open:focus-visible { outline: none; }
.work__open:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 4px; }

.work__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 28px;
  margin-top: 4px;
}
.work__cue {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--text);
  font: 500 16px/1.4 var(--font-display);
}
.work__cue::before {
  content: "+";
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--accent);
  font: 400 15px/1 var(--font-display);
  transition: transform 0.6s var(--ease-out), border-color 0.4s var(--ease-out);
}
.work:hover .work__cue::before { transform: rotate(90deg); border-color: var(--accent); }

.work__link {
  position: relative;
  z-index: 2; /* カード全体に広げたボタンより上に置き、直接サイトを開けるようにする */
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: start;
  min-height: 44px;
  color: var(--muted);
  font: 500 16px/1.4 var(--font-display);
  text-decoration: none;
  transition: color 0.4s var(--ease-out);
}
.work__link:hover { color: var(--text); }
.work__link svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  transition: transform 0.5s var(--ease-out);
}
.work__link span {
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size 0.5s var(--ease-out);
}
.work__link:hover span { background-size: 100% 1px; }
.work__link:hover svg { transform: translate(3px, -3px); }
.work__link.is-pending { color: var(--muted); font-weight: 400; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.chips li {
  padding: 4px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font: 400 13px/1.6 var(--font-display);
  letter-spacing: 0.01em;
  transition: border-color 0.4s var(--ease-out), color 0.4s var(--ease-out);
}

/* ---------- About ---------- */
.about__intro {
  display: grid;
  gap: 24px;
  max-width: 46em;
  margin-bottom: clamp(56px, 8vw, 112px);
}
.about__intro p { margin: 0; color: var(--muted); }
.about__intro .about__statement {
  color: var(--text);
  font-size: clamp(22px, 3vw, 38px);
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: 0.03em;
  word-break: keep-all; /* 折り返しは <wbr> の位置で */
}

/* ベントーグリッド: 3D のタイルを大きく、残り 2 つを右に積む */
.bento {
  display: grid;
  gap: clamp(12px, 1.4vw, 20px);
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 900px) {
  .bento {
    grid-template-columns: 1.15fr 1fr;
    grid-template-rows: auto auto;
  }
  .bento__tile--3d { grid-row: span 2; }
}

.bento__tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(28px, 3.4vw, 48px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--surface);
  transition: border-color 0.6s var(--ease-out), background-color 0.6s var(--ease-out);
}
/* カーソルの近くだけ、ほのかに光を当てる（--mx / --my は js/main.js が入れる） */
.bento__tile::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 0%), rgba(232, 189, 143, 0.08), transparent 60%);
  opacity: 0;
  transition: opacity 0.6s var(--ease-out);
}
.bento__tile:hover { border-color: var(--line-strong); }
.bento__tile:hover::before { opacity: 1; }
.bento__tile p {
  position: relative;
  margin: 0;
  max-width: 34em;
  color: var(--muted);
}
.bento__title {
  position: relative;
  display: grid;
  gap: 4px;
  margin: 0;
  font: 400 clamp(24px, 2.4vw, 34px)/1.15 var(--font-display);
  letter-spacing: -0.02em;
}
.bento__title span {
  color: var(--accent);
  font: 400 14px/1.6 var(--font-body);
  letter-spacing: 0.1em;
}
.bento__art {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(120px, 14vw, 170px);
  margin-bottom: auto;
  padding-bottom: 12px;
}
.bento__tile--3d .bento__art {
  flex: 1; /* 縦長のタイルでは、余った高さの真ん中に立方体を置く */
  min-height: clamp(180px, 22vw, 320px);
  height: auto;
}

/* タイルのアートが動く合図: ホバー（JS が無いとき）か is-engaged（js/main.js が付ける。
   ホバーできる端末ではカーソルが乗ったとき、タッチ端末ではタイルが画面の中ほどに来たとき） */

/* 立方体（3D タイル）: ゆっくり回り続け、ホバーで速く回って覗き込む角度へ。
   面の明るさ（--d: 光の当たり具合、--s: 照り返し）は js/main.js が光の向きから計算する */
.cube {
  --size: clamp(90px, 12vw, 180px);
  --gain: 0;
  position: relative;
  width: var(--size);
  height: var(--size);
  transform-style: preserve-3d;
  transform: rotateX(-24deg) rotateY(38deg);
  transition: transform 1.4s var(--ease-out);
}
.cube.is-live { transition: none; } /* JS が毎フレーム角度を入れるときは、transition を切る */
.cube span {
  --d: 0.4;
  --s: 0;
  position: absolute;
  inset: 0;
  border: 1px solid rgba(169, 203, 183, calc(0.3 + var(--d) * 0.45 + var(--s) * 0.4));
  background:
    /* 照り返し: 光の側の角から差し込むハイライト */
    linear-gradient(135deg, rgba(236, 233, 227, calc(var(--s) * 0.38)) 0%, transparent 55%),
    rgba(169, 203, 183, calc(0.02 + var(--d) * 0.11));
  box-shadow: 0 0 calc(var(--s) * 28px) rgba(169, 203, 183, calc(var(--s) * 0.35 * var(--gain)));
}
.cube span:nth-child(1) { transform: translateZ(calc(var(--size) / 2)); }
.cube span:nth-child(2) { transform: rotateY(180deg) translateZ(calc(var(--size) / 2)); }
.cube span:nth-child(3) { transform: rotateY(90deg) translateZ(calc(var(--size) / 2)); }
.cube span:nth-child(4) { transform: rotateY(-90deg) translateZ(calc(var(--size) / 2)); }
.cube span:nth-child(6) { transform: rotateX(-90deg) translateZ(calc(var(--size) / 2)); }
/* 上の面だけ、キーライトの暖色 */
.cube span:nth-child(5) {
  transform: rotateX(90deg) translateZ(calc(var(--size) / 2));
  border-color: rgba(232, 189, 143, calc(0.35 + var(--d) * 0.45 + var(--s) * 0.4));
  background:
    linear-gradient(135deg, rgba(255, 243, 227, calc(var(--s) * 0.5)) 0%, transparent 60%),
    rgba(232, 189, 143, calc(0.06 + var(--d) * 0.16));
  box-shadow: 0 0 calc(var(--s) * 36px) rgba(232, 189, 143, calc(var(--s) * 0.45 * var(--gain)));
}
.bento__tile--3d .bento__art { perspective: 700px; }
/* 床に落ちる影。ホバーで光が強まると、くっきりする */
.bento__tile--3d .bento__art::after {
  content: "";
  position: absolute;
  left: 50%;
  top: calc(50% + clamp(90px, 12vw, 180px) * 0.82); /* 立方体のすぐ下 */
  width: clamp(90px, 12vw, 180px);
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.55), transparent);
  transform: translateX(-50%) scaleX(1.1);
  opacity: 0.5;
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}
.bento__tile--3d:is(:hover, .is-engaged) .bento__art::after { opacity: 0.85; transform: translateX(-50%) scaleX(0.9); }
/* JS が動かないときだけ、ホバーで向きを変える */
.bento__tile--3d:hover .cube:not(.is-live) { transform: rotateX(-36deg) rotateY(218deg); }

/* 迷う線と、まっすぐな線（人に寄り添うタイル）:
   ホバーで迷う線の揺れが減衰して直線におさまり（js/main.js）、同時に最短の線が描かれる */
.path-art {
  width: min(100%, 260px);
  overflow: visible;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.path-art__wander {
  stroke: var(--muted);
  stroke-width: 1.5;
  stroke-dasharray: 3 7;
  opacity: 0.7;
  transition: opacity 1.2s var(--ease-out), stroke 1.2s var(--ease-out);
}
.path-art__direct {
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  filter: drop-shadow(0 0 0 rgba(169, 203, 183, 0));
  transition: stroke-dashoffset 1.1s var(--ease-in-out), filter 0.8s var(--ease-out);
}
.path-art__start { fill: var(--muted); transition: fill 0.5s var(--ease-out); }
.path-art__goal {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 1.5;
  transition: fill 0.5s var(--ease-out);
}
.path-art__pulse {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
}
.bento__tile--human:is(:hover, .is-engaged) .path-art__wander { opacity: 0.22; stroke: var(--line-strong); }
.bento__tile--human:is(:hover, .is-engaged) .path-art__direct {
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 6px rgba(169, 203, 183, 0.55));
  transition-delay: 0.35s, 0.9s; /* 揺れが落ち着きはじめてから、線を引く */
}
.bento__tile--human:is(:hover, .is-engaged) .path-art__start { fill: var(--accent); }
.bento__tile--human:is(:hover, .is-engaged) .path-art__goal { fill: var(--accent); transition-delay: 1.35s; }
/* ゴールに着いたら、波紋が一度ひろがる */
.bento__tile--human:is(:hover, .is-engaged) .path-art__pulse { animation: goal-pulse 1.1s var(--ease-out) 1.35s both; }
@keyframes goal-pulse {
  from { opacity: 0.9; transform: scale(1); }
  to { opacity: 0; transform: scale(2.6); }
}

/* 絞り（ビジュアルのタイル）:
   羽根が 1 枚ずつ外側の付け根を軸に回って絞りが開き、奥の光の点にピントが合う。
   ぼけた点光源は大きく淡い円（玉ぼけ）になり、ピントが合うと小さく鋭い点になる */
.lens {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(110px, 11vw, 140px);
  aspect-ratio: 1;
}
.aperture {
  width: 100%;
  overflow: visible;
}
.aperture__glass { fill: #15171b; }
.aperture__subject {
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(1.7);
  opacity: 0.35;
  transition: transform 1s var(--ease-out), opacity 1s var(--ease-out);
}
.aperture__ring {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1.5;
  transition: stroke 0.8s var(--ease-out);
}
.aperture__ticks {
  stroke: var(--line-strong);
  stroke-width: 1.2;
  transform: rotate(0deg);
  transition: transform 1.4s var(--ease-in-out), stroke 0.8s var(--ease-out);
}
.aperture__blades path {
  --blade: 0deg; /* 付け根まわりの回り具合。0 で絞り込み、マイナスで開く */
  --spin: 0deg;  /* 羽根全体の回転 */
  fill: var(--surface-2);
  stroke: rgba(232, 189, 143, 0.55);
  stroke-width: 0.8;
  stroke-linejoin: round;
  transform-origin: 0 0;
  transform:
    rotate(calc(var(--i) * 60deg + var(--spin)))
    translate(0, -50px) rotate(var(--blade)) translate(0, 50px);
  /* 少しだけ行き過ぎて止まる、機械の精密な動き */
  transition: transform 1.1s cubic-bezier(0.3, 1.25, 0.4, 1);
}
.bento__tile--visual:is(:hover, .is-engaged) .aperture__blades path { --blade: -34deg; --spin: 24deg; }
.bento__tile--visual:is(:hover, .is-engaged) .aperture__ticks { transform: rotate(-30deg); stroke: var(--muted); }
.bento__tile--visual:is(:hover, .is-engaged) .aperture__ring { stroke: rgba(232, 189, 143, 0.6); }
/* 絞りが開ききるころ、ピントが合う */
.bento__tile--visual:is(:hover, .is-engaged) .aperture__subject {
  transform: scale(0.42);
  opacity: 1;
  transition-delay: 0.45s;
}

/* オートフォーカスの枠: ふだんは広く淡い。ピントが合うと縮み、緑青で 2 回またたく */
.af-frame {
  position: absolute;
  inset: -16%;
  max-width: none; /* 全体の svg { max-width: 100% } が効くと幅が縮み、枠が左上へずれる */
  overflow: visible;
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1.5;
  stroke-linecap: round;
  transform: scale(1.12);
  opacity: 0.6;
  transition: transform 0.7s var(--ease-out), stroke 0.3s var(--ease-out), opacity 0.6s var(--ease-out);
  pointer-events: none;
}
.bento__tile--visual:is(:hover, .is-engaged) .af-frame {
  transform: scale(0.94);
  stroke: var(--accent);
  opacity: 1;
  transition-delay: 0.7s;
  animation: af-lock 0.28s linear 1.3s 2;
}
@keyframes af-lock {
  50% { opacity: 0.2; }
}

/* ---------- Skills ---------- */
.skills {
  margin: 0;
  border-top: 1px solid var(--line);
}
.skills__row {
  display: grid;
  gap: 16px;
  padding: clamp(24px, 3vw, 40px) 0;
  border-bottom: 1px solid var(--line);
}
@media (min-width: 760px) {
  .skills__row {
    grid-template-columns: minmax(200px, 1fr) 2.2fr;
    align-items: baseline;
  }
}
.skills__row dt {
  font: 400 clamp(22px, 2.4vw, 32px)/1.2 var(--font-display);
  letter-spacing: -0.02em;
}
.skills__row dd { margin: 0; }
.skills .chips { gap: 10px; }
.skills .chips li {
  padding: 8px 18px;
  color: var(--text);
  font-size: 15px;
}
.skills__row:hover .chips li { border-color: var(--line-strong); }
.skills .chips li:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Contact ---------- */
.contact {
  display: grid;
  gap: clamp(20px, 2.4vw, 32px);
}
.contact__message {
  margin: 0;
  font-size: clamp(32px, 6vw, 80px);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.02em;
  word-break: keep-all; /* 折り返しは <wbr> の位置で */
}
.contact__note {
  max-width: 32em;
  margin: 0;
  color: var(--muted);
}
.contact__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 28px;
  margin-top: clamp(12px, 2vw, 24px);
}
/* アドレスとコピーのボタン。メールアプリが無い人は、ここからコピーして使う */
.contact__address {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
.contact__email {
  font: 400 16px/1.4 var(--font-display);
  overflow-wrap: anywhere;
  user-select: all; /* 1 回のクリックで全体を選べる */
}
.contact__copy {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: none;
  color: var(--text);
  font: 400 14px/1 var(--font-body);
  cursor: pointer;
  transition: border-color 0.4s var(--ease-out), color 0.4s var(--ease-out);
}
.contact__copy:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.contact__copy-status {
  color: var(--accent);
  font-size: 13px;
}
.contact__copy-status:empty { display: none; }

/* ---------- 作品の詳細モーダル ---------- */
/* 開いているあいだは、後ろのページをスクロールさせない */
html:has(.work-modal[open]) { overflow: hidden; }

.work-modal {
  width: min(100% - 32px, 920px);
  max-width: none;
  max-height: min(100svh - 48px, 1000px);
  margin: auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-l);
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 40px 120px -20px rgba(0, 0, 0, 0.7);
  /* 開く: 少し下から、ピントが合うように現れる */
  opacity: 0;
  transform: translateY(28px) scale(0.98);
  filter: blur(6px);
  transition:
    opacity 0.45s var(--ease-out),
    transform 0.6s var(--ease-out),
    filter 0.5s var(--ease-out);
}
.work-modal::backdrop {
  background: rgba(10, 11, 14, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.45s var(--ease-out);
}
.work-modal.is-open { opacity: 1; transform: none; filter: none; }
.work-modal.is-open::backdrop { opacity: 1; }
/* 閉じる: 少しだけ沈みながら消える */
.work-modal.is-closing {
  transform: translateY(12px) scale(0.99);
  transition-duration: 0.35s;
}

.work-modal__panel {
  max-height: inherit;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.work-modal__close {
  position: absolute; /* 基準はダイアログ。中身をスクロールしても、右上に残る */
  top: 14px;
  right: 14px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background: rgba(19, 21, 25, 0.66);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.4s var(--ease-out), transform 0.5s var(--ease-out);
}
.work-modal__close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}
.work-modal__close:hover { border-color: var(--accent); transform: rotate(90deg); }

.work-modal__shot {
  margin: 0;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--surface);
}
.work-modal__shot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.06);
  transition: transform 1.4s var(--ease-out);
}
.work-modal.is-open .work-modal__shot img { transform: none; }

.work-modal__body {
  display: grid;
  gap: clamp(28px, 4vw, 44px);
  padding: clamp(24px, 4.5vw, 56px);
}
/* 中身は、写真のあとに少しずつ順に現れる */
.work-modal__body > * {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.7s var(--ease-out), transform 0.8s var(--ease-out);
}
.work-modal.is-open .work-modal__body > * { opacity: 1; transform: none; }
.work-modal.is-open .work-modal__body > :nth-child(2) { transition-delay: 0.06s; }
.work-modal.is-open .work-modal__body > :nth-child(3) { transition-delay: 0.12s; }
.work-modal.is-open .work-modal__body > :nth-child(n + 4) { transition-delay: 0.18s; }
.work-modal.is-closing .work-modal__body > * { transition-delay: 0s; }

.work-modal__head { display: grid; gap: 10px; }
.work-modal__head > * { margin: 0; }
.work-modal__meta {
  color: var(--accent);
  font: 400 14px/1.6 var(--font-display);
  letter-spacing: 0.04em;
}
.work-modal__meta:empty { display: none; }
.work-modal__title {
  font-size: clamp(26px, 3.6vw, 40px);
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: 0.04em;
}
.work-modal__summary { color: var(--muted); }

/* 制作背景・ターゲット */
.work-modal__facts {
  display: grid;
  gap: 1px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--line);
}
@media (min-width: 760px) {
  .work-modal__facts { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
}
.work-modal__facts > div {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: clamp(18px, 2.4vw, 26px);
  background: var(--surface);
}
.work-modal__facts dt {
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.12em;
}
.work-modal__facts dd { margin: 0; font-size: 15px; line-height: 1.85; }

/* こだわりポイント: 番号つきの縦の流れ */
.work-modal__points h3 {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.12em;
}
.work-modal__points ol {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: point;
}
.work-modal__points li {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 20px 0 20px 56px;
  border-top: 1px solid var(--line);
  counter-increment: point;
}
.work-modal__points li:last-child { border-bottom: 1px solid var(--line); }
.work-modal__points li::before {
  content: counter(point, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 21px;
  color: var(--accent);
  font: 300 22px/1.2 var(--font-display);
  letter-spacing: -0.02em;
}
.work-modal__points h4 {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: 0.03em;
}
.work-modal__points p { margin: 0; color: var(--muted); font-size: 15px; }

.work-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.work-modal__actions .button { align-items: center; }
.button__icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  transition: transform 0.5s var(--ease-out);
}
.button:hover .button__icon { transform: translate(2px, -2px); }

[hidden] { display: none !important; } /* hidden を付けた項目は、どの表示指定よりも優先して隠す */

@media (max-width: 599px) {
  /* スマホでは、下からせり上がるシートにする */
  .work-modal {
    width: 100%;
    max-height: calc(100svh - 24px);
    margin: auto 0 0;
    border-radius: var(--radius-l) var(--radius-l) 0 0;
    border-bottom: 0;
    transform: translateY(48px);
  }
  .work-modal.is-closing { transform: translateY(32px); }
  .work-modal__points li { padding-left: 44px; }
  .work-modal__actions .button { flex: 1 1 auto; justify-content: center; }
}

/* ---------- フッター ---------- */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding: 32px var(--gutter) 40px;
  border-top: 1px solid var(--line);
  background: var(--bg-deep);
  color: var(--muted);
  font: 400 14px/1.6 var(--font-display);
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

/* ---------- スマホ ---------- */
@media (max-width: 599px) {
  .site-header { padding-block: 10px; }
  .site-header__brand { font-size: 18px; }
  .site-header__nav a { padding-inline: 7px; font-size: 14px; }
  .site-header__nav a::after { left: 7px; right: 7px; }
  .hero__actions .button { flex: 1 1 auto; justify-content: center; }
  .contact__actions .button { width: 100%; justify-content: center; }
}

/* ---------- 動きを減らす設定のとき ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
  .js .reveal { transform: none; }
}
