/* r-kusunoki.com — モノクロの展示室。色は写真にだけ出す */
:root {
  --black: #000;
  --graphite: #1c1c1b;
  --ash: #7a7975;
  --bone: #e8e6e1;

  --mincho: "Zen Old Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --gothic: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", sans-serif;

  --gutter: clamp(16px, 3vw, 40px);
  --ease: cubic-bezier(.22, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--black);
  color: var(--bone);
  font-family: var(--gothic);
  font-size: 15px;
  line-height: 1.9;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
body[data-view="about"] { overflow-y: auto; }
a { color: inherit; }
img { display: block; max-width: 100%; }

:focus-visible { outline: 1px solid var(--bone); outline-offset: 4px; }

.sr, .photo-list {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip {
  position: fixed; left: var(--gutter); top: -60px; z-index: 50;
  background: var(--bone); color: var(--black); padding: 6px 12px; text-decoration: none;
}
.skip:focus { top: 12px; }

/* ── ヘッダー ─────────────────────────── */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  display: flex; justify-content: space-between; align-items: baseline;
  padding: calc(var(--gutter) * .8) var(--gutter);
  padding-top: max(calc(var(--gutter) * .8), env(safe-area-inset-top));
  pointer-events: none;
  mix-blend-mode: difference;
}
.bar a { pointer-events: auto; text-decoration: none; }
.bar__name { display: block; padding: 4px 0; }
/* 手書きサイン（白インクの画像を型にして、文字色で塗る） */
.bar__sig {
  display: block; width: 124px; aspect-ratio: 1850 / 515;
  background: var(--bone);
  -webkit-mask: url(/assets/img/signature.png) center / contain no-repeat;
  mask: url(/assets/img/signature.png) center / contain no-repeat;
  transition: opacity .3s;
}
body.is-loading .bar__sig { opacity: 0; transition: none; }
.bar { align-items: center; }
.bar__nav { display: flex; align-items: center; gap: 28px; font-size: 13px; letter-spacing: .08em; }
.bar__all {
  pointer-events: auto;
  width: 32px; height: 32px; margin: -6px -8px -6px -6px; padding: 0;
  display: grid; place-items: center;
  background: none; border: 0; color: var(--ash); cursor: pointer;
  transition: color .3s;
}
.bar__all:hover, .bar__all[aria-expanded="true"] { color: var(--bone); }
.bar__all svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.3; }
.bar__all svg rect { transition: transform .5s var(--ease); transform-box: fill-box; transform-origin: center; }
.bar__all[aria-expanded="true"] svg rect { transform: scale(.72); }
.bar__nav a { color: var(--ash); transition: color .3s; position: relative; }
.bar__nav a:hover,
.bar__nav a[aria-current="page"] { color: var(--bone); }
.bar__nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 2px; height: 1px; background: currentColor;
}

/* ── TOP：カテゴリ一覧 ─────────────────── */
@property --r { syntax: "<length>"; inherits: true; initial-value: 0px; }

.works {
  --ph: min(64vh, 640px);      /* 表紙の高さ */
  --rowgap: 16vh;              /* 行と行の間（次の行の頭が画面の下にわずかにのぞく） */
  position: fixed; inset: 0;
  overflow: hidden;
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior: contain;
  cursor: grab;
}
/* 8件を超えたら行を分け、下へ1行ずつ移る */
.works.is-multi { overflow-y: auto; }
.works.is-dragging { cursor: grabbing; user-select: none; }
/* 行・列にピタッと止めるのは指のスワイプだけ（マウスはJSでなめらかに寄せる） */
@media (pointer: coarse) {
  .works.is-multi { scroll-snap-type: y mandatory; }
}
.works.is-dragging .work { pointer-events: none; }
.works::-webkit-scrollbar { display: none; }
.works[hidden] { display: none; }
.works__list {
  --cols: 4;
  list-style: none; margin: 0 auto;
  width: max-content;
  padding: calc((100vh - var(--ph)) / 2 + 20px) var(--gutter) calc((100vh - var(--ph)) / 2 - 20px);
  display: grid;
  grid-template-columns: repeat(var(--cols), max-content);
  column-gap: clamp(48px, 7vw, 120px);
  row-gap: var(--rowgap);
}
.works__list > li { scroll-snap-align: center; }
.work img { -webkit-user-drag: none; user-select: none; }

