/* ==========================================================
   서도호 — 전시의 재구성
   ----------------------------------------------------------
   단위 규칙
   · 1rem = 시안(2769px 너비) 기준 100px.
     main.js 가 화면 너비에 맞춰 html font-size 를 바꿔줍니다.
     예) 시안 좌표 x=246, y=868  →  left: 2.46rem; top: 8.68rem;
   · 작품 패널(.gallery)은 화면 고정 레이어라 vw/vh 를 함께 씁니다.
   ========================================================== */

@font-face {
  font-family: "Pretendard";
  src: url("../fonts/PretendardVariable.woff2") format("woff2-variations"),
       url("../fonts/PretendardVariable.woff2") format("woff2");
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #e5e1d8;            /* 시안 배경 (229,225,216) */
  --bg-light: #f0ebe7;      /* 하단 사진 아래 밝은 배경 */
  --ink: #000;              /* 제목 */
  --text: #161412;          /* 본문 */
  --info: #574c46;          /* 하단 정보 텍스트 */
  --muted: #7d746c;
  --paper: #f7f5f1;         /* 작품 액자 매트 */
  --stage-h: 141.69rem;     /* 시안 전체 높이 14169px */
}

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

html {
  /* JS 가 정확한 값으로 덮어씁니다 (스크롤바 제외 너비 / 27.69) */
  font-size: calc(100vw / 27.69);
  background: var(--bg);
}

body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img { display: block; max-width: none; user-select: none; -webkit-user-drag: none; }

/* 스크롤 높이용 */
#scroll-spacer { width: 1px; pointer-events: none; }

/* 실제 화면 — 고정 레이어 */
#viewport {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
}

/* ===== 시안 캔버스 ===== */
#stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 27.69rem;
  height: var(--stage-h);
  will-change: transform;
}

#stage > *,
.hero > *,
.finale > * { position: absolute; }

