/**
 * Letter Honeycomb Game - Stylesheet
 * Author: Abdullatif Alkhanbashi
 * Year: 2025
 * 
 * Modern, responsive CSS for a bilingual educational game.
 * Features dark mode, animations, and mobile-optimized design.
 */

/* Import fonts for Arabic and English support */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;900&family=Cairo:wght@400;700;900&family=Roboto:wght@400;500;700;900&display=swap');

/* CSS Custom Properties for theming */
:root {
    /* Light mode color palette */
    --primary-color: #4caf50;
    --primary-dark: #388e3c;
    --primary-light: #81c784;
    --secondary-color: #ff5252;
    --secondary-dark: #d32f2f;
    --secondary-light: #ff8a80;
    --accent-color: #9c27b0;
    --accent-dark: #7b1fa2;
    --accent-light: #ce93d8;
    --cream-color: #fffde7;
    --cream-dark: #f9f7d7;
    --dark-color: #1a237e;
    
    /* Background and surface colors */
    --bg-color: #f5f7fa;
    --bg-gradient: radial-gradient(circle, #f7f9fc 0%, #e4e8ed 100%);
    --card-bg: white;
    --overlay-bg: rgba(0, 0, 0, 0.7);
    
    /* Text colors */
    --text-color: #333;
    --title-color: #000000;
    --footer-color: #777;
    --hex-text-color: #333;
    
    /* Button colors */
    --btn-bg: #e9ecef;
    --reset-btn-bg: #607d8b;
    --reset-btn-color: white;
    --theme-btn-bg: #000000;
    --theme-btn-color: white;
    
    /* Shadows and borders */
    --shadow-sm: 0 3px 6px rgba(0,0,0,0.15);
    --shadow-md: 0 5px 12px rgba(0,0,0,0.2);
    --shadow-lg: 0 12px 28px rgba(0,0,0,0.25);
    --hex-border: rgba(0,0,0,0.2);
    --honeycomb-border: rgba(255, 255, 255, 0.1);
    
    /* Layout properties */
    --border-radius: 12px;
    --transition-normal: all 0.3s ease;
    --help-dialog-width: 600px;
    
    /* Honeycomb specific */
    --honeycomb-gradient: linear-gradient(135deg, #1a237e, #283593);
    --highlight-glow: 0 0 15px 5px rgba(147, 112, 219, 0.7);
}

/* Dark mode color overrides */
.dark-mode {
    --bg-color: #121212;
    --bg-gradient: radial-gradient(circle, #1a1a1a 0%, #0a0a0a 100%);
    --primary-color: #66bb6a;
    --primary-dark: #4CAF50;
    --primary-light: #a5d6a7;
    --secondary-color: #ff7070;
    --secondary-dark: #E53935;
    --secondary-light: #ffcdd2;
    --accent-color: #ba68c8;
    --accent-dark: #9575CD;
    --accent-light: #d1c4e9;
    --cream-color: #f5f5f5;
    --cream-dark: #e0e0e0;
    --dark-color: #0d0d0d;
    --text-color: #f5f5f5;
    --title-color: #FFFFFF;
    --card-bg: #1e1e1e;
    --footer-color: #BBBBBB;
    --btn-bg: #2a2a2a;
    --theme-btn-bg: #f5f5f5;
    --theme-btn-color: #121212;
    --shadow-sm: 0 3px 6px rgba(0,0,0,0.35);
    --shadow-md: 0 5px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(255,255,255,0.07);
    --honeycomb-gradient: linear-gradient(135deg, #1c1c1c, #0f0f0f);
    --honeycomb-border: rgba(255, 255, 255, 0.08);
    --hex-text-color: #000000;
    --hex-border: rgba(255, 255, 255, 0.15);
    --highlight-glow: 0 0 18px 8px rgba(186, 104, 200, 0.8);
    --overlay-bg: rgba(0, 0, 0, 0.85);
}

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

/* Font family selection based on language */
html[lang="ar"] {
    font-family: 'Cairo', 'Tajawal', Arial, sans-serif;
}

html[lang="en"] {
    font-family: 'Roboto', Arial, sans-serif;
}

/* Body and main container */
body {
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--bg-color);
    color: var(--text-color);
    background-image: var(--bg-gradient);
    transition: var(--transition-normal);
}

.container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    position: relative;
}

/* Theme transition animation */
@keyframes mode-transition {
    0% { opacity: 0.8; }
    100% { opacity: 1; }
}

body.dark-mode, body:not(.dark-mode) {
    animation: mode-transition 0.3s ease;
}

/* Main control buttons layout */
.main-controls {
    display: flex;
    justify-content: flex-end;
    width: 100%;
    margin-bottom: 10px;
    z-index: 10;
}

.controls-group {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

/* Control button styling */
.control-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: none;
    border-radius: 20px;
    background-color: var(--theme-btn-bg);
    color: var(--theme-btn-color);
    cursor: pointer;
    font-weight: bold;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.control-btn.icon-only {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    padding: 0;
    justify-content: center;
}

.control-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.control-btn i {
    font-size: 16px;
    transition: transform 0.5s ease;
}

/* Special styling for sun icon in dark mode */
body.dark-mode .control-btn i.fa-sun {
    color: #f9d71c;
}

/* Header and title styling */
.header {
    text-align: center;
    margin-bottom: 1.5rem;
    width: 100%;
}

.game-title {
    font-size: 2.8rem;
    font-weight: 900;
    color: var(--title-color);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
    transition: var(--transition-normal);
}

.game-title i {
    color: var(--accent-color);
    margin: 0 10px;
    transition: var(--transition-normal);
}

.game-title span {
    background: linear-gradient(45deg, var(--secondary-color), var(--accent-color));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 900;
}

/* Color control buttons container */
.controls-container {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 25px;
    width: 100%;
    border-top: 4px solid var(--primary-color);
    transition: var(--transition-normal);
}

.controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

html[dir="rtl"] .controls {
    direction: rtl;
}

/* Color selection buttons */
.color-btn {
    padding: 12px 18px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    flex: 1;
    min-width: 130px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.color-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.color-btn:active {
    transform: translateY(1px);
}

/* Individual button color schemes */
.green-btn { 
    background-color: var(--primary-color); 
    color: white; 
    border: 2px solid var(--primary-dark);
}

.green-btn:hover {
    background-color: var(--primary-dark);
}

.red-btn { 
    background-color: var(--secondary-color); 
    color: white; 
    border: 2px solid var(--secondary-dark);
}

.red-btn:hover {
    background-color: var(--secondary-dark);
}

.cream-btn { 
    background-color: var(--cream-color);
    color: var(--hex-text-color);
    border: 2px solid var(--cream-dark);
}

.cream-btn:hover {
    background-color: var(--cream-dark);
}

.reset-btn { 
    background-color: var(--reset-btn-bg); 
    color: var(--reset-btn-color); 
    border: 2px solid #455a64;
}

.reset-btn:hover {
    background-color: #455a64;
}

.random-btn { 
    background-color: var(--accent-color); 
    color: white; 
    border: 2px solid var(--accent-dark);
}

.random-btn:hover {
    background-color: var(--accent-dark);
}

.shuffle-btn { 
    background-color: #ff9800; 
    color: white; 
    border: 2px solid #f57c00;
}

.shuffle-btn:hover {
    background-color: #f57c00;
}

/* Status message display */
.status-text {
    margin: 20px 0;
    padding: 15px 25px;
    font-size: 18px;
    font-weight: bold;
    background-color: var(--card-bg);
    border-radius: 10px;
    box-shadow: var(--shadow-md);
    width: 100%;
    text-align: center;
    transition: var(--transition-normal);
    border-left: 4px solid var(--accent-color);
    border-right: 4px solid var(--accent-color);
}

/* Status update animation */
@keyframes status-update {
    0% { transform: scale(0.98); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.status-text-update {
    animation: status-update 0.5s ease;
}

/* Honeycomb game board container */
.honeycomb-container {
    width: 100%;
    max-width: 630px;
    height: 540px;
    position: relative;
    background-color: var(--dark-color);
    padding: 15px;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow-lg);
    margin-top: 10px;
    background-image: var(--honeycomb-gradient);
    border: 5px solid var(--honeycomb-border);
    overflow: hidden;
    transition: var(--transition-normal);
}

.honeycomb {
    position: relative;
    width: 449px;
    height: 500px;
    margin: 0 auto;
    transform-origin: center center;
    transition: transform 0.3s ease;
}

/* Hexagonal cell styling */
.hex {
    position: absolute;
    width: 80px;
    height: 92px;
    background-color: var(--cream-color);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    -webkit-clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid var(--hex-border);
    z-index: 1;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.hex:hover {
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 0 15px rgba(255,255,255,0.2);
}

/* Mobile-specific hover behavior */
@media (hover: none) {
    .hex:hover {
        transform: none;
    }
    
    .hex:active {
        transform: scale(1.05);
    }
}

/* Hex cell color variations */
.hex.cream { 
    background-color: var(--cream-color); 
    color: var(--hex-text-color);
}

.hex.letter {
    color: var(--hex-text-color);
    font-weight: bold;
    text-shadow: 0 0 1px rgba(0,0,0,0.3);
}

.dark-mode .hex.cream.letter {
    color: #000000;
    background-color: #f0f0f0;
    text-shadow: none;
}

.hex.green { 
    background-color: var(--primary-color); 
    color: white;
}

.hex.pink { 
    background-color: var(--secondary-color); 
    color: white;
}

.hex.purple {
    background-color: var(--accent-color);
    color: white;
}

/* Selected cell styling */
.hex.selected-green, .hex.selected-red {
    transform: scale(1.05);
    z-index: 5;
    animation: subtle-pulse 2s infinite ease-in-out;
}

.hex.selected-green {
    background-color: var(--primary-color) !important;
    color: white !important;
    box-shadow: 0 0 12px var(--primary-light);
}

.hex.selected-red {
    background-color: var(--secondary-color) !important;
    color: white !important;
    box-shadow: 0 0 12px var(--secondary-light);
}

/* Animation keyframes */
@keyframes subtle-pulse {
    0% { transform: scale(1.05); }
    50% { transform: scale(1.08); box-shadow: 0 0 12px rgba(255, 255, 255, 0.3); }
    100% { transform: scale(1.05); }
}

@keyframes highlight-pulse {
    0% { transform: scale(1.1); box-shadow: var(--highlight-glow); }
    50% { transform: scale(1.15); box-shadow: 0 0 20px 8px var(--accent-color); }
    100% { transform: scale(1.1); box-shadow: var(--highlight-glow); }
}

@keyframes letter-flip {
    0% { transform: rotateY(0deg); opacity: 1; }
    50% { transform: rotateY(90deg); opacity: 0; }
    100% { transform: rotateY(0deg); opacity: 1; }
}

@keyframes color-change {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); filter: brightness(1.2); }
    100% { transform: scale(1.05); }
}

/* Animation classes */
.hex.letter.shuffling {
    animation: letter-flip 0.5s ease;
}

.hex.color-changing {
    animation: color-change 0.3s forwards;
}

/* Random letter highlight effect */
.hex.highlight {
    transform: scale(1.1) !important;
    box-shadow: var(--highlight-glow) !important;
    z-index: 20 !important;
    animation: highlight-pulse 1.5s infinite !important;
}

.hex.highlight.purple {
    background-color: var(--accent-color) !important;
    color: white !important;
    text-shadow: 0 0 4px white !important;
}

.dark-mode .hex.highlight.purple {
    background-color: var(--accent-light) !important;
    color: #000 !important;
    text-shadow: 0 0 4px rgba(0,0,0,0.5) !important;
}

/* Hexagon positioning grid - optimized positioning */
.hex:nth-child(1) { left: -35px; top: 0px; }
.hex:nth-child(2) { left: 45px; top: 0px; }
.hex:nth-child(3) { left: 125px; top: 0px; }
.hex:nth-child(4) { left: 205px; top: 0px; }
.hex:nth-child(5) { left: 285px; top: 0px; }
.hex:nth-child(6) { left: 365px; top: 0px; }
.hex:nth-child(7) { left: -75px; top: 70px; }
.hex:nth-child(8) { left: 5px; top: 70px; }
.hex:nth-child(9) { left: 85px; top: 70px; }
.hex:nth-child(10) { left: 165px; top: 70px; }
.hex:nth-child(11) { left: 245px; top: 70px; }
.hex:nth-child(12) { left: 325px; top: 70px; }
.hex:nth-child(13) { left: 405px; top: 70px; }
.hex:nth-child(14) { left: -35px; top: 140px; }
.hex:nth-child(15) { left: 45px; top: 140px; }
.hex:nth-child(16) { left: 125px; top: 140px; }
.hex:nth-child(17) { left: 205px; top: 140px; }
.hex:nth-child(18) { left: 285px; top: 140px; }
.hex:nth-child(19) { left: 365px; top: 140px; }
.hex:nth-child(20) { left: 445px; top: 140px; }
.hex:nth-child(21) { left: -75px; top: 210px; }
.hex:nth-child(22) { left: 5px; top: 210px; }
.hex:nth-child(23) { left: 85px; top: 210px; }
.hex:nth-child(24) { left: 165px; top: 210px; }
.hex:nth-child(25) { left: 245px; top: 210px; }
.hex:nth-child(26) { left: 325px; top: 210px; }
.hex:nth-child(27) { left: 405px; top: 210px; }
.hex:nth-child(28) { left: -35px; top: 280px; }
.hex:nth-child(29) { left: 45px; top: 280px; }
.hex:nth-child(30) { left: 125px; top: 280px; }
.hex:nth-child(31) { left: 205px; top: 280px; }
.hex:nth-child(32) { left: 285px; top: 280px; }
.hex:nth-child(33) { left: 365px; top: 280px; }
.hex:nth-child(34) { left: 445px; top: 280px; }
.hex:nth-child(35) { left: -75px; top: 350px; }
.hex:nth-child(36) { left: 5px; top: 350px; }
.hex:nth-child(37) { left: 85px; top: 350px; }
.hex:nth-child(38) { left: 165px; top: 350px; }
.hex:nth-child(39) { left: 245px; top: 350px; }
.hex:nth-child(40) { left: 325px; top: 350px; }
.hex:nth-child(41) { left: 405px; top: 350px; }
.hex:nth-child(42) { left: -35px; top: 420px; }
.hex:nth-child(43) { left: 45px; top: 420px; }
.hex:nth-child(44) { left: 125px; top: 420px; }
.hex:nth-child(45) { left: 205px; top: 420px; }
.hex:nth-child(46) { left: 285px; top: 420px; }
.hex:nth-child(47) { left: 365px; top: 420px; }

/* Game statistics display */
.game-stats {
    display: flex;
    justify-content: space-around;
    width: 100%;
    margin-top: 20px;
    gap: 20px;
}

.stat-box {
    flex: 1;
    padding: 15px;
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    transition: var(--transition-normal);
}

.stat-box:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.stat-box:first-child {
    border-bottom: 3px solid var(--primary-color);
}

.stat-box:last-child {
    border-bottom: 3px solid var(--secondary-color);
}

.stat-box i {
    font-size: 20px;
}

.stat-box:first-child i {
    color: var(--primary-color);
}

.stat-box:last-child i {
    color: var(--secondary-color);
}

/* Footer styling */
.footer {
    margin-top: 30px;
    text-align: center;
    color: var(--footer-color);
    font-size: 14px;
    padding: 15px;
    background-color: var(--card-bg);
    width: 100%;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-normal);
}

/* Modal dialog styles */
.confirm-dialog, .help-dialog {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay-bg);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
    transition: opacity 0.3s ease;
}

.dialog-content, .help-content {
    background-color: var(--card-bg);
    padding: 25px;
    border-radius: var(--border-radius);
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    text-align: center;
    transition: var(--transition-normal);
    transform: scale(0.95);
    animation: dialog-appear 0.3s forwards;
}

.help-content {
    max-width: var(--help-dialog-width);
    max-height: 80vh;
    overflow-y: auto;
    text-align: left;
}

@keyframes dialog-appear {
    0% { transform: scale(0.95); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.dialog-content h3 {
    margin-bottom: 15px;
    color: var(--accent-color);
    font-size: 1.5rem;
}

.dialog-content p {
    margin-bottom: 20px;
    font-size: 1.1rem;
    line-height: 1.6;
    color: var(--text-color);
}

/* Help dialog content styling */
.help-content h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.8rem;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 10px;
}

.help-content h4 {
    color: var(--accent-color);
    margin: 20px 0 10px;
    font-size: 1.3rem;
}

.help-content p {
    margin-bottom: 15px;
    line-height: 1.6;
    font-size: 1.05rem;
}

.help-content ul {
    margin-bottom: 15px;
    padding-left: 20px;
    padding-right: 20px;
}

/* Arabic content specific styling */
html[lang="ar"] .help-content ul {
    padding-left: 0;
    padding-right: 20px;
    text-align: right;
    direction: rtl;
}

html[lang="ar"] .help-content li {
    text-align: right;
    direction: rtl;
}

.help-content li {
    margin-bottom: 8px;
    line-height: 1.4;
}

.help-content li strong {
    color: var(--accent-color);
}

/* Dialog button styling */
.dialog-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.dialog-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.yes-btn { 
    background-color: var(--primary-color); 
    color: white; 
}

.yes-btn:hover {
    background-color: var(--primary-dark);
}

.no-btn { 
    background-color: var(--secondary-color); 
    color: white; 
}

.no-btn:hover {
    background-color: var(--secondary-dark);
}

.dialog-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.close-help-btn {
    display: block;
    margin: 20px auto 0;
    padding: 10px 25px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.close-help-btn:hover {
    background-color: var(--accent-dark);
    transform: translateY(-3px);
}

/* Responsive design - Mobile optimization */

/* Hide button text on smaller screens */
@media (max-width: 600px) {
    .btn-text {
        display: none;
    }
    
    .control-btn {
        padding: 8px;
        width: 38px;
        height: 38px;
        justify-content: center;
        align-items: center;
    }
}

/* Medium mobile devices */
@media (max-width: 700px) {
    .container { 
        padding: 10px; 
    }
    
    .main-controls {
        margin-bottom: 15px;
        justify-content: center;
    }
    
    .honeycomb-container { 
        width: 100%; 
        max-width: 600px;
        height: 420px;
        padding: 10px;
    }
    
    .honeycomb {
        transform: scale(0.7);
        transform-origin: center center;
        margin: 0 auto;
    }
    
    .controls { 
        gap: 8px; 
    }
    
    .color-btn {
        min-width: 110px;
        font-size: 14px;
        padding: 10px 15px;
    }
    
    .game-title { 
        font-size: 2.5rem; 
        margin-top: 10px;
    }
    
    .status-text {
        font-size: 16px;
        padding: 12px 15px;
    }
    
    .help-content {
        max-width: 95%;
        padding: 20px;
    }
    
    .help-content h3 {
        font-size: 1.5rem;
    }
    
    .help-content h4 {
        font-size: 1.2rem;
    }
}

/* Small mobile devices */
@media (max-width: 500px) {
    .honeycomb {
        transform: scale(0.55);
    }
    
    .honeycomb-container { 
        height: 380px; 
    }
    
    .color-btn {
        min-width: 100px;
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .game-title { 
        font-size: 2rem; 
    }
    
    .game-stats { 
        flex-direction: column; 
    }
}

/* Extra small mobile devices */
@media (max-width: 400px) {
    .honeycomb { 
        transform: scale(0.45); 
    }
    
    .honeycomb-container { 
        height: 340px; 
    }
    
    .color-btn {
        min-width: 90px;
        padding: 8px 10px;
        font-size: 13px;
    }
    
    .controls-container { 
        padding: 15px 10px; 
    }
}
