/* ==========================================================================
   SpeedType Pro - Comprehensive & Ultra-Clean Design System
   ========================================================================== */

/* Design Tokens & CSS Variables */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-hover: rgba(51, 65, 85, 0.8);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-primary: #6366f1;
    --accent-primary-hover: #4f46e5;
    --accent-cyan: #06b6d4;
    --accent-glow: rgba(99, 102, 241, 0.3);
    
    --color-correct: #10b981;
    --color-incorrect: #ef4444;
    --color-incorrect-bg: rgba(239, 68, 68, 0.2);
    --color-extra: #f59e0b;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(99, 102, 241, 0.3);
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --shadow-subtle: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.25);
    
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-card-hover: rgba(241, 245, 249, 0.9);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --accent-primary: #4f46e5;
    --accent-primary-hover: #4338ca;
    --accent-cyan: #0891b2;
    --accent-glow: rgba(79, 70, 229, 0.15);
    
    --color-correct: #059669;
    --color-incorrect: #dc2626;
    --color-incorrect-bg: rgba(220, 38, 38, 0.15);
    
    --border-color: rgba(0, 0, 0, 0.08);
    --border-highlight: rgba(79, 70, 229, 0.25);
    
    --shadow-subtle: 0 4px 20px -2px rgba(0, 0, 0, 0.08);
}

/* CSS Reset & General Rules */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Background Atmosphere */
.bg-gradient-glow {
    position: fixed;
    top: -20%;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 600px;
    background: radial-gradient(circle, var(--accent-glow) 0%, rgba(0,0,0,0) 70%);
    pointer-events: none;
    z-index: 0;
}

.bg-grid-pattern {
    position: fixed;
    inset: 0;
    background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
    background-size: 32px 32px;
    opacity: 0.5;
    pointer-events: none;
    z-index: 0;
}

/* Container */
.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
    position: relative;
    z-index: 1;
}

.text-center { text-align: center; }

/* Glassmorphism Styles */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-subtle);
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    transition: var(--transition);
}

.glass-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-highlight);
    transform: translateY(-2px);
}

/* Typography & Gradient Text */
.gradient-text {
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.highlight {
    color: var(--accent-cyan);
}

.accent {
    color: var(--accent-primary);
}

/* Navigation Bar */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}

[data-theme="light"] .navbar {
    background: rgba(248, 250, 252, 0.85);
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

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

.nav-links {
    display: flex;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.25rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
}

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

.nav-btn.active {
    background: var(--accent-primary);
    color: #ffffff;
    box-shadow: 0 2px 10px var(--accent-glow);
}

.btn-theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    transition: var(--transition);
}

.btn-theme-toggle:hover {
    border-color: var(--accent-primary);
    transform: rotate(15deg);
}

/* Hero Section */
.hero-section {
    padding: 3.5rem 0 2rem;
}

.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--border-highlight);
    color: var(--accent-primary);
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-correct);
    box-shadow: 0 0 8px var(--color-correct);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -1px;
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 680px;
    margin: 0 auto;
}

/* Test Section & Controls */
.test-section {
    padding: 1.5rem 0 3.5rem;
}

.test-card {
    padding: 2.25rem;
}

.test-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.control-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Segmented Control */
.segmented-control {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 3px;
    border-radius: var(--radius-sm);
}

[data-theme="light"] .segmented-control {
    background: rgba(0, 0, 0, 0.05);
}

.segment-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: calc(var(--radius-sm) - 2px);
    cursor: pointer;
    transition: var(--transition);
}

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

.segment-btn.active {
    background: var(--bg-card);
    color: var(--accent-cyan);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Buttons */
.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
}

.btn-secondary:hover {
    border-color: var(--accent-primary);
    background: var(--bg-card-hover);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
    border: none;
    color: #ffffff;
    padding: 0.85rem 1.75rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 15px var(--accent-glow);
    transition: var(--transition);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.full-width {
    width: 100%;
}

/* Live Stats Bar */
.live-stats-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin: 1.75rem 0;
}

.stat-box {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    text-align: center;
}

.stat-value {
    display: block;
    font-family: var(--font-mono);
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-top: 0.25rem;
    display: block;
}

