/* =========================================================
   チュートリアルページ（tutorial-page.php 専用）
   クラス名はすべて tp- から始まり、テーマのCSSと衝突しにくくしています。
   色やサイズは下の :root の変数を変えるだけで調整できます。
   ========================================================= */
:root {
  --tp-ink: #444;          /* 文字色 */
  --tp-ink-sub: #5a6375;      /* 補足の文字色 */
  --tp-paper: #ffffff;        /* カードの背景 */
  --tp-backdrop: #ffdce4;     /* ポップアップの外側 */
  --tp-line: #e3e7ee;         /* 区切り線 */
  --tp-accent: #f7567c;       /* メインカラー（ボタンなど） */
  --tp-accent-ink: #ffffff;   /* メインカラー上の文字 */
  --tp-accent-soft: #8ea7c4;  /* メインカラーの薄い背景 */
  --tp-warn: #9a4a07;         /* 注意ボックスの文字 */
  --tp-warn-soft: #fbf0e3;    /* 注意ボックスの背景 */
  --tp-ph: #eef1f5;           /* 仮画像の背景 */
  --tp-ph-ink: #8a93a3;       /* 仮画像の文字 */

  --tp-font: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  --tp-slide-w: 86%;          /* スライドの幅（左右に前後のスライドが少し見える） */
  --tp-gap: 12px;             /* スライド同士の間隔 */
  --tp-radius: 20px;
}

/* ---------- ダークモード（不要ならこのブロックごと削除してOK） ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tp-ink: #e8ebf1; --tp-ink-sub: #a3abba; --tp-paper: #1d222c; --tp-backdrop: #11141a;
    --tp-line: #2e3542; --tp-accent: #4fb89c; --tp-accent-ink: #0d1a16; --tp-accent-soft: #1d3530;
    --tp-warn: #f0b77a; --tp-warn-soft: #362818; --tp-ph: #262c37; --tp-ph-ink: #7f889a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --tp-ink: #e8ebf1; --tp-ink-sub: #a3abba; --tp-paper: #1d222c; --tp-backdrop: #11141a;
  --tp-line: #2e3542; --tp-accent: #4fb89c; --tp-accent-ink: #0d1a16; --tp-accent-soft: #1d3530;
  --tp-warn: #f0b77a; --tp-warn-soft: #362818; --tp-ph: #262c37; --tp-ph-ink: #7f889a;
  color-scheme: dark;
}

/* ---------- ページ全体 ---------- */
html.tp-html, body.tp-body { height: 100%; margin: 0; }
body.tp-body { background: var(--tp-backdrop); overflow: hidden; }

.tp, .tp *, .tp *::before, .tp *::after { box-sizing: border-box; }

.tp {
  position: fixed; inset: 0; z-index: 9999;
  display: grid; place-items: center;
  padding: max(8px, env(safe-area-inset-top, 0px)) max(8px, env(safe-area-inset-right, 0px))
           max(8px, env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  background: var(--tp-backdrop);
  font-family: var(--tp-font); color: var(--tp-ink);
  font-size: 16px; line-height: 1.8; letter-spacing: .02em;
  -webkit-text-size-adjust: 100%;
}

/* ポップアップ本体 */
.tp-dialog {
  width: min(100%, 760px);
  height: min(100%, 880px);
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--tp-paper) 55%, var(--tp-backdrop));
  border-radius: 28px;
  box-shadow: 0 30px 80px -30px rgba(20, 28, 45, .45);
  overflow: hidden;
  animation: tp-open .45s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes tp-open { from { opacity: 0; transform: translateY(16px) scale(.98); } }

/* ---------- ヘッダー（タイトル・進捗・スキップ） ---------- */
.tp-header {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  padding: 16px 20px 10px;
}
.tp-heading { margin: 0; font-size: 15px; font-weight: 700; line-height: 1.4; }
.tp-counter { grid-column: 1; grid-row: 2; font-size: 12px; color: var(--tp-ink-sub); font-variant-numeric: tabular-nums; }
.tp-skip {
  grid-column: 2; grid-row: 1 / span 2;
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--tp-line); background: var(--tp-paper);
  color: var(--tp-ink-sub); font-size: 14px; font-weight: 700; text-decoration: none;
  transition: opacity .25s, visibility .25s;
}
.tp-skip:hover { color: var(--tp-ink); }
.tp.is-last .tp-skip { opacity: 0; visibility: hidden; }

