/*
  Apply box-sizing to all elements,
  including pseudo-elements
*/
*,
*::before,
*::after {
  box-sizing: border-box;
}

/*
  Define global CSS variables
*/
:root {
  --ff-primary: "Inter", system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif; /* Primary font family */
  --ff-secondary: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    "Roboto Mono", monospace; /* Secondary font family */
  --fw-reg: 300; /* Regular font weight */
  --fw-bold: 900; /* Bold font weight */
  --body-weight: 400;
  --heading-weight: 800;
  --clr-light: #f8f8f8; /* Light color */
  --clr-dark: #1a1a1a; /* Dark color */
  --clr-accent: #ad0e0e; /* Accent color */
  --fs-h1: 2.5rem;
  --fs-h2: 2rem;
  --fs-h3: 1.5rem;
  --fs-h4: 1.25rem;
  --fs-body: 1rem; /* Body font size */
  --bs: 0.25em 0.25em 0.75em rgb(0, 0, 0, 0.5),
    0.125em 0.125em 0.25em rgba(0, 0, 0, 0.25); /* Box shadow */
  --background-color: var(--clr-dark); /* Background color */
  --font-color: var(--clr-light); /* Font color */
  --toggle-color: var(--clr-light); /* Toggle color */
}

/*   Media query for screens wider than 900px */
@media (min-width: 650px) {
  :root {
    --fs-h1: 4.5rem;
    --fs-h2: 3.5rem;
    --fs-h3: 2rem;
    --fs-h4: 1.5rem;
    --fs-body: 1.25rem;
  }
}

/*   Media query for screens narrower than 350px */
@media (max-width: 350px) {
  :root {
    --fs-h1: 2rem;
    --fs-h2: 1.5rem;
    --fs-h3: 1.25rem;
    --fs-h4: 1rem;
    --fs-body: 0.75rem;
  }
}

/*   Media query for high DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/*   Media query dark theme preference */
@media (prefers-color-scheme: dark) {
  :root {
    --background-color: var(--clr-dark);
    --font-color: var(--clr-light);
  }

  :root.light {
    --background-color: var(--clr-light);
    --font-color: var(--clr-dark);
  }
}

/*   Media query for reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ###################### GENERAL STYLES CSS ################################# */

html {
  scroll-behavior: smooth;
}

::-webkit-scrollbar {
  scrollbar-color: transparent;
  width: 0;
  height: 10px;
}

::-webkit-scrollbar-track {
  display: none;
}

::-webkit-scrollbar-thumb {
  background-color: var(--clr-accent);
  border-radius: 10px;
}

body {
  background-color: var(--background-color);
  color: var(--font-color);
  margin: 0;
  font-family: var(--ff-primary);
  font-size: var(--fs-body);
  font-weight: var(--body-weight);
  line-height: 1.5;
  overflow-y: scroll;
  overflow-x: hidden;
  user-select: none;
  cursor: default;
  transition: background-color 700ms ease-in-out, color 300ms ease-in-out;
}

/* Screen-reader only text */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

section {
  padding: 1.5em 2em;
}

img {
  display: block;
  max-width: 90%;
  height: auto;
}

strong {
  font-weight: var(--fw-bold);
}

/* ###################### TYPOGRAPHY CSS ################################# */

.name-element {
  font-family: var(--ff-secondary);
  position: relative;
  padding-bottom: 0.2em;
}

.name-element::after {
  content: "";
  position: absolute;
  width: 100%;
  transform: scaleX(0);
  height: 2px;
  bottom: 0;
  left: 0;
  background-color: var(--background-color);
  filter: invert(1);
  transform-origin: bottom right;
  transition: transform 0.5s ease-out;
  z-index: -1;
}

.name-element:hover::after {
  transform: scaleX(1);
  transform-origin: bottom left;
}

h1,
h2,
h3,
h4 {
  line-height: 1;
  margin: 5px;
}

h1 {
  font-size: var(--fs-h1);
  font-weight: var(--heading-weight);
}

