/*
 * 検索まわりの共通の見た目（2026-11-06）
 *
 * 新しい検索（z-search/nkproduct-search.php）の検索窓・Filter by Keyword と同じ見た目にする。
 * 値は nkproduct-search.php の <style> からそのまま写したもの（独自の値を足さない）。
 *
 * 使っている場所
 * 1. ページ内の検索（外側に .kec-search-ui を付ける）
 *    サイト全体検索 z-search/siteall-wpmlfix.php・取扱説明書 torisetu-wpmlfix.php・2D CAD cad-wpmlfix.php・
 *    FAQ faq-wpmlfix.php / faq-wpmlfix-en.php
 * 2. ヘッダーの検索窓（.search-form。新ヘッダー header-new-*.php と旧ヘッダー header-*.php の両方）
 * 3. ヘッダーの検索窓の下に出る上位5件（js/kec-site-search.js が作る .kec-search-preview）
 *
 * 注意
 * - css/zsearch-page-for.css（ページ本文の中で後から読み込まれる）・css/redstone.css・旧ヘッダーの <style> に
 *   同じ要素への古い指定があるため、上書きが必要なところは .kec-search-ui / .search-form を前に付けて
 *   詳細度を上げ、古い指定が !important のところは !important を付けている。
 * - 3. はJSで作る要素なので、LiteSpeed の UCSS（未使用CSSの削除）から外している（inc/kec-site-search.php）。
 */

/* ============================================================
   1. ページ内の検索
   ============================================================ */

/* .sfiltering.sanctuary と同じ（zsearch-page-for.css と redstone.css の .sfiltering が幅を奪い合うのを止める） */
.kec-search-ui .sfiltering {
    width: 100% !important;
    max-width: 1200px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

.kec-search-ui div#InputFilter {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 4rem 0 !important;
}

/* FAQ の「形名やキーワードを入力してください」の説明文。検索窓の上に1行で出す */
.kec-search-ui div#InputFilter > .kec-search-note {
    flex: 1 1 100%;
    max-width: 720px;
    margin: 0 auto !important;
    padding: 0 !important;
    font-size: .85rem;
    color: #555;
    text-align: left;
}

.kec-search-ui .nk-search-bar,
.search-form .nk-search-bar {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex: 0 1 auto;
    width: 100%;
    max-width: 720px;
    background: #fff;
    border-radius: 999px;
    padding: .3rem .3rem .3rem 1.25rem;
    border: 2px solid transparent;
    box-shadow: 0 4px 18px rgba(23, 79, 158, .15);
    transition: border-color .2s ease, box-shadow .2s ease;
    box-sizing: border-box;
}

.kec-search-ui .nk-search-bar:hover,
.kec-search-ui .nk-search-bar:focus-within,
.search-form .nk-search-bar:hover,
.search-form .nk-search-bar:focus-within {
    border-color: #174f9e;
    box-shadow: 0 4px 22px rgba(23, 79, 158, .28);
}

.kec-search-ui .nk-search-icon,
.search-form .nk-search-icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-top: 1px; /* 虫眼鏡アイコンは円が左上寄りの視覚重心なので下に微調整 */
    color: #999;
}

.kec-search-ui .nk-search-icon svg,
.search-form .nk-search-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

/* zsearch-page-for.css・FAQ の input#searchInput（大きい太字・大文字・枠線）を打ち消す */
.kec-search-ui input#searchInput,
.search-form input#headerSearchInput {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    padding: .4rem 0 !important;
    width: auto !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    outline: none !important;
    background: none !important;
    box-shadow: none !important;
    font-size: 1rem !important;
    line-height: 1.4 !important;
    text-transform: none !important;
    font-family: inherit !important;
    font-weight: 400 !important;
    letter-spacing: normal !important;
    color: #333 !important;
    text-indent: .5rem !important;
}

.kec-search-ui .sfiltering a.kensakubotw.nk-search-btn,
.search-form a.kensakubot.nk-search-btn {
    flex: 0 0 auto;
    color: #fff !important;
    background: #174f9e !important;
    padding: .5rem 1.5rem !important;
    display: inline-block;
    text-align: center !important;
    font-size: .85rem !important;
    font-weight: 700 !important;
    transition: box-shadow .3s ease !important;
    margin: 0 5px !important;
    white-space: nowrap !important;
    line-height: 1.2;
    border: none;
    min-width: auto;
    text-decoration: none;
    letter-spacing: 0.005rem;
    border-radius: 999px;
}

.kec-search-ui .sfiltering a.kensakubotw.nk-search-btn:hover,
.search-form a.kensakubot.nk-search-btn:hover {
    box-shadow: 0 0 0 4px rgba(23, 79, 158, .25) !important;
}

