/* 집현전 한글 탐험 — 한글 제작소 (저학년) */

/* ---------------- 1단계: 글자 만들기 ---------------- */
.fac-card { gap: 16px; align-items: center; }
.fac-prompt { margin: 0; font-size: 24px; }

.fac-top {
  display: flex; align-items: center; justify-content: center; gap: 18px;
}
.fac-pic {
  display: flex; align-items: center; justify-content: center;
  width: 128px; height: 128px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #fff 0%, #fff6de 70%, #f7e2b4 100%);
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
}
.fac-pic-emoji { font-family: var(--font-emoji); font-size: 80px; line-height: 1; }
.fac-pic.small { width: 84px; height: 84px; flex: 0 0 auto; }
.fac-pic.small .fac-pic-emoji { font-size: 52px; }
.fac-arrow { font-size: 40px; font-weight: 900; color: var(--ink-2); }
.fac-preview {
  display: flex; align-items: center; justify-content: center;
  width: 132px; height: 132px;
  border-radius: 24px;
  background: #fff;
  border: 3px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  font-size: 96px; font-weight: 900; line-height: 1;
  color: var(--navy);
  transition: transform .2s var(--ease-pop), background-color .2s;
}
.fac-preview.empty { border-style: dashed; border-color: var(--ink-2); background: rgba(255, 255, 255, .5); box-shadow: none; }
.fac-preview.empty::after { content: "?"; font-size: 64px; color: #d9c4a0; }
.fac-preview.fac-raw { font-size: 46px; letter-spacing: 2px; }
.fac-preview.fac-big {
  background: var(--gold-soft);
  border-color: var(--gold-2);
  color: #7a4a00;
  box-shadow: 0 4px 0 var(--gold-2), 0 0 0 6px rgba(245, 184, 46, .35);
  animation: fac-grow .6s var(--ease-pop) both;
}
@keyframes fac-grow { 0% { transform: scale(1); } 45% { transform: scale(1.35); } 100% { transform: scale(1.12); } }

.fac-pic.fac-jump { animation: fac-jump .7s var(--ease-pop) both; }
@keyframes fac-jump {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-26px) scale(1.25) rotate(-6deg); }
  70% { transform: translateY(0) scale(1.08) rotate(3deg); }
  100% { transform: translateY(0) scale(1.1); }
}

.fac-slots { display: flex; align-items: flex-end; justify-content: center; gap: 10px; }
.fac-slot-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.fac-slot-label {
  font-size: 15px; font-weight: 800;
  padding: 2px 10px; border-radius: 999px;
  border: 2px solid var(--ink);
  background: #e3efff; color: var(--navy);
  white-space: nowrap;
}
.fac-slot-label.v { background: #ffe3e0; color: #7a1f1a; }
.fac-plus { font-size: 32px; font-weight: 900; color: var(--ink-2); padding-bottom: 22px; }
.slot.fac-slot {
  width: 88px; height: 88px;
  font-size: 50px; font-family: var(--font);
  cursor: pointer;
  padding: 0;
}
.slot.fac-slot:not(.filled) { cursor: default; }
.slot.fac-slot.filled {
  background: linear-gradient(180deg, #f3cf98 0%, #e2ad6a 100%);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .5), inset 0 -4px 0 rgba(120, 70, 20, .25), 0 4px 0 var(--ink);
}
.slot.fac-slot.fac-snap { animation: jh-pop-in .3s var(--ease-pop); }
.slot.fac-slot.fac-right { border-color: var(--green); background: var(--green-soft); box-shadow: 0 4px 0 var(--green); color: #1d5e2b; }
.slot.fac-slot.fac-wrong { border-color: var(--red); background: var(--red-soft); }
.slot.fac-slot:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }

.fac-tray {
  display: grid;
  grid-template-columns: repeat(6, 76px);
  gap: 12px;
  justify-content: center;
  padding: 14px 16px;
  background: linear-gradient(180deg, var(--wood) 0%, var(--wood-2) 100%);
  border: 3px solid var(--ink);
  border-radius: 20px;
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .25), 0 4px 0 var(--ink);
}
.tile.fac-tile { width: 76px; height: 76px; font-size: 42px; cursor: grab; }
.tile.fac-tile.fac-used { visibility: hidden; }
.tile.fac-tile:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }
/* 힌트 쪽지와 건너뛰기 버튼을 한 줄로 늘어놓아 카드가 화면 아래로 길어지지 않게 한다 */
.fac-card .hint-box {
  margin-top: 0; width: 100%;
  flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center;
  gap: 8px 10px;
}
.fac-card .hint { width: auto; flex: 0 1 auto; max-width: 100%; padding: 8px 14px; font-size: 17px; }
.fac-card .skip-btn { flex: 0 0 auto; }
.fac-card .hint-box > * { scroll-margin-bottom: 16px; } /* 새 힌트로 스크롤할 때 화면 끝에 딱 붙지 않게 */

