/*
Theme Name: NTR MANGAism
Theme URI: https://eromanga-s.com/
Description: NTR（寝取られ）エロ漫画のまとめサイト用テーマ。作品は通常の投稿、パーマリンクは /ntr/%postname%/。画像はメディアライブラリに入れず /image/{フォルダ}/001.webp を参照する。
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
Text Domain: ntrmanga
*/

:root {
    --bg:       #ffffff;
    --panel:    #f7f6f8;
    --panel2:   #f0eef2;
    --line:     #e6e2ea;
    --line2:    #d5cfdc;
    --fg:       #1d1a22;
    --body:     #332e3b;
    --sub:      #5f5869;
    --dim:      #7d7588;
    --accent:   #b4245c;
    --accent-h: #8e1848;
    --accent-s: #fdf0f5;
    --ink:      #111014;
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--body);
    font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.75;
}

img { max-width: 100%; height: auto; }

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

h1, h2, h3 { color: var(--fg); line-height: 1.4; text-wrap: balance; }

.wrap {
    max-width: 1180px;
    margin: 0 auto;
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.screen-reader-text,
.skip {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}
.skip:focus {
    position: fixed; top: 8px; left: 8px;
    width: auto; height: auto; clip: auto;
    z-index: 100; padding: 10px 16px;
    background: var(--accent); color: #fff; border-radius: 6px;
}

/* ============================================================
   ヘッダー
   ============================================================ */

.site-head {
    background: #fff;
    border-bottom: 1px solid var(--line);
    position: relative;
    z-index: 5;
}
.head-in {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 62px;
}
.logo { margin: 0; font-size: 18px; font-weight: 800; white-space: nowrap; }
.logo a { color: var(--fg); display: block; }
.logo a:hover { color: var(--accent); text-decoration: none; }

/*
 * ロゴ画像。高さを固定して横幅は原寸の比率に任せる。
 * 高さを決めておけば、寸法を持たない画像でも読み込み時に位置がずれない。
 */
.logo img {
    display: block;
    height: 38px;
    width: auto;
    max-width: 230px;
    object-fit: contain;
}
.logo a:hover img { opacity: .85; }

@media (max-width: 720px) {
    .logo img { height: 30px; max-width: 160px; }
}

.head-nav { display: flex; gap: 4px; margin-right: auto; }
.head-nav a {
    padding: 7px 13px;
    font-size: 13.5px; font-weight: 600;
    color: var(--sub);
    border-radius: 999px;
    white-space: nowrap;
}
.head-nav a:hover { background: var(--accent-s); color: var(--accent); text-decoration: none; }

.searchform { display: flex; align-items: center; flex: 0 1 300px; min-width: 0; }
.searchform input[type=search] {
    flex: 1 1 auto; min-width: 0;
    height: 38px; padding: 0 13px;
    font: inherit; font-size: 13px;
    color: var(--fg); background: var(--panel);
    border: 1px solid var(--line); border-right: 0;
    border-radius: 8px 0 0 8px; outline: none;
}
.searchform input[type=search]:focus { border-color: var(--accent); }
.searchform button {
    flex-shrink: 0; height: 38px; width: 46px;
    display: grid; place-items: center;
    background: var(--accent); color: #fff;
    border: 0; border-radius: 0 8px 8px 0; cursor: pointer;
}
.searchform button:hover { background: var(--accent-h); }

@media (max-width: 760px) {
    .head-in { height: auto; padding-top: 12px; padding-bottom: 12px; flex-wrap: wrap; gap: 10px; }
    .searchform { order: 3; flex-basis: 100%; }
    .head-nav { gap: 2px; }
    .head-nav a { padding: 6px 10px; font-size: 12.5px; }
}

/* ============================================================
   見出し・セクション
   ============================================================ */

.page-head { margin: 26px 0 20px; }
.page-head h1 { margin: 0; font-size: 25px; font-weight: 800; letter-spacing: .01em; }

.page-lead { margin-top: 10px; max-width: 70ch; color: var(--sub); font-size: 14px; }
.page-lead p { margin: 0 0 .6em; }
.page-lead p:last-child { margin-bottom: 0; }

.sec { margin: 0 0 38px; }
.sec-hd {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 14px; flex-wrap: wrap; margin-bottom: 14px;
}
.sec-hd h2 {
    margin: 0; font-size: 18px; font-weight: 700;
    padding-left: 11px; border-left: 4px solid var(--accent);
}
.sec-hd .more, .more { font-size: 12.5px; font-weight: 600; white-space: nowrap; }

.axis { margin-bottom: 18px; }
.axis h3 {
    margin: 0 0 8px; font-size: 14px; font-weight: 700; color: var(--sub);
}

.empty { color: var(--dim); padding: 28px 0; }

/* ============================================================
   パンくず
   ============================================================ */

.crumb { margin: 16px 0 0; font-size: 12px; color: var(--dim); }
.crumb ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.crumb li + li::before { content: "›"; margin-right: 6px; color: var(--line2); }
.crumb a { color: var(--sub); }
.crumb span { color: var(--dim); }

/* ============================================================
   カードの格子
   ============================================================ */

.grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 18px 14px;
    list-style: none; margin: 0; padding: 0;
}
@media (max-width: 1080px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 820px)  { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px)  { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; } }

