/* ===========================================================================
   Slay the Spire 2 プレイメモメモ — レスポンシブ素のCSS（フレームワーク不使用）
   ブレークポイント: 〜640px(スマホ) / 641-1024px(タブレット) / 1025px〜(PC)
   =========================================================================== */

:root {
    --bg:        #14161c;
    --surface:   #1e2230;
    --surface-2: #262b3b;
    --border:    #333a4d;
    --text:      #e7e9ef;
    --muted:     #9aa1b4;
    --accent:    #d8b15a;   /* StS の金 */
    --accent-2:  #6ea8ff;
    --radius:    10px;
    --maxw:      1100px;

    --r-common:   #b9c0cf;
    --r-uncommon: #5fc6e0;
    --r-rare:     #f1c453;
    --r-special:  #c98bdb;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN",
                 "Noto Sans JP", Meiryo, sans-serif;
    line-height: 1.7;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    width: 100%;
    max-width: var(--maxw);
    margin-inline: auto;
    padding-inline: clamp(16px, 4vw, 32px);
}

/* ---------- ヘッダー / ナビ ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgb(20 22 28 / 92%);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.nav {
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 56px;
    flex-wrap: wrap;
}
.brand {
    font-weight: 800;
    letter-spacing: .5px;
    color: var(--accent);
    font-size: 1.15rem;
}
.brand:hover { text-decoration: none; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-left: auto;
}
.nav-links > a,
.nav-group__label {
    color: var(--text);
    font-weight: 600;
    cursor: default;
}
.nav-links > a { cursor: pointer; }
.is-active { color: var(--accent); }
.nav-version {
    color: var(--muted);
    font-size: .82rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 10px;
}

/* データのサブメニュー（クリックでトグル＝<details>/<summary>） */
.nav-group { position: relative; }
/* <summary> をボタン風にし、既定の三角マーカーは隠す */
summary.nav-group__label {
    cursor: pointer;
    list-style: none;
    user-select: none;
}
summary.nav-group__label::-webkit-details-marker { display: none; }
summary.nav-group__label::after {
    content: "▾";
    font-size: .8em;
    margin-left: 4px;
    color: var(--muted);
    transition: transform .15s ease;
    display: inline-block;
}
.nav-group[open] summary.nav-group__label::after { transform: rotate(180deg); }

/* パネルは details の開閉で表示制御（ホバー依存を撤廃） */
.nav-sub {
    position: absolute;
    top: 130%;
    right: 0;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    box-shadow: 0 12px 30px rgb(0 0 0 / 40%);
}
.nav-sub a {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--text);
}
.nav-sub a:hover { background: var(--surface-2); text-decoration: none; }
.nav-sub small { color: var(--muted); }

/* ハンバーガー（スマホのみ表示） */
.nav-burger { display: none; flex-direction: column; gap: 5px; cursor: pointer; padding: 6px; }
.nav-burger span {
    width: 24px; height: 2px; background: var(--text); border-radius: 2px;
}

/* ---------- メイン ---------- */
.site-main { padding-block: 28px 56px; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); margin: .2em 0 .6em; }
h2 { font-size: 1.35rem; margin-top: 1.6em; border-bottom: 1px solid var(--border); padding-bottom: .3em; }

.page-head { margin-bottom: 22px; }
.page-head p { color: var(--muted); margin: 0; }
.crumbs { color: var(--muted); font-size: .85rem; margin-bottom: 6px; }

/* ---------- データ一覧グリッド（自動可変） ---------- */
.entry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    margin-top: 18px;
}

/* データカード */
.entry-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    color: var(--text);
    transition: transform .12s ease, border-color .12s ease;
}
.entry-card:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
.entry-card__thumb { display: block; }
.entry-thumb {
    display: grid;
    place-items: center;
    aspect-ratio: 1 / 1;
    width: 100%;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--surface-2), #161a26);
    border: 1px solid var(--border);
    font-size: 2rem;
}
img.entry-thumb { object-fit: contain; padding: 4px; }

/* 詳細ページの大きめ画像 */
.entry-detail-img { max-width: 240px; }
.entry-detail-img .entry-thumb { aspect-ratio: auto; }
.entry-card__body { display: flex; flex-direction: column; gap: 3px; }
.entry-name { font-weight: 700; }
.entry-sub  { color: var(--muted); font-size: .8rem; }
.entry-desc { color: var(--muted); font-size: .85rem; margin-top: 4px; }

