/* ==========================================================================
   JUSTA住宅ローン相談 かんたん診断ツール - 専用スタイル
   base.css(../../css/base.css)読み込み後に適用。design.md 4章「診断ツールS1〜S6」を実装。
   ========================================================================== */

html, body { height: 100%; }
html { scroll-padding-bottom: calc(var(--cta-bar-h) + 24px); }
body.diag-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--cta-bar-h) + 24px + env(safe-area-inset-bottom));
}

/* ---- シンプルヘッダー ---- */
.diag-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.diag-header__inner {
  width: 100%;
  max-width: var(--container-text);
  margin-inline: auto;
  padding-inline: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.diag-header .site-logo { font-family: var(--font-latin); font-weight: 700; font-size: 1.2rem; }
.diag-header__back {
  font-size: var(--text-small);
  color: var(--color-ink-soft);
}

/* ---- ドットインジケーター ---- */
.diag-progress {
  padding: 20px 20px 4px;
  max-width: var(--container-text);
  margin-inline: auto;
  width: 100%;
}
.diag-progress__dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.diag-progress__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-paper-deep);
  transition: background-color .25s var(--ease-out), transform .25s var(--ease-out);
}
.diag-progress__dot.is-current {
  background: var(--color-ink);
  transform: scale(1.3);
}
.diag-progress__dot.is-filled { background: var(--color-ink-soft); }
.diag-progress__label {
  text-align: center;
  margin-top: 10px;
  font-family: var(--font-latin);
  font-size: var(--text-small);
  color: var(--color-ink-faint);
}
.diag-progress[hidden] { display: none; }

/* ---- 画面本体 ---- */
.diag-main {
  flex: 1;
  display: flex;
  align-items: center;
  width: 100%;
}
.diag-stage {
  width: 100%;
  max-width: var(--container-text);
  margin-inline: auto;
  padding: 24px 20px 40px;
  position: relative;
}

.screen { display: none; }
.screen.is-active { display: block; }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes crossFadeOnly {
  from { opacity: 0; }
  to { opacity: 1; }
}
.screen.is-active.dir-forward { animation: slideInRight .35s var(--ease-in-out); }
.screen.is-active.dir-back { animation: slideInLeft .35s var(--ease-in-out); }

/* prefers-reduced-motion時は横スライドをクロスフェードに縮退させる(移動を伴う演出だけを止める) */
@media (prefers-reduced-motion: reduce) {
  .screen.is-active.dir-forward,
  .screen.is-active.dir-back { animation: crossFadeOnly .25s linear; }
}

.screen__title {
  font-size: var(--text-h2);
  line-height: 1.5;
  text-align: center;
}
.screen__lead {
  margin-top: 16px;
  text-align: center;
  color: var(--color-ink-soft);
  font-size: var(--text-body-lg);
  line-height: 1.9;
}

/* ---- イントロ(S0) ---- */
.screen--intro { text-align: center; }
.screen--intro .screen__title { font-size: var(--text-h2); }
.screen--intro .screen__actions { margin-top: 40px; }

