/* The second scene is one continuous ribbon in the same green/ivory glass world as the hero. */
#work.projects {
  width: var(--page);
  height: calc(100svh - 72px);
  min-height: 0;
  padding: clamp(18px, 3vh, 34px) 0 clamp(16px, 3vh, 30px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  overflow: visible;
  isolation: isolate;
}
#work.projects::before {
  inset: 0 calc((100vw - var(--page)) / -2);
  background:
    radial-gradient(ellipse 42% 54% at 72% 30%, rgba(71, 216, 127, .19), transparent 78%),
    radial-gradient(ellipse 56% 50% at 20% 76%, rgba(144, 192, 159, .17), transparent 82%),
    linear-gradient(135deg, #f9fcf9 2%, #eaf5ed 54%, #f8fbf8 100%);
}
#work.projects::after {
  width: min(48vw, 680px);
  top: 10%; left: 44%;
  background: radial-gradient(circle, rgba(106, 226, 149, .15), transparent 73%);
  filter: blur(52px);
}
#work .showcase-nav-wrap { position: relative; z-index: 5; }
#work .showcase-nav { gap: clamp(12px, 2.6vw, 42px); }
#work .showcase-nav button { font-size: clamp(.7rem, 1.1vw, .85rem); }
#work .showcase-stage {
  --drag: 0;
  width: 100vw;
  height: 100%;
  min-height: 0;
  margin-left: calc((var(--page) - 100vw) / 2);
  overflow: hidden;
  perspective: 1700px;
  perspective-origin: 50% 48%;
  mask-image: none;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
}
#work .showcase-stage.is-dragging,
#work .showcase-stage.is-dragging .ribbon-target { cursor: grabbing; }
/* A quiet horizon and perspective grid anchor the ribbon in space. */
#work .showcase-stage::before {
  z-index: 0;
  left: 10%; right: 10%; bottom: 6%;
  height: 30%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(43, 112, 68, .17), rgba(48, 148, 86, .055) 45%, transparent 73%);
  filter: blur(28px);
}
#work .showcase-stage::after {
  content: "";
  position: absolute;
  z-index: 0;
  pointer-events: none;
  width: 130vw;
  height: 48%;
  left: -15vw;
  bottom: -25%;
  border-top: 1px solid rgba(46, 137, 79, .16);
  border-radius: 50% 50% 0 0;
  background:
    repeating-linear-gradient(90deg, rgba(24, 112, 61, .07) 0 1px, transparent 1px 7vw),
    repeating-linear-gradient(0deg, rgba(24, 112, 61, .055) 0 1px, transparent 1px 4.2vh);
  box-shadow: 0 -18px 62px rgba(255,255,255,.34);
  transform: perspective(720px) rotateX(64deg);
  transform-origin: 50% 0;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,.72), rgba(0,0,0,.18) 62%, transparent 94%);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.72), rgba(0,0,0,.18) 62%, transparent 94%);
}
.ribbon-canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  pointer-events: none;
}
.ribbon-target {
  position: absolute;
  z-index: 2;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: grab;
}
.ribbon-target:focus-visible {
  outline: 2px solid #009d55;
  outline-offset: 4px;
}
.gallery-footer {
  position: relative; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 12px;
  border-top: 1px solid rgba(16,39,29,.11);
}
.gallery-count { color: var(--green-deep); font-size: .7rem; font-weight: 780; letter-spacing: .16em; }
.gallery-open { border: 0; border-bottom: 1px solid var(--green-deep); padding: 5px 0; background: transparent; color: var(--forest); font-size: .82rem; font-weight: 700; cursor: pointer; }
.gallery-open span { margin-left: 14px; }
.gallery-open:hover, .gallery-open:focus-visible { color: var(--green-deep); }

