@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400&display=swap");

*,
::before,
::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --calc-shadow: rgba(0, 0, 0, 0.17) 0px -23px 25px 0px inset,
    rgba(0, 0, 0, 0.15) 0px -26px 30px 0px inset,
    rgba(0, 0, 0, 0.1) 0px -50px 30px 0px inset, rgba(0, 0, 0, 0.06) 0px 2px 1px,
    rgba(0, 0, 0, 0.09) 0px 4px 2px, rgba(0, 0, 0, 0.09) 0px 8px 4px,
    rgba(0, 0, 0, 0.09) 0px 16px 8px, rgba(0, 0, 0, 0.09) 0px 32px 16px;
  --text-shadow: 0px 0px 6px rgba(255, 255, 255, 0.7);
  --text-color: #222223;
}

body {
  font-family: "Open Sans", sans-serif;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  margin: 0;
  padding: 0;
  background-image: linear-gradient(
    135deg,
    rgba(108, 36, 139, 1) 0%,
    rgba(70, 138, 126, 1) 23%,
    rgba(36, 139, 137, 1) 45%,
    rgba(92, 39, 115, 1) 71%,
    rgba(87, 99, 54, 1) 100%,
    rgba(43, 72, 81, 1) 100%
  );
  background-size: cover;
  background-repeat: no-repeat;
}

.calculator {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 22rem;
  height: 38rem;
  border-radius: 1rem;
  background-color: #adb1a9;
  box-shadow: var(--calc-shadow);
}

#display {
  inline-size: 22rem;
  overflow: auto;
  scrollbar-width: thin;
  margin-top: 1rem;
  height: 25%;
  width: 90%;
  border-radius: 0.5rem;
  color: var(--text-color);
  text-shadow: var(--text-shadow);
  background: linear-gradient(
    141deg,
    rgb(123, 123, 122) 0%,
    rgb(206, 205, 197) 23%,
    rgb(197, 197, 195) 47%,
    rgb(200, 199, 195) 74%,
    rgb(134, 133, 131) 100%
  );
  box-shadow: rgb(56, 60, 62) 2px 2px 5px 0px inset,
    rgba(136, 136, 137, 0.5) -2px -2px 5px 0.5px inset;
}

/* Styles for the calculator screen's scroll-bar*/
#display::-webkit-scrollbar {
  width: 0.5rem;
  height: 0.5rem;
  padding: 0;
  margin: 0;
  background-color: #222223;
}
#display::-webkit-scrollbar-track {
  background: transparent;
}
#display::-webkit-scrollbar-thumb {
  background-color: #3b3939;
  border-radius: 5px;
  border: 1px solid #766f6f;
}
/*  End of scrollbar styles */

.history {
  padding: 1.2rem 0.5rem 1rem 1rem;
  text-align: right;
  font-size: 1.5rem;
  color: var(--text-color);
  text-shadow: var(--text-shadow);
}

.output {
  text-align: right;
  height: 1.5em;
  width: 100%;
  font-size: 2.5rem;
  padding: 1.2rem 0.5rem 0 0.5rem;
  color: var(--text-color);
  text-shadow: var(--text-shadow);
}

.keyboard {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  width: 90%;
  margin: 1.5rem;
}

button {
  width: 4rem;
  height: 4rem;
  margin: 0.4rem;
  font-size: 1.5rem;
  border: none;
  border-radius: 0.5rem;
  box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px,
    rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset;
  text-shadow: 0px 0px 6px rgba(124, 124, 124, 0.7);
}

.clearAll,
.deleteLastKey,
.operator,
.negative {
  background: #6dca9a;
}

.equals {
  width: 9rem;
  height: 4rem;
  font-size: 1.5em;
  background: #ff9e3d;
}

@media (hover: hover) and (pointer: fine) {
  button:hover {
    cursor: pointer;
    box-shadow: rgba(243, 239, 239, 0.904) 0px 2px 4px,
      rgba(255, 251, 251, 0.808) 0px -2px 0px inset;
    text-shadow: none;
  }
}

@media (max-width: 25rem) {
  .calculator {
    width: 20rem;
  }

  button {
    width: 3.5rem;
    height: 3.5rem;
  }
  button.equals {
    width: 8rem;
    height: 3.5rem;
  }
}

/* ------------ MODAL STYLES ------------ */
button.open-legend-modal {
  position: relative;
  top: 52px;
  left: 0;
  width: 5rem;
  height: 2.5rem;
  border-radius: 45%;
  background-color: rgb(18, 62, 61);
  color: #fafff4;
  font-size: 1.3rem;
  letter-spacing: 1px;
}

.modal-container {
  margin: 0;
  background-color: #4a4d3eef;
  position: fixed;
  display: none;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

.modal-header {
  display: flex;
  letter-spacing: 1px;
}

.modal-header p {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.modal-container ul {
  list-style: none;
  font-size: 1rem;
  letter-spacing: 1px;
}

.modal-container ul li {
  line-height: 1.5rem;
  margin-bottom: 1rem;
}
.modal-container.show {
  display: block;
}

button.close-modal {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  /* color: #fafff4; */
  position: absolute;
  top: 0;
  right: 0;
  box-shadow: none;
}

button.close-modal:hover {
  background-color: var(--text-color);
  color: #fafff4;
}

.legend {
  background-color: #fafff4;
  color: var(--dark-grey);
  border-radius: 5px;
  max-width: 55rem;
  width: 100%;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  position: absolute;
  overflow: hidden;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-name: modalopen;
  animation-duration: 0.5s;
  padding: 30px;
}
.legend p {
  margin-bottom: 0.5rem;
}

ul img {
  width: 40px;
  height: 40px;
  vertical-align: middle;
  margin: 0 0.2rem;
}

@keyframes modalopen {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (min-width: 300px) and (max-width: 800px) {
  .legend {
    max-width: 30rem;
  }
  .modal-header p {
    font-size: 1.5rem;
  }
  .modal-container ul li,
  section p {
    font-size: 0.8rem;
    line-height: normal;
  }
  button.close-modal {
    width: 2rem;
    height: 2rem;
    font-size: 1.2rem;
  }
}

/* ----------------- COPYERIGHT ---------------- */
.copyright {
  color: rgb(18, 62, 61);
  text-align: right;
  position: relative;
  top: 10px;
  left: 100px;
}
.copyright a {
  color: rgb(18, 62, 61);
  text-decoration: none;
  text-align: right;
}

.copyright a:hover {
  text-decoration: underline 2px #ff9e3d;
}

/* horizontal lines styles */
hr {
  width: 100%;
  border: 0;
  height: 2px;
  margin: 1rem 0;
  background-image: linear-gradient(
    to right,
    rgba(0, 0, 0, 0),
    rgb(18, 62, 61),
    rgba(0, 0, 0, 0)
  );
}
