/* ========================================
   Dart学習ノート - 共通スタイル
   PC・スマホ両対応の2カラムレイアウト
   ======================================== */

:root {
    --color-bg: #f5f6f8;
    --color-surface: #fff;
    --color-border: #e0e4e8;
    --color-text: #1a1d21;
    --color-text-muted: #5c6370;
    --color-accent: #02569b;
    --color-accent-hover: #0175c7;
    --color-menu-bg: #fff;
    --color-menu-current: #e3f2fd;
    --font-sans: 'Segoe UI', 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    --font-mono: 'Cascadia Code', 'Consolas', 'Monaco', monospace;
    --sidebar-width: 260px;
    --header-height: 72px;
    --content-max-width: 900px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
    --shadow-strong: 0 4px 12px rgba(0,0,0,.1);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ----- ヘッダー ----- */
.site-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.25rem;
}

.header-top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
}

.header-title-area {
    flex: 1;
    min-width: 0;
}

.header-search {
    display: flex;
    gap: .35rem;
    flex-shrink: 0;
}

.header-search-input {
    width: 160px;
    padding: .4rem .5rem;
    font-size: .9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.header-search-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.header-search-btn {
    padding: .4rem .75rem;
    font-size: .9rem;
    background: var(--color-accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

.header-search-btn:hover {
    background: var(--color-accent-hover);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

/* ハンバーガーボタン（PCでは非表示） */
.hamburger-btn {
    display: none;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
}

.hamburger-line {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text);
    border-radius: 1px;
    transition: transform .25s, opacity .25s;
}

.hamburger-btn[aria-expanded="true"] .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger-btn[aria-expanded="true"] .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-btn[aria-expanded="true"] .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.site-title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
}

.site-title a {
    color: var(--color-accent);
    text-decoration: none;
}

.site-title a:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

.site-desc {
    margin: .25rem 0 0;
    font-size: .875rem;
    color: var(--color-text-muted);
}

/* ----- 2カラムレイアウト ----- */
.layout-wrapper {
    flex: 1;
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    padding: 0;
}

/* 左カラム：メニュー */
.side-column {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--color-menu-bg);
    border-right: 1px solid var(--color-border);
    padding: 1.25rem .75rem;
    flex-shrink: 0;
}

.side-menu {
    position: sticky;
    top: calc(var(--header-height) + 1rem);
}

.menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.menu-item {
    margin: 0;
    border-radius: var(--radius);
}

.menu-item a {
    display: block;
    padding: .5rem .75rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: .9rem;
}

.menu-item a:hover {
    background: var(--color-bg);
    color: var(--color-accent);
}

.menu-item.is-current a {
    background: var(--color-menu-current);
    color: var(--color-accent);
    font-weight: 600;
}

/* 2階層メニュー：カテゴリ見出し */
.menu-category {
    margin: 0;
    margin-top: .75rem;
}

.menu-category:first-child {
    margin-top: 0;
}

.menu-category-label {
    display: block;
    padding: .4rem .75rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--color-text);
    border-left: 3px solid var(--color-accent);
    margin-bottom: .25rem;
    background: #e8eef2;
    border-radius: 0 var(--radius) 0 0;
}

.menu-sub-list {
    list-style: none;
    margin: 0;
    padding: 0 0 0 .5rem;
}

.menu-sub-list .menu-item a {
    padding: .4rem .6rem;
    font-size: .85rem;
}

/* 右カラム：コンテンツ */
.main-column {
    flex: 1;
    min-width: 0;
    padding: 1.5rem 1.75rem 2rem;
    background: var(--color-surface);
}

.main-column h1 {
    margin: 0 0 1rem;
    font-size: 1.6rem;
    border-bottom: 2px solid var(--color-accent);
    padding-bottom: .5rem;
}

.main-column h2 {
    margin: 1.75rem 0 .75rem;
    font-size: 1.2rem;
    color: var(--color-text);
}

.main-column h3 {
    margin: 1.25rem 0 .5rem;
    font-size: 1.05rem;
}

.main-column p {
    margin: 0 0 1rem;
}

.main-column ul, .main-column ol {
    margin: 0 0 1rem;
    padding-left: 1.5rem;
}

/* ----- Dartソースコード表示（見やすく） ----- */
.code-block-wrap {
    margin: 1rem 0 1.5rem;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-strong);
    border: 1px solid var(--color-border);
    position: relative;
}

.code-block-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    background: #2d2d2d;
    color: #ccc;
    font-size: .8rem;
    padding: .35rem .75rem;
    font-family: var(--font-mono);
    border-bottom: 1px solid #444;
}

.code-block-title {
    flex: 1;
    min-width: 0;
}

.code-block-copy {
    flex-shrink: 0;
    padding: .25rem .5rem;
    font-size: .75rem;
    background: #444;
    color: #ccc;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-sans);
}

.code-block-copy:hover {
    background: #555;
    color: #fff;
}

.code-block-copy.copied {
    background: #2d5a2d;
    border-color: #3d6a3d;
    color: #fff;
}

.code-block-wrap pre {
    margin: 0;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    font-size: .875rem;
    line-height: 1.55;
    min-height: 3em;
}

.code-block-wrap pre code {
    font-family: var(--font-mono);
    background: none !important;
    padding: 0 !important;
}

/* Prism テーマ調整（行番号なし時用） */
pre[class*="language-"] {
    margin: 1rem 0 1.5rem;
    border-radius: var(--radius);
    overflow-x: auto;
    padding: 1rem 1.25rem !important;
    font-size: .875rem !important;
    line-height: 1.55 !important;
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow);
}

