/* WHO AM D — 레이어: 배경 → 타이틀 → Three 캔버스 → INSERT */

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

html.is-booting {
  /* 본문만 숨김 — 로딩 동공은 보이게 */
  visibility: hidden;
}

html.is-booting .boot-loader {
  visibility: visible;
}

.boot-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f3f1;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.22s ease;
}

.boot-loader.is-done {
  opacity: 0;
  visibility: hidden;
}

.boot-loader__eyes {
  position: relative;
  width: 124px;
  height: 64px;
}

.boot-loader__pupil {
  position: absolute;
  top: 50%;
  width: 52px;
  height: 52px;
  margin-top: -26px;
  border-radius: 50%;
  /* 메인 화면 3D 동공 음영을 따라: 왼쪽 위 밝은 회색 → 오른쪽 아래 검정, 오른쪽 가장자리 얇은 반사 */
  background: radial-gradient(circle at 30% 26%, #4d4d4d 0%, #333 38%, #1a1a1a 68%, #070707 100%);
  box-shadow: inset -2px -1px 3px rgba(255, 255, 255, 0.12), inset 3px 4px 6px rgba(255, 255, 255, 0.05);
  transform-origin: 50% 100%;
  will-change: transform;
}

.boot-loader__pupil[data-boot-pupil="L"] {
  left: 6px;
}

.boot-loader__pupil[data-boot-pupil="R"] {
  right: 6px;
}

html {
  width: 100%;
  overflow-x: clip;
  overflow-y: auto;
  background-color: #f5f3f1;
}

body {
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: visible;
  background-color: #f5f3f1;
}

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

img.is-missing {
  visibility: hidden;
  pointer-events: none;
}

:root {
  --design-w: 1440;
  --design-h: 1024;
  --scene-scale: 1;
}

.page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  transform: translateZ(0);
}

.page-bg img {
  position: absolute;
  top: -1px;
  left: -1px;
  width: calc(100% + 2px);
  height: calc(100% + 2px);
  object-fit: cover;
  object-position: center;
}

.stage {
  position: relative;
  z-index: 1;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: visible;
  pointer-events: none;
  line-height: 0;
}

