.projects-hero {
  padding: clamp(8px, 2.2vw, 24px) clamp(24px, 4vw, 58px) clamp(20px, 3vw, 32px);
  text-align: center;
}

.projects-title {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", Baskerville, Georgia, serif;
  font-size: clamp(2.6rem, 5vw, 4.4rem);
  font-style: italic;
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: 0.03em;
  color: rgba(255, 248, 236, 0.96);
}

.projects-intro {
  max-width: 780px;
  margin: 0.9rem auto 0;
  font-family: "Palatino Linotype", "Book Antiqua", Baskerville, Georgia, serif;
  font-size: clamp(1.08rem, 1.55vw, 1.45rem);
  line-height: 1.5;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.72);
}

.projects-list {
  display: flex;
  flex-direction: column;
}
.project-item {
  min-height: 100dvh;
  padding: clamp(18px, 3vh, 36px) 34px;
  display: flex;
  align-items: center;
  position: relative;
}
.project-item.bg-1 {
  background: #101010;
}
.project-item.bg-2 {
  background: #151515;
}
.project-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(18px, 3vw, 40px);
  align-items: center;
  justify-items: center;
  width: 100%;
}

.project-counter {
  position: absolute;
  top: clamp(18px, 3vh, 28px);
  left: 34px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  color: rgba(255, 255, 255, 0.42);
  user-select: none;
  pointer-events: none;
}
.project-item.reverse .project-media {
  order: 2;
}
.project-item.reverse .project-text {
  order: 1;
}
.project-media.placeholder {
  background: linear-gradient(135deg, #232323, #111111);
}
.project-text {
  border: 1px solid rgba(255, 255, 255, 0.75);
  padding: 24px;
  max-width: 520px;
  width: 100%;
  text-align: left;
}
.project-text h2 {
  margin: 0 0 12px;
  font-size: 1.35rem;
  letter-spacing: 0.03em;
}

.project-text p {
  margin: 0;
  color: #c9c9c9;
  line-height: 1.6;
  white-space: pre-line;
}
.separator {
  display: flex;
  justify-content: center;
  background: #0d0d0d;
}
.separator::before {
  content: "";
  width: 1px;
  height: 60px;
  background: rgba(255, 255, 255, 0.35);
  margin: 6px 0;
}

/* ===== PROJECT CONTENT WRAPPER ===== */
.content-pane .project-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 60px);
}

.project-context:empty,
.project-related-links:empty {
  display: none;
}

.project-context {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px) 0 clamp(20px, 4vw, 44px);
  text-align: center;
}

.project-context-title {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", Baskerville, Georgia, serif;
  font-size: clamp(2.1rem, 4.1vw, 3.4rem);
  font-style: italic;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: 0.03em;
  color: rgba(255, 248, 236, 0.96);
}

.project-context-description,
.project-context-lead {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", Baskerville, Georgia, serif;
  line-height: 1.6;
  letter-spacing: 0.01em;
}

.project-context-description {
  margin-top: 0.95rem;
  font-size: clamp(1rem, 1.35vw, 1.18rem);
  color: rgba(255, 255, 255, 0.74);
}

.project-context-lead {
  margin-top: 0.95rem;
  font-size: clamp(1.02rem, 1.45vw, 1.22rem);
  color: rgba(255, 248, 236, 0.88);
}

/* ===== PROJECT GALLERY ===== */
.content-pane .project-gallery {
  display: flex;
  flex-direction: column;
  gap: min(35vh, 320px);
  padding: clamp(20px, 4vh, 60px) 0;
}

.project-related-links {
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(12px, 2.5vw, 24px) 0 0;
  display: grid;
  gap: 12px;
}

.project-related-label {
  margin: 0 0 0.2rem;
  text-align: center;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.44);
}

.project-related-link {
  display: grid;
  gap: 0.35rem;
  padding: 0.95rem 1.1rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  text-decoration: none;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    transform 0.2s ease;
}

.project-related-link:hover,
.project-related-link:focus-visible {
  border-color: rgba(111, 177, 255, 0.5);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-1px);
}

