/* theme/home.css — ホーム（index.html）の見た目。
   2026-10-24 に index.html の <style> から出した。配色（明るい・暗い）の上書きは
   theme/style.css がやるので、ここは暗い配色を基準に形だけ決める。
   背景の fixed グラデーションと放射の重ね、カードの大きな影と hover の動きは
   やめた（古い端末でスクロールが重い割に、見た目はほとんど変わらない）。 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Hiragino Mincho ProN", "BIZ UDPMincho", "Yu Mincho", YuMincho, "Noto Serif CJK JP", "Noto Serif JP", serif;
    background: #24243e;
    min-height: 100vh;
    color: #e0e0e0;
    padding: 1.5rem 1rem 3rem;
    font-size: 1.15rem;
    line-height: 1.8;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ---- 頭 ---- */
header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    letter-spacing: 0.06em;
    margin-bottom: 0.4rem;
    line-height: 1.3;
}

h1 a {
    color: #fff;
    text-decoration: none;
}

.online-now,
.visitor-count {
    font-size: 0.95rem;
    opacity: 0.8;
}

.visitor-count {
    margin-bottom: 1rem;
}

/* 人数が届くまでは見せないが、場所は取っておく（届いたときに下の一覧が押し下げられない。
   PageSpeed の CLS 0.048 はこれだった）。取れなかったときは空いた1行のまま */
.online-now:not(.on),
.visitor-count:not(.on) {
    visibility: hidden;
}

.online-now::before {
    content: '●';
    color: #22c55e;
    margin-right: 0.4em;
}

/* 「あなたは 0005689 人目の訪問者です」の数字。昔のアクセスカウンターのように、黒い箱に1桁ずつ。
   箱の高さは行の高さ（1.8）より低くして、数字が入っても行の高さを変えない */
.visitor-count .counter {
    display: inline-flex;
    gap: 2px;
    margin: 0 0.25em;
    vertical-align: 0.1em;
}

.visitor-count .counter span {
    display: inline-block;
    min-width: 1.15em;
    padding: 0 0.15em;
    line-height: 1.45;
    font-family: Consolas, Menlo, "Courier New", monospace;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
    color: #f5f5f5;
    background: #111;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

/* 明るい配色では style.css が span の字を全部黒にするので、ここだけ白に戻す */
body.light-mode .visitor-count .counter span {
    color: #f5f5f5 !important;
    border-color: #111;
}

/* 検索の下の「今日は 2026年11月7日（土） 天一国14年 天暦9月28日」。狭い画面では陽暦と天暦の間で折り返す */
.tenreki-today {
    margin-top: 0.9rem;
    font-size: 0.95rem;
    opacity: 0.8;
}

.tenreki-today span {
    display: inline-block;
    margin: 0 0.3em;
}

.tenreki-today:empty {
    display: none;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* 右上の「更新情報」。パソコンでは配色ボタン（#theme-toggle、右上に固定の 44px）の左に並べる。
   absolute なので、出ても下の一覧は動かない。スマホでは配色ボタンが右下に移るので右上の角へ。
   幅が狭いと題の「み旨の裏庭」にかぶるので、440px 以下はベルだけにする */
.updates {
    position: absolute;
    top: 20px;
    right: 76px;
    z-index: 50;
    text-align: left;
}

.updates-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    height: 44px;
    padding: 0 1em;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    cursor: pointer;
}

.updates-btn:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* 新着の印。いちばん新しい更新が14日以内で、まだ開いていないとき（index.html の JS が .new を付ける） */
.updates-btn.new::after {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #f43f5e;
    box-shadow: 0 0 0 2px #24243e;
}

.updates-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: min(380px, calc(100vw - 24px));
    max-height: min(70vh, 520px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.9rem 1.1rem;
    background: #2b2754;
    color: #e6e6f0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    font-size: 0.95rem;
    line-height: 1.7;
    color-scheme: dark;  /* スクロールバーも暗く */
}

.updates-panel[hidden] {
    display: none;
}

.updates-title {
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.updates-list {
    list-style: none;
}

.updates-list li {
    padding: 0.55em 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.updates-list li:first-child {
    border-top: 0;
}

.updates-list time {
    display: block;
    font-size: 0.8rem;
    opacity: 0.65;
}

body.light-mode .updates-btn {
    background: #f0f0f0;
    border-color: #ddd;
}

body.light-mode .updates-btn.new::after {
    box-shadow: 0 0 0 2px #fff;
}

body.light-mode .updates-panel {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.12);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
    color-scheme: light;
}

body.light-mode .updates-list li {
    border-top-color: rgba(0, 0, 0, 0.08);
}

@media (max-width: 768px) {
    .updates {
        top: 12px;
        right: 12px;
    }
}

@media (max-width: 440px) {
    .updates-btn {
        width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
        font-size: 1.05rem;
    }

    .updates-label {
        display: none;
    }
}

/* 検索欄。押すと search-all.html?q=… へ */
.home-search {
    display: flex;
    max-width: 640px;
    margin: 0 auto 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.home-search input {
    flex: 1 1 auto;
    min-width: 0;
    font: inherit;
    font-size: 1.1rem;
    padding: 0.7em 1.2em;
    border: 0;
    background: none;
    color: inherit;
    outline: none;
}

.home-search input::placeholder {
    color: inherit;
    opacity: 0.55;
}

.home-search input::-webkit-search-decoration,
.home-search input::-webkit-search-cancel-button {
    -webkit-appearance: none;
}

.home-search button {
    flex: 0 0 auto;
    font: inherit;
    font-weight: 700;
    padding: 0 1.4em;
    border: 0;
    background: #667eea;
    color: #fff;
    cursor: pointer;
}

.home-search:focus-within {
    border-color: rgba(102, 126, 234, 0.9);
}

.search-links {
    display: flex;
    gap: 0.7rem;
    justify-content: center;
    flex-wrap: wrap;
}

.search-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55em 1.3em;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    color: #fff;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
}

.search-btn:hover {
    background: rgba(255, 255, 255, 0.18);
}

/* ---- 本の一覧 ---- */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
}

.section-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.6rem 1.8rem;
}

