/* ─── Page override ───────────────────────────────────────────── */
.page { width: 100%; }

/* ─── Work overlay — full-bleed, vertically & horizontally centred over pond ── */
.work-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 72px 24px 28px;
  box-sizing: border-box;
  overflow: hidden;
  /* Smooth transition using --scene-content */
  opacity: var(--scene-content, 1);
  transition: opacity 0.35s ease;
  pointer-events: none; /* children opt back in */
  width: 100%;
}

[data-pond-ready="true"] .work-overlay {
  opacity: var(--scene-content, 1);
}

/* ─── Page header ─────────────────────────────────────────────── */
.work-header {
  text-align: center;
  margin-bottom: 22px;
  flex-shrink: 0;
  pointer-events: auto;
  width: 100%;
}

.work-heading {
  font: 500 clamp(24px, 3.2vw, 38px)/1.15 "DM Sans", sans-serif;
  letter-spacing: -0.025em;
  color: #ffffff;
  margin: 0 0 6px;
  text-shadow: 0 2px 20px rgba(10, 40, 30, 0.7);
}

.work-subheading {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(220, 235, 215, 0.82);
  margin: 0;
  text-shadow: 0 1px 8px rgba(10, 40, 30, 0.5);
}

/* ─── Carousel shell — centered container with side arrow space ── */
.carousel-shell {
  position: relative;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 48px;
  box-sizing: border-box;
  flex-shrink: 0;
  pointer-events: auto;
  display: flex;
  align-items: center;
}

.carousel-navigation { display: contents; }

/* ─── Scroll track ────────────────────────────────────────────── */
.work-carousel {
  display: flex;
  gap: 22px;
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 10px 0 16px;
  cursor: grab;
}

.work-carousel:active { cursor: grabbing; }
.work-carousel::-webkit-scrollbar { display: none; }

/* ─── Individual card ─────────────────────────────────────────── */
.project-card {
  /* Exactly 3 cards fill 100% of the centered track on desktop */
  flex: 0 0 calc((100% - 2 * 22px) / 3);
  min-width: 250px;
  box-sizing: border-box;
  scroll-snap-align: start;
  /* Frosted glass */
  background:
    linear-gradient(145deg, rgba(255,255,252,0.88) 0%, rgba(244,248,240,0.82) 100%);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
  backdrop-filter: blur(24px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, 0.65);
  /* Organic rounded corners */
  border-radius: 26px;
  box-shadow:
    0 8px 30px rgba(10, 38, 28, 0.20),
    0 2px 6px rgba(10, 38, 28, 0.08),
    inset 0 1px 0 rgba(255,255,255,0.8);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* ─── Card image ──────────────────────────────────────────────── */
.card-image-wrap {
  width: 100%;
  overflow: hidden;
  border-radius: 26px 26px 0 0;
  aspect-ratio: 16 / 9;
  background: #c2cdb7;
  flex-shrink: 0;
  position: relative;
}

.card-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

/* ─── Card body ───────────────────────────────────────────────── */
.card-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

/* ─── Tags ────────────────────────────────────────────────────── */
.card-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.card-tag {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #3e6252;
  background: rgba(62, 98, 82, 0.1);
  border: 1px solid rgba(62, 98, 82, 0.2);
  border-radius: 100px;
  padding: 3px 10px;
  line-height: 1.5;
}

/* ─── Card title + desc ───────────────────────────────────────── */
.card-title {
  font: 500 clamp(19px, 1.4vw, 22px)/1.2 "DM Sans", sans-serif;
  letter-spacing: -0.025em;
  color: #172a20;
  margin: 0;
}

.card-desc {
  font-size: 13px;
  line-height: 1.6;
  color: #435649;
  margin: 0 0 8px;
  min-height: 42px; /* Keep button rows perfectly aligned */
}

/* ─── Link pills ──────────────────────────────────────────────── */
.card-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 4px;
}

.card-link {
  display: inline-flex;
  align-items: center;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 12px 24px;
  border-radius: 100px;
  text-decoration: none;
  transition: all 0.18s ease;
  line-height: 1;
}

.card-link--view {
  background: #233c2e;
  color: #f1f7ec;
  box-shadow: 0 2px 8px rgba(18, 45, 32, 0.22);
  border: 1px solid transparent;
}

.card-link--view:hover {
  background: #182c21;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(18, 45, 32, 0.32);
  transform: translateY(-1px);
}

.card-link--download {
  background: rgba(255, 255, 255, 0.65);
  color: #1c3527;
  border: 1px solid rgba(28, 53, 39, 0.22);
  box-shadow: 0 1px 4px rgba(10, 38, 28, 0.06);
}

.card-link--download:hover {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(28, 53, 39, 0.35);
  color: #112219;
  transform: translateY(-1px);
}

.card-link:focus-visible {
  outline: 2px solid #3e6252;
  outline-offset: 2px;
}

/* ─── Carousel arrow buttons ──────────────────────────────────── */
.carousel-arrow {
  position: absolute;
  top: 50%;
  translate: 0 -50%;
  z-index: 10;
  width: 40px;
  height: 40px;
  border-radius: 100%;
  border: 1px solid rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.22);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: #ffffff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 4px 16px rgba(10, 38, 28, 0.22);
  padding: 0;
}

