/* =========================================
   ▼ フォント定義
   ========================================= */
@font-face {
    font-family: 'IBM Plex Sans JP';
    src: url('../fonts/IBM_Plex_Sans_JP/IBMPlexSansJP-Light.ttf') format('truetype');
    font-weight: 300;
}

@font-face {
    font-family: 'IBM Plex Sans JP';
    src: url('../fonts/IBM_Plex_Sans_JP/IBMPlexSansJP-Regular.ttf') format('truetype');
    font-weight: 400;
}

@font-face {
    font-family: 'IBM Plex Sans JP';
    src: url('../fonts/IBM_Plex_Sans_JP/IBMPlexSansJP-Medium.ttf') format('truetype');
    font-weight: 500;
}

@font-face {
    font-family: 'IBM Plex Sans JP';
    src: url('../fonts/IBM_Plex_Sans_JP/IBMPlexSansJP-Bold.ttf') format('truetype');
    font-weight: 700;
}

/* =========================================
   ▼ 追加・上書き用の変数定義
   ========================================= */
:root {
    --font-base: 'IBM Plex Sans JP', sans-serif;
    --anchor-offset: 5rem;
}

/* =========================================
   ▼ 基本設定の上書き
   ========================================= */
html {
    scroll-behavior: smooth;
    scroll-padding-top: var(--anchor-offset);
}

/* 見出しへのアンカー移動時の位置調整 */
h1[id],
h2[id],
h3[id],
h4[id],
h5[id],
h6[id],
[id] {
    scroll-margin-top: var(--anchor-offset);
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5,
.article-body h6 {
    scroll-margin-top: 4.2rem;
}

body {
    font-family: var(--font-base);
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background-image: linear-gradient(#e7e7e7 1px, transparent 1px), linear-gradient(90deg, #e7e7e7 1px, transparent 1px);
    background-size: 20px 20px;
}

#content h3,
#content h4,
#content h5,
#content h6 {
    color: #333;
}

.table-scroll-wrapper {
    width: 100%;
    overflow-x: scroll;
}

table {
    border-spacing: 0;
    border-collapse: collapse;
    white-space: nowrap;
}

td,
th {
    text-align: center;
    background-color: #fff;
    border: 2px solid var(--color-border);
    padding: 4px 8px;
}

/* =========================================
   ▼ ヘッダーの固定化（style.cssへの上書き）
   ========================================= */
.site-header {
    position: fixed;
    top: 0;
    z-index: 1000;
    width: 100%;
    height: 4.2rem;
    box-shadow: 0 3px 0.3125rem rgba(0, 0, 0, .1);
}

.site-brand {
    margin: 5px 0 0 0;
}

/* 固定ヘッダー分の余白確保 */
main {
    padding: 4.2rem 0 0 0;
}

.nav-mobile {
    padding: 0 1rem;
    height: calc(95svh - 4.2rem);
    overflow-y: auto;
    background-color: transparent;

    /* 上下のスクロール影（JS制御用） */
    --shadow-opacity-top: 0;
    --shadow-opacity-bottom: 0;
    background-image:
        linear-gradient(to bottom, rgba(0, 0, 0, var(--shadow-opacity-top)) 30%, transparent 100%),
        linear-gradient(to top, rgba(0, 0, 0, var(--shadow-opacity-bottom)) 30%, transparent 100%);
    background-repeat: no-repeat;
    background-attachment: scroll, scroll;
    background-position: top, bottom;
    background-size: 100% 24px, 100% 24px;
    will-change: background-image;
}

/* PC表示では非表示にする要素 */
#nav,
#navgation,
#mobile-nav-toc,
.toc-toggle-btn {
    display: none;
}

/* =========================================
   ▼ 記事・目次まわりの追加設定
   ========================================= */
.mobile-toc-title {
    margin: 1.5rem 0 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-muted);
}

.toc-box {
    top: calc(36px + 4.2rem);
}

#article-toc {
    height: 70svh;
    overflow: scroll;
}

.article-body img {
    margin: 1.5rem 0;
}

/* =========================================
   ▼ フッター（デザイン変更）
   ========================================= */
.site-footer {
    background-color: var(--color-text);
    text-align: left;
}

