/*
 * EduGames - Interactive Learning Games
 * (c) 2025-2026 Prof. N. All rights reserved.
 *
 * File:    styles/components/scoreboard.css
 * Updated: 2026-10-04 13:01
 * Purpose: The scoreboard (scripts/components/scoreboard.js): two columns of "label: value" metrics and a bottom row
 *          with the time and the score. A metric's value is found by its data-metric attribute.
 */

#scoreboard {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 8px;
  box-sizing: border-box;
  width: max-content;
  min-width: 200px;
  max-width: 300px;
  margin: 0 auto;
  padding: 6px 10px;
  background-color: var(--scoreboard-bg);
  color: var(--scoreboard-text);
  border-radius: var(--border-radius-md);
  box-shadow: 0 4px 8px var(--shadow-color);
}

/* One metric of the grid: label and value side by side */
.score-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1);
  border-radius: var(--border-radius-sm);
  text-align: center;
  line-height: 1.2;
}

.score-item .label {
  margin-right: 5px;
  font-size: 0.7rem;
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text-secondary);
}

.score-item .value {
  font-family: var(--font-family-code);
  font-size: 1.1rem;
  font-weight: var(--font-weight-bold);
  line-height: 1;
}

/* Bottom row: the time group at the left, the score group at the right */
.score-bottom-row {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid color-mix(in srgb, var(--text-primary) 10%, transparent);
}

.score-bottom-row > span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.score-bottom-row > span.label {
  font-size: 0.8rem;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text-secondary);
}

.score-bottom-row > span.value {
  margin-right: var(--space-3);
  font-family: var(--font-family-code);
  font-size: 1.1rem;
  font-weight: var(--font-weight-bold);
  line-height: 1;
}

.score-bottom-row > span.value:last-child {
  margin-right: 0;
}

/* Value colors by metric */
[data-metric="score"].value,
[data-metric="right"].value { color: var(--text-success); }
[data-metric="wrong"].value { color: var(--text-danger); }
[data-metric="remaining"].value { color: var(--text-warning); }
[data-metric="remaining"].value.warning { color: var(--text-danger); } /* almost out (set by Scoreboard) */
[data-metric="moves"].value { color: var(--text-info); }
[data-metric="max"].value { color: var(--color-primary-light); }
[data-metric="timer"].value { color: var(--text-primary); }

/* Clock drawn by CSS */
.timer-icon {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: var(--space-1);
  vertical-align: middle;
  color: var(--text-secondary);
  border: 2px solid currentColor;
  border-radius: 50%;
  opacity: 0.9;
}

.timer-icon::before,
.timer-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  height: 1.5px;
  background-color: currentColor;
  transform-origin: 0% 50%;
}

.timer-icon::before {
  width: 5px; /* minute hand */
  transform: translate(-50%, -50%);
}

.timer-icon::after {
  width: 3px; /* hour hand */
  transform: translate(-50%, -50%) rotate(90deg);
}

/* Flash when a value changes (applied to the parent of the value) */
.score-highlight {
  animation: score-highlight 1s ease-out;
}

@keyframes score-highlight {
  0% {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
  }

  100% {
    background-color: transparent;
  }
}
