#home {
  /* Fallback for engines without image-set(): plain JPG + dark overlay. */
  background-image:
    linear-gradient(rgba(24, 28, 20, 0.45), rgba(24, 28, 20, 0.55)),
    url('background.jpg');
  /* Preferred: serve lightweight WebP, fall back to JPG; same dark overlay on top. */
  background-image:
    linear-gradient(rgba(24, 28, 20, 0.45), rgba(24, 28, 20, 0.55)),
    image-set(url('background.webp') type('image/webp'),
              url('background.jpg') type('image/jpeg'));
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  /* min-height (not fixed height) + dvh lets content grow and scroll on short
     phones while still accounting for mobile browser chrome. */
  min-height: 100dvh;
  width: 100%;
}

/* ---- Latest Projects: tappable card rows ----
   Surfaces are alpha tints of --color-light (#ECDFCC = 236,223,204). */

.project {
  width: 100%;
  /* Keep the column from stretching on desktop; the layout is mobile-first. */
  max-width: 420px;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(236, 223, 204, 0.045);
  border: 1px solid rgba(236, 223, 204, 0.13);
}

/* --- Header row: the tap target --- */
.project-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  min-height: 54px;
  cursor: pointer;
  text-align: left;
  transition: background 0.18s ease;
}

.project-head:hover {
  background: rgba(236, 223, 204, 0.06);
}

.project-head:active {
  background: rgba(236, 223, 204, 0.1);
}

.project-head:focus-visible,
.project-links a:focus-visible {
  outline: 2px solid var(--color-light, #ECDFCC);
  outline-offset: -2px;
}

.project-title {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.project-name {
  font-size: 18px;
  font-weight: 700;
  /* Tailwind's base line-height of 1.5 would add ~9px per row. */
  line-height: 1.2;
}

.project-sub {
  font-size: 13px;
  line-height: 1.2;
  color: var(--color-dim, #A8A497);
}

.project-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid rgba(236, 223, 204, 0.3);
  font-size: 13px;
  white-space: nowrap;
}

.chev {
  transition: transform 0.3s cubic-bezier(0.22, 0.8, 0.28, 1);
}

.project-head[aria-expanded="true"] .chev {
  transform: rotate(180deg);
}

/* --- Panel: animates to a true 0px via grid-template-rows --- */
.project-panel {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  /* Without this the collapsed anchors stay clickable and Tab-focusable. */
  visibility: hidden;
  overflow: hidden;
  transition: grid-template-rows 0.32s cubic-bezier(0.22, 0.8, 0.28, 1),
              opacity 0.24s ease,
              visibility 0.24s;
}

.project-head[aria-expanded="true"] + .project-panel {
  grid-template-rows: 1fr;
  opacity: 1;
  visibility: visible;
}

/* Grid items default to min-height:auto, which never resolves below content
   height — the card would keep ~64px of dead space when closed. */
.project-panel > * {
  min-height: 0;
}

/* Padding lives here, not on the grid item: padding is part of the item's
   border box and survives a 0fr row. */
.project-links {
  display: flex;
  gap: 10px;
  padding: 0 16px 14px;
}

.project-links a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 46px;
  border-radius: 11px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}

.btn-live {
  background: var(--color-light, #ECDFCC);
  color: var(--color-pdark, #181C14);
}

.btn-live:hover {
  background: #FFF8EA;
}

.btn-code {
  border: 1px solid rgba(236, 223, 204, 0.4);
  color: var(--color-light, #ECDFCC);
}

.btn-code:hover {
  background: rgba(236, 223, 204, 0.1);
  border-color: var(--color-light, #ECDFCC);
}

.project-links a:active {
  transform: scale(0.96);
}

/* ---- Entrance ---- */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

@keyframes fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.rise { animation: rise 0.7s ease both; }
.fade { animation: fade 0.9s 0.5s ease both; }

.social a {
  transition: transform 0.2s ease;
}

.social a:hover {
  transform: translateY(-3px);
}

@media (prefers-reduced-motion: reduce) {
  .rise,
  .fade {
    animation: none;
  }

  .project-head,
  .project-panel,
  .chev,
  .project-links a,
  .social a {
    transition: none;
  }
}