.card { min-width: 0; display: flex; flex-direction: column; }
.card-link { display: block; color: inherit; }
.card-link:hover { text-decoration: none; }
.card-link:hover .card-title { color: var(--accent); }

.card-thumb {
    position: relative;
    aspect-ratio: 720 / 1040;
    background: var(--panel2);
    border: 1px solid var(--line);
    border-radius: 7px;
    overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.card-noimg {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    color: var(--dim); font-size: 11px;
}

.card-rank {
    position: absolute; top: 0; left: 0;
    min-width: 26px; height: 26px; padding: 0 6px;
    display: grid; place-items: center;
    background: rgba(17,16,20,.82); color: #fff;
    font-size: 13px; font-weight: 800;
    font-variant-numeric: tabular-nums;
    border-radius: 7px 0 7px 0;
}
.card-rank.is-top { background: var(--accent); }

.card-pages {
    position: absolute; right: 5px; bottom: 5px;
    padding: 2px 6px;
    background: rgba(17,16,20,.82); color: #fff;
    font-size: 10.5px; font-weight: 700; line-height: 1.5;
    border-radius: 3px; font-variant-numeric: tabular-nums;
}
.card-kind {
    position: absolute; left: 5px; bottom: 5px;
    padding: 2px 6px;
    background: var(--accent); color: #fff;
    font-size: 10px; font-weight: 700; line-height: 1.5;
    border-radius: 3px;
}

.card-title {
    margin: 7px 0 0;
    font-size: 12.5px; font-weight: 600; line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; min-height: 2.9em;
}
.card-circle {
    margin: 3px 0 0;
    font-size: 11px; color: var(--dim);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-circle a { color: var(--dim); }

/* ============================================================
   タグのピル
   ============================================================ */

.pills { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 7px; }
.pills a {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 13px;
    font-size: 13px; font-weight: 500;
    color: var(--fg); background: var(--panel);
    border: 1px solid var(--line); border-radius: 999px;
}
.pills a:hover { background: var(--accent-s); border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pills a span { font-size: 11px; font-weight: 600; color: var(--dim); font-variant-numeric: tabular-nums; }
.pills a:hover span { color: var(--accent); opacity: .75; }

.pills.tight { gap: 5px; }
.pills.tight a { padding: 4px 10px; font-size: 12px; }

.plain-list {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px 18px;
    font-size: 13px;
}
.plain-list li {
    display: flex; justify-content: space-between; gap: 8px;
    padding: 4px 0; border-bottom: 1px solid var(--line);
    min-width: 0;
}
.plain-list li > a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plain-list span { color: var(--dim); font-size: 11px; font-variant-numeric: tabular-nums; flex-shrink: 0; }
@media (max-width: 900px) { .plain-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .plain-list { grid-template-columns: 1fr; } }

/* ============================================================
   作品ページ
   ============================================================ */

.work-title { margin: 14px 0 20px; font-size: 24px; font-weight: 800; }

.work-top { display: flex; gap: 26px; margin-bottom: 30px; align-items: flex-start; }
.work-cover { flex: 0 0 240px; }
.work-cover img {
    width: 100%; display: block;
    border: 1px solid var(--line); border-radius: 8px;
}
.cover-link { display: block; }
.work-nocover { color: #b3261e; font-size: 13px; }

.work-meta { flex: 1 1 auto; min-width: 0; }
.work-meta dl { margin: 0; display: grid; grid-template-columns: 6.5em 1fr; gap: 9px 14px; }
.work-meta dt { color: var(--dim); font-size: 13px; font-weight: 600; }
.work-meta dd { margin: 0; font-size: 14px; min-width: 0; }

.badge {
    display: inline-block; padding: 2px 9px;
    background: var(--accent); color: #fff;
    font-size: 11.5px; font-weight: 700; border-radius: 4px;
}

.work-read { margin: 22px 0 0; }
.btn {
    display: inline-block; padding: 13px 30px;
    background: var(--accent); color: #fff;
    font-size: 15px; font-weight: 700; line-height: 1;
    border: 1px solid var(--accent); border-radius: 8px;
    cursor: pointer;
}
.btn:hover { background: var(--accent-h); border-color: var(--accent-h); color: #fff; text-decoration: none; }
.btn.ghost { background: #fff; color: var(--accent); font-size: 13.5px; padding: 11px 24px; }
.btn.ghost:hover { background: var(--accent-s); color: var(--accent-h); }

.work-body { margin: 0 0 30px; max-width: 70ch; }

@media (max-width: 720px) {
    .work-top { flex-direction: column; gap: 18px; }
    .work-cover { flex: none; width: 190px; margin: 0 auto; }
    .work-meta dl { grid-template-columns: 5.5em 1fr; }
    .work-title { font-size: 20px; }
}

/* ============================================================
   読む（縦スクロール）
   ------------------------------------------------------------
   1ページ目から順に縦に並べる。ビューアは使わない。
   ============================================================ */

.reader-sec { scroll-margin-top: 12px; }

.reader-page {
    position: relative;
    max-width: 780px;
    margin: 0 auto 5px;
    scroll-margin-top: 12px;

    /*
     * 画面外のページは描画しない。390ページの作品でも
     * スクロールが重くならないようにする。
     * contain-intrinsic-size を入れないと、描画していないあいだ
     * 高さが0になってスクロールバーが暴れる。
     */
    content-visibility: auto;
    contain-intrinsic-size: auto 1127px;
}
.reader-page:last-of-type { margin-bottom: 0; }

.reader-page img {
    display: block;
    width: 100%;
    height: auto;
}

/* ページ番号。読んでいる位置の目印だけなので控えめに。 */
.reader-no {
    position: absolute; left: 0; top: 0;
    padding: 2px 8px;
    background: rgba(17,16,20,.72); color: #fff;
    font-size: 11px; font-weight: 700; line-height: 1.5;
    font-variant-numeric: tabular-nums;
    border-radius: 0 0 5px 0;
    pointer-events: none;
}

.reader-sec .sec-hd { margin-bottom: 12px; }
.reader-sec { padding: 0 0 20px; }

.reader-end { margin: 20px 0 0; text-align: center; }

/*
 * スマホでは左右の余白を消して端まで使う。
 * .wrap の 16px ぶんを打ち消して全幅にする。
 * 画面の1割強が余白に取られると、読む面がそれだけ狭くなる。
 */
@media (max-width: 720px) {
    .reader-sec {
        margin-left:  calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
        margin-right: calc(-1 * max(16px, env(safe-area-inset-right, 0px)));
        padding: 0 0 18px;
    }
    .reader-sec .sec-hd,
    .reader-end {
        padding-left:  max(16px, env(safe-area-inset-left, 0px));
        padding-right: max(16px, env(safe-area-inset-right, 0px));
    }
    .reader-page { margin-bottom: 3px; }
}

/* ============================================================
   ランキング
   ============================================================ */

.rank-tabs { display: flex; gap: 8px; margin: 0 0 20px; flex-wrap: wrap; }
.rank-tab {
    display: flex; flex-direction: column; gap: 1px;
    min-width: 108px; padding: 8px 16px;
    background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
    font-size: 14px; font-weight: 800; color: var(--sub); line-height: 1.3;
}
.rank-tab span { font-size: 11px; font-weight: 600; color: var(--dim); }
.rank-tab:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.rank-tab.is-on { background: var(--accent-s); border-color: var(--accent); color: var(--accent); }
.rank-tab.is-on span { color: var(--accent); opacity: .8; }

.rank-list { list-style: none; }
.rank-list > li { min-width: 0; }
.rank-count { margin: 2px 0 0; font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }

/* ============================================================
   ページ送り
   ============================================================ */

.pagination { margin: 26px 0 0; }
.nav-links { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.page-numbers {
    display: inline-grid; place-items: center;
    min-width: 40px; height: 40px; padding: 0 12px;
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 13.5px; font-weight: 600; color: var(--sub);
    font-variant-numeric: tabular-nums;
}
a.page-numbers:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.page-numbers.current { background: var(--accent); border-color: var(--accent); color: #fff; }
.page-numbers.dots { background: transparent; border-color: transparent; }

/* ============================================================
   本文・固定ページ
   ============================================================ */

.doc, .doc-page { max-width: 70ch; }
.doc h2 {
    margin: 30px 0 10px;
    font-size: 17px; font-weight: 700;
    padding-left: 11px; border-left: 4px solid var(--accent);
}
.doc h2:first-child { margin-top: 0; }
.doc p { margin: 0 0 1em; }
.doc-page h1 { font-size: 23px; margin: 14px 0 18px; }

/* ============================================================
   フッター
   ============================================================ */

.site-foot {
    margin-top: 44px; padding: 30px 0 36px;
    background: var(--panel);
    border-top: 1px solid var(--line);
    font-size: 13px;
}
.foot-tags h2 { margin: 0 0 10px; font-size: 13px; font-weight: 700; color: var(--sub); }
.foot-tags ul { list-style: none; margin: 0 0 22px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.foot-tags a {
    display: inline-block; padding: 5px 11px;
    background: #fff; border: 1px solid var(--line); border-radius: 999px;
    font-size: 12.5px; color: var(--sub);
}
.foot-tags a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.foot-tags a.more { background: transparent; border-color: transparent; color: var(--accent); font-weight: 600; }

.foot-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 18px; }
.foot-nav a { color: var(--sub); font-size: 12.5px; }

.copy { margin: 20px 0 0; color: var(--dim); font-size: 12px; }
