/* ─────────────────────────────────────────────
   디자인 값 (여기 숫자와 색만 바꾸면 사이트 전체가 바뀝니다)
   ───────────────────────────────────────────── */
:root {
  --밤: #040406;          /* 배경색. 기준 작품의 밤하늘 색 */
  --밤-옅게: #0c0c10;     /* 빈 사진 칸 */
  --달빛: #e6e0d3;        /* 기본 글자색 */
  --재: #8b877f;          /* 보조 글자색 */
  --별: #b89a68;          /* 포인트 색 (선, 표시) */
  --선: #24232a;          /* 구분선 */

  --제목글꼴: "Noto Serif KR", "Nanum Myeongjo", "Apple SD Gothic Neo", serif;
  --본문글꼴: "Gowun Batang", "Noto Serif KR", serif;
  --작은글꼴: "IBM Plex Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;

  --본문크기: 16px;
  --최대너비: 1280px;
  --여백: clamp(16px, 5vw, 72px);
  --전환: .7s ease;
  color-scheme: dark;
}

/* ───────────── 기본 ───────────── */
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--밤); color: var(--달빛); }
body {
  font-family: var(--본문글꼴); font-size: var(--본문크기); line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0px);
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 1px solid var(--별); outline-offset: 4px; }
[hidden] { display: none !important; }
.label { font-family: var(--작은글꼴); font-weight: 300; font-size: 11px; letter-spacing: .22em; color: var(--재); }
.wrap {
  max-width: var(--최대너비); margin: 0 auto;
  padding-left: max(var(--여백), env(safe-area-inset-left, 0px));
  padding-right: max(var(--여백), env(safe-area-inset-right, 0px));
}
.link-line { display: inline-flex; gap: 14px; align-items: center; font-family: var(--작은글꼴); font-size: 13px; letter-spacing: .14em; }
.link-line::after { content: ""; width: 48px; height: 1px; background: var(--별); transition: width .6s; }
.link-line:hover::after { width: 80px; }

/* ───────────── 머리말 ───────────── */
.bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-block: 28px; }
.mark { font-family: var(--제목글꼴); font-weight: 300; font-size: 15px; letter-spacing: .3em; }
.nav { display: flex; gap: 24px; align-items: center; }
.nav a { color: var(--재); transition: color .4s; display: grid; place-items: center; padding: 6px; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--달빛); }
/* 메뉴 아이콘: 전시는 초승달, 작품은 겹친 액자. 가는 선 하나로만 그립니다 */
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

/* ───────────── 화면 전환 ───────────── */
.view { animation: fade var(--전환); }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ───────────── 첫 화면 (작품 → 사이트 이름 → 글) ───────────── */
.intro {
  position: fixed; inset: 0; z-index: 60; background: var(--밤);
  display: grid; place-items: center; cursor: pointer; outline: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  transition: opacity .9s ease;
}
.intro.leaving { opacity: 0; pointer-events: none; }
/* 작품 한 장이 화면에 잘리지 않고 꼭 맞게 */
/* --비율 은 작품의 가로÷세로 (코드가 사진을 읽어 자동으로 맞춥니다) */
.intro-frame {
  --비율: .6667;
  --화면너비: calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  --화면높이: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  position: relative; container-type: inline-size; line-height: 0;
  width: min(var(--화면너비), var(--화면높이) * var(--비율));
}
.intro-frame img { width: 100%; height: auto; animation: fade 1.6s ease; }
/* 글은 작품 왼쪽 위의 빈 하늘에 놓입니다 */
.intro-text { position: absolute; top: 6cqw; left: 7cqw; width: 46cqw; line-height: 1.9; display: grid; gap: 5cqw; justify-items: start; }
.intro-hanja {
  font-family: var(--제목글꼴); font-weight: 200; font-size: 8.5cqw; line-height: 1.12; letter-spacing: .06em;
  writing-mode: vertical-rl; text-orientation: upright;
}
.intro-poem { font-family: var(--제목글꼴); font-weight: 300; font-size: clamp(10px, 2.55cqw, var(--첫글크기, 15px)); line-height: 2.05; letter-spacing: .04em; color: var(--달빛); }
.intro-poem p { margin: 0; white-space: nowrap; }
.intro-poem .gap { height: .9em; }
.intro-hanja, .intro-poem { opacity: 0; transform: translateY(6px); transition: opacity 1.6s ease, transform 1.6s ease; }
.intro[data-step="1"] .intro-hanja, .intro[data-step="2"] .intro-hanja,
.intro[data-step="2"] .intro-poem { opacity: 1; transform: none; }

