/* General Styles */
body {
    font-family: sans-serif;
    background-color: #f0f2f5;
    color: #333;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

#app {
    width: 90%;
    max-width: 1200px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

header {
    background-color: #4a90e2;
    color: #fff;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.options button {
    background-color: transparent;
    border: 1px solid #fff;
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 0.5rem;
}

.options button:hover {
    background-color: #fff;
    color: #4a90e2;
}

main {
    display: flex;
}

aside {
    width: 250px;
    background-color: #f7f9fc;
    padding: 1rem;
    border-right: 1px solid #e0e0e0;
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

nav li a {
    display: block;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: #555;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

nav li a.active, nav li a:hover {
    background-color: #4a90e2;
    color: #fff;
}

.stats {
    margin-top: 2rem;
}

.stats h3 {
    font-size: 1.2rem;
    color: #333;
}

#practice-area {
    flex-grow: 1;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    position: relative; /* Needed for hand container positioning */
}

#text-display-container {
    background-color: #f7f9fc;
    border-radius: 8px;
    padding: 2rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

#text-display {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    white-space: pre-wrap; /* Allows wrapping and preserves spaces */
    line-height: 1.5; /* Improves readability */
}

#translation-display {
    font-size: 1.2rem;
    color: #777;
    min-height: 20px; /* Reserve space */
}

.long-translation {
    margin-bottom: 1rem;
    background-color: #f7f9fc;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.long-translation summary {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-weight: bold;
    color: #4a90e2;
}

.long-translation p {
    padding: 0 1.5rem 1rem;
    margin: 0;
    color: #555;
}

#text-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.2rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

#keyboard-container {
    margin-top: 2rem;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 40px; /* Make space for the hands above */
}

#hand-container {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 800px; /* Approx width of keyboard */
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.finger {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: rgba(74, 144, 226, 0.7);
    border: 1px solid rgba(25, 102, 198, 0.8);
    transition: transform 0.15s ease-out, background-color 0.15s ease-out, opacity 0.15s ease-out;
    box-sizing: border-box;
}

.keyboard-row {
    display: flex;
    margin-bottom: 0.5rem;
    justify-content: center;
}

.key {
    width: 48px;
    height: 48px;
    border: 1px solid #ccc;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0.25rem;
    font-size: 1.4rem;
    background-color: #fff;
    transition: all 0.1s;
    position: relative;
}

.key.space {
    width: 290px;
}

.key.highlight {
    background-color: #a1c4fd;
    border-color: #4a90e2;
}

#text-display span {
    display: inline-block; /* Treat each character/grapheme as a block */
    transition: all 0.1s;
    vertical-align: middle; /* Align characters properly */
    padding: 0.1em; /* Add some padding for visual separation */
}

/* Give space characters a specific, consistent width */
.space-char {
    width: 0.5em; /* Adjust as needed */
    background-color: transparent !important; /* Ensure spaces are always transparent */
}

#text-display .correct {
    color: #28a745;
    background-color: #e9f7ec;
    border-radius: 4px;
}

#text-display .incorrect {
    color: #dc3545;
    text-decoration: underline;
    text-decoration-color: #dc3545;
    background-color: #f8d7da;
    border-radius: 4px;
}
