/* ============================================================
   GearNas Keyboard Simulator — Theme
   Dark / Purple Glass-Morphism
   ============================================================ */

/* ── CSS Custom Properties ──────────────────────────────────── */
:root {
  /* Palette */
  --color-bg:            #0d0d0f;
  --color-bg-alt:        #13111a;
  --color-surface:       rgba(22, 16, 38, 0.75);
  --color-surface-hover: rgba(32, 22, 54, 0.85);
  --color-border:        rgba(255, 255, 255, 0.09);
  --color-border-strong: rgba(255, 255, 255, 0.16);

  /* Accent — Violet-600 */
  --color-accent:        #7c3aed;
  --color-accent-light:  #a78bfa;
  --color-accent-dim:    rgba(124, 58, 237, 0.25);
  --color-accent-glow:   rgba(124, 58, 237, 0.55);

  /* Text */
  --color-text:          #e8e0f5;
  --color-text-muted:    #8b7da8;
  --color-text-faint:    #4e4563;

  /* Key colours */
  --key-bg:              rgba(28, 18, 50, 0.78);
  --key-bg-hover:        rgba(42, 28, 72, 0.9);
  --key-bg-active:       rgba(60, 35, 100, 0.95);
  --key-border:          rgba(255, 255, 255, 0.10);
  --key-border-top:      rgba(255, 255, 255, 0.20);
  --key-shadow:          0 2px 6px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255,255,255,0.05) inset;
  --key-shadow-active:   0 0 0 2px var(--color-accent), 0 0 18px var(--color-accent-glow), inset 0 0 8px rgba(124,58,237,0.2);

  /* Glass panel */
  --glass-bg:            rgba(255, 255, 255, 0.04);
  --glass-border:        rgba(255, 255, 255, 0.10);
  --glass-blur:          blur(24px);
  --glass-shadow:        0 8px 40px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255,255,255,0.07) inset;

  /* Typography */
  --font-ui:             'Inter', system-ui, -apple-system, sans-serif;
  --font-key:            'Inter', system-ui, -apple-system, sans-serif;

  /* Sizing */
  --key-unit:            44px;   /* base unit — 1u key width */
  --key-height:          44px;
  --key-gap:             5px;
  --key-radius:          6px;
  --border-radius-panel: 14px;

  /* Transitions */
  --transition-key:      80ms ease;
  --transition-ui:       180ms ease;
}

/* ── Base Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font-ui);
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  overflow-x: hidden;

  /* Gradient backdrop */
  background-image:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(100, 40, 200, 0.18) 0%, transparent 65%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(70, 20, 160, 0.12) 0%, transparent 60%);
}

/* ── Glass Panel ────────────────────────────────────────────── */
.glass-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  border-radius: var(--border-radius-panel);
}

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  padding: 16px 0;
  border-bottom: 1px solid var(--color-border);
  background: rgba(13, 13, 15, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  user-select: none;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--color-accent-dim);
  border: 1px solid var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--color-accent-light);
  box-shadow: 0 0 16px var(--color-accent-dim);
}

.brand-name {
  display: block;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--color-text);
  line-height: 1.1;
}

.brand-sub {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ── Controls ───────────────────────────────────────────────── */
.control-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  white-space: nowrap;
  margin: 0;
}

.select-wrapper {
  position: relative;
}

.glass-select {
  background: var(--color-surface) !important;
  border: 1px solid var(--color-border-strong) !important;
  color: var(--color-text) !important;
  font-size: 13px;
  font-family: var(--font-ui);
  padding: 6px 32px 6px 12px;
  border-radius: 8px;
  min-width: 200px;
  cursor: pointer;
  transition: border-color var(--transition-ui), box-shadow var(--transition-ui);
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b7da8' d='M6 8L1 3h10z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 10px center !important;
}

.glass-select:focus {
  outline: none;
  border-color: var(--color-accent) !important;
  box-shadow: 0 0 0 3px var(--color-accent-dim) !important;
}

.glass-select option {
  background: #1a1030;
  color: var(--color-text);
}

/* ── Loading / Ready indicators ─────────────────────────────── */
.loading-indicator {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: var(--color-text-muted);
}

