@import url('https://fonts.googleapis.com/css2?family=Roboto+Mono:wght@400;500;700&family=Lexend+Deca:wght@400;500;700&display=swap');

:root {
    --bg-color: #323437;
    --main-color: #e2b714;
    --sub-color: #646669;
    --sub-alt-color: #2c2e31;
    --text-color: #d1d0c5;
    --error-color: #ca4754;
    --error-extra-color: #7e2a33;
    --colorful-error-color: #ca4754;
    --colorful-error-extra-color: #7e2a33;
    --font-family: 'Roboto Mono', monospace;
    --roundness: 10px;
}

.light-theme {
    --bg-color: #ffffff;
    --main-color: #0d6efd;
    --sub-color: #6c757d;
    --sub-alt-color: #f8f9fa;
    --text-color: #212529;
    --error-color: #dc3545;
    --error-extra-color: #a71d2a;
    --colorful-error-color: #dc3545;
    --colorful-error-extra-color: #a71d2a;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Lexend Deca', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.app-container {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

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

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    nav {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .toolbar {
        justify-content: center;
    }

    .mode-group, .sub-mode-group, .lang-group, .type-group, .diff-group {
        justify-content: center;
        flex-wrap: wrap;
    }
}

.logo {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.logo .icon {
    font-size: 2rem;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--sub-color);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
    padding: 0.5rem;
}

.icon-btn:hover {
    color: var(--text-color);
}

.toolbar {
    background: var(--sub-alt-color);
    border-radius: var(--roundness);
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.mode-group, .sub-mode-group, .lang-group, .type-group, .diff-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.mode-btn, .sub-option {
    background: transparent;
    border: none;
    color: var(--sub-color);
    font-family: inherit;
    cursor: pointer;
    font-size: 0.9rem;
    transition: color 0.2s;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.mode-btn:hover, .sub-option:hover {
    color: var(--text-color);
}

.mode-btn.active, .sub-option.active {
    color: var(--main-color);
}

.divider {
    width: 2px;
    height: 20px;
    background: var(--sub-color);
    border-radius: 1px;
}

select {
    background: transparent;
    border: none;
    color: var(--sub-color);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    outline: none;
}

select:hover {
    color: var(--text-color);
}

.typing-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    min-height: 200px;
}

.stats-overlay {
    display: flex;
    gap: 2rem;
    font-size: 1.5rem;
    color: var(--main-color);
    margin-bottom: 1rem;
    opacity: 0; /* Hidden initially, shown when typing */
    transition: opacity 0.2s;
}

.stats-overlay.visible {
    opacity: 1;
}

.caps-lock-warning {
    background: var(--sub-alt-color);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 500;
}

.words-wrapper {
    font-family: var(--font-family);
    font-size: 1.5rem;
    line-height: 1.5;
    color: var(--sub-color);
    word-break: break-word;
    height: 150px;
    overflow: hidden;
    position: relative;
    user-select: none;
    cursor: text;
}

.word {
    display: inline-block;
    margin-right: 0.6em;
}

.letter {
    position: relative;
}

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

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

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

.word.active .letter.active::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 5%;
    height: 90%;
    width: 2px;
    background-color: var(--main-color);
    animation: blink 1s infinite;
}

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

.hidden-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    opacity: 0;
    z-index: -1;
}

.restart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 2rem;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none; /* Prevent clicks when hidden */
}

.typing-container:hover .restart-container,
.restart-container:focus-within {
    opacity: 1;
    pointer-events: auto;
}

.key-hint {
    background: var(--sub-alt-color);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--sub-color);
}

#restart-btn {
    font-size: 1.5rem;
    padding: 1rem;
    background: var(--sub-alt-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sub-color);
    border: none;
    cursor: pointer;
    transition: color 0.2s;
}

#restart-btn:hover {
    color: var(--text-color);
}

