/**
 * HugeModel Website - Stylesheet
 * Modern, responsive design with theme support
 * Author: Emmanuel Forgues
 * Version: 0.99
 * Year: 2025
 */

/* ============================================
   CSS Variables and Theme Support
   ============================================ */

:root {
    /* Light theme (default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --bg-card: #ffffff;
    --bg-code: #f4f4f4;
    
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-muted: #6c757d;
    --text-inverse: #ffffff;
    
    --border-color: #dee2e6;
    --border-light: #e9ecef;
    
    --accent-primary: #0d6efd;
    --accent-secondary: #6610f2;
    --accent-success: #198754;
    --accent-warning: #ffc107;
    --accent-danger: #dc3545;
    --accent-info: #0dcaf0;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', Consolas, 'Liberation Mono', Menlo, monospace;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --navbar-height: 64px;
}

[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --bg-card: #1f2937;
    --bg-code: #2d2d2d;
    
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-inverse: #1a1a2e;
    
    --border-color: #374151;
    --border-light: #1f2937;
    
    --accent-primary: #3b82f6;
    --accent-secondary: #8b5cf6;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

/* ============================================
   Base Styles
   ============================================ */

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: 0.5em;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
    margin-top: 0;
    margin-bottom: 1rem;
}

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 0.2em 0.4em;
    background-color: var(--bg-code);
    border-radius: var(--radius-sm);
}

pre {
    background-color: var(--bg-code);
    padding: 1rem;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 1rem 0;
}

pre code {
    padding: 0;
    background: none;
}

/* ============================================
   Navigation
   ============================================ */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-brand h1 {
    font-size: 1.5rem;
    margin: 0;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-brand .version {
    font-size: 0.75rem;
    padding: 0.2em 0.5em;
    background-color: var(--accent-primary);
    color: var(--text-inverse);
    border-radius: var(--radius-sm);
}

.nav-links {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0.5rem;
}

.nav-links a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent-primary);
    background-color: var(--bg-secondary);
    text-decoration: none;
}

.theme-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-selector label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.theme-selector select {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
}

/* ============================================
   Main Container
   ============================================ */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: calc(var(--navbar-height) + 2rem) 2rem 2rem;
}

main {
    min-height: calc(100vh - var(--navbar-height) - 200px);
}

/* ============================================
   Page Header
   ============================================ */

.page-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-light);
}

.page-header h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.page-header p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin: 0;
}

/* ============================================
   Hero Section
   ============================================ */

.hero {
    text-align: center;
    padding: 4rem 2rem;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border-radius: var(--radius-lg);
    margin-bottom: 3rem;
}

.hero h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}

.hero .subtitle {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-top: 2rem;
}

.stat {
    text-align: center;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    display: block;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ============================================
   Cards
   ============================================ */

.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.card-icon {
    font-size: 1.5rem;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.feature-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    transition: all var(--transition-normal);
}

.feature-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
}

.feature-card .icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    justify-content: center;
}

/* ============================================
   Sections
   ============================================ */

.section {
    margin-bottom: 4rem;
}

.section-title {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--accent-primary);
}

.tech-section {
    margin-bottom: 3rem;
    scroll-margin-top: calc(var(--navbar-height) + 2rem);
}

.tech-section h2 {
    color: var(--accent-primary);
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-light);
    margin-bottom: 1.5rem;
}

