/* =========================================================
   quiz.css — 法曹タイプ診断ページ専用の演出
   ※ 質問データ・スコア計算・タイプ判定は js/quiz.js のまま不変。
     ここと js/quiz-fx.js は「見た目と動き」だけを重ねます。
   ========================================================= */

.quiz-section {
  position: relative;
  overflow: hidden;
  overflow: clip;
  isolation: isolate;
  --theme: var(--color-primary);
  --theme-on: #fff;
}

/* 背景の水彩（結果表示後はタイプのテーマカラーに切り替わる） */
.quiz-section::before {
  content: "";
  position: absolute;
  inset: -10% -5%;
  z-index: -1;
  background:
    radial-gradient(26% 32% at 8% 20%, rgba(0, 180, 216, 0.16), transparent 70%),
    radial-gradient(24% 30% at 94% 12%, rgba(230, 57, 115, 0.13), transparent 70%),
    radial-gradient(28% 34% at 88% 90%, rgba(255, 183, 3, 0.16), transparent 70%),
    radial-gradient(24% 30% at 10% 92%, rgba(131, 56, 236, 0.12), transparent 70%);
  animation: headerBleed 20s ease-in-out infinite alternate;
  transition: opacity 0.8s ease;
}
.quiz-section::after {
  content: "";
  position: absolute;
  inset: -10% -5%;
  z-index: -1;
  background:
    radial-gradient(34% 40% at 14% 24%, color-mix(in srgb, var(--theme) 26%, transparent), transparent 70%),
    radial-gradient(34% 40% at 90% 80%, color-mix(in srgb, var(--theme) 22%, transparent), transparent 70%);
  opacity: 0;
  transition: opacity 1s ease;
}
.quiz-section.has-theme::before { opacity: 0.25; }
.quiz-section.has-theme::after { opacity: 1; }

.page-header.has-theme::before {
  background:
    radial-gradient(34% 70% at 14% 40%, color-mix(in srgb, var(--theme) 28%, transparent), transparent 70%),
    radial-gradient(30% 60% at 88% 20%, color-mix(in srgb, var(--theme) 20%, transparent), transparent 70%),
    radial-gradient(30% 55% at 60% 100%, color-mix(in srgb, var(--theme) 16%, transparent), transparent 70%);
}

.quiz-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: 0 40px 70px -40px rgba(20, 33, 61, 0.4);
}

/* ---------- Start screen ---------- */
.quiz-start-blobs {
  display: flex;
  justify-content: center;
  margin: 0 0 26px;
  height: 64px;
}
.quiz-start-blobs i {
  display: block;
  width: 58px;
  height: 58px;
  margin: 0 -9px;
  border-radius: 50%;
  mix-blend-mode: multiply;
  animation: blobBob 3.8s ease-in-out infinite;
}
.quiz-start-blobs i:nth-child(1) { background: var(--c-turquoise); }
.quiz-start-blobs i:nth-child(2) { background: var(--c-magenta); animation-delay: 0.3s; }
.quiz-start-blobs i:nth-child(3) { background: var(--c-yellow); animation-delay: 0.6s; }
.quiz-start-blobs i:nth-child(4) { background: var(--c-violet); animation-delay: 0.9s; }
@keyframes blobBob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.08); }
}

#start-screen h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }

.quiz-chips {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 32px;
}
.quiz-chips li {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--color-tint);
  font-family: var(--font-label);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--color-text-light);
}
.quiz-chips b {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
  color: var(--color-primary);
}

/* ---------- Progress — パレットの色で満たされていく ---------- */
.quiz-progress-track {
  position: relative;
  overflow: visible;
  height: 12px;
  border-radius: 12px;
  background: var(--color-tint);
  margin-bottom: 36px;
  --p: 0.02;
}
.quiz-progress-bar {
  position: relative;
  z-index: 1;
  height: 100%;
  border-radius: 12px;
  background-image: var(--paint-gradient);
  background-repeat: no-repeat;
  /* バー幅に関わらず虹のグラデーションは全幅基準 → 進むほど色が現れる */
  background-size: calc(100% / var(--p)) 100%;
  transition: width 0.7s var(--ease-out);
}
.quiz-progress-bar::after {
  content: "";
  position: absolute;
  right: -9px;
  top: 50%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--dot, #00B4D8);
  box-shadow: 0 0 0 4px #fff, 0 8px 16px -6px rgba(20, 33, 61, 0.5);
  transform: translateY(-50%);
  transition: background 0.6s ease;
}
/* 15問の区切り */
.quiz-progress-track::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent calc(100% - 2px), rgba(250, 249, 246, 0.95) 0) 0 0 / calc(100% / 15) 100%;
}

