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

/* Prevent font size inflation */
html {
  -moz-text-size-adjust: none;
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

/* Remove default margin in favour of better control in authored CSS */
body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin: 0;
}

/* Remove list styles on ul, ol elements with a list role, which suggests default styling will be removed */
ul[role="list"],
ol[role="list"] {
  list-style: none;
}

/* Set core body defaults */
body {
  min-height: 100vh;
  line-height: 1.5;
}

/* Set shorter line heights on headings and interactive elements */
h1,
h2,
h3,
h4,
button,
input,
label {
  line-height: 1.1;
}

/* Balance text wrapping on headings */
h1,
h2,
h3,
h4 {
  text-wrap: balance;
}

/* A elements that don't have a class get default styles */
a:not([class]) {
  text-decoration-skip-ink: auto;
  color: currentColor;
}

/* Make images easier to work with */
img,
picture {
  max-width: 100%;
  display: block;
}

/* Inherit fonts for inputs and buttons */
input,
button,
textarea,
select {
  font: inherit;
}

/* Make sure textareas without a rows attribute are not tiny */
textarea:not([rows]) {
  min-height: 10em;
}

/* Anything that has been anchored to should have extra scroll margin */
:target {
  scroll-margin-block: 5ex;
}

:root {
  --white: hsl(0, 0%, 100%);

  --clr-bright-blue: hsl(220, 98%, 61%);
  --clr-gradient: linear-gradient(
    to right,
    hsl(192, 100%, 67%),
    hsl(280, 87%, 65%)
  );

  --very-light-gray: hsl(0, 0%, 98%);
  --very-light-grayish-blue: hsl(236, 33%, 92%);
  --light-grayish-blue: hsl(233, 11%, 84%);
  --dark-grayish-blue: hsl(236, 9%, 61%);
  --very-dark-grayish-blue: hsl(235, 19%, 35%);

  --very-dark-blue: hsl(235, 21%, 11%);  
  --very-dark-desaturated-blue: hsl(235, 24%, 19%); 
  --light-grayish-blue--dark: hsl(234, 39%, 85%);
  --light-grayish-blue--hover: hsl(236, 33%, 92%);
  --dark-grayish-blue--dark: hsl(234, 11%, 52%);
  --very-dark-grayish-blue--dark: hsl(233, 14%, 26%);

  --step--2: clamp(0.61rem, 0.6rem + 0.06vw, 0.64rem);
  --step--1: clamp(0.73rem, 0.7rem + 0.12vw, 0.8rem);
  --step-0: clamp(0.88rem, 0.83rem + 0.22vw, 1rem);
  --step-1: clamp(1.05rem, 0.98rem + 0.35vw, 1.25rem);
  --step-2: clamp(1.26rem, 1.15rem + 0.53vw, 1.56rem);
  --step-3: clamp(1.51rem, 1.36rem + 0.77vw, 1.95rem);
  --step-4: clamp(1.81rem, 1.6rem + 1.09vw, 2.44rem);
  --step-5: clamp(2.18rem, 1.87rem + 1.52vw, 3.05rem);

  --fs-xsmall: var(--step--2);
  --fs-small: var(--step--1);
  --fs-base: var(--step-0);
  --fs-medium: var(--step-1);
  --fs-large: var(--step-2);
  --fs-xlarge: var(--step-3);
  --fs-xxlarge: var(--step-4);
  --fs-xxxlarge: var(--step-5);

  --fw-base: 400;
  --fw-bold: 700;

  --font-family: "DM Sans", Inter, system-ui, sans-serif;
}

[data-theme="light"] {
  --clr-background: var(--very-light-gray);
  --clr-field-background: var(--white);
  --clr-shadow: var(--very-dark-grayish-blue);
  --clr-button-border: var(--dark-grayish-blue);
  --clr-todo-border:  var(--light-grayish-blue);
  --clr-text: var(--very-dark-grayish-blue);
  --clr-placeholder: var(--clr-text);
  --clr-filter-button: var(--dark-grayish-blue);
  --clr-filter-button--hover: var(--very-dark-grayish-blue);
}

[data-theme="dark"] {
  --clr-background: var(--very-dark-blue);
  --clr-field-background: var(--very-dark-desaturated-blue);
  --clr-shadow: var(--very-dark-desaturated-blue);
  --clr-button-border: var(--very-dark-grayish-blue--dark);
  --clr-todo-border: var(--very-dark-grayish-blue--dark);
  --clr-text: var(--light-grayish-blue--dark);
  --clr-placeholder: var(--dark-grayish-blue--dark);
  --clr-filter-button: var(--dark-grayish-blue--dark);
  --clr-filter-button--hover: var(--light-grayish-blue--hover);
}

body {
  font-family: var(--font-family);
  font-size: var(--fs-base);
  font-weight: var(--fw-base);
  color: var(--clr-text);
  background-color: var(--clr-background);
  background-image: url("../images/bg-mobile-light.jpg");
  background-repeat: no-repeat;
  background-position: top;
  background-size: 100% 25vh;
}

