/* ============================================================
   오늘의 개발 운세 — 우주 / 타로 테마
   ============================================================ */

:root {
  --bg-0: #07040f;
  --bg-1: #150a30;
  --bg-2: #23103f;

  --gold: #e9c979;
  --gold-soft: #f7e6b6;
  --gold-deep: #a9803a;
  --violet: #a98bff;

  --ink: #f4effe;
  --muted: #b6aad6;
  --line: rgba(233, 201, 121, 0.28);

  /* 뽑기 화면의 카드 (7장 부채꼴) */
  --card-w: clamp(4.6rem, 15vw, 8.5rem);
  --card-h: calc(var(--card-w) * 1.5);

  /* 결과 화면의 카드 (3장 스프레드) */
  --flip-w: clamp(5.4rem, 27vw, 12rem);
  --flip-h: calc(var(--flip-w) * 1.5);

  --shadow-lift: 0 1.25rem 2.5rem rgba(0, 0, 0, 0.55);
  --font: 'Nanum Gothic', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% 0%, var(--bg-2) 0%, var(--bg-1) 38%, var(--bg-0) 78%),
    var(--bg-0);
  background-attachment: fixed;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}

b { font-weight: 800; color: var(--gold-soft); }

/* ---------- 배경 ---------- */
#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.nebula {
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  opacity: 0.5;
}

.nebula--violet {
  width: 34rem; height: 34rem;
  top: -12rem; left: -10rem;
  background: radial-gradient(circle, rgba(126, 78, 232, 0.55), transparent 68%);
  animation: drift 24s ease-in-out infinite alternate;
}

.nebula--gold {
  width: 28rem; height: 28rem;
  bottom: -12rem; right: -8rem;
  background: radial-gradient(circle, rgba(214, 158, 71, 0.4), transparent 68%);
  animation: drift 30s ease-in-out infinite alternate-reverse;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(3rem, 2rem, 0) scale(1.12); }
}

/* ---------- 레이아웃 ---------- */
.stage {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.5rem, 5vw, 3rem) 1.25rem 1rem;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 46rem;
}

.screen--wide { max-width: 62rem; }

.screen.is-active {
  display: flex;
  animation: rise 0.6s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(1.25rem); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 타이포 ---------- */
.eyebrow {
  margin: 0 0 0.9rem;
  font-size: 0.8rem;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--gold);
  opacity: 0.85;
}

.title {
  margin: 0;
  font-size: clamp(2.3rem, 9vw, 3.6rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.25;
  background: linear-gradient(180deg, #fff9ea 8%, var(--gold-soft) 42%, var(--gold) 72%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 3.5rem rgba(233, 201, 121, 0.28);
}

.subtitle {
  margin: 0 0 0.75rem;
  font-size: clamp(1.25rem, 5vw, 1.6rem);
  font-weight: 800;
  color: var(--gold-soft);
}

.lead {
  margin: 1.1rem 0 0;
  font-size: clamp(0.95rem, 3.4vw, 1.05rem);
  line-height: 1.9;
  color: var(--muted);
}

.lead--sm { margin-top: 0; font-size: 0.9rem; opacity: 0.9; }

.hint {
  margin: 1.1rem 0 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: rgba(182, 170, 214, 0.7);
}

/* ---------- 인트로 오브 ---------- */
.orb {
  position: relative;
  width: clamp(11rem, 44vw, 14rem);
  aspect-ratio: 1;
  margin: clamp(1.75rem, 6vw, 2.75rem) 0 clamp(1.75rem, 6vw, 2.5rem);
  display: grid;
  place-items: center;
}

.orb__ring {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  border-top-color: var(--gold);
  animation: spin 14s linear infinite;
}

.orb__ring--2 {
  inset: 1.4rem;
  border-color: rgba(169, 139, 255, 0.28);
  border-bottom-color: var(--violet);
  animation-duration: 9s;
  animation-direction: reverse;
}

@keyframes spin { to { transform: rotate(1turn); } }

.orb__core {
  width: 62%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.5), transparent 42%),
    radial-gradient(circle at 50% 60%, rgba(169, 139, 255, 0.65), rgba(35, 16, 63, 0.9) 70%);
  box-shadow:
    inset 0 0 2.5rem rgba(255, 255, 255, 0.14),
    0 0 3.5rem rgba(126, 78, 232, 0.55);
  animation: pulse 4.5s ease-in-out infinite;
}