.kec-search-ui .sfiltering a.allclear.nk-reset-link,
.search-form a.allclear.nk-reset-link {
    color: #174f9e !important;
    border: none;
    background: none;
    padding: 0 !important;
    text-align: center !important;
    font-size: .85rem !important;
    font-weight: normal !important;
    transition: .3s color !important;
    margin: 0 !important;
    white-space: nowrap !important;
    line-height: 1.2;
    border-radius: 0;
    text-decoration: underline;
}

.kec-search-ui .sfiltering a.allclear.nk-reset-link:hover,
.search-form a.allclear.nk-reset-link:hover {
    color: #0d356e !important;
}

.kec-search-ui div#categoryFilter {
    border-radius: 1rem;
    padding: .25rem 1.5rem .25rem !important;
    margin: 1rem 0 !important;
}

/* 見出し（▸ Filter by Keyword）。開閉できる */
.kec-search-ui .cat-details {
    margin-top: 0;
    padding-top: 1rem;
    border-top: none;
}

.kec-search-ui .cat-heading {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin-bottom: 0.75rem;
    padding: 0;
    border: none;
    font-size: .9rem;
    font-weight: bold;
    color: #666;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.kec-search-ui .cat-details[open] > .cat-heading {
    font-weight: 700;
}

.kec-search-ui .cat-heading:hover {
    color: #174f9e;
}

.kec-search-ui .cat-heading::-webkit-details-marker {
    display: none;
}

.kec-search-ui .cat-heading::before {
    content: "";
    display: inline-block;
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    background-color: currentColor;
    -webkit-mask: url(../img/SVG/harrow.svg) center/contain no-repeat;
    mask: url(../img/SVG/harrow.svg) center/contain no-repeat;
    transition: transform .2s;
}

.kec-search-ui .cat-details[open] > .cat-heading::before {
    transform: rotate(90deg);
}

.kec-search-ui .cat-heading::after {
    content: "";
    flex: 1 1 auto;
    border-bottom: 1px #eee solid;
    margin-left: .5rem;
}

.kec-search-ui .cat-details .kec-filter-list {
    margin-top: 0.5rem;
}

/* 絞り込みの選択肢（#tags2 label と同じ：▸ 文字 ＋ 点線の下線。選ぶと赤い × と太字） */
.kec-search-ui .kec-filter-list input[type="checkbox"],
.kec-search-ui .kec-filter-list input[type="radio"],
.search-form #vvcategoryFilter input[type="checkbox"] {
    display: none !important;
}

.kec-search-ui .kec-filter-list label,
.kec-search-ui .kec-filter-list a.rankten,
.search-form #vvcategoryFilter label {
    display: inline-block !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    background: none !important;
    color: #666 !important;
    cursor: pointer !important;
    margin: .5rem 1.5rem .5rem 0 !important;
    font-size: .9rem !important;
    font-weight: normal !important;
    line-height: 1.5 !important;
    text-decoration: none !important;
    transition: none !important;
}

.kec-search-ui .kec-filter-list label::after,
.kec-search-ui .kec-filter-list a.rankten::after,
.search-form #vvcategoryFilter label::after {
    content: "";
    display: block;
    height: 2px;
    width: calc(100% - 1rem);
    border-bottom: 1px dashed #222;
    margin-left: 1rem;
}

.kec-search-ui .kec-filter-list label:hover,
.kec-search-ui .kec-filter-list a.rankten:hover,
.search-form #vvcategoryFilter label:hover {
    background: none !important;
    color: #174f9e !important;
}

.kec-search-ui .kec-filter-list label::before,
.kec-search-ui .kec-filter-list a.rankten::before,
.search-form #vvcategoryFilter label::before {
    content: "" !important;
    display: inline-block !important;
    flex: 0 0 auto !important;
    width: 8px !important;
    height: 8px !important;
    margin-right: .4rem !important;
    background-color: currentColor !important;
    -webkit-mask: url(../img/SVG/harrow.svg) center/contain no-repeat !important;
    mask: url(../img/SVG/harrow.svg) center/contain no-repeat !important;
    font-family: initial !important;
    font-size: 0 !important;
    top: 0 !important;
    position: relative !important;
    color: inherit !important;
    transition: none !important;
}

.kec-search-ui .kec-filter-list label:hover::before,
.kec-search-ui .kec-filter-list a.rankten:hover::before,
.search-form #vvcategoryFilter label:hover::before {
    color: #174f9e !important;
}

.kec-search-ui .kec-filter-list label:has(input:checked),
.search-form #vvcategoryFilter label:has(input:checked) {
    background: none !important;
    border: none !important;
    color: #666 !important;
    font-weight: bold !important;
}

