/*!
 * base.css — やまなし治療院 デモサイト
 * 内容：リセット / :root デザイントークン / 要素既定値 / ユーティリティ
 * 禁止：レイアウト・コンポーネント・セクション固有のスタイル
 */

/* =====================================================================
   1. リセット
   ===================================================================== */

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

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

ul,
ol {
  list-style: none;
}

img,
svg {
  display: block;
  max-inline-size: 100%;
}

/* =====================================================================
   2. デザイントークン
   ===================================================================== */

:root {
  /* ============ Color : Surfaces ============ */
  --color-bg:               #FAF6EF; /* 生成り（基本地） */
  --color-bg-alt:           #F3EDE3; /* 一段濃い生成り（交互セクション） */
  --color-surface:          #FFFDF9; /* カード地。生成り寄りのオフホワイト（純白は不採用） */
  --color-overlay:          rgba(42, 39, 36, .5); /* ドロワー/モーダル背景 */

  /* ============ Color : Text on light ============ */
  --color-ink:              #2A2724; /* 墨・本文/見出し */
  --color-ink-weak:         #524C45; /* リード・補助本文 */
  --color-ink-muted:        #6E675C; /* キャプション・注記・英字ラベル */

  /* ============ Color : Brand ============ */
  --color-primary:          #23445E; /* 藍鉄 */
  --color-primary-dark:     #17303F; /* 藍鉄ホバー */
  --color-primary-light:    #4A6F8A; /* UI補助（本文には使わない） */
  --color-cta:              #7E4220; /* 深灸火・塗りCTAの地色 */
  --color-cta-hover:        #663519;
  --color-accent:           #C8703C; /* 灸火色。★文字を載せない用途のみ */
  --color-accent-soft:      #E8C9B0; /* 罫・図版・藍鉄地上のリンクホバー */

  /* ============ Color : Lines & non-text ============ */
  --color-border:           #DED5C7;
  --color-border-strong:    #C3B8A6;
  --color-muted:            #8C8375; /* ★非テキスト専用（罫・図版）。文字に使わない */

  /* ============ Color : on Primary（藍鉄地の上） ============ */
  --color-on-primary:       #FAF6EF; /* 見出し・本文 */
  --color-on-primary-weak:  #D6D0C6; /* 補助テキスト */
  --color-on-primary-muted: #B8B2A8; /* 注記・著作権表記 */
  --color-on-primary-border:rgba(250, 246, 239, .24);

  /* ============ Color : Feedback ============ */
  --color-danger:           #8C2A21;
  --color-danger-bg:        #FBEFED;

  /* ============ Color : Focus ============ */
  --color-focus:            #23445E; /* 明るい地の上 */
  --color-focus-inverse:    #E8C9B0; /* 暗い地（藍鉄・CTA）の上 */

  /* ============ Typography : families ============ */
  --font-serif: "Zen Old Mincho", "Yu Mincho", YuMincho, "Hiragino Mincho ProN", serif;
  --font-sans:  "Noto Sans JP", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  --font-latin: "Cormorant Garamond", Georgia, "Times New Roman", serif;

  /* ============ Typography : sizes ============ */
  --fs-display: clamp(1.5rem, 6vw, 2.5rem); /* FVキャッチ。縦組みの実寸計算は S02 を参照 */
  --fs-h2:      clamp(1.375rem, 4.6vw, 2rem);
  --fs-h3:      clamp(1.125rem, 3vw, 1.375rem);
  --fs-h4:      clamp(1.0625rem, 2.6vw, 1.1875rem);
  --fs-lead:    clamp(1.0625rem, 2.8vw, 1.1875rem);
  --fs-body:    1.0625rem;  /* 17px。1024px以上で 1.125rem に上書き */
  --fs-small:   0.9375rem;  /* 15px */
  --fs-xs:      0.8125rem;  /* 13px */
  --fs-en:      0.75rem;    /* 12px 英字ラベル */
  --fs-en-logo: 0.5625rem;  /* 9px ロゴ英字 */
  --fs-tel:     clamp(1.5rem, 5vw, 2rem);
  --fs-num:     clamp(1.75rem, 5.5vw, 2.5rem); /* 理由・ステップの連番 */

  /* ============ Typography : rhythm ============ */
  --lh-catch: 1.15;
  --lh-tight: 1.45;
  --lh-base:  1.9;   /* 本文 */
  --ls-tight: .02em;
  --ls-base:  .04em;
  --ls-wide:  .12em;
  --ls-en:    .18em;

  /* ============ Spacing（8pxベース） ============ */
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;
  --space-10: 8rem;

  /* ============ Layout ============ */
  --container:        1120px;
  --container-narrow: 720px;
  --container-pad:    clamp(1.25rem, 5vw, 2.5rem);
  --section-py:       clamp(3.5rem, 10vw, 7rem);
  --header-h:         64px;
  --callbar-h:        64px;

  /* ============ Radius（和モダン＝控えめ） ============ */
  --radius-sm:   2px;
  --radius-md:   4px;
  --radius-lg:   8px;
  --radius-pill: 999px;

  /* ============ Shadow ============ */
  --shadow-sm: 0 1px 2px rgba(42, 39, 36, .06);
  --shadow-md: 0 4px 16px rgba(42, 39, 36, .08);
  --shadow-lg: 0 12px 32px rgba(42, 39, 36, .12);

  /* ============ z-index ============ */
  --z-header:  100;
  --z-callbar: 150;
  --z-drawer:  200;
  --z-modal:   300;

  /* ============ Motion ============ */
  --ease:      cubic-bezier(.22, .61, .36, 1);
  --ease-out:  cubic-bezier(.16, 1, .3, 1);
  --dur-fast:  .2s;
  --dur-base:  .45s;
  --dur-slow:  .8s;
}

