/* jpdocs - Japanese Documentation Styles */

:root {
    --bg: #1a1a2e;
    --bg-light: #16213e;
    --text: #e4e4e7;
    --text-muted: #a1a1aa;
    --accent: #7c3aed;
    --accent-light: #a78bfa;
    --border: #27273a;
    --code-bg: #0f0f1a;
    --highlight: #fbbf24;
    --highlight-bg: rgba(251, 191, 36, 0.15);
    --link: #60a5fa;
    --success: #34d399;
    --warning: #fbbf24;
    --error: #f87171;
    --sidebar-width: 280px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 16px;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-light);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-light);
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* TOC */
.toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc li {
    margin: 0;
}

.toc a {
    display: block;
    padding: 0.5rem 1.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    border-left: 2px solid transparent;
    transition: all 0.15s ease;
}

.toc a:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
    border-left-color: var(--accent);
}

.toc-level-2 a { padding-left: 2rem; font-size: 0.85rem; }
.toc-level-3 a { padding-left: 2.75rem; font-size: 0.8rem; }
.toc-level-4 a { padding-left: 3.5rem; font-size: 0.75rem; }

/* Content */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem 3rem;
    max-width: 900px;
}

.menu-button {
    display: none;
    background: var(--bg-light);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 1rem;
    font-family: inherit;
}

article {
    max-width: 100%;
}

/* Typography */
h1, h2, h3, h4 {
    margin: 2rem 0 1rem 0;
    font-weight: 600;
    color: var(--text);
    position: relative;
}

h1 { font-size: 2rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; color: var(--text-muted); }

h1:first-child { margin-top: 0; }

.anchor {
    opacity: 0;
    color: var(--text-muted);
    text-decoration: none;
    margin-left: 0.5rem;
    font-size: 0.8em;
    transition: opacity 0.15s;
}

h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor {
    opacity: 1;
}

p {
    margin: 1rem 0;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

strong {
    color: var(--text);
    font-weight: 600;
}

code {
    background: var(--code-bg);
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-family: 'Fira Code', 'JetBrains Mono', monospace;
    font-size: 0.9em;
}

pre {
    background: var(--code-bg);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    border: 1px solid var(--border);
}

pre code {
    background: none;
    padding: 0;
}

blockquote {
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    border-left: 3px solid var(--accent);
    background: rgba(124, 58, 237, 0.1);
    border-radius: 0 4px 4px 0;
}

blockquote p {
    margin: 0;
}

hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: 2rem 0;
}

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

li {
    margin: 0.5rem 0;
}

li > ul, li > ol {
    margin: 0.25rem 0;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.95rem;
}

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

th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text);
}

tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.02);
}

/* Cell highlighting */
td.highlight {
    background: var(--highlight-bg) !important;
    border-color: rgba(251, 191, 36, 0.3);
}

td.highlight-red {
    background: rgba(248, 113, 113, 0.15) !important;
    border-color: rgba(248, 113, 113, 0.3);
}

td.highlight-green {
    background: rgba(52, 211, 153, 0.15) !important;
    border-color: rgba(52, 211, 153, 0.3);
}

td.highlight-blue {
    background: rgba(96, 165, 250, 0.15) !important;
    border-color: rgba(96, 165, 250, 0.3);
}

td.highlight-purple {
    background: rgba(167, 139, 250, 0.15) !important;
    border-color: rgba(167, 139, 250, 0.3);
}

/* Furigana */
ruby {
    ruby-align: center;
}

rt {
    font-size: 0.55em;
    color: var(--text-muted);
}

/* Error state */
.error {
    text-align: center;
    padding: 3rem;
}

.error h1 {
    color: var(--error);
    border: none;
}

/* Mobile */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    }
    
    .sidebar-close {
        display: block;
    }
    
    .content {
        margin-left: 0;
        padding: 1rem 1.5rem;
    }
    
    .menu-button {
        display: block;
    }
    
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.1rem; }
    
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
    
    th, td {
        padding: 0.5rem 0.75rem;
    }
}

/* Print */
@media print {
    .sidebar, .menu-button, .anchor {
        display: none;
    }
    
    .content {
        margin-left: 0;
        max-width: 100%;
    }
    
    body {
        background: white;
        color: black;
    }
    
    a {
        color: inherit;
    }
    
    h1, h2, h3, h4 {
        break-after: avoid;
    }
    
    table, pre {
        break-inside: avoid;
    }
}