.hero-tests {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1rem;
    margin: 2rem 0;
    padding: 2rem;
    background: var(--sub-alt-color);
    border-radius: var(--roundness);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.hero-title {
    font-size: 2.2rem;
    line-height: 1.2;
    color: var(--text-color);
}

.hero-subtext {
    max-width: 800px;
    color: var(--sub-color);
    font-size: 1rem;
}

/* SEO Content */
.seo-content {
    margin-top: 4rem;
    display: block;
    color: var(--sub-color);
    font-size: 0.9rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.seo-content h1, .seo-content h2, .seo-content h3, .seo-content h4, .seo-content h5, .seo-content h6 {
    color: var(--text-color);
    margin-bottom: 1rem;
    margin-top: 1.5rem;
    text-align: center;
}

.seo-content p, .seo-content li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.seo-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.footer-links {
    display: flex;
    gap: 1rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-color);
    padding: 2rem;
    border-radius: var(--roundness);
    width: 90%;
    max-width: 600px;
    text-align: center;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin: 2rem 0;
}

.stat-big .value {
    font-size: 4rem;
    color: var(--main-color);
    line-height: 1;
}

.stat-big .label {
    font-size: 1.5rem;
    color: var(--sub-color);
}

.chart-container {
    height: 200px;
    margin: 2rem 0;
}

.hidden {
    display: none !important;
}

/* 3D Button Styles */
.btn-3d-container {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.btn-3d {
    position: relative;
    display: inline-block;
    padding: 10px 20px;
    text-decoration: none;
    color: var(--bg-color);
    background: var(--main-color);
    border-radius: var(--roundness);
    font-weight: bold;
    text-transform: uppercase;
    transition: transform 0.1s;
    box-shadow: 0 5px 0 var(--sub-color);
    border: none;
    cursor: pointer;
}

.btn-3d:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 var(--sub-color);
}

.btn-3d span {
    position: relative;
    z-index: 1;
}

/* Settings Panel (New) */
.settings-panel {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 2rem;
    margin-top: 0;
    margin-bottom: 2rem;
    background: transparent;
    padding: 0;
    width: 100%;
    flex-wrap: wrap;
}

.dropdown-3d-wrapper {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 120px;
    justify-content: space-between;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--sub-alt-color);
    border-radius: var(--roundness);
    margin-top: 10px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.3);
    z-index: 100;
    overflow: hidden;
    padding: 0.5rem 0;
}

.dropdown-3d-wrapper:hover .dropdown-menu {
    display: block;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    color: var(--sub-color);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: bold;
    text-align: center;
}

.dropdown-item:hover {
    background: var(--bg-color);
    color: var(--text-color);
}

.dropdown-item.active {
    background: var(--main-color);
    color: var(--bg-color);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 1rem;
    }

    header .logo {
        font-size: 1.6rem;
        justify-content: center;
        width: 100%;
    }

    header nav {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
    }

    .icon-btn {
        font-size: 1rem;
    }
    .app-container {
        padding: 1rem;
    }
    
    .toolbar {
        flex-wrap: wrap;
        gap: 1rem;
        justify-content: center;
    }

    .mode-group, .sub-mode-group, .lang-group, .type-group, .diff-group {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .divider {
        display: none;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .stat-big .value {
        font-size: 3rem;
    }
    
    .words-wrapper {
        font-size: 1.2rem;
        height: 200px;
        overflow: auto;
    }
    
    .footer-info {
        display: none;
    }
    
    .settings-panel {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
}

/* Footer Styling */
footer {
    margin-top: auto;
    padding-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--sub-color);
}

.footer-links a {
    color: var(--sub-color);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--main-color);
}

.footer-links a.active {
    color: var(--text-color);
    font-weight: bold;
}

.footer-copyright {
    text-align: center;
    font-size: 0.9rem;
}

/* FAQ Section */
.faq-section {
    margin-top: 4rem;
    width: 100%;
}

