/* 
 * TypeSmash - Main Stylesheet
 * Dark theme with responsive design
 */

/* CSS Variables for theme colors */
:root {
    /* Main theme colors - dark theme */
    --bg-color: #323437;
    --main-color: #b19cd9; /* Changed from yellow to lavender */
    --text-color: #d1d0c5;
    --error-color: #ca4754;
    --success-color: #7aac7a;
    --subtle-color: #646669;
    --focus-color: #2c2e31;
    
    /* Zoro mode colors */
    --zoro-bg-color: #121212;
    --zoro-accent: #a88bfa;
    --zoro-text: #e9e9e9;
    
    /* Size variables */
    --font-size: 1rem;
    --font-size-large: 1.5rem;
    --font-size-small: 0.85rem;
    --border-radius: 4px;
    
    /* Animation timing */
    --transition-speed: 0.3s;
}

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

body {
    font-family: 'Roboto Mono', monospace;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color var(--transition-speed) ease;
}

/* App container */
.app-container {
    width: 100%;
    max-width: 900px;
    min-height: 100vh;
    margin: 0 auto;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
}

/* Header styling */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--subtle-color);
}

/* Logo styling */
.logo {
    display: flex;
    align-items: center;
}

.logo-image {
    height: 110px; /* Significantly increased from previous size */
    margin-right: 10px;
    transition: transform 0.3s ease;
}

.logo-image:hover {
    transform: scale(1.05);
}

.logo-title {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--text-color);
}

.mode-switcher {
    display: flex;
    gap: 0.75rem; /* Slightly increased gap */
    align-items: center;
}

.mode-btn, .stats-btn {
    background-color: transparent;
    color: var(--text-color);
    border: 1px solid var(--subtle-color);
    border-radius: var(--border-radius);
    padding: 0.6rem 1.2rem; /* Slightly larger padding */
    cursor: pointer;
    font-family: inherit;
    font-size: var(--font-size);
    transition: all var(--transition-speed) ease;
    min-width: 80px; /* Ensure consistent button width */
    text-align: center;
}

.mode-btn:hover, .stats-btn:hover {
    background-color: var(--focus-color);
}

.mode-btn.active {
    background-color: var(--main-color);
    color: var(--bg-color);
    border-color: var(--main-color);
    font-weight: bold; /* Make active state more visible */
}

.stats-btn {
    background-color: var(--subtle-color);
    min-width: 90px;
}

/* Main content styling */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}

#typing-container {
    width: 100%;
    position: relative;
    min-height: 150px;
}

/* Text display styling */
.text-display {
    width: 100%;
    min-height: 150px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.line {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
    min-height: 2rem;
    gap: 0.8rem;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

/* Ensure smooth line transition with a subtle animation */
@keyframes lineScroll {
    0% { transform: translateY(10px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.line.active {
    opacity: 1;
}

.line.next {
    opacity: 0.6;
}

.line.future {
    opacity: 0.3;
}

.line {
    animation: lineScroll 0.3s ease-out;
}

.word {
    position: relative;
    display: inline-flex;
    margin-right: 0;
    margin-bottom: 0;
}

.word.completed {
    color: var(--success-color);
}

.word.current {
    position: relative;
}

.char {
    font-size: 1.5rem;
    position: relative;
    transition: color 0.15s ease;
}

.char.correct {
    color: var(--success-color);
}

.char.incorrect {
    color: var(--error-color);
}

.char.current {
    text-decoration: underline;
}

.char.extra {
    color: var(--error-color);
}

.cursor {
    position: absolute;
    width: 2px;
    background-color: var(--main-color); /* Now uses lavender color */
    transition: left 0.1s ease, top 0.1s ease;
    animation: blink 1s infinite;
    z-index: 10;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

#input-area {
    width: 0;
    height: 0;
    overflow: hidden;
}

#hidden-input {
    opacity: 0;
    position: absolute;
}

/* Stats container */
#stats-container {
    display: flex;
    gap: 2rem;
    padding: 1.5rem;
    background-color: var(--focus-color);
    border-radius: var(--border-radius);
    flex-wrap: wrap;
    justify-content: center;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.stat-label {
    font-size: var(--font-size-small);
    color: var(--subtle-color);
    text-transform: uppercase;
    margin-bottom: 0.3rem;
}

.stat-value {
    font-size: var(--font-size-large);
    font-weight: bold;
    color: var(--text-color);
}

#wpm {
    color: var(--main-color);
}

#accuracy {
    color: var(--success-color);
}

#errors {
    color: var(--error-color);
}

/* Restart prompt */
#restart-prompt {
    font-size: var(--font-size);
    color: var(--subtle-color);
    padding: 1rem;
    text-align: center;
}

