/* styles.css — Choice Helper
   콘셉트: "운명의 오라클" — 점술사/크리스털 오브 배경 + 금색·상아 포인트,
   명조(세리프) 타이포. 주사위는 딥 자수정 레진. 모바일 우선. */

/* 명조(세리프) 폰트 — 나눔명조(OFL, 웹 임베드·수정 허용). 로컬 번들, 외부 URL 없음 */
@font-face {
  font-family: 'Nanum Myeongjo';
  src: url('../fonts/nanum-myeongjo.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

:root {
  /* 오라클 팔레트 (배경 이미지에서 추출) */
  --bg-base: #14101f;      /* fallback·오버레이 베이스 */
  --gold: #f0c36a;         /* 주 포인트: 타이틀·테두리·버튼·글로우 */
  --gold-deep: #c9932f;    /* hover·보조선 */
  --robe-blue: #2b3a7a;
  --robe-purple: #6b3fa0;  /* 주사위와 연결되는 보조 포인트 */
  --ivory: #f5eedc;        /* 본문 텍스트 */

  /* 기존 참조 유지 (주사위 CSS fallback·연출 등에서 사용) */
  --amethyst: #8b5cf6;
  --amethyst-soft: #a78bfa;
  --pink: #f472b6;
  --pink-bright: #ff7ac2;

  --text: var(--ivory);
  --text-dim: #cdbfa0;
  --text-faint: #9a8f78;
  --card: rgba(24, 18, 40, 0.55);
  --card-border: rgba(240, 195, 106, 0.25);
  --type-card-bg: rgba(24, 18, 40, 0.55);
  --type-card-border: rgba(240, 195, 106, 0.25);
  --radius: 18px;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.5);
  --serif: 'Nanum Myeongjo', "Apple SD Gothic Neo", "Noto Serif KR", serif;
}

* { box-sizing: border-box; }

/* 폼 요소(button/input 등)는 기본적으로 폰트를 상속하지 않으므로 강제 상속 */
button, input, select, textarea { font-family: inherit; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--serif);
  color: var(--text);
  background:
    radial-gradient(1200px 900px at 50% -10%, #241733, transparent 60%),
    radial-gradient(900px 600px at 90% 110%, rgba(107, 63, 160, 0.18), transparent 55%),
    linear-gradient(180deg, #17122a, var(--bg-base));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 32px) 20px
           calc(env(safe-area-inset-bottom) + 32px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.is-hidden { display: none !important; }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ── 헤더 (명조 세리프) ── */
.app-header { text-align: center; margin-bottom: 24px; }

.app-title {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 400;
  line-height: 1.1;
  margin: 0 0 4px;
  letter-spacing: 0.06em;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(240, 195, 106, 0.5), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.screen-title {
  font-family: var(--serif);
  font-size: 25px;
  font-weight: 400;
  margin: 0 0 2px;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-shadow: 0 0 14px rgba(240, 195, 106, 0.35);
}

.app-subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 15px;
  letter-spacing: 0.02em;
}

/* ── 선택 타입 카드 (가로 배치, §3.2) ── */
/* 데스크톱·태블릿: 한 줄 4개 / 좁은 모바일(≤480px): 2×2 */
.type-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: auto;
  margin-bottom: auto;
}

/* 반투명 다크 글래스 + 금색 테두리 */
.type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 168px;
  padding: 22px 14px;
  border: 1px solid var(--type-card-border);
  border-radius: 22px;
  background: var(--type-card-bg);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--text);
  cursor: pointer;
  text-align: center;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.type-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.55), 0 0 20px rgba(240, 195, 106, 0.15);
  border-color: rgba(240, 195, 106, 0.6);
}
.type-card:active { transform: translateY(-2px) scale(0.99); }

/* 큰 표기 글리프(명조 세리프, 금색). 구분자는 작고 연하게 */
.type-card__glyph {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0.03em;
  margin-top: 8px;
  color: var(--gold);
}
.type-card__glyph em {
  font-style: normal;
  font-size: 16px;
  color: rgba(240, 195, 106, 0.45);
  margin: 0 4px;
  vertical-align: middle;
}

