/* ══════════════════════════════════════════════
   연산 MBTI 페이지 전용 (front-mbti.css) — v4
   3 screen: intro / quiz / result + 교재 모달(학년별 그룹)
   nav/footer 는 공통 레이아웃 제공, 여기서는 페이지 고유 규칙만
   ══════════════════════════════════════════════ */

:root {
  --mint:        #1DBFB0;
  --mint-dark:   #129E91;
  --mint-mid:    #D4F2EE;
  --mint-light:  #F0FAF9;
  --coral:       #F4623A;
  --coral-dark:  #D9502C;
  --coral-light: #FDF4F2;
  --amber:       #F5A623;
  --amber-light: #FDF8F0;
  --indigo:      #5C6BC0;
  --indigo-light:#F4F4FB;
  --navy:        #1C1F33;
  --gray-bg:     #F7F8FA;
  --gray-border: #EEF0F3;
  --gray-line:   #C8CDD6;
  --gray-text:   #6B7280;
  --white:       #FFFFFF;
}

/* ══════════ 공통 래퍼 ══════════ */
/* ver4: sticky footer 구조로 바뀌면서 min-height 대신 flex:1 (front.css에서 지정) */
.page-wrap {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 16px 60px;
}

/* ══════════ SCREEN: 학년 선택 (ver4 신규) ══════════ */
.grade-select-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.grade-btn {
  padding: 22px 0; border-radius: 14px;
  border: 2px solid var(--gray-border); background: var(--white);
  font-size: 17px; font-weight: 700; color: var(--navy);
  cursor: pointer; transition: all 0.18s; font-family: inherit;
}
.grade-btn:hover {
  border-color: var(--mint); background: var(--mint-light); color: var(--mint-dark);
}
.card {
  background: var(--white);
  border-radius: 24px;
  box-shadow: 0 8px 40px rgba(29,191,176,0.1), 0 2px 12px rgba(0,0,0,0.04);
  max-width: 560px; width: 100%;
  padding: 44px 40px;
  overflow: hidden;
}

/* ══════════ SCREEN 전환 ══════════ */
.screen { display: none; }
.screen.active { display: block; }

/* ══════════ SCREEN 1: 인트로 ══════════ */
/* 인트로 전용 — 카드 패딩 밖으로 이미지 돌출 */
#screen-intro {
  margin: -44px -40px 0;
}
.intro-img {
  width: 100%; display: block;
  object-fit: cover;
}
.intro-content {
  padding: 28px 40px 0;
}
.intro-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--mint-light); color: var(--mint-dark);
  font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
  padding: 5px 14px; border-radius: 20px; margin-bottom: 16px;
}
.intro-title {
  font-size: 28px; font-weight: 900;
  color: var(--navy); letter-spacing: -0.5px;
  line-height: 1.25; margin-bottom: 10px;
  word-break: keep-all;
}
.intro-sub {
  font-size: 15px; color: var(--gray-text); line-height: 1.7;
  margin-bottom: 28px; word-break: keep-all;
}

.btn-start {
  width: 100%; padding: 18px;
  background: var(--mint-dark); color: white;
  border: none; border-radius: 14px;
  font-size: 17px; font-weight: 700;
  cursor: pointer; transition: all 0.18s;
  letter-spacing: -0.3px; font-family: inherit;
}
.btn-start:hover {
  background: var(--mint); transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(29,191,176,0.3);
}

