/*
Theme Name: Necosuke Portal
Theme URI: https://cms.necosuke.jp/
Author: ねこすけ（福井俊治）
Description: 歴史地図ポータル向けの軽量・モバイルファースト・PWA対応の独自テーマ。余白を活かしたモダンなデザイン。メニューはドロワー（ポップアップ）方式。necosuke-history プラグインの daisyUI（.nechist スコープ）と衝突しないよう、外枠のみを提供する。
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 8.1
License: GPL-2.0-or-later
Text Domain: necosuke-portal
Tags: custom-menu, threaded-comments, translation-ready, full-width-template
*/

/* =========================================================
   デザイントークン
   ========================================================= */
:root {
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Hiragino Sans",
        "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;

    --bg: #fbfbfd;
    --surface: #ffffff;
    --surface-2: #f4f5f8;
    --text: #1c1d22;
    --muted: #6b6f7a;
    --border: #e7e8ee;
    --accent: #3b6fd4;
    --accent-ink: #ffffff;
    --accent-soft: #eef3fc;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(20, 22, 30, .04), 0 8px 24px rgba(20, 22, 30, .06);
    --shadow-lg: 0 12px 40px rgba(20, 22, 30, .16);

    --content: 760px;
    --wide: 1120px;

    --space-1: .5rem;
    --space-2: 1rem;
    --space-3: 1.5rem;
    --space-4: 2.5rem;
    --space-5: 4rem;
    --space-6: 6rem;

    --header-h: 60px;
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1116;
        --surface: #171922;
        --surface-2: #1e2130;
        --text: #e9eaf0;
        --muted: #a2a6b4;
        --border: #2a2d3a;
        --accent: #6f9bef;
        --accent-ink: #0f1116;
        --accent-soft: #1b2233;
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
        --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    }
}

/* =========================================================
   ベース
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.85;
    letter-spacing: .01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "palt";
    overflow-x: hidden;
}

img, svg, video { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { opacity: .82; }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* 見出し（プラグイン側はユーティリティで上書きされるため干渉しない） */
h1, h2, h3, h4 { line-height: 1.34; letter-spacing: -.02em; font-weight: 700; }

/* =========================================================
   レイアウト骨格
   ========================================================= */
.container { width: 100%; max-width: var(--content); margin-inline: auto; }
.container-wide { width: 100%; max-width: var(--wide); margin-inline: auto; }

.site-main {
    padding: var(--space-4) max(var(--space-2), var(--safe-l)) var(--space-6) max(var(--space-2), var(--safe-r));
    min-height: 60vh;
}
@media (min-width: 768px) {
    .site-main { padding-top: var(--space-5); }
}

/* =========================================================
   ヘッダー（最小・スティッキー）
   ========================================================= */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--border);
    padding-top: var(--safe-t);
}
.site-header__inner {
    max-width: var(--wide);
    margin-inline: auto;
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding-inline: max(var(--space-2), var(--safe-l)) max(var(--space-2), var(--safe-r));
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -.02em;
    color: var(--text);
    text-decoration: none;
}
.brand__mark {
    width: 26px; height: 26px; flex: 0 0 auto;
    display: inline-grid; place-items: center;
    background: var(--accent); color: var(--accent-ink);
    border-radius: 8px; font-size: 15px;
}
.brand:hover { opacity: 1; }

/* ハンバーガー */
.nav-toggle {
    -webkit-appearance: none; appearance: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    width: 42px; height: 42px;
    border-radius: 12px;
    display: inline-grid; place-items: center;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.nav-toggle:hover { background: var(--surface-2); }
.nav-toggle__bars, .nav-toggle__bars::before, .nav-toggle__bars::after {
    content: ""; display: block;
    width: 18px; height: 2px; border-radius: 2px;
    background: currentColor;
    transition: transform .2s ease, opacity .2s ease;
}
.nav-toggle__bars { position: relative; }
.nav-toggle__bars::before { position: absolute; top: -6px; }
.nav-toggle__bars::after { position: absolute; top: 6px; }

/* =========================================================
   ドロワー（ポップアップメニュー）
   ========================================================= */
.drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(12, 14, 20, .45);
    opacity: 0; visibility: hidden;
    transition: opacity .25s ease, visibility .25s ease;
    z-index: 60;
}
.drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(84vw, 340px);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4, 0, .2, 1);
    z-index: 70;
    display: flex; flex-direction: column;
    padding: calc(var(--space-3) + var(--safe-t)) var(--space-3) calc(var(--space-3) + var(--safe-b));
    overflow-y: auto;
}
body.drawer-open .drawer-overlay { opacity: 1; visibility: visible; }
body.drawer-open .drawer { transform: translateX(0); }
body.drawer-open { overflow: hidden; }

