/* Single Note Page — Seven Scribes */

/* ── Layout ── */
.note-single-page { padding: 0; }
.note-page-layout { display: flex; min-height: calc(100vh - 72px); position: relative; }

/* ── Sidebar ── */
.note-sidebar {
    width: 260px; flex: 0 0 260px;
    background: var(--card-bg-color, #f9f9f9);
    border-right: 1px solid var(--border-color);
    position: sticky; top: 72px;
    height: calc(100vh - 72px);
    overflow: hidden; display: flex; flex-direction: column;
    z-index: 50; transition: transform 0.3s ease;
}
.note-sidebar-inner { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.sidebar-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 14px; border-bottom: 1px solid var(--border-color);
    background: var(--background-color); flex-shrink: 0;
}
.sidebar-lang-badge { display: flex; align-items: center; gap: 10px; }
.sidebar-lang-emoji { font-size: 1.5rem; line-height: 1; }
.sidebar-lang-badge strong { display: block; font-size: 0.95rem; font-weight: 700; color: var(--text-color); }
.sidebar-lang-count { font-size: 0.75rem; color: var(--text-color); opacity: 0.55; }
.sidebar-close-btn { display: none; background: none; border: none; cursor: pointer; color: var(--text-color); padding: 4px; border-radius: 6px; }
.sidebar-close-btn:hover { background: var(--border-color); }

.sidebar-search-wrap { position: relative; padding: 10px 12px; border-bottom: 1px solid var(--border-color); flex-shrink: 0; }
.sidebar-search { width: 100%; padding: 7px 30px 7px 10px; border: 1px solid var(--border-color); border-radius: 7px; font-size: 0.82rem; background: var(--background-color); color: var(--text-color); outline: none; box-sizing: border-box; }
.sidebar-search:focus { border-color: var(--primary-color); }
.sidebar-search-wrap svg { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); opacity: 0.4; pointer-events: none; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sidebar-topics-list { list-style: none; margin: 0; padding: 0; }

.sidebar-topic-item { margin: 0; }
.sidebar-topic-row { display: flex; align-items: stretch; }
.sidebar-topic-link {
    flex: 1; display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; text-decoration: none; color: var(--text-color);
    font-size: 0.85rem; border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.15s;
}
.sidebar-topic-link:hover { background: rgba(52,152,219,0.07); border-left-color: var(--primary-color); color: var(--text-color); }
.sidebar-topic-item.active > .sidebar-topic-row > .sidebar-topic-link,
.sidebar-topic-item.has-active-child > .sidebar-topic-row > .sidebar-topic-link {
    background: rgba(52,152,219,0.1); border-left-color: var(--primary-color); font-weight: 600;
}
.sidebar-topic-item.active > .sidebar-topic-row > .sidebar-topic-link { color: var(--primary-color); }
.sidebar-topic-num { font-size: 0.72rem; font-weight: 700; color: var(--primary-color); opacity: 0.5; min-width: 22px; font-variant-numeric: tabular-nums; }
.sidebar-topic-title { line-height: 1.35; }
.sidebar-expand-btn {
    width: 34px; background: none; border: none; border-left: 1px solid var(--border-color);
    cursor: pointer; color: var(--text-color); opacity: 0.5;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: opacity 0.15s;
}
.sidebar-expand-btn:hover { opacity: 1; }
.sidebar-expand-btn svg { transition: transform 0.25s; }
.sidebar-topic-item.open .sidebar-expand-btn svg { transform: rotate(180deg); }

.sidebar-subtopics-list { list-style: none; margin: 0; padding: 0; background: rgba(0,0,0,0.02); }
.sidebar-sub-item {}
.sidebar-sub-link {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 12px 6px 36px; text-decoration: none;
    font-size: 0.8rem; color: var(--text-color); opacity: 0.7;
    border-left: 3px solid transparent; transition: all 0.15s;
}
.sidebar-sub-link:hover { opacity: 1; background: rgba(52,152,219,0.07); border-left-color: var(--primary-color); color: var(--text-color); }
.sidebar-sub-item.active .sidebar-sub-link { opacity: 1; color: var(--primary-color); font-weight: 600; border-left-color: var(--primary-color); background: rgba(52,152,219,0.08); }

/* ── Mobile top bar ── */
.note-mobile-bar { display: none; align-items: center; gap: 12px; padding: 10px 16px; background: var(--background-color); border-bottom: 1px solid var(--border-color); position: sticky; top: 72px; z-index: 40; }
.mobile-sidebar-toggle { display: flex; align-items: center; gap: 6px; padding: 7px 12px; background: var(--primary-color); color: #fff; border: none; border-radius: 7px; font-size: 0.82rem; font-weight: 600; cursor: pointer; flex-shrink: 0; }
.mobile-breadcrumb { font-size: 0.78rem; color: var(--text-color); opacity: 0.65; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-breadcrumb a { color: var(--primary-color); text-decoration: none; }

/* ── Sidebar overlay ── */
.note-sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 49; }
.note-sidebar-overlay.active { display: block; }

/* ── Main content wrap ── */
.note-main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.note-article { max-width: 900px; width: 100%; margin: 0 auto; padding: 48px 60px 80px; }

/* ── Right Ad Sidebar ── */
.note-ad-sidebar {
    width: 300px; flex: 0 0 300px;
    border-left: 1px solid var(--border-color);
    background: var(--card-bg-color, #f9f9f9);
    position: sticky; top: 72px;
    height: calc(100vh - 72px);
    overflow-y: auto; padding: 24px;
    display: none; /* hidden by default on small screens */
}
.note-ad-inner { width: 100%; height: 100%; display: flex; flex-direction: column; }
.ad-placeholder-box {
    width: 100%; min-height: 400px; background: rgba(0,0,0,0.03);
    border: 1px dashed var(--border-color); border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-color); opacity: 0.5; font-size: 0.85rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
}
body.dark-theme .ad-placeholder-box { background: rgba(255,255,255,0.02); }
body.dark-theme .note-ad-sidebar { background: #1e1e1e; border-left-color: #333; }

@media (min-width: 1300px) {
    .note-ad-sidebar { display: block; }
}

/* ── Breadcrumb ── */
.note-breadcrumb { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.8rem; margin-bottom: 18px; color: var(--text-color); opacity: 0.6; }
.note-breadcrumb a { color: var(--primary-color); text-decoration: none; }
.note-breadcrumb a:hover { text-decoration: underline; }
.note-breadcrumb span { opacity: 0.7; }

/* ── Article header ── */
.note-title { font-size: 2rem; font-weight: 800; line-height: 1.25; color: var(--text-color); margin: 0 0 18px; }

.note-meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 30px; }
.note-meta-tag { display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; text-decoration: none; }
.note-meta-tag.lang-tag { background: rgba(52,152,219,0.1); color: var(--primary-color); border: 1px solid rgba(52,152,219,0.25); }
.note-meta-tag.lang-tag:hover { background: rgba(52,152,219,0.18); }
.note-meta-tag.cat-tag { background: rgba(46,204,113,0.1); color: var(--secondary-color); border: 1px solid rgba(46,204,113,0.25); }
.note-meta-tag.diff-beginner { background: rgba(46,204,113,0.12); color: #27ae60; border: 1px solid rgba(46,204,113,0.3); }
.note-meta-tag.diff-intermediate { background: rgba(241,196,15,0.12); color: #d4ac0d; border: 1px solid rgba(241,196,15,0.3); }
.note-meta-tag.diff-advanced { background: rgba(231,76,60,0.1); color: #c0392b; border: 1px solid rgba(231,76,60,0.25); }
.note-meta-tag.read-time { background: var(--border-color); color: var(--text-color); opacity: 0.75; border: 1px solid transparent; }

/* ── Table of Contents ── */
.note-toc { background: var(--card-bg-color); border: 1px solid var(--border-color); border-left: 3px solid var(--primary-color); border-radius: 8px; padding: 16px 20px; margin-bottom: 32px; }
.note-toc-header { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 0.9rem; color: var(--text-color); margin-bottom: 12px; }
.toc-toggle-btn { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--text-color); padding: 2px; transition: transform 0.2s; }
.toc-toggle-btn.rotated svg { transform: rotate(180deg); }
.note-toc-list { margin: 0; padding: 0 0 0 18px; list-style: decimal; }
.note-toc-list.toc-collapsed { display: none; }
.note-toc-list li { margin: 4px 0; font-size: 0.85rem; }
.note-toc-list li a { color: var(--primary-color); text-decoration: none; }
.note-toc-list li a:hover { text-decoration: underline; }
.note-toc-list .toc-h3 { margin-left: 16px; list-style: disc; font-size: 0.8rem; opacity: 0.85; }

/* ── Content Body ── */
.note-content-body { font-size: 1rem; line-height: 1.8; color: var(--text-color); }

/* Inline Ads */
.content-inline-ad {
    margin: 32px 0 !important;
    clear: both !important;
    overflow: hidden !important;
    width: 100% !important;
    display: block !important;
    position: relative !important;
    z-index: 1 !important;
}
.content-inline-ad ins.adsbygoogle {
    display: block !important;
    min-height: 90px !important;
    width: 100% !important;
    margin: 0 auto !important;
}

/* Headings */
.note-content-body h1 { font-size: 1.7rem; font-weight: 800; margin: 40px 0 16px; padding-bottom: 10px; border-bottom: 2px solid var(--border-color); color: var(--text-color); }
.note-content-body h2 { font-size: 1.4rem; font-weight: 700; margin: 36px 0 14px; padding-bottom: 8px; border-bottom: 2px solid var(--primary-color); color: var(--text-color); position: relative; }
.note-content-body h2::after { content: ''; position: absolute; left: 0; bottom: -2px; width: 50px; height: 2px; background: var(--secondary-color); }
.note-content-body h3 { font-size: 1.15rem; font-weight: 700; margin: 28px 0 12px; padding-left: 14px; border-left: 4px solid var(--primary-color); color: var(--text-color); }
.note-content-body h4 { font-size: 1.05rem; font-weight: 700; margin: 22px 0 10px; color: var(--text-color); }
.note-content-body h5, .note-content-body h6 { font-size: 0.95rem; font-weight: 700; margin: 18px 0 8px; color: var(--text-color); opacity: 0.8; }

/* Paragraphs */
.note-content-body p { margin: 0 0 18px; }

/* Links */
.note-content-body a { color: var(--primary-color); text-decoration: none; border-bottom: 1px solid rgba(52,152,219,0.35); transition: border-color 0.15s; font-weight: 500; }
.note-content-body a:hover { border-bottom-color: var(--primary-color); }

/* Inline code */
.note-content-body code { background: rgba(52,152,219,0.08); color: #c7254e; padding: 2px 7px; border-radius: 4px; font-family: 'Fira Code', 'Courier New', monospace; font-size: 0.9em; border: 1px solid rgba(52,152,219,0.15); }
body.dark-theme .note-content-body code { background: rgba(255,255,255,0.07); color: #f97316; border-color: rgba(255,255,255,0.1); }

/* Code blocks */
.code-block-wrap { margin: 24px 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--border-color); box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.code-block-header { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; background: #eef1f5; border-bottom: 1px solid var(--border-color); }
.code-lang-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #5c6370; }
.copy-code-btn { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; background: #fff; color: #5c6370; border: 1px solid #d1d5da; border-radius: 5px; font-size: 0.75rem; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.copy-code-btn:hover { background: #f6f8fa; color: #24292e; }
.code-block-wrap pre { margin: 0; border-radius: 0; border: none; background: #f6f8fa; color: #24292e; padding: 20px; font-family: 'Fira Code', 'JetBrains Mono', 'Courier New', monospace; font-size: 0.9rem; line-height: 1.65; overflow-x: auto; tab-size: 4; box-shadow: none; }
.code-block-wrap pre code { background: transparent; color: inherit; padding: 0; border: none; font-size: inherit; text-shadow: none; }

/* Prism Syntax Highlighting - Light Theme (GitHub style) */
.token.comment, .token.prolog, .token.doctype, .token.cdata { color: #6a737d; font-style: italic; }
.token.punctuation { color: #24292e; }
.token.namespace { opacity: .7; }
.token.property, .token.tag, .token.boolean, .token.number, .token.constant, .token.symbol, .token.deleted { color: #005cc5; }
.token.selector, .token.attr-name, .token.string, .token.char, .token.builtin, .token.inserted { color: #032f62; }
.token.operator, .token.entity, .token.url, .language-css .token.string, .style .token.string { color: #d73a49; }
.token.atrule, .token.attr-value, .token.keyword { color: #d73a49; }
.token.function, .token.class-name { color: #6f42c1; }
.token.regex, .token.important, .token.variable { color: #e36209; }

/* Lists */
.note-content-body ul, .note-content-body ol { margin: 0 0 18px; padding-left: 28px; }
.note-content-body li { margin: 6px 0; line-height: 1.7; }
.note-content-body ul li::marker { color: var(--primary-color); }
.note-content-body ol li::marker { color: var(--primary-color); font-weight: 700; }
.note-content-body ul ul, .note-content-body ol ol { margin: 4px 0; }

/* Blockquote */
.note-content-body blockquote { margin: 24px 0; padding: 16px 20px; background: rgba(52,152,219,0.06); border-left: 4px solid var(--primary-color); border-radius: 0 8px 8px 0; color: var(--text-color); font-style: italic; }
.note-content-body blockquote p:last-child { margin: 0; }
.note-content-body blockquote strong { color: var(--primary-color); font-style: normal; }

/* Tables */
.note-content-body table, .note-content-body .wp-block-table { width: 100%; border-collapse: collapse; margin: 24px 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-color); font-size: 0.9rem; }
.note-content-body th, .note-content-body thead td, .note-content-body .wp-block-table th { background: #2186c4 !important; color: #fff !important; padding: 12px 14px; text-align: left; font-weight: 700; font-size: 0.85rem; }
.note-content-body td { padding: 10px 14px; border-bottom: 1px solid var(--border-color); }
.note-content-body tr:last-child td { border-bottom: none; }
.note-content-body tr:nth-child(even) td { background: rgba(52,152,219,0.04); }

/* Images */
.note-content-body img { max-width: 100% !important; height: auto !important; border-radius: 8px; margin: 20px 0; border: 1px solid var(--border-color); display: block; box-sizing: border-box; }
.note-content-body figure { margin: 24px 0; max-width: 100% !important; overflow: hidden; }
.note-content-body figcaption { font-size: 0.82rem; color: var(--text-color); opacity: 0.6; text-align: center; margin-top: 8px; font-style: italic; }

/* iframes / embeds in content */
.note-embed-wrap { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; margin: 24px 0; border-radius: 8px; border: 1px solid var(--border-color); }
.note-embed-wrap iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }

/* Buttons in content (WP classes) */
.note-content-body .wp-block-button__link,
.note-content-body .button {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 22px; border-radius: 7px; font-size: 0.9rem; font-weight: 700;
    text-decoration: none; cursor: pointer; transition: all 0.18s; border: none;
    background: var(--primary-color); color: #fff;
}
.note-content-body .wp-block-button__link:hover,
.note-content-body .button:hover { transform: translateY(-2px); box-shadow: 0 4px 14px rgba(52,152,219,0.35); color: #fff; border-bottom: none; }

/* Multi-column layout support */
.note-content-body .wp-block-columns { gap: 24px; margin: 24px 0; }
.note-content-body .wp-block-column { min-width: 0; }

/* Callout / notice boxes */
.note-content-body .wp-block-notice,
.note-content-body .notice,
.note-content-body .callout {
    padding: 14px 18px; border-radius: 8px; margin: 20px 0;
    border-left: 4px solid var(--primary-color); background: rgba(52,152,219,0.07);
}

/* HR */
.note-content-body hr { border: none; border-top: 2px solid var(--border-color); margin: 36px 0; }

/* ── YouTube Video block ── */
.note-video-block { margin: 32px 0; border-radius: 10px; overflow: hidden; border: 1px solid var(--border-color); }
.note-video-label { display: flex; align-items: center; gap: 8px; padding: 10px 16px; background: var(--card-bg-color); font-size: 0.85rem; font-weight: 700; color: var(--text-color); border-bottom: 1px solid var(--border-color); }
.note-video-wrap { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; }
.note-video-wrap iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }

/* ── GitHub block ── */
.note-github-block { display: flex; align-items: center; gap: 10px; padding: 14px 18px; background: var(--card-bg-color); border: 1px solid var(--border-color); border-radius: 8px; margin: 24px 0; font-size: 0.9rem; }
.note-github-block a { color: var(--text-color); font-weight: 700; text-decoration: none; border-bottom: none; }
.note-github-block a:hover { color: var(--primary-color); }

/* ── Prev/Next nav ── */
.note-nav-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 48px; padding-top: 28px; border-top: 1px solid var(--border-color); }
.note-nav-btn { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--card-bg-color); border: 1px solid var(--border-color); border-radius: 10px; text-decoration: none; color: var(--text-color); transition: all 0.18s; }
.note-nav-btn:hover { border-color: var(--primary-color); background: rgba(52,152,219,0.05); color: var(--text-color); }
.note-nav-btn.next-btn { text-align: right; justify-content: flex-end; flex-direction: row-reverse; }
.note-nav-btn span { display: flex; flex-direction: column; gap: 2px; }
.note-nav-btn small { font-size: 0.72rem; opacity: 0.55; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.note-nav-btn strong { font-size: 0.88rem; font-weight: 700; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.note-nav-btn svg { flex-shrink: 0; color: var(--primary-color); }

/* ── Dark theme overrides ── */
body.dark-theme .note-sidebar { background: #1e1e1e; border-right-color: #333; }
body.dark-theme .sidebar-header { background: #252525; }
body.dark-theme .sidebar-subtopics-list { background: rgba(255,255,255,0.02); }
body.dark-theme .note-content-body th { background: #2186c4; }
body.dark-theme .code-block-wrap { border-color: #333; }

body.dark-theme .code-block-header { background: #1e2029; border-bottom: 1px solid #333; }
body.dark-theme .code-block-wrap pre { background: #282c34; color: #abb2bf; }
body.dark-theme .code-lang-label { color: #abb2bf; }
body.dark-theme .copy-code-btn { background: rgba(255,255,255,0.08); color: #abb2bf; border-color: rgba(255,255,255,0.12); }
body.dark-theme .copy-code-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* Prism Syntax Highlighting - Dark Theme (One Dark style) */
body.dark-theme .token.comment, body.dark-theme .token.prolog, body.dark-theme .token.doctype, body.dark-theme .token.cdata { color: #5c6370; font-style: italic; }
body.dark-theme .token.punctuation { color: #abb2bf; }
body.dark-theme .token.property, body.dark-theme .token.tag, body.dark-theme .token.boolean, body.dark-theme .token.number, body.dark-theme .token.constant, body.dark-theme .token.symbol, body.dark-theme .token.deleted { color: #d19a66; }
body.dark-theme .token.selector, body.dark-theme .token.attr-name, body.dark-theme .token.string, body.dark-theme .token.char, body.dark-theme .token.builtin, body.dark-theme .token.inserted { color: #98c379; }
body.dark-theme .token.operator, body.dark-theme .token.entity, body.dark-theme .token.url, body.dark-theme .language-css .token.string, body.dark-theme .style .token.string { color: #56b6c2; }
body.dark-theme .token.atrule, body.dark-theme .token.attr-value, body.dark-theme .token.keyword { color: #c678dd; }
body.dark-theme .token.function, body.dark-theme .token.class-name { color: #61afef; }
body.dark-theme .token.regex, body.dark-theme .token.important, body.dark-theme .token.variable { color: #e06c75; }

/* ── Responsive ── */
@media (max-width: 1024px) {
    .note-sidebar { width: 220px; flex: 0 0 220px; }
    .note-article { padding: 36px 40px 60px; margin: 0 auto; }
}

@media (max-width: 768px) {
    .note-sidebar {
        position: fixed; top: 72px; left: 0; bottom: 0; width: 280px;
        height: calc(100vh - 72px); z-index: 200;
        transform: translateX(-100%); box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }
    .note-sidebar.open { transform: translateX(0); }
    .sidebar-close-btn { display: flex; }
    
    .note-mobile-bar { display: block; padding: 0; border: none; background: transparent; position: static; }
    .mobile-breadcrumb, .note-breadcrumb { display: none !important; }
    
    .mobile-sidebar-toggle {
        position: fixed; bottom: 24px; left: 20px; z-index: 99;
        padding: 12px 20px; border-radius: 50px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.25);
        font-size: 0.95rem; display: flex; align-items: center;
    }

    .note-article { padding: 24px 20px 48px; margin: 0 auto; }
    .note-title { font-size: 1.5rem; margin-top: 10px; }
    .note-nav-footer { grid-template-columns: 1fr; }
    .note-nav-btn.next-btn { flex-direction: row; text-align: left; justify-content: flex-start; }
    .note-content-body h1 { font-size: 1.35rem; }
    .note-content-body h2 { font-size: 1.15rem; }
    .code-block-wrap pre { font-size: 0.82rem; padding: 16px; }
}

@media (max-width: 480px) {
    .note-article { padding: 16px 14px 40px; margin: 0 auto; }
    .note-title { font-size: 1.3rem; }
    .note-meta-row { gap: 5px; }
    .note-meta-tag { font-size: 0.72rem; padding: 3px 10px; }
}