body.gallery-opened { overflow: hidden; }
.gallery-dialog {
  position: fixed;
  inset: 4vh 3vw;
  width: 94vw;
  height: 92vh;
  max-width: 1600px;
  max-height: 92vh;
  margin: auto;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(255,255,255,.8);
  border-radius: clamp(20px, 2.5vw, 36px);
  background: #f5faf5;
  box-shadow: 0 32px 100px rgba(1,29,16,.22);
  color: var(--forest);
  scroll-behavior: smooth;
}
.gallery-dialog::backdrop { background: rgba(3,33,20,.5); backdrop-filter: blur(14px); animation: gallery-backdrop-in .55s ease both; }
@keyframes gallery-backdrop-in { from { background: rgba(3,33,20,0); backdrop-filter: blur(0); } }
.gallery-dialog-shell {
  position: relative;
  min-height: 100%;
  padding: clamp(22px, 3.2vw, 56px);
  display: grid;
  grid-template-columns: minmax(220px, .34fr) minmax(0, .66fr);
  align-items: start;
  column-gap: clamp(28px, 4.8vw, 82px);
  row-gap: 0;
  background: radial-gradient(ellipse 55% 42% at 92% 1%, rgba(101,219,144,.12), transparent 80%);
}
.gallery-close { position: sticky; z-index: 10; top: 0; float: right; display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid rgba(16,39,29,.13); border-radius: 50%; background: rgba(255,255,255,.88); backdrop-filter: blur(16px); font-size: 1.6rem; line-height: 1; cursor: pointer; }
.gallery-close { grid-column: 1 / -1; justify-self: end; margin-bottom: -42px; }
.gallery-dialog-intro {
  position: sticky;
  top: clamp(22px, 3.2vw, 56px);
  display: grid;
  align-content: space-between;
  gap: clamp(32px, 8vh, 100px);
  min-height: min(76vh, 760px);
  padding: clamp(36px, 7vh, 86px) 0 26px;
}
.gallery-dialog-kicker { margin: 0 0 12px; color: var(--green-deep); font-size: .72rem; font-weight: 780; letter-spacing: .18em; }
.gallery-dialog-copy h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.8rem, 5.4vw, 6.4rem); font-weight: 500; letter-spacing: -.065em; line-height: 1; overflow-wrap: anywhere; }
.gallery-dialog-subtitle { margin: 18px 0 0; color: var(--muted); }
.gallery-detail-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.gallery-detail-tabs a { padding: 8px 13px; border: 1px solid rgba(16,39,29,.12); border-radius: 999px; background: rgba(255,255,255,.64); color: var(--forest); font-size: .76rem; white-space: nowrap; }
.gallery-detail-tabs a:hover, .gallery-detail-tabs a:focus-visible { border-color: var(--green); background: #e7f7eb; }
.gallery-detail-content { display: grid; gap: clamp(36px, 6vw, 90px); padding-top: clamp(36px, 7vh, 86px); }
.gallery-page { scroll-margin-top: 30px; }
.gallery-page-heading { display: flex; align-items: baseline; gap: 16px; padding: 0 0 14px; }
.gallery-page-heading span { color: var(--green-deep); font-size: .72rem; font-weight: 760; letter-spacing: .15em; }
.gallery-page-heading h3 { margin: 0; font-size: clamp(1.25rem, 2.5vw, 2.2rem); letter-spacing: -.035em; }
.gallery-page-heading p { margin: 0 0 0 auto; color: var(--muted); font-size: .8rem; }
.gallery-page-image { overflow: hidden; border-radius: clamp(14px, 2vw, 26px); background: #dcefe0; box-shadow: 0 22px 70px rgba(8,70,38,.1); }
.gallery-page-image img { display: block; width: 100%; height: auto; }
.gallery-page-image.is-crop { aspect-ratio: 1.9; }
.gallery-page-image.is-crop img { height: 100%; object-fit: cover; object-position: 75% center; transform: scale(1.32); }
.gallery-page-pending { min-height: 120px; display: grid; place-items: center; border: 1px dashed rgba(16,39,29,.18); color: var(--muted); font-size: .9rem; }

@media (max-width: 900px) {
  #work.projects { height: calc(100svh - 72px); min-height: 0; display: grid; padding-block: 14px 18px; }
  #work .showcase-stage { min-height: 0; overflow: hidden; padding: 0; margin-left: 0; }
  .gallery-dialog-shell { grid-template-columns: 1fr; gap: 0; }
  .gallery-dialog-intro { position: static; min-height: 0; padding: 30px 0 20px; gap: 22px; }
  .gallery-detail-content { padding-top: 20px; }
}
@media (max-width: 600px) {
  #work.projects { min-height: 0; }
  #work .showcase-stage { margin-left: -16px; }
  #work .showcase-nav { max-width: calc(100vw - 24px); justify-content: flex-start; gap: 18px; }
  .gallery-dialog { inset: 0; width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .gallery-dialog-shell { padding: 20px; }
  .gallery-page-heading { flex-wrap: wrap; gap: 6px 12px; }
  .gallery-page-heading p { flex-basis: 100%; margin: 0; }
}
@media (prefers-reduced-motion: reduce) {
  #work.projects::after { animation: none; transition-duration: 0ms; }
  .gallery-dialog { scroll-behavior: auto; }
  .gallery-dialog::backdrop { animation: none; }
}