/* ---------------- 단계 사이 ---------------- */
.fac-between { align-items: center; text-align: center; gap: 12px; }
.fac-between-badge {
  display: inline-block;
  font-size: 30px; font-weight: 900;
  padding: 8px 22px;
  background: var(--gold-soft);
  border: 3px solid var(--gold-2);
  border-radius: 999px;
  color: #7a4a00;
  animation: jh-stamp .6s var(--ease-pop) both;
}
.fac-between .q-prompt { margin: 4px 0 0; }
.fac-between-text { margin: 0; font-size: 20px; font-weight: 700; }
.fac-between-text.small { font-size: 17px; color: var(--ink-2); }
.fac-between-hearts { margin: 0; font-size: 34px; letter-spacing: 4px; }
.fac-go { min-width: 240px; margin-top: 6px; }

/* ---------------- 2단계: 자모 합체 퍼즐 ---------------- */
.fac-s2 { gap: 12px; }
.fac-s2-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fac-hearts { display: flex; gap: 4px; font-size: 30px; line-height: 1; }
.fac-heart { display: inline-block; }
.fac-heart.lost { opacity: .55; }
.fac-heart-drop { animation: fac-heart-drop .5s ease both; }
@keyframes fac-heart-drop { 0% { transform: scale(1.4); } 60% { transform: scale(.8) translateY(4px); } 100% { transform: scale(1); } }
.fac-target { display: flex; align-items: center; gap: 12px; margin-left: auto; margin-right: auto; }
.fac-boxes { display: flex; gap: 8px; }
.fac-box {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 84px; height: 84px;
  background: rgba(255, 255, 255, .6);
  border: 3px dashed var(--ink-2);
  border-radius: 16px;
  font-size: 56px; font-weight: 900; line-height: 1;
  color: var(--navy);
}
.fac-box.active { border-style: solid; border-color: var(--gold-2); background: var(--gold-soft); animation: jh-glow 1.6s ease-in-out infinite; }
.fac-box.done { border-style: solid; border-color: var(--green); background: var(--green-soft); color: #1d5e2b; }
.fac-built { position: relative; }

.fac-guide {
  margin: 0;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 12px;
  font-size: 20px; font-weight: 800; text-align: center;
  padding: 6px 14px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 999px;
}
.fac-guide-hint { font-size: 16px; color: #8a5a00; background: #fff4b8; border-radius: 999px; padding: 2px 10px; }

.fac-area {
  position: relative;
  height: clamp(250px, 42vh, 340px);
  overflow: hidden;
  background: linear-gradient(180deg, #bfe4ff 0%, #dff1ff 60%, #f1faff 100%);
  border: 3px solid var(--ink);
  border-radius: 20px;
  box-shadow: inset 0 -12px 0 #b8e0a0, inset 0 -15px 0 #8cc46c;
  touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.fac-cloud {
  position: absolute; pointer-events: none;
  width: 120px; height: 38px;
  background: #fff; border-radius: 999px; opacity: .85;
}
.fac-cloud::before, .fac-cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.fac-cloud::before { width: 54px; height: 54px; left: 18px; top: -26px; }
.fac-cloud::after { width: 40px; height: 40px; left: 60px; top: -18px; }
.fac-cloud.c1 { left: 6%; top: 22%; }
.fac-cloud.c2 { right: 8%; top: 12%; transform: scale(.8); }
.fac-cloud.c3 { left: 44%; top: 62%; transform: scale(.65); opacity: .6; }

.fac-fall-wrap { position: absolute; left: 0; top: 0; will-change: transform; z-index: 2; }
.tile.fac-fall { width: 70px; height: 70px; font-size: 40px; cursor: pointer; }
.fac-fall-wrap.still { animation: fac-appear .25s ease both; } /* 위치는 인라인 transform이 담당하므로 opacity만 */
@keyframes fac-appear { from { opacity: 0; } to { opacity: 1; } }
.fac-fall-wrap.fac-caught .tile { animation: fac-caught .32s ease forwards; background: linear-gradient(180deg, #ffe27a 0%, var(--gold) 100%); }
@keyframes fac-caught { to { transform: scale(1.5); opacity: 0; } }
.tile.fac-miss { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.tile.fac-miss:disabled { opacity: 1; }
.tile.fac-miss::after { content: " ✕"; font-size: 18px; position: absolute; right: 4px; top: 2px; }
.tile.fac-fall { position: relative; }
.fac-fall-wrap.fac-fade { transition: opacity .3s; opacity: 0; }
.fac-fall-wrap.fac-fade-slow { transition: opacity .5s .15s; opacity: 0; }

.fac-over {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 16px;
  background: rgba(255, 250, 240, .94);
  text-align: center;
}
.fac-over-title { margin: 0; font-size: 28px; font-weight: 900; }
.fac-over-text { margin: 0; font-size: 19px; font-weight: 700; color: var(--ink-2); }

/* ---------------- 반응형 ---------------- */
@media (max-height: 820px) and (min-width: 700px) {
  .fac-pic:not(.small) { width: 112px; height: 112px; }
  .fac-pic:not(.small) .fac-pic-emoji { font-size: 70px; }
  .fac-preview { width: 116px; height: 116px; font-size: 84px; }
  .fac-card { gap: 12px; }
}
@media (max-width: 640px) {
  .fac-prompt { font-size: 20px; }
  .fac-top { gap: 10px; }
  .fac-pic { width: 100px; height: 100px; }
  .fac-pic-emoji { font-size: 62px; }
  .fac-arrow { font-size: 30px; }
  .fac-preview { width: 104px; height: 104px; font-size: 74px; }
  .fac-preview.fac-raw { font-size: 36px; }
  .fac-slots { gap: 6px; }
  .fac-plus { font-size: 24px; padding-bottom: 24px; }
  .slot.fac-slot { width: 76px; height: 76px; font-size: 44px; }
  .fac-slot-label { font-size: 13px; padding: 2px 6px; }
  .fac-tray { grid-template-columns: repeat(3, 68px); gap: 10px; padding: 12px; }
  .tile.fac-tile { width: 68px; height: 68px; font-size: 38px; }
  .fac-s2-top { justify-content: center; }
  .fac-target { margin: 0; }
  .fac-hearts { font-size: 24px; }
  .fac-pic.small { width: 64px; height: 64px; }
  .fac-pic.small .fac-pic-emoji { font-size: 40px; }
  .fac-box { width: 66px; height: 66px; font-size: 44px; }
  .fac-guide { font-size: 17px; }
  .tile.fac-fall { width: 62px; height: 62px; font-size: 34px; }
  .fac-between-badge { font-size: 24px; }
}
@media (max-width: 360px) {
  .slot.fac-slot { width: 68px; height: 68px; }
  .fac-slot-label { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .fac-box.active { animation: none; box-shadow: 0 0 0 4px rgba(245, 184, 46, .45); }
  .fac-preview.fac-big { animation: none; transform: scale(1.1); }
}
