/* ---------- CUSTOM PROPERTIES --------------- */

:root {
  --cl-body-bg: 0, 0%, 11%;
  --cl-input-color-bg: 0, 0%, 90%;
  --cl-border: 216, 12%, 84%;
  --cl-submit-hover-bg: 209, 98%, 61%;

  /* Light mode */
  --cl-bg: 0, 0%, 100%;
  --cl-select-option: 221, 39%, 11%;
  --cl-submit: 217, 19%, 27%;
  --cl-submit-bg: 0, 0%, 100%;
  --cl-submit-border: 216, 12%, 84%;
  --cl-hex: 250, 18%, 19%;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* Dark mode */
    --cl-bg: 215, 28%, 17%;
    --cl-select-option: 255, 5%, 84%;
    --cl-submit: 0, 0%, 100%;
    --cl-submit-bg: 216, 22%, 31%;
    --cl-submit-border: 216, 22%, 31%;
    --cl-hex: 255, 5%, 84%;
  }
}

/* RESET */
/* CSS Reset https://andy-bell.co.uk/a-modern-css-reset/ */

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

body,
h1,
h2,
h3,
h4,
h5,
h6,
p {
  margin: 0;
}

/* Set up body */
body {
  font-family: "Inter", sans-serif;
  line-height: 1.5;
  margin: 10vh auto;
  background-color: hsl(var(--cl-body-bg));
}

/* ---------------- UTILITY CLASSES ------------------*/

.container {
  margin: 0 auto;
  width: 100%;
  max-width: 34.375rem;
}

.grid {
  display: grid;
}

.scheme {
  display: block;
}

@media (width > 450px) {
  .scheme {
    display: flex;
    flex-direction: column;
  }
}

.color {
  max-width: 100%;
  min-height: 3.5rem;
  height: 10vh;
}

@media (width > 450px) {
  .color {
    height: 45vh;
  }
}

.hex {
  background-color: hsl(var(--cl-bg));
  color: hsl(var(--cl-hex));
  padding: 0.75rem 0;
  text-align: center;
  cursor: pointer;
}

.hex:hover,
.hex:focus {
  font-weight: 600;
  text-decoration: underline;
}

/* ----------------- TYPOGRAPHY ------------------- */

select {
  font-family: inherit;
  font-size: 1.125rem;
}

@media (width > 450px) {
  select {
    font-size: 1rem;
  }
}

option:checked {
  font-weight: 600;
}

form > button {
  font-family: inherit;
  font-size: 1.125rem;
  font-weight: 500;
}

@media (width > 450px) {
  form > button {
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
  }
}

.hex {
  font-size: 1rem;
  font-weight: 500;
}

@media (width > 450px) {
  .hex {
    font-size: 0.75rem;
  }
}

/* ----------------- FORM ------------------- */

input,
select {
  cursor: pointer;
  background-color: inherit;
  border: 1px solid hsl(var(--cl-border));
}

input[type="color"] {
  background-color: hsl(var(--cl-input-color-bg));
  width: 40%;
  height: 3rem;
}

@media (width > 450px) {
  input[type="color"] {
    width: 3.75rem;
    height: 2.625rem;
  }
}

select {
  color: hsl(var(--cl-select-option));
  border-radius: 0.375rem;
  width: 100%;
  padding: 0.875rem 0.75rem;
}

@media (width > 450px) {
  select {
    width: 19.5rem;
    padding: 0.625rem 0.75rem;
  }
}

/* ---------------- BUTTON -------------------- */

form > button {
  cursor: pointer;
  color: hsl(var(--cl-submit));
  background-color: hsl(var(--cl-submit-bg));
  padding: 0.875rem 0;
  border: 1px solid hsl(var(--cl-submit-border));
  border-radius: 0.25rem;
  text-decoration: none;

  position: relative;
  isolation: isolate;
}

@media (width > 450px) {
  form > button {
    padding: 0 0.625rem;
  }
}

form > button::after {
  content: "";
  position: absolute;
  z-index: -1;
  background-color: hsl(var(--cl-submit-hover-bg));
  inset: 0;

  scale: 0 1;
  transform-origin: right;
  transition: scale 350ms;
}

form > button:hover::after,
form > button:focus-visible::after {
  transform-origin: left;
  scale: 1 1;
}

/* ---------------- LAYOUT -------------------- */

header > .container {
  padding: 1.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.375rem;
  background-color: hsl(var(--cl-bg));
}

@media (width > 450px) {
  header > .container {
    padding: 1.5rem 0.875rem;
    flex-direction: row;
    align-items: normal;
    gap: 0.75rem;
  }
}

main > .container {
  grid-template-rows: auto;
  grid-template-columns: auto;
}

@media (width > 450px) {
  main > .container {
    grid-template-rows: auto auto;
    grid-template-columns: repeat(5, 1fr);
  }
}