.type-card__sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: rgba(240, 195, 106, 0.7);
}

.type-card__ko {
  margin-top: auto;
  font-size: 15px;
  color: var(--ivory);
}

@media (max-width: 480px) {
  .type-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .type-card { min-height: 150px; padding: 20px 12px; }
  .type-card__glyph { font-size: 30px; }
}

/* ── 메인(오라클) 배경 + 가독성 오버레이 ── */
/* home 화면이 표시될 때만 렌더(숨김 시 display:none 으로 함께 사라짐). */
.screen--home { position: relative; }

.screen--home::before,
.screen--home::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
}
/* 배경 이미지 (로딩 전/실패 시 --bg-base fallback) */
.screen--home::before {
  z-index: -3;
  background: url('../assets/bg-oracle.webp') center 20% / cover no-repeat;
  background-color: var(--bg-base);
}
/* 상단은 배경이 살고 하단(카드)은 어두워지는 그라데이션 */
.screen--home::after {
  z-index: -2;
  background: linear-gradient(
    180deg,
    rgba(20, 16, 31, 0.35) 0%,
    rgba(20, 16, 31, 0.15) 30%,
    rgba(20, 16, 31, 0.75) 70%,
    rgba(20, 16, 31, 0.92) 100%
  );
}
/* 모바일 세로: 오브·두 손이 상단 1/3에 오도록 크롭 기준 조정 */
@media (max-width: 560px) {
  .screen--home::before { background-position: center 14%; }
}

/* 오브 자리의 금빛 펄스 글로우 (정지 이미지에 생기) */
.oracle-glow {
  position: fixed;
  top: 27%;
  left: 50%;
  width: 260px;
  height: 260px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(240, 195, 106, 0.4) 0%,
    rgba(240, 195, 106, 0.14) 40%,
    rgba(240, 195, 106, 0) 70%
  );
  filter: blur(10px);
  pointer-events: none;
  z-index: -1;
  animation: orb-pulse 3.6s ease-in-out infinite;
}
@keyframes orb-pulse {
  0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
  50%      { opacity: 0.9; transform: translate(-50%, -50%) scale(1.12); }
}

/* home 레이아웃: 타이틀은 상단, 카드는 하단(어두운 영역)으로 */
.screen--home .app-header { margin-top: 8vh; }
.screen--home .type-grid { margin-top: auto; margin-bottom: 4vh; }

@media (prefers-reduced-motion: reduce) {
  .oracle-glow { animation: none; }
  .type-card, .btn { transition: none; }
}

/* ── 라벨 입력 ── */
.label-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-top: 12px;
}