@media (min-width: 1024px) {
  :root {
    --fs-body:  1.125rem; /* 18px */
    --header-h: 88px;
  }
}

/* =====================================================================
   3. 要素既定値
   （ul,ol の margin/padding/list-style は 1.リセット で既に0/noneに統一済み）
   ===================================================================== */

body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: var(--lh-base);
  color: var(--color-ink);
  background: var(--color-bg);
  /* 日本語の禁則処理。未指定だと「マ/ッサージ」のように語中で改行される */
  line-break: strict;
  word-break: normal;
  /* 文節の途中で折り返さないようにする。未対応ブラウザでは宣言が破棄され、
     直前の normal が残るだけなので副作用はない。確実に切りたくない語句は
     個別に .nowrap で囲う。 */
  word-break: auto-phrase;
  /* overflow-wrap は anywhere ではなく break-word を使う。
     anywhere は「はみ出す前」でも要素の min-content 幅を1文字まで縮めてよいと
     許可してしまうため、flex 内のロゴ等が異常に圧縮されて折り返し・高さ破綻を起こす
     （実測：1024pxでヘッダーロゴが91.9pxまで潰れ高さ123.5pxに膨張、88pxヘッダーから
     上下17.7pxずつ溢れる）。break-word は「実際にはみ出す場合のみ」折り返すため
     min-content 幅に影響しない。今後 anywhere に戻さないこと。 */
  overflow-wrap: break-word;
  /* 和文の約物（句読点・括弧等）の前後アキを詰め、行長の実効文字数を稼ぐ。
     対応ブラウザのみ効く漸進的強化で、非対応環境への副作用はない */
  text-spacing-trim: trim-start;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: var(--lh-tight);
  color: var(--color-ink);
}

h1,
h2,
h3,
h4 {
  /* 見出しは balance で孤立語を減らす */
  text-wrap: balance;
}

p {
  line-height: var(--lh-base);
}

p,
li,
dd {
  /* 本文は pretty で孤立行を減らす */
  text-wrap: pretty;
}

/* 400 しか読み込んでいないため、既定で700になる strong/b をリセットする。
   放置すると明朝の偽ボールド（合成太字）で輪郭が潰れる */
strong,
b,
em {
  font-weight: 400;
  font-style: normal;
}

/* リンクの既定色と下線は :where() で詳細度 0 にしてある。
   .btn--cta のように自分で色を持つ部品が a:hover に負けて
   地色に沈むのを防ぐため（詳細度 0,1,1 が 0,1,0 に勝っていた）。
   詳細度が 0 でも、あとに書いた :where(a:hover) が :where(a) に勝つので
   クラスを持たないリンクのホバーはこれまでどおり効く。 */
:where(a) {
  color: var(--color-primary);
  text-decoration: underline;
}

:where(a:hover) {
  color: var(--color-primary-dark);
}

/* キーボード操作の目印。:where() で詳細度 0 にしてあるので、部品側が
   独自の :focus-visible を持つ場合はそちらが勝つ。これが無いと、個別指定の
   無いリンク（ヘッダーの電話番号・本文中のリンク・アクセス欄の電話）が
   ブラウザ既定の細い枠のままになる。 */
:where(a, button, summary, select, [tabindex]):focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* 暗い地のセクションの上では淡い枠に入れ替える（濃い枠が地に沈むため）。 */
:where(.s-visit, .site-footer, .callbar) :where(a, button, summary, [tabindex]):focus-visible {
  outline-color: var(--color-focus-inverse);
}

img {
  block-size: auto;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
  inline-size: 100%;
}

