/* TODO - make site responsive. Remove px. */

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

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Roboto", sans-serif;
  line-height: 1.5;
  height: 100%;
}

main {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 100%;
}

/* This results in being able to add global event listener to a button based on data-attribute and not have to worry about elements within the button preventing the event listner from firing */
button > * {
  pointer-events: none;
}

/*----------MISC COMMON COMPONENTS----------*/

.btn {
  padding: 0.5em 1em;
  background: hsl(140, 35%, 25%);

  font-family: inherit;
  color: white;

  outline: none;
  cursor: pointer;
  border: 1px solid hsl(140, 35%, 15%);
  border-radius: 0.3em;
}

.btn:hover {
  background: hsl(140, 35%, 35%);
}

.hidden {
  display: none;
}

.pause-scrolling {
  height: 100%;
  overflow: hidden;
}

/*----------HEADER GAME----------*/

.header-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.header-title h1 {
  margin-bottom: 0.5em;

  font-weight: 300;
  font-size: 2.5em;
}

.header-title h2 {
  margin-top: 0;

  font-weight: 100;
  font-style: italic;
  font-size: 1rem;
}

.header-game {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

/*car image*/

.header-car {
  position: relative;
}

.header-game-img {
  width: 200px;
}

.left-headlight,
.right-headlight {
  position: absolute;

  height: 25px;
  width: 25px;
  background-color: yellow;

  border-radius: 50%;
  box-shadow: 0 0 20px 15px yellow;
}

.left-headlight {
  left: 25.8px;
  top: 85.8px;
}

.right-headlight {
  left: 149px;
  top: 85.8px;
}

/*headlight toggle*/
/*CSS by Jon Kantner - https://codepen.io/jkantner/pen/XEzWGr*/

.headlight-toggle {
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 0.75em;
  box-shadow: 0.125em 0.125em 0 0.125em rgba(0, 0, 0, 0.3) inset;
  color: #fdea7b;
  display: inline-flex;
  align-items: center;
  margin: auto;
  padding: 0.15em;
  width: 3em;
  height: 1.5em;
  transition: background-color 0.1s 0.3s ease-out, box-shadow 0.1s 0.3s ease-out;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
}

.headlight-toggle:before,
.headlight-toggle:after {
  content: "";
  display: block;
}

.headlight-toggle:before {
  background-color: #d7d7d7;
  border-radius: 50%;
  width: 1.2em;
  height: 1.2em;
  transition: background-color 0.1s 0.3s ease-out, transform 0.3s ease-out;
  /* z-index: 1; */
}

.headlight-toggle:after {
  background: linear-gradient(transparent 50%, rgba(0, 0, 0, 0.15) 0) 0 50% / 50% 100%,
    repeating-linear-gradient(90deg, #bbb 0, #bbb, #bbb 20%, #999 20%, #999 40%) 0 50% / 50% 100%,
    radial-gradient(circle at 50% 50%, #888 25%, transparent 26%);
  background-repeat: no-repeat;
  border: 0.25em solid transparent;
  border-left: 0.4em solid #d8d8d8;
  border-right: 0 solid transparent;
  transition: border-left-color 0.1s 0.3s ease-out, transform 0.3s ease-out;
  transform: translateX(-22.5%);
  transform-origin: 25% 50%;
  width: 1.2em;
  height: 1em;
}

.headlight-toggle:checked {
  background-color: rgba(0, 0, 0, 0.45);
  box-shadow: 0.125em 0.125em 0 0.125em rgba(0, 0, 0, 0.1) inset;
}

.headlight-toggle:checked:before {
  background-color: currentColor;
  transform: translateX(125%);
}

.headlight-toggle:checked:after {
  border-left-color: currentColor;
  transform: translateX(-2.5%) rotateY(180deg);
}

/*headlight colour picker*/

.headlight-color-picker {
  display: flex;
  gap: 0.2rem;
}

.colors {
  height: 15px;
  width: 15px;

  border-radius: 50%;

  cursor: pointer;
}

@media screen and (max-width: 700px) {
  .colors {
    height: 20px;
    width: 20px;
    margin-top: 0.5rem;
  }
}

.colors.selected {
  border-style: solid;
  border-color: black;
}

.headlight-color-picker .red {
  background-color: red;
}
.headlight-color-picker .orange {
  background-color: orange;
}

.headlight-color-picker .yellow {
  background-color: yellow;
}

.headlight-color-picker .green {
  background-color: green;
}

.headlight-color-picker .blue {
  background-color: blue;
}

.headlight-color-picker .purple {
  background-color: purple;
}

.horn-img {
  width: 40px;
  cursor: pointer;
}

/*----------ADD NEW VEHICLE BUTTON----------*/

.add-vehicle-btn {
  position: relative;
  left: 50%;

  width: 600px;
  margin-top: 2rem;
  margin-bottom: 2rem;
  padding: 1em;

  transform: translateX(-50%);
}

@media screen and (max-width: 700px) {
  .add-vehicle-btn {
    width: 300px;
    font-size: 0.9em;
  }
}

/*----------VEHICLE GALLERY----------*/

.gallery-section {
  background: hsl(207, 32%, 26%);
  padding-top: 2rem;
  padding-bottom: 2rem;
  /* min-height: 600px; */

  color: white;
}

.gallery-title {
  position: relative;
  text-align: center;

  font-weight: 300;
  font-size: 2em;
}

.gallery-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, 300px);
  justify-content: center;
  gap: 2rem;

  padding: 1rem 5rem;
}

.item-container {
  width: 300px;
}

.item-image-container {
  position: relative;

  width: 100%;
  height: 300px;
}

.item-image {
  position: relative;

  height: 100%;
  width: 100%;

  object-fit: cover;
  border-radius: 1rem;
  cursor: pointer;
}

.item-image.highlight {
  border: 1px solid whitesmoke;
  box-shadow: 0 0 10px 5px whitesmoke;
}

.item-info {
  display: flex;
  /* justify-content: flex-start; */
  justify-content: space-between;

  align-items: center;
  gap: 0.5rem;

  padding-top: 0.5rem;
  font-size: 1rem;
  font-weight: 100;
}

.item-driver {
  width: 70px;
  border-radius: 50%;
}

.item-name {
  max-width: 9ch;
  white-space: nowrap;
  overflow: hidden;
}

.sort-arrows {
  display: flex;
  flex-direction: column;
}

.arrow {
  cursor: pointer;
}

.arrow:hover {
  color: #999;
}

.delete-item {
  /* position: absolute; */

  /* right: 0.3em; */
  /* top: 0.3em; */
  /* right: 0; */

  color: white;
  min-width: 30px;
  max-width: 30px;
  font-size: 1.3rem;
  /* width: 100px; */

  cursor: pointer;
}

.delete-item:hover {
  color: #999;
}

/*----------OVERLAY FOR POPUP AND MODALS----------*/

.modal-overlay {
  position: absolute;
  /* top and height set by javascript based on scrollY and innerHeight */
  left: 0;
  right: 0;

  /* background-color: rgba(0, 0, 0, 0.5); */
  background-color: rgba(0, 0, 0, 0.6);
}

/*----------POPUP FOR FULL VEHICLE IMAGE----------*/

.gallery-popup {
  position: absolute;
  left: 50%;
  /* top set by javascript depending on scrollY and innerHeight */

  transform: translate(-50%, -50%);
}

.gallery-popup.landscape {
  width: 70%;
  max-width: 800px;
}

.gallery-popup.portrait {
  width: 50%;
  max-width: 500px;
}

@media screen and (max-width: 600px) {
  .gallery-popup.landscape,
  .gallery-popup.portrait {
    width: 95%;
  }
}

.popup-img {
  width: 100%;
}

/* make these more specific to avoid confusion */
.attribution {
  margin: 0;
  color: white;
}

.attribution a {
  /* text-decoration: none; */
  color: white;
}

.attribution a:hover {
  color: #aaa;
}

/*----------MODALS----------*/

/* common to all modals */

.modal {
  position: absolute;
  left: 50%;
  /* top set by javascript based on scrollY and innerHeight */

  background-color: white;

  transform: translate(-50%, -50%);
  border-radius: 1em;
}

.vehicle-name-modal {
  width: 500px;
}

.driver-modal {
  width: 600px;
}

.img-modal {
  width: 600px;
}

@media screen and (max-width: 600px) {
  .vehicle-name-modal {
    width: 100%;
  }

  .driver-modal {
    width: 100%;
  }

  .img-modal {
    width: 100%;
  }
}

.modal-content {
  display: flex;
  flex-direction: column;

  position: relative;
  left: 50%;

  width: 75%;
  margin-top: 4rem;

  transform: translateX(-50%);
}

.modal-btn-div {
  display: flex;
  justify-content: center;
  gap: 0.5rem;

  margin-top: 2.5rem;
}

.modal-next-prev-btn {
  width: 50%;
  padding: 0.6em;
  background: rgb(43, 90, 59);

  font-size: 1rem;
  color: white;

  border: 1px solid #999;
  border-radius: 0.3em;
}

.disabled-btn {
  background: #ccc;
  cursor: not-allowed;
}

.disabled-btn:hover {
  background: #ccc;
}

.cancel {
  display: inline-block;

  position: relative;
  left: 50%;

  margin-bottom: 1rem;
  margin-top: 0.8rem;

  font-size: 0.8rem;
  color: #999;
  text-decoration: underline;

  cursor: pointer;
  transform: translateX(-50%);
}

.cancel:hover {
  color: #ccc;
}

/* modal step counter */

.modal-steps {
  display: flex;
  justify-content: center;
  gap: 1rem;

  position: relative;
  top: 2rem;
  left: 50%;

  transform: translateX(-50%);
}

.modal-step {
  width: 30px;
  height: 30px;

  background-color: #ccc;

  color: white;

  border-radius: 50%;
}

.modal-step.selected {
  background-color: rgb(43, 90, 59);
}

.modal-step-number {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6em;

  padding-top: 0.25em; /*need more elegant way to align vertically*/
}

.step-title {
  font-weight: 300;
  font-size: 0.8rem;
  color: black;
}

/* vehicle name modal */

.vehicile-name-label {
  margin-top: 0.2rem;
}

.vehicle-name-input {
  margin-top: 0.3rem;
  padding: 0.5rem;

  border: 1px solid #999;
  border-radius: 0.3em;
}

/* driver modal */

.all-drivers {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-evenly;
  gap: 0.5rem;

  margin-top: 1rem;
}

.driver-pic {
  position: relative;

  width: 90px;

  cursor: pointer;
  border: 1px solid #333;
  border-radius: 50%;
  opacity: 0.8;
}

@media screen and (max-width: 600px) {
  .driver-pic {
    width: 70px;
  }
}

.driver-pic:hover {
  opacity: 1;
}

.selected-driver {
  border: 3px solid red;
}

/* image selection modal */

.searchbar {
  position: relative;
  display: flex;
}

.search-input {
  width: 90%;
  padding: 1.2em 1em;

  border-radius: 0.5em 0em 0em 0.5em;
  border: 1px solid rgb(43, 90, 59);
}

.search-input:focus {
  outline: none;
}

.clear-icon {
  position: absolute;
  top: 50%;
  right: 3.5rem;

  font-size: 1.2rem;
  color: #aaa;

  transform: translateY(-50%);
  cursor: pointer;
}

.search-img-btn {
  width: 10%;

  border-radius: 0em 0.5em 0.5em 0em;
  border: 1px solid rgb(43, 90, 59);
}

.search-btn-icon {
  font-size: 1.2rem;
}

.img-gallery {
  margin-top: 0.8rem;
  /* height set based on computed height when images fetched */
  height: 337px;

  border: 1.5px solid hsl(140, 35%, 26%);
  border-radius: 1em;
}

.images {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  justify-content: space-evenly;
  gap: 0.5em;

  padding: 0.5em 0.3em;
}

.gal-img {
  width: 135px;

  cursor: pointer;
  border-radius: 1rem;
  opacity: 0.8;
}

.gal-img:hover {
  opacity: 1;
}

@media screen and (max-width: 600px) {
  .img-gallery {
    height: 230px;
  }

  .gal-img {
    width: 80px;
  }

  .search-input {
    width: 80%;
  }

  .clear-icon {
    /* position: absolute; */
    right: 4rem;
  }

  .search-img-btn {
    width: 20%;
  }
}

.selected-img {
  border: 3px solid red;
}

.page-btns {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  position: absolute;
  bottom: 85px;
  left: 50%;
  transform: translateX(-50%);
}

.page-num {
  font-weight: 100;
  font-size: 0.9rem;
}

@media screen and (max-width: 700px) {
  .page-num {
    font-size: 0.75rem;
  }
}

.page-selector {
  font-size: 2.5rem;
  color: #999;

  cursor: pointer;
}

.page-selector:hover {
  color: #333;
}

.no-photo-msg {
  color: red;
  padding: 1em;
  text-align: center;
}

/* FOOTER */
.footer {
  background: hsl(207, 32%, 26%);

  display: flex;
  justify-content: center;
  padding: 0.5em;
}

.header-img-credit {
  text-decoration: none;
  color: white;
  font-size: 0.7rem;
}

.header-img-credit:hover {
  color: #999;
}

/*----------LOAD SPINNER FOR IMAGE SEARCH----------*/
/*CSS by summer (@Elvira-Ho) - https://codepen.io/Elvira-Ho/pen/jvmRNK*/

.loader {
  position: relative;
  /* height taken from data-images computed height */
  height: 278px;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.car {
  position: relative;
  left: -5%;
}

@media screen and (max-width: 700px) {
  .loader {
    height: 168px;
  }
}

.hide-loader {
  display: none;
}

.car__body {
  -webkit-animation: shake 0.2s ease-in-out infinite alternate;
  animation: shake 0.2s ease-in-out infinite alternate;
}
.car__line {
  transform-origin: center right;
  stroke-dasharray: 22;
  -webkit-animation: line 0.8s ease-in-out infinite;
  animation: line 0.8s ease-in-out infinite;
  -webkit-animation-fill-mode: both;
  animation-fill-mode: both;
}
.car__line--top {
  -webkit-animation-delay: 0s;
  animation-delay: 0s;
}
.car__line--middle {
  -webkit-animation-delay: 0.2s;
  animation-delay: 0.2s;
}
.car__line--bottom {
  -webkit-animation-delay: 0.4s;
  animation-delay: 0.4s;
}

@-webkit-keyframes shake {
  0% {
    transform: translateY(-1%);
  }
  100% {
    transform: translateY(3%);
  }
}

@keyframes shake {
  0% {
    transform: translateY(-1%);
  }
  100% {
    transform: translateY(3%);
  }
}
@-webkit-keyframes line {
  0% {
    stroke-dashoffset: 22;
  }
  25% {
    stroke-dashoffset: 22;
  }
  50% {
    stroke-dashoffset: 0;
  }
  51% {
    stroke-dashoffset: 0;
  }
  80% {
    stroke-dashoffset: -22;
  }
  100% {
    stroke-dashoffset: -22;
  }
}
@keyframes line {
  0% {
    stroke-dashoffset: 22;
  }
  25% {
    stroke-dashoffset: 22;
  }
  50% {
    stroke-dashoffset: 0;
  }
  51% {
    stroke-dashoffset: 0;
  }
  80% {
    stroke-dashoffset: -22;
  }
  100% {
    stroke-dashoffset: -22;
  }
}
