/**
 * AI Terakoya Knowledge Base - Common Stylesheet
 * Version: 2.0.0
 * Date: 2025-11-16
 * Description: Shared styles for all Dojo chapters (FM, MI, ML, MS, PI)
 * Update: Added index page specific styles and CSS variables
 */

/* ========================================
   0. CSS Variables
   ======================================== */

:root {
    /* Primary Colors */
    --primary-gradient-start: #667eea;
    --primary-gradient-end: #764ba2;
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;

    /* Background Colors */
    --bg-color: #ffffff;
    --bg-gray: #f5f5f5;
    --bg-light: #f8f9fa;

    /* Text Colors */
    --text-color: #333333;
    --text-muted: #666666;

    /* Border & Link Colors */
    --border-color: #e0e0e0;
    --link-color: #667eea;
    --link-hover: #764ba2;

    /* Code Colors */
    --code-bg-light: #f5f5f5;
    --code-bg-dark: #1e1e1e;
    --code-text: #d4d4d4;
}

/* ========================================
   1. CSS Reset & Base Styles
   ======================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.8;
    color: var(--text-color);
    background: var(--bg-color);
}

/* ========================================
   2. Header & Navigation
   ======================================== */

header {
    background: linear-gradient(135deg, var(--primary-gradient-start) 0%, var(--primary-gradient-end) 100%);
    color: white;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 0;
}