input,
select,
textarea,
button {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
  text-align: inherit;
}

/* =====================================================================
   4. 共通ブロック（視覚的非表示・スキップリンク・スクロール制御）
   ===================================================================== */

/* ---- 視覚的に隠す（スクリーンリーダーには読ませる） ---- */
.visually-hidden {
  position: absolute;
  inline-size: 1px; block-size: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---- スキップリンク ---- */
.skip-link {
  position: absolute;
  inset-block-start: 0; inset-inline-start: 0;
  z-index: var(--z-modal);
  padding: var(--space-3) var(--space-4);
  background: var(--color-primary);
  color: var(--color-on-primary);
  transform: translateY(-110%);
  transition: transform var(--dur-fast) var(--ease);
}
.skip-link:focus-visible { transform: translateY(0); }

/* ---- 背面スクロールロック ---- */
/* main.js が inset-block-start に -<scrollY>px をインラインで与える。
   overflow:hidden だけでは iOS Safari で止まらないため position:fixed 方式で固定する。 */
body.is-locked {
  position: fixed;
  inset-inline: 0;
  inline-size: 100%;
  overflow: hidden;
}

/* 追従電話バーはフッターに差しかかる手前で非表示になる（main.js）ため、
   フッター末尾を守るための下余白は不要。余白を残すとバーが消えたときに
   空の帯として見えてしまう。 */

/* ---- スムーススクロール（reduced-motion では auto に戻す） ---- */
html { scroll-behavior: smooth; }

/* =====================================================================
   5. prefers-reduced-motion（!important を使うのはこの箇所のみ）
   ===================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  [data-reveal] { opacity: 1 !important; transform: none !important; }
}

/* =====================================================================
   6. reveal 初期状態（.js-enabled ゲート付き）
   ===================================================================== */

/* JSが動いているときだけ初期状態を隠す。JSが落ちたら本文は最初から見える */
.js-enabled [data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
}
.js-enabled [data-reveal].is-revealed {
  opacity: 1;
  transform: none;
}
.js-enabled [data-reveal-delay="1"] { transition-delay: 80ms; }
.js-enabled [data-reveal-delay="2"] { transition-delay: 160ms; }
.js-enabled [data-reveal-delay="3"] { transition-delay: 240ms; }

/* =====================================================================
   7. 数字のライニング化（Cormorant Garamond 対策）
   ===================================================================== */

/* Cormorant Garamond の既定はオールドスタイル数字。
   「01」が「OI」に見えるため、欧文フォントを使う箇所は必ずライニング数字にする */
[class*="__num"],
[class*="__tel"],
[class*="-num"],
.btn__main {
  font-variant-numeric: lining-nums tabular-nums;
}

/* =====================================================================
   8. ユーティリティ
   ===================================================================== */

/* 語中改行を禁止する箇所（電話番号・駅名・住所・「マッサージ」等） */
.nowrap {
  white-space: nowrap;
}

/* <strong> の置き換え（<em class="mark">）。
   ウェイト400しか読み込んでいないため太字にできないので、
   色（--color-primary）と下線あしらいで強調を表現する */
/* 強調。400ウェイトしか読み込んでいないため太字にできない。
   --color-accent-soft の太い下線バーでは背景との輝度比が 1.45:1 と
   ほぼ不可視になるため、線を細くして色を --color-accent に上げ、
   「バー」ではなく「線」として明確に見せる（非テキスト基準 3:1 に対し 3.34:1）。 */
.mark {
  color: var(--color-primary);
  /* 線は細くする。太いバーは強調としての主張が強すぎた。
     色は --color-accent のまま（淡くすると非テキスト基準3:1を割るため）。 */
  box-shadow: inset 0 -.08em 0 var(--color-accent);
}

/* 孤立行対策の追補。
   text-wrap: pretty は分かち書きのある言語向けで、日本語ではほとんど効かない。
   一方 balance は行長を均すため、6行以下の短いテキストでは日本語でも有効に働く。
   孤立行が目立つ箇所（FV補足・お悩み項目・FAQ設問・セクションリード）に
   限定して適用する。本文の長い段落には使わない（balanceは
   行数上限があり、長文では効かないうえ再計算コストが高いため）。 */
.section-head__lead,
.s-hero__sub-access,
.faq__q-text,
.s-worry__item {
  text-wrap: balance;
}

/* .s-hero__sub-main は balance の対象から外している。
   balance を効かせると「ソフトな刺激 / の、はり・きゅう・マッサージ。」と
   助詞「の、」の直前で割れ、自然な改行（「ソフトな刺激の、/ はり…」）より悪化したため。
   短文では balance が必ずしも良い結果を出すとは限らない。 */