.carousel-arrow:hover:not([disabled]) {
  background: rgba(255,255,255,0.36);
}

.carousel-arrow:focus-visible {
  outline: 2px solid rgba(255,255,255,0.85);
  outline-offset: 2px;
}

.carousel-arrow[disabled] {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

.carousel-arrow svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: rotate(-4deg);
}

.carousel-arrow:hover:not([disabled]) svg {
  transform: rotate(4deg) scale(1.08);
}

.carousel-arrow:active:not([disabled]) svg {
  transition-duration: 0.1s;
  transform: rotate(-4deg) scale(0.88);
}

.carousel-arrow.pop svg {
  animation: 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) pop;
}

.carousel-arrow--prev { left: 2px; }
.carousel-arrow--next { right: 2px; }

/* ─── Dot indicators ──────────────────────────────────────────── */
.carousel-dots {
  position: absolute;
  top: 100%;
  left: 0;
  display: flex;
  justify-content: center;
  gap: 0;
  margin-top: 0;
  pointer-events: auto;
  width: 100%;
}

.carousel-dot {
  width: 36px;
  height: 44px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.carousel-dot::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #ffffff66;
  transition: width .25s ease, background .25s ease;
}
.carousel-dot[aria-current="true"]::before {
  width: 16px;
  background: #f1f4e7;
}
.carousel-dot:focus-visible {
  outline: 1px solid #f1f4e7;
  outline-offset: -4px;
  border-radius: 50%;
}

/* ─── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .work-carousel { scroll-behavior: auto; }
  .card-link,
  .carousel-arrow,
  .carousel-arrow svg,
  .carousel-arrow.pop svg,
  .carousel-dot,
  .project-card { transition: none; animation: none; }
}

/* ─── Tablet: show 2 cards ────────────────────────────────────── */
@media (max-width: 1040px) {
  .carousel-shell {
    max-width: 860px;
    padding: 0 44px;
  }
  .project-card {
    flex: 0 0 calc((100% - 20px) / 2);
  }
  .work-carousel {
    gap: 20px;
  }
}

/* One centered project and reachable controls on phones, including landscape.
   The scroll area starts BELOW navigation; content cannot slide across it. */
@media (max-width: 620px), (max-width: 960px) and (max-height: 500px) {
  .work-overlay {
    top: calc(80px + env(safe-area-inset-top));
    padding: 12px max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
    justify-content: flex-start;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    pointer-events: auto;
  }
  .work-overlay::-webkit-scrollbar { display: none; }
  .work-header {
    margin-top: auto;
    margin-bottom: 18px;
  }
  .work-heading { font-size: 28px; font-weight: 400; margin-bottom: 8px; }
  .work-subheading { text-transform: none; letter-spacing: .025em; font-size: 12px; }
  .carousel-shell {
    padding: 0;
    max-width: 380px;
    flex-direction: column;
    margin-bottom: auto;
  }
  .work-carousel {
    gap: 14px;
    padding: 6px 0 12px;
    overscroll-behavior-x: contain;
  }
  .project-card {
    flex: 0 0 100%;
    min-width: 0;
    border-radius: 22px;
    box-shadow: inset 0 1px 0 #ffffff99;
  }
  .card-image-wrap {
    border-radius: 22px 22px 0 0;
    aspect-ratio: 900 / 474;
  }
  .card-body { padding: 18px 20px 20px; gap: 8px; }
  .card-title { font-size: 23px; }
  .card-desc { font-size: 14px; line-height: 1.55; min-height: 0; margin-bottom: 4px; }
  .card-meta { gap: 8px; margin: 0 0 2px; }
  .card-tag { padding: 0; background: none; border: 0; font-size: 9px; letter-spacing: .09em; }
  .card-tag + .card-tag::before { content: '·'; margin-right: 8px; }
  .card-link { min-height: 44px; padding: 0 18px; font-size: 13px; }
  .carousel-navigation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    margin-top: 4px;
    flex-shrink: 0;
  }
  .carousel-dots { position: static; width: auto; margin: 0; }
  .carousel-dot { width: 44px; }
  .carousel-arrow {
    position: static;
    translate: none;
    width: 44px;
    height: 44px;
    background: #ffffff12;
    box-shadow: none;
  }
}

@media (max-width: 960px) and (max-height: 500px) {
  .work-overlay { top: calc(62px + env(safe-area-inset-top)); }
  .carousel-shell { max-width: 620px; }
  .project-card { flex-direction: row; }
  .card-image-wrap { width: 42%; aspect-ratio: auto; border-radius: 0; }
  .card-image { object-fit: contain; }
  .card-body { min-width: 0; padding: 16px; }
  .work-header { margin-bottom: 12px; }
  .work-heading { font-size: 25px; }
}

@media (prefers-reduced-motion: reduce) {
  .carousel-dot::before { transition: none; }
}

/* Keep unfinished case studies visible without sending visitors to empty links. */
.card-link[aria-disabled="true"] { opacity: .48; pointer-events: none; cursor: default; box-shadow: none; }
