/* ベース */

/* 設定の初期言語が分かるまで、別言語のUIを先に表示しない。 */
html[data-language-pending] .site-header,
html[data-language-pending] .wiki-sidebar {
    visibility: hidden;
}

:root {
    --text: #202122;
    --muted: #72777d;

    --link: #3366cc;
    --missing: #ba0000;

    --border: #dcdcde;
    --border-strong: #a2a9b1;

    --surface: #ffffff;
    --surface-soft: #f8f9fa;

    color-scheme: light;
    --header-surface: rgb(255 255 255 / 96%);
    --subtle-text: #54595d;
    --inline-surface: #f1f2f3;
    --hover-surface: #eaecf0;
    --code-surface: #f6f8fa;
    --code-text: #174a67;
    --syntax-keyword: #a02be4;
    --syntax-string: #087ea4;
    --syntax-number: #0969da;
    --syntax-title: #c0268c;
    --syntax-type: #d15704;
    --syntax-builtin: #e05a00;
    --syntax-variable: #1677b8;
    --syntax-comment: #6a737d;
    --syntax-meta: #16803c;

    --sidebar-width: 220px;
    --toc-width: 220px;
    --content-width: 900px;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --text: #e6e9ef;
    --muted: #abb4bf;
    --link: #8ab4ff;
    --missing: #ff8f8f;
    --border: #353e4a;
    --border-strong: #697686;
    --surface: #171b21;
    --surface-soft: #202630;
    --header-surface: rgb(23 27 33 / 96%);
    --subtle-text: #c2c9d2;
    --inline-surface: #252c36;
    --hover-surface: #303946;
    --code-surface: #202630;
    --code-text: #dbe5f3;
    --syntax-keyword: #d2a8ff;
    --syntax-string: #a5d6ff;
    --syntax-number: #79c0ff;
    --syntax-title: #ffabe0;
    --syntax-type: #ffc58b;
    --syntax-builtin: #ffb77c;
    --syntax-variable: #a5d6ff;
    --syntax-comment: #abb4bf;
    --syntax-meta: #a4d897;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height, 58px) + 16px);

    color: var(--text);
    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        "Noto Sans JP",
        sans-serif;

    background: var(--surface);
}

body {
    margin: 0;
    line-height: 1.7;
}


/* ヘッダー */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;

    display: flex;
    align-items: center;
    gap: 24px;

    min-height: 58px;
    padding: 8px 24px;

    background: var(--header-surface);
    border-bottom: 1px solid var(--border);

    backdrop-filter: blur(8px);
}

#wiki-name {
    flex-shrink: 0;

    color: var(--text);
    font-size: 1.3rem;
    font-weight: 700;
    text-decoration: none;
}

.header-articles {
    color: var(--text);
    text-decoration: none;
}

.header-articles:hover {
    color: var(--link);
}


/* 検索 */

.search-area {
    position: relative;

    width: min(420px, 100%);
    margin-left: auto;
}

#search {
    color: var(--text);
    width: 100%;
    padding: 8px 11px;

    font: inherit;

    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 2px;
    outline: none;
}

#search:focus {
    border-color: var(--link);
    box-shadow: inset 0 0 0 1px var(--link);
}

#search::placeholder {
    color: var(--muted);
    opacity: 1;
}

#search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 10;

    display: flex;
    flex-direction: column;

    width: 100%;
    max-height: calc(100dvh - var(--header-height, 58px) - 16px);
    overflow-y: auto;
    overflow-wrap: anywhere;

    background: var(--surface);
    border: 1px solid var(--border-strong);

    box-shadow:
        0 2px 6px
        rgb(0 0 0 / 12%);
}

#search-results:empty,
#search-results[hidden] {
    display: none;
}

#search-results a {
    display: flex;
    flex-direction: column;
    gap: 2px;

    padding: 8px 12px;

    color: var(--link);
    text-decoration: none;
}

