/* ことらタロット 共通スタイル
   サイトごとの差分は --site-color（カテゴリ色）と --bg-image（背景画像）だけ。
   どちらも js/site-config.js から設定される。 */

:root {
  color-scheme: light;
  --site-color: #E3DCF5;           /* カテゴリ色（下地） */
  --bg-image: none;                /* 背景画像（本採用のシンプル版）。none なら下地の色だけ */

  /* カード枠のラベンダー紫を基準にした差し色 */
  --accent: #7A68B5;               /* 主ボタンの面（白文字とのコントラスト 4.8:1） */
  --accent-deep: #5E4E98;          /* 輪郭・小見出し・アイコン */
  --accent-soft: #CFC5EC;

  --ink: #4B3F48;                  /* 本文：真っ黒ではない、こげ茶寄りの濃い色 */
  --ink-muted: #685C6A;            /* 注意書きなど控えめな文字 */
  --paper: rgba(255, 255, 255, 0.62);
  --paper-strong: rgba(255, 255, 255, 0.78);

  /* 引く前の画面で「ほかのタロット」が最初の画面の下端から見える量
     none（標準）：見せない。最初の画面は山札とボタンだけで、スクロールすると出てくる
     small：見出し＋タイルの上端が少し（64px。html に .peek-small が付いたとき）
     large：見出し＋タイルの2/3ほど（html に .peek-large が付いたとき） */
  --peek-visible: 0px;
  /* 山札の大きさは、画面の高さから山札以外の分とのぞかせる分を引いて決める */
  /* 引く前の画面で山札以外（タイトル・吹き出し・余白・ボタン）が使う高さの目安。
     山札を 0.9 倍にして空いた分でボタンとの間を広げているので、実際の合計より少し小さい値にしてある */
  --home-fixed: 339px;
  --card-scale-home: 0.9; /* 入る最大の大きさに対する山札の大きさ（2026-11-28 実機確認で 0.9 に） */
  --card-w-home: clamp(150px, calc(min(64vw, calc((100svh - var(--home-fixed) - var(--peek-visible)) * 0.6667), 262px) * var(--card-scale-home)), 262px);
  --card-w-result: clamp(180px, min(86vw, calc((100svh - 225px) * 0.6667)), 360px);
  /* 表カード画像は角丸の外側が白で塗られている（半径およそ50px/幅1200px）。
     それより少し大きく角を切り抜き、白を見せずに背景を透かす */
  --card-radius: 4.7% / 3.13%;

  /* Zen Maru Gothic は 400/500/700 を読み込み。読み込み前・失敗時は端末の丸ゴシック等で表示 */
  --font: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "BIZ UDPGothic", "Yu Gothic UI", "Yu Gothic", "Meiryo", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  /* シャッフルで画面の外へはみ出したカードは画面の端で切る（横スクロールを出さない）。
     中身の要素で切ると画面の内側に切れ目が見えるので、ここで切る */
  overflow-x: clip;
  background-color: var(--site-color);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  -webkit-tap-highlight-color: transparent;
}

img { display: block; max-width: 100%; height: auto; }

/* 背景は中身と別レイヤー。--bg-image を none にすれば下地のカテゴリ色に戻る */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: var(--site-color);
  background-image: var(--bg-image);
  background-position: center top;
  background-size: cover;
  pointer-events: none;
}
@media (min-width: 700px) {
  .bg-layer { background-size: 560px auto; background-repeat: repeat; }
}

.page {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ───────── 引く前の画面 ───────── */

.view-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: max(10px, env(safe-area-inset-top));
}

.site-title {
  /* タイトル画像の大きさ：絵の部分（虎〜月。画像幅の約93%）が、下の「マスコット＋吹き出し」（幅約275px）より
     左右に18pxほどはみ出す大きさ＝画像幅333px（2026-11-28 実機確認で調整）。狭い画面では横幅いっぱいまで */
  margin: 0;
  width: min(333px, calc(100% + 24px));
  font-size: 1.25rem;
  line-height: 1.4;
}
.site-title img { width: 100%; }

/* タイトル画像を使わないときの代替見出し（マスコット＋HTMLテキスト） */
.site-title.is-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 0 6px;
}
.site-title.is-text img { width: 48px; border-radius: 50%; }

.guide {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 0;
  max-width: 340px;
}
.guide-mascot {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 38%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}
.guide-bubble {
  position: relative;
  margin: 0;
  padding: 7px 13px;
  background: var(--paper-strong);
  border-radius: 14px 14px 14px 4px;
  font-size: 0.8125rem;
  line-height: 1.55;
  white-space: pre-line;   /* 文言の \n で改行し、吹き出しの幅を文字の長さに合わせる */
  word-break: auto-phrase; /* 画面がとても狭いときだけ文節で折り返す（対応ブラウザのみ） */
}
.guide-bubble::before {
  content: "";
  position: absolute;
  left: -6px;
  bottom: 8px;
  border: 6px solid transparent;
  border-right-color: var(--paper-strong);
  border-left: 0;
}