/* ----- 계단 배경 ----- */
.stair-layer {
  left: 0;
  top: 0;
  width: 27.69rem;
  height: 121.18rem;          /* stair.png 2769 × 12118 */
  background: var(--bg);
  z-index: 0;
}
.stair-img {
  width: 100%;
  height: 100%;
  mix-blend-mode: darken;     /* 흰 배경 → 베이지, 실 색은 그대로 (시안과 동일) */
}
/* 상단 안개: 0px 에서 97% → 2260px 에서 0% */
.stair-haze-tint {
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  height: 22.6rem;
  background: linear-gradient(to bottom, rgba(229,225,216,.97), rgba(229,225,216,0));
  pointer-events: none;
}
.stair-haze-blur {
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  height: 22.6rem;
  -webkit-backdrop-filter: blur(.05rem);
  backdrop-filter: blur(.05rem);
  -webkit-mask-image: linear-gradient(to bottom, #000 35%, transparent);
  mask-image: linear-gradient(to bottom, #000 35%, transparent);
  pointer-events: none;
}

/* ----- 작품 감상 중 계단 흐림 막 ----- */
#veil {
  left: 0;
  top: 0;
  width: 27.69rem;
  height: 100vh;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  background: rgba(229, 225, 216, .55);
  -webkit-backdrop-filter: blur(.14rem);
  backdrop-filter: blur(.14rem);
}

/* ----- 인트로 ----- */
.hero { left: 0; top: 0; width: 27.69rem; height: 37rem; z-index: 2; }

.hero-artist {
  left: 2.41rem;
  top: 2.46rem;
  font-size: 1rem;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
  white-space: nowrap;
}

.hero-title {
  left: 2.44rem;
  top: 4.50rem;
  font-size: 2rem;
  line-height: 1;
  font-weight: 600;
  letter-spacing: -0.065em;
  color: var(--ink);
  white-space: nowrap;
}

.hero-desc .ln { display: block; white-space: nowrap; }  /* 시안과 같은 줄바꿈 */
.hero-desc .bk { margin: 0 .14em 0 .3em; }                  /* 《서도호》 앞뒤 간격 */
.hero-desc {
  left: 2.38rem;
  top: 8.60rem;
  width: 18.3rem;
  font-size: .35rem;
  line-height: .55rem;
  font-weight: 400;
  letter-spacing: -0.044em;
  color: var(--text);
}

.hero-frame {
  left: .60rem;
  top: 15.70rem;
  width: 26.48rem;            /* frame.png 2648 × 1895 */
}
.hero-frame img { width: 100%; height: auto; }

.hero-caption {
  left: 2.41rem;
  top: 34.88rem;
  font-size: .41rem;
  line-height: 1;
  font-weight: 400;
  letter-spacing: -0.043em;
  color: var(--text);
  white-space: nowrap;
}

/* 감상 모드에서 잠깐 흐려지는 요소 (--dim 은 main.js 가 0~1 로 조절) */
.flow,
.hero,
.finale { opacity: var(--dim, 1); }

/* ----- 걸어나오는 집 ----- */
.house {
  z-index: 3;
  height: auto;
  transform-origin: 50% 85%;
  will-change: transform;
}
#house-1 { left: 3.55rem;  top: 36.55rem; width: 14.98rem; }  /* image 1087 × 0.54 */
#house-2 { left: 4.60rem;  top: 51.95rem; width: 11.87rem; }  /* image 1088 × 0.52 */
#house-3 { left: -5.20rem; top: 60.16rem; width: 27.45rem; }  /* image 1090 × 0.90 */
#house-4 { left: -2.04rem; top: 79.92rem; width: 21.18rem; }  /* image 1089 × 0.71 */

.impression-label {
  z-index: 4;
  font-size: .45rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: -0.072em;
  color: var(--ink);
  white-space: nowrap;
}
#label-1 { left: 22.37rem; top: 37.58rem; }
#label-2 { left: 2.41rem;  top: 52.10rem; }
#label-3 { left: 15.68rem;  top: 74.93rem; }
#label-4 { left: 2.41rem;  top: 92.73rem; }

/* ----- 마무리 ----- */
.finale { left: 0; top: 106.7rem; width: 27.69rem; height: 35rem; z-index: 2; }

/* 사진 아래 밝은 배경 (12917px → 14169px) */
.finale::after {
  content: "";
  position: absolute;
  left: 0;
  top: 22.47rem;
  width: 100%;
  height: 12.52rem;
  background: linear-gradient(to bottom, var(--bg-light) 0%, #eeeae4 50%, var(--bg) 100%);
  z-index: -1;
}

.finale-photo {
  left: 0;
  top: 0;
  width: 27.69rem;
  height: 22.47rem;
  will-change: opacity, transform;
}
/* 사진 위 베이지 → 어두운 그라데이션 (10670px → 10958px) */
.finale-fade {
  position: absolute;
  left: 0; top: 0;
  width: 100%;
  height: 2.88rem;
    background: linear-gradient(to bottom, rgba(229,225,216,0) 0%, #625c55 100%);
}
.finale-photo::after {          /* 사진 아래쪽 바닥 → 밝은 배경으로 (12650px → 12720px) */
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 2.67rem;
  z-index: 1;
  background: linear-gradient(to bottom, rgba(240,235,231,0) 0%, var(--bg-light) 26%, var(--bg-light) 100%);
}
.finale-photo img {
  position: absolute;
  left: 0;
  top: 2.88rem;
  width: 27.69rem;            /* image 1085 2769 × 1959 */
  height: 19.59rem;
}

.poster {
  left: 4.05rem;
  top: 21.40rem;              /* 시안 y 12810 */
  width: 7.64rem;
  height: 10.79rem;
}
.poster img {
  width: 100%;
  height: 100%;
}
.poster {
  cursor: pointer;
  transition: opacity 1.1s cubic-bezier(.2,.7,.2,1), translate 1.1s cubic-bezier(.2,.7,.2,1),
              transform .4s ease, box-shadow .4s ease;
}
.poster:hover {
  transform: translateY(-.15rem);
  box-shadow: 0 .3rem .9rem rgba(60, 50, 40, .25);
}
.info {
  left: 13.42rem;
  top: 26.50rem;
  font-size: .305rem;
  line-height: .65rem;
  font-weight: 500;
  letter-spacing: -0.073em;
  color: var(--info);
}
.info dt, .info dd { font-weight: 500; }
.info-row:nth-child(2) { margin-top: .48rem; }
.info-row:nth-child(3) { margin-top: .80rem; }
.info-row--split { display: flex; gap: 0; }
.info-row--split > div:first-child { width: 3.85rem; }

/* ===== 등장 애니메이션 ===== */
.reveal-load,
.reveal {
  opacity: 0;
  translate: 0 .8rem;
  transition: opacity 1.1s cubic-bezier(.2,.7,.2,1), translate 1.1s cubic-bezier(.2,.7,.2,1);
}
.is-loaded .reveal-load,
.reveal.is-in { opacity: 1; translate: 0 0; }
.hero-title.reveal-load { transition-delay: .12s; }
.hero-desc.reveal-load  { transition-delay: .26s; }
.hero-frame.reveal-load { transition-delay: .42s; }
.info.reveal { transition-delay: .25s; }

/* ==========================================================
   작품 패널 (좌우 스크롤 구간)
   ========================================================== */
.gallery {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  visibility: hidden;
}
.gallery.is-active { visibility: visible; }

.gallery-window {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 35vw;
  right: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 7vw);
  mask-image: linear-gradient(to right, transparent 0, #000 7vw);
}

.track {
  display: flex;
  align-items: center;
  gap: 3.2rem;
  padding: 0 7vw 0 7vw;
  will-change: transform;
}

.work {
  flex: none;
  display: flex;
  align-items: center;
  gap: 1.4rem;
}

.work-img {
  position: relative;
  flex: none;
  height: min(64vh, 15rem);
  aspect-ratio: var(--ratio, 4/5);
  background: var(--paper);
  padding: .32rem;
  box-shadow:
    0 .04rem .1rem rgba(60, 50, 40, .12),
    0 .5rem 1.4rem rgba(60, 50, 40, .14);
}
.work-img img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* 이미지가 없을 때 보이는 자리표시 */
.work-img .ph {
  position: absolute;
  inset: .32rem;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(87, 76, 70, .35);
  color: var(--muted);
  font-size: max(.36rem, 12px);
  letter-spacing: -0.02em;
}
.work-img.is-empty img { display: none; }

.work-text {
  width: max(8.6rem, 300px);
  color: var(--text);
}
.work-index {
  font-size: max(.28rem, 12px);
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--muted);
  margin-bottom: .3rem;
}
.work-title {
  font-size: max(.56rem, 22px);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.05em;
  color: var(--ink);
}
.work-meta {
  margin-top: .13rem;
  font-size: max(.3rem, 12px);
  color: var(--muted);
  letter-spacing: -0.02em;
}
.work-label {
  margin-top: .62rem;
  margin-bottom: .14rem;
  font-size: max(.32rem, 14px);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.work-label::before {
  content: "";
  display: inline-block;
  width: .5rem;
  height: 2px;
  margin-right: .18rem;
  vertical-align: middle;
  background: currentColor;
}
.work-body {
  font-size: max(.25rem, 14px);
  line-height: 1.62;
  font-weight: 400;
  letter-spacing: -0.03em;
  word-break: keep-all;
}

/* 좌우 스크롤 진행 표시 */
#hscroll-ui {
  position: absolute;
  left: 50%;
  bottom: 4.5vh;
  z-index: 11;
  display: flex;
  align-items: center;
  gap: .3rem;
  translate: -50% 0;
  opacity: 0;
  pointer-events: none;
  font-size: max(.3rem, 11px);
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--info);
}
.hscroll-bar {
  position: relative;
  width: max(4rem, 120px);
  height: 2px;
  background: rgba(87, 76, 70, .2);
  overflow: hidden;
}
#hscroll-fill {
  position: absolute;
  inset: 0;
  background: var(--info);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* ===== 세로로 긴 화면(모바일 등): 집은 위, 작품은 아래 ===== */
@media (max-aspect-ratio: 4/5) {
  .gallery-window {
    left: 0;
    top: 36vh;
    bottom: 7vh;
    align-items: flex-start;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 6vw, #000 94vw, transparent);
    mask-image: linear-gradient(to right, transparent 0, #000 6vw, #000 94vw, transparent);
  }
  .track { gap: 12vw; padding: 0 12vw; align-items: flex-start; }
  .work { flex-direction: column; align-items: flex-start; gap: 4vw; }
  .work-img { height: 24vh; }
  .work-text { width: 76vw; }
  .work-label { margin-top: 3vw; }
  #hscroll-ui { bottom: 3vh; }
}

/* ===== 정지 모드 (index.html?static) — 시안 비교용 ===== */
.is-static .reveal-load,
.is-static .reveal { opacity: 1; translate: 0 0; transition: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal-load, .reveal { transition: opacity .4s linear; translate: 0 0; }
}
/* ===== 소리 켜기 버튼 ===== */
#sound-toggle {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 50;
  padding: 8px 14px;
  border: 1px solid rgba(216, 164, 207, 0.4);
  border-radius: 999px;
  background: rgba(216, 164, 207, 0.4);
  color: var(--info);
  font: 600 12px/1 "Pretendard", sans-serif;
  letter-spacing: .08em;
  cursor: pointer;
}
#sound-toggle.is-on { background: var(--info); color: #fff; }