code[class*="language-"] {
    font-family: var(--font-mono) !important;
}

/* インラインコード */
.main-column code:not([class*="language-"]) {
    background: var(--color-bg);
    padding: .15em .4em;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: .9em;
}

/* ----- 出力結果ブロック ----- */
.code-output-wrap {
    margin: 0 0 1.5rem;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #f8f9fa;
}

.code-output-label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    padding: .4rem .75rem;
    background: #e9ecef;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}

.code-output-wrap pre,
.code-output-wrap .code-output-body {
    margin: 0;
    padding: .75rem 1rem;
    font-size: .875rem;
    font-family: var(--font-mono);
    line-height: 1.5;
    color: var(--color-text);
    overflow-x: auto;
}

/* ----- ポイント・注意点の囲み枠 ----- */
.note {
    margin: 1rem 0 1.5rem;
    padding: .75rem 1rem;
    border-radius: var(--radius);
    border-left: 4px solid;
    font-size: .95rem;
}

.note-title {
    font-weight: 600;
    margin-bottom: .35rem;
}

.note-point {
    background: #f0f7ff;
    border-left-color: var(--color-accent);
}

.note-point .note-title {
    color: var(--color-accent);
}

.note-attention {
    background: #fff8e6;
    border-left-color: #e6a800;
}

.note-attention .note-title {
    color: #b38600;
}

.note-tip {
    background: #f0fff4;
    border-left-color: #2e7d32;
}

.note-tip .note-title {
    color: #1b5e20;
}

/* ----- 前へ / 次へ ----- */
.prevnext {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.prevnext-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
}

.prevnext-btn {
    display: inline-block;
    padding: .5rem .75rem;
    font-size: .9rem;
    background: var(--color-bg);
    color: var(--color-accent);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    text-decoration: none;
    max-width: 48%;
}

.prevnext-btn:hover {
    background: var(--color-menu-current);
    border-color: var(--color-accent);
}

.prevnext-btn.is-disabled {
    color: var(--color-text-muted);
    cursor: default;
}

.prevnext-next {
    margin-left: auto;
    text-align: right;
}

/* ----- 検索ページ ----- */
.search-form {
    display: flex;
    gap: .5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 200px;
    padding: .5rem .75rem;
    font-size: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.search-input:focus {
    outline: none;
    border-color: var(--color-accent);
}

.search-submit {
    padding: .5rem 1rem;
    font-size: 1rem;
    background: var(--color-accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

.search-submit:hover {
    background: var(--color-accent-hover);
}

.search-result-count {
    margin-bottom: 1rem;
    color: var(--color-text-muted);
}

.search-result-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.search-result-list li {
    margin: .5rem 0;
    padding: .5rem 0;
    border-bottom: 1px solid var(--color-border);
}

.search-result-list a {
    color: var(--color-accent);
    text-decoration: none;
}

.search-result-list a:hover {
    text-decoration: underline;
}

/* ----- フッター ----- */
.site-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    margin-top: auto;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: .75rem 1.25rem;
    text-align: center;
    font-size: .8rem;
    color: var(--color-text-muted);
}

/* ----- オーバーレイ（スマホでメニュー背面） ----- */
.menu-overlay {
    display: none;
}

/* ----- レスポンシブ：スマホ（ハンバーガーメニュー） ----- */
@media (max-width: 768px) {
    .hamburger-btn {
        display: flex;
    }

    .header-top {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
    }

    .header-title-area {
        flex: 1;
        min-width: 0;
    }

    .header-search {
        width: 100%;
        order: 3;
    }

    .header-search-input {
        flex: 1;
        width: auto;
    }

    .layout-wrapper {
        flex-direction: column;
    }

    .prevnext-btn {
        max-width: 100%;
    }

    /* スマホ：メニューは左からスライドするドロワー、初期は非表示 */
    .side-column {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(280px, 85vw);
        min-width: 0;
        max-width: 280px;
        padding: 1rem .75rem 2rem;
        border-right: 1px solid var(--color-border);
        box-shadow: 4px 0 12px rgba(0,0,0,.15);
        z-index: 200;
        transform: translateX(-100%);
        transition: transform .25s ease-out;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.menu-open .side-column {
        transform: translateX(0);
    }

    .menu-overlay {
        display: none;
    }

    body.menu-open .menu-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,.4);
        z-index: 150;
        animation: overlay-fade-in .2s ease-out;
    }

    @keyframes overlay-fade-in {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    .side-menu {
        position: static;
    }

    .menu-category-label {
        font-size: .75rem;
        padding: .3rem .6rem;
    }

    .menu-sub-list {
        padding-left: .4rem;
    }

    .menu-item a,
    .menu-sub-list .menu-item a {
        padding: .35rem .6rem;
        font-size: .8rem;
    }

    /* メニュー開時は本文スクロール防止 */
    body.menu-open {
        overflow: hidden;
    }

    .main-column {
        padding: 1rem 1rem 1.5rem;
    }

    .main-column h1 {
        font-size: 1.35rem;
    }

    .code-block-wrap pre,
    pre[class*="language-"] {
        padding: .75rem 1rem !important;
        font-size: .8rem !important;
        margin-left: -1rem;
        margin-right: -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .code-block-wrap {
        margin-left: -1rem;
        margin-right: -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .header-inner {
        padding: .75rem 1rem;
    }

    .site-title {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .menu-category-label {
        font-size: .7rem;
    }
}