.notice {
  margin: 10px 0 0;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--ink-muted);
  text-align: center;
  word-break: auto-phrase; /* 文節で折り返す（「す」だけが次の行に落ちないように） */
  text-wrap: balance;
}

/* 山札 */
.deck {
  position: relative;
  width: var(--card-w-home);
  aspect-ratio: 2 / 3;
  margin: 28px 0 48px; /* 吹き出しとの間・ボタンとの間はしっかり空ける（ボタンとの間は実機確認で48pxに） */
  perspective: 1400px;
}

/* 背の低い画面（iPhone の Safari などツールバーで高さが減る端末）：山札の大きさを決める目安を調整 */
@media (max-height: 760px) {
  :root { --home-fixed: 318px; }
}
/* とても背の低い画面（iPhone SE の Safari など）だけ、ボタンが最初の画面に収まるようタイトルを少し小さくする */
@media (max-height: 600px) {
  .view-home .site-title { max-width: calc(19svh * 2.6667); }
}
/* 山札の置き場：カードのまわりの背景だけを、ふちがぼんやり消える楕円の影でほんのり暗くする */
.deck::before {
  content: "";
  position: absolute;
  inset: -16% -30% -14%;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(70, 52, 112, 0.24), rgba(70, 52, 112, 0.12) 55%, rgba(70, 52, 112, 0) 100%);
  pointer-events: none;
}
.deck-card {
  position: absolute;
  inset: 0;
  border-radius: var(--card-radius);
}
.deck-card img,
.face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--card-radius);
}
.deck-under { box-shadow: 0 1px 2px rgba(74, 56, 110, 0.18); }
.deck-under.u3 { transform: translate(7px, 8px) rotate(2.2deg); z-index: 1; }
.deck-under.u2 { transform: translate(4px, 5px) rotate(1.1deg); z-index: 2; }
.deck-under.u1 { transform: translate(2px, 2px); z-index: 3; }
.deck-top { z-index: 4; }

.flip {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform var(--flip-ms, 500ms) cubic-bezier(0.3, 0.7, 0.3, 1);
}
.deck-top.is-flipped .flip { transform: rotateY(180deg) translateZ(0); }
.deck-top.no-anim .flip { transition: none; }

.face {
  position: absolute;
  inset: 0;
  border-radius: var(--card-radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 10px 24px -10px rgba(74, 56, 110, 0.45), 0 1px 2px rgba(74, 56, 110, 0.2);
}
.face-front { transform: rotateY(180deg); }
.face-front.is-reversed img,
.result-card.is-reversed img { transform: rotate(180deg); }

/* ボタン：主（カードを引く）と副（シャッフル）で格差をつける */
.actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  max-width: 360px;
}
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  border: 0;
  font: inherit;
  white-space: nowrap; /* ボタンの文言は折り返さない */
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, background-color 0.2s ease, opacity 0.2s ease;
}
.btn:active { transform: translateY(1px) scale(0.985); }
.btn:disabled { cursor: default; opacity: 0.55; }
.btn:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }

.btn-main {
  flex: 1.5;
  min-height: 58px;
  padding: 0 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  box-shadow: 0 3px 0 var(--accent-deep), 0 10px 20px -12px rgba(60, 40, 110, 0.7);
}
.btn-main:active { box-shadow: 0 2px 0 var(--accent-deep); }

.btn-sub {
  flex: 1;
  min-width: max-content; /* 狭い画面でも「シャッフルする」を1行に保ち、主ボタンの方を縮める */
  min-height: 46px;
  padding: 0 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.35);
  color: var(--accent-deep);
  box-shadow: inset 0 0 0 1.5px var(--accent-deep);
  font-size: 0.875rem;
  font-weight: 500;
}

.load-error {
  margin: 14px 0 0;
  font-size: 0.8125rem;
  text-align: center;
}

/* ───────── 結果画面 ───────── */

.result-hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: max(18px, env(safe-area-inset-top));
  padding-bottom: 56px;
}
.result-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-indent: 0.3em; /* 字間ぶんのずれを打ち消して中央に見せる */
  color: var(--accent-deep);
  animation: fade-up 0.4s ease both;
}
.result-label::before,
.result-label::after {
  content: "";
  width: 22px;
  height: 1px;
  background: currentColor;
  opacity: 0.45;
}

.result-card {
  margin: 0;
  width: var(--card-w-result);
  aspect-ratio: 2 / 3;
  border-radius: var(--card-radius);
  box-shadow: 0 18px 36px -16px rgba(74, 56, 110, 0.55), 0 2px 4px rgba(74, 56, 110, 0.18);
  animation: card-arrive 0.45s cubic-bezier(0.25, 0.8, 0.3, 1) both;
}
.result-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--card-radius);
}
@keyframes card-arrive {
  from { opacity: 0; transform: scale(0.82); }
  to   { opacity: 1; transform: none; }
}

