/* ============================================================================
   TYPING TEST — All-WebTools
   ============================================================================ */

:root {
    --tt-primary: #FF8C00;
    --tt-primary-hover: #E67E00;
    --tt-correct: #10b981;
    --tt-incorrect: #ef4444;
    --tt-extra: #f59e0b;
    --tt-untyped: #94a3b8;
    --tt-caret: #FF8C00;
    --tt-gray-50: #f8fafc;
    --tt-gray-100: #f1f5f9;
    --tt-gray-200: #e2e8f0;
    --tt-gray-300: #cbd5e1;
    --tt-gray-400: #94a3b8;
    --tt-gray-500: #64748b;
    --tt-gray-600: #475569;
    --tt-gray-700: #334155;
    --tt-gray-800: #1e293b;
    --tt-gray-900: #0f172a;
}

/* ─────────────────────────────────────────
   SETTINGS BAR
   ───────────────────────────────────────── */
.tt-settings-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--tt-gray-50);
    border: 1px solid var(--tt-gray-200);
    border-radius: 16px;
    padding: 12px 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tt-opt-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--tt-gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 4px;
}

.tt-mode-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tt-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--tt-gray-500);
    background: white;
    border: 1px solid var(--tt-gray-200);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tt-mode-btn:hover {
    color: var(--tt-gray-700);
    border-color: var(--tt-gray-300);
}

.tt-mode-btn.active {
    color: white;
    background: var(--tt-primary);
    border-color: var(--tt-primary);
}

.tt-chip-group {
    display: flex;
    gap: 4px;
}

.tt-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--tt-gray-500);
    background: white;
    border: 1px solid var(--tt-gray-200);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tt-chip:hover {
    color: var(--tt-primary);
    border-color: var(--tt-primary);
}

.tt-chip.active {
    color: white;
    background: var(--tt-primary);
    border-color: var(--tt-primary);
}

.tt-chip-toggle.active {
    color: white;
    background: var(--tt-primary);
    border-color: var(--tt-primary);
}

.tt-separator {
    width: 1px;
    height: 24px;
    background: var(--tt-gray-200);
    flex-shrink: 0;
}

.tt-lang-group {
    display: flex;
    align-items: center;
}

.tt-select {
    padding: 5px 28px 5px 10px;
    border: 1px solid var(--tt-gray-200);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--tt-gray-700);
    background: white;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    transition: border-color 0.2s;
}

.tt-select:focus {
    outline: none;
    border-color: var(--tt-primary);
    box-shadow: 0 0 0 3px rgba(255, 140, 0, 0.1);
}

.tt-toggle-group {
    display: flex;
    gap: 4px;
}

/* ─────────────────────────────────────────
   TYPING CARD
   ───────────────────────────────────────── */
.tt-card {
    background: white;
    border: 1px solid var(--tt-gray-200);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    position: relative;
}

/* Live Stats */
.tt-live-stats {
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 14px 24px;
    border-bottom: 1px solid var(--tt-gray-100);
    background: var(--tt-gray-50);
}

.tt-stat {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.tt-stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--tt-gray-800);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.tt-stat-timer .tt-stat-value {
    color: var(--tt-primary);
}

.tt-stat-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--tt-gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Typing Area */
.tt-typing-area {
    position: relative;
    padding: 32px 28px;
    min-height: 160px;
    max-height: 210px;
    overflow: hidden;
    cursor: text;
    user-select: none;
}

.tt-words {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    font-family: 'Fira Code', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    font-size: 20px;
    line-height: 2;
    transition: transform 0.2s ease;
    position: relative;
}

.tt-word {
    display: inline-block;
    margin-right: 0.5em;
    border-bottom: 2px solid transparent;
}

.tt-word.error {
    border-bottom-color: var(--tt-incorrect);
}

/* Current word — subtle underline highlight */
.tt-word.active {
    border-bottom-color: var(--tt-primary);
}