/* ============================================
   Tables
   ============================================ */

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background-color: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.data-table th {
    background-color: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

.data-table tr:hover {
    background-color: var(--bg-secondary);
}

.data-table.compact th,
.data-table.compact td {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

/* ============================================
   Mermaid Diagrams
   ============================================ */

.mermaid {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    overflow-x: auto;
}

.diagram-container {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.diagram-container h4 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* ============================================
   Code Examples
   ============================================ */

.code-example {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin: 1.5rem 0;
    overflow: hidden;
}

.code-example h4 {
    margin: 0;
    padding: 0.75rem 1rem;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.code-example pre {
    margin: 0;
    border-radius: 0;
}

/* ============================================
   Math Blocks
   ============================================ */

.math-block {
    background-color: var(--bg-secondary);
    border-left: 4px solid var(--accent-primary);
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.math-block h4 {
    margin-top: 0;
    color: var(--accent-primary);
}

.formula {
    background-color: var(--bg-card);
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    margin: 1rem 0;
    overflow-x: auto;
}

.formula-box {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin: 1rem 0;
}

.formula-box h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.formula-box code {
    display: block;
    background: none;
    padding: 0;
}

/* ============================================
   Term Styling (Clickable Terms)
   ============================================ */

.term {
    color: var(--accent-primary);
    cursor: pointer;
    border-bottom: 1px dashed var(--accent-primary);
    transition: all var(--transition-fast);
}

.term:hover {
    color: var(--accent-secondary);
    border-bottom-color: var(--accent-secondary);
    background-color: rgba(59, 130, 246, 0.1);
}

/* ============================================
   Term Popup
   ============================================ */

.term-popup {
    position: fixed;
    width: 400px;
    max-height: 80vh;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    overflow: hidden;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.term-popup.hidden {
    display: none;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.popup-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.popup-fullname {
    font-weight: normal;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.popup-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition-fast);
}

.popup-close:hover {
    color: var(--accent-danger);
}

#popup-content {
    padding: 1.25rem;
    overflow-y: auto;
    max-height: calc(80vh - 60px);
}

.popup-definition {
    margin-bottom: 1rem;
    line-height: 1.5;
}

.popup-formula,
.popup-keypoints,
.popup-examples,
.popup-related,
.popup-link {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.popup-keypoints ul {
    margin: 0.5rem 0 0 0;
    padding-left: 1.25rem;
}

.popup-keypoints li {
    margin-bottom: 0.25rem;
}

.popup-link {
    text-align: right;
}

/* ============================================
   Glossary Page
   ============================================ */

.glossary-search {
    margin-bottom: 1.5rem;
}

.glossary-search input {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background-color: var(--bg-card);
    color: var(--text-primary);
    transition: border-color var(--transition-fast);
}

.glossary-search input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.glossary-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.category-btn {
    padding: 0.5rem 1rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.category-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.category-btn.active {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--text-inverse);
}

.glossary-entry {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 2rem;
    overflow: hidden;
    scroll-margin-top: calc(var(--navbar-height) + 2rem);
}

.glossary-entry header {
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.glossary-entry header h2 {
    margin: 0;
    color: var(--accent-primary);
}

.glossary-entry .full-name {
    display: block;
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.glossary-entry .definition,
.glossary-entry .diagram,
.glossary-entry .key-points,
.glossary-entry .examples,
.glossary-entry .specs,
.glossary-entry .comparison {
    padding: 1.5rem;
}

.glossary-entry .definition {
    border-bottom: 1px solid var(--border-light);
    font-size: 1.1rem;
    line-height: 1.6;
}

.glossary-entry .key-points ul,
.glossary-entry .examples ul {
    margin: 0.5rem 0 0 0;
    padding-left: 1.25rem;
}

.glossary-entry .key-points li {
    margin-bottom: 0.5rem;
}

/* ============================================
   Table of Contents
   ============================================ */

.toc {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.toc h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.toc ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.toc li {
    margin-bottom: 0.5rem;
}

.toc a {
    display: block;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.toc a:hover,
.toc a.active {
    color: var(--accent-primary);
    background-color: var(--bg-tertiary);
    text-decoration: none;
}

/* ============================================
   Optimization List
   ============================================ */

.optimization-list {
    display: grid;
    gap: 1rem;
}

.optimization {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.optimization h4 {
    margin-top: 0;
    color: var(--accent-primary);
}

.optimization p {
    margin: 0.5rem 0 0 0;
    font-size: 0.95rem;
}

.optimization p:last-child {
    color: var(--accent-success);
    font-weight: 500;
}

/* ============================================
   Metrics Grid
   ============================================ */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.metric-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
}

.metric-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.metric-card .label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ============================================
   Footer
   ============================================ */

footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
    color: var(--text-muted);
}

.footer-content p {
    margin: 0.5rem 0;
}

.footer-content strong {
    color: var(--text-primary);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        height: auto;
        padding: 1rem;
        gap: 1rem;
    }
    
    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .container {
        padding: 1rem;
        padding-top: 150px;
    }
    
    .hero h1 {
        font-size: 2rem;
    }
    
    .hero-stats {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .feature-grid {
        grid-template-columns: 1fr;
    }
    
    .term-popup {
        width: calc(100vw - 2rem);
        left: 1rem !important;
        right: 1rem;
    }
    
    .glossary-categories {
        justify-content: center;
    }
    
    .data-table {
        font-size: 0.875rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
    
    pre {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .page-header h1 {
        font-size: 2rem;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    .navbar,
    .theme-selector,
    .term-popup,
    .glossary-search,
    .glossary-categories {
        display: none !important;
    }
    
    .container {
        padding-top: 0;
    }
    
    body {
        background: white;
        color: black;
    }
    
    a {
        color: black;
        text-decoration: underline;
    }
    
    .card,
    .feature-card,
    .glossary-entry {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
