/* Reset and base */
*, *::before, *::after {
    box-sizing: border-box;
}

:root {
    --color-bg: #0f0f0f;
    --color-surface: #1a1a1a;
    --color-surface-hover: #252525;
    --color-border: #333;
    --color-text: #e0e0e0;
    --color-text-muted: #888;
    --color-accent: #4A90D9;
    --color-accent-light: #6BA3E0;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Header */
header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 2rem;
    text-align: center;
}

header h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 600;
    color: var(--color-text);
}

header .subtitle {
    margin: 0.5rem 0 0;
    color: var(--color-text-muted);
    font-size: 1rem;
}

/* Main content */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

section {
    margin-bottom: 3rem;
}

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

/* Card Grid - max 3 columns */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

@media (min-width: 1000px) {
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 700px) and (max-width: 999px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Graph Cards */
.card {
    display: block;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

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

.card-preview {
    aspect-ratio: 4/3;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 1rem;
}

.card-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.card-content {
    padding: 1rem;
}

.card-content h3 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-accent-light);
}

.card-content p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

/* Findings Grid */
.findings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

@media (min-width: 1000px) {
    .findings-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.finding-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.finding-card h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-accent-light);
}

.finding-card p,
.finding-card ul {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
}

.finding-card ul {
    padding-left: 1.25rem;
}

.finding-card li {
    margin-bottom: 0.25rem;
}

.finding-card code {
    background: #2a2a2a;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-size: 0.85em;
    color: #f0f0f0;
}

.workflow-diagram {
    background: #2a2a2a;
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    overflow-x: auto;
}

.workflow-diagram code {
    background: none;
    padding: 0;
    font-size: 0.8rem;
    white-space: nowrap;
}

.state-flow {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    word-break: break-all;
}

.stats-table {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
}

.stats-table td {
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--color-border);
}

.stats-table td:first-child {
    font-family: monospace;
    color: var(--color-accent-light);
}

.stats-table td:last-child {
    color: var(--color-text-muted);
    text-align: right;
}

/* Tech Stack Grid */
.tech-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

@media (min-width: 700px) {
    .tech-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.tech-column {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
}

.tech-column h3 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-accent-light);
}

.tech-column ul {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.9rem;
}

.tech-column li {
    margin-bottom: 0.25rem;
}

/* Footer */
footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 1.5rem 2rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

footer p {
    margin: 0.25rem 0;
}

/* Graph Viewer Page */
.graph-viewer {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.graph-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.graph-header .back-link {
    color: var(--color-accent);
    text-decoration: none;
    font-size: 0.9rem;
}

.graph-header .back-link:hover {
    text-decoration: underline;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-controls button {
    background: var(--color-surface-hover);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 0.4rem 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.nav-controls button:hover:not(:disabled) {
    background: var(--color-border);
}

.nav-controls button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.nav-controls span {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    min-width: 3rem;
    text-align: center;
}

.graph-header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
}

.graph-controls {
    display: flex;
    gap: 0.5rem;
}

.graph-controls button {
    background: var(--color-surface-hover);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.graph-controls button:hover {
    background: var(--color-border);
}

.graph-container {
    flex: 1;
    overflow: auto;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.graph-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.graph-container.fit-width img {
    width: 100%;
    height: auto;
    max-height: none;
}

.graph-container.fit-height img {
    height: calc(100vh - 80px);
    width: auto;
    max-width: none;
}

.graph-container.actual-size img {
    max-width: none;
    max-height: none;
}

/* Graph Sections (index page) */
.graph-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 2rem;
    overflow: hidden;
}

.graph-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.graph-header-row h2 {
    margin: 0;
    padding: 0;
    border: none;
    font-size: 1.25rem;
}

.view-btn {
    background: var(--color-accent);
    color: #fff;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.view-btn:hover {
    background: var(--color-accent-light);
}

.graph-section .graph-preview {
    display: block;
    background: #fff;
    max-height: 400px;
    overflow: hidden;
}

.graph-section .graph-preview img {
    width: 100%;
    height: auto;
    object-fit: contain;
    object-position: top left;
}

.graph-details {
    padding: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.graph-details p {
    margin: 0 0 1rem;
    color: var(--color-text-muted);
}

.graph-details h4 {
    margin: 1.5rem 0 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-accent-light);
}

.graph-details h4:first-child {
    margin-top: 0;
}

.graph-details ul {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.9rem;
}

.graph-details li {
    margin-bottom: 0.35rem;
}

.graph-details code {
    background: #2a2a2a;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-size: 0.85em;
}

/* Details Table */
.details-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    margin: 0.5rem 0 1rem;
}

.details-table th {
    text-align: left;
    padding: 0.5rem;
    background: #2a2a2a;
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    color: var(--color-text);
}

.details-table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}

.details-table code {
    background: #2a2a2a;
    padding: 0.15em 0.4em;
    border-radius: 3px;
    font-size: 0.85em;
    white-space: nowrap;
}

.note {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-style: italic;
    margin-top: 0.5rem;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    main {
        padding: 1rem;
    }

    header {
        padding: 1.5rem 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .card-grid,
    .findings-grid {
        grid-template-columns: 1fr;
    }

    .graph-header {
        flex-wrap: wrap;
        padding: 1rem;
    }

    .graph-header h1 {
        order: -1;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .graph-controls {
        flex-wrap: wrap;
    }
}