/* Completed words — dim so focus stays on current word */
.tt-word.typed {
    opacity: 0.35;
}

.tt-word.typed .tt-char.correct {
    color: var(--tt-gray-400);
}

.tt-word.typed .tt-char.incorrect {
    color: var(--tt-incorrect);
    opacity: 0.7;
}

.tt-char {
    color: var(--tt-untyped);
    transition: color 0.05s;
}

.tt-char.correct {
    color: var(--tt-correct);
}

.tt-char.incorrect {
    color: var(--tt-incorrect);
    text-decoration: underline;
    text-decoration-color: var(--tt-incorrect);
}

.tt-char.extra {
    color: var(--tt-extra);
    opacity: 0.8;
    font-size: 0.85em;
}

/* Caret */
.tt-caret {
    position: absolute;
    width: 2.5px;
    height: 1.6em;
    background: var(--tt-caret);
    border-radius: 2px;
    top: 32px;
    left: 28px;
    transition: left 0.08s ease, top 0.08s ease;
    animation: tt-blink 1s step-end infinite;
    z-index: 5;
    pointer-events: none;
}

.tt-caret.typing {
    animation: none;
}

@keyframes tt-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Hidden Input — inside .tt-typing-area (position: relative) */
.tt-hidden-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: text;
    z-index: 10;
    font-size: 16px;
    caret-color: transparent;
}

/* Focus hint — shown when input not focused, hidden on focus */
.tt-focus-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(3px);
    z-index: 8;
    cursor: text;
    transition: opacity 0.25s;
    pointer-events: none;
}

.tt-focus-hint span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--tt-gray-400);
}

.tt-focus-hint span iconify-icon {
    font-size: 18px;
}

/* Hide hint when input is focused */
.tt-typing-area.focused .tt-focus-hint {
    opacity: 0;
}

/* Also hide hint once test has started */
.tt-typing-area.active .tt-focus-hint {
    opacity: 0;
    pointer-events: none;
}

/* Bottom Bar */
.tt-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    border-top: 1px solid var(--tt-gray-100);
    background: var(--tt-gray-50);
}

.tt-hint {
    font-size: 12px;
    color: var(--tt-gray-400);
    display: flex;
    align-items: center;
    gap: 6px;
}

.tt-hint kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    color: var(--tt-gray-500);
    background: white;
    border: 1px solid var(--tt-gray-200);
    border-radius: 4px;
}

.tt-hint-sep {
    color: var(--tt-gray-300);
    margin: 0 2px;
}

.tt-restart-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--tt-gray-400);
    background: white;
    border: 1px solid var(--tt-gray-200);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 16px;
}

.tt-restart-btn:hover {
    color: var(--tt-primary);
    border-color: var(--tt-primary);
    background: #fff7ed;
}

/* ─────────────────────────────────────────
   RESULTS PANEL
   ───────────────────────────────────────── */
.tt-results {
    background: white;
    border: 1px solid var(--tt-gray-200);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.tt-results-header {
    display: flex;
    justify-content: center;
    gap: 64px;
    padding: 40px 24px 24px;
}

.tt-big-stat {
    text-align: center;
}

.tt-big-value {
    display: block;
    font-size: 72px;
    font-weight: 800;
    color: var(--tt-primary);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.tt-big-stat:last-child .tt-big-value {
    color: var(--tt-gray-800);
}

.tt-big-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--tt-gray-400);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 8px;
}

/* Chart */
.tt-chart-wrap {
    padding: 16px 24px;
}

.tt-chart-wrap canvas {
    width: 100%;
    height: 180px;
    display: block;
}

/* Details Grid */
.tt-details-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 0 24px 24px;
}

.tt-detail-card {
    background: var(--tt-gray-50);
    border: 1px solid var(--tt-gray-100);
    border-radius: 10px;
    padding: 14px 16px;
    text-align: center;
}

.tt-detail-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--tt-gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.tt-detail-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--tt-gray-800);
    font-variant-numeric: tabular-nums;
}