.kec-search-ui .kec-filter-list label:has(input:checked)::before,
.search-form #vvcategoryFilter label:has(input:checked)::before {
    /* 選択中は > から赤い × に変える。8pxのままだと×は小さすぎて見えないため、ひとまわり大きくする */
    color: crimson !important;
    width: 12px !important;
    height: 12px !important;
    margin-right: .5rem !important;
    -webkit-mask: url(../img/SVG/close-x.svg) center/contain no-repeat !important;
    mask: url(../img/SVG/close-x.svg) center/contain no-repeat !important;
}

.kec-search-ui .kec-filter-list label:has(input:checked)::after,
.search-form #vvcategoryFilter label:has(input:checked)::after {
    border-bottom: 1px solid red !important;
}

/* 2段目の絞り込み（FAQ の「さらに絞り込む」） */
.kec-search-ui .kec-filter-sub {
    margin-top: .25rem;
}

/* 画面上部に固定で出ていた選択中の条件のバー。新しい検索と同じく出さない（JSが参照するのでDOMは残す） */
.kec-search-ui .selected-categories {
    display: none !important;
}

/* 結果の件数 */
.kec-search-ui .sresults,
.kec-search-ui p.sresults {
    font-size: 10px;
    opacity: .7;
    text-align: right;
}

/* ページ送り（#pagination a.page-link と同じ。FAQ は a に .page-link が無く、今のページは span.current） */
.kec-search-ui .pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 2rem 0;
    text-align: center;
}

.kec-search-ui .pagination a {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    border: 1px solid #174f9e;
    border-radius: 5px;
    text-decoration: none;
    color: #174f9e;
    font-size: 0.85rem;
    font-weight: bold;
    transition: background-color 0.3s, color 0.3s;
}

.kec-search-ui .pagination a:hover {
    background-color: #174f9e;
    color: #fff;
}

.kec-search-ui .pagination span.current,
.kec-search-ui .pagination span.current-page {
    display: inline-block;
    padding: 0.5rem 1rem;
    background-color: #174f9e;
    color: #fff;
    border-radius: 5px;
    font-size: 0.9rem;
}

@media screen and (max-width: 768px) {
    .kec-search-ui div#InputFilter {
        margin: 2.5rem 0 !important;
    }
    .kec-search-ui div#categoryFilter {
        padding: .25rem 0.5rem .25rem !important;
    }
    .kec-search-ui .nk-search-bar,
    .search-form .nk-search-bar {
        max-width: 100%;
        padding-left: 1rem;
    }
    .kec-search-ui .kec-filter-list label,
    .kec-search-ui .kec-filter-list a.rankten {
        margin: 0.5rem 1rem .5rem 0 !important;
        font-size: 0.65rem !important;
    }
    .kec-search-ui .pagination a {
        padding: 0.4rem 1rem;
        font-size: 0.75rem;
    }
}

/* ============================================================
   2. ヘッダーの検索窓
   ============================================================ */

.search-form .header-search-field {
    display: flex;
    justify-content: center;
    padding: 0 !important;
    margin: .5rem 0 1rem;
}

/* 旧ヘッダーには redstone.css の .sfiltering（幅1200px・中央寄せ）が無いので、同じ値をここで持つ */
.search-form .sfiltering {
    width: min(calc(100vw - 32px), 1200px) !important;
    max-width: none !important;
    margin: 0 auto !important;
    box-sizing: border-box;
}

.search-form:not(#headerSearchForm) .sfiltering {
    padding: 1.25rem 0 1.5rem !important;
    border: none !important;
}

.search-form #vvcategoryFilter {
    padding: 0 1rem;
}

/* 検索バー（中央寄せ）に合わせて、種類の選択肢とリセットも中央に並べる。
   選択肢は右側にだけ余白（margin-right 1.5rem）があるので、その分を左にも足して見た目の中心を合わせる */
.search-form #vvcategoryList {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding-left: 1.5rem;
}

/* 2026-11-06 ヘッダーではページの種類で絞り込まなくてよいかもしれないので、いったん隠して様子を見る。
   戻すときはこのルールを消すだけ（HTML・JSはそのまま。隠している間はチェックが付かないので、全種類から検索する） */
.search-form #vvcategoryList {
    display: none !important;
}

.search-form .sibobot {
    margin: .5rem auto 0 !important;
    max-width: none !important;
    text-align: center;
}

/* リセットは条件があるときだけ（.is-visible は redstone.js・旧ヘッダーのJSが付け外しする） */
.search-form a.allclear.nk-reset-link {
    display: none !important;
}

