/* 百八の窓 — 暗い展示室。部屋ごとに壁を塗り替えるのが唯一の見せ場で、他は静かにする */
:root {
  --ink: #ece5d8;            /* 作品ラベルの紙の白 */
  --ink-dim: #ece5d8a8;
  --ink-faint: #ece5d85c;
  --brass: #c7a66b;          /* 部屋番号の真鍮プレート。焦点枠にも使う */
  --spot: #ffe9c81c;         /* 作品の上から当たる照明のたまり */
  --frame-shadow: 0 2.2rem 3.6rem -1.6rem #000000c7, 0 0.4rem 1rem -0.4rem #00000080;
  --mincho: "Shippori Mincho B1", "Yu Mincho", "Hiragino Mincho ProN", serif;
  --gothic: "Zen Kaku Gothic New", "Yu Gothic", "Hiragino Sans", sans-serif;
  --gutter: clamp(1rem, 4vw, 3.5rem);
  --wall-fade: 1.4s;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background-color: var(--wall);
  color: var(--ink);
  font-family: var(--gothic);
  font-size: 1rem;
  line-height: 1.8;
  overflow-x: clip;
  transition: background-color var(--wall-fade) ease;
}
main { overflow-x: clip; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 4px; }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 30;
  padding: .5rem 1rem; background: var(--ink); color: #111; text-decoration: none;
}
.skip:focus { top: 1rem; }

/* ---- 上の帯（現在地と館内図）。枠はクリックを吸わない ---- */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: .9rem var(--gutter) 1.6rem;
  pointer-events: none;
  /* 作品や文字が帯の下を通っても、題名やボタンと重なって読めなくならないよう壁の色で薄く覆う */
  background: linear-gradient(to bottom, color-mix(in srgb, var(--wall) 94%, transparent) 55%, transparent);
}
.bar__home, .bar__guide { pointer-events: auto; }
.bar__home {
  font-family: var(--mincho); font-weight: 800; font-size: 1rem; letter-spacing: .2em;
  text-decoration: none; color: var(--ink-dim);
  transition: color .3s;
}
.bar__home:hover { color: var(--ink); }
.bar__guide {
  display: flex; align-items: center; gap: .9rem; min-height: 44px;
  padding: .35rem .5rem .35rem 1rem;
  border: 1px solid var(--ink-faint); border-radius: 999px;
  background: color-mix(in srgb, var(--wall) 70%, transparent);
  backdrop-filter: blur(6px);
  color: var(--ink); font: inherit; font-size: .82rem; cursor: pointer;
  transition: border-color .3s, background-color var(--wall-fade);
}
.bar__guide:hover { border-color: var(--ink-dim); }
.bar__here { color: var(--ink-dim); white-space: nowrap; }
.bar__map {
  padding: .1rem .75rem; border-radius: 999px;
  background: var(--ink); color: #1a1714; font-weight: 500;
}