.project-related-title {
  font-size: 1rem;
  letter-spacing: 0.04em;
  color: rgba(255, 248, 236, 0.96);
}

.project-related-copy {
  font-size: 0.92rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.68);
}

/* ===== GALLERY IMAGES ===== */
.content-pane .project-gallery img {
  display: block;
  width: min(100%, 1100px);
  height: auto;
  max-width: 100%;
  max-height: calc(100dvh - 120px);
  object-fit: contain;
  margin: 0 auto;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(255, 255, 255, 0.06);

  /* Image protection */
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

a.project-text {
  color: #fff;
  text-decoration: none;
}
.project-text .enter {
  display: block;
  width: fit-content;
  margin-top: 10px;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: #3a8bff;
  border-bottom: 1px solid rgba(58,139,255,0.6);
  transition: color 0.2s ease, border-color 0.2s ease;
}
.project-text:hover .enter {
  color: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid #6fb1ff;
}

.project-figure {
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0;
  margin-inline: auto;

  /* Required for absolute children (code tag, protect overlay) */
  position: relative;
}

.project-caption {
  max-width: 900px;
  width: 100%;
  font-size: 1.33rem;
  color: rgba(255, 255, 255, 0.75);
  text-align: center;
  white-space: pre-line;
}

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

.project-caption p,
.project-description p {
  margin-bottom: 1.4em;
}

.project-caption p + p,
.project-description p + p {
  margin-top: 1.8em;
  color: #4da3ff;
  display: table;
  margin-left: auto;
  margin-right: auto;
  border-bottom: 1px solid rgba(77, 163, 255, 0.6);
  padding-bottom: 0.05em;
  transition: border-color 0.2s ease;
}

.project-caption p + p:hover,
.project-description p + p:hover {
  border-bottom-color: #4da3ff;
}

.project-caption .project-caption-line--enter {
  color: #4da3ff;
  display: table;
  margin-left: auto;
  margin-right: auto;
  border-bottom: 1px solid rgba(77, 163, 255, 0.6);
  padding-bottom: 0.05em;
  transition: border-color 0.2s ease;
}

.project-caption .project-caption-line--enter:hover {
  border-bottom-color: #4da3ff;
}

/* ===== LIGHTBOX ===== */
.lightbox {
  position: fixed;
  inset: 0;
  background: #000;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;

  /* Image protection */
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.lightbox.active {
  display: flex;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  left: 20px;
  background: none;
  border: 1px solid #fff;
  color: #fff;
  padding: 6px 12px;
  cursor: pointer;
}

.project-gallery img {
  cursor: pointer;
}

.project-gallery img:hover {
  filter: brightness(1.05);
}

/* ===== PROJECT MEDIA (projects list) ===== */
.project-media {
  display: block;
  width: 100%;
  max-width: 520px;
  max-height: min(68dvh, 760px);
  height: auto;
  object-fit: contain;
}

/* ===== IMAGE FADE CLEAN ===== */
.project-media,
.project-gallery img {
  opacity: 0;
  filter: blur(6px);
  transition:
    opacity 1.5s ease,
    filter 1.5s ease;
  will-change: opacity, filter;
}

.project-media.is-ready,
.project-gallery img.is-ready {
  opacity: 1;
  filter: blur(0);
}

/* ===== IMAGE CODE OVERLAY ===== */
.project-figure {
  position: relative;
}

.project-image-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  max-width: 100%;
}

.image-code {
  position: static;
  font-size: 12px;
  letter-spacing: 0.08em;
  opacity: 0.85;
  background: rgba(0, 0, 0, 0.45);
  padding: 4px 8px;
  border-radius: 3px;
  margin: 0 0 8px auto;
  pointer-events: auto;
}

.project-image-code {
  pointer-events: auto;
  cursor: pointer;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.06em;
  transition: opacity 0.25s ease, transform 0.25s ease, color 0.25s ease;
}

.project-image-wrapper .project-image-code {
  position: static;
  width: auto;
  height: auto;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  white-space: nowrap;
}

.project-image-code:hover {
  opacity: 1;
  transform: translateY(-2px);
}

.project-image-code .add-to-cart-hint {
  display: block;
  font-size: 9px;
  opacity: 0.7;
  letter-spacing: 0.15em;
  margin-top: 2px;
  transition: opacity 0.25s ease;
}

.project-image-code:hover .add-to-cart-hint {
  opacity: 1;
}

.project-image-code.added {
  color: #6cff9a;
  transform: translateY(-3px);
}

.project-image-code:hover::after {
  content: "";
  display: block;
  width: 40px;
  height: 1px;
  margin: 4px auto 0;
  background: rgba(255, 255, 255, 0.4);
}

/* ===================================================================
   IMAGE PROTECTION LAYER
   - Transparent overlay covers each figure (above the img, below
     the image-code tag). pointer-events: none passes all clicks
     through to the img for lightbox. The overlay's presence still
     disrupts some platform long-press save UI.
=================================================================== */
.img-protect-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  background: transparent;
}

