/* 
   CSS Styles for Volleyball Adventure Interactive
   Designed for iframe (450px height) and standalone (90vh)
   Follows cognitive load principles and Mayer's multimedia learning principles
*/

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    touch-action: none;
}

/* Main container adapts to iframe or standalone */
#main-container {
    width: 100%;
    height: 450px; /* Default for iframe */
    display: flex;
    flex-direction: column;
    position: relative;
    background: linear-gradient(to bottom, #e8f4f8 0%, #b8d4e8 100%);
}

/* Standalone mode detection */
@media (min-height: 500px) {
    #main-container {
        height: 90vh;
    }
}

/* Tooltip for header (appears on hover at top) */
#header-tooltip {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 1000;
    max-width: 90%;
    text-align: center;
}

#main-container:hover #header-tooltip {
    opacity: 1;
}

/* Story panel for narrative and choices */
#story-panel {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    padding: 12px 15px;
    border-bottom: 3px solid #e17055;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    min-height: 80px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#story-text {
    font-size: 14px;
    line-height: 1.4;
    color: #2d3436;
    font-weight: 500;
}

#choices-container {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.choice-btn {
    background: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    height: auto;
}

.choice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #00cec9 0%, #00b894 100%);
}

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

/* Main game area with three columns */
#game-area {
    flex: 1;
    display: flex;
    gap: 10px;
    padding: 10px;
    overflow: hidden;
}

/* Left column: Draggable roles */
#roles-container {
    flex: 0 0 140px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-label {
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 10px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    text-align: center;
    color: #2d3436;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: help;
}

#draggable-roles {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    padding: 4px;
}

.role-card {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    padding: 10px;
    border-radius: 10px;
    cursor: grab;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    user-select: none;
    touch-action: none;
}

.role-card:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.role-card:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.role-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.role-card.matched {
    background: linear-gradient(135deg, #a8e6cf 0%, #74b9ff 100%);
    cursor: default;
    opacity: 0.6;
}

/* Center column: Volleyball court */
#court-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

#volleyball-court {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: 100%;
    background: linear-gradient(135deg, #ff9a56 0%, #ff6b6b 100%);
    border: 4px solid white;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Court lines */
.court-line {
    position: absolute;
    background: white;
}

.court-line.horizontal {
    width: 100%;
    height: 2px;
}

.court-line.horizontal.top {
    top: 20%;
}

.court-line.horizontal.middle {
    top: 50%;
    height: 3px;
}

.court-line.horizontal.bottom {
    bottom: 20%;
}

.court-line.vertical {
    height: 100%;
    width: 2px;
}

.court-line.vertical.left {
    left: 20%;
}

.court-line.vertical.center {
    left: 50%;
    width: 3px;
}

.court-line.vertical.right {
    right: 20%;
}

/* Drop zones for matching */
.drop-zone {
    position: absolute;
    width: 60px;
    height: 60px;
    border: 3px dashed rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    cursor: help;
}

.drop-zone:hover {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.9);
    transform: translate(-50%, -50%) scale(1.1);
}

.drop-zone.drag-over {
    background: rgba(255, 255, 255, 0.6);
    border-color: #00b894;
    border-style: solid;
    transform: translate(-50%, -50%) scale(1.15);
}

.drop-zone.filled {
    border-color: #00b894;
    border-style: solid;
    background: rgba(0, 184, 148, 0.3);
}

.drop-zone .role-card {
    font-size: 10px;
    padding: 6px;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* Right column: Info and controls */
#info-container {
    flex: 0 0 140px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#score-display {
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.score-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 13px;
}

.score-label {
    font-weight: 600;
    color: #2d3436;
}

#points, #matches {
    font-weight: 700;
    color: #e17055;
    font-size: 15px;
}

#feedback-area {
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 8px;
    min-height: 80px;
    font-size: 12px;
    color: #2d3436;
    overflow-y: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    line-height: 1.4;
}

#reset-btn, #hint-btn, #continue-btn {
    background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
    height: auto;
    white-space: normal;
    text-align: center;
}

#reset-btn:hover, #hint-btn:hover, #continue-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.3);
}

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

/* Audio controls */
#audio-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 8px;
    z-index: 100;
}

.audio-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.audio-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.audio-btn.muted {
    opacity: 0.5;
}

/* Celebration overlay */
#celebration-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

#celebration-overlay.hidden {
    display: none;
}

#celebration-content {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 80%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: popIn 0.5s ease;
}

@keyframes popIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

#celebration-title {
    font-size: 24px;
    color: #e17055;
    margin-bottom: 15px;
}

#celebration-message {
    font-size: 16px;
    color: #2d3436;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Tooltip styling */
.tooltip {
    position: relative;
}

/* Responsive adjustments for touch devices */
@media (hover: none) {
    .role-card {
        min-height: 44px; /* Minimum touch target size */
    }
    
    .drop-zone {
        width: 70px;
        height: 70px;
    }
}

/* Feedback animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

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

.shake {
    animation: shake 0.3s ease;
}

.pulse {
    animation: pulse 0.5s ease;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}