.key {
    background-color: var(--focus-color);
    padding: 0.2rem 0.5rem;
    border-radius: var(--border-radius);
    margin: 0 0.3rem;
    color: var(--main-color);
}

/* Stats section */
#stats-section {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow-y: auto;
}

.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.stats-header h2 {
    font-size: 1.8rem;
    color: var(--main-color);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 2rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: var(--error-color);
}

.filter-controls {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-group, .view-group {
    display: flex;
    gap: 0.5rem;
}

.filter-btn, .view-btn {
    background-color: transparent;
    color: var(--text-color);
    border: 1px solid var(--subtle-color);
    border-radius: var(--border-radius);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: inherit;
    font-size: var(--font-size-small);
    transition: all 0.2s ease;
}

.filter-btn:hover, .view-btn:hover {
    background-color: var(--focus-color);
}

.filter-btn.active, .view-btn.active {
    background-color: var(--main-color);
    color: var(--bg-color);
    border-color: var(--main-color);
}

#filter-zoro.active {
    background-color: var(--zoro-accent);
    border-color: var(--zoro-accent);
}

.stats-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 2rem;
}

.history-graph {
    width: 100%;
    height: 300px;
    background-color: var(--focus-color);
    border-radius: var(--border-radius);
    padding: 1rem;
}

#wpm-graph {
    width: 100%;
    height: 100%;
}

.history-table-container {
    width: 100%;
    overflow-x: auto;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-small);
}

.history-table th,
.history-table td {
    padding: 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--subtle-color);
}

.history-table th {
    color: var(--main-color);
    font-weight: bold;
}

.history-table tbody tr:hover {
    background-color: var(--focus-color);
}

.zoro-mode-cell {
    color: var(--zoro-accent);
    font-weight: bold;
}

.stats-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 1rem;
}

.danger-btn {
    background-color: var(--error-color);
    color: var(--text-color);
    border: none;
    border-radius: var(--border-radius);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: inherit;
    font-size: var(--font-size-small);
    transition: background-color 0.2s ease;
}

.danger-btn:hover {
    background-color: #e03b49;
}

/* Helper classes */
.hidden {
    display: none !important;
}

.flash {
    animation: flash 0.5s;
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Zoro Mode Styling */
.zoro-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    overflow: hidden;
    background-color: #000;
}

.zoro-bg-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.6;
    z-index: 1;
    pointer-events: none; /* Prevent video from capturing clicks */
}

#zoro-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none; /* Allow clicks to pass through canvas */
}

.zoro-score-display {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #b19cd9;
    padding: 12px;
    border-radius: 5px;
    border: 2px solid #b19cd9;
    z-index: 20;
    min-width: 200px;
    font-family: 'Roboto Mono', monospace;
    box-shadow: 0 0 15px rgba(177, 156, 217, 0.5);
    text-align: right;
    pointer-events: none; /* Allow clicks to pass through the score display */
}

.level-indicator {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 8px;
    text-align: center;
    color: #ff9900;
    text-shadow: 0 0 5px rgba(255, 153, 0, 0.7);
}

.score-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.stat-value {
    font-weight: bold;
    color: #ffffff;
}

.zoro-lives {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    z-index: 20;
    pointer-events: none; /* Allow clicks to pass through */
}

.zoro-heart {
    font-size: 2rem;
    filter: drop-shadow(0 0 5px rgba(255, 0, 0, 0.7));
}

.zoro-power-ups {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 20;
    pointer-events: auto; /* Ensure power-ups are clickable */
}

.power-up {
    cursor: pointer; 
    background-color: rgba(0, 0, 0, 0.6);
    border: 1px solid #b19cd9;
    padding: 5px 8px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
    pointer-events: auto;
}

