/* =========================================================
   接骨院LPジェネレーター 共通 Custom CSS
   Tailwind CDN を補完する独自スタイル
   ========================================================= */

/* ---------- CSS 変数（テーマ） ---------- */
:root {
  /* 院別色(--brand/--brand-dark/--accent/--accent-dark)は各HTMLのhead内<style>で注入。
     ここで再定義すると後勝ちで院別色を打ち消すため定義しない（共通値のみ）。 */
  --muted-bg: #F3F7FB;
  --ink: #1A2633;
  --muted-text: #51627A;
  --header-height: 64px;
}

@media (min-width: 768px) {
  :root {
    --header-height: 80px;
  }
}

/* ---------- ベース調整 ---------- */
html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-height);
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  /* iOS Safari 100vh 対策 */
  min-height: 100vh;
  min-height: -webkit-fill-available;
  /* モバイル追従CTA被り回避（スマホのみ追加余白） */
}

@media (max-width: 767px) {
  body {
    padding-bottom: 0;
  }
}

/* タップハイライト調整 */
a, button, summary, [role="button"] {
  -webkit-tap-highlight-color: rgba(30, 91, 158, 0.08);
}

/* フォーカスリング */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- プレースホルダ背景 ---------- */
/* 画像が未配置・読み込み失敗時のフォールバック表示 */
.bg-placeholder {
  background: linear-gradient(135deg, #E8F0F9 0%, #D4E4F5 50%, #E8F0F9 100%);
  position: relative;
  overflow: hidden;
}

.bg-placeholder::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 24 24' fill='none' stroke='%231E5B9E' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round' opacity='0.35'%3E%3Crect x='3' y='3' width='18' height='18' rx='2' ry='2'%3E%3C/rect%3E%3Ccircle cx='8.5' cy='8.5' r='1.5'%3E%3C/circle%3E%3Cpolyline points='21 15 16 10 5 21'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 64px 64px;
  pointer-events: none;
  z-index: 0;
}

.bg-placeholder::after {
  content: "画像準備中";
  position: absolute;
  bottom: 20%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--brand);
  opacity: 0.55;
  letter-spacing: 0.05em;
  pointer-events: none;
  z-index: 0;
  white-space: nowrap;
}

.bg-placeholder > img {
  position: relative;
  z-index: 1;
}

