/* Projects — portfolio catalog, distinct from events/blog grids */

.projects-page,
.project-detail-page {
  --projects-accent: var(--theme-blue);
  --projects-accent-soft: color-mix(in srgb, var(--theme-blue) 10%, var(--color-bg));
  --projects-line: color-mix(in srgb, var(--color-border) 65%, transparent);
}

#main-content:has(.projects-page),
#main-content:has(.project-detail-page) {
  background:
    radial-gradient(ellipse 70% 45% at 12% 0%, rgba(var(--rgb-blue), 0.07), transparent 52%),
    radial-gradient(ellipse 55% 40% at 92% 6%, rgba(var(--rgb-green), 0.05), transparent 48%),
    linear-gradient(180deg, var(--projects-accent-soft) 0%, var(--color-bg) 20%, var(--color-bg) 100%);
}

.projects-page,
.project-detail-page {
  background: transparent;
}

/* —— List —— */
.projects-hero {
  padding: 0 0 1.25rem;
}

.projects-hero__label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--projects-accent);
  margin-bottom: 0.65rem;
}

.projects-hero__label::before {
  content: '';
  width: 2rem;
  height: 1px;
  background: var(--projects-accent);
  opacity: 0.55;
}

.projects-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 4vw, 2.65rem);
  font-weight: 500;
  line-height: 1.12;
  margin: 0 0 0.6rem;
  max-width: 20ch;
}

.projects-hero__lead {
  margin: 0;
  max-width: 44ch;
  color: var(--color-text-soft);
  font-size: 1.05rem;
  line-height: 1.55;
}

.projects-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: flex-end;
  margin: 2rem 0 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--projects-line);
}

.projects-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.projects-filter__link {
  display: inline-block;
  padding: 0.38rem 0.9rem;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--color-text-soft);
  text-decoration: none;
  border: 1px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.projects-filter__link:hover {
  color: var(--color-text);
  border-color: var(--projects-line);
}

.projects-filter__link.is-active {
  color: var(--color-surface);
  background: var(--projects-accent);
  border-color: var(--projects-accent);
}

.projects-filter--years .projects-filter__link {
  font-variant-numeric: tabular-nums;
}

/* Featured case */
.projects-spotlight {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: clamp(1.25rem, 3vw, 2.25rem);
  margin-bottom: clamp(2rem, 4vw, 3rem);
  padding-bottom: clamp(2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--projects-line);
}

.projects-spotlight__media {
  display: block;
  position: relative;
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  aspect-ratio: 16 / 10;
  max-height: min(42vh, 340px);
  background: var(--color-bg-alt);
  box-shadow: var(--color-shadow);
}

.projects-spotlight__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

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

.projects-spotlight__body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.65rem;
}

.projects-spotlight__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.85rem;
  align-items: center;
  font-size: 0.88rem;
  color: var(--color-muted);
}

.projects-spotlight h2 {
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  font-weight: 500;
  margin: 0;
  line-height: 1.2;
}

.projects-spotlight h2 a {
  color: inherit;
  text-decoration: none;
}

.projects-spotlight h2 a:hover {
  color: var(--projects-accent);
}

.projects-spotlight__summary {
  margin: 0;
  color: var(--color-text-soft);
  line-height: 1.55;
}

/* Catalog grid */
.projects-catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: clamp(1.1rem, 2.5vw, 1.65rem);
}

.project-card {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--projects-line);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.project-card:hover {
  border-color: color-mix(in srgb, var(--projects-accent) 35%, var(--projects-line));
  box-shadow: var(--color-shadow);
  transform: translateY(-2px);
}

.project-card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  max-height: 220px;
  overflow: hidden;
  background: var(--color-bg-alt);
}

.project-card__media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.project-card:hover .project-card__media img {
  transform: scale(1.03);
}

.project-card__year {
  position: absolute;
  top: 0.65rem;
  inset-inline-start: 0.65rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: rgba(var(--rgb-text), 0.72);
  color: #fff;
  border-radius: 4px;
}

.project-card__body {
  padding: 1rem 1.1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  flex: 1;
}

.project-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.project-difficulty {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.18rem 0.5rem;
  border-radius: 4px;
  background: color-mix(in srgb, var(--projects-accent) 12%, transparent);
  color: var(--projects-accent);
}

.project-difficulty--complex {
  background: color-mix(in srgb, var(--theme-teal) 14%, transparent);
  color: var(--theme-teal);
}

.project-difficulty--high_risk {
  background: color-mix(in srgb, #b45309 12%, transparent);
  color: #9a3412;
}

.project-difficulty--critical {
  background: color-mix(in srgb, #b91c1c 12%, transparent);
  color: #991b1b;
}

.project-scope {
  font-size: 0.82rem;
  color: var(--color-muted);
}

.project-card__title {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 500;
  margin: 0;
  line-height: 1.25;
}

.project-card__summary {
  margin: 0;
  font-size: 0.9rem;
  color: var(--color-text-soft);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-card__foot {
  margin-top: auto;
  padding-top: 0.5rem;
  font-size: 0.82rem;
  color: var(--projects-accent);
  font-weight: 500;
}

/* —— Detail —— */
.project-detail-page {
  padding-bottom: 3rem;
}

.project-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 1.25rem 0 0.5rem;
  font-size: 0.9rem;
  color: var(--color-muted);
  text-decoration: none;
}

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

.project-hero {
  position: relative;
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  margin: 1rem 0 2rem;
  aspect-ratio: 21 / 9;
  max-height: min(46vh, 380px);
  width: 100%;
  background: var(--color-bg-alt);
  box-shadow: var(--color-shadow-lg);
}

.project-hero__image {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  display: block;
}

.project-hero .media-player,
.project-hero .project-hero__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
}

.project-hero .media-player {
  display: block;
}

.project-hero .media-player__trigger {
  height: 100%;
  border-radius: 0;
}

.project-hero .media-player__frame {
  height: 100%;
  min-height: 100%;
  border-radius: 0;
  aspect-ratio: unset;
}

.project-hero .media-player__poster {
  object-fit: cover;
  min-height: clamp(220px, 40vw, 420px);
}

.project-hero__overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  pointer-events: none;
  padding: clamp(1.25rem, 4vw, 2.5rem);
  background: linear-gradient(
    0deg,
    rgba(var(--rgb-text), 0.94) 0%,
    rgba(var(--rgb-text), 0.72) 32%,
    rgba(var(--rgb-text), 0.38) 55%,
    transparent 78%
  );
  color: #fff;
}