/* 説明文中のキーワード/数値の色分け（[gold] 等を span 化したもの） */
.kw { font-weight: 600; }
.kw-gold   { color: var(--accent); }
.kw-blue   { color: var(--accent-2); }
.kw-red    { color: #ff8a8a; }
.kw-green  { color: #7bd88f; }
.kw-purple { color: #c98bdb; }

.entry-rarity {
    align-self: flex-start;
    font-size: .7rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    border: 1px solid currentcolor;
    border-radius: 999px;
    padding: 1px 8px;
    margin-top: 2px;
}
[data-rarity="common"]   .entry-rarity, .entry-rarity[data-rarity="common"]   { color: var(--r-common); }
[data-rarity="uncommon"] .entry-rarity, .entry-rarity[data-rarity="uncommon"] { color: var(--r-uncommon); }
[data-rarity="rare"]     .entry-rarity, .entry-rarity[data-rarity="rare"]     { color: var(--r-rare); }
[data-rarity="special"]  .entry-rarity, .entry-rarity[data-rarity="special"]  { color: var(--r-special); }

/* ---------- エンカウンター・タイムライン（幕→難易度のリスト表示） ---------- */
.enc-act { margin-top: 8px; }
.enc-tier {
    margin: 18px 0 8px;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}
.enc-list { display: flex; flex-direction: column; gap: 10px; }
/* 1エンカウンター=1ブロック（画像列の下に名前を改行）。高さは120px以下に収める */
.enc-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    max-height: 120px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    color: var(--text);
    transition: transform .12s ease, border-color .12s ease;
}
.enc-row:hover { transform: translateY(-2px); border-color: var(--accent); text-decoration: none; }
/* 最大4体なので折返さず1列に保ち、高さの増加を防ぐ */
.enc-row__monsters { display: flex; flex-wrap: nowrap; gap: 6px; }
.enc-mon {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--surface-2), #161a26);
    border: 1px solid var(--border);
    padding: 3px;
}
span.enc-mon { display: grid; place-items: center; font-size: 1.6rem; }
/* 画像読み込み失敗時に imgFallback が差し込むプレースホルダを同じ枠に収める */
.enc-row__monsters .entry-thumb { width: 60px; height: 60px; aspect-ratio: auto; font-size: 1.6rem; }
.enc-row__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* 記事内インライン引用カード */
.entry-card--inline {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    max-width: 320px;
    padding: 8px 12px;
    margin: 6px 8px 6px 0;
    vertical-align: middle;
}
.entry-card--inline .entry-thumb { width: 40px; font-size: 1.2rem; }
.entry-card--inline .entry-card__thumb { flex: 0 0 auto; width: 40px; }
.embed-missing {
    color: #ff8a8a;
    border: 1px dashed #714; border-radius: 6px;
    padding: 0 6px; font-size: .85em;
}

/* ---------- 記事（ブログ） ---------- */
.post-list { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.post-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}
.post-item h2 { margin: 0 0 6px; border: 0; padding: 0; font-size: 1.15rem; }
.post-meta { color: var(--muted); font-size: .82rem; display: flex; gap: 10px; flex-wrap: wrap; }
.post-excerpt { color: var(--muted); margin: 8px 0 0; }

/* 外部 wiki リンク（詳細ページ先頭付近） */
.wiki-link { margin: 2px 0 12px; font-size: .9rem; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wiki-link a { font-weight: 600; }
.ext-note {
    font-size: .68rem; color: var(--muted); letter-spacing: .04em;
    border: 1px solid var(--border); border-radius: 999px; padding: 0 7px;
}
.wiki-yes     { color: #7bd88f; font-size: .8rem; }
.wiki-no      { color: var(--muted); font-size: .8rem; }
.wiki-unknown { color: var(--muted); font-size: .8rem; }
.post-draft {
    font-size: .7rem; font-weight: 700; vertical-align: middle;
    color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 1px 8px;
}

/* ブログ編集フォーム */
.blog-editor textarea {
    width: 100%; padding: 10px 12px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
    font: inherit; line-height: 1.6; resize: vertical; min-height: 240px;
}
.blog-editor input[type="text"] {
    width: 100%; padding: 8px 10px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit;
}
.blog-status { display: flex; align-items: center; gap: 16px; color: var(--muted); }
.blog-status label.inline { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.blog-delete-form { margin-top: 14px; }
.btn-danger {
    background: #ff8a8a; color: #14161c; border: 0; border-radius: 8px;
    padding: 8px 16px; font-weight: 700; cursor: pointer;
}
.btn-danger:hover { filter: brightness(1.05); }

.tag {
    display: inline-block;
    font-size: .75rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 1px 9px;
    color: var(--muted);
}

.article {
    max-width: 760px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: clamp(18px, 4vw, 36px);
}
.article :is(p, ul, ol, blockquote) { margin: 0 0 1.1em; }
.article ul, .article ol { padding-left: 1.4em; }
.article blockquote {
    border-left: 3px solid var(--accent);
    margin-left: 0; padding: .2em 1em; color: var(--muted);
    background: var(--surface-2); border-radius: 0 8px 8px 0;
}
.article pre {
    background: #0f1118; border: 1px solid var(--border);
    border-radius: 8px; padding: 14px; overflow-x: auto;
}
.article code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: .9em; }
.article pre code { background: none; padding: 0; }

/* ---------- ナビのログイン状態 ---------- */
.nav-user { color: var(--muted); font-size: .85rem; }
.nav-logout { display: inline; margin: 0; }
.nav-logout button {
    background: none; border: 0; color: var(--text); font: inherit; font-weight: 600;
    cursor: pointer; padding: 0;
}
.nav-logout button:hover { color: var(--accent); }

/* ---------- ログイン / アップロードフォーム ---------- */
.auth-form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
.auth-form input[type="text"], .auth-form input[type="password"], .run-memo-form textarea {
    width: 100%; padding: 8px 10px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
    font: inherit;
}
.auth-form button, .run-memo-form button, .btn {
    align-self: flex-start; display: inline-block;
    background: var(--accent); color: #14161c; border: 0; border-radius: 8px;
    padding: 8px 16px; font-weight: 700; cursor: pointer; text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.login-error, .upload-flash {
    background: var(--surface-2); border: 1px solid var(--border);
    border-left: 3px solid var(--accent); border-radius: 6px; padding: 8px 12px; color: var(--text);
}
.dropzone {
    display: block; border: 2px dashed var(--border); border-radius: var(--radius);
    padding: 28px 16px; text-align: center; color: var(--muted); cursor: pointer; background: var(--surface-2);
}
.dropzone:hover { border-color: var(--accent); }
.dropzone input[type="file"] { display: block; margin: 0 auto 10px; }

/* ---------- ラン一覧テーブル ---------- */
.run-table { width: 100%; border-collapse: collapse; margin-top: 18px; }
.run-table th, .run-table td {
    text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.run-table th { color: var(--muted); font-size: .82rem; font-weight: 600; }
.run-table tbody tr:hover { background: var(--surface); }
.run-win     { color: #7bd88f; font-weight: 700; }
.run-lose    { color: #ff8a8a; font-weight: 700; }
.run-abandon { color: var(--muted); font-weight: 700; }

/* ---------- ラン詳細 ---------- */
.run-article { max-width: 860px; }
.run-header { padding: 4px 0 4px 14px; margin-bottom: 8px; }
.run-header h1 { margin: 0; }
.run-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.run-badges .badge {
    font-size: .78rem; color: var(--muted);
    border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px;
}
.section { margin-top: 26px; }
.section-title { font-size: 1.2rem; border-bottom: 1px solid var(--border); padding-bottom: .3em; margin: 0 0 .6em; }
.section-meta { color: var(--muted); font-size: .85rem; font-weight: 400; }
.run-summary-grid { display: flex; flex-wrap: wrap; gap: 12px; }
.run-stat {
    flex: 1 1 110px; background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 8px; padding: 10px 12px; text-align: center;
}
.run-stat-val { font-size: 1.3rem; font-weight: 700; }
.run-stat-label { color: var(--muted); font-size: .78rem; margin-top: 2px; }
.run-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.run-tag {
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
    padding: 3px 9px; font-size: .85rem; color: var(--text);
}
.run-tag:hover { border-color: var(--accent); text-decoration: none; }
.run-tag-up   { color: var(--accent-2); font-size: .78em; }
.run-tag-meta { color: var(--muted); font-size: .78em; }
.run-memo-form { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }

/* フロアタイムライン */
.floor-row {
    padding: 6px 0; border-bottom: 1px dashed var(--border);
    font-size: .9rem; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
}
.floor-badge {
    font-size: .72rem; border-radius: 4px; padding: 1px 7px; color: #14161c; font-weight: 700; white-space: nowrap;
}
.floor-monster, .floor-unknown { background: #9aa1b4; }
.floor-elite { background: #f1c453; }
.floor-boss { background: #ff8a8a; }
.floor-shop { background: #5fc6e0; }
.floor-treasure { background: #d8b15a; }
.floor-rest_site { background: #7bd88f; }
.floor-ancient, .floor-event { background: #c98bdb; }
.floor-meta { color: var(--muted); font-size: .8em; }
.floor-pick a { color: #7bd88f; }
.floor-skip a { color: var(--muted); }
.floor-remove { color: #ff8a8a; font-size: .85em; }
.floor-relic a { color: var(--accent); }
.floor-rest { color: var(--accent-2); font-size: .85em; }
.floor-hp { color: var(--muted); font-size: .82em; margin-left: auto; }
.hp-dmg { color: #ff8a8a; }
.hp-heal { color: #7bd88f; }

/* ---------- 工事中 ---------- */
.under-construction {
    text-align: center;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    margin-top: 18px;
}
.under-construction .uc-icon { font-size: 3rem; }
.under-construction p { color: var(--muted); }

/* ---------- フッター ---------- */
.site-footer {
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .85rem;
    padding-block: 22px;
}

/* ===========================================================================
   スマホ（〜640px）: ナビをハンバーガーで畳む
   =========================================================================== */
@media (max-width: 640px) {
    .nav-burger { display: flex; margin-left: auto; }
    .nav-links {
        flex-basis: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        margin-left: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height .25s ease;
    }
    .nav-toggle:checked ~ .nav-links { max-height: 70vh; padding-bottom: 12px; }
    /* スマホでも details のタップ開閉に従う（静的配置で本文を押し下げる） */
    .nav-sub { position: static; border: 0; box-shadow: none; padding-left: 12px; }
    .nav-version { align-self: flex-start; }
    .entry-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
    .enc-row { padding: 8px 10px; }
    .enc-mon, .enc-row__monsters .entry-thumb { width: 48px; height: 48px; }
}