#search-results a:hover,
#search-results a[aria-selected="true"] {
    background: var(--surface-soft);
}

#search-results a[aria-selected="true"] {
    box-shadow: inset 3px 0 var(--link);
}

.search-status {
    margin: 0;
    padding: 8px 12px;
    color: var(--muted);
    font-size: 0.85rem;
}

.search-snippet {
    overflow: hidden;

    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.4;

    white-space: nowrap;
    text-overflow: ellipsis;
}


/* Wikiレイアウト */

.wiki-layout {
    display: grid;

    grid-template-columns:
        var(--sidebar-width)
        minmax(0, var(--content-width))
        var(--toc-width);

    gap: 36px;

    width: min(100% - 48px, 1440px);
    margin: 32px auto 80px;
}


/* 記事 */

#article {
    min-width: 0;
    overflow-wrap: anywhere;
}

.split-article {
    display: grid;
    gap: 1.5rem;
}

.split-article-row {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: minmax(0, 1fr);
}

.split-article-two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.split-article-section {
    min-width: 0;
    overflow-wrap: anywhere;
}

.split-article-section img {
    max-width: 100%;
    height: auto;
}

@media (max-width: 900px) {
    .split-article-two-columns {
        grid-template-columns: minmax(0, 1fr);
    }
}

#article p {
    margin: 0.8em 0;
}


/* 見出し */

#article h1,
#article h2,
#article h3 {
    color: var(--text);
    line-height: 1.3;
}

#article h1 {
    margin: 0 0 12px;
    padding-bottom: 8px;

    font-size: 2rem;
    font-weight: 600;

    border-bottom:
        1px solid
        var(--border-strong);
}

#article h2 {
    margin: 36px 0 12px;
    padding-bottom: 5px;

    font-size: 1.5rem;
    font-weight: 600;

    border-bottom:
        1px solid
        var(--border);
}

#article h3 {
    margin: 28px 0 10px;

    font-size: 1.2rem;
    font-weight: 600;
}


/* リンク */

#article a {
    color: var(--link);
    text-decoration: none;
}

#article a:hover {
    text-decoration: underline;
}

#article a.wiki-link-missing,
#article a.wiki-link-missing:visited {
    color: var(--missing);
}


/* タグ */

.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;

    margin: 8px 0 20px;
}

#article .article-tag {
    padding: 2px 8px;

    color: var(--subtle-text);
    font-size: 0.82rem;
    text-decoration: none;

    background: var(--inline-surface);
    border: 1px solid var(--hover-surface);
    border-radius: 2px;
}

#article .article-tag:hover {
    color: var(--text);
    background: var(--hover-surface);
}


/* リスト */

#article ul,
#article ol {
    padding-left: 28px;
}

#article li {
    margin: 3px 0;
}


/* 引用 */

#article blockquote {
    margin: 20px 0;
    padding: 6px 16px;

    color: var(--subtle-text);

    border-left:
        4px solid
        var(--border-strong);
}

#article blockquote > :first-child {
    margin-top: 0;
}

#article blockquote > :last-child {
    margin-bottom: 0;
}


/* インラインコード */

#article :not(pre) > code {
    padding: 2px 5px;

    color: var(--text);

    font-family:
        Consolas,
        "Courier New",
        monospace;

    font-size: 0.9em;

    background: var(--inline-surface);
    border: 1px solid var(--hover-surface);
    border-radius: 3px;
}


/* コードブロック */

.code-block {
    position: relative;
    margin: 20px 0;
    background: var(--code-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    overflow: hidden;
}

#article pre {
    overflow-x: auto;
    margin: 20px 0;
    padding: 16px 18px;
    background: var(--code-surface);
}

#article .code-block > pre {
    margin: 0;
    /* コピー済みの表示でも本文に重ならない操作領域を確保する。 */
    padding-top: 48px;
}