/* どこまで進んだか：今の行の下の黒い余白（次の行との間）の真ん中に置き、写真と重ねない */
.works__progress {
  position: fixed; z-index: 2;
  left: 50%; width: min(280px, 56vw); translate: -50% 0;
  bottom: calc((100vh - var(--ph)) / 2 - 20px - var(--rowgap) / 2);
  height: 2px; border-radius: 1px;
  background: rgba(232, 230, 225, .2);
  pointer-events: none;
  opacity: 0; transition: opacity .6s;
}
.works__progress.is-on { opacity: 1; }
.works__fill {
  display: block; height: 100%; width: 100%; background: var(--bone); border-radius: 1px;
  transform-origin: 0 50%; transform: scaleX(0);
  transition: transform .5s var(--ease);
}
.works__tick { position: absolute; top: -1px; width: 4px; height: 4px; margin-left: -2px; background: var(--black); }
.work {
  --mx: 50%; --my: 50%; --r: 0px;
  display: flex; gap: 16px; align-items: flex-start;
  text-decoration: none; color: var(--bone);
  transition: --r .7s ease-in;
}
.work:hover, .work:focus-visible, .work.is-center {
  --r: 1600px;
  transition: --r 1.6s var(--ease);
}
.work:focus-visible { outline-offset: 10px; }
.work__frame {
  position: relative; overflow: hidden;
  height: var(--ph); width: calc(var(--ph) * .7);
  background: var(--graphite);
}
.work__frame img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 1.6s var(--ease);
}
.work__mono { filter: grayscale(1) brightness(.9) contrast(1.05); }
.work__color {
  -webkit-mask-image: radial-gradient(circle at var(--mx) var(--my), #000 calc(var(--r) - 160px), transparent var(--r));
  mask-image: radial-gradient(circle at var(--mx) var(--my), #000 calc(var(--r) - 160px), transparent var(--r));
}
.work:hover .work__frame img { transform: scale(1.03); }
.work__text {
  writing-mode: vertical-rl;
  display: flex; gap: 12px;
}
.work__title {
  margin: 0;
  font-family: var(--mincho); font-weight: 400;
  font-size: 19px; line-height: 1; letter-spacing: .24em;
}
.work__meta {
  display: flex; gap: 1.2em;
  font-size: 11px; line-height: 1; letter-spacing: .16em; color: var(--ash);
}
.works.is-in .work__frame { animation: rise 1.4s calc(var(--i) * .12s) var(--ease) both; }
.works.is-in .work__text { animation: fade 1s calc(.5s + var(--i) * .12s) var(--ease) both; }

/* ── 全体表示 ─────────────────────────── */
.overview {
  position: fixed; inset: 0; z-index: 25;
  background: var(--black);
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  display: flex;
  padding: 76px var(--gutter) 28px;
}
.overview::-webkit-scrollbar { display: none; }
.overview[hidden] { display: none; }
.overview__grid {
  --ow: 160px; --oc: 4;
  list-style: none; margin: auto; padding: 0;
  display: grid;
  grid-template-columns: repeat(var(--oc), var(--ow));
  gap: var(--og, 20px);
}
.ov {
  --mx: 50%; --my: 50%; --r: 0px;
  display: block;
  transition: --r .6s ease-in;
}
.ov:hover, .ov:focus-visible { --r: 1000px; transition: --r 1.2s var(--ease); }
.ov .work__frame { display: block; width: var(--ow); height: calc(var(--ow) / .7); }
.overview.is-in .ov { animation: fade .7s calc(var(--i) * 30ms) var(--ease) both; }

/* 表紙が、写真の壁の中のその写真の位置へ移ってつながる */
.expand {
  position: fixed; z-index: 27; overflow: hidden; pointer-events: none;
  transition: left .9s var(--ease), top .9s var(--ease), width .9s var(--ease), height .9s var(--ease), opacity .8s var(--ease);
}
.expand img { width: 100%; height: 100%; object-fit: cover; transition: transform .9s var(--ease); }
.expand.is-moving img { transform: scale(1.12); }
.expand img { filter: grayscale(1) brightness(.9) contrast(1.05); }   /* 壁の写真と同じ白黒のまま */   /* 壁の中の写真と同じ切り取りにそろえる */
.expand.is-out { opacity: 0; transition-duration: 1.1s; }

.wall-progress {
  position: fixed; inset: 0 0 auto; z-index: 45; height: 1px; pointer-events: none;
}
.wall-progress__fill {
  display: block; height: 100%; background: var(--bone);
  transform-origin: 0 50%; transform: scaleX(0); opacity: 0;
  transition: transform .3s linear, opacity .4s;
}

/* ── 写真の壁 ─────────────────────────── */
.gallery { position: fixed; inset: 0; }
.gallery[hidden] { display: none; }
/* 上下の文字が写真に負けないよう、端だけ影を落とす */
.gallery::before, .gallery::after {
  content: ""; position: fixed; left: 0; right: 0; height: 110px; z-index: 1; pointer-events: none;
}
.gallery::before { top: 0; background: linear-gradient(rgba(0,0,0,.7), transparent); }
body[data-view="wall"] .bar { mix-blend-mode: normal; }
.gallery::after { bottom: 0; background: linear-gradient(transparent, rgba(0,0,0,.65)); }
.wall-info {
  position: fixed; left: var(--gutter); bottom: max(calc(var(--gutter) * .8), env(safe-area-inset-bottom));
  z-index: 30; display: flex; align-items: baseline; gap: 16px;
  color: var(--bone);
}
.wall-info__back {
  align-self: center; display: grid; place-items: center;
  width: 36px; height: 36px; margin-left: -8px; color: var(--bone);
}
.wall-info__back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.2; transition: translate .4s var(--ease); }
.wall-info__back:hover svg { translate: -4px 0; }
.wall-info__title { margin: 0; font-family: var(--mincho); font-weight: 400; font-size: 16px; letter-spacing: .2em; }
.wall-info__meta { font-size: 11px; letter-spacing: .16em; color: #a8a6a1; }
.gallery__canvas {
  display: block; width: 100%; height: 100%;
  cursor: grab; touch-action: none;
  transition: opacity .9s var(--ease), filter .9s var(--ease);
}
.gallery__canvas.is-dragging { cursor: grabbing; }
.gallery__canvas.is-pointing { cursor: pointer; }
.photo-list button { all: unset; }
.photo-list:focus-within {
  clip: auto; width: auto; height: auto; left: var(--gutter); bottom: var(--gutter);
  background: var(--graphite); padding: 8px 14px; list-style: none; margin: 0; z-index: 25;
}
.noscript { position: fixed; inset: 45% 0 auto; text-align: center; color: var(--ash); }

/* ── 拡大表示 ─────────────────────────── */
.viewer {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(0, 0, 0, 0);
  transition: background .6s var(--ease);
}
.viewer.is-open { background: rgba(0, 0, 0, .94); }
.viewer[hidden] { display: none; }
.viewer__img {
  position: fixed; left: 0; top: 0; transform-origin: 0 0;
  will-change: transform; cursor: zoom-out;
}
.viewer__btn {
  position: fixed; z-index: 2;
  width: 48px; height: 48px; display: grid; place-items: center;
  background: none; border: 0; color: var(--bone); cursor: pointer;
  opacity: 0; transition: opacity .4s .25s;
}
.viewer.is-open .viewer__btn { opacity: .75; }
.viewer.is-open .viewer__btn:hover { opacity: 1; }
.viewer__btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.2; }
.viewer__close { top: max(12px, env(safe-area-inset-top)); right: 12px; }

/* サムネイル列：今の1枚だけカラー、ほかは白黒（ホバーで色が戻る） */
.viewer__thumbs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2;
  overflow-x: auto; scrollbar-width: none;
  padding: 16px var(--gutter) max(20px, env(safe-area-inset-bottom));
  opacity: 0; transition: opacity .5s .3s;
}
.viewer__thumbs::-webkit-scrollbar { display: none; }
.viewer.is-open .viewer__thumbs { opacity: 1; }
.viewer__track { display: flex; gap: 6px; width: max-content; margin: 0 auto; }
.viewer__thumb {
  position: relative; flex: none;
  height: 52px; padding: 0; border: 0; background: var(--graphite); cursor: pointer;
}
.viewer__thumb img {
  height: 100%; width: auto;
  filter: grayscale(1) brightness(.55);
  transition: filter .5s var(--ease);
}
.viewer__thumb:hover img { filter: grayscale(0) brightness(.85); }
.viewer__thumb[aria-current] img { filter: none; }
.viewer__thumb::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -8px; height: 1px;
  background: var(--bone); transform: scaleX(0); transition: transform .5s var(--ease);
}
.viewer__thumb[aria-current]::after { transform: scaleX(1); }
.viewer__thumb:focus-visible { outline-offset: 3px; }
.viewer__prev { left: 8px; top: 50%; translate: 0 -50%; }
.viewer__next { right: 8px; top: 50%; translate: 0 -50%; }

