/**
 * Project card → page expand transition
 * Used on projects/index.html. Easy revert: remove this file + js/project-expand.js link.
 */

.card--expandable.is-origin {
  visibility: hidden;
}

.card__media--empty {
  display: grid;
  place-items: center;
  min-height: 10.5rem;
  border: 1px dashed rgba(74, 102, 112, 0.35);
  background:
    linear-gradient(145deg, rgba(231, 241, 244, 0.5), rgba(255, 255, 255, 0.35));
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.expand-shell {
  position: fixed;
  z-index: 80;
  margin: 0;
  overflow: hidden;
  background: var(--shell);
  border-radius: var(--radius);
  box-shadow: 0 24px 64px rgba(2, 21, 28, 0.45);
  transform-origin: top left;
  will-change: top, left, width, height, border-radius;
}

/* Keep site nav above the expand overlay so it stays usable */
body.is-project-expand .site-nav {
  z-index: 90;
}

.expand-shell[data-phase="open"],
.expand-shell[data-phase="settled"],
.expand-shell[data-phase="closing"] {
  transition:
    top 0.95s cubic-bezier(0.22, 1, 0.36, 1),
    left 0.95s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.95s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.95s cubic-bezier(0.22, 1, 0.36, 1),
    border-radius 0.85s ease,
    background 0.7s ease,
    box-shadow 0.7s ease;
}

/* Sheet sits under the nav — same inset language as direct project pages */
.expand-shell[data-phase="open"],
.expand-shell[data-phase="settled"] {
  top: calc(var(--nav-h) + 0.65rem) !important;
  left: 0.65rem !important;
  width: calc(100vw - 1.3rem) !important;
  height: calc(100vh - var(--nav-h) - 1.3rem) !important;
  border-radius: var(--radius);
  background: var(--shell);
  box-shadow: 0 24px 64px rgba(2, 21, 28, 0.35);
}

.expand-shell__card {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.75rem;
  padding: 0.65rem 0.65rem 0.65rem 0.85rem;
  box-sizing: border-box;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.expand-shell[data-phase="empty"] .expand-shell__card,
.expand-shell[data-phase="open"] .expand-shell__card,
.expand-shell[data-phase="settled"] .expand-shell__card,
.expand-shell[data-phase="closing"] .expand-shell__card {
  opacity: 0;
  pointer-events: none;
}

.expand-shell__card .card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.2rem 0.15rem 0.2rem 0.25rem;
}

.expand-shell__card .card__media {
  position: relative;
  flex: none;
  width: min(16rem, 42%);
  min-height: 10.5rem;
  border-radius: 0.5rem;
  overflow: hidden;
  background: rgba(13, 36, 48, 0.08);
}

.expand-shell__card .card__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.expand-shell__card .card__media--contain img {
  object-fit: contain;
}

.expand-shell__card h2 {
  margin: 0 0 0.5rem;
}

.expand-shell__card .card__hit::after {
  display: none;
}

.expand-shell__page {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: auto;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.65s ease;
}

.expand-shell[data-phase="settled"] .expand-shell__page {
  opacity: 1;
  pointer-events: auto;
}

.expand-shell[data-phase="closing"] .expand-shell__page {
  opacity: 0;
  transition-duration: 0.3s;
}

.expand-shell[data-phase="settled"] .expand-shell__page .back-link,
.expand-shell[data-phase="settled"] .expand-shell__page .page__header,
.expand-shell[data-phase="settled"] .expand-shell__page .deck--project > * {
  animation: expand-soft-in 0.75s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.expand-shell[data-phase="settled"] .expand-shell__page .page__header {
  animation-delay: 0.06s;
}

.expand-shell[data-phase="settled"] .expand-shell__page .deck--project > *:nth-child(1) {
  animation-delay: 0.12s;
}

.expand-shell[data-phase="settled"] .expand-shell__page .deck--project > *:nth-child(2) {
  animation-delay: 0.2s;
}

@keyframes expand-soft-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.expand-shell__page .page {
  padding: 1.25rem clamp(1.25rem, 3vw, 2.5rem) 2.75rem;
  color: var(--ink);
  /* Avoid a sheet-inside-sheet when fetching real project pages */
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  margin: 0;
  min-height: 0;
  max-width: none;
  width: 100%;
}

/* Project pages are white-on-ocean; invert chrome for the light sheet */
.expand-shell__page .page__header h1 {
  color: var(--ink);
}

.expand-shell__page .page__header p {
  color: var(--muted);
}

.expand-shell__page .back-link a {
  color: var(--link);
}

.expand-shell__page .back-link a:hover {
  color: var(--accent);
}

.expand-shell__page .card {
  background: #fff;
  box-shadow: 0 8px 28px rgba(2, 21, 28, 0.08);
}

.expand-shell__page .card--mist {
  background: rgba(231, 241, 244, 0.85);
}

.expand-shell__status {
  margin: 2rem 1.5rem;
  color: var(--muted);
  font-size: 1rem;
}

.expand-backdrop {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 70;
  background: rgba(4, 24, 32, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.65s ease;
}

.expand-backdrop.is-on {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 560px) {
  .expand-shell__card {
    flex-direction: column;
  }

  .expand-shell__card .card__media {
    width: 100%;
    min-height: 0;
    aspect-ratio: 16 / 10;
    order: -1;
  }

  .expand-shell[data-phase="open"],
  .expand-shell[data-phase="settled"] {
    top: calc(var(--nav-h) + 0.4rem) !important;
    left: 0.4rem !important;
    width: calc(100vw - 0.8rem) !important;
    height: calc(100vh - var(--nav-h) - 0.8rem) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .expand-shell[data-phase="open"],
  .expand-shell[data-phase="settled"],
  .expand-shell[data-phase="closing"],
  .expand-shell__card,
  .expand-shell__page,
  .expand-backdrop {
    transition: none !important;
  }

  .expand-shell[data-phase="settled"] .expand-shell__page .back-link,
  .expand-shell[data-phase="settled"] .expand-shell__page .page__header,
  .expand-shell[data-phase="settled"] .expand-shell__page .deck--project > * {
    animation: none !important;
  }
}
