/* Global element styles */
body {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  margin: 0;
  font-family: var(--font-base);
  background: transparent;
  color: var(--color-text);
  margin: 0;
  line-height: 1.6;
  transition: background var(--transition-duration),
  color var(--transition-duration);
}

html {
  min-height: 100%;
  background: var(--bg-gradient, var(--color-background));
  background-size: 200% 200%;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
}

/* Skip link styling */
.skip-link {
  position: absolute;
  top: -2rem;
  left: 0;
  background: var(--color-primary);
  color: var(--color-background);
  padding: 0.5rem 1rem;
  z-index: 100;
  transition: top var(--transition-duration);
}

.skip-link:focus {
  top: 0;
}

/* Header and Navigation */
header {
  position: relative;
  z-index: 50;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  padding: 1rem;
  background: var(--color-surface, var(--color-background));
  border-bottom: 1px solid var(--color-secondary);
  box-shadow: 1px 1px 10px var(--color-primary);
  border-radius: 999px;
  width: calc(100% - 4rem);
  margin: 1rem 2rem 0.5rem;
}

nav {
  display: flex;
  align-items: center;
}

.nav__list {
  display: flex;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav__list > .nav__item {
  margin: 0 0.5rem;
}

.nav__list > .nav__item .nav__link {
  text-decoration: none;
  color: var(--color-text);
  font-size: 1rem;
  transition: color var(--transition-duration);
}

.nav__list > .nav__item .nav__link:hover,
.nav__list > .nav__item .nav__link:focus {
  color: var(--color-accent);
}

/* Main content */
main {
  container-type: inline-size; 
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  margin-bottom: 2rem;
}

h1 {
  margin-top: 2.5rem;
  font-size: 2.5rem;
  display: block;
  text-align: center;
}

.project-heading {
  margin-bottom: 2.5rem;
}


h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--color-text);
  background: none;
  -webkit-text-fill-color: currentColor;
  text-shadow: none;
}

h1 {
  color: var(--color-primary);
  background: var(--heading-gradient, var(--color-primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 12px rgba(255, 82, 70, 0.55)) drop-shadow(0 0 26px rgba(255, 72, 60, 0.35));
}

/* Hero */
.hero {
  display: flex;
  flex-direction: row;
  align-items: center;
  background: transparent;
  padding: 5rem;
}

.hero__text {
  margin-left: 3rem;
  margin-right: 2rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.hero__desc {
  margin: 2rem 0;
}

.hero__img {
  height: 20rem;
  display: block;
  border-radius: 50%;
  -webkit-mask-image: radial-gradient(
    circle at center,
    black 60%,
    transparent 100%
  );
  mask-image: radial-gradient(
    circle at center,
    hsl(0, 0%, 0%) 60%,
    transparent 100%
  );
}

.latest-work {
  display:flex;
  flex-direction: column;
  margin-top: 3.5rem;
  margin-bottom: 2rem;
}

/* Grid layout for homepage */
.projects{
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  display: grid;
  gap: 2rem;
  margin: 0rem 2rem 2rem 2rem;
}

/* About page */
.skills {
  margin-top: 2rem;
}

.ambition {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: left;;
}

.ambition__desc {
  max-width: 68%;
}

.services {
  margin-top: 2rem;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  text-align: center;
}

.services__heading {
  text-align: center;
}


.services__grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.services__item {
  display: grid;
  grid-template-rows: auto;
  gap: 0.75rem;
  justify-items: center;
  text-align: center;
}

.services__desc {
  max-width: 52ch;
  margin: 0 auto;
}

/* Contact page */
.contact

.contact__form {
  margin-top: 5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 40rem;
  width: 100%;
}

.contact__input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--color-secondary);
  border-radius: 2rem;
}

.contact__textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--color-secondary);
  border-radius: 2rem;
}

.contact__info {
  margin-top: 12rem;
}

/* Buttons */
.btn {
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  border: 1px solid var(--color-primary);
  color: var(--color-background);
  padding: 0.5rem 1rem;
  font-size: 1rem;
  cursor: pointer;
  border-radius: 2rem;
  transition: background var(--transition-duration),
    color var(--transition-duration);
  animation: fadeIn 0.5s ease-in-out;
  box-shadow: 0 8px 22px rgba(255, 72, 60, 0.25);
}

.btn--secondary {
  background: transparent;
  color: var(--color-primary);
  margin-top: 2rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: row;
  align-items: center;
}

.btn--secondary a {
  color: inherit;
  text-decoration: none;
}

.btn--tertiary {
  background: linear-gradient(135deg, var(--color-accent), var(--color-primary));
  color: var(--color-background);
  padding: 0.5rem 1rem;
  border-radius: 2rem;
  transition: background var(--transition-duration),
    color var(--transition-duration);
  text-decoration: none;
  width: fit-content;
}

.btn:hover,
.btn:focus {
  background: linear-gradient(135deg, var(--color-accent), var(--color-primary));
  border-color: var(--color-accent);
}

.btn__link {
  text-decoration: none;
  color: inherit;
}

/* Dialog styling */
dialog {
  border: none;
  padding: 0;
  border-radius: 0.5rem;
  background: transparent;
  overflow: hidden;
  animation: enlarge 0.5s ease forwards;
  margin: auto;
  max-width: 90vw;
  max-height: 90vh;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.8);
}