.orb__core span {
  font-size: clamp(1.6rem, 6vw, 2.1rem);
  font-weight: 800;
  color: var(--gold-soft);
  text-shadow: 0 0 1.2rem rgba(233, 201, 121, 0.75);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}

/* ---------- 버튼 ---------- */
.btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.95rem 2.2rem;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn--primary {
  border: 1px solid rgba(255, 240, 205, 0.65);
  color: #2b1a05;
  background: linear-gradient(160deg, var(--gold-soft), var(--gold) 55%, #cba454 100%);
  box-shadow: 0 0.75rem 2rem rgba(233, 201, 121, 0.3);
}

.btn--ghost {
  border: 1px solid var(--line);
  color: var(--gold-soft);
  background: rgba(255, 255, 255, 0.04);
}

.btn:hover { transform: translateY(-2px); }
.btn--primary:hover { box-shadow: 0 1rem 2.5rem rgba(233, 201, 121, 0.45); }
.btn--ghost:hover { background: rgba(255, 255, 255, 0.09); }
.btn:active { transform: translateY(0); }

.btn:focus-visible,
.deck__card:focus-visible {
  outline: 2px solid var(--gold-soft);
  outline-offset: 4px;
}

/* ---------- 카드 뒷면 ---------- */
.card-back {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 1rem;
  color: var(--gold);
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 34%, rgba(169, 139, 255, 0.22), transparent 62%),
    linear-gradient(165deg, #2a1550 0%, #190c33 55%, #120722 100%);
  box-shadow: inset 0 0 0 3px rgba(233, 201, 121, 0.14), var(--shadow-lift);
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.22, 0.9, 0.3, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}

.card-back::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, 0.16) 50%, transparent 62%);
  transform: translateX(-120%);
  transition: transform 0.75s ease;
}

.card-back__sigil { width: 66%; }

/* ---------- 카드 선택(부채꼴 덱) ---------- */
.counter {
  margin: 1.6rem 0 0;
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.counter b { font-size: 1.15rem; }

.counter__pos {
  display: block;
  margin-top: 0.45rem;
  font-size: 0.8rem;
  letter-spacing: 0.2em;
  color: var(--gold);
  opacity: 0.9;
}

.deck {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  margin-top: clamp(1.75rem, 6vw, 2.75rem);
  padding-bottom: 2rem;
}

.deck__card {
  position: relative;
  flex: 0 0 auto;
  width: var(--card-w);
  height: var(--card-h);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  animation: deal 0.55s cubic-bezier(0.22, 0.9, 0.3, 1) both;
  transition: opacity 0.45s ease;
}

.deck__card + .deck__card { margin-left: calc(var(--card-w) * -0.4); }

/* 부채꼴 배치 — 위치 전용 transform (호버/선택은 안쪽 카드가 담당) */
.deck__card:nth-child(1) { transform: rotate(-15deg) translateY(1.7rem); animation-delay: 0.02s; z-index: 1; }
.deck__card:nth-child(2) { transform: rotate(-10deg) translateY(0.85rem); animation-delay: 0.08s; z-index: 2; }
.deck__card:nth-child(3) { transform: rotate(-5deg) translateY(0.25rem); animation-delay: 0.14s; z-index: 3; }
.deck__card:nth-child(4) { transform: rotate(0deg) translateY(0); animation-delay: 0.2s; z-index: 4; }
.deck__card:nth-child(5) { transform: rotate(5deg) translateY(0.25rem); animation-delay: 0.26s; z-index: 5; }
.deck__card:nth-child(6) { transform: rotate(10deg) translateY(0.85rem); animation-delay: 0.32s; z-index: 6; }
.deck__card:nth-child(7) { transform: rotate(15deg) translateY(1.7rem); animation-delay: 0.38s; z-index: 7; }

@keyframes deal {
  from { opacity: 0; transform: translateY(3rem) rotate(0deg) scale(0.86); }
}

.deck__card:hover,
.deck__card:focus-visible,
.deck__card.is-chosen { z-index: 20; }

.deck__card:hover .card-back,
.deck__card:focus-visible .card-back { transform: translateY(-1.1rem) scale(1.03); }

.deck__card:hover .card-back::after { transform: translateX(120%); }

.deck__card.is-chosen .card-back {
  transform: translateY(-1.5rem) scale(1.05);
  border-color: var(--gold-soft);
  box-shadow:
    inset 0 0 0 3px rgba(233, 201, 121, 0.4),
    0 0 2.5rem rgba(233, 201, 121, 0.45),
    var(--shadow-lift);
}

/* 선택 순서 배지 */
.deck__card::after {
  content: attr(data-order);
  position: absolute;
  top: -0.6rem;
  left: 50%;
  width: 1.75rem;
  height: 1.75rem;
  transform: translate(-50%, 0.5rem) scale(0.6);
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 800;
  color: #2b1a05;
  background: linear-gradient(160deg, var(--gold-soft), var(--gold));
  box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
  pointer-events: none;
}

.deck__card.is-chosen::after { opacity: 1; transform: translate(-50%, -0.9rem) scale(1); }

.deck.is-locked .deck__card { pointer-events: none; }
.deck.is-locked .deck__card:not(.is-chosen) { opacity: 0; }

/* ---------- 결과: 3장 스프레드 ---------- */
.spread {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: clamp(0.5rem, 2.5vw, 1.5rem);
  margin-top: 0.5rem;
}

.slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.slot__pos {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: clamp(0.85rem, 3vw, 1rem);
  font-weight: 800;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  color: var(--gold-soft);
}

.slot__pos small {
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-indent: 0.12em;
  color: rgba(182, 170, 214, 0.75);
}

.flipper {
  width: var(--flip-w);
  height: var(--flip-h);
  perspective: 1200px;
}

.flipper__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.95s cubic-bezier(0.3, 0.9, 0.25, 1);
}

