@supports (font-variation-settings: normal) {
  @font-face {
    font-family: "Heebo";
    src: local('Heebo'),
    url("../fonts/heebo/heebo.woff2") format("woff2"),
    url("../fonts/heebo/heebo.woff") format("woff"),
    url("../fonts/heebo/heebo.ttf") format("truetype-variations");
    font-style: normal;
    font-weight: 100 300;
    font-display: swap;
  }
}

@supports not (font-variation-settings: normal) {
  @font-face {
    font-family: "Heebo";
    src: local("Heebo"),
    url("../fonts/heebo/static/Heebo-Regular.woff2") format("woff2"),
    url("../fonts/heebo/static/Heebo-Regular.woff") format("woff"),
    url("../fonts/heebo/static/Heebo-Regular.ttf") format("truetype");
    font-style: normal;
    font-weight: 100;
    font-display: swap;
  }
  @font-face {
    font-family: "Heebo";
    src: local("Heebo Bold"),
    url("../fonts/heebo/static/Heebo-Bold.woff2") format("woff2"),
    url("../fonts/heebo/static/Heebo-Bold.woff") format("woff"),
    url("../fonts/heebo/static/Heebo-Bold.ttf") format("truetype");
    font-style: normal;
    font-weight: 300;
    font-display: swap;
  }
}

* {
  box-sizing: border-box;
}

html {
  --background: #FFFFFF;
  --background-alt: #F4F4F5;
  --primary: #000000;
  --primary-contrast: #FFFFFF;
  --accent: #52525B;
  --color: #18181B;
  --danger: red;
  --shadow: #A1A1AA;
  --border: #E4E4E7;
  --font-family: 'Heebo', sans-serif;
  --font: 400 16px/1.5 var(--font-family);

  background: var(--background);
  color: var(--color);
  font: var(--font);
}

html, body {
  margin: 0;
  padding: 0;
}

main {
  height: 100vh;
  overflow-y: auto;
  scroll-snap-type: y proximity;
  scroll-padding-top: 4rem;
}

main > section, main > footer {
  padding: 2rem;
  scroll-snap-align: start;
}

main > section > *, main > footer > * {
  max-width: 955px;
  margin-left: auto;
  margin-right: auto;
}

main > section > img {
  display: block;
  margin: 2rem auto;
}

:where(h1, h2, h3, h4, h5, h6) {
  color: var(--primary);
  text-align: center;

  /* Force headings to `font-weight: 300` so their visual weight stays
   consistent across browsers and during font loading since bold font weight for our custom heebo font is 300 */
  font-weight: 300;
}

:where(h1) {
  box-shadow: 0 5px 5px var(--shadow);
  margin: 0;
  padding: 1rem;
  position: sticky;
  top: 0;
  background-color: var(--background);
}

main > section:nth-child(odd) {
  background: var(--background-alt);
}

.control-error {
  color: var(--danger);
  letter-spacing: 1px;
  font-weight: 300;
  font-size: 0.9rem;
}

footer :where(a:link, a:visited) {
  color: var(--primary);
  text-decoration-style: dotted;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}

footer :where(a:hover, a:focus) {
  text-decoration-style: solid;
  text-decoration-color: var(--primary);
}

:where(a:link) {
  color: var(--primary);
}

label {
  display: block;
}

main {
  scroll-timeline-name: --progress-timeline;
  scroll-timeline-axis: block;
}

#progress {
  background: var(--primary);
  width: calc(100% + 2rem);
  height: 2px;
  margin: 1rem 0 -1rem -1rem;

  transform-origin: left;
  animation: auto linear grow-progress;
  animation-timeline: --progress-timeline;
}

@keyframes grow-progress {
  0% {
    /*moving it a bit to the left since the scroll snap padding already scrolls a bit down automatically*/
    transform: scaleX(-0.011);
  }
  100% {
    transform: scaleX(1);
  }
}

:where(input[type="text"], input[type="email"], textarea) {
  display: block;
  width: 100%;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  font: inherit;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  border-image: linear-gradient(to right, var(--primary), var(--accent)) 30;
}

:where(input[type="text"], input[type="email"], textarea):hover, :where(input[type="text"]:focus, input[type="email"]:focus, textarea:focus) {
  outline: none;
  border-image: none;
  border-color: var(--primary);
}

textarea {
  resize: vertical;
}

@supports selector(:user-invalid) {
  :where(div.control-error > span) {
    visibility: hidden;
  }

  input:user-invalid + div.control-error > span {
    visibility: visible;
  }

  textarea:user-invalid + div.control-error > span {
    visibility: visible;
  }
}