/* ---- 選択肢カード ---- */
.choice-list {
  margin-top: 36px;
  display: grid;
  gap: 14px;
}
.choice-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-width: 0;
  min-height: 64px;
  padding: 18px 22px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-select);
  background: var(--color-paper);
  text-align: left;
  font-size: var(--text-body-lg);
  font-weight: 500;
  transition: border-color .2s var(--ease-out), background-color .2s var(--ease-out);
}
.choice-card span.choice-card__label {
  min-width: 0;
  overflow-wrap: break-word;
  line-break: strict;
}
.choice-card__mark {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.choice-card__mark svg {
  width: 14px; height: 14px;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity .2s var(--ease-out), transform .2s var(--ease-out);
}
.choice-card.is-selected {
  border-color: var(--color-ink);
  background: var(--color-paper-alt);
}
.choice-card.is-selected .choice-card__mark {
  border-color: var(--color-ink);
  background: var(--color-ink);
  color: var(--color-paper);
}
.choice-card.is-selected .choice-card__mark svg {
  opacity: 1;
  transform: scale(1);
}
@media (prefers-reduced-motion: reduce) {
  .choice-card, .choice-card__mark svg { transition: none; }
}

/* ---- 下部固定CTA ---- */
.diag-cta-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 400;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: oklch(0.975 0.008 75 / 0.94);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--color-border);
}
.diag-cta-bar__inner {
  max-width: var(--container-text);
  margin-inline: auto;
  /* 【auditor指摘・構造的修正】S9で「戻って修正する」(secondary)+「この内容で送信する」(primary)の
     2ボタンを縦積みできるようflex column化。1ボタンのみのモード(S0〜S8)では単に1個のflex itemが
     全幅で並ぶだけで、見た目に変化はない。 */
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.diag-cta-bar .btn {
  width: 100%;
  min-height: 56px;
}
.diag-cta-bar .btn[disabled] {
  background: var(--color-paper-deep);
  color: var(--color-ink-faint);
  pointer-events: none;
}
/* secondaryボタン(「戻って修正する」)はS9以外では常にhidden属性で非表示 */
.diag-cta-bar__btn-secondary[hidden] { display: none; }

/* ---- 【問い合わせメール機能追加】S8(ご相談内容の入力)・S9(確認画面)。
   フォーム自体の見た目(.contact-form__*)は../css/style.cssを流用し、ここでは
   .screen内での見出し直後の余白のみ調整する(inquiry-mail-design.md 6-7章「見た目の統一」)。 ---- */
.screen .contact-form__step,
.screen .contact-form__summary { margin-top: 32px; }
.screen .contact-form__summary-note { text-align: center; }
.screen .g-recaptcha {
  display: flex;
  justify-content: center;
  margin: 24px 0;
}

/* 【reviewer指摘・要修正1→auditor指摘で構造的に作り直し】
   当初はS8/S9とも、固定CTAバー実高さ+余白ぶんのpadding-bottomをscreenに足すだけの対応をしていたが、
   S9は「戻って修正する」がスクロール可能なコンテンツ末尾(.screen__actions)にあったため、
   画面遷移のたびに働くwindow.scrollTo({top:0})の仕様と合わさり、初期表示時点(スクロール前)で
   ボタンが最大255px(320×568)も不可視になっていた。padding-bottomでは「スクロールすれば見える」
   状態にしかならず、利用者がスクロールする動機がないため根本解決にならないとauditor指摘を受け、
   「戻って修正する」「この内容で送信する」を.diag-cta-bar(常に画面内に留まる固定バー)側に統合する
   構造に作り直した(HTML: justa-loan-diagnosis/index.html、JS: diagnosis.js updateCtaBar()参照)。
   これによりS9はスクロール操作なしで両方のボタンが常時可視・操作可能になる。
   S8は元々「次へ」ボタンが固定バー側にあり同種の不具合は発生していなかったが、内容が長いため
   引き続きpadding-bottomで文末(reCAPTCHA等)の可読性を確保する。S9はボタン2個分バーが高くなる
   (実測146px前後)ため、内容末尾(reCAPTCHA)が窮屈にならない程度の余白を別途確保する。 */
.screen[data-step="8"] {
  padding-bottom: calc(82px + 24px + env(safe-area-inset-bottom));
}
.screen[data-step="9"] {
  padding-bottom: calc(148px + 24px + env(safe-area-inset-bottom));
}

/* ---- 結果画面(S7) ---- */
.screen--result { text-align: center; }
.screen--result .screen__actions {
  margin-top: 36px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 420px;
  margin-inline: auto;
}
.screen--result .screen__back {
  margin-top: 24px;
  font-size: var(--text-small);
  color: var(--color-ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.screen--result__icon {
  width: 64px; height: 64px;
  margin: 0 auto 24px;
  border-radius: 50%;
  background: var(--color-paper-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-ink);
}
