@font-face {
  font-family: Pixel_Press_Start_2P;
  src: url(/fonts/Press_Start_2P/PressStart2P-Regular.ttf);
}

:root {
  font-size: 62.5%;
  scroll-behavior: smooth;

  --text-color: #f0f0f0;
  --background-color: #252525;
  --screen-color: #bbbfaa;
  --box-color: #333333;
  --button-text-color: #454545;
  --button-number-color: #666666;
  --complementary-color: #f27830;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;

  font-size: 1.6rem;
  color: var(--text-color);
  font-family: Pixel_Press_Start_2P, "Press Start 2P";

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--background-color);
}

.container {
  display: grid;
  place-content: center;
  height: 100vh;
  width: 100vw;
}

.calculator {
  background: var(--box-color);
  border-radius: 0.8rem;
  padding: 2.4rem;
  box-shadow: 1px 1px 8px 1px rgba(0, 0, 0, 0.2);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.6rem;
}

header h1 {
  font-size: clamp(1.4rem, 3vw, 2.4rem);
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
}

.buttonOpenHistory {
  background: none;
  border: transparent;
  transition: 200ms;
}

.buttonOpenHistory:hover {
  cursor: pointer;
  transform: scale(1.1);
}

.buttonOpenHistory img {
  width: 2rem;
}

.modalHistory {
  background: var(--screen-color);
  border-radius: 8px;
  border: none;
  width: 24rem;
  height: 42rem;
  padding: 1.6rem 0.8rem 0rem;
  margin: 35% auto;
  box-shadow: inset 0 0 12px 1px rgba(0, 0, 0, 0.8);
  text-align: center;
}

.modalHistory::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
}

.buttonCloseModal {
  position: absolute;
  top: 1.6rem;
  left: 1.6rem;
  border: transparent;
  color: var(--button-text-color);
  font-size: 1.2rem;
  padding: 0.8rem;
  background: none;
}

.buttonCloseModal:hover {
  cursor: pointer;
  transform: scale(1.1);
}

.containerHistory {
  overflow: auto;
  height: 85%;
  padding: 2rem 1.2rem;
}

.boxHistory {
  text-align: right;
}

.boxHistory + .boxHistory {
  margin-top: 2rem;
}

.expressionHistory {
  font-size: clamp(0.8rem, 1vw, 1rem);
  color: var(--button-number-color);
}

.resultHistory {
  font-size: clamp(1.2rem, 2vw, 1.6rem);
  color: var(--button-text-color);
  margin-top: 0.8rem;
}

.buttonClearHistory {
  border: transparent;
  color: var(--button-text-color);
  font-size: 1rem;
  width: 12rem;
  margin: 1.2rem auto;
  background: #66666622;
  border-radius: 8px;
  padding: 0.8rem;
}

.buttonClearHistory:hover {
  cursor: pointer;
  background: #66666633;
}

.emptyHistory {
  color: var(--button-number-color);
  display: grid;
  place-content: center;
  height: 100%;
  font-size: 1.2rem;
}

.screen {
  width: 100%;
  height: 12rem;
  background: var(--screen-color);
  border-radius: 0.8rem;
  margin-top: 3.2rem;
  box-shadow: inset 0 0 12px 1px rgba(0, 0, 0, 0.8);
  position: relative;
}

.expressionDisplay {
  position: absolute;
  bottom: 4.8rem;
  right: 2.8rem;
  font-size: clamp(1rem, 1.5vw, 1.6rem);
  color: var(--button-number-color);
}

.expression {
  position: absolute;
  bottom: 2rem;
  right: 2.8rem;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  color: var(--button-text-color);
}

.expression::after {
  content: "|";
  position: absolute;
  bottom: -0.1rem;
  right: -1.2rem;
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  animation: blink 1s infinite;
}

.gridButtons {
  display: grid;
  grid-template-columns: repeat(4, minmax(5rem, 1fr));
  grid-template-rows: repeat(5, minmax(4rem, 9vw));
  gap: 0.8rem;
  margin-top: 2.4rem;
}

.gridButtons button {
  text-align: center;
  border-radius: 0.8rem;
  padding: 1.2rem;
  font-size: clamp(1rem, 2vw, 1.6rem);
}

.gridButtons button:hover {
  cursor: pointer;
  filter: brightness(1.1);
}

.gridButtons button.text {
  background: var(--button-text-color);
}

.gridButtons button.number {
  background: var(--button-number-color);
}

.gridButtons button.equals {
  background: var(--complementary-color);
  grid-column: span 2;
}

footer {
  text-align: center;
  margin: 2.4rem 0 0.8rem;
}

footer a {
  font-size: clamp(1.2rem, 2.5vw, 1.8rem);
  text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.2);
  text-decoration: none;
  padding: 1.2rem;
}

footer a:hover {
  text-decoration: underline;
}

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

  61%,
  100% {
    opacity: 0;
  }
}

@media (min-width: 768px) {
  .calculator {
    padding: 4.2rem;
  }

  .buttonOpenHistory img {
    width: 2.4rem;
  }

  .modalHistory {
    width: 56rem;
    height: 42rem;
    padding: 2.4rem 1.6rem 0.4rem;
    margin: 7% auto;
  }

  .buttonCloseModal {
    top: 2.4rem;
    left: 2.4rem;
    font-size: 1.2rem;
  }

  .containerHistory {
    padding: 1.2rem 1.2rem 0;
  }

  .boxHistory {
    margin-top: 2rem;
  }

  .buttonClearHistory {
    font-size: 1.2rem;
  }

  ::-webkit-scrollbar {
    width: 6px;
  }

  ::-webkit-scrollbar-thumb {
    background: var(--button-number-color);
    border-radius: 8px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: var(--button-text-color);
  }

  main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3.2rem;
  }

  .screen {
    width: 60vw;
    height: 27rem;
  }

  .expression {
    bottom: 2.4rem;
    right: 4.2rem;
  }

  .expression::after {
    bottom: -0.25rem;
    right: -1.75rem;
  }

  .expressionDisplay {
    bottom: 7.2rem;
    right: 4.2rem;
  }

  .gridButtons {
    grid-template-rows: repeat(5, 4.75rem);
    margin-top: 3.2rem;
  }

  footer {
    margin-top: 4.2rem;
  }
}
