/* ── Entry animations ──────────────────────── */

/* body just fades — no transform so position:fixed sidebar stays locked */
@keyframes project-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

body {
  animation: project-fade-in 0.4s ease both;
}

/* Project main must not use transform — fixed sidebar would break */
main.project-main {
  animation: project-fade-in 0.4s ease both;
}

/* gallery slides up from below */
@keyframes gallery-slide-in {
  from {
    opacity: 0;
    transform: translateY(80px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.project-gallery {
  animation: gallery-slide-in 0.65s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Project detail page ───────────────────── */

/* The nav's centred 600px column, starting 40px below it (nav: top 40px,
   24px tall). The Back link hangs in the margin to its left. */
.project-main {
  position: relative;
  width: 600px;
  max-width: calc(100% - 24px);
  margin: 0 auto;
  padding-top: 104px;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

/* ── Back link ─────────────────────────────── */

.project-back {
  position: absolute;
  top: 104px;
  right: calc(100% + 40px);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s ease;
}

.project-back:hover {
  color: var(--text);
}

.back-icon {
  display: block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* the icon is drawn white at 50%, the muted text colour in dark mode */
[data-theme="light"] .back-icon {
  filter: invert(1);
}

.project-back:hover .back-icon {
  transform: translateX(-3px);
}

.pager-arrow {
  width: 19.2px;
  height: 12px;
  filter: invert(1) opacity(0.8);
  transform: rotate(180deg);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

[data-theme="light"] .pager-arrow {
  filter: invert(0) opacity(0.8);
}

/* ── Content column ────────────────────────── */

.project-content {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

/* ── Project header ────────────────────────── */

.project-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project-title {
  font-family: var(--font-sans);
  font-size: 20px;
  font-weight: 400;
  line-height: 24px;
  color: var(--text);
}

.project-tagline {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 20px;
  color: var(--text-muted);
}

/* ── Info block + text sections ────────────── */

.project-info {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.project-facts {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* each heading + body is its own section; the gap between sections is
   well above the 16px between paragraphs, so they read as separate */
.project-text {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.text-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-label {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  line-height: 20px;
  color: var(--text-body);
}

.meta-body {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 20px;
  color: var(--text-body);
  /* keep the paragraph breaks typed in admin */
  white-space: pre-line;
}

/* section copy is quieter than the About paragraph above it */
.project-text .meta-body {
  color: var(--text-muted);
}

/* text block paragraphs: formatting is rendered to real markup, so line
   breaks come from <p>/<br> rather than pre-line */
.rich-text {
  white-space: normal;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rich-text p,
.rich-text ol,
.rich-text ul {
  margin: 0;
}

.rich-text ol,
.rich-text ul {
  padding-left: 1.4em;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* bullets are usually short points; numbered items often carry a paragraph */
.rich-text ul {
  gap: 8px;
}

.rich-text li {
  padding-left: 0.2em;
}

.rich-text li::marker {
  font-weight: 600;
  color: var(--text-body);
}

.rich-text strong {
  font-weight: 400;
  color: var(--text);
}

/* Industry, Role and Year side by side */
.project-meta {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.meta-row {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.meta-value {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 20px;
  color: var(--text-body);
}

/* ── Live project button ───────────────────── */

.btn-live-project {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
  padding: 16px 24px;
  border-radius: 100px;
  background: var(--text);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.btn-live-project:hover {
  opacity: 0.92;
}

.btn-live-project img {
  width: 19.2px;
  height: 12px;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-live-project:hover img {
  transform: translateX(4px);
}

[data-theme="light"] .btn-live-project img {
  filter: invert(1);
}

/* ── Gallery ───────────────────────────────── */

.media-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gallery-img {
  overflow: hidden;
  background: #fff;
  flex: 1;
  min-width: 0;
  position: relative;
}

.gallery-img--full {
  width: 100%;
  height: 500px;
  flex: none;
}

/* natural height for non-cover gallery images */
.gallery-img img,
.gallery-img video {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}

/* cover (first) image fills its fixed-height container */
.gallery-img--full img,
.gallery-img--full video {
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.gallery-img img {
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.gallery-img:hover img {
  transform: scale(1.02);
}

/* ── Side-by-side row ──────────────────────── */

.gallery-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* equal tiles: same width, and the same shape (--pair-ar, the average of
   the pair's images, set by script.js); each image fills its tile */
.gallery-row .gallery-img {
  flex: 1 1 0;
  aspect-ratio: var(--pair-ar, auto);
}

.gallery-row .gallery-img img,
.gallery-row .gallery-img video {
  height: 100%;
  object-fit: cover;
}

/* ── Previous / next ───────────────────────── */

.project-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.project-pager:empty {
  display: none;
}

.pager-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 500;
  line-height: 20px;
  color: var(--text-soft);
  text-decoration: none;
  transition: color 0.2s ease;
}

.pager-link:hover {
  color: var(--text);
}

.pager-link--next {
  margin-left: auto;
}

.pager-link--next .pager-arrow {
  transform: none;
}

.pager-link:hover .pager-arrow {
  transform: rotate(180deg) translateX(4px);
}

.pager-link--next:hover .pager-arrow {
  transform: translateX(4px);
}

/* ── Responsive ────────────────────────────── */

/* No room for Back in the left margin: it sits above the title instead */
@media (max-width: 800px) {
  .project-back {
    position: static;
    align-self: flex-start;
    margin-bottom: -8px;
  }
}

@media (max-width: 600px) {
  .project-main {
    max-width: calc(100% - 32px);
    padding-top: 124px;
  }

  .gallery-img--full {
    height: auto;
    aspect-ratio: 6 / 5;
  }

  .project-meta {
    flex-wrap: wrap;
    row-gap: 20px;
  }

  .meta-row {
    flex-basis: 40%;
  }
}

@media (max-width: 480px) {
  .gallery-row {
    flex-direction: column;
  }

  .gallery-row .gallery-img {
    flex: none;
    width: 100%;
  }
}

/* ── Video controls overlay ─────────────────── */

.video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
  z-index: 2;
}

.gallery-img:hover .video-controls {
  opacity: 1;
  pointer-events: auto;
}

.vc-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}

.vc-btn:hover {
  opacity: 1;
}

.vc-progress {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  transition: height 0.15s ease;
}

.vc-progress:hover {
  height: 5px;
}

.vc-progress-fill {
  height: 100%;
  background: #fff;
  border-radius: 2px;
  width: 0%;
  pointer-events: none;
}
/* ── Image zoom ────────────────────────────── */

.gallery-img:has(img),
.gallery-img:has(video) {
  cursor: zoom-in;
}

/* the source stays hidden while its copy is lifted out */
.gallery-img.is-zoomed img {
  visibility: hidden;
}

.img-zoom {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0);
  cursor: zoom-out;
  transition: background 0.35s ease;
}

.img-zoom.is-open {
  background: rgba(0, 0, 0, 0.85);
}

.img-zoom-img {
  position: fixed;
  display: block;
  max-width: none;
  object-fit: cover;
  object-position: center top;
  transition: left 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    top 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    width 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* a lifted video fills its stage; its controls come along */
.img-zoom-stage {
  overflow: hidden;
  /* the frame's own fill, while a video is still loading */
  background: #fff;
}

.img-zoom-stage video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--zoom-pos, center);
}

.img-zoom-stage:hover .video-controls {
  opacity: 1;
  pointer-events: auto;
}

@media (prefers-reduced-motion: reduce) {
  .img-zoom,
  .img-zoom-img {
    transition-duration: 0.01s;
  }
}