#article pre code,
.hljs {
    padding: 0;

    color: var(--code-text);

    font-family:
        Consolas,
        "Courier New",
        monospace;

    font-size: 0.9rem;

    background: transparent;
}

.code-copy {
    position: absolute;
    top: 8px;
    right: 8px;

    padding: 4px 8px;

    color: var(--subtle-text);
    font: inherit;
    font-size: 0.78rem;

    background: var(--surface);
    border:
        1px solid
        var(--border-strong);

    border-radius: 3px;

    cursor: pointer;
}

.code-copy:hover {
    color: var(--text);
    background: var(--hover-surface);
}


/* highlight.js */

.hljs-keyword,
.hljs-selector-tag {
    color: var(--syntax-keyword);
}

.hljs-string,
.hljs-attr {
    color: var(--syntax-string);
}

.hljs-number,
.hljs-literal {
    color: var(--syntax-number);
}

.hljs-title,
.hljs-title.function_,
.hljs-function .hljs-title {
    color: var(--syntax-title);
}

.hljs-type {
    color: var(--syntax-type);
}

.hljs-built_in {
    color: var(--syntax-builtin);
}

.hljs-variable,
.hljs-template-variable,
.hljs-property,
.hljs-params {
    color: var(--syntax-variable);
}

.hljs-comment,
.hljs-quote {
    color: var(--syntax-comment);
}

.hljs-meta {
    color: var(--syntax-meta);
}


/* テーブル */

#article table {
    border-collapse: collapse;

    max-width: 100%;
    margin: 20px 0;

    font-size: 0.95rem;
}

#article th,
#article td {
    padding: 7px 11px;

    border:
        1px solid
        var(--border-strong);
}

#article th {
    font-weight: 600;
    background: var(--hover-surface);
}


.article-table {
    max-width: 100%;
    overflow-x: auto;
    overflow-wrap: normal;
}

.article-table:focus-visible {
    outline: 2px solid var(--link);
}

/* 画像 */

.article-image {
    width: fit-content;
    max-width: 100%;

    margin: 24px 0;
}

#article img {
    display: block;

    max-width: min(100%, 700px);
    height: auto;
}

.article-image figcaption {
    margin-top: 5px;

    color: var(--muted);
    font-size: 0.82rem;
}


/* 記事一覧 */

.article-list {
    display: flex;
    flex-direction: column;

    margin-top: 20px;
}

.article-list-item {
    padding: 12px 4px;

    border-bottom:
        1px solid
        var(--border);
}

.article-list-item:first-child {
    border-top:
        1px solid
        var(--border);
}

.article-list-title {
    font-size: 1.05rem;
    font-weight: 600;
}

.article-list-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;

    margin-top: 3px;
}

#article .article-list-tags a {
    color: var(--muted);
    font-size: 0.8rem;
}


/* ホーム */

.home-article-list {
    margin-bottom: 16px;
}

.home-all-articles {
    display: inline-block;
    margin-top: 4px;
}


/* 関連リンク */

.article-links {
    margin-top: 48px;
}

.article-links h2 {
    margin-top: 0;
}


/* 左サイドバー */

.wiki-sidebar {
    position: sticky;
    top: 90px;

    align-self: start;

    max-height: calc(100vh - 110px);
    overflow-y: auto;

    color: var(--muted);
    font-size: 0.9rem;
}

.wiki-sidebar section,
.wiki-sidebar nav {
    margin-bottom: 28px;
}

.wiki-sidebar h2 {
    margin: 0 0 8px;

    color: var(--text);
    font-size: 0.8rem;
    font-weight: 700;

    text-transform: uppercase;
}

.wiki-sidebar a {
    display: block;

    padding: 3px 0;

    color: var(--link);
    text-decoration: none;
}

.wiki-sidebar a:hover {
    text-decoration: underline;
}

#sidebar-tags {
    display: flex;
    flex-direction: column;
}

.wiki-stats p {
    margin: 3px 0;
}