/* Update UI positioning for the new score position */
.zoro-ui {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 230px; /* To avoid overlapping with the score display */
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 20;
}

.zoro-input-area {
    width: 100%;
    max-width: 600px;
    margin-bottom: 10px;
}

#zoro-input {
    width: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: 2px solid #b19cd9;
    padding: 12px;
    font-size: 1.2rem;
    border-radius: 4px;
    outline: none;
}

#zoro-input:focus {
    box-shadow: 0 0 15px rgba(177, 156, 217, 0.7);
}

.zoro-exit-btn {
    background-color: #333;
    color: #fff;
    border: 1px solid #b19cd9;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.zoro-exit-btn:hover {
    background-color: #444;
}

.sword-slash {
    position: absolute;
    width: 80px;
    height: 80px;
    background-image: linear-gradient(45deg, transparent 45%, #b19cd9 45%, #b19cd9 55%, transparent 55%);
    transform: rotate(45deg);
    z-index: 15;
    opacity: 0;
    animation: slash 0.5s ease-out;
}

.flash {
    animation: damageFlash 0.5s;
}

.onigiri-flash {
    animation: onigiriFlash 0.5s;
}

.haki-active {
    filter: sepia(0.5) hue-rotate(220deg);
}

.ashura-clones {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 25;
    pointer-events: none;
}

.ashura-clone {
    position: absolute;
    width: 100px;
    height: 100px;
    background-image: url('../assets/ashura.png');
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0;
    animation: ashuraClone 3s ease-out;
}

/* Animations */
@keyframes slash {
    0% {
        transform: scale(0) rotate(45deg);
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    100% {
        transform: scale(2) rotate(45deg);
        opacity: 0;
    }
}

@keyframes damageFlash {
    0%, 100% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(255, 0, 0, 0.3);
    }
}

@keyframes onigiriFlash {
    0%, 100% {
        background-color: transparent;
    }
    50% {
        background-color: rgba(177, 156, 217, 0.3);
    }
}

@keyframes comboUpdate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.5);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes ashuraClone {
    0% {
        opacity: 0;
        transform: translate(0, 0) scale(0.5);
    }
    20% {
        opacity: 0.7;
        transform: translate(var(--tx, 0), var(--ty, 0)) scale(1);
    }
    80% {
        opacity: 0.7;
        transform: translate(var(--tx, 0), var(--ty, 0)) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(var(--tx, 0), var(--ty, 0)) scale(0.5);
    }
}

/* One Piece Easter Egg Effects */
.nami-effect::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../assets/namiswan.png') no-repeat center center, 
                radial-gradient(circle, rgba(255, 215, 0, 0.1) 0%, rgba(255, 215, 0, 0) 70%);
    background-size: contain;
    animation: berryRain 4s linear; /* Changed from 5s to 4s */
    pointer-events: none;
    z-index: 100;
}

@keyframes berryRain {
    0% { opacity: 0; transform: scale(0.8); }
    20% { opacity: 0.9; transform: scale(1); }
    80% { opacity: 0.9; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.8); }
}

/* Luffy laugh effect */
.luffy-laugh::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../assets/luffylaugh.gif') no-repeat center center;
    background-size: contain;
    opacity: 0.7;
    pointer-events: none;
    z-index: 100;
    animation: luffyLaugh 8s ease-in-out; /* Extended to 8 seconds */
}

@keyframes luffyLaugh {
    0% { opacity: 0; transform: scale(0.5); }
    10% { opacity: 0.7; transform: scale(1); }
    90% { opacity: 0.7; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.5); }
}

/* Gomu Gomu effect */
.gomu-effect::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../assets/angryluffy.gif') no-repeat center center;
    background-size: contain;
    opacity: 0.7;
    pointer-events: none;
    z-index: 100;
    animation: gomuAppear 5s ease-in-out; /* Extended to 5 seconds */
}

@keyframes gomuAppear {
    0% { opacity: 0; transform: scale(0.3) rotate(-10deg); }
    20% { opacity: 0.7; transform: scale(1.1) rotate(5deg); }
    30% { opacity: 0.7; transform: scale(1) rotate(0deg); }
    90% { opacity: 0.7; transform: scale(1) rotate(0deg); }
    100% { opacity: 0; transform: scale(0.3) rotate(10deg); }
}

