/* =========================================================
   SCENE 01 — 1만 원의 경로 (후원금 흐름)
   방식: 상태 단계형
   부모 영역 : .scene-01  (스크롤 구간 250vh)
   고정 화면 : .scene-01 > .sticky-screen
   상태 클래스: js/script.js 가 스크롤 진행률에 따라 .scene-01 에
              is-step-1 ~ is-step-4 를 누적해서 붙인다.
              보이는 변화는 아래 transition 이 항상 같은 시간으로 재생한다.
   순서 규칙 : 사라지는 요소가 먼저, 나타나는 요소는 transition-delay 로 뒤에.
              되돌아갈 때는 기본 규칙의 delay 가 쓰이므로 순서가 거꾸로 된다.
   ========================================================= */

.scene-01 {
  --scene-length: 250vh;    /* 상태마다 스크롤 3~4번이면 다음 상태로 넘어가도록 */
  --s01-shift: 0px;          /* 컨트롤이 사라진 뒤 제목·수조가 이동할 거리 (JS) */
  --s01-field-offset: 0px;   /* 86% 수조를 가운데로 옮길 거리 (JS) */
  --s01-box-h: 86%;          /* 수조 틀 높이 (위쪽은 비율 숫자 자리) */
  --t-fast: 0.45s;
  --t: 0.7s;
  --t-slow: 0.9s;
}

/* 터치 화면: 한 번 쓸 때 움직이는 거리가 길어 상태 사이를 넓힌다 (상태 하나 ≈ 화면 80%) */
@media (pointer: coarse) {
  .scene-01 { --scene-length: 420vh; }
}

.scene-01 .sticky-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(14px, 2.6vh, 30px);
  padding: calc(var(--top-space) + 4vh) var(--gutter) calc(clamp(96px, 14vh, 150px) + var(--toolbar));
}

/* =========================================================
   요소 기본 모양 (시안: 낡은 인쇄 질감, 피 빨강, 낡은 금화)
   ========================================================= */

/* ---------- 제목: 세 문장이 같은 자리에서 교체된다 ---------- */

.s01-headlines {
  display: grid;
  width: 100%;
  text-align: center;
  transition: transform var(--t-slow) var(--ease);
}

.s01-title {
  grid-area: 1 / 1;
  align-self: center;
  font-size: clamp(26px, 2.75vw, 54px);
  font-weight: 900;
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-shadow: 2px 3px 0 var(--red-deep);
  filter: url(#fx-grain);
  transition: opacity var(--t-fast) ease, transform var(--t) var(--ease);
}

.s01-title em,
.s01-title strong { color: var(--red); font-weight: 900; }

/* 넓은 화면에서는 첫 질문을 한 줄로 (시안) */
@media (min-width: 900px) {
  .s01-title--ask br { display: none; }
}

/* ---------- 후원 금액 설정: 라벨 · 손그림 슬라이더 · 붉은 도장 버튼 ---------- */

.s01-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px clamp(20px, 2.4vw, 56px);
  transition: opacity var(--t-fast) ease, transform var(--t) var(--ease), visibility 0s;
}

.s01-control-label {
  font-size: clamp(15px, 1.1vw, 21px);
  font-weight: 700;
  color: var(--fg);
}

.s01-range {
  --p: 0;                    /* 0~1 슬라이더 위치 (JS) */
  position: relative;
  width: clamp(200px, 30vw, 580px);
  padding-bottom: 30px;
  margin-bottom: -30px;      /* 값 표시 자리만큼 아래로 넘쳐도 줄 높이는 그대로 */
}

.s01-amount {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 26px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  filter: url(#fx-rough);
}

.s01-amount::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--red) calc(var(--p) * 100%), #d9cfbf calc(var(--p) * 100%));
}

.s01-amount::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 24px;
  margin-top: -9px;
  border: 0;
  background: url("../../img/s01/thumb.png") center / contain no-repeat;   /* 핏방울 */
}

.s01-amount::-moz-range-track { height: 4px; border-radius: 2px; background: #d9cfbf; }
.s01-amount::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--red); }
.s01-amount::-moz-range-thumb {
  width: 22px;
  height: 24px;
  border: 0;
  border-radius: 0;
  background: url("../../img/s01/thumb.png") center / contain no-repeat;
}

.s01-amount:focus-visible { outline: 2px solid var(--gold); outline-offset: 6px; }