/* 右目次 */

.toc-panel {
    position: sticky;
    top: 90px;

    align-self: start;

    max-height: calc(100vh - 110px);
    overflow-y: auto;

    font-size: 0.85rem;
}

.toc-panel[hidden] {
    display: block;
    visibility: hidden;
}

.toc-title {
    margin-bottom: 8px;

    color: var(--text);
    font-weight: 700;
}

.toc-panel ul {
    margin: 0;
    padding: 0;

    list-style: none;

    border-left:
        1px solid
        var(--border);
}

.toc-panel li {
    margin: 2px 0;
}

.toc-panel a {
    overflow-wrap: anywhere;
    position: relative;
    display: block;

    padding: 3px 0 3px 12px;

    color: var(--muted);
    text-decoration: none;
}

.toc-panel a:hover {
    color: var(--link);
}

.toc-panel .toc-h3 a {
    padding-left: 24px;
}


/* 現在位置 */

.toc-panel a.active {
    color: var(--link);
    font-weight: 600;
}

.toc-panel a.active::before {
    content: "";

    position: absolute;
    left: -1px;

    width: 2px;
    height: 1.7em;

    background: var(--link);
}

/* 目次とモバイル目次ボタンの非表示 */

.toc-panel[hidden],
.mobile-toc-button[hidden] {
    display: none !important;
}


/* モバイル */

.mobile-menu-button,
.mobile-toc-button {
    display: none;
}

.mobile-backdrop {
    display: none;
}

@media (max-width: 900px) {
    .site-header {
        gap: 12px;
        padding: 8px 14px;
    }

    .header-articles {
        display: none;
    }

    .mobile-menu-button,
    .mobile-toc-button {
        display: block;

        padding: 5px 8px;

        color: var(--text);
        font: inherit;

        background: transparent;

        border:
            1px solid
            var(--border);

        border-radius: 4px;

        cursor: pointer;
    }

    .mobile-toc-button {
        margin-left: auto;
    }

    .search-area {
        flex: 1;

        width: auto;
        margin-left: 0;
    }

    .wiki-layout {
        display: block;

        width: 100%;
        margin: 24px 0 60px;
    }

    #article {
        padding: 0 18px;
    }

    .wiki-sidebar,
    .toc-panel {
        visibility: hidden;
        position: fixed;

        top: 0;
        bottom: 0;
        z-index: 200;

        width: min(82vw, 320px);
        max-height: none;

        padding: 24px;

        background: var(--surface);

        transform: translateX(-105%);
        transition: transform 0.2s ease;
    }

    .wiki-sidebar {
        left: 0;
    }

    .toc-panel {
        right: 0;
        left: auto;

        transform: translateX(105%);
    }

    .wiki-sidebar.open,
    .toc-panel.open {
        visibility: visible;
        transform: translateX(0);
    }

    .mobile-backdrop.show {
        position: fixed;
        inset: 0;
        z-index: 150;

        display: block;

        background:
            rgb(0 0 0 / 35%);
    }

    .toc-panel[hidden] {
        visibility: hidden;
    }
}

/* 狭い画面でも検索欄を操作できる幅にする。 */
@media (max-width: 600px) {
    .site-header {
        flex-wrap: wrap;
    }

    #wiki-name {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .search-area {
        order: 1;
        flex-basis: 100%;
        min-width: 0;
    }
}

.theme-toggle {
    flex-shrink: 0;
    padding: 5px 8px;
    color: var(--text);
    font: inherit;
    font-size: 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    cursor: pointer;
}

.theme-toggle:hover {
    background: var(--hover-surface);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
}

@media (max-width: 600px) {
    .theme-prefix {
        display: none;
    }
}

.language-settings {
    display: grid;
    gap: 6px;
    margin: 20px 0;
}

#language-select {
    width: 100%;
    padding: 6px 8px;
    color: var(--text);
    font: inherit;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
}

#language-select:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
}
