/* common-base-css: 単独で公開するページ(LP など)の最初に読み込む土台
   - リセット / 日本語の組版 / Safari(iOS)との差をなくす指定だけを入れる。色・フォント・余白などの見た目は入れない
   - すべて :where() で詳細度を 0 にしてあるので、後から読み込む CSS のクラス指定が必ず勝つ
   - カラーミーのテンプレート内(フリーページ・parts)では読み込まない。ショップ全体の見た目が変わるため
   規則と理由は docs/css.md */

/* ===== リセット ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

:where(html) {
    /* iOS で横向きにしたときに文字が勝手に大きくなるのを止める */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* ページ内リンクで固定ヘッダーの下に隠れないよう、ヘッダーの高さを --header-height に入れる */
    scroll-padding-top: var(--header-height, 0px);
}

:where(body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd) {
    margin: 0;
}

/* 点や番号を消すリストには role="list" を付ける。
   Safari の読み上げは list-style: none のリストをリストと扱わなくなるため、role で明示する */
:where(ul[role="list"], ol[role="list"]) {
    margin: 0;
    padding: 0;
    list-style: none;
}

:where(img, svg, video, canvas) {
    vertical-align: middle;
}

/* width / height 属性つきの画像が縦に伸びないよう height: auto */
:where(img, video) {
    max-width: 100%;
    height: auto;
}

/* フォーム部品はブラウザの既定(Safari は青い文字・独自のフォント)をやめて周りに合わせる */
:where(button, input, select, textarea) {
    font: inherit;
    color: inherit;
}

/* iOS は 16px 未満の入力欄をタップすると画面を拡大する。部品側でも 16px 未満にしない */
:where(input, select, textarea) {
    font-size: max(16px, 1em);
}

:where(button) {
    cursor: pointer;
}

/* iOS の検索欄は角丸と内側の飾りが残り、border-radius が効かない */
:where(input[type="search"]) {
    -webkit-appearance: none;
    appearance: none;
}

:where(input[type="search"])::-webkit-search-decoration {
    -webkit-appearance: none;
}

/* details の三角(Safari は ::-webkit-details-marker で出る)。開閉の印は部品側で描く */
:where(summary) {
    list-style: none;
    cursor: pointer;
}

:where(summary)::-webkit-details-marker {
    display: none;
}

/* hidden 属性は、クラスで display を指定していても必ず隠す */
[hidden] {
    display: none !important;
}

/* ===== 日本語の組版 =====
   非対応のブラウザ(Safari・Firefox の一部)では無視されるだけで崩れない */
:where(:root) {
    /* 小さい「っ」「ゃ」や長音を行頭に置かない */
    line-break: strict;
    /* 収まらない長い英数字(型番・URL)だけ途中で折る。word-break: break-all は禁則が効かなくなるので使わない */
    overflow-wrap: anywhere;
    /* 和文と英数字の間に少し空きを入れる(Chrome 140・Safari 18.4 以降。古い iOS では空きなし) */
    text-autospace: normal;
    /* 「」()などの約物が続いたときと行頭の空きを詰める */
    text-spacing-trim: trim-start;
}

:where(body) {
    /* 日本語の本文に合う行間 */
    line-height: 1.8;
}

/* 見出しは行の長さをそろえ、文節で折り返す(auto-phrase は html の lang="ja" が必要)
   本文には使わない(右端がガタつく) */
:where(h1, h2, h3, h4) {
    text-wrap: balance;
    word-break: auto-phrase;
}

/* 等幅・日付・入力中の文字は自動の空きを入れない */
:where(pre, code, time, input, textarea, [contenteditable]) {
    text-autospace: no-autospace;
}

:where(pre) {
    text-spacing-trim: space-all;
}

/* ===== 動きを減らす設定 ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== 共通の小さな部品 ===== */
/* 画面には出さず、読み上げには残す */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
