/* style.css */
.cursor {
    position: absolute;
    display: block;
    width: 0.1em;
    height: 1.4em;
    background-color: var(--cursor-color, var(--accent-color));
    border-radius: 0.05em;
    opacity: 0.8;
    animation: blink 1s infinite;
    transition: left 0.1s ease, height 0.2s ease, opacity 0.2s ease;
    bottom: 0;
    top: 0;
    margin: auto;
    z-index: 2;
}

/* Default-Stil (leicht verbesserter ursprünglicher Stil) */
.cursor.default {
    transition: left 0.05s ease;
}

/* Noch weicherer, flüssigerer Cursor */
.cursor.smooth {
    transition: left 0.1s ease;
}

/* Verbesserte Sichtbarkeit statt Blinken */
.cursor.blinking {
    opacity: 0.85;
}

/* Verbesserte smooth typing Animation */
.cursor.typing {
    animation: none;
    opacity: 0.9;
    height: 1.6em;
}

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

.hidden {
    visibility: hidden;
}

/* Verbesserte Word-Animation */
.word {
    display: inline;
    position: relative;
    margin-right: 0.5em;
    transition: opacity 0.25s, transform 0.25s, color 0.25s;
    padding: 0.1em 0;
}

.word.current-word {
    color: var(--text-color);
    font-weight: 500;
    text-decoration: none;
    border-bottom: none;
}

.letter {
    display: inline-block;
    position: relative;
    user-select: none;
    transition: color 0.1s, transform 0.1s;
}

.letter.correct {
    color: var(--text-color);
}

.letter.incorrect {
    color: var(--error-color);
    text-decoration: underline;
    text-decoration-color: var(--error-color);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.letter.pending {
    color: var(--sub-color);
}

/* Fokusmode-Verbesserungen */
body.focus-mode .line:not(:first-of-type):not(:nth-of-type(2)) {
    opacity: 0;
    transition: opacity 0.3s ease;
}

body.focus-mode .word:not(.current-word) {
    opacity: 0.4;
    transition: opacity 0.3s ease;
}

/* Verbessertes Header-Verhalten */
header.typing {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

/* Footer ausblenden beim Tippen */
footer.typing {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow-y: hidden; /* Verhindert unnötiges Scrollen */
}

html {
    overflow-y: auto;
    height: 100%;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Verhindert unnötiges Scrollen */
}

header.typing .logo {
    opacity: 0.5;
    pointer-events: auto;
    position: fixed;
    top: 10px;
    left: 10px;
    font-size: 1.2em;
    transition: opacity 0.5s ease, color 0.3s ease;
}

header.typing .logo:hover {
    opacity: 1;
}

/* Echtzeit-Statistiken */
#stats {
    position: fixed;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 5px;
    font-size: 0.9em;
    z-index: 100;
    transition: opacity 0.3s ease;
}

#stats.zen {
    top: auto;
    bottom: 60px;
    text-align: center;
    right: 50%;
    transform: translateX(50%);
    background-color: transparent;
}

nav {
    display: flex;
    justify-content: center; /* Zentral ausrichten */
    align-items: center;
    gap: 15px; /* Größerer Abstand zwischen Elementen */
    flex-wrap: wrap; /* Elemente umbrechen bei kleiner Bildschirmgröße */
    padding: 0 10px; /* Etwas Padding für bessere Optik */
}

/* Responsivität für die Navbar */
@media (max-width: 768px) {
    nav {
        justify-content: center; /* Bei kleinen Bildschirmen zentrieren */
        gap: 10px;
    }
}

/* Caret-Style-Auswahlmenü */
.caret-style-container {
    display: inline-block;
    position: relative;
}

#caret-style-btn {
    color: inherit;
    background-color: transparent;
    border: none;
    cursor: pointer;
    font-size: 1em;
    padding: 8px 15px;
    border-radius: 5px;
    font-family: 'Roboto Mono', 'Courier New', monospace;
    transition: color 0.3s ease, background-color 0.3s ease;
}

