:root {
    --trig-primary: #1e3a8a; /* Deep Blue */
    --trig-secondary: #3b82f6; /* Bright Blue */
    --sage-light: #f0f4f8;
    --sage-medium: #94a3b8;
    --whale-blue: #0f172a;
    --whale-dark: #020617;
    --accent: #f59e0b; /* Amber */
    --success: #10b981;
    --text-color: #334155;
    --bg-color: #f8fafc;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Navigation */
header {
    background: linear-gradient(135deg, var(--whale-blue) 0%, var(--whale-dark) 100%);
    color: white;
    padding: 2.5rem 2rem;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    color: var(--sage-light);
    letter-spacing: -0.5px;
}

.back-home {
    position: absolute;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    text-decoration: none;
    font-weight: 600;
    opacity: 0.8;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.back-home:hover {
    opacity: 1;
    transform: translateY(-50%) translateX(-5px);
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 3rem auto;
    padding: 0 2rem;
}

.section-title {
    margin-bottom: 2rem;
    text-align: center;
    font-size: 2.5rem;
    color: var(--whale-blue);
    font-weight: 800;
}

/* Topics Grid */
.topics-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 4rem;
}

.topic-link {
    background: white;
    padding: 1.8rem;
    border-radius: 20px;
    text-align: center;
    cursor: pointer;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    border: 2px solid transparent;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--whale-blue);
}

.topic-link:hover {
    transform: translateY(-5px);
    border-color: var(--trig-secondary);
    color: var(--trig-secondary);
}

.topic-link.active {
    background: var(--trig-primary);
    color: white;
    border-color: var(--trig-primary);
}

/* Content Sections */
.trig-section {
    display: none;
    animation: fadeIn 0.6s ease;
}

.trig-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Info Cards */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 2.5rem;
}

.info-card {
    background: white;
    padding: 2.5rem;
    border-radius: 24px;
    box-shadow: var(--card-shadow);
    border: 1px solid rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
}

.info-card h3 {
    color: var(--trig-primary);
    font-size: 1.6rem;
    margin-bottom: 1.5rem;
    border-bottom: 3px solid var(--sage-light);
    padding-bottom: 0.5rem;
    font-weight: 800;
}

.info-card p {
    margin-bottom: 1.2rem;
    color: #475569;
    font-size: 1.05rem;
}

.info-card ul {
    list-style: none;
    margin-top: 0.5rem;
}

.info-card li {
    margin-bottom: 1rem;
    padding-left: 1.8rem;
    position: relative;
    font-size: 1.05rem;
}

.info-card li::before {
    content: "📐";
    position: absolute;
    left: 0;
    font-size: 0.9rem;
}

.highlight {
    color: var(--trig-secondary);
    font-weight: 700;
}

/* Visuals */
.trig-viz {
    background: #fdfdfd;
    border-radius: 20px;
    padding: 2rem;
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 280px;
    box-shadow: inset 0 2px 15px rgba(0, 0, 0, 0.02);
    border: 2px dashed #e2e8f0;
}

svg {
    max-width: 100%;
    height: auto;
}

/* Formula Box */
.formula-box {
    background: var(--whale-blue);
    color: white;
    padding: 1.5rem;
    border-radius: 16px;
    margin: 1rem 0;
    text-align: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
}

.formula-box .katex-display {
    margin: 0.5rem 0;
}

/* Badge mini-panel */
.badge-panel {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
    margin-bottom: 2rem;
}

.mini-badge {
    font-size: 1.5rem;
    opacity: 0.1;
    filter: grayscale(1);
    background: white;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: var(--transition);
}

.mini-badge.unlocked {
    opacity: 1;
    filter: none;
    background: var(--trig-primary);
    color: white;
    transform: scale(1.1);
}

/* Challenge Mode */
#challenge-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(20px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.challenge-workspace {
    width: 100%;
    max-width: 700px;
    background: white;
    padding: 3rem;
    border-radius: 32px;
    box-shadow: 0 40px 100px rgba(0,0,0,0.4);
    animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { transform: translateY(40px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.tutor-bubble {
    background: #f1f5f9;
    padding: 2rem;
    border-radius: 20px;
    border-left: 8px solid var(--trig-secondary);
    margin-bottom: 2rem;
    font-size: 1.2rem;
    color: var(--whale-blue);
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.2rem;
}

.option-btn {
    background: white;
    border: 2px solid #e2e8f0;
    padding: 1.5rem;
    border-radius: 16px;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--whale-blue);
    font-family: 'Outfit';
}

.option-btn:hover {
    border-color: var(--trig-secondary);
    background: var(--sage-light);
    transform: translateX(5px);
}

.stage-tracker {
    display: flex;
    gap: 0.8rem;
    margin-bottom: 2rem;
    justify-content: center;
}

.dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #cbd5e1;
    transition: var(--transition);
}

.dot.active {
    background: var(--trig-secondary);
    transform: scale(1.4);
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 5px 15px rgba(245, 158, 11, 0.3); }
    50% { transform: scale(1.05); box-shadow: 0 8px 25px rgba(245, 158, 11, 0.5); }
    100% { transform: scale(1); box-shadow: 0 5px 15px rgba(245, 158, 11, 0.3); }
}

.topic-link[onclick*="startChallenge"] {
    animation: pulse 2s infinite ease-in-out;
}

@media (max-width: 768px) {
    .challenge-workspace { padding: 1.5rem; }
    .tutor-bubble { font-size: 1rem; }
}
footer {
    margin-top: 6rem;
    padding: 4rem 2rem;
    text-align: center;
    border-top: 1px solid #e2e8f0;
}

.footer-nav a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    text-decoration: none;
    color: var(--whale-blue);
    font-weight: 700;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: var(--transition);
}

.footer-nav a:hover {
    transform: translateY(-3px);
    background: var(--whale-blue);
    color: white;
}

@media (max-width: 768px) {
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
}
