body {
  height: 100vh;
  margin: 20px;
  gap: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  background-color: rgb(255, 255, 255);
  align-content: flex-start;
}

img {
  max-width: 100%;
  height: auto;
  background-color: antiquewhite;
}

.cards-front .cards-content:not(:has(img)) {
  font-size: 18px;
  color: black;
}

.cards-front .cards-content:has(img) {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.cards-front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.header {
  width: 100%;
  display: flex;
  justify-content: space-between;
}

.cards {
  width: 500px;
  display: flex;
}

.cards-inner {
  flex: 1;
  min-height: 300px;
  position: relative;
  width: 100%;
  display: grid;
  grid-template-areas: "card";
  transition: transform 0.6s ease;
  transform-style: preserve-3d;
  transform-origin: center center;
  border-radius: 20px;
}

.cards-front,
.cards-back {
  grid-area: card;
  width: 100%;
  border-radius: 20px;
  backface-visibility: hidden;
  display: flex;
  box-sizing: border-box;
  transition: background-color 0.3s linear 0.15s;
}

.project-urls .cards-front {
  background-color: white;
  color: black;
}

.cards-front {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 20px;
  backface-visibility: hidden;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
  background-color: white;
  box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
}

.cards-back {
  transform: rotateY(180deg);
  padding: 20px;
  background-color: white;
  box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.3);
}

.project-urls .cards-back {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.project-urls .cards-back ul {
  padding: 0;
  margin: 0;
}

/* ── Shading via JS classes ── */
.cards.shade-in .cards-front {
  background-color: rgb(225, 225, 225);
}

.cards.shade-in .cards-back {
  background-color: white;
}

.cards.shade-out .cards-front {
  background-color: white;
}

.cards.shade-out .cards-back {
  background-color: rgb(225, 225, 225);
}

/* Transform on hover (desktop) */
@media (hover: hover) {
  .cards:hover .cards-inner {
    transform: rotateY(180deg);
  }
}

/* Always apply the flipped class (for mobile/touch) */
.cards.flipped .cards-inner {
  transform: rotateY(180deg);
}

@media (max-width: 498px) and (orientation: portrait) {
  body {
    align-items: flex-start;
    height: 100%;
    margin: 15px;
    margin-bottom: 30px;
    font-size: 14px;
    gap: 25px;
  }

  .cards {
    margin: 0px;
  }

  .cards-inner {
    min-height: 200px;
  }
}

@media (max-width: 498px) and (orientation: portrait) {
  .cards {
    min-width: 338px;
    min-height: 498px;
    width: 100%;
    max-width: 100%;
  }

  .cards-inner {
    min-height: 498px;
  }

  .cards-front .cards-content {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .cards-front img {
    max-width: none;
    width: 498px;
    height: 100vw;
    object-fit: cover;
    transform: rotate(90deg);
    transform-origin: center center;
    display: block;
  }
}