/* ══════════ SCREEN 2: 퀴즈 ══════════ */
.progress-wrap { margin-bottom: 28px; }
.progress-top {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 8px;
}
.progress-label { font-size: 13px; font-weight: 700; color: var(--mint-dark); }
.progress-frac  { font-size: 13px; color: var(--gray-text); }
.progress-track {
  height: 8px; background: var(--mint-light);
  border-radius: 4px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--mint), var(--mint-dark));
  border-radius: 4px; transition: width 0.4s ease;
}
.q-num {
  font-size: 12px; font-weight: 700; color: var(--mint);
  letter-spacing: 0.6px; text-transform: uppercase;
  margin-bottom: 12px;
}
.q-text {
  font-size: 20px; font-weight: 700;
  color: var(--navy); line-height: 1.5;
  margin-bottom: 28px; word-break: keep-all;
}
.choices { display: flex; flex-direction: column; gap: 10px; margin-bottom: 32px; }
.choice {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; border-radius: 14px;
  border: 2px solid var(--gray-border); background: var(--white);
  cursor: pointer; transition: all 0.18s;
  font-size: 15px; color: var(--navy); font-weight: 500;
  text-align: left; width: 100%; min-height: 52px;
  word-break: keep-all; font-family: inherit;
}
.choice:hover { border-color: var(--mint-mid); background: var(--mint-light); }
.choice.selected {
  border-color: var(--mint); background: var(--mint-light);
  color: var(--mint-dark); font-weight: 700;
}
.choice-idx {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--gray-bg); color: var(--gray-text);
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all 0.18s;
}
.choice.selected .choice-idx { background: var(--mint); color: white; }
.quiz-nav {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.btn-prev {
  padding: 13px 24px; border-radius: 12px;
  border: 2px solid var(--gray-border); background: white;
  font-size: 14px; font-weight: 700; color: var(--gray-text);
  cursor: pointer; transition: all 0.18s; flex-shrink: 0; font-family: inherit;
}
.btn-prev:hover { border-color: var(--gray-line); color: var(--navy); }
.btn-prev:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-next {
  flex: 1; padding: 14px 20px; border-radius: 12px;
  background: var(--mint-dark); color: white;
  border: none; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: all 0.18s; font-family: inherit;
}
.btn-next:hover:not(:disabled) { background: var(--mint); }
.btn-next:disabled {
  background: var(--gray-border); color: var(--gray-text); cursor: not-allowed;
}

/* ══════════ SCREEN 3: 결과 ══════════ */

/* 히어로 이미지 (엣지 투 엣지) */
.result-hero-img-wrap { margin: -44px -40px 0; }
.result-hero-full-img { width: 100%; display: block; object-fit: cover; }
.result-hero-info { padding: 20px 0 16px; }
.result-hero-tag {
  display: inline-flex; align-items: center;
  padding: 4px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 700; margin-bottom: 8px;
}
.result-hero-name {
  font-size: 28px; font-weight: 900; color: var(--navy);
  line-height: 1.2; margin-bottom: 8px; letter-spacing: -0.5px;
}
.result-hero-quote {
  font-size: 15px; font-weight: 700; color: var(--navy);
  line-height: 1.6; margin-bottom: 4px; word-break: keep-all;
}
.result-hero-tagline {
  font-size: 14px; color: var(--gray-text);
  line-height: 1.6; margin-bottom: 14px; word-break: keep-all;
}
.result-hero-diag {
  font-size: 13px; color: var(--gray-text);
  line-height: 1.7; word-break: keep-all;
}

/* 캐릭터 스토리 */
.result-story-section {
  border-radius: 14px; padding: 15px 18px; margin-bottom: 12px;
  border: 1.5px solid var(--gray-border);
}
.result-section-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  text-transform: uppercase; color: var(--gray-text); margin-bottom: 7px;
}
.result-story-text {
  font-size: 14px; line-height: 1.8; color: var(--navy); word-break: keep-all;
}

/* 추천 공부법 */
.result-tip-card { border-radius: 16px; padding: 18px 20px; margin-bottom: 24px; }
.result-tip-card-label { display: flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 800; margin-bottom: 8px; }
.section-icon-wrap { height: 40px; flex-shrink: 0; }
/* front.css 의 전역 img{max-width:100%} 가 아이콘을 래퍼 너비로 눌러 찌그러뜨린다.
   (아래 크롭 규칙처럼 래퍼보다 큰 아이콘을 쓰는 경우가 있어 상한을 푼다) */
.section-icon-wrap img { height: 100%; width: auto; max-width: none; display: block; }
/* 추천 공부법 아이콘만 여백이 커서 시각 크기를 맞추려고 크롭해서 사용 */
.result-tip-card-label .section-icon-wrap { width: 27px; height: 24px; overflow: hidden; position: relative; }
.result-tip-card-label .section-icon-wrap img { position: absolute; height: 40px; width: 40px; top: -7px; left: -6.6px; }
.result-tip-card-text { font-size: 14px; line-height: 1.8; word-break: keep-all; }

