/* Personality test pages — soft picture-book look (see design/landing_mockup.png). */
:root {
  --ink: #5a3d30;
  --ink-soft: #7d6152;
  --cream: #fff8ea;
  --pink: #ffc1d2;
  --pink-deep: #f59ab4;
  --mint: #c9eed9;
  --sky: #cfeaf8;
  --lavender: #e5d9f7;
  --round: var(--font);
  --name: var(--font);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: #bfe3f6 url("design/page_bg.webp") center top / cover no-repeat fixed; }
body { position: relative; isolation: isolate; font-family: var(--body); color: var(--ink); touch-action: manipulation; word-break: keep-all; overflow-wrap: break-word; }
body::before {
  content: ""; position: fixed; z-index: -1; pointer-events: none; inset: 0;
  height: 100vh; height: 100lvh;
  background: #bfe3f6 url("design/page_bg.webp") center top / cover no-repeat;
}
button, input { font: inherit; color: inherit; }

.page { max-width: 460px; margin: 0 auto; min-height: 100vh; min-height: var(--viewport-height, 100dvh); position: relative; overflow-x: hidden; }
.screen {
  display: none; min-height: 100vh; min-height: var(--viewport-height, 100dvh);
  flex-direction: column; align-items: center; justify-content: center;
  padding: 28px 22px;
  padding: max(28px, env(safe-area-inset-top)) max(22px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(22px, env(safe-area-inset-left));
  gap: 18px; text-align: center;
}
.screen.on { display: flex; animation: screenIn .45s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes screenIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }

/* Hand-drawn outline: the border lives on a pseudo element so only the line wobbles. */
.sketch { position: relative; border: 0; isolation: isolate; background: transparent; }
.sketch::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  border: 2.6px solid var(--ink); border-radius: inherit; background: var(--fill, #fff);
  filter: url(#wobble);
}

.card { --fill: var(--cream); border-radius: 26px 30px 24px 32px / 30px 24px 32px 26px; padding: 18px 22px; box-shadow: 0 6px 0 rgba(90, 61, 48, .08); }
.title {
  position: relative; margin: 6px 0 0; font-family: var(--round); font-weight: 400;
  font-size: clamp(35px, 10.4vw, 47px); line-height: 1.12; letter-spacing: -.5px; color: var(--ink);
  text-shadow: 0 3px 0 #fff, 3px 0 0 #fff, -3px 0 0 #fff, 0 -3px 0 #fff, 2px 2px 0 #fff, -2px 2px 0 #fff, 2px -2px 0 #fff, -2px -2px 0 #fff, 0 7px 0 rgba(90, 61, 48, .12);
}
.spark { position: absolute; width: 26px; height: 26px; animation: twinkle 1.8s ease-in-out infinite; }
.spark.s1 { left: -18px; top: 10px; }
.spark.s2 { right: -14px; bottom: 6px; width: 22px; height: 22px; animation-delay: .6s; }
@keyframes twinkle { 50% { transform: scale(.6) rotate(20deg); opacity: .6; } }
.intro-desc { margin: 0; font-size: 15px; line-height: 1.6; color: var(--ink-soft); text-wrap: balance; }
.h2 { margin: 0; font-family: var(--round); font-weight: 400; font-size: 21px; line-height: 1.35; text-wrap: balance; }
.sub { margin: 0; color: var(--ink-soft); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 0 30px; border-radius: 999px; cursor: pointer;
  font-family: var(--round); font-size: 18px; color: var(--ink);
  box-shadow: 0 5px 0 rgba(90, 61, 48, .18); transition: transform .12s, box-shadow .12s;
  -webkit-tap-highlight-color: transparent;
}
.btn.big { min-height: 64px; min-width: 240px; font-size: 22px; }
.btn.pink { --fill: var(--pink); }
.btn.mint { --fill: var(--mint); }
.btn.sky { --fill: var(--sky); }
.btn.lavender { --fill: var(--lavender); }
.btn:hover { transform: translateY(-2px) rotate(-1deg); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(90, 61, 48, .18); }
.btn:focus-visible, .link:focus-visible, .answer:focus-visible, input:focus-visible { outline: 3px dashed var(--pink-deep); outline-offset: 4px; }
.ico { width: 22px; height: 22px; }
.link { background: none; border: 0; padding: 6px 10px; color: var(--ink-soft); font-size: 13px; text-decoration: underline wavy rgba(90, 61, 48, .35); text-underline-offset: 5px; cursor: pointer; }

/* Intro parade: random creatures walking to the right, looping. */
.parade { width: 100vw; max-width: 460px; overflow: hidden; margin-top: -10px; padding: 10px 0 6px; mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); }
.parade-track { display: flex; width: max-content; animation: parade 38s linear infinite; }
.parade-track canvas { width: 116px; height: auto; margin: 0 -6px; animation: hop .9s ease-in-out infinite; }
.parade-track canvas:nth-child(2n) { animation-delay: .45s; }
@keyframes parade { from { transform: translateX(-50%); } to { transform: translateX(0); } }
@keyframes hop { 50% { transform: translateY(-6px) scale(1.03, .97); } }

/* Info form */
.peek { width: 150px; height: 148px; margin-bottom: -30px; position: relative; z-index: 1; }
.peek canvas { width: 100%; height: 100%; animation: hop 1.6s ease-in-out infinite; }
.form { width: 100%; display: flex; flex-direction: column; gap: 14px; padding: 46px 22px 22px; text-align: left; }
.form .h2 { text-align: center; margin-bottom: 4px; }
.field { display: flex; flex-direction: column; gap: 6px; font-family: var(--round); font-size: 15px; }
.field input {
  height: 50px; padding: 0 16px; border: 2.4px solid var(--ink); border-radius: 18px 22px 16px 20px;
  background: #fff; font-family: var(--body); font-size: 16px; outline: none;
}
.field input:focus { border-color: var(--pink-deep); box-shadow: 0 0 0 4px rgba(245, 154, 180, .25); }
.err { min-height: 1.2em; margin: 0; color: #d0587a; font-size: 12px; line-height: 1.5; text-align: center; white-space: pre-line; }
.form .btn { align-self: center; min-width: 200px; }

/* Quiz */
.progress { display: flex; gap: 8px; }
.progress i { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2.2px solid var(--ink); transition: background .3s, transform .3s; }
.progress i.done { background: var(--pink-deep); }
.progress i.now { background: #ffe27a; transform: scale(1.3); }
.qcard { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 18px 18px 22px; }
.qnum { margin: 0; font-family: var(--round); color: var(--pink-deep); font-size: 15px; }
.mini-wrap { width: 170px; height: 168px; position: relative; }
.mini { position: absolute; inset: 0; }
.mini canvas { width: 100%; height: 100%; animation: hop 1.4s ease-in-out infinite; }
.qtext { width: 100%; min-height: 2.7em; display: flex; align-items: center; justify-content: center; }
.answers { width: 100%; display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.answer {
  width: 100%; min-height: 62px; padding: 12px 18px; border-radius: 22px 26px 20px 24px; cursor: pointer;
  --fill: #fff; font-size: 15px; line-height: 1.4; color: var(--ink); text-wrap: pretty;
  box-shadow: 0 4px 0 rgba(90, 61, 48, .12); transition: transform .12s, background .15s;
}
.answer:hover { --fill: #fff3f7; transform: translateY(-2px); }
.answer:active, .answer.picked { --fill: var(--pink); transform: translateY(2px); }

/* Making */
.making { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.dough {
  width: 120px; height: 100px; border-radius: 50% 50% 46% 46% / 58% 58% 42% 42%;
  background: #fff8ea; border: 3px solid var(--ink); box-shadow: inset -10px -12px 0 rgba(222, 184, 174, .35);
  animation: knead .7s ease-in-out infinite alternate;
}
@keyframes knead { from { transform: scale(1.12, .86); } to { transform: scale(.92, 1.08) translateY(-14px); } }

/* Result */
#result {
  --result-x: max(22px, env(safe-area-inset-left), env(safe-area-inset-right));
  position: relative; min-height: 0; height: 100vh; height: var(--viewport-height, 100dvh);
  padding: max(16px, env(safe-area-inset-top)) var(--result-x) max(16px, env(safe-area-inset-bottom));
}
.result-layout {
  position: absolute; left: 50%; top: 50%; width: calc(100% - var(--result-x) - var(--result-x)); max-width: 416px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  transform: translate(-50%, -50%) scale(var(--result-fit, 1));
}
.result-card { width: 100%; --fill: var(--cream); border-radius: 30px 34px 28px 36px / 34px 28px 36px 30px; padding: 12px; box-shadow: 0 6px 0 rgba(90, 61, 48, .08); }
.result-card .stage-wrap { border-radius: 22px 26px 20px 24px; box-shadow: none; }
.result-caption { position: absolute; z-index: 3; top: 14px; left: 10px; right: 10px; display: flex; flex-direction: column; align-items: center; gap: 5px; pointer-events: none; }
.result-caption .type { max-width: 100%; word-break: keep-all; }
.result-caption .cname { margin: 0; font-size: 34px; line-height: 1.1; color: var(--caption-ink, var(--ink)); text-shadow: 0 2px 3px var(--caption-shadow, #fff8ea); transition: color .2s, text-shadow .2s; }
/* Zoom the result stage around the creature (values set by test.js). */
#resultStage { transform: scale(var(--scale)) translate(var(--zx), var(--zy)) scale(var(--zoom)) translate(calc(-1 * var(--zx)), calc(-1 * var(--zy))); }
.result-text { padding: 10px 8px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.type { margin: 0; padding: 4px 14px; border-radius: 999px; background: var(--sky); font-family: var(--round); font-size: 14px; }
.cname { margin: -2px 0 -4px; font-family: var(--round); font-weight: 400; font-size: 30px; line-height: 1.05; }
.desc { margin: 0; font-size: 14px; line-height: 1.65; color: var(--ink-soft); word-break: keep-all; overflow-wrap: break-word; text-wrap: balance; }
.desc .sentence { display: block; }
.tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 6px 0 0; padding: 0; list-style: none; }
.tags li { padding: 3px 11px; border-radius: 999px; background: #fff; border: 2px solid var(--ink); font-size: 12px; white-space: nowrap; }
.birth { margin: 4px 0 0; font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.birth i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); display: inline-block; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; width: 100%; }
.row .btn { flex: 1 1 150px; padding: 0 14px; font-size: 17px; white-space: nowrap; }
.row.small { gap: 4px; }

@media (prefers-reduced-motion: reduce) {
  .screen.on, .parade-track, .parade-track canvas, .peek canvas, .spark, .dough { animation: none; }
}

/* Wide screens: keep the horizon (35% down the portrait art) near the middle of the view. */
@media (min-aspect-ratio: 3/4) {
  html, body::before { background-position: center 27%; }
}


/* Gamja Flower for names and inputs; body copy keeps Gowun Dodum. */
.cname { font-family: var(--name); }
.field input, .field input::placeholder { font-family: var(--name); font-size: 19px; }

.btn:disabled { opacity: .7; cursor: progress; }

/* Background picker above the result picture */
.bg-pick { display: grid; grid-template-columns: repeat(8, 1fr); gap: 5px; padding: 0 2px 12px; }
.bg-thumb { width: 100%; aspect-ratio: 1; padding: 0; border-radius: 11px 13px 10px 12px; cursor: pointer;
  border: 2.2px solid rgba(90, 61, 48, .35); background: center / cover; transition: transform .15s; }
.bg-thumb:hover { transform: translateY(-2px); }
.bg-thumb.on { border-color: var(--ink); box-shadow: 0 0 0 3px var(--pink); transform: scale(1.08); }

/* Re-roll / save / share icon buttons */
.icon-row { display: flex; justify-content: center; gap: 22px; width: 100%; }
.ibtn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ibtn .disc { width: 66px; height: 66px; display: grid; place-items: center; border-radius: 47% 53% 50% 50% / 52% 48% 52% 48%;
  box-shadow: 0 5px 0 rgba(90, 61, 48, .18); transition: transform .12s, box-shadow .12s; }
.ibtn .disc.mint { --fill: var(--mint); }
.ibtn .disc.pink { --fill: var(--pink); }
.ibtn .disc.kakao { --fill: #fee500; }
.ibtn svg { width: 32px; height: 32px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ibtn svg .fill { fill: var(--ink); stroke: none; }
.ibtn .lbl { font-family: var(--round); font-size: 14px; color: var(--ink); }
.ibtn:hover .disc { transform: translateY(-2px) rotate(-4deg); }
.ibtn:active .disc { transform: translateY(3px); box-shadow: 0 1px 0 rgba(90, 61, 48, .18); }
.ibtn:focus-visible { outline: 3px dashed var(--pink-deep); outline-offset: 4px; border-radius: 12px; }
.ibtn.busy .disc { animation: knead .5s ease-in-out infinite alternate; }

/* Re-roll popup */
.roll-pop { --fill: var(--cream); width: min(320px, 86vw); padding: 24px 20px 14px; border: 0; border-radius: 28px 32px 26px 30px;
  display: none; flex-direction: column; gap: 12px; text-align: center; color: var(--ink); overflow: visible; }
.roll-pop[open] { display: flex; animation: screenIn .3s cubic-bezier(.2, 1.3, .4, 1); }
.roll-pop::backdrop { background: rgba(70, 60, 50, .35); }
.roll-pop .h2 { margin-bottom: 4px; }
.roll-pop .btn { flex-direction: column; gap: 0; min-height: 66px; line-height: 1.15; }
.roll-pop .btn small { font-family: var(--body); font-size: 12px; color: var(--ink-soft); }