.site-footer h6 {
    margin: 0 0 1.5rem 0;
}

.footer-links {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    margin: 1rem 0 1rem 0;
}

.footer-links h6 {
    font-size: 1em;
    margin: 0;
}

.footer-links div {
    width: fit-content;
    text-align: left;
    margin: 0 2rem 2rem 0;
}

.footer-links div ul {
    padding-left: 0;
    margin: 0;
}

.footer-links div ul li {
    list-style: none;
}

.footer-links div ul li a {
    color: var(--color-muted);
}

.footer-links div ul li::before {
    content: '';
    display: inline-block;
    margin: 0 0 2.5px 0;
    width: 3px;
    height: 1em;
    background-color: var(--color-muted);
    margin-right: 4px;
    vertical-align: middle;
    transform-origin: center;
}

/* ==============================================
   ▼ 注釈（脚注）スタイル
   ============================================== */
.footnote-wrap {
    position: relative;
    display: inline-block;
    margin: 0 1px;
    line-height: normal;
    text-indent: 0;
}

.footnote-marker {
    color: #e63946;
    font-size: 0.6em;
    font-weight: bold;
    text-decoration: none;
    vertical-align: super;
    padding: 0 2px;
    transition: opacity 0.2s ease;
    cursor: pointer;
}

.footnote-marker:hover {
    opacity: 0.7;
    text-decoration: underline;
}

.footnote-content {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 160%;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 260px;
    background-color: #2b2d42;
    color: #edf2f4;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
    z-index: 1000;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    white-space: normal;
    pointer-events: none;
}

.footnote-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    border-width: 6px;
    border-style: solid;
    border-color: #2b2d42 transparent transparent transparent;
}

@media (hover: hover) {
    .footnote-wrap:hover .footnote-content {
        visibility: visible;
        opacity: 1;
        bottom: 140%;
    }
}

.footnote-wrap.active .footnote-content {
    visibility: visible;
    opacity: 1;
    bottom: 140%;
}

.footnote-definition {
    font-size: 0.8em;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 0 4px 4px 0;
}

.footnote-definition strong {
    color: #e63946;
}

.footnote-backref {
    text-decoration: none;
    color: #e63946;
    font-size: 0.6rem;
    font-weight: bold;
    display: inline-block;
    margin-left: 8px;
    transition: transform 0.2s, color 0.2s;
    margin-top: 5px;
}

.footnote-backref:hover {
    transform: scale(1.2);
    color: #b91d2a;
}

.crimson {
    color: crimson;
}

/* =========================================
   ▼ 検索機能
   ========================================= */

/* --- ヘッダー検索フォーム --- */
.nav-search-item {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

#search-input {
    padding: 0.4rem 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
    font-size: 0.9rem;
    width: 200px;
    transition: all 0.2s;
    background: #fdfdfd;
    height: 1.6rem;
}

#search-input:focus {
    border-color: #4d7ea8;
    box-shadow: 0 0 0 2px rgba(77, 126, 168, 0.1);
    outline: none;
}

#search-button {
    padding: 0.4rem 1rem;
    background-color: #4d7ea8;
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
    white-space: nowrap;
    height: 1.6rem;
    display: flex;
    align-items: center;
}

#search-button:hover {
    background-color: #3a658a;
}

/* --- ドロップダウン候補リスト --- */
.search-results {
    position: absolute;
    top: 100%;
    right: 0;
    width: 300px;
    max-height: 400px;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: none;
}

.search-results.active {
    display: block;
}

.search-result-item {
    display: block;
    padding: 0.8rem 1rem;
    color: #333;
    text-decoration: none;
    font-size: 0.9rem;
    border-bottom: 1px solid #eee;
    transition: background-color 0.1s;
    line-height: 1.4;
}

.search-result-item:hover {
    background-color: #f0f7ff;
    color: #4d7ea8;
}

/* --- 検索結果ページ（リスト表示） --- */
.search-results-page {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.search-results-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: #333;
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
}

/* リスト全体のスタイル */
.search-results-list {
    list-style-type: disc;
    padding: 0;
    margin: 0;
}

.search-results-list li {
    margin-bottom: 1rem;
}