.caret-style-dropdown {
    display: none;
    position: absolute;
    z-index: 10;
    min-width: 120px;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.caret-style-dropdown.show {
    display: block;
}

.caret-style-option {
    padding: 8px 12px;
    cursor: pointer;
    font-family: 'Roboto Mono', 'Courier New', monospace;
    transition: background-color 0.2s ease;
}

#auth-btn {
    color: inherit; /* Farbe wird vom Theme übernommen */
    background-color: transparent;
    border: none;
    cursor: pointer;
    font-size: 1em;
    padding: 8px 15px; /* Wie bei anderen Buttons */
    border-radius: 5px;
    font-family: 'Roboto Mono', 'Courier New', monospace;
    transition: color 0.3s ease, background-color 0.3s ease;
}

/* Verbesserte Zeitanzeige-Stil */
.main-timer {
    font-family: 'Roboto Mono', monospace;
    font-size: 2.2em;
    color: inherit;
    opacity: 0.8;
    margin-bottom: 30px;
    transition: opacity 0.3s ease, font-size 0.3s ease;
    text-align: center;
    display: block;
    width: 100%;
    position: relative;
    z-index: 5;
    max-width: 1200px;
    padding: 0 20px;
    box-sizing: border-box;
}

/* Die Timer-Container-Stile korrigieren */
.timer-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
    height: 36px;
    z-index: auto;
    background-color: transparent;
}

.timer-container select {
    width: 100%;
    text-align-last: center;
    padding: 8px 15px;
    padding-right: 25px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    font-family: 'Roboto Mono', monospace;
    background-color: transparent;
    color: inherit;
    border: none;
    border-radius: 5px;
}

.test-active .timer-container select {
    opacity: 0;
    pointer-events: none;
}

.test-active .main-timer {
    font-size: 2.8em;
    opacity: 0.9;
    color: var(--accent-color);
    font-weight: 500;
}

/* Stilisierung für den Timer mit Minuten:Sekunden Format */
.main-timer {
    font-variant-numeric: tabular-nums;
}

/* Verbesserte Sichtbarkeitsregeln für den Test-Container */
#words-container {
    background-color: transparent !important;
    overflow: visible !important; /* Verhindert Abschneiden von Wörtern */
    position: relative;
    padding: 15px 0;
    box-sizing: border-box;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px; /* Erhöht für bessere vertikale Zentrierung */
    margin: 60px auto 0; /* Erhöhter Abstand zur Navbar */
    width: 90%;
    max-width: 1200px;
}

body.test-active #words-container {
    transition: opacity 0.3s ease;
}

body.test-finished #words-container {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
    visibility: hidden;
}

body.test-finished #input {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
    visibility: hidden;
}

/* Animationen für die End-Stats */
#end-stats {
    animation: fadeIn 0.5s ease 0.3s forwards;
    opacity: 0;
}

/* Hervorhebung bei Hover über Statisitikelementen */
.stat-item {
    position: relative;
    overflow: hidden;
}

.stat-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.stat-item:hover::before {
    opacity: 1;
}

/* Highlight-Animation für WPM-Wert */
@keyframes highlightPulse {
    0% { transform: scale(1); color: var(--text); }
    50% { transform: scale(1.15); color: var(--accent); }
    100% { transform: scale(1); color: var(--text); }
}

.highlight-value {
    animation: highlightPulse 1.5s ease-in-out 1;
    display: inline-block;
    transform-origin: center;
}

/* Verbesserte Darstellung der Statistiken */
.stat-value {
    font-size: 1.8em;
    font-weight: 700;
    transition: all 0.3s ease;
    display: block;
    margin-top: 5px;
}

.stat-label {
    font-size: 0.9em;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Hover-Animationen für die Buttons */
#end-stats .end-stats-buttons button {
    position: relative;
    overflow: hidden;
}

#end-stats .end-stats-buttons button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.4);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%, -50%);
    transform-origin: 50% 50%;
}

#end-stats .end-stats-buttons button:hover::after {
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    0% {
        opacity: 1;
        transform: scale(0, 0) translate(-50%, -50%);
    }
    100% {
        opacity: 0;
        transform: scale(20, 20) translate(-50%, -50%);
    }
}

/* Verbesserte Wortanzeige */
#words {
    text-align: left;
    width: 100%;
    max-width: 90%;
    margin: 0 auto;
    padding: 5px;
    box-sizing: border-box;
    overflow-x: visible !important; /* Verhindert Abschneiden von Wörtern */
    overflow-y: visible;
    min-height: 150px;
    position: relative;
    line-height: 1.5;
    font-size: 1.7rem;
}