.tp-progress { grid-column: 1 / -1; height: 3px; border-radius: 3px; background: var(--tp-line); overflow: hidden; margin-top: 8px; }
.tp-progress span { display: block; height: 100%; width: 0; background: var(--tp-accent); transition: width .4s cubic-bezier(.2, .8, .2, 1); }

/* ---------- スライドの並び（フリック部分） ---------- */
/* ★変更：スクロールではなく transform で動かす方式にしたため、
   .tp-track は「窓」、JSが自動で作る .tp-rail が中で左右に動く「レール」になります */
.tp-track {
  position: relative; flex: 1; min-height: 0;
  display: flex;
  overflow: hidden;
  padding: 6px 0 10px;
  cursor: grab;
  touch-action: pan-y;          /* 縦はブラウザ、横の操作はスクリプトで処理 */
}
.tp-track.is-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; }
.tp-track.is-dragging .tp-slide { transition: none; }   /* ドラッグ中は指にそのまま追従 */
.tp-track:focus-visible { outline: 3px solid var(--tp-accent); outline-offset: -3px; }

.tp-rail {
  position: relative; flex: 0 0 100%; width: 100%; min-width: 0;
  display: flex; gap: var(--tp-gap); align-items: stretch;
  will-change: transform;
  backface-visibility: hidden;
}
/* 指を離したあと次のカードへ移動するときの動き（時間と加速の具合はここで調整） */
.tp-rail.is-animating { transition: transform .45s cubic-bezier(.22, .8, .24, 1); }

/* ---------- 1枚のスライド（=カード） ---------- */
.tp-slide {
  flex: 0 0 var(--tp-slide-w);
  display: flex; flex-direction: column; gap: 18px;
  padding: 28px 24px 32px;
  background: var(--tp-paper);
  border-radius: var(--tp-radius);
  overflow-y: auto;
  touch-action: pan-y;          /* ★修正：縦スクロールはブラウザ、横はスクリプト（overscroll-behavior は削除） */
  transform: scale(.94); opacity: .5;
  transition: transform .45s cubic-bezier(.22, .8, .24, 1), opacity .45s;  /* ★変更：レールと同じ動きに統一 */
}
.tp-slide.is-active { transform: none; opacity: 1; }

/* スライド内の基本要素（ブロックエディタの見出し・段落・画像にも効きます） */
.tp-slide > *, .tp-body > *, .tp-text > *, .tp-slide li { margin: 0; }
.tp-slide h2, .tp-title {
  font-size: clamp(21px, 5.2vw, 27px); line-height: 1.45; font-weight: 700; letter-spacing: .03em;
  text-wrap: balance;color: var(--tp-ink);
}
.tp-slide h3 { font-size: 17px; line-height: 1.5; font-weight: 700; }
.tp-slide p { max-width: 36em; }
.tp-lead { font-size: 17px; color: var(--tp-ink); }
.tp-sub, .tp-slide small { font-size: 13px; color: var(--tp-ink-sub); }
.tp-slide img { display: block; max-width: 100%; height: auto; border-radius: 14px; }
.tp-slide a:not([class]) { color: var(--tp-accent); }

/* 画像エリア */
.tp-media { border-radius: 14px; overflow: hidden; flex-shrink: 0; }
.tp-media img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }

/* 仮画像（本番では <img src="..." alt="..."> に差し替え） */
.tp-ph {
  display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 10;
  /**
    background:
    repeating-linear-gradient(135deg, transparent 0 14px, color-mix(in srgb, var(--tp-ph-ink) 10%, transparent) 14px 15px),
    var(--tp-ph);**/
  color: var(--tp-ph-ink); font-size: 13px; font-weight: 700; text-align: center; padding: 12px;
}
.tp-ph::before { content: attr(data-label); }
.tp-ph--square { aspect-ratio: 1 / 1; }
.tp-ph--tall { aspect-ratio: 3 / 4; }

/* チェック付きリスト */
.tp-list { list-style: none; padding: 0; display: grid; gap: 12px; }
.tp-list li { position: relative; padding-left: 30px; }
.tp-list li::before {
  content: ""; position: absolute; left: 0; top: .35em; width: 20px; height: 20px; border-radius: 50%;
  background: var(--tp-accent-soft)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 10.5l3 3 6-7' fill='none' stroke='%231f6f5c' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat;
}

/* 手順（順番に意味があるときだけ使う） */
.tp-steps { list-style: none; padding: 0; display: grid; gap: 14px; counter-reset: tp-step; }
.tp-steps li { counter-increment: tp-step; display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; }
.tp-steps li::before {
  content: counter(tp-step); display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--tp-accent); color: var(--tp-accent-ink); font-size: 14px; font-weight: 700; line-height: 1;
}