.quiz-qnum {
  font-family: var(--font-label);
  font-size: 0.8rem;
  letter-spacing: 0.22em;
  color: var(--color-accent-ink);
}
.quiz-qtext {
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  line-height: 1.75;
  min-height: 3.5em;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Question transition ---------- */
.fx-q-in { animation: qIn 0.6s var(--ease-out) both; }
.quiz-qtext.fx-q-in { animation-delay: 0.05s; }
.quiz-scale.fx-q-in { animation-delay: 0.12s; }
@keyframes qIn {
  from { opacity: 0; transform: translate3d(48px, 0, 0); }
  to   { opacity: 1; transform: none; }
}
.q-ghost {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  text-align: center;
  animation: qOut 0.42s cubic-bezier(0.5, 0, 0.9, 0.4) forwards;
}
.q-ghost .quiz-qnum, .q-ghost .quiz-qtext { margin-bottom: 0; }
.q-ghost .quiz-qnum { margin-bottom: 10px; }
@keyframes qOut {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translate3d(-56px, 0, 0); }
}
.fx-screen-in { animation: screenIn 0.7s var(--ease-out) both; }
@keyframes screenIn {
  from { opacity: 0; transform: translate3d(0, 26px, 0) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Scale buttons ---------- */
.quiz-scale-btn { transition: transform 0.35s var(--ease-out), background 0.25s ease, border-color 0.25s ease, box-shadow 0.35s ease; }
.quiz-scale-btn:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 4px; }
.quiz-scale-btn:nth-child(1):hover { background: #C85A32; border-color: #C85A32; box-shadow: 0 14px 22px -10px rgba(200, 90, 50, 0.7); }
.quiz-scale-btn:nth-child(2):hover { background: #D9825F; border-color: #D9825F; box-shadow: 0 12px 20px -10px rgba(200, 90, 50, 0.6); }
.quiz-scale-btn:nth-child(3):hover { background: #E9BBA6; border-color: #E9BBA6; }
.quiz-scale-btn:nth-child(4):hover { background: #B7B2A6; border-color: #B7B2A6; }
.quiz-scale-btn:nth-child(5):hover { background: #B9C7EA; border-color: #B9C7EA; }
.quiz-scale-btn:nth-child(6):hover { background: #7C98D8; border-color: #7C98D8; box-shadow: 0 12px 20px -10px rgba(43, 89, 195, 0.6); }
.quiz-scale-btn:nth-child(7):hover { background: #2B59C3; border-color: #2B59C3; box-shadow: 0 14px 22px -10px rgba(43, 89, 195, 0.7); }
.quiz-scale-labels span:first-child { color: var(--color-accent-ink); }
.quiz-scale-labels span:last-child { color: var(--c-royal); }

/* 回答時に飛び散るしずく */
.fx-drop { position: absolute; z-index: 3; border-radius: 50%; pointer-events: none; will-change: transform, opacity; }

/* ---------- Result — タイプのテーマカラーを鮮やかに ---------- */
#result-screen {
  --theme: var(--color-primary);
  --theme-on: #fff;
  isolation: isolate;
  padding-top: 64px;
}

/* ヒーローブロブ（画像の背後） */
#result-screen::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -190px;
  width: 470px;
  height: 470px;
  margin-left: -235px;
  z-index: -1;
  border-radius: 58% 42% 55% 45% / 48% 56% 44% 52%;
  background: var(--theme);
  opacity: 0;
}
#result-screen::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -80px;
  width: 280px;
  height: 280px;
  margin-left: 70px;
  z-index: -1;
  border-radius: 50%;
  background: color-mix(in srgb, var(--theme) 55%, #fff);
  mix-blend-mode: multiply;
  opacity: 0;
}
#result-screen.fx-result::before { animation: blotIn 1.1s var(--ease-out) 0.05s both, blotMorph 10s ease-in-out 1.2s infinite alternate; }
#result-screen.fx-result::after { animation: blotIn 1.2s var(--ease-out) 0.2s both; }
@keyframes blotIn {
  from { opacity: 0; transform: scale(0.2) rotate(-25deg); }
  to   { opacity: 1; transform: none; }
}

.quiz-result-image {
  width: 232px;
  height: 232px;
  border: 7px solid #fff;
  background: var(--color-surface);
  box-shadow: 0 30px 56px -22px color-mix(in srgb, var(--theme) 80%, #000);
  position: relative;
}
#result-screen.fx-result .quiz-result-image { animation: popIn 0.95s cubic-bezier(0.34, 1.56, 0.64, 1) 0.25s both; }
@keyframes popIn {
  from { opacity: 0; transform: scale(0.35) rotate(-10deg); }
  to   { opacity: 1; transform: none; }
}

/* 4軸のタイプコード */
.result-code {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: -6px 0 22px;
}
.result-code span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 56px;
  padding: 10px 8px 8px;
  border-radius: 14px;
  background: color-mix(in srgb, var(--theme) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--theme) 40%, transparent);
}
.result-code b {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1;
  color: var(--color-primary);
}
.result-code small {
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-text-light);
}
#result-screen.fx-result .result-code span { animation: tileIn 0.7s var(--ease-out) both; }
#result-screen.fx-result .result-code span:nth-child(1) { animation-delay: 0.55s; }
#result-screen.fx-result .result-code span:nth-child(2) { animation-delay: 0.65s; }
#result-screen.fx-result .result-code span:nth-child(3) { animation-delay: 0.75s; }
#result-screen.fx-result .result-code span:nth-child(4) { animation-delay: 0.85s; }
@keyframes tileIn {
  from { opacity: 0; transform: translateY(18px) rotateX(70deg); }
  to   { opacity: 1; transform: none; }
}

.quiz-result-badge {
  display: table;
  margin: 0 auto 18px;
  background: var(--theme);
  color: var(--theme-on);
  font-family: var(--font-label);
  letter-spacing: 0.08em;
  padding: 8px 20px;
  box-shadow: 0 14px 24px -14px color-mix(in srgb, var(--theme) 90%, #000);
}
.quiz-result-title {
  position: relative;
  display: table;
  margin-left: auto;
  margin-right: auto;
  font-size: clamp(1.7rem, 4.2vw, 2.4rem);
  line-height: 1.4;
  margin-bottom: 28px;
  padding-bottom: 14px;
}
.quiz-result-title::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 72px;
  height: 5px;
  margin-left: -36px;
  border-radius: 5px;
  background: var(--theme);
  transform: scaleX(0);
}
#result-screen.fx-result .quiz-result-title::after { animation: lineGrow 0.9s var(--ease-out) 0.9s forwards; }
@keyframes lineGrow { to { transform: scaleX(1); } }

#result-screen.fx-result .quiz-result-badge,
#result-screen.fx-result .quiz-result-title,
#result-screen.fx-result .quiz-result-desc,
#result-screen.fx-result .quiz-cta,
#result-screen.fx-result .quiz-again { animation: subRise 0.8s var(--ease-out) both; }
#result-screen.fx-result .quiz-result-badge { animation-delay: 0.7s; }
#result-screen.fx-result .quiz-result-title { animation-delay: 0.8s; }
#result-screen.fx-result .quiz-result-desc { animation-delay: 1s; }
#result-screen.fx-result .quiz-cta { animation-delay: 1.15s; }
#result-screen.fx-result .quiz-again { animation-delay: 1.3s; }

.quiz-result-desc {
  position: relative;
  background: color-mix(in srgb, var(--theme) 8%, #fff);
  border-left: 5px solid var(--theme);
  border-radius: 6px var(--radius-md) var(--radius-md) 6px;
  color: var(--color-text);
  line-height: 2;
}
.quiz-result-desc strong {
  color: var(--color-primary);
  background: linear-gradient(transparent 62%, color-mix(in srgb, var(--theme) 45%, transparent) 62%);
  padding: 0 2px;
}

#result-screen .quiz-cta .btn-primary {
  --fill-a: var(--theme);
  --fill-b: var(--theme);
  --hover-color: var(--theme-on);
}

.quiz-again {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin-top: 28px;
}
.text-btn {
  position: relative;
  appearance: none;
  background: none;
  border: 0;
  padding: 6px 2px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--color-primary);
  cursor: pointer;
}
.text-btn::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--paint-gradient);
  transform-origin: left;
  transition: transform 0.6s var(--ease-out);
}
.text-btn:hover::after { transform: scaleX(0.3); }

@media (max-width: 768px) {
  .quiz-start-blobs i { width: 50px; height: 50px; }
  .quiz-qtext { min-height: 5.2em; }
  #result-screen { padding-top: 52px; }
  #result-screen::before { width: 360px; height: 360px; margin-left: -180px; top: -150px; }
  #result-screen::after { width: 200px; height: 200px; margin-left: 50px; }
  .quiz-result-image { width: 190px; height: 190px; }
  .result-code { gap: 7px; }
  .result-code span { min-width: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .quiz-start-blobs i { animation: none; }
  .quiz-progress-bar { transition: none; }
  #result-screen::before, #result-screen::after { opacity: 1; }
  .quiz-result-title::after { transform: scaleX(1); }
}

@keyframes blotMorph {
  0%   { border-radius: 58% 42% 55% 45% / 48% 56% 44% 52%; }
  50%  { border-radius: 42% 58% 40% 60% / 58% 42% 58% 42%; }
  100% { border-radius: 52% 48% 62% 38% / 40% 60% 46% 54%; }
}
