/* keyboard — monokrom dark yazma testi */

:root {
  color-scheme: dark;
  --bg: #0a0a0b;
  --bg-soft: #0d0d0f;
  --text: #ffffff;
  --text-2: rgba(255, 255, 255, .68);
  --text-3: rgba(255, 255, 255, .50);
  --text-4: rgba(255, 255, 255, .28);
  --pending: rgba(255, 255, 255, .44);
  --err: #ff5c5c;
  --line: rgba(255, 255, 255, .10);
  --line-strong: rgba(255, 255, 255, .24);
  --hover: rgba(255, 255, 255, .05);
  --ease: cubic-bezier(.22, .61, .36, 1);
  --dur: .28s;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Geist', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(1000px 460px at 50% -12%, rgba(255,255,255,.05), transparent 72%),
    radial-gradient(700px 320px at 92% 108%, rgba(255,255,255,.022), transparent 70%);
}
::selection { background: rgba(255,255,255,.18); }

.wrap { width: 100%; max-width: 1160px; margin: 0 auto; padding: 0 32px; position: relative; z-index: 1; }

kbd {
  font-family: 'Geist Mono', monospace;
  font-size: 9.5px;
  border: 1px solid var(--line-strong);
  padding: 1px 5px;
  margin-left: 6px;
  color: var(--text-3);
  letter-spacing: .08em;
}

/* ── header ───────────────────────────────────────────── */
header { padding: 26px 0 0; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 12px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--text-3); text-decoration: none;
  transition: color var(--dur) var(--ease);
}
.brand:hover { color: var(--text-2); }
.brand::before { content: ""; width: 6px; height: 6px; background: var(--text); }
.brand b { color: var(--text-2); font-weight: 500; }

.seg { display: inline-flex; border: 1px solid var(--line); }
.seg-btn {
  background: transparent; border: 0; color: var(--text-3);
  font-family: 'Geist Mono', monospace; font-size: 10.5px;
  letter-spacing: .14em; text-transform: uppercase;
  padding: 7px 12px; cursor: pointer;
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.seg-btn:hover { color: var(--text-2); background: var(--hover); }
.seg-btn.is-on { color: var(--bg); background: var(--text); }

/* ── toolbar ──────────────────────────────────────────── */
main { flex: 1; padding: 44px 0 90px; }
.toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.006));
  padding: 10px 14px;
}
.group { display: inline-flex; gap: 4px; }
.pill {
  background: transparent; border: 1px solid transparent; color: var(--text-3);
  font-family: 'Geist Mono', monospace; font-size: 10.5px;
  letter-spacing: .14em; text-transform: uppercase;
  padding: 6px 10px; cursor: pointer;
  transition: color .18s var(--ease), background .18s var(--ease), border-color .18s var(--ease);
}
.pill:hover { color: var(--text-2); background: var(--hover); }
.pill.is-on { color: var(--text); border-color: var(--line-strong); }
.sep { width: 1px; height: 18px; background: var(--line); }
.grow { flex: 1; }
.live { display: flex; align-items: baseline; gap: 8px; font-family: 'Geist Mono', monospace; }
.live-label { font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--text-4); }
.live-value { font-size: 15px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.live-value.hot { color: var(--text); }

/* ── yazma alanı ──────────────────────────────────────── */
.stage { margin-top: 26px; position: relative; }

.words-wrap {
  position: relative;
  height: calc(3 * 1.85em);
  overflow: hidden;
  padding: 6px 0;
  transition: filter var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.words-wrap.blurred .words { filter: blur(4px); opacity: .35; }
.words-wrap.blurred .caret { opacity: 0; }

.words {
  display: flex; flex-wrap: wrap;
  gap: 0 1.05em;
  font-family: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(24px, 2.9vw, 32px);
  line-height: 1.82;
  transition: transform .28s var(--ease), filter var(--dur) var(--ease), opacity var(--dur) var(--ease);
  user-select: none;
  will-change: transform;
}
.word { position: relative; white-space: nowrap; }
.word.done .char { color: rgba(255, 255, 255, .30); }
.char { color: var(--pending); transition: color .09s linear, background .12s var(--ease); }
.char.correct { color: var(--text); }
.char.wrong {
  color: var(--err);
  background: rgba(255, 92, 92, .12);
  border-bottom: 2px solid var(--err);
}
.char.extra { color: rgba(255, 92, 92, .8); background: rgba(255, 92, 92, .08); border-bottom: 2px solid rgba(255, 92, 92, .6); }
.word.active .char { color: var(--pending); }
.word.active .char.correct { color: var(--text); }
.word.active .char.wrong { color: var(--err); }
.word.active .char.extra { color: rgba(255, 92, 92, .8); }
.word.error { text-decoration: underline; text-decoration-color: rgba(255, 92, 92, .45); text-underline-offset: 6px; }

.caret {
  position: absolute;
  top: 0; left: 0;
  width: 2px;
  height: 1.42em;
  background: var(--text);
  border-radius: 1px;
  transform: translate3d(0, 0, 0);
  transition: transform .085s cubic-bezier(.2,.7,.3,1), opacity .2s var(--ease);
  will-change: transform;
  pointer-events: none;
}
.caret.blink { animation: caretBlink 1.06s steps(1) infinite; }
@keyframes caretBlink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .15; } }

.stage-hint {
  margin-top: 18px;
  font-family: 'Geist Mono', monospace;
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--text-4);
  transition: opacity var(--dur) var(--ease);
}
.stage-hint.hidden { opacity: 0; }

