/* Reset and base styles for cross-browser compatibility */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    overflow: hidden;
    user-select: none;
}

/* Main container adapts to iframe or full browser window */
#main-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    position: relative;
    display: flex;
    flex-direction: column;
    background: linear-gradient(to bottom, #87CEEB 0%, #98FB98 50%, #8FBC8F 100%);
    cursor: help;
}

/* Detect if running in full browser window */
@media (min-height: 500px) {
    #main-container {
        height: 90vh;
    }
}

/* Earth visualization container */
#earth-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Earth representation */
#earth {
    width: 120px;
    height: 120px;
    background: radial-gradient(circle at 30% 30%, #4CAF50, #2E7D32);
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    animation: rotate 20s linear infinite;
}

/* Earth rotation animation */
@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Atmosphere layer around Earth - Modified to create a visible ring for particles */
#atmosphere {
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border: 3px solid rgba(135, 206, 235, 0.6);
    border-radius: 50%;
    animation: pulse 3s ease-in-out infinite;
    /* Added background to create a visible atmospheric layer */
    background: rgba(135, 206, 235, 0.1);
}

/* Atmosphere pulsing effect */
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

/* Sun representation */
#sun {
    position: absolute;
    top: 20px;
    right: 30px;
    width: 40px;
    height: 40px;
    background: radial-gradient(circle, #FFD700, #FFA500);
    border-radius: 50%;
    box-shadow: 0 0 15px #FFD700;
    animation: sunGlow 2s ease-in-out infinite alternate;
}

/* Sun glowing animation */
@keyframes sunGlow {
    from { box-shadow: 0 0 15px #FFD700; }
    to { box-shadow: 0 0 25px #FFD700, 0 0 35px #FFA500; }
}

/* Heat rays from sun */
#heat-rays {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

/* Individual greenhouse gas particles - Modified to stay within atmosphere ring */
.gas-particle {
    position: absolute;
    border-radius: 50%;
    animation: float 4s ease-in-out infinite;
    pointer-events: none;
    /* Added z-index to ensure particles appear above Earth but below other elements */
    z-index: 10;
}

/* Floating animation for gas particles - Modified for more realistic atmospheric movement */
@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); opacity: 0.8; }
    25% { transform: translateY(-8px) rotate(90deg); opacity: 1; }
    50% { transform: translateY(-4px) rotate(180deg); opacity: 0.9; }
    75% { transform: translateY(-12px) rotate(270deg); opacity: 1; }
}

/* CO2 particles - gray, slightly larger as they're more abundant */
.co2-particle {
    background: rgba(128, 128, 128, 0.8);
    width: 6px;
    height: 6px;
    box-shadow: 0 0 3px rgba(128, 128, 128, 0.5);
}

/* Methane particles - orange, medium size */
.ch4-particle {
    background: rgba(255, 165, 0, 0.8);
    width: 5px;
    height: 5px;
    box-shadow: 0 0 3px rgba(255, 165, 0, 0.5);
}

/* Nitrous oxide particles - purple, smaller size */
.n2o-particle {
    background: rgba(147, 112, 219, 0.8);
    width: 4px;
    height: 4px;
    box-shadow: 0 0 2px rgba(147, 112, 219, 0.5);
}

/* Control panel styling */
#controls-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-top: 2px solid #ddd;
    display: flex;
    justify-content: space-around;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

/* Individual control group */
.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
    flex: 1;
}

/* Gas labels with color coding */
.gas-label {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 5px;
    text-align: center;
}

.co2-label { color: #666; }
.ch4-label { color: #FF8C00; }
.n2o-label { color: #9370DB; }

/* Unit labels */
.unit {
    font-size: 11px;
    font-weight: normal;
    opacity: 0.7;
}

/* Slider styling for better touch interaction */
.slider {
    width: 100%;
    height: 25px;
    border-radius: 15px;
    outline: none;
    margin: 5px 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

/* Slider track */
.slider::-webkit-slider-track {
    height: 8px;
    border-radius: 4px;
    background: #ddd;
}

/* Slider thumb */
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

/* Color-coded slider thumbs */
.co2-slider::-webkit-slider-thumb { background: #666; }
.ch4-slider::-webkit-slider-thumb { background: #FF8C00; }
.n2o-slider::-webkit-slider-thumb { background: #9370DB; }

/* Value display */
.value-display {
    font-size: 12px;
    font-weight: bold;
    color: #333;
    min-width: 40px;
    text-align: center;
}

/* Thermometer container in bottom left */
#thermometer-container {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 100;
}

/* Thermometer styling */
#thermometer {
    display: flex;
    align-items: flex-end;
    gap: 5px;
}

/* Temperature scale */
#temperature-scale {
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    font-size: 10px;
    color: #333;
}

.temp-mark {
    text-align: right;
    padding-right: 5px;
}

/* Temperature tube */
#temperature-tube {
    width: 15px;
    height: 80px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #333;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

/* Mercury/temperature indicator */
#mercury {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, #ff4444, #ff6666);
    border-radius: 0 0 4px 4px;
    transition: height 0.5s ease;
    height: 50%;
}

/* Temperature display */
#temperature-display {
    font-size: 12px;
    font-weight: bold;
    color: #333;
    text-align: center;
    margin-top: 5px;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 5px;
    border-radius: 3px;
}

/* Reset button */
#reset-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #4CAF50;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    min-height: 32px;
}

#reset-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

#reset-btn:active {
    transform: translateY(0);
}

/* Tooltip styling */
.tooltip {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 15px;
    border-radius: 8px;
    max-width: 300px;
    font-size: 12px;
    line-height: 1.4;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    /* Allow dragging interaction */
    pointer-events: auto;
    cursor: grab;
}

.tooltip.dragging {
    cursor: grabbing;
}

.tooltip h3 {
    margin-bottom: 8px;
    color: #4CAF50;
    font-size: 14px;
}

.tooltip ul {
    margin-top: 8px;
    padding-left: 15px;
}

.tooltip li {
    margin-bottom: 4px;
}

.hidden {
    display: none;
}

/* Mobile responsiveness */
@media (max-width: 480px) {
    #controls-panel {
        padding: 10px;
        gap: 8px;
    }
    
    .gas-label {
        font-size: 12px;
    }
    
    .slider {
        height: 30px;
    }
    
    #earth {
        width: 100px;
        height: 100px;
    }
    
    #sun {
        width: 35px;
        height: 35px;
    }
    
    #thermometer-container {
        bottom: 15px;
        left: 15px;
    }
    
    #temperature-tube {
        height: 60px;
        width: 12px;
    }
}