.title-pad {
  width: 100%;
  height: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.scene-clip {
  width: 100%;
  overflow: visible;
  clip-path: inset(-100vmax 0 -100vmax 0);
  line-height: normal;
}

.scene {
  position: relative;
  width: calc(var(--design-w) * 1px);
  height: calc(var(--design-h) * 1px);
  transform: scale(var(--scene-scale));
  transform-origin: top left;
  overflow: visible;
  pointer-events: none;
  margin: 0;
  padding: 0;
  background: transparent;
}

.title,
.subtitle,
.insert-label,
.insert-triangle {
  position: absolute;
  pointer-events: none;
}

/* DRAG & INSERT·▼ → 3D insertBadge. DOM은 측정용으로만 유지 */
.insert-label,
.insert-triangle {
  display: none !important;
}

/* Three 캔버스: 배경·WHO AM D·오브젝트·유리. INSERT·부제는 위 HTML */
.world3d {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 10;
  width: 100%;
  height: 100%;
  display: block;
  background: transparent;
  pointer-events: none;
}

.title {
  margin: 0;
  padding: 0;
  z-index: 1;
  font-family: "Archivo Black", sans-serif;
  font-weight: 400;
  font-style: normal;
  color: #fff;
  text-align: left;
  white-space: nowrap;
  overflow: visible;
}

.subtitle {
  margin: 0;
  /* 캔버스(배경 불투명) 위에 유지 — EYE DARE YOU */
  z-index: 14;
  font-family: "Pretendard", sans-serif;
  font-weight: 700;
  color: var(--water-subtitle-ink, #fff);
  white-space: nowrap;
  text-align: left;
}

/* 물 차오름과 같은 타이밍 — CSS blur (크기·위치 불변) */
html.water-active .subtitle,
html.water-active .insert-label {
  filter: blur(var(--water-page-blur, 0px));
}
/*
 * ▼: insert-tri-flash 키프레임이 filter를 덮어써서 블러가 사라졌음.
 * water-active 동안 애니 끄고 부제·INSERT와 동일 blur(+틴트) 적용.
 */
html.water-active .insert-triangle {
  animation: none !important;
  filter: blur(var(--water-page-blur, 0px))
    var(--water-tri-filter, brightness(1) drop-shadow(0 0 0 transparent));
}

/* 물 효과 중: HTML 글자를 RT에 스탬프하므로 DOM은 숨김 */
html.water-labels-stamped .subtitle,
html.water-labels-stamped .insert-label,
html.water-labels-stamped .insert-triangle {
  visibility: hidden !important;
}

/*
 * 물 페이지 전환: 이전 페이지 CSS 애니(스윕·삼각 플래시) 정지 후 페이드아웃.
 * 목록: insert-light-sweep, insert-tri-flash (현재 CSS animation 전부).
 */
html.water-page-paused .insert-label::before,
html.water-page-paused .insert-triangle {
  animation-play-state: paused !important;
}

html.water-page-paused .insert-label::before {
  transition: opacity 0.55s ease;
  opacity: 0 !important;
}

html.water-page-paused .insert-triangle {
  transition: filter 0.55s ease;
}
/* water-active가 블러+틴트를 담당. paused만일 때는 틴트/원본 */
html.water-page-paused:not(.water-active) .insert-triangle {
  filter: var(--water-tri-filter, brightness(1) drop-shadow(0 0 0 transparent));
}

/* 물 찬 뒤 수면 위 호버 — 나가기 가능 표시 */
html.water-exit-cursor,
html.water-exit-cursor body,
html.water-exit-cursor #scene,
html.water-exit-cursor #scene * {
  cursor: pointer !important;
}

/* 단일 캔버스 모드: HTML 배경·WHO AM D 숨김 (WebGL로 이전) */
html.canvas-unify .page-bg {
  display: none !important;
}

html.canvas-unify .title {
  visibility: hidden !important;
}

html.canvas-unify .scene {
  /* 타이틀 오버플로만큼 위로 확장 — D 잘림·스크롤과 동일 좌표계 */
  height: calc((var(--design-h) + var(--title-overflow, 0)) * 1px);
}

/* INSERT HTML은 display:none — 스윕/플래시 애니 제거됨. 스타일은 측정용 유지 */
.insert-label {
  z-index: 18;
  font-family: "Headline Gothic ATF", "Arial Narrow", Impact, sans-serif;
  font-weight: 400;
  color: transparent;
  white-space: nowrap;
  line-height: 1;
  letter-spacing: 0;
}
.insert-label::after {
  content: attr(data-text);
  color: var(--water-insert-ink, #111);
}
.insert-triangle {
  z-index: 18;
}

/* ----- 정렬 모드 (G) — 사이트에는 안 보임, 작업용 ----- */
.align-guides {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

html.align-mode-on .align-guides {
  display: block;
}

.align-guide {
  position: absolute;
  object-fit: fill;
  opacity: 0.4;
  outline: 1px solid rgba(255, 40, 80, 0.45);
  transform-origin: center center;
  pointer-events: none;
}

.align-sel-box {
  position: absolute;
  z-index: 45;
  box-sizing: border-box;
  border: 2px solid #ff2d55;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

html.align-mode-on .world3d {
  pointer-events: auto;
  cursor: crosshair;
}

html.align-mode-on .insert-label,
html.align-mode-on .insert-triangle {
  pointer-events: auto;
  cursor: pointer;
}

.align-toggle {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 200;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: rgba(18, 20, 24, 0.88);
  color: #f2f2f2;
  font: 600 12px/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
}

.align-toggle[aria-pressed="true"] {
  background: #b91c1c;
}

.align-panel {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 200;
  width: 248px;
  max-height: calc(100vh - 72px);
  overflow: auto;
  padding: 12px 12px 14px;
  border-radius: 10px;
  background: rgba(16, 18, 22, 0.92);
  color: #f3f3f3;
  font: 12px/1.35 ui-sans-serif, system-ui, sans-serif;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

.align-panel h2 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
}

.align-panel__hint {
  margin: 0 0 10px;
  opacity: 0.65;
  font-size: 11px;
}

.align-panel__sel {
  margin: 0 0 8px;
  font-weight: 600;
  color: #ff8fa3;
}

.align-panel__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.align-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 10px;
  opacity: 0.95;
}

.align-field span {
  opacity: 0.7;
}

.align-field input {
  width: 100%;
  box-sizing: border-box;
  padding: 4px 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font: 12px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.align-panel__actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.align-panel__actions button {
  padding: 7px 8px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font: 600 11px/1 ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
}

.align-panel__actions button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.align-panel__out {
  display: block;
  width: 100%;
  margin-top: 8px;
  box-sizing: border-box;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.4);
  color: #d8d8d8;
  font: 10px/1.35 ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
}

.align-panel__status {
  margin: 8px 0 0;
  font-size: 11px;
  color: #9ae6b4;
}

/* ----- 나토리 INSERT → YouTube MV (오른쪽 아래, 정렬 버튼 위) ----- */
.natori-music {
  position: fixed;
  right: 24px;
  /* align-toggle(bottom:12 · ~36px) 위로 — 겹침 방지 */
  bottom: 64px;
  z-index: 180;
  pointer-events: none;
  transform: translateY(120%);
  opacity: 0;
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.35s ease;
}

.natori-music.is-visible {
  pointer-events: auto;
  transform: translateY(0);
  opacity: 1;
}

.natori-music__panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 356px;
  max-width: calc(100vw - 48px);
}

.natori-music__frame {
  position: relative;
  width: 356px;
  height: 200px;
  max-width: 100%;
  overflow: hidden;
  background: #0a0a0a;
  border-radius: 2px;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.28);
  /* 플레이어 위에 덮개·버튼 없음 — iframe만 */
}

.natori-music__host,
.natori-music__frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.natori-music__caption {
  margin: 0;
  padding: 0 2px;
  font-family: "Pretendard", sans-serif;
  font-weight: 600;
  font-size: 12px;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: rgba(28, 30, 36, 0.72);
  pointer-events: none;
}

.natori-music__error {
  padding: 14px 14px 16px;
  background: rgba(18, 20, 24, 0.92);
  color: #f2f2f2;
  border-radius: 8px;
  font-family: "Pretendard", sans-serif;
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.28);
}

.natori-music__error[hidden] {
  display: none !important;
}

.natori-music__error-msg {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.natori-music__error-link {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 6px;
  background: #fff;
  color: #111;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  pointer-events: auto;
}

.natori-music__error-link:hover {
  background: #f3f3f3;
}

/* 금붕어 혼잣말 — Chrome 링크 상태표시줄 형식(꼬리·그림자 없음) */
.fish-mutter {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 36;
  margin: 0;
  padding: 4px 8px;
  box-sizing: border-box;
  max-width: none;
  background: #2b2c2f;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  color: #d4d4d6;
  font-family: "Pretendard", sans-serif;
  font-weight: 400;
  font-size: 13px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
  word-break: keep-all;
  overflow: hidden;
  text-overflow: clip;
  pointer-events: none;
  opacity: 0;
  transform: translate3d(0, 0, 0);
  will-change: left, top, opacity;
  -webkit-font-smoothing: antialiased;
  box-shadow: none;
  filter: none;
  text-shadow: none;
}

.fish-mutter[hidden] {
  display: none !important;
}
