:root {
  --color-primary: hsl(203, 25%, 29%);
  --color-secondary: hsl(5, 85%, 77%);
  --color-tertiary: hsl(52, 90%, 73%);

  --color-primary-shade: hsl(203, 25%, 29%);
  --color-secondary-shade: hsl(5, 51%, 63%);
  --color-tertiary-shade: #cea556;

  --color-primary-highlight: hsl(0, 0%, 100%);
  --color-secondary-highlight: hsla(0, 0%, 85%, 0.9);
  --color-tertiary-highlight: hwb(0 47% 53%);
}

*,
::before,
::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-weight: bold;
  max-width: 100vw;
  font-family: "Lexend", sans-serif;
}

body {
  display: grid;
  grid-template-rows: 1fr 1fr auto;
  max-width: 100vw;
  overflow-x: hidden;
}

header {
  position: relative;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  width: 100%;
  max-width: 100vw;

  background-color: hsl(203, 25%, 29%);

  overflow: hidden;
}

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;

  padding: 1.5rem;

  position: absolute;
  top: 0;
}

nav a {
  font-size: clamp(1.2rem, calc(1.2rem + 0.1vw), 2.5rem);

  z-index: 1;
  text-decoration: none;
  color: var(--color-primary-highlight);
}

nav a:hover {
  text-decoration: underline;
  color: var(--color-secondary-highlight);
}

.header__image {
  background-image: url(assets/images/image-background.jpg);
  background-size: 80%;
  background-position: 50% 50%;
  background-repeat: no-repeat;

  width: 100%;
  aspect-ratio: 1 / 1;
}

.header__text {
  display: flex;
  flex-direction: column;

  width: 80vw;

  text-align: center;

  gap: 2rem;

  margin-block-end: 3rem;
}

.header__text h1 {
  font-size: clamp(2rem, calc(2rem + 1vw), 6rem);
  color: var(--color-primary-highlight);
  font-weight: 500;
}

.header__text p {
  font-size: clamp(1.2rem, calc(1.2rem + 0.2vw), 2.5rem);
  color: var(--color-secondary-highlight);
  font-weight: 400;
}

header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;

  width: 100vw;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0.7) 100%
  );
}

.header__text > * {
  position: relative;
  z-index: 1;
}

#home {
  position: sticky;
}

main {
  min-height: 80%;
}

.library {
  display: grid;
  grid-template-columns: repeat(
    auto-fill,
    clamp(15rem, calc(30rem - 15vw), 30rem)
  );
  gap: 1rem;

  justify-content: center;

  padding: 2rem;
}

.library__heading {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  width: 100vw;

  text-align: center;
  color: var(--color-tertiary-highlight);
  background: var(--color-secondary-highlight);
  font-size: clamp(0.8rem, calc(0.8rem + 1vw), 2.5rem);

  margin-bottom: 1rem;
  padding-inline: 1rem;
  z-index: 999;
}

.library__heading h2 {
  margin-inline-end: 1rem;
}

.library__book {
  display: flex;
  flex-direction: column;
  justify-content: center;

  position: relative;
  padding: 1rem;
  width: 100%;
  border-radius: 1.5rem;
  aspect-ratio: 1 / 1;

  background: var(--color-tertiary);
  border: 0.5rem solid var(--color-tertiary-shade);
}

.library__book__title {
  font-size: clamp(1.5rem, calc(1.5rem + 0.1vw), 3rem);
  text-align: center;
  margin-block-end: 1rem;
}

.library__book p {
  margin-block: 0.3rem;
  font-size: clamp(0.9rem, calc(0.9rem + 0.2vw), 1.5rem);
}

.library__book span:not(.bold) {
  font-weight: 400;
}

.library__book__image {
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: top;
  margin-block-end: 1rem;

  border-radius: 0.5rem;
}

.bold {
  font-weight: 700;
}
.library__book__delete-button {
  position: absolute;
  top: 0;
  right: 0;
  margin: 0 0.5rem;
  background: none;
  width: 0.5rem;
  border: none;
  font-size: 1rem;
  color: black;
  z-index: 100;
}