.project-dialog-img {
  display: block;
  width: 100%;
  height: auto;
}

/* Popover styling */
.popover {
  display: none;
  background: var(--color-background);
  color: var(--color-text);
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-secondary);
  border-radius: 2rem;
  box-shadow: 0 0 0.5rem hsla(0, 0%, 0%, 0.3);
  position: absolute;
  z-index: 1000;
  bottom: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
}

.popover-container {
  position: relative;
  display: flex;
  flex-direction: row;
  justify-content: center;
  margin: 1.5rem 0 1.5rem 0;
}

/* Contact page */
.contact {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem;
  gap: 1rem;
}

.contact__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.contact__info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  gap: 0.5rem;
  margin: 5rem 0rem 5rem 0rem;
}

.contact__info a {
  color: var(--color-text);
  text-decoration: none;
}

/* Reveal the popover on hover of the container */
.popover-container:hover .popover {
  display: block;
}

.popover-container:focus-within .popover {
  display: block;
}

/* View transitions for navigation */
@view-transition {
  navigation: auto;
}

::view-transition-old {
  animation: slideOut 500ms ease-in-out forwards;
}

::view-transition-new {
  animation: slideIn 500ms ease-in-out forwards;
}

/* Keyframe animations */
@keyframes slideOut {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100vw);
  }
}

@keyframes slideIn {
  from {
    transform: translateX(100vw);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes enlarge {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    transform: translateY(1rem);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes card-expand {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.05);
  }
}

.projects__item:hover {
  animation: card-expand 0.5s ease forwards;
  cursor: pointer;
}

/* Footer */
footer {
  padding: 1rem;
  text-align: center;
  background-color: var(--color-background);
  border-top: 1px solid var(--color-secondary);
  box-shadow: 1px 1px 10px var(--color-primary);
  border-radius: 999px;
  width: calc(100% - 4rem);
  margin: 0.5rem 2rem 1rem;
}

.footer__social {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.footer__icon {
  width: 1.5rem;
  height: 1.5rem;
}

html[data-theme="dark"] .footer__icon {
  filter: invert(1);
}

.footer__copy {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

/* Hamburger Menu */
.nav__toggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 100;
}

.hamburger {
  display: block;
  position: relative;
  width: 24px;
  height: 2px;
  background: var(--color-text);
  transition: background 0.3s;
}

.hamburger::before,
.hamburger::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--color-text);
  transition: transform 0.3s, top 0.3s;
}

.hamburger::before {
  top: -8px;
}

.hamburger::after {
  top: 8px;
}

.nav__toggle[aria-expanded="true"] .hamburger {
  background: transparent;
}

.nav__toggle[aria-expanded="true"] .hamburger::before {
  top: 0;
  transform: rotate(45deg);
}

.nav__toggle[aria-expanded="true"] .hamburger::after {
  top: 0;
  transform: rotate(-45deg);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: calc(100% - 2rem);
    margin: 1rem 1rem 0.5rem;
  }

  nav {
    width: auto;
  }

  .nav__toggle {
    display: block;
  }

  .nav__list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-surface, var(--color-background));
    flex-direction: column;
    padding: 1rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border: 1px solid var(--color-secondary);
    margin-top: 0.5rem;
    z-index: 100;
  }

  .nav__list[data-visible="true"] {
    display: flex;
  }

  .nav__list > .nav__item {
    margin: 0.5rem 0;
    text-align: center;
  }

  main {
    margin: 0 1rem 2rem;
  }

  h1 {
    margin-top: 1.5rem;
    font-size: 2rem;
  }

  h2 {
    font-size: 1.35rem;
  }

  .hero {
    flex-direction: column;
    align-items: center;
    padding: 2rem 1.5rem;
    text-align: center;
  }

  .hero__text {
    margin: 0;
    align-items: center;
  }

  .hero__desc {
    margin: 1rem 0;
    max-width: 45ch;
  }

  .hero__img {
    margin-top: 1.5rem;
    height: 14rem;
  }

  .projects {
    margin: 0 1rem 2rem;
  }

  .projects__item {
    padding: 1.5rem;
  }

  .latest-work {
    width: 100%;
    padding: 0 0.5rem;
    margin-top: 2.5rem;
  }

  .services__grid {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .ambition__desc {
    max-width: 100%;
  }

  .services {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.5rem;
  }

  .services__item {
    text-align: center;
    max-width: 80%;
  }

  .contact__info {
    margin: 2rem 0;
  }

  .contact__actions {
    width: 100%;
  }

  footer {
    padding: 1.5rem 1rem;
    width: calc(100% - 2rem);
    margin: 0.5rem 1rem 1rem;
  }
}

@media (max-width: 480px) {
  header {
    padding: 0.75rem;
  }

  .nav__list {
    gap: 0.5rem;
  }

  .hero {
    padding: 1.5rem 1rem;
  }

  .hero__img {
    height: 12rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.2rem;
  }

  .btn {
    width: 100%;
    text-align: center;
  }
}

@media (min-width: 769px) {
  .services__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-items: stretch;
  }

  .services__item {
    max-width: 100%;
  }
}