.project-hero__overlay h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.5vw, 2.35rem);
  font-weight: 500;
  margin: 0 0 0.35rem;
  line-height: 1.15;
  color: #fff;
  text-shadow: 0 1px 14px rgba(0, 0, 0, 0.35);
}

.project-hero__overlay .lead {
  margin: 0;
  max-width: 52ch;
  font-size: 1.02rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.3);
}

/* Tags on hero — light pills readable over imagery */
.project-hero__overlay .project-card__tags {
  margin-bottom: 0.55rem;
}

.project-hero__overlay .project-difficulty,
.project-hero__overlay .project-scope {
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.project-hero__overlay .project-scope {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
}

.project-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
  gap: clamp(1.5rem, 4vw, 2.75rem);
  align-items: start;
}

.project-section {
  margin-bottom: 2.25rem;
}

.project-section h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  margin: 0 0 0.85rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--projects-line);
}

.project-prose {
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--color-text-soft);
}

.project-prose p {
  margin: 0 0 1rem;
}

.project-prose p:last-child {
  margin-bottom: 0;
}

/* Media hub — photos & videos */
.project-media {
  margin-bottom: 2.5rem;
  padding: 1.35rem 1.25rem;
  border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--projects-line);
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
}

.project-media > h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 500;
  margin: 0 0 1.15rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--projects-line);
}

.project-video-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.project-video-grid:last-child {
  margin-bottom: 0;
}

.project-video-item {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 1rem 1.25rem;
  align-items: start;
}

.project-video-item__player .media-player__frame {
  border-radius: var(--radius-md, 8px);
}

.project-video-item__text h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
}

.project-video-item__text p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--color-text-soft);
}

.project-gallery--detail {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
  gap: 0.75rem;
}

.project-gallery__link {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: var(--color-bg-alt);
  cursor: pointer;
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
  text-align: inherit;
  font: inherit;
  color: inherit;
}

.project-gallery__link:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.project-gallery__link img {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 180px;
  object-fit: cover;
  transition: transform 0.25s ease;
}

.project-gallery__link:hover img {
  transform: scale(1.03);
}

/* Sidebar links */
.project-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.project-links__url {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 0.5rem;
  text-decoration: none;
  color: var(--projects-accent);
  font-weight: 600;
  font-size: 0.92rem;
}

.project-links__url:hover {
  text-decoration: underline;
}

.project-links__type {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.project-links__desc {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--color-text-soft);
}

.project-challenges {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.project-challenges li {
  position: relative;
  padding-inline-start: 1.35rem;
  color: var(--color-text-soft);
  line-height: 1.5;
}

.project-challenges li::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--projects-accent);
}

.project-outcomes {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.project-outcomes li {
  padding: 0.75rem 1rem;
  background: var(--projects-accent-soft);
  border-radius: var(--radius-md, 8px);
  border-inline-start: 3px solid var(--projects-accent);
  font-size: 0.95rem;
  line-height: 1.45;
}

.project-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr));
  gap: 0.85rem;
}

.project-gallery__item {
  margin: 0;
  border-radius: var(--radius-md, 8px);
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--projects-line);
}

.project-gallery__item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 200px;
  object-fit: cover;
  display: block;
}

.project-gallery__item figcaption {
  padding: 0.5rem 0.65rem;
  font-size: 0.82rem;
  color: var(--color-muted);
}

.project-sidebar__box {
  position: sticky;
  top: 5.5rem;
  padding: 1.25rem;
  background: var(--color-surface);
  border: 1px solid var(--projects-line);
  border-radius: var(--radius-lg, 12px);
}

.project-sidebar__box h2 {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin: 0 0 1rem;
}

.project-meta-grid {
  display: grid;
  gap: 0.85rem;
  margin: 0;
}

.project-meta-grid dt {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  margin: 0;
}

.project-meta-grid dd {
  margin: 0.15rem 0 0;
  font-weight: 500;
}

.project-related {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--projects-line);
}

.project-related h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 1.25rem;
}

.project-related .projects-catalog {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
}

@media (max-width: 900px) {
  .projects-spotlight {
    grid-template-columns: 1fr;
  }

  .projects-spotlight__media {
    max-height: min(38vh, 280px);
  }

  .project-hero {
    aspect-ratio: 16 / 9;
    max-height: min(40vh, 280px);
  }

  .project-layout {
    grid-template-columns: 1fr;
  }

  .project-sidebar__box {
    position: static;
  }

  .project-video-item {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .projects-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .projects-spotlight__media {
    max-height: 220px;
  }

  .project-card__media {
    max-height: 180px;
  }

  .project-hero {
    max-height: 220px;
  }

  .project-gallery__item img {
    max-height: 160px;
  }
}