h2 {
  font-size: var(--fs-h2);
  font-weight: var(--heading-weight);
}

h3 {
  font-size: var(--fs-h3);
  font-weight: var(--heading-weight);
}

h4 {
  font-size: var(--fs-h4);
  pointer-events: none;
}

.section__title {
  margin-bottom: 0.25em;
}

.section__title--intro {
  font-weight: var(--fw-reg);
}

.section__title--intro strong {
  display: block;
}

.section__subtitle {
  margin: auto;
  font-size: var(--fs-h3);
}

.section__subtitle--intro,
.section__subtitle--about,
.section__subtitle--skills,
.section__subtitle--projects {
  background: var(--clr-accent);
  padding: 0.25em 1em;
  font-family: var(--ff-secondary);
  color: var(--clr-light);
}

/* ###################### INTRO SECTION CSS ################################# */

.intro {
  padding-top: 15vh;
  padding-bottom: 15vh;
  margin-inline: auto;
}

.intro__img {
  box-shadow: var(--bs);
  border-top-right-radius: 4.5em;
  border-bottom-left-radius: 4.5em;
}

.section__subtitle--intro {
  display: inline-block;
}

@media (min-width: 650px) {
  .intro {
    display: grid;
    max-width: 1000px;
    padding-top: 35vh;
    padding-bottom: 1vh;
    grid-column-gap: 1em;
    grid-template-areas: "img title" "img subtitle";
    grid-template-columns: min-content max-content;
  }

  .intro__img {
    grid-area: img;
    min-width: 250px;
    position: relative;
    z-index: 2;
  }

  .section__subtitle--intro {
    align-self: start;
    grid-column: -1/1;
    grid-row: 2;
    text-align: right;
    position: relative;
    left: -1.5em;
    width: calc(100% + 1em);
  }
}

.about-me,
.my-experience,
.my-projects,
.my-skills {
  opacity: 0;
  visibility: hidden;
  transition: all 700ms ease-in-out;
}

.about-me.is-visible,
.my-experience.is-visible,
.my-projects.is-visible,
.my-skills.is-visible {
  opacity: 1;
  visibility: visible;
  padding-top: 5em;
}

/* ###################### ABOUT ME SECTION CSS ################################# */

.about-me {
  margin-inline: auto;
  padding-top: 10em;
  text-align: justify;
  text-justify: inter-word;
}

.about-me__img {
  box-shadow: var(--bs);
  border-top-left-radius: 2.5em;
  border-bottom-right-radius: 2.5em;
}

@media (min-width: 650px) {
  .about-me {
    max-width: 1000px;
    display: grid;
    grid-template-columns: 1fr 200px;
    grid-template-areas: "title img" "subtitle img" "text img";
    grid-column-gap: 2em;
  }

  .section__title--about {
    grid-area: title;
  }

  .section__subtitle--about {
    grid-column: 1/-1;
    grid-row: 2;
    position: relative;
    left: -1em;
    width: calc(100% + 3em);
    padding-left: 1em;
    padding-right: calc(200px + 4em);
  }

  .about-me__img {
    grid-area: img;
    position: relative;
    z-index: 2;
  }

  .about-me__body {
    grid-column: span 2;
  }
}

/* ###################### EXPERIENCE SECTION CSS ################################# */

.my-experience {
  margin-top: 2em;
}

.section__title--experience {
  position: relative;
  text-align: center;
}

.section__title--experience::after,
.section__title--experience::before {
  content: "";
  display: block;
  width: 20vh;
  height: 1px;
  margin: 0.5em auto 0.5em;
  background: var(--background-color);
  filter: invert(1);
  opacity: 0.25;
  transition: background-color 700ms ease-in-out;
}

.experiences {
  margin-bottom: 4em;
}

.job {
  max-width: 1000px;
  margin-inline: auto;
}

.job + .job {
  margin-top: 1em;
}

.job-desc li {
  margin-bottom: 1em;
}