.text-accent { color: var(--color-accent-light) !important; }

.ready-badge {
  display: flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: #4ade80;
  letter-spacing: 0.3px;
}

/* ── Volume Slider ──────────────────────────────────────────── */
.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  border-radius: 2px;
  background: var(--color-border-strong);
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 2px solid var(--color-accent-light);
  box-shadow: 0 0 6px var(--color-accent-glow);
  cursor: pointer;
  transition: transform var(--transition-ui);
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* ── Main Layout ────────────────────────────────────────────── */
.app-main {
  padding: 32px 0 24px;
  min-height: calc(100vh - 140px);
}

/* ── Switch Info Banner ─────────────────────────────────────── */
.switch-info-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  flex-wrap: wrap;
}

.switch-type-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--color-accent-dim);
  color: var(--color-accent-light);
  border: 1px solid var(--color-accent);
  white-space: nowrap;
}

.switch-info-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.switch-info-desc {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.4;
  margin-top: 2px;
}

/* ── Hint Bar ───────────────────────────────────────────────── */
.hint-bar {
  font-size: 12px;
  color: var(--color-text-faint);
  padding: 8px 0;
}

/* ── Footer ─────────────────────────────────────────────────── */
.app-footer {
  border-top: 1px solid var(--color-border);
  padding: 16px 0;
  background: rgba(13, 13, 15, 0.7);
}

.footer-text {
  font-size: 13px;
  color: var(--color-text-muted);
}

.footer-text strong {
  color: var(--color-accent-light);
}

.footer-link {
  font-size: 13px;
  color: var(--color-text-muted);
  text-decoration: none;
  transition: color var(--transition-ui);
}

.footer-link:hover {
  color: var(--color-accent-light);
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-accent-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-accent); }

/* ── Typing Game Panel ──────────────────────────────────────── */
.typing-panel {
  padding: 20px 24px 24px;
}

.tg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.tg-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.tg-stats {
  display: flex;
  align-items: center;
  gap: 20px;
}

.tg-stat {
  display: flex;
  align-items: baseline;
  gap: 5px;
}

.tg-wpm-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-accent-light);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  min-width: 3ch;
  text-align: right;
}

.tg-stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tg-progress {
  font-size: 13px;
  color: var(--color-text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Text display area ─────────────────────────────────────── */
.tg-text-area {
  font-family: var(--font-key);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.3px;
  line-height: 1.7;
  word-break: break-word;
}

/* ── Individual characters ─────────────────────────────────── */
.tg-char {
  position: relative;
  color: var(--color-text-faint);
  transition: color 100ms ease;
}

.tg-char.tg-correct {
  color: var(--color-accent-light);
}

.tg-char.tg-current {
  color: var(--color-text);
}

/* Blinking underline cursor on current character */
.tg-char.tg-current::after {
  content: '';
  position: absolute;
  bottom: 1px;
  left: 0;
  width: 100%;
  min-width: 6px;
  height: 2px;
  background: var(--color-accent-light);
  border-radius: 1px;
  animation: tg-blink 1s step-end infinite;
}

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

/* Wrong key — red flash animation */
@keyframes tg-error-flash {
  0%   { color: var(--color-text-faint); background: transparent; border-radius: 0; }
  25%  { color: #f87171;                 background: rgba(239, 68, 68, 0.18); border-radius: 3px; }
  100% { color: var(--color-text-faint); background: transparent; border-radius: 0; }
}

.tg-char.tg-error {
  animation: tg-error-flash 0.35s ease forwards;
}

/* ── Between-text transitions ──────────────────────────────── */

/* All chars flash to success color on completion */
.tg-text-area.tg-complete .tg-char {
  color: var(--color-accent-light) !important;
  transition: color 0.25s ease;
}

@keyframes tg-fadeout {
  from { opacity: 1; transform: translateY(0);    }
  to   { opacity: 0; transform: translateY(-8px); }
}

.tg-text-area.tg-fade-out {
  animation: tg-fadeout 0.3s ease forwards;
}

@keyframes tg-fadein {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.tg-text-area.tg-fade-in {
  animation: tg-fadein 0.35s ease forwards;
}
