/* ヘルプ（help.js）: 各所の「?」のボタンと、説明の小さな画面。ログイン画面でも使うので、ほかの CSS に頼らない */

/* 画面の CSS（.toolbar button など）より強くするため、要素名とクラスを重ねて指定する */
button.help-button,
.toolbar button.help-button,
.settings button.help-button {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 20px;
    height: 20px;
    min-width: 0;
    min-height: 0;
    line-height: 1;
    box-shadow: none;
    margin: 0 0 0 6px;
    padding: 0;
    color: #0969da;
    background: #ffffff;
    border: 1px solid #b6d4f7;
    border-radius: 50%;
    font: 700 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
    vertical-align: middle;
    cursor: help;
}

button.help-button:hover,
button.help-button:focus-visible,
.toolbar button.help-button:hover,
.settings button.help-button:hover {
    color: #ffffff;
    background: #0969da;
    border-color: #0969da;
}

/* 画面全体の「使い方」のボタン */
.help-page {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #0969da;
    background: #ffffff;
    border: 1px solid #b6d4f7;
    border-radius: 6px;
    cursor: help;
}

.help-page::before {
    content: "?";
    display: inline-grid;
    place-items: center;
    width: 16px;
    height: 16px;
    color: #ffffff;
    background: #0969da;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
}

/* ダイアログの見出しの横の「?」（見出しの文字は画面のスクリプトが書き換えることがあるので、見出しの外に置く） */
.dialog-title-row {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* ログイン画面などの「使い方」 */
.help-line {
    margin: -4px 0 14px;
    text-align: center;
}

/* ログイン画面の CSS は、ボタンを横いっぱいの青にするので、元に戻す */
.help-line .help-page,
.help-line .help-page:hover {
    width: auto;
    height: auto;
    margin: 0;
    padding: 4px 12px;
    color: #0969da;
    background: #ffffff;
    border: 1px solid #b6d4f7;
    font-size: 14px;
    font-weight: 400;
}

.help-line .help-page:hover {
    background: #ddf4ff;
}

.help-dialog {
    width: min(600px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    color: #1f2328;
    background: #ffffff;
    border: 1px solid #d0d7de;
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(31, 35, 40, 0.25);
    font: 15px/1.75 -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
    text-align: left;
}

.help-dialog[open] {
    display: flex;
    flex-direction: column;
}

.help-dialog::backdrop {
    background: rgba(31, 35, 40, 0.35);
}

.help-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 12px 20px;
    border-bottom: 1px solid #eaeef2;
}

.help-head h2 {
    flex: 1;
    margin: 0;
    font-size: 17px;
    line-height: 1.4;
}

.help-mark {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 24px;
    height: 24px;
    color: #ffffff;
    background: #0969da;
    border-radius: 50%;
    font-weight: 700;
}

.help-close {
    flex: none;
    width: 32px;
    height: 32px;
    padding: 0;
    color: #59636e;
    background: transparent;
    border: 0;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
}

.help-close:hover {
    background: #f6f8fa;
}

.help-body {
    overflow-y: auto;
    padding: 12px 20px 8px;
}

.help-body p {
    margin: 0 0 10px;
}

.help-body h3 {
    margin: 16px 0 6px;
    font-size: 15px;
}

.help-body ul,
.help-body ol {
    margin: 0 0 10px;
    padding-left: 1.4em;
}

.help-body li {
    margin: 2px 0;
}

.help-note {
    padding: 8px 12px;
    background: #fff8c5;
    border-left: 4px solid #d4a72c;
    border-radius: 4px;
    font-size: 14px;
}

.help-keys {
    width: 100%;
    margin: 0 0 10px;
    border-collapse: collapse;
    font-size: 14px;
}

.help-keys th,
.help-keys td {
    padding: 5px 8px;
    border-bottom: 1px solid #eaeef2;
    text-align: left;
    vertical-align: top;
}

.help-keys th {
    width: 38%;
    font-weight: 600;
    white-space: nowrap;
}

.help-dialog kbd {
    display: inline-block;
    padding: 0 6px;
    background: #f6f8fa;
    border: 1px solid #d0d7de;
    border-bottom-width: 2px;
    border-radius: 4px;
    font: 13px/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
    white-space: nowrap;
}

.help-related {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 20px;
    border-top: 1px solid #eaeef2;
    font-size: 13px;
}

.help-related[hidden] {
    display: none;
}

.help-related-label {
    color: #59636e;
}

.help-related button {
    padding: 2px 10px;
    color: #0969da;
    background: #ffffff;
    border: 1px solid #b6d4f7;
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
}

.help-related button:hover {
    background: #ddf4ff;
}

.help-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px 14px 20px;
    border-top: 1px solid #eaeef2;
}

.help-tip {
    flex: 1;
    color: #59636e;
    font-size: 12px;
}

.help-ok {
    margin-left: auto;
    padding: 6px 18px;
    color: #ffffff;
    background: #0969da;
    border: 0;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

@media (max-width: 600px) {
    .help-dialog {
        width: 100vw;
        max-width: 100vw;
        max-height: 88vh;
        margin: auto 0 0;
        border-radius: 14px 14px 0 0;
    }

    .help-tip {
        display: none;
    }

    .help-keys th {
        white-space: normal;
    }
}
