/* Kurzgesagt-inspired color palette */
:root {
    --primary-blue: #4285f4;
    --bright-orange: #ff6b35;
    --cosmic-purple: #8b5cf6;
    --stellar-yellow: #fbbf24;
    --nebula-pink: #ec4899;
    --space-teal: #10b981;
    --dark-space: #1a1a2e;
    --light-space: #16213e;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --card-bg: #1e293b;
    --positive-green: #22c55e;
    --negative-red: #ef4444;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, var(--dark-space) 0%, var(--light-space) 100%);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated space background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, #fff, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.6), transparent),
        radial-gradient(2px 2px at 160px 30px, #fff, transparent);
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: twinkle 8s infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.3; }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

.logo-link {
    display: inline-block;
    transition: transform 0.2s ease;
    text-decoration: none;
    vertical-align: middle;
}

.logo-link:hover {
    transform: scale(1.05);
}

.logo-link .logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    vertical-align: baseline;
    margin-right: 0.5rem;
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(45deg, var(--primary-blue), var(--cosmic-purple), var(--bright-orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 400;
    line-height: 1.6;
}

header p a {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

header p a:hover {
    color: var(--bright-orange);
    text-decoration: underline;
}

.controls-section {
    margin-bottom: 3rem;
}

.presets-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.presets-bar h3 {
    color: var(--text-light);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.preset-btn {
    background: var(--card-bg);
    border: 2px solid var(--text-muted);
    border-radius: 12px;
    color: var(--text-light);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-btn:hover {
    border-color: var(--primary-blue);
    background: rgba(66, 133, 244, 0.1);
    transform: translateY(-2px);
}

.preset-btn.active {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: white;
}

.preset-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.trash-btn {
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    text-align: center;
    line-height: 1;
}

.trash-btn:hover {
    color: var(--negative-red);
    background: rgba(239, 68, 68, 0.1);
    transform: scale(1.1);
}

.final-result-card {
    background: linear-gradient(135deg, var(--cosmic-purple), var(--primary-blue));
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 12px 40px rgba(139, 92, 246, 0.4);
    max-width: 600px;
    margin: 0 auto;
}

.final-result-card h3 {
    font-size: 1.3rem;
    font-weight: 600;
    color: white;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.final-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--stellar-yellow);
    text-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

.great-filter-section {
    margin-top: 3rem;
    padding: 2rem;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.great-filter-text {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-style: italic;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
}

.great-filter-text a {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid var(--primary-blue);
    transition: all 0.2s ease;
}

.great-filter-text a:hover {
    color: var(--bright-orange);
    border-bottom-color: var(--bright-orange);
}

.attribution-text {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.attribution-text p {
    font-size: 0.95rem;
    color: var(--text-muted);
    opacity: 0.8;
    line-height: 1.5;
}

.attribution-text a {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 400;
    transition: color 0.2s ease;
}

.attribution-text a:hover {
    color: var(--bright-orange);
    text-decoration: underline;
}

.prob-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    min-width: 200px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.prob-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-blue), var(--cosmic-purple));
}

.prob-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-blue);
    box-shadow: 0 8px 32px rgba(66, 133, 244, 0.3);
}

.prob-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.percentage {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.absolute-number {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.factors-container {
    margin-top: 2rem;
}

.factors-title {
    text-align: center;
    margin-bottom: 2rem;
}

.factors-title h2 {
    font-size: 1.8rem;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.factors-title p {
    color: var(--text-muted);
    font-size: 1rem;
}

.factors-list {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.factor-item {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    position: relative;
}

.factor-item.baseline {
    border-left: 6px solid var(--stellar-yellow);
    background: linear-gradient(135deg, var(--card-bg), rgba(251, 191, 36, 0.1));
}

.factor-item.reduction {
    border-left: 6px solid var(--negative-red);
    background: linear-gradient(135deg, var(--card-bg), rgba(239, 68, 68, 0.05));
}

.factor-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.factor-item.disabled {
    opacity: 0.4;
    filter: grayscale(70%);
}

.factor-content {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.factor-main {
    flex: 1;
}

.factor-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.factor-icon {
    font-size: 1.5rem;
    min-width: 2rem;
}

.factor-title-group {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.factor-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text-light);
    white-space: nowrap;
}

.factor-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

.factor-slider-container {
    margin-bottom: 0.5rem;
}

.slider-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.slider-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    min-width: 55px;
}

.slider-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary-blue);
    white-space: nowrap;
    min-width: 45px;
    text-align: right;
}

.factor-slider {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.factor-slider::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-blue);
    cursor: pointer;
    border: 2px solid white;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.factor-slider::-webkit-slider-thumb:hover {
    background: var(--bright-orange);
    transform: scale(1.2);
}

.factor-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-blue);
    cursor: pointer;
    border: 2px solid white;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.factor-slider::-moz-range-thumb:hover {
    background: var(--bright-orange);
    transform: scale(1.2);
}

.factor-result {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-blue);
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(66, 133, 244, 0.15), rgba(139, 92, 246, 0.1));
    border-radius: 12px;
    border: 2px solid rgba(66, 133, 244, 0.3);
    min-width: 140px;
    white-space: nowrap;
}

