@import './variables.css';

/* 리셋 & 기본 설정 */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-primary);
  background-color: #EBF5F4;
  color: var(--color-text-primary);
}

/* 배경 제주 자연 오름 & 바다 그라데이션 */
.app-container {
  width: 100%;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at 50% 20%, #F4FBFB 0%, #E0F2F1 50%, #C8E6C9 100%);
  position: relative;
  overflow: hidden;
}

/* 가로형 태블릿 PC (Landscape) 관람 컨테이너 */
.quiz-wrapper {
  width: 100%;
  max-width: 960px;
  height: 100vh;
  max-height: 640px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 28px;
  position: relative;
  z-index: 10;
  background: var(--color-sea-glass);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
}

@media (min-height: 500px) and (min-width: 768px) {
  .quiz-wrapper {
    height: 88vh;
    border: 2px solid rgba(255, 255, 255, 0.75);
  }
}

/* 제주 장식 배경 요소를 위한 백그라운드 무드 */
.bg-decor {
  position: absolute;
  pointer-events: none;
  z-index: 1;
}

.bg-oreum {
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 120%;
  height: 220px;
  background: radial-gradient(ellipse at center, rgba(46, 125, 50, 0.12) 0%, rgba(129, 199, 132, 0.04) 70%, transparent 100%);
  border-radius: 50% 50% 0 0;
}

.bg-wave {
  top: -50px;
  right: -50px;
  width: 250px;
  height: 250px;
  border-radius: 40%;
  background: rgba(0, 150, 136, 0.08);
  animation: waveRotate 20s infinite linear;
}

@keyframes waveRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ----------------------------------------------------
 * 화면 전환 (Screen View Management)
 * ---------------------------------------------------- */