h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.subtitle {
    opacity: 0.95;
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

.breadcrumb {
    background: #f7fafc;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 0;
    font-size: 0.9rem;
}

.breadcrumb-content {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.breadcrumb a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

.breadcrumb-separator {
    color: #a0aec0;
    margin: 0 0.25rem;
}

.breadcrumb-current {
    color: #4a5568;
    font-weight: 500;
}

/* ========================================
   3. Layout & Container
   ======================================== */

.container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.content {
    background: white;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

/* ========================================
   4. Typography
   ======================================== */

h2 {
    color: #667eea;
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e0e0e0;
}

h3 {
    color: #764ba2;
    margin: 1.5rem 0 0.8rem 0;
}

p {
    margin-bottom: 1rem;
}

ul, ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

/* ========================================
   5. Content Boxes (Definition, Theorem, Example)
   ======================================== */

.definition {
    background: #e7f3ff;
    border-left: 4px solid #667eea;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 4px;
}

.theorem {
    background: #f3e5f5;
    border-left: 4px solid #764ba2;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 4px;
}

.example {
    background: #fff3e0;
    border-left: 4px solid #ff9800;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 4px;
}

.note {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 4px;
}

.exercise {
    background: #d4edda;
    border-left: 4px solid #28a745;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 4px;
}

/* ========================================
   6. Code Blocks & Examples
   ======================================== */

.code-title {
    background: #667eea;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px 6px 0 0;
    font-weight: 600;
    margin-top: 1.5rem;
}

.code-example {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1.5rem;
    border-radius: 0 0 8px 8px;
    overflow-x: auto;
    margin: 0 0 1rem 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.code-block {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.code-block code {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.output {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    font-family: monospace;
    font-size: 0.9rem;
}

.output-box {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 1rem;
    border-radius: 6px;
    margin: 1rem 0;
    font-family: monospace;
    font-size: 0.9rem;
    white-space: pre-wrap;
}

/* ========================================
   7. Tables
   ======================================== */

table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

th, td {
    padding: 0.8rem;
    text-align: left;
    border: 1px solid #ddd;
}

th {
    background: #667eea;
    color: white;
    font-weight: 600;
}

tr:nth-child(even) {
    background: #f8f9fa;
}

/* ========================================
   8. Navigation Buttons
   ======================================== */

.nav-buttons {
    display: flex;
    justify-content: space-between;
    margin: 2rem 0;
    gap: 1rem;
}

.nav-button {
    padding: 0.8rem 1.5rem;
    background: var(--link-color);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.nav-button:hover {
    background: var(--link-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* ========================================
   9. Footer
   ======================================== */

footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 3rem;
}

footer a {
    color: #67c7f5;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ========================================
   10. Responsive Design
   ======================================== */

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

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    .nav-buttons {
        flex-direction: column;
    }

    .nav-button {
        text-align: center;
    }

    /* Index page responsive styles */
    .series-meta {
        font-size: 0.85rem;
        gap: 1rem;
    }

    .chapter-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .chapter-number {
        align-self: flex-start;
    }

    .chapter-topics {
        gap: 0.4rem;
    }

    .topic-tag {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.5rem;
    }

    .content {
        padding: 1rem;
        border-radius: 8px;
    }

    h1 {
        font-size: 1.3rem;
    }

    h2 {
        font-size: 1.1rem;
    }

    .code-example,
    .code-block {
        font-size: 0.8rem;
        padding: 1rem;
    }

    /* Index page mobile styles */
    .series-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    .chapter-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    .chapter-card {
        margin-bottom: 1.5rem;
    }

    .chapter-body {
        padding: 1rem;
    }
}

/* ========================================
   11. Print Styles
   ======================================== */

@media print {
    body {
        background: white;
    }

    header {
        background: none;
        color: black;
        border-bottom: 2px solid #333;
    }

    .content {
        box-shadow: none;
        padding: 0;
    }

    .nav-buttons,
    footer {
        display: none;
    }

    .code-example,
    .code-block {
        border: 1px solid #ccc;
        background: #f5f5f5;
        color: #000;
    }
}

/* ========================================
   12. Utility Classes
   ======================================== */

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.hidden {
    display: none;
}

/* ========================================
   15. Locale Switcher Styles
   ======================================== */

/* Main locale switcher container */
.locale-switcher {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 6px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Current locale indicator */
.current-locale {
    font-weight: 600;
    color: var(--color-accent, #7b2cbf);
}

/* Separator between locales */
.locale-separator {
    color: var(--color-border, #cbd5e0);
    font-weight: 300;
}

/* Active locale link */
.locale-link {
    color: var(--color-link, #3182ce);
    text-decoration: none;
    transition: color 0.2s, transform 0.2s;
    font-weight: 500;
}

.locale-link:hover {
    color: var(--color-link-hover, #2c5aa0);
    text-decoration: underline;
    transform: translateY(-1px);
}

/* Disabled locale link (when translation not available) */
.locale-link.disabled {
    color: var(--color-text-light, #a0aec0);
    cursor: not-allowed;
    pointer-events: none;
}

/* Sync date metadata */
.locale-meta {
    font-size: 0.8rem;
    color: var(--color-text-light, #718096);
    margin-left: auto;
    opacity: 0.8;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .locale-switcher {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }

    .locale-meta {
        display: none; /* Hide sync date on mobile */
    }
}

/* Print styles - hide locale switcher */
@media print {
    .locale-switcher {
        display: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .locale-switcher {
        border: 2px solid currentColor;
        background: transparent;
    }

    .locale-link {
        text-decoration: underline;
    }
}

/* ========================================
   13. Accessibility Enhancements
   ======================================== */

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    left: -9999px;
    z-index: 999;
}

.skip-to-main:focus {
    left: 0;
    top: 0;
    background: #667eea;
    color: white;
    padding: 1rem;
}

/* Focus indicators */
a:focus,
button:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    body {
        background: white;
        color: black;
    }

    .content {
        border: 2px solid black;
    }

    a {
        color: #0000ff;
        text-decoration: underline;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* ========================================
   14. Index Page Specific Styles
   ======================================== */

/* Series Meta (Header badges) */
.series-meta {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
    opacity: 0.95;
    margin-top: 1rem;
    color: white;
}

.series-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

/* Chapter Cards */
.chapters {
    margin-top: 3rem;
}

.chapter-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chapter-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.chapter-header {
    background: linear-gradient(135deg, var(--primary-gradient-start) 0%, var(--primary-gradient-end) 100%);
    color: white;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chapter-number {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
}

.chapter-title {
    font-size: 1.3rem;
    font-weight: 600;
    flex: 1;
}

.chapter-body {
    padding: 1.5rem;
}

.chapter-desc {
    color: var(--text-color);
    line-height: 1.8;
    margin-bottom: 1.5rem;
}

/* Topic Tags */
.chapter-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.topic-tag {
    background: #e7f3ff;
    color: var(--link-color);
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Chapter Metadata */
.chapter-meta {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

/* Chapter Link */
.chapter-link {
    display: inline-block;
    padding: 0.7rem 1.5rem;
    background: var(--link-color);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.chapter-link:hover {
    background: var(--link-hover);
    transform: translateX(4px);
    text-decoration: none;
}

/* Learning Path Section */
.learning-path {
    background: #f0f7ff;
    border-left: 4px solid var(--link-color);
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 4px;
}

.learning-path h3 {
    color: var(--primary-color);
    margin-top: 0;
}

/* Objectives Section */
.objectives {
    background: #f3e5f5;
    border-left: 4px solid var(--primary-gradient-end);
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 4px;
}

.objectives h3 {
    color: var(--primary-color);
    margin-top: 0;
}

.objectives ul {
    margin-left: 1.5rem;
    margin-bottom: 0;
}

/* Prerequisites Section */
.prereq {
    background: #fff3e0;
    border-left: 4px solid #ff9800;
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 4px;
}

.prereq h3 {
    color: var(--primary-color);
    margin-top: 0;
}

/* Introduction Section */
.intro {
    margin-bottom: 3rem;
}

.intro h2 {
    color: var(--primary-color);
}

/* Back Link */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--link-color);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 2rem;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: var(--link-hover);
    text-decoration: none;
}

/* Info Box (General) */
.info-box {
    background: var(--bg-light);
    border-left: 4px solid var(--link-color);
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 4px;
}

.info-box h3 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 1rem;
}

.info-box ul {
    margin-bottom: 0;
}

/* Disclaimer Section */
.disclaimer {
    max-width: 900px;
    margin: 3rem auto 2rem;
    padding: 1.5rem;
    background: var(--bg-light);
    border-left: 4px solid #6c757d;
    border-radius: 4px;
}

.disclaimer h3 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 1rem;
}

.disclaimer ul {
    margin-left: 1.5rem;
    margin-bottom: 0;
    line-height: 1.8;
}

.disclaimer li {
    margin-bottom: 0.8rem;
}