/* 注意ボックス */
.tp-note { padding: 16px 18px; border-radius: 14px; background: var(--tp-warn-soft); color: var(--tp-warn); font-size: 15px; }
.tp-note strong { display: block; margin-bottom: 4px; }

/* 補足ボックス（通常） */
.tp-box { padding: 16px 18px; border-radius: 14px; background: var(--tp-accent-soft); font-size: 15px;color: white; }

/* 文章の羅列用（長文） */
.tp-text { display: grid; gap: 1em; }
.tp-text p { margin: 0; }

/* ---------- レイアウトのバリエーション ---------- */
/* 上下中央に寄せる（短い内容向け） */
.tp-slide--center { justify-content: center; text-align: center; align-items: center; }
.tp-slide--center p { margin-inline: auto; }
/* 画像のみ（カード全面） */
.tp-slide.tp-slide--image { padding: 0; gap: 0; position: relative; }
.tp-slide--image .tp-media, .tp-slide--image .tp-ph { flex: 1; height: 100%; aspect-ratio: auto; border-radius: 0; }
.tp-slide--image .tp-caption {
  position: absolute; left: 16px; right: 16px; bottom: 16px; padding: 12px 16px; border-radius: 12px;
  background: var(--tp-accent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 14px; line-height: 1.6;margin: auto;color:white;opacity: 0.85;
}
/* 広い画面では画像と文章を左右に並べる */
@media (min-width: 720px) {
  .tp-slide.tp-slide--split { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 28px; padding: 36px; }
  .tp-slide--split .tp-ph { aspect-ratio: 4 / 5; }
  .tp-slide--split > .tp-body { display: flex; flex-direction: column; gap: 16px; }
}
.tp-slide--split > .tp-body { display: flex; flex-direction: column; gap: 16px; }

/* ---------- ボタン ---------- */
.tp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 28px; border-radius: 999px; border: 0;
  font: inherit; font-size: 16px; font-weight: 700; text-decoration: none; cursor: pointer;
  background: var(--tp-accent); color: var(--tp-accent-ink);
  transition: transform .15s, filter .15s;
}
.tp-btn:hover { filter: brightness(1.08); }
.tp-btn:active { transform: scale(.97); }
.tp-btn--wide { width: 100%; max-width: 360px; }
.tp-start { margin-top: 8px; }

/* ---------- フッター（戻る・ドット・次へ） ---------- */
.tp-footer {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: 6px 20px 18px;
}
.tp-nav {
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--tp-line);
  background: var(--tp-paper); color: var(--tp-ink); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  transition: opacity .2s, visibility .2s;
}
.tp-prev { justify-self: start; }
.tp-next { justify-self: end; background: var(--tp-ink); color: var(--tp-paper); border-color: var(--tp-ink); }
.tp-nav[disabled] { opacity: 0; visibility: hidden; }

.tp-dots { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; max-width: 46vw; }
.tp-dot {
  width: 8px; height: 8px; padding: 0; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--tp-line); transition: width .3s, background .3s;
}
.tp-dot[aria-current="true"] { width: 22px; background: var(--tp-accent); }
.tp-dots.is-many { display: none; } /* 枚数が多い時はドットを隠し、上の進捗バーで表示 */

/* フォーカスの見え方 */
.tp a:focus-visible, .tp button:focus-visible { outline: 3px solid var(--tp-accent); outline-offset: 3px; }

/* ---------- 画面サイズ別 ---------- */
@media (max-width: 480px) {
  .tp { padding: max(0px, env(safe-area-inset-top, 0px)) 0 0; }
  .tp-dialog { border-radius: 22px 22px 0 0; height: 100%; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .tp-slide { padding: 24px 20px 28px; }
  :root { --tp-slide-w: 88%; --tp-gap: 10px; }
}
@media (min-width: 900px) {
  :root { --tp-slide-w: 80%; --tp-gap: 20px; }
  .tp-slide { padding: 40px 44px 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .tp-dialog, .tp-slide, .tp-rail, .tp-rail.is-animating, .tp-progress span, .tp-dot { animation: none; transition: none; }
}

/* 画像のみスライドで <img> を直接置いた場合 */
.tp-slide--image > img, .tp-slide--image .tp-media img { flex: 1; width: 100%; height: 100%; min-height: 0; object-fit: cover; border-radius: 0; }