.screen {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  width: 100%;
  animation: fadeIn 0.35s ease-out;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ----------------------------------------------------
 * 1. 시작 화면 (#start-screen) - 좌우 잘림 없는 contain 및 정중앙 오버레이
 * ---------------------------------------------------- */
#start-screen {
  /* 로컬 file://, 상대경로 및 웹서버 다중 지원 */
  background-image: 
    url('../../images/main_quiz.png'), 
    url('../images/main_quiz.png'), 
    url('./images/main_quiz.png'), 
    url('file:///C:/Users/user/.gemini/antigravity/scratch/jeju-quiz-app/images/main_quiz.png');
  background-size: contain; /* 좌/우 잘림 100% 방지 */
  background-position: center center;
  background-repeat: no-repeat;
  margin: -24px -28px;
  padding: 24px 28px;
  height: calc(100% + 48px);
  width: calc(100% + 56px);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center; /* 정중앙 수직 정렬 */
  align-items: center; /* 정중앙 수평 정렬 */
}

.start-bg-spacer {
  display: none;
}

/* 이미지 정중앙 오버레이 영역 */
.start-overlay-card {
  width: auto;
  padding: 0;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 0;
  border: none;
  box-shadow: none;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: auto;
  animation: zoomIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes zoomIn {
  from { transform: scale(0.88); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* 주황색 박스를 지우고 네이비 컬러로 정돈된 도전하기 버튼 */
.btn-start {
  width: auto;
  min-width: 140px;
  padding: 10px 26px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #0F2042; /* 또렷한 깊은 네이비 */
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  border: 2.5px solid #0F2042; /* 선명한 네이비 테두리 */
  border-radius: var(--radius-full);
  box-shadow: 0 6px 16px rgba(15, 32, 66, 0.22);
  text-shadow: none;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.btn-start:active {
  transform: translateY(2px);
  background-color: #0F2042;
  color: #FFFFFF;
  box-shadow: 0 2px 8px rgba(15, 32, 66, 0.2);
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.start-bottom-card .description-text {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--color-ocean-dark);
  margin-bottom: 0;
  word-break: keep-all;
  line-height: 1.4;
}

/* 3D 입체 카드 스타일 시작 버튼 ('도전하기') */
.btn-start {
  width: 100%;
  padding: 18px 0;
  background: linear-gradient(135deg, #FFA726 0%, #FF6F00 100%);
  color: var(--color-text-white);
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  border: 2px solid #FFE082;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 0 #B74100, 0 14px 28px rgba(230, 81, 0, 0.4);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.btn-start:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #B74100, 0 6px 14px rgba(230, 81, 0, 0.35);
}

/* ----------------------------------------------------
 * 2. 문제 화면 (#quiz-screen)
 * ---------------------------------------------------- */
.quiz-header {
  margin-bottom: 20px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.progress-text {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--color-ocean-dark);
}

.progress-bar-bg {
  width: 100%;
  height: 12px;
  background-color: rgba(0, 121, 107, 0.12);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 10%;
  background: linear-gradient(90deg, var(--color-ocean-light) 0%, var(--color-tangerine-main) 100%);
  border-radius: var(--radius-full);
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.question-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: var(--color-card-bg);
  padding: 32px 24px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  margin-bottom: 20px;
  border: 1px solid rgba(0, 121, 107, 0.08);
}

.question-text {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--color-text-primary);
  line-height: 1.55;
  word-break: keep-all;
}

/* 선택지 카드 세로 배치 */
.choices-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 10px;
}

.choice-btn {
  width: 100%;
  padding: 20px 24px;
  background-color: var(--color-card-bg);
  border: 2px solid rgba(0, 121, 107, 0.15);
  border-radius: var(--radius-md);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text-primary);
  text-align: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
  word-break: keep-all;
}

/* 터치 / 누름 애니메이션 피드백 */
.choice-btn.selected {
  background-color: var(--color-sky-blue);
  border-color: var(--color-ocean-main);
  color: var(--color-ocean-dark);
  transform: scale(0.97);
  box-shadow: inset 0 2px 6px rgba(0, 77, 64, 0.15);
}

/* ----------------------------------------------------
 * 3. 계산 연출 화면 (#calculating-screen)
 * ---------------------------------------------------- */
.calc-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.calc-spinner {
  width: 90px;
  height: 90px;
  margin-bottom: 30px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.spinner-icon {
  font-size: 3.5rem;
  animation: pulseSpin 1.2s infinite ease-in-out;
}

@keyframes pulseSpin {
  0% { transform: scale(0.9) rotate(0deg); }
  50% { transform: scale(1.15) rotate(180deg); }
  100% { transform: scale(0.9) rotate(360deg); }
}

.calc-title {
  font-size: 1.65rem;
  font-weight: 900;
  color: var(--color-ocean-dark);
  margin-bottom: 12px;
}

.calc-sub {
  font-size: 1.1rem;
  color: var(--color-text-secondary);
}

/* ----------------------------------------------------
 * 4. 최종 결과 화면 (#result-screen)
 * ---------------------------------------------------- */
.result-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  padding: 10px 0;
}

.score-card {
  width: 100%;
  background: var(--color-card-bg);
  padding: 28px 20px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 2px solid rgba(0, 121, 107, 0.12);
  margin-bottom: 16px;
}

.score-label {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.score-display {
  font-size: 4.2rem;
  font-weight: 900;
  color: var(--color-tangerine-dark);
  line-height: 1;
  margin-bottom: 16px;
  letter-spacing: -0.03em;
  text-shadow: 0 4px 12px var(--color-tangerine-glow);
}

.grade-badge-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 24px;
  background-color: var(--color-oreum-soft);
  border-radius: var(--radius-full);
  margin-bottom: 14px;
}

.grade-icon {
  font-size: 1.8rem;
}

.grade-title {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--color-oreum-green);
}

.grade-quote {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--color-ocean-dark);
  margin-bottom: 8px;
  word-break: keep-all;
}

.grade-desc {
  font-size: 0.98rem;
  color: var(--color-text-secondary);
  line-height: 1.45;
  word-break: keep-all;
}

/* 제주 요소 그래픽 믹스 */
.jeju-motifs-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
  font-size: 2rem;
  margin-bottom: 16px;
}

.result-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-retry {
  width: 100%;
  padding: 18px 0;
  background: linear-gradient(135deg, var(--color-ocean-main) 0%, var(--color-ocean-dark) 100%);
  color: var(--color-text-white);
  font-size: 1.3rem;
  font-weight: 800;
  border: none;
  border-radius: var(--radius-md);
  box-shadow: 0 6px 16px rgba(0, 77, 64, 0.25);
  cursor: pointer;
}

.btn-home {
  width: 100%;
  padding: 16px 0;
  background-color: rgba(255, 255, 255, 0.8);
  color: var(--color-text-primary);
  font-size: 1.1rem;
  font-weight: 700;
  border: 1.5px solid rgba(0, 77, 64, 0.2);
  border-radius: var(--radius-md);
  cursor: pointer;
}

/* ----------------------------------------------------
 * 하단 제주어 작성 원칙 및 안내
 * ---------------------------------------------------- */
.footer-notice {
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 14px;
  line-height: 1.3;
}

/* ----------------------------------------------------
 * 경고 토스트 (방치 카운트다운 알림)
 * ---------------------------------------------------- */
.auto-reset-toast {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background-color: var(--color-basalt-main);
  color: var(--color-text-white);
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}

.auto-reset-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