/* ---------- FAQ アコーディオン ---------- */
.faq-item summary {
  list-style: none;
  transition: background-color 0.2s ease;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary:hover {
  background-color: rgba(30, 91, 158, 0.03);
}

.faq-item .faq-icon {
  display: inline-block;
  transition: transform 0.25s ease;
  font-weight: 300;
  line-height: 1;
}

.faq-item[open] .faq-icon {
  transform: rotate(45deg);
}

.faq-item[open] summary {
  border-bottom: 1px solid rgba(30, 91, 158, 0.08);
}

/* ---------- ヒーロー微調整 ---------- */
@media (max-width: 767px) {
  h1 {
    line-height: 1.3;
  }
}

/* ---------- カード ホバー効果 ---------- */
@media (hover: hover) {
  article[class*="rounded"]:hover {
    transform: translateY(-2px);
    transition: transform 0.25s ease;
  }
}

/* ---------- スクロールバー（PC） ---------- */
@media (min-width: 1024px) {
  ::-webkit-scrollbar {
    width: 10px;
  }
  ::-webkit-scrollbar-track {
    background: var(--muted-bg);
  }
  ::-webkit-scrollbar-thumb {
    background: var(--brand);
    border-radius: 5px;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: var(--brand-dark);
  }
}

/* ---------- スキップリンク ---------- */
.sr-only:not(:focus):not(:active) {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- iOS Safari 100vhフォールバック ---------- */
@supports (-webkit-touch-callout: none) {
  .min-h-screen {
    min-height: -webkit-fill-available;
  }
}

/* ---------- 追従CTA下余白（コンテンツが被らないように） ---------- */
@media (max-width: 767px) {
  main {
    padding-bottom: 0;
  }
}

/* ---------- 症状別 詳細アコーディオン ---------- */
.symptom-detail summary {
  list-style: none;
}
.symptom-detail summary::-webkit-details-marker {
  display: none;
}
.symptom-detail .symptom-icon {
  display: inline-block;
  transition: transform 0.25s ease;
  font-weight: 300;
  line-height: 1;
}
.symptom-detail[open] .symptom-icon {
  transform: rotate(45deg);
}

/* ---------- 症例カード ハイブリッド表示 ---------- */
.case-card dl {
  display: flex;
  flex-direction: column;
}

.case-card .case-result {
  order: -1;
  background: rgba(245, 158, 11, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 4px;
}

.case-card .case-result dt {
  color: var(--accent-dark, #C97A05);
  margin-bottom: 2px;
}

.case-card .case-collapsible {
  display: none;
}

.case-card.case-card-open .case-collapsible {
  display: block;
  animation: case-fade-in 0.2s ease;
}

@keyframes case-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.case-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--brand);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 0 0;
  margin-top: 8px;
  cursor: pointer;
  background: none;
  border: none;
  transition: color 0.2s;
}

.case-toggle:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

.case-toggle:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.case-card.case-card-open .case-collapsible:first-of-type {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(30, 91, 158, 0.12);
}

@media (prefers-reduced-motion: reduce) {
  .case-card.case-card-open .case-collapsible { animation: none; }
}

/* ---------- 症例タブ切り替え ---------- */
.case-tab {
  background: #ffffff;
  border: 1.5px solid rgba(30, 91, 158, 0.2);
  color: #1A2633;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  transition: all 0.2s ease;
  cursor: pointer;
  white-space: nowrap;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.case-tab:hover {
  background: rgba(30, 91, 158, 0.05);
  border-color: rgba(30, 91, 158, 0.4);
}

.case-tab.active {
  background: var(--brand);
  color: #ffffff;
  border-color: var(--brand);
  box-shadow: 0 4px 12px rgba(30, 91, 158, 0.25);
}

.case-tab:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .case-tab {
    font-size: 12px;
    padding: 7px 12px;
  }
}

/* カードの切り替えアニメ */
.case-card {
  transition: opacity 0.2s ease;
}

/* ---------- 退出時ポップアップ ---------- */
@keyframes popup-in {
  from { opacity: 0; transform: scale(0.92) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.animate-popup-in { animation: popup-in 0.3s ease-out; }

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
#exit-popup:not(.hidden) #exit-popup-overlay {
  animation: overlay-in 0.25s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .animate-popup-in,
  #exit-popup:not(.hidden) #exit-popup-overlay {
    animation: none;
  }
}

/* ---------- フローティングチャットボット ---------- */
@keyframes pulse-soft {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(245, 158, 11, 0); }
}

.animate-pulse-soft {
  animation: pulse-soft 2.4s ease-in-out infinite;
}

@keyframes chatbot-popup {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

#chatbot-window:not(.hidden) {
  animation: chatbot-popup 0.25s ease-out;
  transform-origin: bottom right;
}

/* モーション削減ユーザー向け */
@media (prefers-reduced-motion: reduce) {
  .animate-pulse-soft { animation: none; }
  #chatbot-window:not(.hidden) { animation: none; }
}

/* ---------- プリント対応 ---------- */
@media print {
  header,
  .fixed,
  .sticky,
  iframe,
  [class*="bottom-0"] {
    display: none !important;
  }
  body {
    color: #000;
    background: #fff;
  }
  a {
    text-decoration: underline;
  }
}

/* ---------- アニメーション（控えめ） ---------- */
@media (prefers-reduced-motion: no-preference) {
  section {
    animation-fill-mode: both;
  }
}

/* ---------- フォント最適化 ---------- */
body {
  font-feature-settings: "palt";
  letter-spacing: 0.01em;
  line-height: 1.75;
}

h1, h2, h3, h4 {
  letter-spacing: 0.02em;
  line-height: 1.4;
}

/* ---------- 初回キャンペーンバッジ（ヒーロー右上・回転シール） ---------- */
.campaign-badge {
  position: absolute;
  top: -14px;
  right: -6px;
  z-index: 20;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: var(--accent, #F59E0B);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.45);
  animation: cb-float 3.5s ease-in-out infinite;
}
.campaign-badge:hover { background: var(--accent-dark, #C97A05); }
.cb-ring {
  position: absolute;
  inset: 7px;
  border: 1.5px dashed rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  animation: cb-spin 10s linear infinite;
}
.cb-l1 { font-size: 10px; font-weight: 700; }
.cb-l2 { font-size: 9px; color: #FFF3DC; margin-top: 1px; }
.cb-price { font-size: 23px; font-weight: 900; line-height: 1.15; margin-top: 2px; }
.cb-price small { font-size: 12px; font-weight: 700; }
.cb-l3 { font-size: 9px; color: #FFF3DC; margin-top: 2px; }
@media (min-width: 768px) {
  .campaign-badge { width: 150px; height: 150px; top: -88px; right: -8px; }
  .cb-ring { inset: 9px; }
  .cb-l1 { font-size: 12px; }
  .cb-l2 { font-size: 11px; }
  .cb-price { font-size: 30px; }
  .cb-price small { font-size: 14px; }
  .cb-l3 { font-size: 10px; }
}
@keyframes cb-spin { to { transform: rotate(360deg); } }
@keyframes cb-float {
  0%, 100% { transform: rotate(8deg) translateY(0); }
  50%      { transform: rotate(8deg) translateY(-6px); }
}
@media (prefers-reduced-motion: reduce) {
  .campaign-badge, .cb-ring { animation: none; }
}

/* バッジの表示切替: PC(lg)=写真右上 / スマホ・タブレット=本文先頭にフロート */
.cb-desktop { display: none; }
@media (min-width: 1024px) {
  .cb-desktop { display: flex; }
}
.cb-mobile {
  position: static;
  float: right;
  width: 108px;
  height: 108px;
  margin: -30px 0 6px 12px;
}
.cb-mobile .cb-l1 { font-size: 9px; }
.cb-mobile .cb-l2 { font-size: 8px; }
.cb-mobile .cb-price { font-size: 20px; }
.cb-mobile .cb-price small { font-size: 11px; }
.cb-mobile .cb-l3 { font-size: 8px; }
@media (min-width: 1024px) {
  .cb-mobile { display: none; }
}

/* 外部予約ウィジェット(rizbell)のフロート表示をLPでは抑止（既存GTM経由で注入されるため。
   予約ボタンからの遷移は維持。AI招き猫と競合させない） */
[class*="rzb-widget"], .rzb-widget-btn { display: none !important; }