/* Traditional Checkbox Styling */
.checkbox-container {
    display: block;
    position: relative;
    cursor: pointer;
    font-size: 1rem;
    user-select: none;
}

.checkbox-container input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: relative;
    display: inline-block;
    height: 20px;
    width: 20px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--text-muted);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.checkbox-container:hover input ~ .checkmark {
    border-color: var(--primary-blue);
    background-color: rgba(66, 133, 244, 0.1);
}

.checkbox-container input:checked ~ .checkmark {
    background-color: var(--primary-blue);
    border-color: var(--primary-blue);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-container .checkmark:after {
    left: 6px;
    top: 2px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}


.factor-percentage {
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.factor-percentage.clickable {
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.factor-percentage.clickable:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--primary-blue);
    transform: scale(1.05);
}

.rewind-icon {
    color: var(--bright-orange);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: 0.25rem;
}

.rewind-icon:hover {
    color: var(--stellar-yellow);
    transform: rotate(-360deg);
}

.positive .factor-percentage {
    color: var(--positive-green);
}

.negative .factor-percentage {
    color: var(--negative-red);
}

.factor-toggle {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid var(--text-muted);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.factor-toggle:checked {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
}

.factor-toggle:checked::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 12px;
    top: -2px;
    left: 2px;
}

.info-button {
    background: var(--cosmic-purple);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    min-width: 28px;
}

.info-button:hover {
    background: var(--bright-orange);
    border-color: var(--bright-orange);
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.4);
}


/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal.show {
    opacity: 1;
}

.modal.hide {
    opacity: 0;
}

.modal-content {
    background: var(--card-bg);
    margin: 15% auto;
    padding: 2rem;
    border-radius: 16px;
    width: 80%;
    max-width: 500px;
    border: 2px solid var(--primary-blue);
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: scale(1);
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.close:hover {
    color: var(--bright-orange);
}

#modalTitle {
    color: var(--text-light);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

#modalDescription {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

#modalLink {
    color: white;
    text-decoration: underline;
    font-weight: 400;
    transition: all 0.2s ease;
}

#modalLink:hover {
    color: var(--text-muted);
}