.flipper.is-flipped .flipper__inner { transform: rotateY(180deg); }

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 1rem;
}

.face--front { transform: rotateY(180deg); }

/* 현재 자리 카드는 조금 크게 강조 */
.slot--present .flipper {
  width: calc(var(--flip-w) * 1.08);
  height: calc(var(--flip-h) * 1.08);
}

/* ---------- 카드 앞면 ---------- */
.card-front {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 1rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: calc(var(--flip-w) * 0.08);
  border: 1px solid rgba(233, 201, 121, 0.55);
  background:
    radial-gradient(circle at 50% 12%, rgba(233, 201, 121, 0.2), transparent 58%),
    linear-gradient(170deg, #2c1a54 0%, #1b0e38 58%, #130826 100%);
  box-shadow: inset 0 0 0 3px rgba(233, 201, 121, 0.16), var(--shadow-lift);
}

.card-front::before {
  content: '';
  position: absolute;
  inset: 0.5rem;
  border: 1px solid rgba(233, 201, 121, 0.22);
  border-radius: 0.6rem;
  pointer-events: none;
}

.card-front__watermark {
  position: absolute;
  left: 12%;
  top: 9%;
  width: 76%;
  height: auto;
  color: var(--gold);
  opacity: 0.08;
  pointer-events: none;
}

.card-front__tag {
  font-size: calc(var(--flip-w) * 0.062);
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  padding: 0.3em 0.9em;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--gold);
}