/* ===================================================================
   FLOATING PROJECT TITLE
   Appears in the top gap area once the first image scrolls out of view.
   Hidden automatically when the lightbox is open (handled by JS).
   Must not overlap any image (positioned in the 0-60px gap area on
   desktop where padding-top was collapsed to 0).
=================================================================== */
.project-floating-title {
  position: fixed;
  top: 0;
  left: 260px;
  right: 0;
  z-index: 110;
  padding: 0 20px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  pointer-events: none;
  user-select: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.project-floating-title.is-visible {
  opacity: 1;
}

.lightbox.active ~ .project-floating-title,
body:has(.lightbox.active) .project-floating-title {
  opacity: 0 !important;
}

/* ===================================================================
   NEXT PROJECT SECTION
=================================================================== */
.next-project-section {
  margin-top: min(35vh, 320px);
  padding-top: clamp(30px, 5vh, 60px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.next-project-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 24px;
  text-align: center;
}

.next-project-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.next-project-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(18px, 3vw, 40px);
  align-items: center;
  justify-items: center;
  background: #0f0f0f;
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: clamp(20px, 3vh, 40px) clamp(20px, 3vw, 40px);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.next-project-link:hover .next-project-grid {
  border-color: rgba(255, 255, 255, 0.2);
  background: #141414;
}

.next-project-media {
  display: block;
  width: 100%;
  max-width: 480px;
  max-height: min(52dvh, 560px);
  height: auto;
  object-fit: contain;
  opacity: 0;
  filter: blur(6px);
  transition: opacity 1.2s ease, filter 1.2s ease;
}

.next-project-media.is-ready,
.next-project-media.placeholder {
  opacity: 1;
  filter: blur(0);
}

.next-project-media.placeholder {
  background: linear-gradient(135deg, #1c1c1c, #0d0d0d);
  min-height: 200px;
}

.next-project-text {
  max-width: 520px;
  width: 100%;
  text-align: left;
}

.next-project-text h3 {
  margin: 0 0 12px;
  font-size: 1.25rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: #fff;
}

.next-project-text p {
  margin: 0;
  color: #b0b0b0;
  line-height: 1.6;
  font-size: 0.92rem;
}

.next-project-text .enter {
  display: block;
  width: fit-content;
  margin-top: 8px;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.45);
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.next-project-link:hover .enter {
  color: rgba(255, 255, 255, 0.8);
  border-bottom-color: rgba(255, 255, 255, 0.4);
}

/* ===================================================================
   LIGHTBOX NAVIGATION ARROWS
=================================================================== */
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.75);
  width: 48px;
  height: 72px;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  pointer-events: auto;
}

.lightbox.active .lightbox-nav {
  display: flex;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.lightbox-nav:active {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-nav--prev { left: 16px; }
.lightbox-nav--next { right: 16px; }

.lightbox[data-single="true"] .lightbox-nav {
  display: none;
}

/* ===================================================================
   PROJECT GALLERY: first image vertically centered (desktop)
=================================================================== */
@media (min-width: 701px) {
  body[data-page="projects"] .content-pane {
    padding-top: 0;
  }

  body[data-page="project"] .content-pane {
    padding-top: 0;
  }

  body[data-page="project"] .project-content {
    padding-top: 0;
  }

  body[data-page="project"] .project-gallery {
    padding-top: 0;
  }

  .project-floating-title {
    left: 260px;
  }
}

/* ===================================================================
   MOBILE  (<= 700px)
=================================================================== */
@media (max-width: 700px) {
  .projects-hero {
    padding: 22px 14px 18px;
  }

  .projects-title {
    font-size: clamp(2.05rem, 9vw, 2.7rem);
  }

  .projects-intro {
    font-size: 0.98rem;
    margin-top: 0.65rem;
  }

  .projects-list {
    padding: 0 14px 100px;
  }
  .project-item {
    min-height: auto;
    margin-bottom: 40px;
    padding: 0;
    background: none !important;
    display: block;
  }

  .project-counter {
    position: static;
    display: block;
    margin: 0 0 12px;
    font-size: 0.68rem;
    letter-spacing: 0.14em;
  }

  .project-grid,
  .project-item.reverse .project-grid {
    display: flex;
    flex-direction: column;
  }
  .project-grid > .project-link,
  .project-item.reverse .project-grid > .project-link {
    order: 1;
  }
  .project-grid > .project-text,
  .project-item.reverse .project-grid > .project-text {
    order: 2;
  }
  .project-text {
    max-width: none;
    width: 100%;
    margin-bottom: 14px;
    border: none;
    padding: 0;
  }
  .project-media {
    width: 100%;
    max-width: none;
    margin: 0;
    display: block;
  }

  .project-caption {
    font-size: 1rem;
  }

  .content-pane .project-content {
    padding: 20px 14px 40px;
  }
  .project-context {
    padding: 18px 0 26px;
  }
  .project-context-title {
    font-size: clamp(1.9rem, 8vw, 2.5rem);
  }
  .project-context-description,
  .project-context-lead {
    font-size: 0.98rem;
  }
  .content-pane .project-gallery {
    gap: clamp(120px, 18vh, 240px);
    padding: 20px 0;
    overflow-x: clip;
  }
  .project-gallery .project-figure {
    width: 100%;
    min-height: auto;
    padding: 40px 0;
    align-items: stretch;
  }
  .project-image-wrapper {
    width: 100%;
  }
  .content-pane .project-gallery img {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 150px);
    height: auto;
    margin: 0;
    display: block;
    box-shadow:
      0 20px 60px rgba(0, 0, 0, 0.7),
      0 0 0 1px rgba(255, 255, 255, 0.05);
  }

  .lightbox-nav {
    width: 44px;
    height: 64px;
    font-size: 1.1rem;
  }
  .lightbox-nav--prev { left: 6px; }
  .lightbox-nav--next { right: 6px; }

  .project-floating-title {
    left: 0;
    top: 56px;
    height: 28px;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
  }

  .next-project-grid {
    grid-template-columns: 1fr;
  }
  .next-project-media {
    max-width: 100%;
    max-height: min(45dvh, 400px);
  }
  .next-project-text h3 {
    font-size: 1.1rem;
  }

}

/* Mobile: collapse inner padding on project pages (navbar offset kept) */
@media (max-width: 700px) {
  body[data-page="project"] .project-content {
    padding-top: 0;
  }
  body[data-page="project"] .project-context {
    padding-top: 12px;
  }
  body[data-page="project"] .project-gallery {
    padding-top: 0;
  }
}

/* ===================================================================
   PROJECT LOAD ERROR STATE
=================================================================== */
.project-load-error {
  padding: 4rem 2rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.9rem;
  line-height: 1.7;
}

.project-load-error p {
  margin: 0 0 0.5rem;
}

.project-reload-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.project-reload-btn:hover {
  color: #fff;
}

.project-load-error a {
  color: rgba(255, 255, 255, 0.7);
}

.project-load-error a:hover {
  color: #fff;
}

.project-gallery img {
  image-rendering: auto;
  backface-visibility: hidden;
  transform: translateZ(0);
}