div.control-error {
  margin-bottom: 2rem;
}

:where(fieldset) {
  margin: 0 0 1rem;
  padding: 0;
  border: none;
}

:where(fieldset > legend) {
  margin-bottom: 0.5rem;
}

:where(input[type="radio"]) {
  accent-color: var(--accent);
}

label:has(+ :where(input[required], textarea[required]))::before {
  content: "* ";
  color: var(--danger);
}

legend:has(~ label > *[required])::before {
  content: "* ";
  color: var(--danger);
}

button[type="submit"], div.actions > a.link, dialog button {
  background: var(--primary);
  color: var(--primary-contrast);
  border: none;
  padding: 0.5rem 2rem;
  font-size: 1rem;
  border-radius: 24px;
  text-decoration-line: none;
  display: inline-block;
  text-align: center;
}

:where(button[type="submit"]:hover, button[type="submit"]:focus, div.actions > a.link:hover, div.actions > a.link:focus), dialog :where(button:hover, button:focus) {
  outline: 1px solid var(--primary);
  outline-offset: 2px;
}

:where(img.avatar) {
  height: 150px;
  width: 150px;
  object-fit: cover;
  border-radius: 50%;
}

:where(section.skills > ul) {
  text-align: center;
  list-style-type: none;
  padding: 0;
  column-width: 200px;
}

:where(section.projects img) {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: cover;
  margin: 0 auto;
}

:where(section.projects > div.container) {
  display: grid;
  gap: 3rem;
  margin: 2rem 0;
}

:where(ul.contacts, ul.socials) {
  list-style-type: none;
  padding: 0;
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

:where(ul.contacts > li:not(:last-of-type)) {
  border-right: 1px solid var(--accent);
  padding-right: 1rem;
}

:where(ul.socials > li > a) {
  display: block;
  height: 30px;
  width: 30px;
  border-radius: 50%;
}

:where(ul.socials > li > a:where(:hover, :focus)) {
  outline: 1px dotted var(--primary);
  outline-offset: 5px;
}

:where(dialog) {
  padding: 0;
  border: none;
  box-shadow: 0 0 5px var(--shadow);
}

:where(dialog > header) {
  background-color: var(--primary);
  padding: 1rem;
  color: var(--primary-contrast);
  font-weight: bold;
  font-size: 1.25rem;
}

:where(dialog > section.content) {
  padding: 1rem;
}

:where(dialog > footer) {
  display: flex;
  justify-content: flex-end;
  padding: 0.5rem 1rem;
  border-top: 1px solid var(--border);
}

::backdrop {
  backdrop-filter: blur(5px);
}

@media (min-width: 750px) {
  :where(section.project *) {
    margin: 0;
  }

  :where(section.projects > div.container) {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 150px min-content auto min-content;
    row-gap: 0;
    column-gap: 3rem;
  }

  :where(section.project) {
    display: grid;
    grid-template-rows: subgrid;
    grid-row-start: 1;
    grid-row-end: 5;
    row-gap: 1rem;
    align-items: center;
    text-align: center;
  }

  :where(section.project > img) {
    grid-row: 1;
  }

  :where(section.project > h2) {
    grid-row: 2;
  }

  :where(section.project > div.description) {
    grid-row: 3;
  }

  :where(section.project > div.actions) {
    grid-row: 4;
  }

  @supports not (grid-template-rows: subgrid) {
    :where(section.project > div.container) {
      grid-template-rows: auto;
    }

    :where(section.project) {
      display: flex;
      flex-direction: column;
    }

    :where(section.project > div.actions) {
      /*recommended to use margin but from self knowledge i'm using justify-self'*/
      /*margin-top: auto;*/
      justify-self: flex-end;
    }
  }
}

/*Adjust scroll padding for very small screens (Specifically Iphone 12/13 mini) so that the headers of each section dont hide behind the sticky header*/
@media (max-width: 319px) {
  main {
    scroll-padding-top: 6rem;
  }
}

@media (prefers-color-scheme: dark) {
  html {
    --background: #000000;
    --background-alt: #18181B;
    --primary: #FFFFFF;
    --primary-contrast: #000000;
    --accent: #D4D4D8;
    --color: #F4F4F5;
    --danger: red;
    --shadow: #27272A;
    --border: #27272A;
    --visited-link: #A1A1AA;
    --pressed-link: #71717A;
  }

  /*Adding the below where clauses for better contrast for better accessibility*/
  :where(a:link) {
    color: var(--primary);
  }

  :where(a:visited) {
    color: var(--visited-link);
  }

  :where(a:active) {
    color: var(--pressed-link);
  }
}