@import url("https://fonts.googleapis.com/css2?family=Overpass:ital,wght@0,100..900;1,100..900&display=swap");

:root {
  --bg: #060912;
  --accent-1: #643afb;
  --accent-2: #f42156;
  --text-dim: #ffffff55;
  --right: #3ddc84;
  --wrong: #ff4d6d;
}

* {
  font-family: "Overpass";
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  color: white;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(100, 58, 251, 0.22), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(244, 33, 86, 0.18), transparent 42%),
    radial-gradient(circle at 50% 50%, rgba(20, 30, 60, 0.4), transparent 70%);
  background-attachment: fixed;
}

.github_link {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.github_link:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.22);
}

@media (max-width: 600px) {
  .github_link {
    top: 0.85rem;
    right: 0.85rem;
    width: 38px;
    height: 38px;
  }
}

.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 1200px;
  width: 100%;
  min-height: 100vh;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

/* heading pinned to the top */
.heading {
  width: 100%;
  text-align: center;
}

.container h2 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0;
  background: linear-gradient(120deg, var(--accent-1), var(--accent-2));
  color: transparent;
  background-clip: text;
  -webkit-background-clip: text;
  filter: drop-shadow(0 2px 18px rgba(100, 58, 251, 0.35));
}

/* main fills the space under the heading and centers the test block */
.main {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  padding: 2rem 0;
}

@media (max-width: 600px) {
  .container {
    /* extra top space so the heading clears the fixed github button */
    padding: 3.75rem 1rem 2.5rem;
  }
  .container h2 {
    font-size: 1.9rem;
  }
  .main {
    gap: 1.25rem;
    padding: 1.25rem 0;
  }
}

.typing_wrapper {
  position: relative;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 2.2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  gap: 2rem;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.button_wrapper button ,
.button_wrapper_again button {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: white;
  background: linear-gradient(120deg, var(--accent-1), var(--accent-2));
  border: none;
  border-radius: 10px;
  padding: 11px 26px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  box-shadow: 0 8px 24px rgba(100, 58, 251, 0.35);
}

.button_wrapper button:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 12px 30px rgba(244, 33, 86, 0.4);
}

.button_wrapper button:active {
  transform: translateY(0);
}

.typing_text {
  font-size: 1.9rem;
  line-height: 3.1rem;
  letter-spacing: 1px;
  word-spacing: 4px;
  font-weight: 400;
  color: var(--text-dim);
  text-align: left;
  margin: 0;
}

/* invisible input — just there to summon the mobile keyboard.
   font-size 16px stops ios from zooming in when it focuses */
.hidden_input {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  font-size: 16px;
  background: transparent;
  caret-color: transparent;
  pointer-events: none;
}

/* "tap to type" hint — only on touch devices, and gone once typing */
.tap_hint {
  display: none;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--highlight, #ffd60a);
}

body.is-touch .tap_hint {
  display: block;
}

body.is-touch.input-focused .tap_hint {
  display: none;
}

.wrong {
  color: var(--wrong);
  background: rgba(255, 77, 109, 0.12);
  border-radius: 3px;
  padding: 0;
  margin: 0;
  display: inline;
}

.right {
  color: var(--right);
  padding: 0;
  margin: 0;
  display: inline;
}

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

.cursor {
  background: #ffd60a;
  height: 32px;
  width: 3px;
  border-radius: 2px;
  box-shadow: 0 0 12px rgba(255, 214, 10, 0.9);
  animation: blink 1.1s infinite;

  display: inline-block;
  margin: 0;
  padding: 0;

  position: relative;
  top: 6px;
}

/* ---------- Timer ---------- */
#timer_wrapper {
  margin: 0 auto;
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(100, 58, 251, 0.18), transparent 70%),
    rgba(255, 255, 255, 0.03);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  position: relative;
}

/* countdown ring that drains as the seconds tick down */
.timer_ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg); /* start the progress from the top */
}

.timer_ring_track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 6;
}

.timer_ring_progress {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  /* dasharray/offset are set from js, this just animates the change smoothly */
  transition:
    stroke-dashoffset 1s linear,
    stroke 0.4s ease;
}

/* turn the ring red in the last few seconds */
#timer_wrapper.low .timer_ring_progress {
  stroke: var(--wrong);
}

.second {
  position: relative;
  z-index: 1;
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(120deg, var(--accent-1), var(--accent-2));
  color: transparent;
  background-clip: text;
  -webkit-background-clip: text;
}

#timer_wrapper.low .second {
  background: var(--wrong);
  background-clip: text;
  -webkit-background-clip: text;
}

.second::after {
  content: "s";
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-left: 1px;
  -webkit-text-fill-color: var(--text-dim);
}

/* ---------- Results ---------- */
@keyframes resultReveal {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* hidden until the test finishes — no empty/zeroed panel up front */
.result_wrapper {
  display: none;
}

.result_wrapper.show {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  animation: resultReveal 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* gradient separator line on top of the result */
.result_topline {
  height: 3px;
  width: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
}

/* "Result" reads as a heading, with a gradient underline */
.result_heading {
  position: relative;
  align-self: flex-start;
  margin: 0.5rem 0 0.25rem;
  padding-bottom: 0.5rem;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #ffffffee;
}

.result_heading::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 46px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
}
.button_wrapper_again{
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.result_cards {
  display: flex;
  align-items: stretch;
  gap: 1rem;
}

/* shared card: equal cells, centered content */
.result_card {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
}

/* highlighted WPM card — slightly wider + accent fill */
.card_wpm {
  flex: 1.5;
  background: linear-gradient(
    135deg,
    rgba(100, 58, 251, 0.22),
    rgba(244, 33, 86, 0.14)
  );
  border-color: rgba(124, 92, 255, 0.4);
}

.card_value {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  color: #ffffff;
}

.card_label {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-dim);
}

.stat_value {
  font-size: 1.8rem;
  font-weight: 600;
  line-height: 1;
  color: #ffffffdd;
}

/* semantic highlight per stat */
.total_time.stat_value {
  color: #4ca3ff;
}
.noOfRightWord.stat_value {
  color: var(--right);
}
.noOfWrongWord.stat_value {
  color: var(--wrong);
}

.stat_label {
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: var(--text-dim);
}

.card_label {
  letter-spacing: 0.3px;
  text-transform: uppercase;
  font-weight: 500;
}

@media (max-width: 560px) {
  .result_cards {
    flex-wrap: wrap;
  }
  .card_wpm {
    flex: 1 0 100%;
  }
  .stat_card {
    flex: 1 0 28%;
  }
}

.button_wrapper_again {
  display: flex;
  justify-content: center;
  margin-top: 0.75rem;
}

#again_test_button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: white;
  background: linear-gradient(120deg, var(--accent-1), var(--accent-2));
  border: none;
  border-radius: 10px;
  padding: 11px 22px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  box-shadow: 0 8px 24px rgba(100, 58, 251, 0.3);
}

#again_test_button:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 12px 30px rgba(244, 33, 86, 0.35);
}

#again_test_button:active {
  transform: translateY(0);
}

#again_test_button svg {
  width: 17px;
  height: 17px;
}