@media (min-width: 650px) {
  .experiences {
    display: grid;
    grid-template-columns: repeat(3, minmax(100%, 1fr));
    gap: 10rem;
    max-width: 1000px;
    margin: auto;
    grid-auto-flow: column;
    overflow-x: scroll;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    align-items: center;
  }

  .job {
    padding: 20px;
    margin: 1em;
    scroll-snap-align: center;
  }

  .job-desc > * {
    word-wrap: break-word;
    word-break: break-word;
  }
}

/* ###################### PROJECTS SECTION CSS ################################# */
.my-projects {
  margin-inline: auto;
  text-align: justify;
  padding: 15px;
  margin-top: 30px;
}

.projects-grid {
  display: grid;
  gap: 1rem;
}

.project-item {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.02),
    rgba(255, 255, 255, 0.01)
  );
  border: 1px solid;
  border-radius: 0.9rem;
  box-shadow: var(--bs);
  transition: transform 220ms ease, box-shadow 220ms ease, background 220ms ease;
}

.project-item__title {
  margin: 0 0 0.5rem 0;
}

.project-item__head {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.25rem;
}

.project__logo {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  object-fit: cover;
}

.project-item__subtitle {
  margin: 0 0 1rem 0;
  color: var(--font-color);
  opacity: 0.9;
  font-size: 0.98rem;
  line-height: 1.4;
}

.project-item__link {
  display: block; /* fill the article */
  color: inherit;
  text-decoration: none;
  padding: 1.2rem; /* provide the visual padding inside the card and make the full area clickable */
  border-radius: 0.9rem; /* match article radius */
  width: 100%;
}

.project-item__link:focus-visible {
  outline-offset: 4px;
  border-radius: 0.7rem;
}

/* Space between projects subtitle and grid */
.section__subtitle--projects {
  margin-bottom: 0.5rem; /* reduce to match other sections */
}

.project-item:hover {
  box-shadow: none;
  transition: box-shadow 250ms ease-in-out;
}

/* Also trigger the hover/focus styles when interacting with the inner link so the visual feedback feels immediate */
.project-item__link:hover,
.project-item__link:focus {
  box-shadow: none;
  transition: box-shadow 250ms ease-in-out;
}

/* ###################### SKILLS SECTION CSS ################################# */

.my-skills {
  margin-inline: auto;
  text-align: justify;
  padding: 15px;
  margin-top: 30px;
}

/* Consolidated skill-list and skill-item styles (removed duplicate definitions) */
.skill-list {
  /* reset list padding and use flex layout for wrapping */
  padding-inline-start: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.6rem;
  margin: 0;
  align-items: center;
}

.skill-item {
  border: 1px solid;
  border-radius: 0.6rem;
  display: inline-block;
  margin: 0;
  padding: 0.38em 0.65em;
  box-shadow: var(--bs);
  transition: box-shadow 400ms ease-in-out;
}

.skill-item:hover {
  box-shadow: none;
  transition: box-shadow 250ms ease-in-out;
}

/* Compact 2x2 grid for skills to reduce vertical space */
.skills-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem 2rem;
}

.skill-group__title {
  font-size: var(--fs-h4);
  margin: 0 0 0.4rem 0;
  color: var(--font-color);
  font-weight: var(--fw-bold);
}

.skill-group {
  margin: 0;
}

/* (Previous detailed .skill-list and .skill-item merged above) */
@media (min-width: 900px) {
  .skills-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem 3rem;
  }

  .skill-item {
    font-size: 1.05rem; /* slightly larger for readability */
    padding: 0.55em 0.95em;
  }
}

@media (min-width: 650px) {
  .my-skills {
    max-width: 1000px;
  }
  .my-projects {
    max-width: 1000px;
    margin-inline: auto;
  }
}

/* ###################### SCROLL PROGRESS CSS ################################# */

.scroll-progress {
  position: sticky;
  bottom: 0;
  width: 0%;
  height: 5px;
  background: var(--clr-accent);
  border-radius: 10px;
  z-index: 1000;
  animation: scroll-progress linear;
  animation-timeline: scroll();
}

@keyframes scroll-progress {
  to {
    width: 100%;
  }
}
