.projects-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 0 32px;
}
.filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.view-toggles {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  padding-top: 2px;
}
.view-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #ccc;
  background: transparent;
  color: #999;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
}
.view-btn:hover { color: var(--brass-dark); border-color: var(--brass); }
.view-btn.active { color: #2a2a2a; border-color: #2a2a2a; }
.filter-btn {
  font-family: 'Outfit', sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 7px 16px;
  border: 1px solid #ccc;
  background: transparent;
  color: #666;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
}
.filter-btn:hover {
  border-color: var(--brass);
  color: var(--brass-dark);
}
.filter-btn.active {
  background: #2a2a2a;
  border-color: #2a2a2a;
  color: #fff;
}

.masonry-grid {
  columns: 4;
  column-gap: 14px;
}

.project-card {
  break-inside: avoid;
  display: inline-block;
  width: 100%;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: box-shadow 0.35s ease, transform 0.35s ease;
}
.project-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}
.project-card a {
  display: block;
  text-decoration: none;
  color: inherit;
}

.project-card-image {
  position: relative;
  overflow: hidden;
  background: #e8e6e2;
  min-height: 180px;
}
.project-card-image::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid rgba(0,0,0,0.08);
  border-top-color: var(--brass);
  border-radius: 50%;
  animation: card-spin 0.8s linear infinite;
  z-index: 1;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.project-card-image.is-ready::before {
  opacity: 0;
}
@keyframes card-spin {
  to { transform: rotate(360deg); }
}
.project-card-image > img,
.card-embla .card-embla__slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  position: relative;
  z-index: 2;
}
.project-card-image > img.is-loaded,
.card-embla .card-embla__slide img.is-loaded {
  opacity: 1;
  transform: translateY(0);
}

.card-embla { overflow: hidden; user-select: none; cursor: grab; position: relative; z-index: 3; }
.card-embla:active { cursor: grabbing; }
.card-embla img { pointer-events: none; -webkit-user-drag: none; }
.card-embla__container { display: flex; touch-action: pan-y pinch-zoom; }
.card-embla__slide { flex: 0 0 100%; min-width: 0; aspect-ratio: 4 / 3; overflow: hidden; }

/* Fill left-to-right when few items visible */
.masonry-grid.flex-mode {
  columns: unset;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}
.masonry-grid.flex-mode .project-card {
  display: block;
  width: calc(25% - 11px);
}
.masonry-grid.flex-mode .card-embla__slide { aspect-ratio: 4 / 3 !important; }
@media (max-width: 1200px) {
  .masonry-grid.flex-mode .project-card { width: calc(33.333% - 10px); }
}
@media (max-width: 900px) {
  .masonry-grid.flex-mode .project-card { width: calc(50% - 7px); }
}
@media (max-width: 580px) {
  .masonry-grid.flex-mode .project-card { width: 100%; }
}

/* ── Magazine rhythm — varied aspect ratios for editorial feel ── */
.project-card.featured .card-embla__slide { aspect-ratio: 3 / 4; }
.project-card:nth-child(5n+2) .card-embla__slide { aspect-ratio: 1 / 1; }
.project-card:nth-child(7n+4) .card-embla__slide { aspect-ratio: 3 / 4; }
.project-card:nth-child(11n+7) .card-embla__slide { aspect-ratio: 5 / 4; }
.project-card:nth-child(9n+6) .card-embla__slide { aspect-ratio: 2 / 3; }
.project-card:nth-child(13n+1):not(.featured) .card-embla__slide { aspect-ratio: 3 / 5; }
.project-card:nth-child(17n+10) .card-embla__slide { aspect-ratio: 1 / 1; }

/* Vary aspect ratios within the featured set so the lead row doesn't read as a uniform grid */
.project-card:nth-child(2 of .featured) .card-embla__slide { aspect-ratio: 5 / 4; }
.project-card:nth-child(5 of .featured) .card-embla__slide { aspect-ratio: 4 / 5; }
.project-card:nth-child(7 of .featured) .card-embla__slide { aspect-ratio: 4 / 3; }
.project-card:nth-child(8 of .featured) .card-embla__slide { aspect-ratio: 1 / 1; }

/* ── Carousel chevron arrows ── */
.card-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 6;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.15);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.25s ease, background 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0;
  line-height: 0;
}
.card-arrow::after {
  content: '';
  display: block;
  width: 7px;
  height: 7px;
  border-right: 1.5px solid rgba(255,255,255,0.9);
  border-bottom: 1.5px solid rgba(255,255,255,0.9);
}
.card-arrow-prev { left: 6px; }
.card-arrow-prev::after { transform: rotate(135deg); margin-left: 2px; }
.card-arrow-next { right: 6px; }
.card-arrow-next::after { transform: rotate(-45deg); margin-right: 2px; }
.card-arrow:hover { background: rgba(0,0,0,0.3); }
.project-card:hover .card-arrow { opacity: 1; }

/* ── Dot indicators ── */
.card-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 5px;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.project-card:hover .card-dots { opacity: 1; }
.card-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s;
}
.card-dot.active { background: #fff; }

/* ── Overlay — hidden by default, used in compact mode ── */
.project-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, rgba(0,0,0,0.05) 50%, transparent 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px 18px;
  z-index: 4;
  pointer-events: none;
}
.project-card-overlay .overlay-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.project-card-overlay .overlay-tag {
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  background: var(--accent);
  color: #fff;
  line-height: 1.3;
}
.project-card-overlay .overlay-title {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #fff;
  margin-bottom: 2px;
}
.project-card-overlay .overlay-location {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 12px;
  color: rgba(255,255,255,0.65);
}