/* 값은 슬라이더 손잡이 바로 아래를 따라간다 */
.s01-amount-value {
  position: absolute;
  top: 30px;
  left: calc(11px + (100% - 22px) * var(--p));
  transform: translateX(-50%);
  font-size: clamp(14px, 1vw, 19px);
  color: var(--fg-soft);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.s01-donate {
  position: relative;
  isolation: isolate;
  min-height: 50px;
  min-width: 8em;
  padding: 0 26px;
  border: 0;
  background: none;
  color: var(--fg);
  font-size: clamp(16px, 1.15vw, 22px);
  font-weight: 800;
  cursor: pointer;
  transform: rotate(-1.2deg);
  transition: transform 0.2s var(--ease);
}

/* 거칠게 찢긴 붉은 종이 (img/s01/stamp.png) */
.s01-donate::before {
  content: "";
  position: absolute;
  inset: -4px -6px;
  z-index: -1;
  background: url("../../img/s01/stamp.png") center / 100% 100% no-repeat;
  transition: filter 0.2s;
}

.s01-donate span { display: inline-block; text-shadow: 0 1px 0 rgba(90, 8, 8, 0.6); }
.s01-donate:hover::before { filter: brightness(1.12); }
.s01-donate:active { transform: rotate(-1.2deg) scale(0.96); }
.s01-donate:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.s01-donate:disabled { color: var(--muted); cursor: default; }
.s01-donate:disabled::before { filter: grayscale(0.7) brightness(0.4); }

/* ---------- 3개의 수조: 손으로 그은 붉은 선 ---------- */

.s01-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  width: min(1500px, 100%);
  display: flex;
  align-items: stretch;
  gap: clamp(12px, 2vw, 38px);
  transition: transform var(--t-slow) var(--ease), opacity var(--t) ease;
}

.s01-tank {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 0;
  transition: opacity var(--t-fast) ease, transform var(--t) var(--ease);
}

.s01-tank--field {
  flex: 2.12 1 0;
  transform-origin: 50% 100%;
  transition: transform var(--t-slow) var(--ease);
}

.s01-tank-body {
  position: relative;
  flex: 1;
  min-height: 0;
}

/* 86% 수조 뒤의 따뜻한 빛 (수조를 따라 움직인다) */
.s01-tank--field .s01-tank-body::before {
  content: "";
  position: absolute;
  left: -18%;
  right: -18%;
  top: -10%;
  bottom: -32%;
  background: radial-gradient(closest-side, rgba(150, 108, 34, 0.30), rgba(150, 108, 34, 0.12) 55%, transparent);
  opacity: 0.75;
  pointer-events: none;
  transition: opacity var(--t) ease;
}

