/* Google Fonts: Bitter (serif display) + JetBrains Mono (typing area, stats) */
@import url('https://fonts.googleapis.com/css2?family=Bitter:wght@700&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
    --bg: #1C1917;
    --surface: #262220;
    --text: #F2EDE4;
    --text-muted: #9C9187;
    --accent: #C89B3C;
    --correct: #7FA65C;
    --incorrect: #D65A4A;
}

/* Light theme palette, applied when body has this class */
body.light-theme {
    --bg: #F5F1E8;
    --surface: #FFFFFF;
    --text: #2B2620;
    --text-muted: #6B6259;
    --accent: #B8842E;
    --correct: #4C7A34;
    --incorrect: #B33A2B;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    min-height: 100vh;
    padding: 2rem 1rem;
    display: flex;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Theme toggle button, sits above the heading */
#theme-toggle {
    display: block;
    margin: 0 auto 0.5rem;
    background: none;
    border: 1px solid rgba(200, 155, 60, 0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

#theme-toggle:hover {
    transform: scale(1.08);
    border-color: var(--accent);
}

/* Full-bleed layout, no boxed card, matches how most typing test tools
   are designed (MonkeyType, etc.) — content floats centered with
   generous spacing instead of being contained in a bordered panel. */
.app-shell {
    width: 100%;
    max-width: 760px;
    padding: 1rem 1rem 3rem;
}

header h1 {
    font-family: 'Bitter', serif;
    font-weight: 700;
    text-align: center;
    color: var(--text);
    letter-spacing: 0.02em;
    font-size: 2.2rem;
    margin-bottom: 0.25rem;
    margin-top: 1rem;
}

header .tagline {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 3rem;
}

/* Stat boxes: subtle typewriter-key look, brass numbers */
.stat-box {
    background-color: var(--surface);
    color: var(--text-muted);
    padding: 0.75rem 1.25rem;
    border-radius: 10px 10px 6px 6px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 4px rgba(0, 0, 0, 0.3);
    font-size: 0.95rem;
    min-width: 110px;
    text-align: center;
}

.stat-box span {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.1rem;
}

main {
    max-width: 700px;
    margin: 0 auto;
}

/* Typing text display: darker, recessed look, reads as "reference text".
   This is now the visual anchor of the page since there's no card border,
   so it gets extra size and spacing to carry that weight. */
.typing-text {
    background-color: #17130F;
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 2rem;
    font-size: 1.5rem;
    line-height: 2;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    word-spacing: 0.15em;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

.typing-text span {
    transition: color 0.15s ease, background-color 0.15s ease;
}

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

.typing-text span.incorrect {
    color: var(--incorrect);
    background-color: rgba(214, 90, 74, 0.15);
    border-radius: 2px;
}

/* Highlights the next character to type, like a blinking cursor */
.typing-text span.current {
    background-color: rgba(200, 155, 60, 0.25);
    border-radius: 2px;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        background-color: rgba(200, 155, 60, 0.15);
    }

    50% {
        background-color: rgba(200, 155, 60, 0.4);
    }
}

/* Progress bar: fills as the 60-second timer counts down */
.progress-track {
    width: 100%;
    height: 6px;
    background-color: var(--surface);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background-color: var(--accent);
    transition: width 1s linear;
}

/* Typing input: lighter surface, visible border, clearly reads as
   "the thing you interact with", distinct from the display above it */
.typing-input {
    width: 100%;
    background-color: var(--surface);
    color: var(--text);
    border: 2px solid rgba(200, 155, 60, 0.25);
    border-radius: 8px;
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    resize: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.typing-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(200, 155, 60, 0.2);
}

.typing-input:disabled {
    opacity: 0.5;
}

.hint-text {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 0.5rem;
    font-family: 'JetBrains Mono', monospace;
}

/* Results section */
.results-box {
    background-color: var(--surface);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    margin-top: 1.5rem;
    animation: fadeIn 0.3s ease;
}

.results-box p {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.results-box span {
    color: var(--accent);
    font-weight: 700;
    font-size: 1.3rem;
}

/* Makes the WPM stat stand out as the headline number */
.wpm-highlight {
    font-size: 1.2rem;
    margin-bottom: 1rem !important;
}

.wpm-highlight span {
    font-size: 2.2rem;
    color: var(--correct);
}

/* Shown only when a new best WPM is set */
.congrats-banner {
    background-color: rgba(200, 155, 60, 0.15);
    border: 1px solid var(--accent);
    color: var(--accent);
    font-weight: 700;
    border-radius: 6px;
    padding: 0.6rem;
    margin-bottom: 1.25rem;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#restart-btn {
    background-color: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 6px;
    padding: 0.6rem 1.5rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    margin-top: 1rem;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

#restart-btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

#restart-btn:active {
    transform: translateY(0);
}

/* Responsiveness */
/* Responsive Design */
@media (max-width: 768px) {

    body {
        padding: 1rem 0.5rem;
    }

    .app-shell {
        padding: 0.5rem;
        max-width: 100%;
    }

    header h1 {
        font-size: 1.8rem;
    }

    header .tagline {
        font-size: 0.8rem;
        margin-bottom: 2rem;
    }

    .stat-box {
        min-width: 95px;
        padding: 0.6rem 0.7rem;
        font-size: 0.8rem;
    }

    .stat-box span {
        font-size: 1rem;
    }

    main {
        width: 100%;
    }

    .typing-text {
        font-size: 1.1rem;
        padding: 1.2rem;
        line-height: 1.8;
        word-spacing: 0.1em;
        overflow-wrap: break-word;
    }

    .typing-input {
        font-size: 1rem;
        padding: 0.8rem;
    }

    .results-box {
        padding: 1.2rem;
    }

    .results-box p {
        font-size: 1rem;
    }

    .wpm-highlight span {
        font-size: 1.8rem;
    }

    .app-footer {
        font-size: 0.75rem;
    }
}


@media (max-width: 400px) {

    header h1 {
        font-size: 1.5rem;
    }

    header .tagline {
        font-size: 0.75rem;
    }

    .stat-box {
        min-width: 75px;
        padding: 0.5rem;
        font-size: 0.7rem;
    }

    .stat-box span {
        font-size: 0.9rem;
    }

    .typing-text {
        font-size: 0.95rem;
        padding: 0.8rem;
        line-height: 1.7;
    }

    .typing-input {
        font-size: 0.9rem;
    }

    #restart-btn {
        width: 100%;
    }
}

/* Motivational message on results screen */
.motivation-text {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 1rem 0 !important;
}

/* Footer: ownership + links */
.app-footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(200, 155, 60, 0.15);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.app-footer p {
    margin-bottom: 0.4rem;
}

.app-footer a {
    color: var(--accent);
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
}