/* ---- 館内図（Popover。最前面の専用の層に出る） ---- */
.guide {
  margin: 4.2rem var(--gutter) auto auto;
  width: min(22rem, calc(100vw - 2rem));
  padding: 1.4rem 1.4rem 1rem;
  border: 1px solid var(--ink-faint); border-radius: 6px;
  background: color-mix(in srgb, var(--wall) 88%, #000);
  color: var(--ink);
  box-shadow: var(--frame-shadow);
}
.guide::backdrop { background: #0006; }
.guide__title { margin: 0 0 .6rem; font-family: var(--mincho); font-weight: 800; letter-spacing: .2em; }
.guide__list, .directory { list-style: none; margin: 0; padding: 0; }
.guide__link {
  display: grid; grid-template-columns: 3.6em minmax(0, 1fr) auto; align-items: baseline; gap: .6rem;
  padding: .5rem .2rem; border-top: 1px solid #ffffff14;
  text-decoration: none; font-size: .92rem;
  transition: color .25s;
}
.guide__link:hover { color: var(--brass); }
.guide__no { color: var(--brass); font-size: .78rem; }
.guide__count { color: var(--ink-faint); font-size: .78rem; }
.guide__close {
  margin-top: .8rem; min-height: 40px; padding: 0 1rem;
  border: 1px solid var(--ink-faint); border-radius: 999px; background: none;
  color: var(--ink-dim); font: inherit; font-size: .82rem; cursor: pointer;
}
.guide__close:hover { color: var(--ink); border-color: var(--ink-dim); }

/* ---- 作品（額＋照明のたまり＋展示ラベル） ---- */
.work { position: relative; margin: 0; }
.work::before {
  /* 天井のスポットが壁に落とす光。作品の少し上から広がる */
  content: ""; position: absolute; z-index: -1;
  inset: -22% -14% 8% -14%;
  background: radial-gradient(ellipse 55% 60% at 50% 30%, var(--spot), transparent 70%);
  pointer-events: none;
}
.work__frame {
  display: block; position: relative;
  box-shadow: var(--frame-shadow);
  cursor: zoom-in;
}
.work__frame img { width: 100%; }
.work__frame::after {
  /* 額のガラスの映り込み。触れると少しだけ光る */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(115deg, #ffffff00 40%, #ffffff10 50%, #ffffff00 60%);
  opacity: 0; transition: opacity .5s ease;
}
.work__frame:hover::after, .work__frame:focus-visible::after { opacity: 1; }

.label {
  display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: .9rem;
  margin-top: 1rem; max-width: 26rem;
  font-size: .8rem; line-height: 1.6;
}
.label__no { grid-row: span 2; color: var(--brass); font-size: .72rem; padding-top: .2rem; }
.label__title { font-family: var(--mincho); font-weight: 600; font-size: 1rem; color: var(--ink); }
.label__kind { color: var(--ink-faint); }

/* ---- 入口 ---- */
.entrance {
  display: grid; gap: 2.5rem;
  min-height: 100svh;
  padding: 6rem var(--gutter) 4rem;
  align-content: center;
}
.entrance__title {
  margin: 0;
  font-family: var(--mincho); font-weight: 800;
  font-size: clamp(3.4rem, 15vw, 5.5rem); line-height: 1.1; letter-spacing: .12em;
}
.entrance__artist { margin: .6rem 0 0; color: var(--brass); letter-spacing: .25em; font-size: .9rem; }
.entrance__note { margin: 1.6rem 0 2rem; color: var(--ink-dim); font-size: .95rem; line-height: 2; }
.directory { max-width: 24rem; }
.directory .guide__link { font-size: .88rem; padding: .35rem 0; }
.entrance__work { max-width: 40rem; justify-self: end; width: 100%; }

/* ---- 部屋 ---- */
.room { padding: 7rem var(--gutter) 8rem; scroll-margin-top: 0; }
.plaque { margin-bottom: 4rem; max-width: 30rem; }
.plaque__no { margin: 0; color: var(--brass); font-size: .85rem; letter-spacing: .3em; }
.plaque__name {
  margin: .4rem 0 .8rem;
  font-family: var(--mincho); font-weight: 800;
  font-size: clamp(2rem, 8vw, 3.4rem); line-height: 1.3; letter-spacing: .08em;
}
.plaque__lead { margin: 0; color: var(--ink-dim); font-family: var(--mincho); font-size: 1.05rem; }
.plaque__count { margin: .6rem 0 0; color: var(--ink-faint); font-size: .8rem; }

.room__wall { display: grid; row-gap: clamp(5rem, 12vw, 9rem); }
.hang { display: grid; gap: 4rem; }

/* 出口 */
.exit {
  min-height: 80svh; display: grid; align-content: center; justify-items: start;
  padding: 6rem var(--gutter); background: #0d0c0b;
}
.exit__title { margin: 0; font-family: var(--mincho); font-weight: 800; font-size: clamp(2rem, 8vw, 3.4rem); letter-spacing: .3em; }
.exit__note { margin: 1rem 0 2rem; font-family: var(--mincho); font-size: 1.1rem; line-height: 2; color: var(--ink-dim); }
.exit__back {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 1.4rem;
  border: 1px solid var(--ink-dim); border-radius: 999px; text-decoration: none;
  transition: background-color .3s, color .3s;
}
.exit__back:hover { background: var(--ink); color: #111; }
.exit__credit { margin-top: 4rem; color: var(--ink-faint); font-size: .78rem; }

/* ---- 拡大表示 ---- */
.viewer {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: color-mix(in srgb, var(--wall) 45%, #050505);
  color: var(--ink);
}
.viewer::backdrop { background: #000c; }
.viewer[open] { display: grid; grid-template-rows: minmax(0, 1fr); }
.viewer__stage {
  margin: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 1rem;
  padding: 3.6rem var(--gutter) 5rem; min-height: 0;  /* 下に前へ・次へのボタンを置くぶん空ける */
}
.viewer__img { width: 100%; height: 100%; object-fit: contain; min-height: 0; }
.viewer__label { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; align-items: baseline; justify-content: center; font-size: .82rem; }
.viewer__room { color: var(--brass); }
.viewer__title { font-family: var(--mincho); font-weight: 600; font-size: 1.05rem; }
.viewer__count { color: var(--ink-faint); }
.viewer__btn, .viewer__close {
  position: absolute; min-width: 44px; min-height: 44px; padding: 0 1rem;
  border: 1px solid var(--ink-faint); border-radius: 999px;
  background: #00000066; color: var(--ink); font: inherit; font-size: .82rem; cursor: pointer;
  transition: border-color .25s, background-color .25s;
}
.viewer__btn:hover, .viewer__close:hover { border-color: var(--ink); background: #000000a0; }
.viewer__btn--prev { left: var(--gutter); bottom: 1rem; }
.viewer__btn--next { right: var(--gutter); bottom: 1rem; }
.viewer__close { right: var(--gutter); top: .9rem; }
.viewer__img.is-swapping { opacity: 0; }
.viewer__img { transition: opacity .25s ease; }

/* JS が動く時は部屋ごとの背景をやめ、body の壁の色をゆっくり塗り替える。
   JS が無い時は各部屋が自分の壁の色で塗られる（どちらでも部屋の色は伝わる） */
.room { background: var(--room-wall); }
.js .room { background: transparent; }

/* ---- 768px 以上：作品の掛け方を変える ---- */
@media (min-width: 768px) {
  .hang { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: clamp(1.5rem, 3vw, 3rem); }
  .hang--full .work { grid-column: 1 / -1; }
  .hang--right .work { grid-column: 4 / -1; }
  .hang--left .work { grid-column: 1 / 10; }
  .hang--pair .work:first-child { grid-column: 1 / 7; }
  .hang--pair .work:last-child { grid-column: 7 / -1; margin-top: 18%; }  /* 2枚目を下げて段差をつける */
  .hang--tall { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hang--tall .work:nth-child(2) { margin-top: 12%; }
  .hang--left .label { margin-left: 0; }
  .hang--right .label { margin-left: auto; }

  .viewer__btn--prev { left: var(--gutter); top: 50%; bottom: auto; transform: translateY(-50%); }
  .viewer__btn--next { right: var(--gutter); top: 50%; bottom: auto; transform: translateY(-50%); }
  .viewer__stage { padding: 3.6rem calc(var(--gutter) + 5rem) 1.4rem; }
}

/* ---- 1024px 以上：部屋の名前を縦書きの壁の文字にして、作品の横に付いてこさせる ---- */
@media (min-width: 1024px) {
  .entrance { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: clamp(2.5rem, 5vw, 5rem); }
  .entrance__words { display: flex; gap: clamp(1.5rem, 3vw, 3rem); align-items: flex-start; }
  .entrance__title { writing-mode: vertical-rl; font-size: clamp(4.5rem, 7vw, 6.5rem); }
  .entrance__text { padding-top: .6rem; width: 19rem; }
  .entrance__note { margin: 1.2rem 0 1.8rem; }

  .room { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: clamp(2rem, 5vw, 5rem); padding-top: 9rem; }
  .plaque {
    position: sticky; top: 6rem; align-self: start;
    writing-mode: vertical-rl; margin: 0;
    max-height: calc(100svh - 8rem);
  }
  .plaque__name { margin: 0 .9rem; font-size: clamp(2.4rem, 3.6vw, 3.4rem); }
  .plaque__lead { font-size: 1rem; }
  .plaque__count { margin: 0 .6rem 0 0; }
}

/* 高さの低い画面では縦書きが重なるので横書きに戻す */
@media (min-width: 1024px) and (max-height: 640px) {
  .room { display: block; }
  .plaque { position: static; writing-mode: horizontal-tb; max-height: none; margin-bottom: 4rem; }
  .plaque__name { margin: .4rem 0 .8rem; }
  .entrance__title { writing-mode: horizontal-tb; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body, .bar__guide { transition: none; }
  .work__frame::after, .viewer__img { transition: none; }
}

/* 縦書きの中の2桁の数字は横に寝かせず、1文字分に収めて立てる */
.tcy { text-combine-upright: all; }