[data-theme="dark"] body {
  background-image: url("../images/bg-mobile-dark.jpg");
}

@media (min-width: 50em) {
  body {
    background-image: url("../images/bg-desktop-light.jpg");
    background-size: 100% 38vh;
  }

  [data-theme="dark"] body {
    background-image: url("../images/bg-desktop-dark.jpg");
  }
}

button,
label {
  cursor: pointer;
}

input {
  border: none;
  outline: none;
}

input,
input::placeholder {
  color: var(--clr-text);
  font-size: var(--fs-base);
  font-weight: var(--fw-base);
}

input::placeholder {
  color: var(--clr-placeholder);
}

.wrapper {
  width: min(575px, 100% - 2rem);
  margin-inline: auto;
}

header {
  padding-block: 3rem;
}

header .wrapper {
  display: flex;
  justify-content: space-between;
}

.theme-toggle {
  background: transparent;
  border: 0;
  width: 1.5rem;
  height: 1.5rem;
  background-image: url("../images/icon-moon.svg");
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
}

[data-theme="dark"] .theme-toggle {
  background-image: url("../images/icon-sun.svg");
}

h1 {
  letter-spacing: 0.75rem;
  font-size: var(--fs-xlarge);
  font-weight: var(--fw-bold);
  color: var(--white);
}

.todo-input-field {
  position: relative;
}

.todo-input-field input {
  width: 100%;
  align-items: center;
  gap: 1rem;
  border-radius: 0.5rem;
  padding-block: 1rem;
  padding-left: 3.5rem;
  background-color: var(--clr-field-background);
  box-shadow: -2px 0px 43px -12px var(--clr-shadow);
}

.todo-input-field button {
  position: absolute;
  display: inline-block;
  inset: 0;
  margin: auto 1rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1px solid var(--clr-button-border);
  background: transparent;
}

.todos {
  width: 100%;
  border-radius: 0.5rem;
  box-shadow: -2px 0px 43px -12px var(--clr-shadow);
}

.todo-list {
  margin-bottom: 0;
  padding-left: 0;
  list-style-type: none;
}

.todo-list > * + * {
  border-top: 1px solid var(--clr-todo-border);
}

.empty-todo-message {
  text-align: center;
  padding: 1rem;
  border-top-left-radius: .5rem;
  border-top-right-radius: .5rem;
  background-color: var(--clr-field-background);
}

.todo-list__item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-block: 1rem;
  padding-left: 1rem;
  background-color: var(--clr-field-background);
}

.todo-list__item:first-child {
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
}

.todos > :last-child {  
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
}

.todo-list input[type="checkbox"] {
  position: absolute;
  opacity: 0;
}

.todo-list input[type="checkbox"]:checked ~ .todo-name {
  text-decoration: line-through;
  opacity: 0.5;
}

.todo-list input[type="checkbox"]:checked ~ .todo-name {
  text-decoration: line-through;
  opacity: 0.5;
}

.todo-checkbox {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: 1px solid var(--clr-button-border);
}

.todo-list input[type="checkbox"]:checked ~ .todo-checkbox {
  border: 0;
  background: url("../images/icon-check.svg"), var(--clr-gradient);
  background-repeat: no-repeat;
  background-position: center;
}

.todo-name {
  margin-right: auto;
}

.remove-todo-btn {
  padding-right: 1rem;
  border: none;
  background: transparent;
}

.remove-todo-btn img {
  width: 70%;
}

.todos__status {
  display: flex;
  justify-content: space-between;
  padding: 1rem;
  border-top: 1px solid var(--clr-todo-border);
  border-bottom-left-radius: 0.5rem;
  border-bottom-right-radius: 0.5rem;
  background-color: var(--clr-field-background);
}

.todos-filter {
  display: flex;
  justify-content: center;
  align-content: center;
  border-radius: 0.5rem;
  margin-top: 2rem;
  padding: 1rem;
  background-color: var(--clr-field-background);
  box-shadow: -2px 0px 43px -12px var(--clr-shadow);
}

.todos-filter {
  position: relative;
}

.todos-filter button {
  font-weight: var(--fw-bold);
  border: 0;
  background: transparent;
  color: var(--clr-filter-button);
}

.todos-filter p {
  display: none;
  position: absolute;
}

.todos-filter > *:hover {
  color: var(--clr-filter-button--hover);
}

.todos-filter .active-todos {
  left: 1rem;
}

.todos-filter .clear-completed-todos {
  font-weight: var(--fw-base);
  display: none;
  position: absolute;
  right: 1rem;
}

.todos-filter button[aria-selected="true"] {
  color: var(--clr-bright-blue);
}

.clear-completed-todos {
  color: inherit;
  border: 0;
  background: transparent;
}

@media (min-width: 50em) {
  .empty-todo-message {
    border-radius: .5rem;
  }

  .todo-list__item:last-child {
    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
  }

  .todos__status {
    display: none;
  }

  .todos-filter {
    margin-top: 1rem;
  }

  .todos-filter p {
    display: block;
  }

  .todos-filter .clear-completed-todos {
    display: block;
  }
}