.card-front__name {
  margin: 0.5em 0 0.1em;
  font-size: calc(var(--flip-w) * 0.19);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-indent: 0.04em;
  white-space: nowrap;
  background: linear-gradient(180deg, #fffaf0, var(--gold-soft) 45%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 2rem rgba(233, 201, 121, 0.35);
}

.card-front__label {
  margin: 0.5em 0 0.3em;
  font-size: calc(var(--flip-w) * 0.068);
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  color: var(--muted);
}

.card-front__ornament {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  color: var(--gold);
  opacity: 0.7;
}

.card-front__ornament span {
  display: block;
  width: calc(var(--flip-w) * 0.18);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
}

.card-front__ornament span:last-child { transform: scaleX(-1); }
.card-front__ornament i { font-style: normal; font-size: 0.6rem; }

/* ---------- 별점 ---------- */
.stars { display: flex; gap: 0.2rem; }

.stars svg {
  width: calc(var(--flip-w) * 0.11);
  height: calc(var(--flip-w) * 0.11);
}

.stars .star--on {
  fill: var(--gold);
  filter: drop-shadow(0 0 0.35rem rgba(233, 201, 121, 0.7));
  animation: twinkle-in 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.stars .star--off { fill: rgba(255, 255, 255, 0.14); }

@keyframes twinkle-in {
  from { opacity: 0; transform: scale(0.2) rotate(-40deg); }
}

/* ---------- 결과 상세 ---------- */
.detail {
  width: 100%;
  max-width: 36rem;
  margin-top: clamp(1.75rem, 6vw, 2.75rem);
  opacity: 0;
  transform: translateY(1rem);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.detail.is-shown { opacity: 1; transform: none; }

.verdict {
  padding: 1.4rem 1.4rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: linear-gradient(160deg, rgba(233, 201, 121, 0.14), rgba(233, 201, 121, 0.03));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.verdict__label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  color: var(--gold);
}

.verdict .stars svg { width: 1.6rem; height: 1.6rem; }

.verdict__text {
  margin: 0.2rem 0 0;
  font-size: clamp(0.95rem, 3.6vw, 1.05rem);
  line-height: 1.8;
  color: var(--ink);
}

.reading {
  margin-top: 0.85rem;
  padding: 1.25rem 1.4rem 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 1rem;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  backdrop-filter: blur(8px);
}

.reading--present { border-color: rgba(233, 201, 121, 0.32); }

.reading__pos {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  color: var(--gold);
}

.reading__pos small {
  font-weight: 400;
  letter-spacing: 0.1em;
  color: rgba(182, 170, 214, 0.8);
}

.reading__name {
  margin: 0.55rem 0 0.15rem;
  font-size: clamp(1.3rem, 5vw, 1.6rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--gold-soft);
}

.reading__meta {
  margin: 0 0 0.9rem;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.reading__meta .glyph {
  color: var(--gold);
  letter-spacing: 0.12em;
  margin-right: 0.45rem;
}

.reading__body {
  margin: 0;
  font-size: clamp(0.95rem, 3.6vw, 1.02rem);
  line-height: 2;
  color: var(--ink);
  white-space: pre-line;
}

.detail__block {
  margin-top: 0.85rem;
  padding: 1.35rem 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 1rem;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  backdrop-filter: blur(8px);
}

.detail__block--caution {
  border-color: rgba(233, 201, 121, 0.3);
  background: linear-gradient(160deg, rgba(233, 201, 121, 0.12), rgba(233, 201, 121, 0.03));
}

.detail__head {
  margin: 0 0 0.7rem;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  color: var(--gold);
}

.detail__body {
  margin: 0;
  font-size: clamp(0.95rem, 3.6vw, 1.02rem);
  line-height: 2;
  color: var(--ink);
  white-space: pre-line;
}

.detail__source {
  margin: 0.7rem 0 0;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: rgba(182, 170, 214, 0.7);
}

.actions {
  display: flex;
  gap: 0.7rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.75rem;
}

/* ---------- 푸터 / 토스트 ---------- */
.footer {
  position: relative;
  z-index: 1;
  padding: 1.5rem 1rem 2rem;
  text-align: center;
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  color: rgba(182, 170, 214, 0.5);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  z-index: 5;
  transform: translate(-50%, 1.5rem);
  padding: 0.7rem 1.4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(19, 8, 38, 0.92);
  color: var(--gold-soft);
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 반응형 ---------- */
@media (max-width: 30rem) {
  .stage { padding-inline: 0.75rem; }

  /* 좁은 화면: 부채꼴 대신 격자로 펼쳐 탭하기 쉽게 */
  :root { --card-w: 4.2rem; }

  .deck {
    flex-wrap: wrap;
    align-items: center;
    max-width: 19rem;
    gap: 0.55rem;
    padding-bottom: 1rem;
  }

  .deck__card:nth-child(n) {
    transform: none;
    margin-left: 0;
    z-index: auto;
  }

  .deck__card.is-chosen { z-index: 20; }
  .deck__card:hover .card-back { transform: none; }
  .deck__card.is-chosen .card-back { transform: translateY(-0.4rem) scale(1.04); }

  /* 작은 카드에서는 이름과 별점만 */
  .card-front__tag,
  .card-front__label,
  .card-front__ornament { display: none; }

  .card-front { gap: 0.5rem; }
  .card-front__name { font-size: calc(var(--flip-w) * 0.2); }
  .stars svg { width: calc(var(--flip-w) * 0.13); height: calc(var(--flip-w) * 0.13); }
  .verdict .stars svg { width: 1.4rem; height: 1.4rem; }

  .btn { padding: 0.85rem 1.6rem; font-size: 0.95rem; }
  .reading, .detail__block { padding-inline: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