/* ───────────── 작품 목록 ───────────── */
.section { padding-block: clamp(72px, 12vh, 160px); display: grid; gap: 48px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; border-top: 1px solid var(--선); padding-top: 20px; }
.section-head h2 { margin: 0; font-family: var(--제목글꼴); font-weight: 300; font-size: clamp(20px, 2vw, 26px); }
.works { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(28px, 4vw, 64px) clamp(20px, 3vw, 48px); }
.work { display: grid; gap: 14px; align-content: start; }
.work .frame { aspect-ratio: 2 / 3; background: var(--밤-옅게); overflow: hidden; }
.work img { width: 100%; height: 100%; object-fit: cover; transition: opacity .6s, transform 1.2s ease; }
.work a:hover img { opacity: .85; transform: scale(1.015); }

/* ───────────── 작가: 사진 옆 세 줄, 아래 이름 ───────────── */
.section-small { padding-block: clamp(48px, 8vh, 96px); gap: 0; }
.about {
  display: grid; grid-template-columns: var(--작가사진너비, 120px) auto; justify-content: start; row-gap: 0;
  align-items: end; padding-top: 40px;
}
.about .portrait { max-width: var(--작가사진너비, 120px); }
/* 사진과 세 줄이 한 가는 선 위에 함께 앉고, 이름은 그 선 아래에: 세 요소를 한 선으로 붙잡기 */
.about::after { content: ""; grid-row: 2; grid-column: 1; height: 1px; background: var(--재); opacity: .45; }
.about-words {
  font-family: var(--제목글꼴); font-weight: 300; font-size: var(--작가글크기, 12px); line-height: 2.1; letter-spacing: .24em; color: var(--재); white-space: nowrap;
  padding: 0 0 0 36px; text-align: center; align-self: center;
}
.about-words p { margin: 0; }
.about-words .gap { height: 1.2em; }
.about-words .hanja { font-size: calc(var(--한문배율, 1.18) * 1em); }
.about-name {
  grid-row: 3; grid-column: 1 / -1; margin: 7px 0 0;
  font-family: var(--이름글꼴, "Times New Roman", Times, serif); font-weight: 400;
  font-size: var(--이름크기, 12px); letter-spacing: .12em; color: var(--재);
}
.about-text { grid-column: 1 / -1; display: grid; gap: 20px; }
.about-text p { margin: 0; max-width: 34em; font-size: 14px; white-space: pre-line; }

/* ───────────── 작가 사진 (증명사진 비율 3:4) ───────────── */
.portrait { margin: 0; aspect-ratio: 3 / 4; width: 100%; max-width: 280px; background: var(--밤-옅게); display: grid; place-items: center; overflow: hidden; }
.portrait img { width: 100%; height: 100%; object-fit: cover; }

/* ───────────── 작품 상세 ───────────── */
.detail { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: clamp(32px, 6vw, 96px); padding-block: 24px 120px; align-items: start; }
.detail figure { margin: 0; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 24px); }
.detail figure img { width: 100%; height: auto; max-height: calc(100vh - 100px); object-fit: contain; cursor: zoom-in; }
.detail figcaption { margin-top: 14px; display: flex; justify-content: space-between; gap: 12px; }
.detail-text { display: grid; gap: 28px; max-width: 34em; padding-top: 10vh; min-width: 0; }
.detail-text h1 { margin: 0; font-family: var(--제목글꼴); font-weight: 300; font-size: clamp(28px, 3.4vw, 44px); line-height: 1.35; }
.detail-text h1 small { display: block; margin-top: 10px; font-family: var(--작은글꼴); font-weight: 300; font-size: 13px; letter-spacing: .08em; color: var(--재); }
.detail-text p { margin: 0; }
.pager { display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid var(--선); padding-top: 20px; }
.pager a { display: inline-flex; align-items: center; gap: 12px; padding-block: 12px; font-family: var(--작은글꼴); font-weight: 300; font-size: 12px; letter-spacing: .08em; color: var(--재); transition: color .3s; }
.pager a:hover { color: var(--달빛); }
/* 화살표 대신 가는 선 하나 */
.pager .stroke { width: 28px; height: 1px; background: currentColor; transition: width .5s ease; }
.pager a:hover .stroke { width: 48px; }

