/* ============================================================
   Projects (portfolio public) - talent dialect (V5)
   Voix neutre 3e personne. Background warm canvas, asymmetric
   featured grid, responsive 3 / 2 / 1.
   Reference: docs/design/landing-mockups/v5-landing-camille.html
   ============================================================ */

.projects-page {
  background: var(--canvas);
  color: var(--text-primary);
  padding-block: clamp(48px, 7vw, 96px) clamp(64px, 9vw, 120px);
}

.projects-page .wrap {
  max-width: var(--container-app);
  margin-inline: auto;
  padding-inline: var(--gutter-app);
}

/* ---------- Page head ---------- */
.projects-page__head {
  margin-bottom: clamp(32px, 5vw, 56px);
  display: grid;
  gap: var(--space-2);
}

.projects-page__hand {
  font-family: var(--font-hand);
  font-size: 1.6rem;
  line-height: 1;
  color: var(--accent-deep, var(--accent));
  transform: rotate(-2deg);
  display: inline-block;
  margin-bottom: var(--space-1);
}

.projects-page__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 4.5vw, 3.4rem);
  line-height: 1.04;
  letter-spacing: -0.028em;
  color: var(--ink-900);
  margin: 0;
}

.projects-page__sub {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 50ch;
  margin: var(--space-2) 0 0;
}

/* ---------- Section heads ---------- */
.projects-page__section-head {
  margin-bottom: var(--space-5);
  display: grid;
  gap: var(--space-1);
}

.projects-page__section-head--inline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.projects-page__section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  line-height: 1.1;
  letter-spacing: -0.022em;
  color: var(--ink-900);
  margin: 0;
}

.projects-page__count {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-500);
}

/* ---------- Filter bar (non sticky) ---------- */
.projects-page__filterbar {
  background: var(--canvas);
  border-block: 1px solid var(--hairline);
  margin-bottom: clamp(24px, 4vw, 48px);
}

.projects-page__filterbar-inner {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-3);
  align-items: center;
  padding-block: var(--space-3);
}

.projects-page__search {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.projects-page__search input {
  width: 100%;
  height: 42px;
  padding: 0 var(--space-4) 0 42px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background: var(--paper);
  color: var(--text-primary);
  transition: border-color var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) var(--ease-out);
}

.projects-page__search input::placeholder { color: var(--ink-500); }

.projects-page__search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.projects-page__search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-500);
  pointer-events: none;
  display: inline-flex;
}

.filter-select {
  height: 44px;
  padding: 0 36px 0 var(--space-4);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background-color: var(--paper);
  color: var(--text-primary);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23525252' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  min-width: 0;
  flex: 0 1 auto;
  transition: border-color var(--t-fast) var(--ease-out),
              box-shadow var(--t-fast) var(--ease-out);
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}

.filter-reset-btn {
  height: 44px;
  padding: 0 var(--space-5);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink-700);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease-out),
              color var(--t-fast) var(--ease-out),
              border-color var(--t-fast) var(--ease-out);
}

.filter-reset-btn:hover {
  background: var(--ink-900);
  color: var(--paper);
  border-color: var(--ink-900);
}

.filter-reset-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-color: var(--accent);
}

/* ---------- Highlighted (asymmetric) ---------- */
.highlighted-section {
  margin-bottom: clamp(48px, 6vw, 80px);
}

.highlighted-section[hidden] { display: none; }

.highlighted-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
}

@media (min-width: 760px) {
  .highlighted-grid {
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(80px, auto);
  }
  .highlighted-grid > .highlight-card:nth-child(6n+1) { grid-column: 1 / span 7; aspect-ratio: 16 / 11; }
  .highlighted-grid > .highlight-card:nth-child(6n+2) { grid-column: 8 / span 5; aspect-ratio: 4 / 5; }
  .highlighted-grid > .highlight-card:nth-child(6n+3) { grid-column: 1 / span 4; aspect-ratio: 4 / 5; }
  .highlighted-grid > .highlight-card:nth-child(6n+4) { grid-column: 5 / span 8; aspect-ratio: 16 / 10; }
  .highlighted-grid > .highlight-card:nth-child(6n+5) { grid-column: 1 / span 6; aspect-ratio: 4 / 3; }
  .highlighted-grid > .highlight-card:nth-child(6n+6) { grid-column: 7 / span 6; aspect-ratio: 4 / 3; }
}

