/* 기아서체: fonts/ 폴더에 파일을 넣으면 적용됩니다. 없으면 system sans-serif로 대체됩니다. */
@font-face {
  font-family: "KiaFont";
  src: url("fonts/KiaSignatureLight.woff2") format("woff2");
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: "KiaFont";
  src: url("fonts/KiaSignatureRegular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "KiaFont";
  src: url("fonts/KiaSignatureBold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #ffffff;
  --ink-soft: rgba(255, 255, 255, 0.62);
  --line: rgba(255, 255, 255, 0.85);
  --bg: #000000;
  --title: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  color: var(--ink);
  font-family: "KiaFont", -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  height: 100%;
  overflow-y: auto;
  padding: 0 16px;
}

/* ---------- 화면 공통 ---------- */
.screen,
.qscreen {
  display: none;
  min-height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
  padding: 48px 0;
}
.screen.active,
.qscreen.active {
  display: flex;
  animation: enter 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes enter {
  from { opacity: 0; transform: translateY(18px) scale(0.98); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.3em;
  font-size: 12px;
  color: var(--ink-soft);
}

h1,
.qtext {
  text-shadow: 0 0 14px #000, 0 0 4px #000;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 6.4vw, 44px);
  line-height: 1.25;
  font-weight: 700;
}

.sub,
.lead {
  margin: 0;
  font-size: clamp(16px, 4vw, 20px);
  line-height: 1.6;
  color: var(--ink);
  text-shadow: 0 0 14px #000, 0 0 4px #000;
}
.lead.small { font-size: 15px; }

/* ---------- 질문 화면 ---------- */
.progress {
  width: min(320px, 80vw);
  height: 2px;
  background: rgba(255, 255, 255, 0.2);
  position: relative;
  overflow: hidden;
}
.progress i {
  position: absolute;
  inset: 0;
  background: var(--ink);
  transform-origin: left;
  transition: transform 0.8s cubic-bezier(0.6, 0, 0.2, 1);
}
.qcount {
  font-size: 12px;
  letter-spacing: 0.25em;
  color: var(--ink-soft);
}
.qtag {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--ink-soft);
}
.qtext {
  margin: 0;
  font-size: clamp(22px, 5.6vw, 34px);
  line-height: 1.35;
  font-weight: 700;
  max-width: 560px;
  word-break: keep-all;
}
.choices {
  display: grid;
  gap: 12px;
  width: min(440px, 100%);
}
.choice {
  appearance: none;
  background: rgba(0, 0, 0, 0.88);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 20px 18px;
  text-align: left;
  cursor: pointer;
  transition: background 0.35s, color 0.35s, transform 0.35s;
  font: inherit;
}
.choice:hover,
.choice:focus-visible {
  background: var(--ink);
  color: var(--bg);
  transform: translateX(6px);
  outline: none;
}
.choice b {
  display: block;
  font-size: 18px;
  margin-bottom: 4px;
}
.choice span {
  font-size: 14px;
  opacity: 0.75;
}
.back {
  background: none;
  border: 0;
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ---------- 버튼 ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  padding: 14px 26px;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.3s, background 0.3s, color 0.3s;
}
.btn:hover { transform: translateY(-2px); }
.btn.ghost {
  background: transparent;
  color: var(--ink);
}
.btn.ghost:hover {
  background: var(--ink);
  color: var(--bg);
}

/* ---------- 결과 카드 ---------- */
.result-head { max-width: 480px; }

.stage {
  perspective: 1200px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.card {
  width: min(420px, 92vw);
  container-type: inline-size;
  overflow: hidden;
  position: relative;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(26px) saturate(140%);
  backdrop-filter: blur(26px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  color: #fff;
  text-align: left;
  user-select: none;
}
.card-top {
  height: 94cqw;
  background: linear-gradient(160deg, rgba(60, 60, 60, 0.35), rgba(10, 10, 10, 0.25));
  overflow: hidden;
}
.card-panel { padding: 4.1cqw 3.7cqw 3.6cqw; background: rgba(20, 20, 20, 0.28); }
route-cube#cardCube {
  display: block;
  width: 100%;
  height: 100%;
  --cube-font: "KiaFont", "Helvetica Neue", Arial, sans-serif;
  --ink: #ffffff;
}
#cardBody { padding-top: 10px; }

.card:active { cursor: grabbing; }

.card-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
}
.card-mood {
  margin: 22px 0 6px;
  font-size: 13px;
  color: var(--ink-soft);
}
.card-mood b {
  display: block;
  color: var(--ink);
  font-size: 22px;
  margin-bottom: 2px;
}
.card-title {
  margin: 4px 0 0;
  font-size: var(--title);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.02em;
  word-break: keep-all;
  transition: font-size 0.2s;
}
.card-title-en {
  margin: 6px 0 16px;
  font-size: 13px;
  color: var(--ink-soft);
}
.card-statement {
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 1.55;
  word-break: keep-all;
}
.card-sug {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.card-sug small {
  display: block;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.card-sug p {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
  word-break: keep-all;
}
.card-pledge {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
}
.card-foot {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}

.hint {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.customize {
  width: min(360px, 100%);
  display: grid;
  gap: 12px;
  text-align: left;
  margin-top: 16px;
}
.customize label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
}
.customize[hidden] { display: none; }
.customize input {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  padding: 8px 2px;
  outline: none;
}
.customize input:focus { border-bottom-color: var(--ink); }
.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}
.actions .btn:first-child { grid-column: 1 / -1; }

/* ---------- 입체 타이틀 (결과 화면) ---------- */
.tilt {
  --tsize: 34px;
  width: min(380px, 92vw);
  transform-style: preserve-3d;
  transition: transform 0.15s linear;
  cursor: grab;
  user-select: none;
  touch-action: none;
}
.tilt:active { cursor: grabbing; }

.card .title-scene {
  margin: 0 -22px 22px;
}
.title-scene {
  position: relative;
  height: 200px;
  perspective: 800px;
  animation: sway 9s ease-in-out infinite alternate;
}
.title-stack {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateX(24deg) rotateY(-26deg) rotateZ(-12deg);
}
.title-layer {
  position: absolute;
  left: 50%;
  top: 50%;
  white-space: nowrap;
  font-size: var(--tsize);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  color: #fff;
  opacity: calc(1 - var(--i) * 0.11);
  transform:
    translate3d(-50%, -50%, 0)
    translate3d(calc(var(--i) * 6px), calc(var(--i) * 14px), calc(var(--i) * -22px));
  animation: layer-in 1.3s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i) * 70ms);
}
.title-layer span {
  display: inline-block;
  animation: drift 5s ease-in-out infinite alternate;
  animation-delay: calc(var(--i) * -0.4s);
}
.title-layer:not(:first-child) span { color: rgba(255, 255, 255, 0.5); }

@keyframes layer-in {
  from {
    transform:
      translate3d(-50%, -50%, 0)
      translate3d(calc(var(--i) * 6px), calc(var(--i) * 14px + 260px), calc(var(--i) * -22px))
      rotateX(-70deg);
  }
}
@keyframes drift {
  from { transform: translate3d(-8px, 0, 0) skewX(-8deg); }
  to   { transform: translate3d(14px, -4px, 0) skewX(8deg); }
}
@keyframes sway {
  from { transform: rotateY(-10deg); }
  to   { transform: rotateY(10deg); }
}

/* ---------- 토스트 ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 5;
  max-width: calc(100vw - 32px);
  word-break: break-all;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  .screen.active, .qscreen.active { animation-duration: 0.01s; }
  .choice:hover, .btn:hover { transform: none; }
}

/* ---------- 결과카드 레이아웃 (참고 이미지 비율을 카드 너비 기준 cqw로 유지) ---------- */
.result-title {
  margin: 0;
  font-size: 5.1cqw;
  font-weight: 700;
  line-height: 1.05;
  text-transform: uppercase;
  color: #fff;
}
.result-statement {
  margin: 3.5cqw 0 0;
  font-size: 2.2cqw;
  line-height: 3.4cqw;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
}
#cardBody { margin-top: 2.6cqw; }
#cardBody .card-pledge { margin: 0; font-size: 2.2cqw; color: #fff; }


/* ---------- 결과 전 브릿지 (배경 큐브 장면 위 멘트) ---------- */
.reveal {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: none;
  padding: 0;
  gap: 0;
  align-items: center;
  justify-content: center;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}
.reveal.active { display: flex; }
.reveal-text {
  position: relative;
  z-index: 1;
  padding: 0 28px;
  text-align: center;
}
.reveal-line {
  margin: 0 0 8px;
  font-size: clamp(18px, 4.6vw, 26px);
  line-height: 1.4;
  color: #fff;
  text-shadow: 0 0 14px #000;
  animation: reveal-in 1.4s ease both;
}
.reveal-line + .reveal-line { animation-delay: 0.9s; }
@keyframes reveal-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

/* ---------- 화면 전환 플래시 ---------- */
#flash {
  position: fixed;
  inset: 0;
  z-index: 6;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
#flash.go { animation: flash-out 0.9s ease-out; }
@keyframes flash-out {
  0% { opacity: 0.85; }
  100% { opacity: 0; }
}

/* ---------- 결과 화면: 배경을 어둡고 단순하게 ---------- */
#bg { transition: opacity 0.8s ease; }
body.is-result #bg { opacity: 0.22; }

/* ---------- 카드 모서리를 따라 흐르는 빛 ---------- */
@property --edge-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1.5px;
  background: conic-gradient(
    from var(--edge-angle),
    transparent 0deg,
    transparent 280deg,
    rgba(255, 255, 255, 0.9) 330deg,
    transparent 360deg
  );
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
  animation: edge-sweep 5s linear infinite;
}
@keyframes edge-sweep {
  to { --edge-angle: 360deg; }
}
@media (prefers-reduced-motion: reduce) {
  .card::after { animation: none; }
}

/* ---------- 카드 안 다짐 문장 ---------- */
.card-pledge {
  margin: 2.6cqw 0 0;
  font-size: 2.6cqw;
  line-height: 1.45;
  color: #fff;
  word-break: keep-all;
}
#cardBody { margin-top: 0; }

/* ---------- 첫 화면 전 라이팅 패턴 인트로 (기아 라이팅 패턴 애니메이션 사용) ---------- */
#lightIntro {
  position: fixed;
  inset: 0;
  z-index: 7;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}