/* 수조 틀: 위가 열린 붉은 선, 양옆 선은 바닥 아래로 조금 더 내려간다 */
.s01-tank-box {
  position: absolute;
  inset: auto 0 0 0;
  height: var(--s01-box-h);
  border: 3px solid var(--red);
  border-top: 0;
  filter: url(#fx-rough);
  transition: opacity var(--t) ease;
}

.s01-tank-box::before {
  content: "";
  position: absolute;
  left: -3px;
  right: -3px;
  top: 100%;
  height: 38px;
  border: 3px solid var(--red);
  border-top: 0;
  border-bottom: 0;
}

/* 바닥 선에서 흘러내린 자국 (img/s01/drip-1~3.png) */
.s01-drip {
  position: absolute;
  top: calc(100% - 1px);
  width: 5px;
  height: calc(var(--h, 18px) + 6px);
  margin-left: -1px;
  background: url("../../img/s01/drip-1.png") top center / 100% 100% no-repeat;
}

.s01-drip--long { background-image: url("../../img/s01/drip-2.png"); }

.s01-coins {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* 수조 위 비율: 크고 거친 붉은 숫자 */
.s01-tank-rate {
  position: absolute;
  left: 50%;
  bottom: calc(var(--s01-box-h) + 8px);
  transform: translate(-50%, 8px);
  font-size: clamp(28px, 3.5vw, 68px);
  font-weight: 900;
  line-height: 1;
  color: #9e211d;
  font-variant-numeric: tabular-nums;
  filter: url(#fx-grain);
  opacity: 0;
  transition: opacity var(--t-fast) ease, transform var(--t) var(--ease);
}

.s01-tank--field .s01-tank-rate { color: var(--red); }

/* 시안에 없는 금액 배지는 쓰지 않는다 (금액은 결과 제목이 보여 준다) */
.s01-tank-badge { display: none; }

.s01-tank-label {
  margin-top: 26px;
  text-align: center;
  font-size: clamp(14px, 1.05vw, 20px);
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  transition: opacity var(--t) ease;
}

/* ---------- 다음 장면으로 잇는 질문 ---------- */

.s01-next {
  position: absolute;
  left: var(--gutter);
  right: var(--gutter);
  top: 50%;
  margin-top: -1.45em;
  text-align: center;
  font-size: clamp(20px, 2.4vw, 46px);
  font-weight: 900;
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-shadow: 2px 3px 0 var(--red-deep);
  filter: url(#fx-grain);
  opacity: 0;
  transform: translateY(24px);
  pointer-events: none;
  transition: opacity var(--t) ease, transform var(--t) var(--ease);
}

.s01-next em { color: var(--gold); }

.s01-hint { transition: opacity 0.4s; color: var(--fg-soft); }

.scene-01 .scene-curtain { transition: opacity var(--t-slow) ease; }

/* =========================================================
   상태별 변화
   ========================================================= */

/* ---------- step 0 : STATE 01·02 (기본 상태) ----------
   되돌아올 때의 순서: 다른 요소가 먼저 빠진 뒤 나타나도록 delay 를 준다 */
.s01-title--split,
.s01-title--result { opacity: 0; transform: translateY(32px); }

.s01-title--ask { transition-delay: 0.3s; }
.s01-control { transition-delay: 0.3s; }
.s01-tank--fund,
.s01-tank--ops { transition-delay: 0.35s; }

.is-dropping .s01-hint { opacity: 0; }

/* ---------- step 1 : STATE 03 분배 확인 ---------- */

/* 컨트롤과 첫 제목이 먼저 빠진다 */
.is-step-1 .s01-control {
  opacity: 0;
  transform: translateY(-12px);
  visibility: hidden;
  transition-delay: 0s, 0s, var(--t-fast);
}

.is-step-1 .s01-title--ask {
  opacity: 0;
  transform: translateY(-32px);
  transition-delay: 0s;
}

.is-step-1 .s01-hint { opacity: 0; }

/* 시안: 컨트롤이 사라져도 제목과 수조는 제자리에 있다 */

/* 그다음 둘째 제목이 아래에서 올라온다 */
.is-step-1 .s01-title--split {
  opacity: 1;
  transform: none;
  transition-delay: 0.35s;
}

/* 86% 수조는 빛이 밝아지고, 10%·4% 수조는 선과 이름이 어두워진다
   (동전 색은 JS 가 같은 시간으로 바꾼다) */
.is-step-1 .s01-tank--field .s01-tank-body::before { opacity: 1; }
.is-step-1 .s01-tank--fund .s01-tank-box,
.is-step-1 .s01-tank--ops .s01-tank-box { opacity: 0.6; }
.is-step-1 .s01-tank--fund .s01-tank-label,
.is-step-1 .s01-tank--ops .s01-tank-label { opacity: 0.55; }

.is-step-1 .s01-tank-rate {
  opacity: 1;
  transform: translate(-50%, 0);
  transition-delay: 0.25s;
}

.is-step-1 .s01-tank-badge {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  transition-delay: 0.6s;
}

/* ---------- step 2 : STATE 04 결과 확인 ---------- */

/* 둘째 제목과 옆 수조가 먼저 빠진다 */
.is-step-2 .s01-title--split {
  opacity: 0;
  transform: translateY(-32px);
  transition-delay: 0s;
}

.is-step-2 .s01-tank--fund,
.is-step-2 .s01-tank--ops {
  opacity: 0;
  transform: translateY(24px);
  transition-delay: 0s;
}

/* 그다음 86% 수조가 가운데로 */
.is-step-2 .s01-tank--field {
  transform: translateX(var(--s01-field-offset));
  transition-delay: 0.3s;
}

/* 결과 제목이 올라온다 */
.is-step-2 .s01-title--result {
  opacity: 1;
  transform: none;
  transition-delay: 0.55s;
}

/* ---------- step 3 : 다음 장면 질문 ---------- */

/* 수조가 아래로 물러나며 어두워진다 */
.is-step-3 .s01-stage {
  opacity: 0.12;
  transform: translateY(40%);
}

/* 결과 확인(STATE 04)부터 비율 숫자는 빠진다 (시안) */
.is-step-2 .s01-tank--field .s01-tank-rate { opacity: 0; transition-delay: 0s; }

.is-step-3 .s01-next {
  opacity: 1;
  transform: none;
  transition-delay: 0.4s;
}

/* 동전이 떨어지는 동안에는 배지를 띄우지 않는다 (쌓인 뒤 등장) */
.is-dropping .s01-tank-badge { opacity: 0; transition-delay: 0s; }

/* ---------- step 4 : 장면 끝 ---------- */

.is-step-4 .scene-curtain { opacity: 1; }

/* ---------- 움직임 줄이기 설정 ---------- */
@media (prefers-reduced-motion: reduce) {
  .scene-01 * ,
  .scene-01 *::after {
    transition-duration: 0.01s !important;
    transition-delay: 0s !important;
  }
}

@media (max-width: 640px) {
  .scene-01 .sticky-screen { padding-bottom: calc(92px + var(--toolbar)); }
  .s01-control { gap: 10px 16px; }
  .s01-range { width: calc(100% - 5em); }
  .s01-donate { margin-top: 24px; min-width: 60%; }
  .s01-tank--field { flex-grow: 1.9; }
  .s01-tank-label { margin-top: 20px; font-size: 12px; }
  .s01-tank-box { border-width: 2px; }
  .s01-tank-box::before { border-width: 2px; height: 22px; }
}