/* When 3 highlight cards or fewer, simpler layout */
@media (min-width: 760px) {
  .highlighted-grid:has(> .highlight-card:nth-child(3):last-child) {
    grid-template-columns: repeat(3, 1fr);
  }
  .highlighted-grid:has(> .highlight-card:nth-child(3):last-child) > .highlight-card:nth-child(n) {
    grid-column: span 1;
    aspect-ratio: 4 / 5;
  }
  .highlighted-grid:has(> .highlight-card:nth-child(2):last-child) {
    grid-template-columns: repeat(2, 1fr);
  }
  .highlighted-grid:has(> .highlight-card:nth-child(2):last-child) > .highlight-card:nth-child(n) {
    grid-column: span 1;
    aspect-ratio: 4 / 3;
  }
  .highlighted-grid:has(> .highlight-card:only-child) > .highlight-card {
    grid-column: 1 / -1;
    aspect-ratio: 16 / 9;
  }
}

/* ---------- Main grid : 3 / 2 / 1 responsive ---------- */
.all-projects-section { min-height: 240px; }

.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(16px, 2.4vw, 28px);
}

@media (max-width: 1024px) { .projects-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .projects-grid { grid-template-columns: 1fr; } }

/* ---------- Project card (talent dialect) ---------- */
.project-card,
.highlight-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition: transform var(--t-base) var(--ease-out),
              box-shadow var(--t-base) var(--ease-out),
              border-color var(--t-base) var(--ease-out);
}

.project-card:hover,
.highlight-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md, var(--shadow-2));
  border-color: var(--ink-300);
}

.project-card:focus-visible,
.highlight-card:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-color: var(--accent);
}

.project-card__media,
.highlight-card .card-img-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--paper-2);
}

.highlight-card .card-img-wrapper { aspect-ratio: auto; height: 100%; min-height: 280px; }

.project-card__media img,
.highlight-card .card-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow) var(--ease-out),
              filter var(--t-slow) var(--ease-out);
  filter: grayscale(0.4);
}

.project-card:hover .project-card__media img,
.highlight-card:hover .card-img-wrapper img {
  transform: scale(1.04);
  filter: grayscale(0);
}

.project-card__flag {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------- Card body ---------- */
.project-card__body,
.highlight-card .card-body {
  padding: var(--space-4) var(--space-5) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.project-card__brand,
.highlight-card .card-brand {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.project-card__title,
.highlight-card .card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  line-height: 1.2;
  letter-spacing: -0.018em;
  color: var(--ink-900);
  margin: 0;
}

.project-card__meta,
.highlight-card .card-meta {
  font-family: var(--font-sans);
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: var(--space-1) 0 0;
  line-height: 1.5;
}

/* ---------- JS-rendered highlight badge (kept for compat with projects.js) ---------- */
.highlight-badge {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  z-index: 2;
}

.highlight-badge svg { width: 12px; height: 12px; fill: currentColor; }

.card-img-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, oklch(0.16 0.014 75 / 0.4) 0%, transparent 50%);
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease-out);
  pointer-events: none;
}

.project-card:hover .card-img-overlay { opacity: 1; }

/* ---------- Empty / no-results ---------- */
.projects-page__no-results {
  text-align: center;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text-secondary);
  padding: var(--space-9) 0;
  margin: 0;
}

/* ---------- Card fade-in (referenced by projects.js) ---------- */
@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive filter bar ---------- */
@media (max-width: 768px) {
  .projects-page__filterbar-inner {
    flex-direction: column;
    flex-wrap: wrap;
    align-items: stretch;
  }
  .projects-page__filterbar-inner .filter-select,
  .projects-page__filterbar-inner .filter-reset-btn,
  .projects-page__filterbar-inner .projects-page__search { width: 100%; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .project-card,
  .highlight-card,
  .project-card__media img,
  .highlight-card .card-img-wrapper img,
  .card-img-overlay,
  .filter-select,
  .filter-reset-btn,
  .projects-page__search input {
    transition: none;
  }
  .project-card:hover,
  .highlight-card:hover { transform: none; }
  .project-card:hover .project-card__media img,
  .highlight-card:hover .card-img-wrapper img { transform: none; filter: grayscale(0.4); }
  @keyframes cardFadeIn {
    from { opacity: 1; transform: none; }
    to   { opacity: 1; transform: none; }
  }
}
