/* ===== Base Styles ===== */
:root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --accent-primary: #4a9eff;
    --accent-hover: #6bb0ff;
    --border-color: #3a3a3a;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 {
    font-size: 2rem;
    margin: 0 0 2rem 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

h2 {
    font-size: 1.5rem;
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

h3 {
    font-size: 1.25rem;
    margin: 1.5rem 0 0.75rem 0;
}

h4 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem 0; }
h5 { font-size: 1rem; margin: 1rem 0 0.5rem 0; }
h6 { font-size: 0.95rem; margin: 1rem 0 0.5rem 0; }

/* Page title uses same style as h1 */

p {
    margin-bottom: 1rem;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--accent-hover);
}

/* ===== Header ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
}

.header-content {
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo a {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent-primary);
    text-decoration: none;
}

.logo a:hover {
    color: var(--accent-hover);
}

.language-switcher {
    display: flex;
    gap: 1rem;
}

.lang-switch-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    background-color: transparent;
    transition: all 0.2s;
}

.lang-switch-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ===== Breadcrumb Bar ===== */
.breadcrumb-bar {
    position: sticky;
    top: 0;
    z-index: 999;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 0;
}

.breadcrumb-content {
    padding: 0 1.5rem;
}

/* ===== Breadcrumb ===== */
.breadcrumb {
    margin-bottom: 0;
    padding: 0;
    font-size: 0.85rem;
}

.breadcrumb ol {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
    margin: 0;
    padding: 0;
}

.breadcrumb li:not(:last-child)::after {
    content: "›";
    margin-left: 0.35rem;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--accent-primary);
}

.breadcrumb li.active {
    color: var(--text-secondary);
}

/* ===== Page Layout (3-column: Nav | TOC | Content) ===== */
.page-layout {
    display: flex;
    min-height: calc(100vh - 60px);
}

/* --- Navigation Sidebar (left) --- */
.nav-sidebar {
    flex: 0 0 220px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.nav-sidebar-content {
    padding: 1rem 0;
}

.nav-category {
    margin-bottom: 0.25rem;
}

.nav-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.5rem 1rem;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s;
}

.nav-category-header:hover {
    background: rgba(255, 255, 255, 0.04);
}

.nav-category-header::before {
    content: "▸";
    display: inline-block;
    margin-right: 0.4rem;
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.nav-category-header.expanded::before {
    transform: rotate(90deg);
}

.nav-category-count {
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.06);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    font-weight: 400;
}

.nav-tool-list {
    list-style: none;
    margin: 0;
    padding: 0 0 0.25rem 0;
}

.nav-tool-list li {
    margin: 0;
}

.nav-tool-link {
    display: block;
    padding: 0.3rem 1rem 0.3rem 2rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}

.nav-tool-link:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.nav-tool-link.active {
    color: var(--accent-primary);
    background: rgba(74, 158, 255, 0.08);
    border-left-color: var(--accent-primary);
    font-weight: 600;
}

/* Mobile nav toggle button */
.nav-toggle-btn {
    display: none;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-toggle-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Mobile nav overlay backdrop */
.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1499;
}

.nav-overlay.active {
    display: block;
}

/* --- TOC Sidebar (middle) --- */
.toc-sidebar {
    flex: 0 0 200px;
    border-right: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.toc-wrapper {
    padding: 1.25rem;
}

.toc-wrapper h2 {
    font-size: 0.9rem;
    margin: 0 0 0.75rem 0;
    padding-bottom: 0;
    border-bottom: none;
    color: var(--text-primary);
}

.toc-wrapper ul {
    list-style: none;
    padding-left: 0;
}

.toc-wrapper li {
    margin: 0.3rem 0;
}

.toc-wrapper li ul {
    padding-left: 0.85rem;
    margin-top: 0.2rem;
}

.toc-wrapper a {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.toc-wrapper a:hover {
    color: var(--accent-primary);
}

/* --- Content Area (right) --- */
.content-area {
    flex: 1;
    min-width: 0;
    padding: 2rem 2.5rem;
}

.main-content {
    min-width: 0;
}

/* Legacy content-wrapper (unused in new layout but kept for safety) */
.content-wrapper {
    display: flex;
    gap: 2rem;
}

/* ===== Page Navigation (prev/next) ===== */
.page-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    gap: 1rem;
}

.page-nav-link {
    display: block;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    max-width: 45%;
    transition: border-color 0.2s;
}

.page-nav-link:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.page-nav-prev::before {
    content: "\2190  ";
}

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

.page-nav-next::after {
    content: "  \2192";
}

.page-nav-spacer {
    flex: 1;
}

/* ===== Code Blocks ===== */
code {
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 0.9em;
    background-color: var(--bg-secondary);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    color: #e06c75;
}

pre {
    background-color: #282c34;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0;
    overflow-x: auto;
    margin: 1.5em 0;
}

pre code {
    background-color: transparent;
    padding: 1rem;
    display: block;
    color: inherit;
}

/* highlight.js のスタイル調整 */
pre code.hljs {
    padding: 1rem;
    border-radius: 6px;
}

/* ===== Images ===== */
img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 1.5em 0;
}

/* Inline SVG icons - aligned with text */
img[src$=".svg"] {
    display: inline-block;
    vertical-align: middle;
    margin: 0 0.25em;
    height: 1.2em;
    width: auto;
    border-radius: 0;
}

/* SVG icons in table cells - slightly larger */
td img[src$=".svg"] {
    height: 1.5em;
}

/* Hide figure captions (alt text should not be displayed as caption) */
figure {
    margin: 1.5em 0;
}

figcaption {
    display: none;
}