/* Responsive design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2.5rem;
    }
    
    .logo-link .logo {
        width: 40px;
        height: 40px;
    }
    
    .final-result-card {
        padding: 1.5rem;
    }
    
    .final-result-card h3 {
        font-size: 1.1rem;
    }
    
    .final-number {
        font-size: 2.2rem;
    }
    
    .factors-list {
        max-width: 100%;
        padding: 0 1rem;
    }
    
    .factor-item {
        padding: 1rem;
    }
    
    .factor-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .factor-result {
        font-size: 1.4rem;
        padding: 0.75rem 1rem;
        min-width: 100px;
    }
    
    .factor-header {
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .factor-title-group {
        gap: 0.5rem;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .factor-title {
        white-space: normal;
    }
    
    .factor-description {
        font-size: 0.8rem;
    }
    
    .info-button {
        width: 24px;
        height: 24px;
        font-size: 12px;
        min-width: 24px;
    }
    
    .factor-slider-container {
        margin-bottom: 0.75rem;
    }
    
    .slider-controls {
        gap: 0.75rem;
    }
    
    .slider-label {
        min-width: 50px;
        font-size: 0.8rem;
    }
    
    .slider-value {
        min-width: 40px;
        font-size: 0.9rem;
    }
    
    .factor-icon {
        font-size: 1.2rem;
    }
    
    .presets-bar {
        flex-direction: column;
        gap: 1rem;
    }
    
    .presets-bar h3 {
        margin-bottom: 0.5rem;
    }
    
    .preset-btn {
        padding: 0.75rem 1.25rem;
        font-size: 1rem;
    }
    
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 1.5rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .container {
        padding: 1rem;
    }
}

/* Print styles */
@media print {
    /* Remove animated background for printing */
    body::before {
        display: none;
    }
    
    /* Adjust body styles for print */
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.4;
    }
    
    /* Container adjustments */
    .container {
        max-width: none;
        width: 100%;
        margin: 0;
        padding: 0.5in;
    }
    
    /* Header adjustments */
    header h1 {
        color: black !important;
        font-size: 24pt;
        margin-bottom: 12pt;
        background: none !important;
        -webkit-text-fill-color: initial !important;
    }
    
    header p {
        color: #666 !important;
        font-size: 14pt;
        margin-bottom: 20pt;
    }
    
    /* Hide interactive elements */
    .presets-bar {
        display: none;
    }
    
    .factor-slider {
        display: none;
    }
    
    .slider-controls {
        display: none;
    }
    
    .info-button {
        display: none;
    }
    
    .checkbox-container {
        display: none;
    }
    
    /* Final result card for print */
    .final-result-card {
        background: #f5f5f5 !important;
        border: 2px solid #333 !important;
        color: black !important;
        page-break-inside: avoid;
        margin-bottom: 20pt;
        box-shadow: none !important;
    }
    
    .final-result-card h3 {
        color: black !important;
        font-size: 16pt;
    }
    
    .final-number {
        color: #333 !important;
        font-size: 24pt;
        text-shadow: none !important;
    }
    
    /* Factors container */
    .factors-title h2 {
        color: black !important;
        font-size: 18pt;
        margin-bottom: 12pt;
        page-break-after: avoid;
    }
    
    .factors-title p {
        color: #666 !important;
        font-size: 12pt;
        margin-bottom: 16pt;
    }
    
    /* Factor items for print - override all borders and styling */
    .factor-item,
    .factor-item.baseline,
    .factor-item.reduction {
        background: white;
        border: none;
        border-left: none;
        border-radius: 0;
        margin-bottom: 12pt;
        padding: 8pt 0;
        page-break-inside: avoid;
        box-shadow: none;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        width: 100%;
        max-width: none;
    }
    
    .factor-item.baseline {
        font-weight: bold;
    }
    
    .factor-item.reduction {
        /* No special styling needed */
    }
    
    .factor-item.disabled {
        opacity: 0.5;
        background: #f9f9f9 !important;
    }
    
    /* Factor content layout for print - horizontal layout */
    .factor-item .factor-content {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
        width: 100%;
        max-width: none;
        gap: 20pt;
    }
    
    .factor-item .factor-main {
        flex: 1;
        margin-bottom: 0;
        min-width: 0;
        padding-right: 0;
    }
    
    /* Factor results positioned on the right */
    .factor-item .factor-result {
        flex-shrink: 0;
        min-width: 100pt;
        text-align: right;
    }
    
    .factor-item .factor-header {
        display: flex;
        align-items: flex-start;
        gap: 8pt;
        margin-bottom: 4pt;
        width: 100%;
    }
    
    .factor-item .factor-icon {
        font-size: 14pt;
        min-width: auto;
        flex-shrink: 0;
    }
    
    .factor-item .factor-title-group {
        flex: 1;
        display: block;
        min-width: 0;
    }
    
    .factor-item .factor-title {
        color: black;
        font-weight: bold;
        font-size: 12pt;
        margin-bottom: 2pt;
        word-wrap: break-word;
    }
    
    .factor-item .factor-description {
        color: #666;
        font-size: 10pt;
        font-style: italic;
        word-wrap: break-word;
    }
    
    /* Show current setting values */
    .factor-item .factor-slider-container::after {
        content: attr(data-value);
        display: block;
        color: #333;
        font-size: 10pt;
        font-weight: normal;
        margin-top: 2pt;
    }
    
    /* Show current values and results on the right */
    .factor-item .factor-result {
        display: block;
        text-align: right;
        color: black;
        font-size: 11pt;
        font-weight: bold;
        margin-left: 0;
        min-width: 100pt;
        flex-shrink: 0;
    }
    
    .factor-item .factor-result::before {
        content: "→ ";
        font-weight: normal;
        color: #666;
    }
    
    
    /* Add page breaks and full width layout */
    .factors-container {
        page-break-before: auto;
        width: 100%;
        max-width: none;
    }
    
    .factors-list {
        width: 100%;
        max-width: none;
        margin: 0;
    }
    
    /* Override final result card width constraint */
    .final-result-card {
        max-width: none;
        width: 100%;
        margin: 0 0 20pt 0;
    }
    
    /* Ensure good page breaks */
    h1, h2, h3 {
        page-break-after: avoid;
    }
    
    .factor-item {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    
    /* Print footer with URL */
    @page {
        margin: 0.75in;
        @bottom-right {
            content: "Fermi Paradox Explorer";
            font-size: 10pt;
            color: #666;
        }
    }
    
    /* Hide elements that shouldn't print */
    .modal {
        display: none !important;
    }
}