/* Global styles and responsive design */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #98FB98 100%);
    overflow-x: hidden;
}

/* Container adapts to iframe or full window */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Full window mode detection */
@media (min-height: 500px) {
    .container {
        height: 90vh;
    }
}

/* Rainforest diagram container */
.rainforest-diagram {
    flex: 1;
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* SVG styling for responsive design */
.forest-svg {
    width: 100%;
    max-width: 800px;
    height: auto;
    border: 2px solid #8B4513;
    border-radius: 10px;
    background: linear-gradient(to bottom, #87CEEB 0%, #98FB98 30%, #228B22 70%, #8B4513 100%);
    cursor: pointer;
}

/* Layer interaction styles */
.layer {
    cursor: pointer;
    transition: all 0.3s ease;
}

.layer:hover {
    filter: brightness(1.2);
    transform: scale(1.02);
}

.layer.active {
    filter: brightness(1.3) drop-shadow(0 0 10px rgba(255, 255, 0, 0.8));
}

/* Tree and plant styling */
.tree-trunk {
    transition: all 0.3s ease;
}

.tree-crown {
    transition: all 0.3s ease;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
}

.buttress-root {
    opacity: 0.8;
}

.ground-plant {
    opacity: 0.7;
}

/* Layer labels */
.layer-label {
    font-size: 16px;
    font-weight: bold;
    fill: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
    pointer-events: none;
}

/* Height indicators */
.height-indicators {
    opacity: 0.7;
}

.height-text {
    font-size: 12px;
    fill: #333;
    font-weight: bold;
}

/* Information panel */
.info-panel {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    margin: 10px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    min-height: 80px;
    transition: all 0.3s ease;
}

.info-content h3 {
    color: #2E8B57;
    margin-bottom: 8px;
    font-size: 18px;
}

.info-content p {
    color: #333;
    line-height: 1.4;
    font-size: 14px;
}

/* Control buttons */
.controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px;
    flex-wrap: wrap;
}

.control-btn {
    background: linear-gradient(135deg, #32CD32, #228B22);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    min-height: 36px;
    white-space: nowrap;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    background: linear-gradient(135deg, #228B22, #006400);
}

.control-btn:active {
    transform: translateY(0);
}

/* 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.5);
}

.modal-content {
    background-color: #fff;
    margin: 10% auto;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #000;
}

/* Quiz styles */
.question {
    font-size: 16px;
    margin-bottom: 15px;
    font-weight: bold;
    color: #2E8B57;
}

.options {
    margin-bottom: 15px;
}

.option {
    display: block;
    width: 100%;
    padding: 10px;
    margin: 5px 0;
    background: #f0f0f0;
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
}

.option:hover {
    background: #e0f0e0;
    border-color: #32CD32;
}

.option.correct {
    background: #90EE90;
    border-color: #32CD32;
}

.option.incorrect {
    background: #FFB6C1;
    border-color: #FF6B6B;
}

.quiz-btn {
    background: #32CD32;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.quiz-btn:hover {
    background: #228B22;
}

.quiz-result {
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    margin-top: 15px;
}

/* Tooltip styles */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 200px;
    text-align: center;
}

.tooltip.show {
    opacity: 1;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
    .container {
        height: 450px; /* Fixed height for mobile iframe */
    }
    
    .rainforest-diagram {
        padding: 5px;
    }
    
    .info-panel {
        margin: 5px;
        padding: 10px;
        min-height: 60px;
    }
    
    .info-content h3 {
        font-size: 16px;
    }
    
    .info-content p {
        font-size: 13px;
    }
    
    .control-btn {
        font-size: 12px;
        padding: 6px 12px;
        min-height: 32px;
    }
    
    .layer-label {
        font-size: 14px;
    }
    
    .height-text {
        font-size: 10px;
    }
    
    .modal-content {
        margin: 5% auto;
        width: 95%;
        padding: 15px;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    .layer:hover {
        filter: none;
        transform: none;
    }
    
    .control-btn:hover {
        transform: none;
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        background: linear-gradient(135deg, #32CD32, #228B22);
    }
    
    .option:hover {
        background: #f0f0f0;
        border-color: #ddd;
    }
}

/* Animation for layer highlighting */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.layer.pulse {
    animation: pulse 1s ease-in-out;
}

/* Sound button active state */
.control-btn.sound-active {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #333;
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}