/* 도서 큐레이션 */
.result-book-section { margin-bottom: 24px; }
.result-book-title {
  font-size: 13px; font-weight: 800; color: var(--navy);
  margin-bottom: 14px; display: flex; align-items: center; gap: 6px;
}
.rank-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: 16px;
  border: 1.5px solid var(--gray-border); background: var(--white);
  margin-bottom: 10px; cursor: pointer; transition: all 0.18s;
  position: relative; overflow: visible;
}
.rank-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); transform: translateY(-1px); }
.rank-card.rank-first { border-width: 2px; margin-top: 14px; }
.rank-first-badge {
  position: absolute; top: -11px; left: 14px;
  font-size: 11px; font-weight: 800; padding: 3px 10px;
  border-radius: 10px; color: white; white-space: nowrap;
}
.rank-num {
  font-size: 22px; font-weight: 900;
  min-width: 28px; flex-shrink: 0; text-align: center;
}
.rank-cover-wrap {
  width: 46px; height: 62px; background: var(--gray-border);
  border-radius: 4px; overflow: hidden; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.rank-cover-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rank-info { flex: 1; min-width: 0; }
.rank-name { font-size: 14px; font-weight: 800; color: var(--navy); margin-bottom: 3px; }
.rank-reason { font-size: 12px; color: var(--gray-text); line-height: 1.5; }
.rank-arrow { font-size: 20px; color: var(--gray-line); flex-shrink: 0; }

/* SNS 공유 */
.share-section { margin-bottom: 20px; }
.share-label {
  font-size: 13px; font-weight: 700; color: var(--gray-text);
  margin-bottom: 12px; text-align: center;
}
.share-btns { display: flex; gap: 10px; }
.btn-share-link {
  flex: 1; padding: 13px 16px; border-radius: 12px;
  border: 2px solid var(--gray-border); background: white;
  font-size: 14px; font-weight: 700; color: var(--navy);
  cursor: pointer; transition: all 0.18s; font-family: inherit;
}
.btn-share-link:hover { border-color: var(--navy); }
.btn-share-kakao {
  flex: 1; padding: 13px 16px; border-radius: 12px;
  border: none; background: #FEE500; color: #3A1D1D;
  font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all 0.18s; font-family: inherit;
}
.btn-share-kakao:hover { background: #f5d800; }
.share-toast {
  display: none; margin-top: 10px; text-align: center;
  font-size: 13px; color: var(--mint-dark); font-weight: 600;
}
.share-toast.show { display: block; }

/* 하단 버튼 */
.btn-restart {
  width: 100%; padding: 16px; background: var(--mint-dark); color: white;
  border: none; border-radius: 14px; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: all 0.18s; font-family: inherit;
}
.btn-restart:hover { background: var(--mint); transform: translateY(-1px); }
.btn-home {
  display: block; text-align: center; text-decoration: none;
  width: 100%; padding: 14px; margin-top: 10px;
  background: transparent; color: var(--gray-text);
  border: 2px solid var(--gray-border); border-radius: 14px;
  font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all 0.18s; font-family: inherit;
}
.btn-home:hover { border-color: var(--navy); color: var(--navy); }

@media (max-width: 480px) {
  .result-hero-img-wrap { margin: -32px -24px 0; }
  .result-hero-name { font-size: 24px; }
}

/* ══════════ MODAL ══════════ */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.5);
  align-items: flex-end; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: var(--white);
  border-radius: 24px 24px 0 0;
  width: 100%; max-width: 600px;
  max-height: 82vh; overflow-y: auto;
  padding: 8px 20px 40px;
}
.modal-handle {
  width: 36px; height: 4px;
  background: var(--gray-border); border-radius: 2px;
  margin: 12px auto 20px;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 16px;
}
.modal-title {
  font-size: 17px; font-weight: 800; color: var(--navy);
  margin-bottom: 3px;
}
.modal-subdesc { font-size: 13px; color: var(--gray-text); }
.modal-close {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: var(--gray-bg); border: none; border-radius: 50%;
  font-size: 16px; cursor: pointer; color: var(--gray-text);
  font-family: inherit; flex-shrink: 0; margin-left: 12px;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--gray-border); }
/* ver4: 회색 그룹 박스 → 책 단위 카드로 변경, 표지·정보를 상단에 묶고 구매 버튼을 하단 고정 */
.modal-book-list { display: flex; flex-direction: column; gap: 18px; }
.modal-grade-label {
  font-size: 13px; font-weight: 800; color: var(--mint-dark);
  letter-spacing: 0.2px; margin-bottom: 10px;
}
.modal-grade-books {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.modal-book-item {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 14px 10px; border-radius: 14px;
  border: 1.5px solid var(--gray-border);
  text-align: center;
}
.modal-book-item-top { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.modal-book-cover-lg {
  width: 88px; flex-shrink: 0; aspect-ratio: 3 / 4;
  border-radius: 8px; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.modal-book-cover-lg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.modal-book-info { width: 100%; min-width: 0; }
.modal-book-item-name { font-size: 14px; font-weight: 800; color: var(--navy); }
.modal-book-item-grade { font-size: 11px; color: var(--gray-text); }
.modal-btn-detail {
  width: 100%; padding: 7px 0; border-radius: 8px;
  font-size: 11px; font-weight: 700;
  background: var(--mint-dark); color: white;
  text-decoration: none;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  margin-top: auto;
}
.modal-btn-detail:hover { background: var(--mint); }

/* 반응형 */
@media (min-width: 640px) {
  /* PC에서는 바텀시트가 아니라 화면 중앙 모달 */
  .modal-overlay { align-items: center; padding: 24px; }
  .modal-sheet {
    max-width: 520px; padding: 32px;
    border-radius: 24px; max-height: 80vh;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  }
  .modal-handle { display: none; }
}
@media (max-width: 480px) {
  .card { padding: 32px 24px; }
  #screen-intro { margin: -32px -24px 0; }
  .intro-content { padding: 24px 24px 0; }
  .intro-title { font-size: 22px; }
  .q-text { font-size: 17px; }
}