/* ───────────── 풀프레임 보기 ───────────── */
.viewer {
  position: fixed; inset: 0; z-index: 50; background: var(--밤);
  display: grid; place-items: center; cursor: zoom-out; touch-action: pan-y;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 16px) max(16px, env(safe-area-inset-left, 0px));
  opacity: 0; transition: opacity .9s ease;
}
.viewer.on { opacity: 1; }
/* 지금 보고 있는 화면 크기에 꼭 맞게 (가로·세로 중 먼저 닿는 쪽 기준) */
.viewer img {
  width: auto; height: auto; object-fit: contain; transition: opacity .5s ease;
  max-width: calc(100vw - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
  max-height: calc(100vh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100dvh - 32px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
}
/* 크게 보기의 닫기·이전·다음: 가는 선 아이콘 */
.v-btn { position: absolute; color: var(--재); padding: 12px; opacity: .55; transition: opacity .4s, color .4s; }
.v-btn:hover, .v-btn:focus-visible { opacity: 1; color: var(--달빛); }
.v-close { top: calc(env(safe-area-inset-top, 0px) + 8px); right: max(8px, env(safe-area-inset-right, 0px)); }
.v-prev, .v-next { top: 50%; transform: translateY(-50%); }
.v-prev { left: max(4px, env(safe-area-inset-left, 0px)); }
.v-next { right: max(4px, env(safe-area-inset-right, 0px)); }

/* ───────────── 아래 여백 ───────────── */
main { padding-bottom: 40px; }

/* ───────────── 웹·앱 공통: 작품 한 점씩 화면 가득, 아래 좌우 화살표로 넘기기 ───────────── */
main { padding: 0; }
.slides {
  position: fixed; inset: 0; display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; overscroll-behavior: contain; scrollbar-width: none; background: var(--밤);
}
.slides::-webkit-scrollbar { display: none; }
.slide {
  flex: 0 0 100%; height: 100%; margin: 0; scroll-snap-align: start; scroll-snap-stop: always;
  display: grid; place-items: center;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) calc(64px + env(safe-area-inset-bottom, 0px)) env(safe-area-inset-left, 0px);
}
.slide { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.slide img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; min-height: 0; }
.slide-text { place-items: start stretch; align-content: center; overflow-y: auto; padding-inline: var(--여백); padding-top: calc(48px + env(safe-area-inset-top, 0px)); }
.slide-text { place-items: center; }
.slide-text .section { padding-block: 0; }
.slide-text .about { border-top: 0; padding-top: 0; }
.tabs {
  display: flex; justify-content: center; gap: 120px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 8px 24px calc(env(safe-area-inset-bottom, 0px) + 14px);
}
.tabs button { color: var(--재); padding: 10px 14px; display: grid; place-items: center; opacity: .7; transition: opacity .4s, color .4s; }
.tabs button:active { color: var(--달빛); opacity: 1; }
.tabs button:disabled { opacity: .18; }
.tabs .home-moon { color: var(--달빛); padding: 10px 14px; display: grid; place-items: center; opacity: .8; }
.tabs .home-moon[hidden] { display: none; }
.tabs.at-end { gap: 64px; }
.tabs.at-end [data-slide="next"] { visibility: hidden; }
.tabs button:hover:not(:disabled) { color: var(--달빛); opacity: 1; }
@media (min-width: 821px) { .slide { padding: 48px 48px 88px; } .tabs { gap: 160px; padding-bottom: 28px; } .tabs.at-end { gap: 80px; } }

/* ───────────── 휴대폰 (앱 화면) ───────────── */
@media (max-width: 820px) {
  .nav { display: none; }
  .bar { padding-block: 20px 16px; }
  .works { grid-template-columns: 1fr; }
  .detail { grid-template-columns: 1fr; gap: 28px; }
  .about { grid-template-columns: calc(var(--작가사진너비, 120px) * .87) auto; }
  .about .portrait { max-width: calc(var(--작가사진너비, 120px) * .87); }
  .about-words { padding-left: 22px; font-size: calc(var(--작가글크기, 12px) - 1px); letter-spacing: .16em; }
  .detail { padding-top: 0; }
  .detail figure { position: static; margin-inline: calc(-1 * max(var(--여백), env(safe-area-inset-left, 0px))); }
  .detail figcaption { padding-inline: var(--여백); }
  .detail-text { padding-top: 0; }
  main { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) { *, .view, .intro-frame img { animation: none !important; transition: none !important; } }