/* ===== Tables ===== */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    background-color: var(--bg-secondary);
    border-radius: 6px;
    overflow: hidden;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: #2a2a2a;
    font-weight: 600;
    color: var(--text-primary);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background-color: #2a2a2a;
}

/* ===== Lists ===== */
ul, ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

li {
    margin: 0.5rem 0;
}

/* ===== Blockquotes ===== */
blockquote {
    margin: 1.5em 0;
    padding: 1rem 1.5rem;
    border-left: 4px solid var(--accent-primary);
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: 4px;
}

/* ===== Index Page Specific ===== */
.index-page {
    max-width: 1200px;
}

.category-section {
    margin-bottom: 2rem;
}

.category-section h2 {
    font-size: 1.25rem;
    margin-top: 0;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.category-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    align-items: start;
}

.tool-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0;
    transition: border-color 0.2s;
    position: relative;
    overflow: hidden;
}

.tool-card-header {
    padding: 0.5rem 1rem 0.35rem;
}

.tool-card-body {
    padding: 0.35rem 1rem 0.75rem;
}

.tool-card.has-doc {
    cursor: pointer;
}

.tool-card:hover {
    border-color: var(--accent-primary);
}

.tool-card h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.tool-card h3 a {
    color: var(--text-primary);
    text-decoration: none;
}

.tool-card h3 a:hover {
    color: var(--accent-primary);
}

.tool-card-thumb {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    margin: 0;
    border-radius: 0;
}

.tool-description {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
    margin: 0;
}

.tool-version {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background-color: #2a2a2a;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.tool-card:not(.has-doc) {
    opacity: 0.5;
}

.tool-card:not(.has-doc) h3 {
    color: var(--text-secondary);
}

/* ===== Footer ===== */
.site-footer {
    margin-top: 3rem;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ===== Responsive Design ===== */
@media (max-width: 1200px) {
    .toc-sidebar {
        display: none;
    }
}

@media (max-width: 1024px) {
    .content-area {
        padding: 1.5rem;
    }

    .tool-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .nav-toggle-btn {
        display: block;
    }

    .nav-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1500;
    }

    .nav-sidebar.open {
        transform: translateX(0);
    }

    .content-area {
        padding: 1.5rem 1rem;
    }

    .header-content {
        padding: 0 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.35rem;
    }

    .category-section h2 {
        font-size: 1.35rem;
    }

    .tool-grid {
        grid-template-columns: 1fr;
    }

    .breadcrumb {
        font-size: 0.8rem;
    }

    .page-nav-link {
        max-width: 50%;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .header-content {
        flex-direction: column;
        gap: 0.75rem;
    }

    .logo a {
        font-size: 1.25rem;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }
}

/* ===== Header Actions ===== */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* ===== Search Trigger Button ===== */
.search-trigger-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.search-trigger-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.search-trigger-btn svg {
    flex-shrink: 0;
}

.search-shortcut-hint {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* ===== Search Overlay ===== */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    padding-top: 15vh;
}

.search-overlay.active {
    display: flex;
}

.search-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 100%;
    max-width: 580px;
    max-height: 60vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    align-self: flex-start;
}

.search-input-wrapper {
    display: flex;
    align-items: center;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border-color);
}

.search-input-icon {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.search-input {
    width: 100%;
    padding: 0.9rem 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-results {
    overflow-y: auto;
    padding: 0.5rem;
}

.search-result-item {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.1s;
}

.search-result-item:hover,
.search-result-item.active {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.search-result-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-result-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.search-result-category {
    font-size: 0.7rem;
    padding: 0.1rem 0.45rem;
    background: rgba(74, 158, 255, 0.15);
    color: var(--accent-primary);
    border-radius: 3px;
    flex-shrink: 0;
}

.search-result-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
    line-height: 1.4;
}

.search-result-snippet {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
    line-height: 1.4;
    opacity: 0.8;
}

.search-highlight {
    background: rgba(74, 158, 255, 0.25);
    color: var(--accent-hover);
    border-radius: 2px;
    padding: 0 1px;
}

/* Page-level search highlight (after navigation from search) */
.search-page-highlight {
    background: rgba(255, 193, 7, 0.35);
    color: var(--text-primary);
    border-radius: 2px;
    padding: 1px 2px;
    outline: 2px solid rgba(255, 193, 7, 0.5);
}

.search-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== Back to Top Button ===== */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 998;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, border-color 0.2s, color 0.2s;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* ===== Heading Anchor Links ===== */
.heading-anchor {
    opacity: 0;
    margin-left: 0.5em;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 400;
    font-size: 0.85em;
    transition: opacity 0.2s;
}

h2:hover .heading-anchor,
h3:hover .heading-anchor {
    opacity: 1;
}

.heading-anchor:hover {
    color: var(--accent-primary);
}

/* ===== Code Language Labels ===== */
pre.has-lang-label code,
pre.has-lang-label code.hljs {
    padding-top: 2rem;
}

.code-lang-label {
    position: absolute;
    top: 0;
    left: 0;
    padding: 0.1rem 0.6rem;
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.7rem;
    border-radius: 6px 0 4px 0;
    text-transform: uppercase;
    pointer-events: none;
}

/* ===== Image Lightbox ===== */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.92);
    display: none;
    justify-content: center;
    align-items: center;
}

.lightbox-overlay.active {
    display: flex;
}

.lightbox-image {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    margin: 0;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.lightbox-close:hover {
    color: var(--text-primary);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 3rem;
    cursor: pointer;
    padding: 1rem;
    line-height: 1;
    transition: color 0.2s;
}

.lightbox-nav:hover {
    color: var(--text-primary);
}

.lightbox-prev {
    left: 1rem;
}

.lightbox-next {
    right: 1rem;
}

.lightbox-counter {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ===== Scrollbar Styling ===== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: #2a2a2a;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}
