/* Start CSS Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  box-sizing: inherit;
  height: 100%;
  scroll-behavior: smooth;
}

html {
  text-size-adjust: none;
}

body,
h1,
h2,
h3,
h4,
p,
figure,
blockquote,
dl,
dd {
  margin-block-end: 0;
}

ul[role="list"],
ol[role="list"] {
  list-style: none;
}

body {
  min-height: 100vh;
  height: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
button,
input,
label {
  line-height: 1.1;
}

h1,
h2,
h3,
h4 {
  text-wrap: balance;
}

img,
picture {
  max-width: 100%;
  display: block;
}

input,
button,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
}

textarea:not([rows]) {
  min-height: 10em;
}

:target {
  scroll-margin-block: 5ex;
}
/* End CSS Reset */

/* Start Global Styles */
:root {
  --green-900: #00494d;
  --green-400: #26c0ab;
  --grey-500: #5e7a7d;
  --grey-400: #7f9c9f;
  --grey-200: #c5e4e7;
  --grey-50: #f4fafb;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: var(--grey-200);
  font-family: "Space Mono", monospace;
  height: fit-content;
  padding: 24px 0 0 0;
}

header {
  margin-bottom: 2rem;
}

main {
  max-width: 60rem;
  background-color: white;
  padding: 2rem;
  border-radius: 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
  white-space: nowrap;
  clip-path: inset(50%);
}

.inputs-container {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  justify-content: center;
  align-items: center;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.input-group label,
.tip-percentage-label,
.error-message {
  font-size: 1rem;
  font-weight: 600;
  color: var(--grey-500);
}

input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.bill-input,
.people-input {
  width: 100%;
  border: none;
  background-color: var(--grey-50);
  font-size: 1.5rem;
  text-align: right;
  color: var(--green-900);
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 0.2rem;
  background-repeat: no-repeat;
  background-position: left 1rem center;
  background-size: 0.7rem;
  caret-color: var(--green-400);
  cursor: pointer;
}

.bill-input {
  background-image: url("./images/icon-dollar.svg");
}

.people-input {
  background-image: url("./images/icon-person.svg");
}

.bill-input::placeholder,
.people-input::placeholder {
  color: var(--grey-400);
  font-weight: 400;
}

.bill-input:focus,
.people-input:focus,
.custom-tip:focus {
  border: var(--green-400) solid 2px;
  outline: none;
}

.tip-percentages {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  width: 100%;
  border: none;
}

.tip-percentage-container {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

.tip-option {
  position: relative;
}

.tip-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.tip-option label,
.custom-tip {
  display: block;
  width: 100%;
  text-align: center;
  padding: 0.8rem;
  border-radius: 0.3rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.tip-option label {
  background-color: var(--green-900);
  color: var(--grey-50);
}

input[type="radio"]:checked + label {
  background-color: var(--green-400);
  color: var(--green-900);
}

.custom-tip {
  background-color: var(--grey-50);
  border: none;
  text-align: right;
  color: var(--green-900);
  caret-color: var(--green-400);
  cursor: pointer;
}

.custom-tip::placeholder {
  color: var(--grey-500);
  font-weight: 600;
}

.label-ms-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.error-message {
  display: none;
  color: #ff6257;
}

.error {
  border: 2px solid #ff6257;
}

.display-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  background-color: var(--green-900);
  padding: 2rem 1.5rem;
  gap: 2rem;
  border-radius: 1rem;
}

.tip-container,
.total-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.text-container {
  display: flex;
  flex-direction: column;
}

.tip-amount-text,
.total-amount-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--grey-50);
}

.sp-text {
  color: var(--grey-400);
  font-weight: 600;
}

.tip-amount,
.total-amount {
  font-size: 2rem;
  font-weight: 700;
  color: var(--green-400);
}

.reset-btn {
  background-color: var(--green-400);
  color: var(--green-900);
  font-size: 1.3rem;
  font-weight: 600;
  padding: 0.7rem;
  border-radius: 0.3rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
}

.reset-btn:disabled {
  background-color: #0d686d;
  color: var(--green-900);
  cursor: not-allowed;
}

@media (min-width: 54rem) {
  main {
    grid-template-columns: repeat(2, 1fr);
    gap: 3rem;
  }

  .tip-percentage-container {
    grid-template-columns: repeat(3, 1fr);
  }

  .display-container {
    padding: 3rem 2rem;
  }

  .total-container {
    margin-bottom: 6rem;
  }

  .reset-btn {
    margin-top: auto;
  }
}