/* 結果カードのデザイン */


/* =========================================
   ▼ レスポンシブ対応 (スマホ等)
   ========================================= */
@media (max-width: 960px) {

    .site-header-hight {
        height: 100svh;
        margin: 0;
        padding: 0;
        background-color: rgba(255, 255, 255, 0.6);
        backdrop-filter: blur(10px);
    }

    #nav {
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        width: 4.2rem;
        height: 4.2rem;
        z-index: 999;
    }

    #nav_toggle {
        display: block;
        position: relative;
        margin: auto;
        top: 50%;
        transform: translateY(-50%);
        width: 1.75rem;
        height: 1.5rem
    }

    #nav_toggle i {
        display: block;
        width: 100%;
        height: 4px;
        background-color: var(--color-text);
        position: absolute;
        transition: transform .5s, opacity .5s, background-color .8s cubic-bezier(0.95, 0.05, 0.795, 0.035);
    }

    #nav_toggle.modalopen i {
        background-color: #fff;
    }

    #nav_toggle i:nth-child(1) {
        top: 0;
    }

    #nav_toggle i:nth-child(2) {
        top: 0;
        bottom: 0;
        margin: auto;
    }

    #nav_toggle i:nth-child(3) {
        bottom: 0;
    }

    #nav_toggle.nav_toggle i:nth-child(1) {
        transform: translateY(10px) rotate(-45deg);
    }

    #nav_toggle.nav_toggle i:nth-child(2) {
        opacity: 0;
    }

    #nav_toggle.nav_toggle i:nth-child(3) {
        transform: translateY(-12px) rotate(45deg);
    }

    .site-nav {
        display: none;
    }

    .nav-mobile {
        width: 100%;
        overflow-x: hidden;
        overflow-y: scroll;
    }

    .nav-mobile ul {
        list-style: none;
        margin: 1rem 0;
        padding: 0;
        display: block;
        width: 100%;
    }

    .nav-mobile ul li {
        margin-bottom: 1rem;
    }

    .nav-mobile ul li::before {
        content: '';
        display: inline-block;
        margin: 0 0 2.5px 0;
        width: 3px;
        height: 1em;
        background-color: var(--color-text);
        margin-right: 4px;
        vertical-align: middle;
        transform-origin: center;
    }

    .nav-mobile ul li a {
        color: var(--color-text);
        width: 100%;
    }

    #mobile-nav-toc {
        display: block;
    }

    .mobile-toc-list {
        display: flex;
        flex-direction: column;
        gap: 0.8rem;
        padding-left: 0.5rem;
    }

    .mobile-toc-list a {
        display: block;
        font-size: 0.95rem;
        color: var(--color-text);
        text-decoration: none;
    }

    .toc-level-1 {
        font-weight: bold;
    }

    .article-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .toc-toggle-btn {
        display: block;
        width: 100%;
        margin-top: 0.8rem;
        padding: 0.6rem;
        background-color: transparent;
        border: 1px solid var(--color-accent);
        color: var(--color-accent);
        border-radius: var(--radius-medium);
        cursor: pointer;
        font-size: 0.9rem;
        transition: background-color 0.2s;
    }

    .toc-toggle-btn:hover {
        background-color: rgba(77, 126, 168, 0.1);
    }

    #article-toc {
        height: fit-content;
        max-height: 120px;
        overflow: hidden;
        position: relative;
        transition: max-height 0.4s ease;
    }

    #article-toc:not(.open)::after {
        content: "";
        position: absolute;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 40px;
        background: linear-gradient(to bottom, transparent, var(--color-surface));
        pointer-events: none;
    }

    #article-toc.open {
        max-height: fit-content;
    }

    #article-toc.open::after {
        display: none;
    }

    .footer-links {
        display: block;
    }

    .footer-links div {
        width: 100%;
        margin: 0 auto 2rem auto;
    }

    /* --- 検索機能のスマホ対応 --- */
    .nav-search-item {
        width: 100%;
        margin-left: 0;
        margin-top: 1rem;
    }

    .search-container {
        width: 100%;
    }

    #search-input {
        flex-grow: 1;
        width: auto;
    }
}