/* ── アバウト ─────────────────────────── */
.about {
  position: relative; z-index: 10;
  min-height: 100%;
  padding: 120px var(--gutter) 80px;
  display: grid; place-items: center;
}
.about[hidden] { display: none; }
.about__inner {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 5fr) auto minmax(0, 4fr);
  gap: clamp(24px, 4vw, 64px);
  align-items: end;
}
.about__photo { margin: 0; overflow: hidden; background: var(--graphite); }
.about__photo img { width: 100%; height: auto; }
.about__name { margin: 0; display: flex; gap: 14px; align-self: start; }
.about__ja {
  writing-mode: vertical-rl;
  font-family: var(--mincho);
  font-weight: 400;
  font-size: clamp(40px, 5.2vw, 76px);
  line-height: 1;
  letter-spacing: .28em;
}
.about__en {
  writing-mode: vertical-rl;
  font-size: 12px; font-weight: 400;
  letter-spacing: .24em; color: var(--ash);
}
.about__text { padding-bottom: 4px; }
.about__lead .nw { white-space: nowrap; }
.about__origin {
  margin: 0 0 1.6em;
  font-size: 12px; letter-spacing: .16em; color: var(--ash);
}
.about__lead {
  margin: 0 0 1.4em; max-width: 30em;
  font-size: 14px; line-height: 2.1; color: #bdbbb6;
}
.about__links {
  list-style: none; margin: 1em 0 0; padding: 0;
  font-size: 13px; letter-spacing: .04em;
}
.about__links li + li { margin-top: .4em; }
.about__links a {
  text-decoration: none; color: var(--bone);
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size .5s var(--ease);
}
.about__links a:hover { background-size: 100% 1px; }