.result-name {
  margin: 20px 0 0;
  display: flex;
  align-items: baseline;
  gap: 0.6em;
  font-size: 1.625rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.04em;
  animation: fade-up 0.4s 0.15s ease both;
}
.result-orient {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--accent-deep);
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom));
  translate: -50% 0;
  color: var(--accent-deep);
  opacity: 0.38;
  animation: hint-bob 2s ease-in-out infinite;
}
.scroll-hint svg { display: block; }
@keyframes hint-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(5px); }
}

/* 意味の枠：ベタ塗りではなく細い罫線と淡い面で、キーワードを先に目に入れる */
.meaning {
  margin: 0;
  padding: 14px 16px 14px;
  border: 1px solid rgba(94, 78, 152, 0.35);
  border-radius: 10px;
  background: var(--paper);
}
.meaning-title {
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-deep);
}
.meaning-keywords {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.6;
}
.meaning-keywords span { display: inline-block; } /* キーワード1語ずつで折り返す */
.meaning-summary {
  margin: 4px 0 0;
  font-size: 0.875rem;
  line-height: 1.65;
}

.message {
  margin: 28px 0 0;
  padding: 18px 18px;
  border-radius: 18px 18px 18px 6px;
  background: var(--paper-strong);
  font-size: 1rem;
  line-height: 1.95;
}

.result-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 32px 0 0;
}
.btn-share {
  width: 100%;
  max-width: 320px;
  min-height: 52px;
  border-radius: 999px;
  background: #3D3340;
  color: #fff;
  font-weight: 700;
  font-size: 0.9375rem;
}
.btn-home {
  min-height: 44px;
  padding: 0 22px;
  border-radius: 12px;
  background: transparent;
  color: var(--accent-deep);
  box-shadow: inset 0 0 0 1.5px var(--accent-deep);
  font-size: 0.875rem;
  font-weight: 500;
}

/* 他占いへの回遊タイル（正方形） */
.tiles-wrap { margin: 44px 0 0; }
/* 引く前の画面：主役（山札とボタン）の部分を「画面の高さ−64px」以上にして、
   「ほかのタロット」がどの機種でも画面の下端から少しだけのぞくようにする */
.home-main {
  --peek: calc(var(--peek-visible) + 24px); /* のぞく量＋タイルとの間の余白24px */
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-height: calc(100vh - var(--peek) - max(10px, env(safe-area-inset-top)));
  min-height: calc(100svh - var(--peek) - max(10px, env(safe-area-inset-top)));
}
.tiles-wrap-home { width: 100%; margin-top: 24px; }

/* タイルが2/3ほど見える版：見出し（約30px）＋タイル1枚の高さの2/3
   タイルの一辺＝（ページ幅−左右の余白32px−タイル間20px）÷3 */
.peek-small { --peek-visible: 64px; }
.peek-large {
  --peek-visible: calc(30px + (min(100vw, 480px) - 52px) / 3 * 2 / 3);
}
.tiles-title {
  margin: 0 0 10px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-deep);
  text-align: center;
}
.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  aspect-ratio: 1 / 1;
  padding: 8px 6px;
  border-radius: 18px;
  background: var(--tile-color, #eee);
  color: var(--ink);
  text-decoration: none;
  text-align: center;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7);
}
.tile-img {
  width: 54%;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: cover;
}
.tile-name {
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1.45;
}
.tile-soon {
  padding: 1px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink-muted);
  font-size: 0.6875rem;
  line-height: 1.6;
}
.tile.is-soon { opacity: 0.92; }

.series {
  padding: 36px 16px max(20px, env(safe-area-inset-bottom));
  text-align: center;
  color: var(--ink-muted);
}
.tagline {
  margin: 0 0 6px;
  font-size: 0.75rem;
  line-height: 1.6;
  letter-spacing: 0.04em;
}
.tagline span { display: inline-block; } /* 区切り（｜）ごとにまとめて折り返す */
.series-name {
  margin: 0;
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
}
/* シリーズ名の下に控えめに置くリンク（プライバシーポリシー） */
.footer-links {
  margin: 10px 0 0;
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
}
.footer-links a { color: inherit; text-underline-offset: 3px; }

/* プライバシーポリシーなどの文書ページ。背景は JS を使わず CSS から直接指定する */
.page-legal .bg-layer { background-image: url("../assets/site-background.webp"); }
.legal {
  margin: 32px 0 0;
  padding: 24px 20px 20px;
  border: 1px solid rgba(94, 78, 152, 0.35);
  border-radius: 12px;
  background: var(--paper-strong);
  font-size: 0.9375rem;
  line-height: 1.85;
}
.legal h1 {
  margin: 0 0 16px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent-deep);
  text-align: center;
  letter-spacing: 0.06em;
}
.legal h2 {
  margin: 24px 0 6px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-deep);
}
.legal p, .legal ul { margin: 0 0 10px; }
.legal ul { padding-left: 1.2em; }
.legal a { color: var(--accent-deep); text-underline-offset: 3px; word-break: break-all; }
.legal-date { margin-top: 20px !important; text-align: right; font-size: 0.8125rem; color: var(--ink-muted); }
.legal-back { margin: 24px 0 0; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .result-card, .result-name, .result-label { animation: none; }
  .scroll-hint { animation: none; }
}