.faq-section h2 {
    color: var(--sub-color);
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.faq-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.faq-item {
    background: var(--sub-alt-color);
    border-radius: var(--roundness);
    overflow: hidden;
}

.faq-item summary {
    padding: 1rem;
    cursor: pointer;
    font-weight: bold;
    color: var(--text-color);
    list-style: none; /* Hide default arrow */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '+';
    font-size: 1.5rem;
    transition: transform 0.2s;
}

.faq-item[open] summary::after {
    transform: rotate(45deg);
}

.faq-content {
    padding: 1rem;
    border-top: 1px solid var(--bg-color);
    color: var(--sub-color);
    line-height: 1.6;
}

/* Paragraph Selection */
.paragraph-selection {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    width: 100%;
}

.paragraph-selection h3 {
    color: var(--sub-color);
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.paragraph-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    max-width: 800px;
}

.para-btn {
    position: relative;
    display: inline-block;
    padding: 10px 20px;
    text-decoration: none;
    color: #fff;
    border-radius: var(--roundness);
    font-weight: bold;
    text-transform: uppercase;
    transition: transform 0.1s;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    background-color: var(--sub-alt-color);
    margin-bottom: 5px;
}

.para-btn:active {
    transform: translateY(4px);
}

.para-btn.active {
    transform: translateY(2px);
    filter: brightness(1.1);
}

/* Colorful 3D Buttons */
.para-btn:nth-child(8n+1) { background-color: #e2b714; box-shadow: 0 4px 0 #b59210; color: var(--bg-color); }
.para-btn:nth-child(8n+2) { background-color: #61c05a; box-shadow: 0 4px 0 #4a9645; }
.para-btn:nth-child(8n+3) { background-color: #ca4754; box-shadow: 0 4px 0 #9e3641; }
.para-btn:nth-child(8n+4) { background-color: #4c97ea; box-shadow: 0 4px 0 #3672b5; }
.para-btn:nth-child(8n+5) { background-color: #a661e8; box-shadow: 0 4px 0 #8146b8; }
.para-btn:nth-child(8n+6) { background-color: #e28a2b; box-shadow: 0 4px 0 #b36b1f; }
.para-btn:nth-child(8n+7) { background-color: #d65bad; box-shadow: 0 4px 0 #a84286; }
.para-btn:nth-child(8n+8) { background-color: #4db6ac; box-shadow: 0 4px 0 #398a82; }

.para-btn:nth-child(8n+1):active { box-shadow: 0 0 0 #b59210; }
.para-btn:nth-child(8n+2):active { box-shadow: 0 0 0 #4a9645; }
.para-btn:nth-child(8n+3):active { box-shadow: 0 0 0 #9e3641; }
.para-btn:nth-child(8n+4):active { box-shadow: 0 0 0 #3672b5; }
.para-btn:nth-child(8n+5):active { box-shadow: 0 0 0 #8146b8; }
.para-btn:nth-child(8n+6):active { box-shadow: 0 0 0 #b36b1f; }
.para-btn:nth-child(8n+7):active { box-shadow: 0 0 0 #a84286; }
.para-btn:nth-child(8n+8):active { box-shadow: 0 0 0 #398a82; }

.para-btn.active:nth-child(8n+1) { box-shadow: 0 2px 0 #b59210; }
.para-btn.active:nth-child(8n+2) { box-shadow: 0 2px 0 #4a9645; }
.para-btn.active:nth-child(8n+3) { box-shadow: 0 2px 0 #9e3641; }
.para-btn.active:nth-child(8n+4) { box-shadow: 0 2px 0 #3672b5; }
.para-btn.active:nth-child(8n+5) { box-shadow: 0 2px 0 #8146b8; }
.para-btn.active:nth-child(8n+6) { box-shadow: 0 2px 0 #b36b1f; }
.para-btn.active:nth-child(8n+7) { box-shadow: 0 2px 0 #a84286; }
.para-btn.active:nth-child(8n+8) { box-shadow: 0 2px 0 #398a82; }

/* Custom Text Modal Specifics */
#custom-text-input {
    width: 100%;
    height: 200px;
    background: var(--sub-alt-color);
    color: var(--text-color);
    border: none;
    border-radius: var(--roundness);
    padding: 1rem;
    margin: 1rem 0;
    resize: vertical;
    font-family: inherit;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.secondary-btn, .primary-btn {
    padding: 0.5rem 1.5rem;
    border-radius: var(--roundness);
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    border: none;
}

.secondary-btn {
    background: transparent;
    color: var(--sub-color);
}

.secondary-btn:hover {
    color: var(--text-color);
}

.primary-btn {
    background: var(--main-color);
    color: var(--bg-color);
}

/* Articles Section */
.articles-section {
    margin-top: 4rem;
    width: 100%;
    margin-bottom: 2rem;
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Force 3 columns */
    gap: 1.5rem;
    width: 100%;
}

.article-card {
    background: var(--sub-alt-color);
    border-radius: var(--roundness);
    padding: 2rem 1.5rem;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.2s, background-color 0.2s;
    border: 1px solid transparent;
}

.article-card:hover {
    background: var(--bg-color);
    transform: translateY(-5px);
    border-color: var(--main-color);
}

.icon-wrapper {
    color: var(--main-color);
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.article-card h3 {
    color: var(--text-color);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.article-card p {
    color: var(--sub-color);
    font-size: 0.9rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .articles-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columns on tablet */
    }
}

@media (max-width: 480px) {
    .articles-grid {
        grid-template-columns: 1fr; /* 1 column on mobile */
    }
}