/* ── animasyonlar ─────────────────────────────────────── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes drawLine { to { stroke-dashoffset: 0; } }
@keyframes growBar { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.rise { animation: fadeUp .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ── sonuçlar ─────────────────────────────────────────── */
.results { margin-top: 40px; }
.res-top {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 30px; flex-wrap: wrap;
  padding-bottom: 22px; border-bottom: 1px solid var(--line);
}
.res-big { display: flex; align-items: baseline; gap: 10px; }
.res-num {
  font-size: clamp(56px, 9vw, 104px);
  font-weight: 300; letter-spacing: -0.05em; line-height: .9;
  font-variant-numeric: tabular-nums;
}
.res-unit { font-family: 'Geist Mono', monospace; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--text-3); }

.res-side { display: flex; gap: 34px; flex-wrap: wrap; }
.res-item { display: flex; flex-direction: column; gap: 6px; }
.res-item .k, .cell .k {
  font-family: 'Geist Mono', monospace; font-size: 9.5px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--text-4);
}
.res-item .v { font-family: 'Geist Mono', monospace; font-size: 22px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.chart-card { margin-top: 26px; border: 1px solid var(--line); background: var(--bg-soft); }
.chart-head {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.eyebrow { font-family: 'Geist Mono', monospace; font-size: 9.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--text-4); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; }
.lg { display: inline-flex; align-items: center; gap: 7px; font-family: 'Geist Mono', monospace; font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.lg i { width: 14px; height: 2px; display: block; background: var(--text); }
.lg--raw i { background: rgba(255,255,255,.35); }
.lg--err i { width: 4px; height: 4px; border-radius: 50%; background: rgba(255,255,255,.75); }

.chart-host { padding: 16px 8px 8px; height: 260px; }
.chart-host svg { width: 100%; height: 100%; overflow: visible; display: block; }
.axis-label { fill: rgba(255,255,255,.55); font-family: 'Geist Mono', monospace; font-size: 9px; letter-spacing: .1em; }
.grid-line { stroke: rgba(255,255,255,.07); stroke-width: 1; }
.net-line { fill: none; stroke: #ffffff; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.raw-line { fill: none; stroke: rgba(255,255,255,.45); stroke-width: 1.2; stroke-dasharray: 3 4; }
.area-fill { fill: url(#areaGrad); opacity: .5; }
.err-dot { fill: #0a0a0b; stroke: #ffffff; stroke-width: 1.5; }

.res-grid {
  margin-top: 1px; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line); border-top: 0;
}
.cell { background: var(--bg); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.cell .v { font-family: 'Geist Mono', monospace; font-size: 15px; color: var(--text-2); }

.res-actions { margin-top: 26px; display: flex; gap: 12px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--text); background: var(--text); color: var(--bg);
  font-family: 'Geist Mono', monospace; font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  padding: 12px 20px; cursor: pointer;
  transition: transform .12s var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.99); }
.btn--ghost { background: transparent; color: var(--text-2); border-color: var(--line-strong); }
.btn--ghost:hover { color: var(--text); border-color: var(--text-2); background: var(--hover); }
.btn--small { padding: 8px 12px; font-size: 9.5px; }

/* ── geçmiş ───────────────────────────────────────────── */
.history { margin-top: 56px; }
.section-head { display: flex; align-items: center; gap: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.section-head h2 { margin: 0; font-family: 'Geist Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: .22em; text-transform: uppercase; color: var(--text-2); }
.section-head .rule { flex: 1; height: 1px; background: var(--line); }

.hist-chart { display: flex; align-items: flex-end; gap: 5px; height: 88px; margin: 20px 0 6px; }
.hist-bar {
  flex: 0 1 34px; max-width: 34px; background: rgba(255, 255, 255, .20); min-height: 3px;
  transform-origin: bottom;
  animation: growBar .6s var(--ease) both;
  transition: background var(--dur) var(--ease);
  position: relative;
}
.hist-bar:hover { background: rgba(255, 255, 255, .5); }
.hist-bar.best { background: rgba(255, 255, 255, .82); }

.hist-list { display: flex; flex-direction: column; }
.hist-row {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 2px; border-bottom: 1px solid var(--line);
  font-family: 'Geist Mono', monospace; font-size: 11px; color: var(--text-3);
  animation: fadeIn .4s var(--ease) both;
}
.hist-row .h-wpm { width: 54px; color: var(--text); font-size: 13px; }
.hist-row .h-acc { width: 66px; }
.hist-row .h-mode { flex: 1; letter-spacing: .1em; text-transform: uppercase; font-size: 9.5px; }
.hist-row .h-date { color: var(--text-4); font-size: 9.5px; letter-spacing: .1em; }

footer { border-top: 1px solid var(--line); padding: 16px 0 24px; margin-top: auto; }
footer .wrap { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; font-family: 'Geist Mono', monospace; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-4); }

.toast-host { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast {
  font-family: 'Geist Mono', monospace; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  border: 1px solid var(--line-strong); background: #101012; color: var(--text); padding: 10px 14px;
  animation: fadeUp .3s var(--ease) both;
}

@media (max-width: 720px) {
  .wrap { padding: 0 20px; }
  main { padding: 30px 0 64px; }
  .toolbar { gap: 8px; padding: 8px 10px; }
  .live-label { display: none; }
  .res-top { gap: 18px; }
  .res-side { gap: 20px; }
  .chart-host { height: 200px; }
  .hist-row .h-acc { display: none; }
}
