/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* MUJI Inspired Light Theme Colors */
    --bg-primary: #f5f5f0;
    --bg-secondary: #ffffff;
    --bg-tertiary: #fafaf8;
    --accent-primary: #8b7355;
    --accent-secondary: #a89968;
    --accent-gold: #c9a961;
    --accent-success: #7d9b76;
    --accent-warning: #c17b62;
    --accent-info: #7a9299;
    --text-primary: #3d3d3d;
    --text-secondary: #6b6b6b;
    --text-muted: #999999;
    --border-color: #e0e0dc;

    /* Spacing - Reduced by half */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 0.75rem;
    --spacing-lg: 1rem;
    --spacing-xl: 1.5rem;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;

    /* Shadows - Subtle MUJI style */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 0 10px rgba(139, 115, 85, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft JhengHei', sans-serif;
    background: #f5f5f0;
    background: var(--bg-primary);
    color: #3d3d3d;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background Pattern - Subtle MUJI texture */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(139, 115, 85, 0.02) 2px, rgba(139, 115, 85, 0.02) 4px);
    pointer-events: none;
    z-index: -1;
}

/* Main Layout with Sidebar */
.page-wrapper {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    min-height: 100vh;
}

/* Left Sidebar Navigation */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: #ffffff;
    background: var(--bg-secondary);
    border-right: 1px solid #e0e0dc;
    border-right: 1px solid var(--border-color);
    padding: 1rem;
    padding: var(--spacing-lg);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--accent-primary);
    text-decoration: none;
    display: block;
    margin-bottom: var(--spacing-xs);
}

.sidebar-tagline {
    font-size: 0.625rem;
    color: var(--text-muted);
}

/* Tree Navigation */
.nav-tree {
    list-style: none;
}

.nav-section {
    margin-bottom: var(--spacing-md);
}

.nav-section-title {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 0.5rem;
    gap: var(--spacing-sm);
    padding: 0.5rem;
    padding: var(--spacing-sm) var(--spacing-sm);
    font-size: 0.75rem;
    font-weight: 500;
    color: #8b7355;
    color: var(--accent-primary);
    cursor: pointer;
    border-radius: 6px;
    border-radius: var(--radius-md);
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.nav-section-title:hover {
    background: rgba(139, 115, 85, 0.06);
}

.nav-section-title .nav-icon {
    font-size: 0.875rem;
}

.nav-section-title .nav-arrow {
    margin-left: auto;
    font-size: 0.625rem;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

.nav-section.expanded .nav-arrow {
    transform: rotate(90deg);
}

/* Sub Navigation Items */
.nav-items {
    list-style: none;
    padding-left: var(--spacing-lg);
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}

.nav-group {
    margin: 6px 0;
}

.nav-group-title {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--muted);
    cursor: pointer;
    -webkit-transition: background 0.2s ease, color 0.2s ease;
    transition: background 0.2s ease, color 0.2s ease;
}

.nav-group-title:hover {
    background: rgba(139, 115, 85, 0.08);
    color: var(--text-primary);
}

.nav-group .nav-arrow {
    margin-left: auto;
    font-size: 0.625rem;
    color: var(--muted);
    -webkit-transition: -webkit-transform 0.2s ease, color 0.2s ease;
    transition: -webkit-transform 0.2s ease, color 0.2s ease;
    transition: transform 0.2s ease, color 0.2s ease;
}

.nav-group.expanded .nav-arrow {
    -webkit-transform: rotate(90deg);
    -ms-transform: rotate(90deg);
    transform: rotate(90deg);
    color: var(--primary);
}

.nav-group .nav-items {
    padding-left: var(--spacing-md);
    max-height: 0;
}

.nav-group.expanded > .nav-items {
    max-height: 1200px;
}

.nav-section.expanded .nav-items {
    max-height: 800px;
}

.nav-item {
    margin: 2px 0;
}

.nav-item a {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 0.5rem;
    gap: var(--spacing-sm);
    padding: 0.5rem;
    padding: var(--spacing-sm) var(--spacing-sm);
    font-size: 0.6875rem;
    color: #6b6b6b;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 4px;
    border-radius: var(--radius-sm);
    -webkit-transition: all 0.2s ease;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
}

.nav-item a:hover {
    background: rgba(139, 115, 85, 0.06);
    color: var(--text-primary);
    border-left-color: var(--accent-primary);
}

.nav-item a.active {
    background: rgba(139, 115, 85, 0.1);
    color: var(--accent-primary);
    border-left-color: var(--accent-primary);
    font-weight: 500;
}

.nav-item .item-icon {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Single Nav Links */
.nav-link-single {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    margin-top: var(--spacing-md);
    border: 1px solid var(--border-color);
}

.nav-link-single:hover {
    background: rgba(139, 115, 85, 0.06);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.nav-link-single .nav-icon {
    font-size: 0.875rem;
}

/* Main Content Area */
.main-content {
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    margin-left: 280px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--spacing-lg);
}

/* Mobile Sidebar Toggle */
.sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 48px;
    height: 48px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    z-index: 101;
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s ease;
}

.sidebar-toggle:hover {
    transform: scale(1.1);
}

/* Responsive Sidebar */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
    }

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

/* Header */
.header {
    text-align: center;
    padding: var(--spacing-xl) 0;
    margin-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--accent-primary);
    margin-bottom: var(--spacing-sm);
    letter-spacing: 0.05em;
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Hero Section */
.hero {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.hero-title {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

.hero-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

/* Features Section */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    text-align: center;
    transition: all 0.3s ease;
}

.feature-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-primary);
}