.search-form a.allclear.nk-reset-link.is-visible {
    display: inline-block !important;
}

@media (max-width: 768px) {
    .search-form #vvcategoryFilter {
        padding: 0;
    }
    .search-form #vvcategoryFilter label {
        margin: .4rem 1rem .4rem 0 !important;
        font-size: .75rem !important;
    }
    .search-form #vvcategoryList {
        padding-left: 1rem;
    }
    .search-form a.kensakubot.nk-search-btn {
        padding: .5rem 1rem !important;
    }
}

/* ============================================================
   3. ヘッダーの検索窓の下に出る上位5件
   ============================================================ */

.kec-search-preview {
    margin: 1rem 0 0;
    padding: 0 1rem;
}

.kec-search-preview[hidden] {
    display: none !important;
}

.kec-search-preview-heading {
    display: flex;
    align-items: center;
    gap: .4rem;
    margin: 0 0 .25rem;
    font-size: .9rem;
    font-weight: bold;
    color: #666;
}

.kec-search-preview-heading::after {
    content: "";
    flex: 1 1 auto;
    border-bottom: 1px #eee solid;
    margin-left: .5rem;
}

.kec-search-preview-list {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.kec-search-preview-list li {
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
}

.kec-search-preview-list li::before,
.kec-search-preview-list li::marker {
    content: none !important;
}

.kec-search-preview-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .6rem .75rem;
    border-bottom: 1px dashed #ddd;
    border-radius: 8px;
    color: #333 !important;
    text-decoration: none !important;
    transition: background-color .2s;
}

.kec-search-preview-item:hover,
.kec-search-preview-item.is-active {
    background-color: #f3f6fb;
}

.kec-search-preview-item:focus-visible {
    outline: 2px solid #174f9e;
    outline-offset: -2px;
}

.kec-search-preview-thumb {
    flex: 0 0 64px;
    width: 64px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kec-search-preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    margin: 0 !important;
}

.kec-search-preview-thumb.is-icon img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.kec-search-preview-body {
    flex: 1 1 auto;
    min-width: 0;
}

.kec-search-preview-title {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: .9rem;
    font-weight: bold;
    line-height: 1.4;
    color: #333;
}

.kec-search-preview-item:hover .kec-search-preview-title,
.kec-search-preview-item.is-active .kec-search-preview-title {
    color: #174f9e;
}

.kec-search-preview-type {
    display: block;
    font-size: 11px;
    line-height: 1.4;
    color: #888;
}

.kec-search-preview-message {
    margin: .75rem 0 !important;
    font-size: .85rem;
    color: #666;
}

.kec-search-preview-more {
    margin: .75rem 0 0 !important;
    text-align: right;
}

.kec-search-preview-more a {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    color: #174f9e !important;
    font-size: .85rem;
    font-weight: bold;
    text-decoration: underline !important;
}

.kec-search-preview-more a::after {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: currentColor;
    -webkit-mask: url(../img/SVG/harrow.svg) center/contain no-repeat;
    mask: url(../img/SVG/harrow.svg) center/contain no-repeat;
}

.kec-search-preview-more a:hover {
    color: #0d356e !important;
}

/* 読み込み中（サイト全体検索のスケルトンと同じ色・動き） */
.kec-search-preview-skeleton {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .6rem .75rem;
}

.kec-search-preview-skeleton .sk-thumb,
.kec-search-preview-skeleton .sk-line {
    position: relative;
    overflow: hidden;
    background: #eceff3;
    border-radius: 4px;
}

.kec-search-preview-skeleton .sk-thumb {
    flex: 0 0 64px;
    height: 48px;
    border-radius: 6px;
}

.kec-search-preview-skeleton .sk-body {
    flex: 1 1 auto;
}

.kec-search-preview-skeleton .sk-line {
    height: 12px;
    margin: 4px 0;
}

.kec-search-preview-skeleton .sk-line.w60 { width: 60%; }
.kec-search-preview-skeleton .sk-line.w30 { width: 30%; }

.kec-search-preview-skeleton .sk-thumb::after,
.kec-search-preview-skeleton .sk-line::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.65), rgba(255,255,255,0));
    animation: kec-search-shimmer 1.25s infinite;
}

@keyframes kec-search-shimmer {
    100% { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
    .kec-search-preview-skeleton .sk-thumb::after,
    .kec-search-preview-skeleton .sk-line::after {
        animation: none;
    }
}

@media (max-width: 768px) {
    .kec-search-preview {
        padding: 0;
    }
    .kec-search-preview-thumb,
    .kec-search-preview-skeleton .sk-thumb {
        flex-basis: 48px;
        width: 48px;
        height: 36px;
    }
}