/* Media queries for responsive design */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1.5rem; /* Increased gap for better spacing */
        align-items: center;
        padding-bottom: 1.5rem;
    }
    
    .logo-image {
        height: 60px; /* Slightly smaller on mobile but still larger than original */
    }
    
    .mode-switcher {
        width: 100%;
        justify-content: center;
    }
    
    .mode-btn, .stats-btn {
        flex: 1;
        max-width: 120px; /* Limit maximum width on mobile */
    }
    
    #stats-container {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
    
    .stat {
        min-width: auto;
        width: 100%;
    }
    
    .zoro-stats {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }
    
    .zoro-power-ups {
        flex-direction: row;
        top: auto;
        right: auto;
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
    }
    
    .zoro-lives {
        top: auto;
        left: auto;
        bottom: 5rem;
        right: 1rem;
    }
}

/* Social icons */
#social-links {
    position: absolute;
    bottom: 2rem;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    z-index: 10;
    transition: opacity 0.3s ease;
}

.social-icon {
    color: var(--subtle-color);
    font-size: 1.8rem;
    transition: all 0.3s ease;
}

.social-icon:hover {
    color: var(--main-color);
    transform: translateY(-3px);
}

/* Hide social icons when typing is active or in Zoro mode */
.typing-active #social-links, 
.zoro-active #social-links {
    opacity: 0;
    pointer-events: none;
}

/* Media queries for responsive design */
@media (max-width: 480px) {
    :root {
        --font-size: 0.9rem;
        --font-size-large: 1.3rem;
        --font-size-small: 0.75rem;
    }
    
    .app-container {
        padding: 1rem 0.5rem;
    }
    
    .char {
        font-size: 1.2rem;
    }
    
    #stats-section {
        padding: 1rem;
    }
    
    .filter-controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .filter-group, .view-group {
        justify-content: center;
    }
    
    .zoro-ui {
        bottom: 1rem;
    }
    
    .zoro-input-area {
        padding: 0.5rem;
    }
    
    #zoro-input {
        padding: 0.5rem;
    }
    
    .zoro-power-ups {
        flex-direction: column;
        right: 0.5rem;
        bottom: auto;
        top: 50%;
        transform: translateY(-50%);
        left: auto;
    }
    
    .power-up {
        padding: 0.3rem 0.6rem;
    }
    
    .power-icon {
        font-size: 1.2rem;
    }
}

/* Word mode dropdown styling */
.word-mode-container {
    position: relative;
    display: inline-block;
}

.word-count-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #1c1c1c;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    z-index: 10;
    min-width: 100%;
    margin-top: 5px;
}

.word-mode-container:hover .word-count-dropdown,
.word-count-dropdown.show {
    display: block;
}

.word-count-btn {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background-color: transparent;
    color: #b5b5b5;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    font-family: 'Roboto Mono', monospace;
}

.word-count-btn:hover {
    background-color: #303030;
    color: #ffffff;
}

.word-count-btn.active {
    background-color: #404040;
    color: #ffffff;
}

/* Update filter button group to handle more buttons */
.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.filter-btn {
    padding: 5px 10px;
    font-size: 0.8rem;
}

/* Zoro Mode Score Display */
.zoro-score-display {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 15px 20px;
    border-radius: 10px;
    font-family: 'Roboto Mono', monospace;
    font-size: 18px;
    z-index: 1000;
    border: 2px solid #3a3a3a;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    text-align: right;
    min-width: 180px;
}

.zoro-score-display .score-line {
    margin: 5px 0;
    display: flex;
    justify-content: space-between;
}

.zoro-score-display .stat-value {
    font-weight: bold;
    color: #b19cd9;
    margin-left: 20px;
}

.zoro-score-display .level-indicator {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #c176ff;
    display: flex;
    justify-content: center;
    text-shadow: 0 0 5px rgba(193, 118, 255, 0.7);
}

/* Notification for Easter eggs */
.notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 1.2rem;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border: 2px solid var(--main-color);
    pointer-events: none;
    font-family: 'Roboto Mono', monospace;
}

.notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}