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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    overflow: hidden;
}

/* Main container - responsive height for iframe vs full browser */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    padding: 10px;
    position: relative;
}

/* Full browser height when not in iframe */
@media (min-height: 500px) {
    .container {
        height: 90vh;
    }
}

/* Control panel styling */
.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 10px;
    z-index: 10;
}

.control-btn {
    background: linear-gradient(145deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    min-height: 36px;
    white-space: nowrap;
}

.control-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

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

.control-btn.playing {
    background: linear-gradient(145deg, #f093fb 0%, #f5576c 100%);
}

/* Legend styling */
.legend {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 12px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    font-size: 12px;
    font-weight: 600;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #333;
}

.legend-color.oxygenated {
    background: #e74c3c;
}

.legend-color.deoxygenated {
    background: #4a90e2;
}

/* Main circulatory system container */
.circulatory-system {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
    overflow: hidden;
}

.circulation-svg {
    width: 100%;
    height: 100%;
    max-width: 400px;
    max-height: 350px;
}

/* Organ and vessel styling */
.organ-label {
    font-size: 12px;
    font-weight: bold;
    fill: #333;
}

.vessel {
    opacity: 0.8;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.2));
}

.vessel:hover {
    opacity: 1;
    stroke-width: 10;
}

/* Blood cell animation */
.blood-cell {
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.3));
    opacity: 0;
}

.blood-cell.active {
    opacity: 1;
}

/* Heart chambers with subtle animation */
.right-heart, .left-heart {
    transition: all 0.3s ease;
}

.heart.beating .right-heart,
.heart.beating .left-heart {
    animation: heartbeat 1.2s ease-in-out infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Caption area */
.caption-area {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 10px;
    padding: 8px 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.caption {
    font-size: 14px;
    text-align: center;
    color: #333;
    font-weight: 500;
    line-height: 1.4;
}

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

.tooltip.show {
    opacity: 1;
}

/* Responsive design for mobile */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    .controls {
        gap: 8px;
    }
    
    .control-btn {
        padding: 6px 12px;
        font-size: 12px;
        min-height: 32px;
    }
    
    .legend {
        gap: 15px;
    }
    
    .legend-item {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    .legend-color {
        width: 14px;
        height: 14px;
    }
    
    .caption {
        font-size: 12px;
    }
    
    .organ-label {
        font-size: 10px;
    }
}

/* Touch-friendly hover states for mobile */
@media (hover: none) {
    .control-btn:hover {
        transform: none;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    }
    
    .vessel:hover {
        opacity: 0.8;
        stroke-width: 8;
    }
}

/* Animation states */
.paused .blood-cell {
    animation-play-state: paused !important;
}

.stopped .blood-cell {
    opacity: 0 !important;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .blood-cell {
        animation: none !important;
    }
    
    .heart.beating .right-heart,
    .heart.beating .left-heart {
        animation: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .legend-color.oxygenated {
        background: #ff0000;
    }
    
    .legend-color.deoxygenated {
        background: #0000ff;
    }
    
    .vessel {
        stroke-width: 10;
    }
}