#lightGif {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.5s ease;
}
#lightCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* 파장이 번지는 동안 자막을 숨겼다가 나타냄 */
#app.intro-wait [data-screen="intro"] .eyebrow,
#app.intro-wait [data-screen="intro"] h1,
#app.intro-wait [data-screen="intro"] .sub,
#app.intro-wait [data-screen="intro"] .btn {
  opacity: 0;
}
#app [data-screen="intro"] .eyebrow,
#app [data-screen="intro"] h1,
#app [data-screen="intro"] .sub,
#app [data-screen="intro"] .btn {
  transition: opacity 1s ease;
}

/* ---------- 스토리 연출 ---------- */
/* 선택 반응이 나오는 동안 질문 글자를 흐리게 해 큐브 행동이 보이게 함 */
.qscreen > * { transition: opacity 0.35s ease; }
body.reacting .qscreen.active > *:not(.qcount):not(.progress) { opacity: 0.06; }
body.reacting::after {
  content: "Tap to skip";
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 4;
  font-size: 12px;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.55);
  pointer-events: none;
}
.qcount { letter-spacing: 0.22em; }
.reveal-time {
  margin: 0 0 14px;
  font-size: 12px;
  letter-spacing: 0.3em;
  color: rgba(255, 255, 255, 0.6);
  animation: reveal-in 1s ease both;
}
/* 결과카드: 주인공 큐브가 펼쳐진 뒤 등장 */
.card.card-pre { opacity: 0; transform: scale(0.7) rotateX(35deg); }
.card.card-in { animation: card-in 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes card-in {
  from { opacity: 0; transform: scale(0.7) rotateX(35deg); }
  to { opacity: 1; transform: none; }
}
/* 변신 연출 동안에는 결과 화면의 글자·입력란도 숨겼다가 카드와 함께 나타냄 */
.screen[data-screen="result"] > * { transition: opacity 0.6s ease; }
body.morphing .screen[data-screen="result"] > *:not(.stage) { opacity: 0; }

/* ---------- 줄바꿈: 의미 단위로 나누고, 좁은 화면에서도 한 줄에 한 단어만 남지 않게 ---------- */
.qtext { max-width: min(800px, 100%); }
.qtext .qline { display: inline-block; text-wrap: balance; }
.qtext .qph { white-space: nowrap; } /* 구절 안에서는 끊지 않음 */
h1, .lead, .reveal-line, .result-statement { text-wrap: balance; }

/* ---------- 인트로 영상 (LIGHT / WAVE) ---------- */
.screen.intro-film {
  position: fixed;
  inset: 0;
  z-index: 2;
  padding: 0;
  background: #000;
}
.screen.intro-film.active { animation: none; }
#introFilm {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}
.intro-start {
  position: absolute;
  left: 50%;
  bottom: 12vh;
  transform: translate(-50%, 12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.intro-start.ready {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

/* 피날레 → 결과: 멘트가 빛 속으로 흐려지며 사라짐 */
.reveal-text { transition: opacity 0.6s ease, transform 0.6s ease, filter 0.6s ease; }
.reveal.leaving .reveal-text { opacity: 0; transform: scale(1.06); filter: blur(8px); }