.library__book__delete-button:hover {
  cursor: pointer;
  color: var(--color-tertiary-highlight);
}

.library__book__toggle-read-button {
  border-radius: 1rem;
  border: none;
  padding: 0.3rem;
  margin-block-start: 0.5rem;
}

.library__book__toggle-read-button:hover {
  cursor: pointer;
  filter: brightness(1.2);
}

.library__book__toggle-read-button--read {
  color: hsl(0, 0%, 100%);
  background-color: hsl(120, 41%, 48%);
}

.library__book__toggle-read-button--unread {
  color: hsl(0, 0%, 100%);
  background-color: hsl(0, 94%, 62%);
}

#library__create-book {
  background: none;
  border: none;
  font-size: clamp(1rem, calc(1rem + 1vw), 2.5rem);
  color: var(--color-tertiary-highlight);
  padding: 1rem;
}

#library__create-book:hover {
  cursor: pointer;
  color: var(--color-secondary-highlight);
  background-color: var(--color-tertiary-highlight);
}

#library__book__dialog {
  background: var(--color-secondary-highlight);
  border: 0.6rem solid var(--color-tertiary-highlight);
  border-radius: 1.5rem;

  padding: 1rem;

  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

  width: min(80vw, 30rem);
}

#library__book__form {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#library__book__form label {
  display: block;

  margin-block: 0.5rem;

  font-size: clamp(1rem, calc(1rem + 0.2vw), 3rem);
}

#library__book__form input[type="text"] {
  display: block;
  border-radius: 1rem;
  padding: 0.4rem 1rem;
  margin-block: 0.5rem;
  width: 100%;
  border: none;
  transition: 500ms ease;
}

#library__book__form input[type="text"]:hover,
#library__book__form input[type="number"]:hover {
  transform: scale(1.02);
}

#library__book__form input[type="number"] {
  display: block;
  border-radius: 1rem;
  padding: 0.4rem 1rem;
  margin-block: 0.5rem;
  width: 12rem;
  border: none;
  transition: 500ms ease;
}

#create-book {
  padding: 0.5rem 1rem;
  margin: auto;
  width: fit-content;
  border-radius: 1rem;
  background-color: var(--color-tertiary-highlight);
  border: 1px solid white;
  color: var(--color-primary-highlight);
  font-size: 0.9rem;
  transition: 200ms ease;
}

#create-book:hover {
  cursor: pointer;
  transform: scale(1.05);
  filter: brightness(1.2);
}

#create-book:focus {
  transform: scale(1);
}

#library__book__form input[type="radio"] {
  width: 1rem;
  border: 0;
  aspect-ratio: 1/1;
}

#library__book__form input[type="radio"]:hover {
  cursor: pointer;
}

#library__book__form input[type="file"] {
  border-radius: 1rem;
  overflow: hidden;
  transition: 500ms ease;
}

#close-button {
  position: absolute;
  top: 0;
  right: 0;
  margin: 1rem;
  background: none;
  width: 0.5rem;
  border: none;
  font-size: 1rem;
  color: black;
  z-index: 100;
}

#close-button:hover {
  cursor: pointer;
  color: var(--color-tertiary-highlight);
}

@media screen and (min-width: 45rem) {
  header {
    max-width: 100vw;
  }

  header::before {
    background:
      linear-gradient(to bottom, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.7) 100%),
      linear-gradient(150deg, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.7) 100%);
  }

  nav {
    padding: 2rem;
  }

  .header__image {
    background-position: top left;
    background-size: 80%;

    margin-inline-end: auto;

    width: 80%;
    max-height: 100vh;
  }

  .header__text {
    position: absolute;
    bottom: 0;
    right: 0;

    text-align: right;

    margin-inline-end: 3rem;
    width: clamp(25ch, calc(25ch + 20vw), 100ch);
  }

  .library__heading {
    text-align: right;
    padding-inline-end: 2rem;
  }
}

@media screen and (min-width: 68rem) {
  .header__image {
    background-size: contain;
  }
}