.tt-detail-hint {
    display: block;
    font-size: 10px;
    color: var(--tt-gray-400);
    margin-top: 2px;
}

/* Result Actions */
.tt-result-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 0 24px 28px;
}

.tt-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--tt-gray-600);
    background: white;
    border: 1px solid var(--tt-gray-200);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tt-btn:hover {
    color: var(--tt-primary);
    border-color: var(--tt-primary);
    background: #fff7ed;
}

.tt-btn-primary {
    color: white;
    background: var(--tt-primary);
    border-color: var(--tt-primary);
}

.tt-btn-primary:hover {
    background: var(--tt-primary-hover);
    border-color: var(--tt-primary-hover);
    color: white;
}

.tt-btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* ─────────────────────────────────────────
   HISTORY SECTION
   ───────────────────────────────────────── */
.tt-history-section {
    margin-top: 24px;
    background: white;
    border: 1px solid var(--tt-gray-200);
    border-radius: 16px;
    padding: 20px 24px;
}

.tt-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 8px;
}

.tt-history-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--tt-gray-800);
    margin: 0;
}

.tt-history-title iconify-icon {
    color: var(--tt-primary);
}

.tt-history-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tt-personal-best {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-size: 13px;
    color: #d97706;
    background: #fef3c7;
    border-radius: 20px;
}

.tt-personal-best iconify-icon {
    font-size: 14px;
}

.tt-history-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 300px;
    overflow-y: auto;
}

.tt-history-empty {
    text-align: center;
    font-size: 13px;
    color: var(--tt-gray-400);
    padding: 16px;
    margin: 0;
}

.tt-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--tt-gray-50);
    border-radius: 8px;
    transition: background 0.2s;
}

.tt-history-item:hover {
    background: var(--tt-gray-100);
}

.tt-history-wpm {
    font-size: 18px;
    font-weight: 800;
    color: var(--tt-primary);
    min-width: 55px;
    font-variant-numeric: tabular-nums;
}

.tt-history-wpm small {
    font-size: 11px;
    font-weight: 600;
    color: var(--tt-gray-400);
}

.tt-history-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: var(--tt-gray-500);
    flex: 1;
    margin-left: 16px;
}

.tt-history-meta span {
    white-space: nowrap;
}

.tt-history-date {
    font-size: 11px;
    color: var(--tt-gray-400);
    white-space: nowrap;
}

.tt-history-best-badge {
    font-size: 10px;
    font-weight: 700;
    color: #d97706;
    background: #fef3c7;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

/* ─────────────────────────────────────────
   TOAST
   ───────────────────────────────────────── */
.tt-toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tt-toast {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--tt-gray-800);
    color: white;
    font-size: 13px;
    font-weight: 500;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    animation: tt-toast-in 0.3s ease;
}

.tt-toast.success { background: #16a34a; }
.tt-toast.error { background: #dc2626; }

@keyframes tt-toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ─────────────────────────────────────────
   INFO GRID
   ───────────────────────────────────────── */
.tt-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin-top: 2.5rem;
}

.tt-info-card {
    background: white;
    border: 1px solid var(--tt-gray-200);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
}

.tt-info-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 0.75rem;
}

.tt-info-card h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--tt-gray-800);
    margin: 0 0 0.4rem;
}

.tt-info-card p {
    font-size: 13px;
    color: var(--tt-gray-500);
    line-height: 1.5;
    margin: 0;
}

/* ─────────────────────────────────────────
   SEO CONTENT
   ───────────────────────────────────────── */
.tt-seo-content {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 2rem;
    margin-top: 3rem;
}

.tt-seo-main h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--tt-gray-800);
    margin: 2rem 0 1rem;
}

.tt-seo-main h2:first-child {
    margin-top: 0;
}

.tt-seo-main p,
.tt-seo-main li {
    font-size: 15px;
    line-height: 1.7;
    color: #4b5563;
}

