/* Cleaner, more professional data-science aesthetic */
:root {
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;

    /* Category Colors matching Python script */
    --cat-tech: #2E86C1;
    --cat-acad: #E74C3C;
    --cat-soft: #27AE60;
    --cat-gen: #95A5A6;

    --accent: #2c3e50;
}

body {
    margin: 0;
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow-x: hidden;
}

.background-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    z-index: -1;
    pointer-events: none;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    text-align: center;
}

h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

/* Legend */
.legend {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

/* Tabs */
.tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.tab-btn {
    background: var(--card-bg);
    border: 1px solid #e0e0e0;
    color: var(--text-muted);
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tab-btn:hover {
    background: #f0f0f0;
    color: var(--text-main);
}

.tab-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Controls */
.controls {
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    /* Increased gap */
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    /* Slightly wider */
    height: 32px;
    /* Slightly taller */
    flex-shrink: 0;
    /* Prevent shrinking */
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent);
}

input:checked+.slider:before {
    transform: translateX(28px);
}

#current-dataset-label {
    font-weight: 600;
    min-width: 220px;
    text-align: left;
    white-space: nowrap;
    /* Prevent wrapping */
}

/* Viz Container */
#viz-container {
    min-height: 600px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    padding: 20px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.view {
    display: none;
    width: 100%;
    height: 100%;
    animation: fadeIn 0.5s ease;
    overflow: auto;
    max-height: 650px;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

svg {
    width: 100%;
    height: 600px;
    display: block;
    overflow: visible;
}

/* Network Specific Styles Removed */

.citation {
    display: none;
}

/* N-Grams List */
.ngram-container {
    display: flex;
    gap: 30px;
    padding: 20px;
    text-align: left;
}

.ngram-col {
    flex: 1;
}

.ngram-col h3 {
    margin-top: 0;
    color: var(--accent);
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 10px;
}

.ngram-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 10px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.ngram-item:hover {
    background: #f8f9fa;
}

.ngram-text {
    font-weight: 600;
    color: var(--text-main);
}

.ngram-count {
    color: var(--text-muted);
    font-size: 0.9em;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 12px;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(44, 62, 80, 0.9);
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    pointer-events: none;
    font-size: 0.9rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 100;
}

/* Gallery Removed */
.generated-images,
.gallery {
    display: none;
}

/* Adding styles for the context link and hint */
.context-link {
    margin-left: auto;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
    padding: 0.5rem 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    background: #fff;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.context-link:hover {
    background: #f8f9fa;
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.instruction-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    margin-top: -1rem;
    opacity: 0.8;
}

/* Back link style */
.back-link {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.2s;
    font-size: 0.9rem;
}

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

.methodology-note {
    background: #eaf2f8;
    color: var(--text-main);
    padding: 1rem;
    margin-top: 2rem;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
    border: 1px solid #d4e6f1;
    text-align: center;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* Navigation Back Button */
.back-nav {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
}

.back-btn {
    text-decoration: none;
    color: var(--text-main);
    background: white;
    padding: 10px 20px;
    border-radius: 30px;
    border: 1px solid #e0e0e0;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.back-btn:hover {
    transform: translateX(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: var(--text-muted);
    background: #f8f9fa;
}