.feature-icon {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-sm);
}

.feature-card h3 {
    font-size: 0.875rem;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
    font-weight: 500;
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Bento Grid */
.bento-grid {
    margin-top: var(--spacing-xl);
}

.section-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: var(--spacing-sm);
    color: var(--accent-primary);
}

.section-header p {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Grid Layout */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    grid-auto-flow: dense;
}

/* Card Sizes */
.card-large {
    grid-column: span 2;
}

.card-wide {
    grid-column: span 2;
}

.card-medium {
    grid-column: span 1;
}

@media (max-width: 768px) {
    .card-large,
    .card-wide,
    .card-medium {
        grid-column: span 1;
    }
}

/* Card Styles */
.card {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100px;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(139, 115, 85, 0.02);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-primary);
}

.card:hover::before {
    opacity: 1;
}

.card:hover .card-arrow {
    transform: translateX(3px);
}

/* Card Themes - MUJI subtle colors */
.card-primary {
    background: rgba(139, 115, 85, 0.03);
}

.card-secondary {
    background: rgba(168, 153, 104, 0.03);
}

.card-accent {
    background: rgba(122, 146, 153, 0.03);
}

.card-highlight {
    background: rgba(201, 169, 97, 0.03);
}

.card-warning {
    background: rgba(193, 123, 98, 0.03);
}

.card-info {
    background: rgba(122, 146, 153, 0.03);
}

.card-success {
    background: rgba(125, 155, 118, 0.03);
}

.card-purple {
    background: rgba(168, 153, 104, 0.03);
}

.card-gradient {
    background: rgba(139, 115, 85, 0.05);
}

/* Card Components */
.card-icon {
    font-size: 1.25rem;
    margin-bottom: var(--spacing-md);
}

.card-content {
    flex: 1;
}

.card-content h3 {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
}

.card-content p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
    line-height: 1.5;
    font-size: 0.75rem;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    list-style: none;
    margin-top: var(--spacing-md);
}

.card-tags li {
    background: rgba(139, 115, 85, 0.08);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: 0.625rem;
    color: var(--text-secondary);
}

.card-arrow {
    position: absolute;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    font-size: 0.875rem;
    color: var(--accent-primary);
    transition: transform 0.3s ease;
}

/* Footer */
.footer {
    margin-top: var(--spacing-xl);
    padding: var(--spacing-xl) 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.footer-content p {
    color: var(--text-muted);
    margin: var(--spacing-xs) 0;
    font-size: 0.75rem;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeInUp 0.6s ease-out backwards;
}

.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(4) { animation-delay: 0.4s; }
.card:nth-child(5) { animation-delay: 0.5s; }
.card:nth-child(6) { animation-delay: 0.6s; }
.card:nth-child(7) { animation-delay: 0.7s; }
.card:nth-child(8) { animation-delay: 0.8s; }
.card:nth-child(9) { animation-delay: 0.9s; }

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        padding: var(--spacing-md);
    }

    .hero-title {
        font-size: 1.125rem;
    }

    .logo {
        font-size: 1.375rem;
    }
}

@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr;
    }

    .hero-title {
        font-size: 1rem;
    }

    .section-header h2 {
        font-size: 1.125rem;
    }
}

/* Image Modal/Lightbox Styles */
.image-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s ease;
}

.image-modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    animation: zoomIn 0.3s ease;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f5f5f0;
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    transition: color 0.3s ease;
    z-index: 1001;
}

.modal-close:hover,
.modal-close:focus {
    color: var(--accent-gold);
}

/* Clickable images cursor */
.main-content img {
    cursor: pointer;
    transition: opacity 0.3s ease;
}

.main-content img:hover {
    opacity: 0.85;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}


/* Markdown Content Formatting */
.markdown-content {
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-primary);
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin-top: 2em;
    margin-bottom: 1em;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.markdown-content h1 { font-size: 2rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5em; }
.markdown-content h2 { font-size: 1.75rem; }
.markdown-content h3 { font-size: 1.5rem; }
.markdown-content h4 { font-size: 1.25rem; }

.markdown-content p {
    margin-bottom: 1.5em;
}

.markdown-content ul,
.markdown-content ol {
    margin-bottom: 1.5em;
    padding-left: 2em;
}

.markdown-content li {
    margin-bottom: 0.5em;
}

.markdown-content blockquote {
    border-left: 4px solid var(--accent-primary);
    background: rgba(139, 115, 85, 0.05);
    padding: 1em 1.5em;
    margin-bottom: 1.5em;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    color: var(--text-secondary);
}

.markdown-content pre {
    background: #f1f1f1;
    padding: 1em;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin-bottom: 1.5em;
    font-size: 0.9rem;
}

.markdown-content code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background: rgba(0, 0, 0, 0.05);
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-size: 0.9em;
}

.markdown-content pre code {
    background: transparent;
    padding: 0;
}

.markdown-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    margin: 1em 0;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5em;
}

.markdown-content th,
.markdown-content td {
    border: 1px solid var(--border-color);
    padding: 0.75em;
    text-align: left;
}

.markdown-content th {
    background: rgba(0, 0, 0, 0.02);
    font-weight: 600;
}

.markdown-content a {
    color: var(--accent-primary);
    text-decoration: none;
    border-bottom: 1px dotted var(--accent-primary);
    transition: all 0.2s ease;
}

.markdown-content a:hover {
    color: var(--accent-secondary);
    border-bottom-style: solid;
}