/* ── Card body (default mode) ── */
.project-card-body { padding: 14px 16px 16px; }
.project-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}
.project-card-tag {
  display: inline-block;
  font-family: 'Outfit', sans-serif;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  line-height: 1.3;
}
.project-card-tag.tag-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
}
.project-card-tag.tag-secondary {
  background: transparent;
  color: var(--brass);
  border: 1px solid var(--accent-light);
}
.project-card-title {
  font-family: 'Outfit', sans-serif !important;
  font-size: 16px !important;
  font-weight: 300 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.03em !important;
  color: #2a2a2a !important;
  margin: 0 0 3px !important;
  line-height: 1.3 !important;
}
.project-card-location {
  font-size: 13px;
  color: #888;
}

.project-card.featured .project-card-title { font-size: 19px !important; }
.project-card.featured .project-card-body { padding: 16px 18px 18px; }

/* ── Compact mode: image-only grid, info overlaid on hover ── */
.masonry-grid.compact-mode .project-card-body { display: none; }
.masonry-grid.compact-mode .project-card { background: transparent; box-shadow: none; }
.masonry-grid.compact-mode .project-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,0.12); }
.masonry-grid.compact-mode .project-card-overlay { opacity: 0; }
.masonry-grid.compact-mode .project-card:hover .project-card-overlay { opacity: 1; }

/* ── Scroll entrance ── */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(28px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.project-card {
  opacity: 0;
}
.project-card.is-visible {
  animation: cardIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}
.project-card:nth-child(4n+2).is-visible { animation-delay: 0.05s; }
.project-card:nth-child(4n+3).is-visible { animation-delay: 0.1s; }
.project-card:nth-child(4n+4).is-visible { animation-delay: 0.15s; }

@media (max-width: 900px) {
  .masonry-grid { columns: 2; }
  .project-card:nth-child(2n+2) { transition-delay: 0.08s; }
  .project-card:nth-child(2n+1) { transition-delay: 0s; }
}
@media (max-width: 580px) {
  .masonry-grid { columns: 1; }
  .filter-strip { flex-wrap: wrap; }
  .filter-btn { font-size: 10px; padding: 6px 12px; }
  .project-card { transition-delay: 0s !important; }
  .card-arrow { opacity: 0.7; }
}

@media (prefers-reduced-motion: reduce) {
  .project-card { opacity: 1; transform: none; transition: none; animation: none; }
  .project-card.is-visible { animation: none; opacity: 1; }
  .project-card:hover { transform: none; }
  .project-card-overlay { transition: none; }
  .project-card-image::before { animation: none; }
  .project-card-image > img,
  .card-embla .card-embla__slide img { opacity: 1; transform: none; transition: none; }
}

/* ── Featured view: hide non-hero cards on the default ("Featured") tab ── */
.masonry-grid.grid-featured-view .project-card:not([data-built="true"]) { display: none; }

/* ── Filter button count badges ── */
.filter-count {
  display: inline-block;
  margin-left: 7px;
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: #3a2a1c;
  background: rgba(58, 42, 28, 0.12);
  border-radius: 10px;
  vertical-align: 1px;
}
.filter-btn.active .filter-count {
  color: #fff;
  background: rgba(255, 255, 255, 0.22);
}

/* ── Projects index page editorial close ── */
.projects-close {
  max-width: 680px;
  margin: 0 auto;
  padding: 96px 24px 80px;
  text-align: center;
  border-top: 1px solid rgba(176, 141, 87, 0.35);
}
.projects-close__copy {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 18px;
  line-height: 1.65;
  color: #2a2a2a;
  margin: 0 0 44px;
}
.projects-close__actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.projects-close .projects-close__btn {
  display: inline-block;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 14px 32px;
  text-decoration: none;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}
.projects-close .projects-close__btn--primary {
  color: #fff;
  background: var(--brass);
}
.projects-close .projects-close__btn--primary:hover {
  background: var(--brass-dark);
  color: #fff;
}
.projects-close .projects-close__btn--secondary {
  color: var(--brass-dark);
  background: transparent;
  border: 1px solid var(--brass);
}
.projects-close .projects-close__btn--secondary:hover {
  background: var(--brass);
  color: #fff;
}
.projects-close__contact {
  margin: 40px 0 0;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: #888;
}
.projects-close__contact a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid #d4d4d4;
  transition: color 0.2s, border-color 0.2s;
}
.projects-close__contact a:hover {
  color: #2a2a2a;
  border-color: #888;
}
.projects-close__sep {
  margin: 0 14px;
  color: #c8c8c8;
}

@media (max-width: 600px) {
  .projects-close { padding: 64px 20px 56px; }
  .projects-close__copy { font-size: 16px; margin-bottom: 36px; }
  .projects-close__actions { flex-direction: column; align-items: center; }
  .projects-close__btn { width: 100%; max-width: 280px; text-align: center; }
  .projects-close__contact { margin-top: 32px; }
  .projects-close__sep { display: block; margin: 6px 0; }
}
