@import "./styles/root.css";
@import "./styles/animations.css";
@import "./styles/alerts.css";
@import "./styles/modals.css";
@import "./styles/keyboard.css";

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

a,
a:visited {
  color: var(--color-tone-2);
}

.game {
  display: flex;
  flex-direction: column;
  width: max-content;
  max-width: 100vw;
  height: 100%;
  margin: 0 auto;
  padding: 1em;
  padding-top: var(--header-height);
  background-color: var(--color-background);
  font-family: var(--font-family-sans-serif);
  font-size: clamp(0.8rem, 2.5vmin, 1.5rem);
  overflow: hidden;
}

/**
 * Header
 */
header {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  justify-content: center;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  height: var(--header-height);
  padding: 0 1em;
  border-bottom: 1px solid var(--color-tone-4);
}

header .menu {
  display: flex;
  align-items: center;
  gap: 1em;
}

header .menu:first-child {
  justify-self: start;
}

header .menu:last-child {
  justify-self: end;
}

header .title {
  margin: 0;
  font-weight: 900;
  font-size: 34px;
  font-family: var(--font-family-serif);
  color: var(--color-tone-1);
  line-height: 100%;
  letter-spacing: 0.01em;
  text-align: center;
  left: 0;
  right: 0;
  pointer-events: none;
}

.icon {
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  margin: 0;
  padding: 0;
}

.icon > svg {
  fill: currentColor;
  user-select: none;
  pointer-events: none;
}

/**
 * Grid
 */
.grid {
  display: grid;
  justify-content: center;
  align-content: center;
  flex-grow: 1;
  grid-template-columns: repeat(5, 3.75em);
  grid-auto-rows: 3.75em;
  gap: 0.25em;
  margin-bottom: 1em;
}

.tile {
  font-size: 2em;
  color: var(--tile-text-color);
  border: 1px solid var(--color-tone-4);
  text-transform: uppercase;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
  transition: transform 250ms linear;
}

.tile[data-state="active"] {
  border-color: var(--color-tone-3);
  color: var(--color-tone-1);
}

.tile[data-state="absent"] {
  border: none;
  background-color: var(--key-bg-absent);
}

.tile[data-state="present"] {
  border: none;
  background-color: var(--key-bg-present);
}

.tile[data-state="correct"] {
  border: none;
  background-color: var(--key-bg-correct);
}

.tile.flip {
  transform: rotateX(90deg);
}

.tile.shake {
  animation: shake 250ms ease-in-out;
}

.tile.dance {
  animation: dance 500ms ease-in-out;
}

/**
 * Instructions
 */
.instructions {
  font-size: 16px;
}

.instructions .modal-body > p:first-child {
  margin-top: 0;
}

.instructions .examples {
  border-top: 1px solid var(--color-tone-4);
  border-bottom: 1px solid var(--color-tone-4);
}

.instructions figure {
  margin: 0 0 2em;
}

.instructions blockquote {
  display: grid;
  grid-template-columns: repeat(5, 2em);
  grid-auto-rows: 2em;
  gap: 0.25em;
  margin: 0 0 1em;
}

.instructions .tile:not() {
  font-size: 1.25em;
}

/**
 * Settings
 */
.setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-tone-4);
  padding: 16px 0;
}

.setting .text {
  padding-right: 8px;
}

.setting .title {
  font-size: 18px;
}

.setting .description {
  font-size: 12px;
  color: var(--color-tone-2);
}

/**
 * Statistics
 */
.statistics {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 1rem;
  padding-bottom: 1rem;
  gap: 1rem;
}

.statistics .title {
  text-transform: uppercase;
}

.statistics-container {
  display: flex;
  width: 100%;
  margin-bottom: 1em;
}

.statistic {
  flex: 1;
}

.statistic .value {
  font-size: 36px;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  letter-spacing: 0.05em;
  font-variant-numeric: proportional-nums;
}

.statistic .label {
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.guess-distribution {
  width: 80%;
  text-align: center;
  margin-bottom: 1em;
}

.guess-distribution .graph-container {
  width: 100%;
  display: grid;
  grid-template-columns: max-content auto;
  grid-auto-rows: 20px;
  align-items: center;
  font-size: 14px;
  line-height: 20px;
  gap: 4px;
}

.guess-distribution .graph {
  width: 100%;
  height: 100%;
}

.guess-distribution .count {
  height: 100%;
  min-width: min-content;
  width: 0;
  position: relative;
  background-color: var(--color-absent);
  display: flex;
  justify-content: flex-end;
  padding: 0 8px;
  font-weight: bold;
  color: var(--tile-text-color);
  transition: width 750ms ease-in-out;
}

.guess-distribution .count.highlight {
  background-color: var(--color-correct);
}

.share {
  display: flex;
  align-items: center;
  justify-content: center;
}

.share button {
  display: flex;
  align-items: center;
  color: white;
  background-color: var(--key-bg-correct);
  user-select: none;
  cursor: pointer;
  font-size: 20px;
  border-radius: 4px;
  padding: 0.8em 2em;
  gap: 0.4em;
}

@media (hover: hover) {
  [data-theme="dark"] .share button:is(:hover, :focus) {
    background-color: hsl(
      var(--key-bg-correct-h),
      var(--key-bg-correct-s),
      calc(var(--key-bg-correct-l) + 10%)
    );
  }

  [data-theme="light"] .share button:is(:hover, :focus) {
    background-color: hsl(
      var(--key-bg-correct-h),
      var(--key-bg-correct-s),
      calc(var(--key-bg-correct-l) - 10%)
    );
  }
}

.statistics .footer {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* The switch - the box around the slider */
.switch {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 20px;
  user-select: none;
  -webkit-user-select: none;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch .slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--color-tone-3);
  border-radius: 999px;
  transition: 0.4s;
}

.switch .slider:before {
  position: absolute;
  content: "";
  height: calc(100% - 4px);
  width: 50%;
  top: 2px;
  left: 2px;
  background-color: var(--white);
  border-radius: 50%;
  transition: 0.3s;
}

.switch input:checked + .slider {
  background-color: var(--color-correct);
}

.switch input:focus + .slider {
  box-shadow: 0 0 1px var(--color-correct);
}

.switch input:checked + .slider:before {
  transform: translateX(calc(100% - 4px));
}