.label-inputs {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.label-input {
  display: flex;
  align-items: center;
  gap: 12px;
}

.label-input__badge {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  font-size: 20px;
  color: var(--gold);
  background: rgba(240, 195, 106, 0.12);
  border: 1px solid rgba(240, 195, 106, 0.3);
}

.label-input__field {
  flex: 1;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(20, 11, 36, 0.6);
  color: var(--text);
  font-size: 16px; /* iOS 자동 확대 방지 */
  outline: none;
  transition: border-color 0.2s ease;
}

.label-input__field::placeholder { color: rgba(185, 169, 217, 0.55); }
.label-input__field:focus { border-color: var(--amethyst); }

.label-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── 공통 버튼 ── */
.btn {
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.04em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.12s ease, filter 0.2s ease;
}

.btn:active { transform: scale(0.98); }

/* 주요 버튼: 금색 (오라클 포인트) */
.btn--primary {
  color: #2a1c08;
  background: linear-gradient(120deg, var(--gold), var(--gold-deep));
  box-shadow: 0 6px 18px rgba(201, 147, 47, 0.3);
}
.btn--primary:hover { filter: brightness(1.06); }

.btn--ghost {
  color: var(--ivory);
  background: transparent;
  border-color: var(--card-border);
}
.btn--ghost:hover { background: rgba(240, 195, 106, 0.1); }

.link-back {
  margin-top: 20px;
  align-self: center;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
}

/* ── 3D 주사위 스테이지 ── */
.dice-stage {
  position: relative;
  width: 100%;
  height: 260px;
  margin: 4px 0 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.dice-canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

/* 주사위 아래 은은한 보라 글로우 (§7) */
.dice-glow {
  position: absolute;
  left: 50%;
  top: 52%;
  width: 78%;
  height: 78%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(139, 92, 246, 0.42) 0%,
    rgba(192, 38, 211, 0.18) 42%,
    rgba(139, 92, 246, 0) 70%
  );
  filter: blur(8px);
  pointer-events: none;
  z-index: 0;
}

.dice-hint {
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  pointer-events: none;
}

/* CSS fallback (WebGL 미지원) — 연출 상세는 v0.2.3 */
.dice-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dice-fallback__cube {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  font-family: Georgia, serif;
  font-size: 40px;
  color: #f0b27a;
  background: linear-gradient(145deg, rgba(123, 47, 190, 0.55), rgba(58, 24, 90, 0.75));
  border: 1px solid rgba(167, 139, 250, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), inset 0 0 24px rgba(139, 92, 246, 0.35);
  transition: transform 0.12s ease, box-shadow 0.2s ease;
}

.dice-fallback__cube.is-rolling { animation: dice-shake 0.35s linear infinite; }
.dice-fallback__cube.is-settle { animation: dice-settle 0.24s ease-out; }
.dice-fallback__cube.is-nat20 {
  color: #ffe08a;
  box-shadow: 0 0 34px rgba(255, 209, 122, 0.85), inset 0 0 26px rgba(255, 209, 122, 0.6);
  border-color: rgba(255, 209, 122, 0.9);
}
.dice-fallback__cube.is-nat1 {
  color: #ff8a8a;
  box-shadow: 0 0 30px rgba(255, 43, 59, 0.7), inset 0 0 22px rgba(120, 20, 30, 0.8);
  border-color: rgba(255, 43, 59, 0.8);
}

@keyframes dice-shake {
  0%   { transform: rotate(0deg)   translate(0, 0); }
  25%  { transform: rotate(8deg)   translate(2px, -2px); }
  50%  { transform: rotate(-6deg)  translate(-2px, 2px); }
  75%  { transform: rotate(5deg)   translate(1px, 1px); }
  100% { transform: rotate(0deg)   translate(0, 0); }
}
@keyframes dice-settle {
  0%   { transform: scale(1.12); }
  60%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}

.dice-caption {
  position: absolute;
  top: 4px;
  left: 0;
  right: 0;
  margin: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  pointer-events: none;
}

/* ── 결과 ── */
.tie-banner {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 12px;
  text-align: center;
  font-weight: 700;
  color: var(--pink-bright);
  background: rgba(244, 114, 182, 0.14);
  border: 1px solid rgba(244, 114, 182, 0.4);
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.result-card {
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  background: var(--card);
  box-shadow: var(--shadow);
}

.result-card__name {
  font-size: 15px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.result-card__grade {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

/* 등급별 색 구분 (내추럴20/1의 특별 연출은 v0.2 예정) */
.result-card--nat20 {
  border-color: rgba(255, 209, 102, 0.7);
  background: linear-gradient(135deg, rgba(255, 209, 102, 0.18), rgba(244, 114, 182, 0.14));
}
.result-card--nat20 .result-card__grade { color: #ffd166; }

.result-card--t7 .result-card__grade,
.result-card--t6 .result-card__grade { color: var(--pink-bright); }
.result-card--t5 .result-card__grade,
.result-card--t4 .result-card__grade { color: var(--amethyst-soft); }
.result-card--t3 .result-card__grade,
.result-card--t2 .result-card__grade { color: var(--text-dim); }

.result-card--nat1 {
  border-color: rgba(120, 120, 140, 0.5);
  background: rgba(40, 30, 60, 0.5);
}
.result-card--nat1 .result-card__grade { color: #9aa0b5; }

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}