.drawer__head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: var(--space-3);
}
.drawer__title { font-weight: 700; letter-spacing: -.02em; }
.drawer__close {
    -webkit-appearance: none; appearance: none;
    border: none; background: var(--surface-2); color: var(--text);
    width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
    font-size: 20px; line-height: 1;
}
.drawer__close:hover { background: var(--border); }

.drawer nav ul { list-style: none; margin: 0; padding: 0; }
.drawer nav li { margin: 0; }
.drawer nav a {
    display: block;
    padding: .95rem .75rem;
    border-radius: 12px;
    color: var(--text);
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -.01em;
    transition: background .15s ease;
}
.drawer nav a:hover { background: var(--surface-2); opacity: 1; }
.drawer nav .current-menu-item > a { background: var(--accent-soft); color: var(--accent); }
.drawer nav .sub-menu { margin-left: .5rem; }
.drawer nav .sub-menu a { font-size: .98rem; font-weight: 500; color: var(--muted); }

.drawer__foot { margin-top: auto; padding-top: var(--space-3); }
.pwa-install {
    display: none;
    width: 100%;
    padding: .85rem 1rem;
    border: none; border-radius: 12px;
    background: var(--accent); color: var(--accent-ink);
    font-weight: 700; cursor: pointer;
}
.pwa-install.is-ready { display: block; }

/* =========================================================
   コンテンツ（通常の投稿・固定ページ）
   ========================================================= */
.entry {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: clamp(1.25rem, 4vw, 2.75rem);
}
.entry-header { margin-bottom: var(--space-3); }
.entry-title { font-size: clamp(1.5rem, 5vw, 2.1rem); margin: 0 0 .5rem; }
.entry-meta { color: var(--muted); font-size: .85rem; }

.entry-content > * + * { margin-top: 1.15em; }
.entry-content h2 { font-size: 1.5rem; margin-top: 2em; }
.entry-content h3 { font-size: 1.22rem; margin-top: 1.6em; }
.entry-content ul, .entry-content ol { padding-left: 1.4em; }
.entry-content img { border-radius: var(--radius-sm); }
.entry-content blockquote {
    margin: 1.5em 0; padding: .5em 1.2em;
    border-left: 3px solid var(--accent); color: var(--muted);
}
.entry-content a { color: var(--accent); }

/* 固定ページはショートコード主体のため枠を薄く（プラグインの .nechist が主役） */
.page .entry, .home .entry, .front .entry {
    background: transparent; border: none; box-shadow: none; padding: 0;
}

/* =========================================================
   ヒーロー（フロントページ）
   ========================================================= */
.hero {
    text-align: center;
    padding: var(--space-4) var(--space-2) var(--space-5);
    max-width: var(--content);
    margin-inline: auto;
}
.hero__title { font-size: clamp(1.8rem, 7vw, 3rem); margin: 0 0 .6rem; }
.hero__lead { color: var(--muted); font-size: clamp(1rem, 3.5vw, 1.15rem); margin: 0 auto; max-width: 34em; }

/* =========================================================
   フッター
   ========================================================= */
.site-footer {
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .85rem;
    text-align: center;
    padding: var(--space-4) var(--space-2) calc(var(--space-4) + var(--safe-b));
}
.site-footer a { color: var(--muted); }

/* =========================================================
   ユーティリティ
   ========================================================= */
.screen-reader-text {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 100;
    background: var(--accent); color: var(--accent-ink);
    padding: .6rem 1rem; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}