.line {
    display: block;
    margin-bottom: 0.2em; /* Noch kleinerer Abstand für zusammenhängenden Text */
    white-space: nowrap;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    padding: 3px 0; /* Weniger Padding für mehr Kompaktheit */
    font-size: 1.7rem;
    line-height: 1.3; /* Kompakterer Zeilenabstand für zusammenhängenden Text */
    overflow: visible !important; /* Verhindert Abschneiden von Wörtern */
    transition: transform 0.2s ease, opacity 0.2s ease; /* Sanfter Übergang für das Scrollen */
}

/* Animation für Zeilen-Übergang */
.line.current-line {
    background-color: transparent;
    border-radius: 5px;
    position: relative;
}

/* Zeilen-Übergang-Animation */
@keyframes lineScrollUp {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-20px); opacity: 0; }
}

@keyframes lineScrollDown {
    0% { transform: translateY(20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.line-transition-wave {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-color, #e2b714), transparent);
    opacity: 0.5;
    z-index: 1;
    animation: waveAnimation 0.8s ease-in-out forwards;
}

.word {
    display: inline-block;
    position: relative;
    margin-right: 0.35em; /* Kleinerer Abstand zwischen Wörtern */
}

.word.current-word {
    color: var(--text-color);
    font-weight: 500;
    text-decoration: none;
    border-bottom: none;
}

.letter.correct {
    color: var(--monkeytype-correct-letter-color, #d1d0c5);
}

.letter.incorrect {
    color: var(--monkeytype-incorrect-letter-color, #ca4754);
    border-bottom: 2px solid var(--monkeytype-incorrect-letter-color, #ca4754);
}

.letter.pending {
    color: var(--monkeytype-text-color, #9599a1);
}

.cursor {
    position: absolute;
    display: block;
    width: 0.1em;
    height: 1.5em;
    background-color: var(--monkeytype-cursor-color, #e2b714);
    border-radius: 1px;
    bottom: 0;
    transition: left 0.1s ease;
}

.cursor.smooth.typing {
    animation: blink 1s infinite;
}

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

/* Mode-Dropdown-Styling korrigiert */
.mode-dropdown {
    position: relative;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0;
    padding: 0;
    z-index: 1001; /* Höherer z-index für das Container-Element */
}

/* Für das Monkeytype-Theme */
body.monkeytype .word {
    margin-right: 0.35em; /* Kleinerer Abstand im Monkeytype-Theme */
}

body.monkeytype .letter {
    font-family: var(--font-family, 'Roboto Mono', monospace);
    font-weight: 400;
}

body.monkeytype .line {
    margin-bottom: 0.2em; /* Kleinerer Abstand auch im Monkeytype-Theme */
    line-height: 1.3; /* Kompakter Zeilenabstand */
    padding: 3px 0;
}

body.monkeytype .word.current-word {
    text-decoration: none;
    border-bottom: none;
    font-weight: normal;
}

/* Timer-Styling für Monkeytype-Theme */
body.monkeytype #timer {
    font-family: var(--font-family, 'Roboto Mono', monospace);
    font-size: 2rem;
    letter-spacing: 0.05em;
}

/* Input-Feld Styling */
#typing-input {
    width: 0;
    height: 0;
    opacity: 0;
    position: absolute;
    z-index: -1;
}

@media (max-width: 800px) {
    #words {
        font-size: var(--font-size-mobile, 1rem);
    }
}

/* Refresh-Button neu positionieren */
.refresh-container {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    margin: 0;
    z-index: 100 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

#refresh-btn {
    background: rgba(255, 255, 255, 0.1) !important;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: transform 0.3s ease, opacity 0.2s ease;
    opacity: 0.8 !important;
    display: block !important;
    visibility: visible !important;
}

@keyframes waveAnimation {
    0% { 
        transform: translateY(0);
        opacity: 0.1;
        width: 0%;
        left: 50%;
    }
    50% {
        opacity: 0.5;
        width: 100%;
        left: 0%;
    }
    100% { 
        transform: translateY(10px);
        opacity: 0;
        width: 100%;
    }
}