.section-card summary {
    list-style: none;
    cursor: pointer;
}

.section-card summary::-webkit-details-marker {
    display: none;
}

h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    letter-spacing: 0.04em;
    line-height: 1.4;
}

h2::before {
    content: '◆';
    color: #667eea;
    font-size: 0.75em;
    flex: 0 0 auto;
}

/* 開閉の印（スマホだけ） */
h2::after {
    content: '▾';
    margin-left: auto;
    opacity: 0.55;
    font-size: 0.9em;
    transition: transform 0.2s ease;
}

.section-card[open] h2::after {
    transform: rotate(180deg);
}

.section-card[open] summary {
    margin-bottom: 1.1rem;
}

.links-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.links-list li {
    position: relative;
    padding-left: 1.4rem;
}

.links-list li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: #667eea;
}

.links-list a {
    color: #e0e0e0;
    text-decoration: none;
    font-size: 1.1rem;
    line-height: 1.7;
    display: inline-block;
}

.links-list a:hover {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 0.2em;
}

/* 八大教材・教本と天一国経典（2026-10-31）。サイトに無い本はリンクなしで薄く、天聖経は押すと冊・篇の一覧が開く */
.links-list .missing {
    font-size: 1.1rem;
    line-height: 1.7;
    opacity: 0.55;
}

.links-list details.sub > summary {
    /* パソコンでは .section-card summary を押せなくしてある（枠を開いたままにするため）。中の天聖経は押せるように戻す */
    pointer-events: auto;
    cursor: pointer;
    list-style: none;
    color: #e0e0e0;
    font-size: 1.1rem;
    line-height: 1.7;
}

.links-list details.sub > summary::-webkit-details-marker {
    display: none;
}

.links-list details.sub > summary::after {
    content: ' ▾';
    color: #667eea;
}

.links-list details.sub[open] > summary::after {
    content: ' ▴';
}

.links-list details.sub > .links-list {
    margin: 0.4rem 0 0.3rem;
}

.section-card .card-note {
    margin: 1rem 0 0;
    font-size: 0.95rem;
    opacity: 0.7;
}

.long-title {
    font-size: 1.4rem !important;
    word-break: keep-all;
    overflow-wrap: normal;
}

.featured-section {
    grid-column: 1 / -1;
    background: rgba(102, 126, 234, 0.12);
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.featured-section .links-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.6rem 1rem;
}

.section-card p {
    margin-bottom: 1rem;
    font-size: 1.05rem;
}

/* パソコン: 全部開いたまま。開閉の印も出さない（index.html の JS が open を付ける） */
@media (min-width: 769px) {
    .section-card summary {
        pointer-events: none;
    }

    h2::after {
        display: none;
    }
}

@media (max-width: 768px) {
    body {
        padding: 1rem 0.75rem 3rem;
        font-size: 1.05rem;
    }

    .content-grid {
        grid-template-columns: 1fr;
        gap: 0.8rem;
    }

    .section-card {
        padding: 1.1rem 1.2rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    .long-title {
        font-size: 1.2rem !important;
    }

    .links-list a {
        font-size: 1.05rem;
    }

    .featured-section .links-list {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .search-links {
        flex-direction: column;
        align-items: stretch;
    }

    .search-btn {
        justify-content: center;
    }
}