/* Typing Box Display */
.typing-display-wrapper {
    position: relative;
    background: rgba(0, 0, 0, 0.25);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    min-height: 170px;
    max-height: 220px;
    overflow: hidden;
    cursor: text;
    transition: var(--transition);
}

[data-theme="light"] .typing-display-wrapper {
    background: rgba(0, 0, 0, 0.03);
}

.typing-display-wrapper.focused {
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px var(--accent-glow);
}

.hidden-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    top: 0;
    left: 0;
}

.typing-display {
    font-family: var(--font-mono);
    font-size: 1.35rem;
    line-height: 1.8;
    word-break: break-all;
    user-select: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    height: 100%;
}

.word {
    display: inline-flex;
    position: relative;
    border-radius: 4px;
    padding: 0 2px;
}

.letter {
    position: relative;
    color: var(--text-muted);
    transition: color 0.1s ease;
}

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

.letter.incorrect {
    color: var(--color-incorrect);
    background-color: var(--color-incorrect-bg);
    border-radius: 2px;
}

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

/* Cursor Indicator */
.letter.current::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: 2px;
    width: 2px;
    height: 1.2em;
    background-color: var(--accent-cyan);
    animation: blink 1s infinite;
}

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

/* Focus Overlay Prompt */
.typing-prompt-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.25s ease;
    border-radius: calc(var(--radius-md) - 2px);
    z-index: 10;
}

.typing-display-wrapper.focused .typing-prompt-overlay {
    opacity: 0;
    pointer-events: none;
}

.prompt-content {
    text-align: center;
    color: var(--text-primary);
}

.prompt-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}

.typing-footer-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 1.25rem;
}

kbd {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.15rem 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

/* Features Grid */
.features-section {
    padding: 3rem 0;
}

.section-header {
    margin-bottom: 2.5rem;
}

.section-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}

.feature-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Tips Section */
.tips-section {
    padding: 2.5rem 0 4rem;
}

.tips-container {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.tip-item {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
}

.tip-num {
    font-family: var(--font-mono);
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--accent-cyan);
    opacity: 0.7;
}

.tip-content h4 {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.tip-content p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Compliance Notice Box */
.compliance-notice-section {
    padding-bottom: 4rem;
}

.compliance-box {
    border-left: 4px solid var(--accent-cyan);
}

.compliance-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.compliance-header h4 {
    font-size: 1.05rem;
    font-weight: 700;
}

.compliance-box p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Footer Section (Zero External Links) */
.footer {
    margin-top: auto;
    background: rgba(15, 23, 42, 0.9);
    border-top: 1px solid var(--border-color);
    padding: 2.5rem 0 2rem;
}

[data-theme="light"] .footer {
    background: #f1f5f9;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
}

.footer-tagline {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.footer-buttons {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.footer-modal-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    padding: 0.2rem 0.4rem;
}

.footer-modal-btn:hover {
    color: var(--accent-cyan);
    text-decoration: underline;
}

.dot-divider {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.footer-copyright {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Modals Overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.glass-modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 540px;
    box-shadow: var(--shadow-glow);
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.active .glass-modal {
    transform: translateY(0) scale(1);
}

.modal-large {
    max-width: 720px;
}

.modal-header {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.75rem;
}

.modal-scrollable {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 1rem;
}

.modal-footer {
    padding: 1.25rem 1.75rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
}

/* Results Custom Modal Styling */
.large-score {
    font-family: var(--font-mono);
    font-size: 4.5rem;
    font-weight: 800;
    line-height: 1;
    color: var(--accent-cyan);
}

.score-unit {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

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

.res-stat-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 0.85rem;
    border-radius: var(--radius-sm);
    text-align: center;
}

.res-stat-card .label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.res-stat-card .val {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
}

.green-text { color: var(--color-correct); }
.red-text { color: var(--color-incorrect); }

.result-rating-badge {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid var(--border-highlight);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--accent-primary);
    font-weight: 700;
    font-size: 1.05rem;
}

/* Responsive Rules */
@media (max-width: 768px) {
    .hero-title { font-size: 2.25rem; }
    .nav-links { display: none; }
    .live-stats-bar { grid-template-columns: repeat(2, 1fr); }
    .test-controls { flex-direction: column; align-items: stretch; }
    .control-group { justify-content: space-between; }
    .result-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