/* アバウトは入場時に1回だけ動く */
.about.is-in .about__photo img { animation: develop 1.6s var(--ease) both; }
.about.is-in .about__ja { animation: rise 1.2s .2s var(--ease) both; }
.about.is-in .about__en,
.about.is-in .about__origin,
.about.is-in .about__lead,
.about.is-in .about__links { animation: fade 1s .6s var(--ease) both; }
@keyframes develop { from { opacity: 0; transform: scale(1.06); filter: brightness(0); } }
@keyframes rise { from { opacity: 0; clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes fade { from { opacity: 0; } }

/* ── 読み込み ─────────────────────────── */
.loader {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-content: center; justify-items: center; gap: 22px;
  background: var(--black);
  transition: opacity .8s var(--ease), visibility .8s;
}
.loader.is-done { opacity: 0; visibility: hidden; }
.loader__sig { width: min(520px, 76vw); aspect-ratio: 1850 / 515; }
.loader__sig svg { display: block; width: 100%; height: 100%; overflow: visible; transform-origin: 0 0; }
.loader__line { width: 120px; height: 1px; background: var(--graphite); overflow: hidden; transition: opacity .4s; }
/* 書き終わったサインがヘッダーへ移動する間、背景だけ先に抜ける */
.loader.is-leaving { background: transparent; transition: background .9s var(--ease); }
.loader.is-leaving .loader__line { opacity: 0; }
.loader__fill { display: block; height: 100%; background: var(--bone); transform-origin: 0 50%; transform: scaleX(0); transition: transform .3s linear; }

/* ── スマホ ───────────────────────────── */
@media (max-width: 760px) {
  body { font-size: 14px; }
  .bar__sig { width: 100px; }
  .bar__nav { gap: 20px; }
  .about { padding-top: 96px; place-items: start center; }
  .about__inner { grid-template-columns: minmax(0, 1fr) auto; gap: 20px 18px; align-items: start; }
  .about__text { grid-column: 1 / -1; }
  .about__ja { font-size: 40px; }
  .about__lead br { display: none; }
  @media (pointer: coarse) {
    .works { scroll-snap-type: x mandatory; }
    .works.is-multi { scroll-snap-type: both mandatory; }
  }
  .works { --ph: min(62svh, calc(72vw / .7)); --rowgap: 12svh; }
  .works__progress { bottom: calc((100svh - var(--ph)) / 2 - 20px - var(--rowgap) / 2); }
  .works__list {
    column-gap: 28px;
    padding-inline: calc((100vw - var(--ph) * .7) / 2 - 20px);
    padding-block: calc((100svh - var(--ph)) / 2 + 20px) calc((100svh - var(--ph)) / 2 - 20px);
  }
  .work { scroll-snap-align: center; gap: 10px; }
  .work__title { font-size: 17px; }
  .viewer__prev, .viewer__next { display: none; }   /* スマホはサムネイルとスワイプで移動 */
  .viewer__thumb { height: 44px; }
  .viewer__thumbs { padding-inline: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* WebGL が使えないときは一覧をそのまま見せる */
.photo-list.is-fallback {
  position: fixed; clip: auto; width: auto; height: auto; white-space: normal;
  inset: 90px var(--gutter) auto; list-style: none; margin: 0; padding: 0;
  display: grid; gap: 6px; color: var(--ash);
}
.photo-list.is-fallback button { cursor: pointer; }