.tt-seo-main ol,
.tt-seo-main ul {
    padding-left: 1.25rem;
    margin: 0.75rem 0;
}

.tt-seo-main li {
    margin-bottom: 0.5rem;
}

/* Sidebar */
.tt-seo-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tt-related-tools {
    background: white;
    border: 1px solid var(--tt-gray-200);
    border-radius: 12px;
    padding: 1.25rem;
    position: sticky;
    top: 6rem;
}

.tt-related-tools h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--tt-gray-800);
    margin: 0 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--tt-primary);
}

.tt-related-tools ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tt-related-tools li {
    margin-bottom: 0.25rem;
}

.tt-related-tools a {
    display: block;
    padding: 0.45rem 0.6rem;
    font-size: 13px;
    color: #4b5563;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
}

.tt-related-tools a:hover {
    color: var(--tt-primary);
    background: #fff7ed;
}

.tt-shortcuts-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    color: var(--tt-gray-500);
}

.tt-shortcuts-list kbd {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--tt-gray-600);
    background: var(--tt-gray-100);
    border: 1px solid var(--tt-gray-200);
    border-radius: 4px;
}

.tt-shortcuts-list span {
    margin-left: auto;
    font-size: 12px;
    color: var(--tt-gray-400);
}

/* FAQ */
.tt-faq-section {
    margin-top: 1rem;
}

.tt-faq-item {
    border: 1px solid var(--tt-gray-200);
    border-radius: 10px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.tt-faq-question {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1rem 1.25rem;
    font-size: 14px;
    font-weight: 600;
    color: var(--tt-gray-800);
    background: white;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.tt-faq-question::after {
    content: '+';
    font-size: 18px;
    font-weight: 400;
    color: var(--tt-gray-400);
    transition: transform 0.2s;
}

.tt-faq-item.active .tt-faq-question::after {
    content: '\2212';
    color: var(--tt-primary);
}

.tt-faq-question:hover {
    background: var(--tt-gray-50);
}

.tt-faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.tt-faq-item.active .tt-faq-answer {
    max-height: 500px;
}

.tt-faq-answer p {
    padding: 0 1.25rem 1rem;
    font-size: 14px;
    line-height: 1.6;
    color: #4b5563;
    margin: 0;
}

/* ─────────────────────────────────────────
   RESPONSIVE
   ───────────────────────────────────────── */
@media (max-width: 1023px) {
    .tt-seo-content {
        grid-template-columns: 1fr;
    }

    .tt-related-tools {
        position: static;
    }
}

@media (max-width: 767px) {
    .tt-settings-bar {
        gap: 8px;
        padding: 10px 14px;
    }

    .tt-live-stats {
        flex-wrap: wrap;
        gap: 16px;
        padding: 12px 16px;
    }

    .tt-stat-value {
        font-size: 22px;
    }

    .tt-typing-area {
        padding: 24px 16px;
        font-size: 16px;
    }

    .tt-words {
        font-size: 17px;
    }

    .tt-results-header {
        gap: 32px;
        padding: 28px 16px 20px;
    }

    .tt-big-value {
        font-size: 48px;
    }

    .tt-details-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 0 16px 16px;
    }

    .tt-result-actions {
        flex-wrap: wrap;
        padding: 0 16px 20px;
    }

    .tt-info-grid {
        grid-template-columns: 1fr;
    }

    .tt-chart-wrap {
        padding: 12px 16px;
    }

    .tt-bottom-bar {
        padding: 8px 16px;
    }

    .tt-history-meta {
        display: none;
    }
}

@media (max-width: 479px) {
    .tt-details-grid {
        grid-template-columns: 1fr;
    }

    .tt-mode-btn {
        padding: 5px 10px;
        font-size: 12px;
    }

    .tt-chip {
        padding: 4px 8px;
        font-size: 11px;
    }

    .tt-separator {
        display: none;
    }
}
