/* Home — 04 Projects / portfolio showcase -------------------------------------
   Canvas background. Bento grid (>= 768px) whose tile spans come from inline
   custom props (--lc/--lr = 12-col grid, --mc/--mr = 6-col grid) set by PHP and
   recalculated by 04-projects.js after filtering. Mobile = scroll-snap rail.
   Each tile carries a "paint chip" caption coloured by its service (--svc).
   --------------------------------------------------------------------------- */

.mx-projects { background: var(--mx-canvas); }

/* Head ----------------------------------------------------------------------- */
.mx-projects__head { margin-bottom: clamp(28px, 3.6vw, 48px); }
.mx-projects__aside { display: grid; justify-items: start; gap: 20px; max-width: 360px; }
.mx-projects__lead { font-size: var(--mx-text-lead, clamp(1.0625rem, 1rem + .2vw, 1.125rem)); line-height: 1.65; color: var(--mx-muted); }
.mx-projects__insta { min-height: 44px; margin-top: -8px; }
.mx-projects__insta i { font-size: 1.1em; }

/* Filter bar ----------------------------------------------------------------- */
.mx-projects__bar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px 24px;
  padding-bottom: 20px; margin-bottom: clamp(20px, 2.4vw, 28px);
  border-bottom: 1px solid var(--mx-line);
}
.mx-projects__filters { display: flex; flex-wrap: wrap; gap: 8px; }
.mx-projects__filter {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 18px 0 15px; margin: 0;
  border: 1px solid var(--mx-line-strong); border-radius: var(--mx-radius-pill);
  background: var(--mx-paper); color: var(--mx-ink-2);
  font: 600 14px/1 var(--mx-font); white-space: nowrap; cursor: pointer;
  transition: background-color .2s var(--mx-ease), border-color .2s var(--mx-ease), color .2s var(--mx-ease), transform .2s var(--mx-ease);
}
.mx-projects__filter:hover { border-color: var(--svc, var(--mx-ink)); background: var(--svc-soft, var(--mx-sand)); }
.mx-projects__filter:active { transform: scale(.97); }
.mx-projects__filter .mx-svc-dot { width: 11px; height: 11px; transition: background-color .2s var(--mx-ease); }
.mx-projects__filter.is-active {
  background: var(--svc, var(--mx-ink)); border-color: var(--svc, var(--mx-ink));
  color: var(--svc-ink, var(--mx-paper));
}
.mx-projects__filter.is-active .mx-svc-dot { background: currentColor; }
.mx-projects__filter--plain .mx-svc-dot { background: var(--mx-subtle); }

/* "All" chip: a mini palette of the colours in play */
.mx-projects__mix { display: inline-flex; gap: 2px; }
.mx-projects__mix span { width: 5px; height: 14px; border-radius: 2px; background: var(--svc, var(--mx-subtle)); }

.mx-projects__hint { display: flex; align-items: center; font: 600 13px/1.3 var(--mx-font); color: var(--mx-muted); }
.mx-projects__hint i { margin-right: 8px; color: var(--mx-brand); }

/* Filters need JS (mx.js) — hide them on the no-JS fallback */
html:not(.mx-js) .mx-projects__filters,
html:not(.mx-js) .mx-projects__railfoot { display: none; }

/* Grid + tiles --------------------------------------------------------------- */
.mx-projects__grid { list-style: none; margin: 0; padding: 0; }
.mx-projects__item { position: relative; min-width: 0; }
.mx-projects__item[hidden] { display: none !important; }

.mx-projects__tile {
  position: relative; isolation: isolate; overflow: hidden;
  display: block; height: 100%;
  border-radius: var(--mx-radius); background: var(--mx-sand);
  color: var(--mx-ink); text-decoration: none;
  container: mxp / inline-size;
  -webkit-tap-highlight-color: transparent;
}
.mx-projects .mx-projects__tile:focus-visible { border-radius: var(--mx-radius); outline-offset: 4px; }
.mx-projects__media { position: absolute; inset: 0; display: block; }
.mx-projects__img {
  width: 100%; height: 100%; object-fit: cover;
  object-position: 50% 30%; /* people and subjects sit in the upper third — keep them in wide, short crops */
  transition: transform 1.1s var(--mx-ease-out);
}
.mx-projects__tile::after { /* soft floor shade so the chip sits on the photo */
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(to top, color-mix(in srgb, var(--mx-night) 34%, transparent), transparent 42%);
}

/* Paint-chip caption: coloured service band on top, name below */
.mx-projects__chip {
  position: absolute; z-index: 2; left: 12px; bottom: 12px; max-width: calc(100% - 24px);
  display: grid; gap: 6px; overflow: hidden;
  padding: 17px 16px 13px;
  border-radius: var(--mx-radius-sm);
  background: var(--mx-paper); box-shadow: var(--mx-shadow-sm);
  transition: transform .25s var(--mx-ease);
}
.mx-projects__chip::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 9px;
  background: var(--svc, var(--mx-line-strong));
  transform: scaleY(.62); transform-origin: top;
  transition: transform .25s var(--mx-ease);
}
.mx-projects__cat {
  display: inline-flex; align-items: center; gap: 7px; min-width: 0;
  font: 700 11.5px/1.2 var(--mx-font); letter-spacing: .12em; text-transform: uppercase;
  color: var(--mx-muted);
}
.mx-projects__cat .mx-svc-dot { width: 8px; height: 8px; border-radius: 2px; }
.mx-projects__name {
  font: 600 1.08rem/1.15 var(--mx-font-display); letter-spacing: -0.025em; color: var(--mx-ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.mx-projects__zoom {
  position: absolute; z-index: 2; top: 12px; right: 12px;
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: color-mix(in srgb, var(--mx-paper) 92%, transparent); color: var(--mx-ink);
  font-size: 15px; box-shadow: var(--mx-shadow-sm);
  transition: opacity .25s var(--mx-ease), transform .25s var(--mx-ease), background-color .2s var(--mx-ease);
}

@container mxp (min-width: 380px) {
  .mx-projects__chip { left: 18px; bottom: 18px; max-width: calc(100% - 36px); padding: 20px 20px 16px; }
  .mx-projects__name { font-size: 1.3rem; }
  .mx-projects__zoom { top: 16px; right: 16px; }
}
@container mxp (min-width: 480px) {
  .mx-projects__chip { left: 22px; bottom: 22px; padding: 22px 24px 18px; gap: 8px; }
  .mx-projects__cat { font-size: 12px; letter-spacing: .14em; }
  .mx-projects__name { font-size: 1.6rem; }
}
/* Small bento tiles: a tighter chip so it covers less of the photo */
@media (min-width: 768px) {
  @container mxp (max-width: 300px) {
    .mx-projects__chip { left: 10px; bottom: 10px; max-width: calc(100% - 20px); padding: 14px 12px 10px; }
    .mx-projects__name { font-size: 1rem; }
  }
}

@media (hover: hover) {
  .mx-projects__zoom { opacity: 0; transform: scale(.85); }
  .mx-projects__tile:hover .mx-projects__zoom,
  .mx-projects__tile:focus-visible .mx-projects__zoom { opacity: 1; transform: none; }
  .mx-projects__tile:hover .mx-projects__zoom { background: var(--mx-accent); }
  .mx-projects__tile:hover .mx-projects__img { transform: scale(1.05); }
  .mx-projects__tile:hover .mx-projects__chip,
  .mx-projects__tile:focus-visible .mx-projects__chip { transform: translateY(-4px); }
  .mx-projects__tile:hover .mx-projects__chip::before,
  .mx-projects__tile:focus-visible .mx-projects__chip::before { transform: scaleY(1); }
}

/* Re-entry after filtering (04-projects.js toggles .is-swap) */
@keyframes mx-projects-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.mx-projects__item.is-swap, .mx-projects__more.is-swap { animation: mx-projects-in .55s var(--mx-ease-out) both; animation-delay: calc(var(--k, 0) * 60ms); }

/* "View all" end card — only in the mobile rail */
.mx-projects__more { display: none; }
.mx-projects__more-link {
  display: flex; flex-direction: column; justify-content: space-between; gap: 20px; height: 100%;
  padding: 26px 24px 24px; border-radius: var(--mx-radius);
  background: var(--mx-night); color: var(--mx-on-night); text-decoration: none;
}
.mx-projects__more .mx-swatches span { background: var(--svc, var(--mx-subtle)); box-shadow: none; }
.mx-projects__more-title { font: 650 1.7rem/1.08 var(--mx-font-display); letter-spacing: -0.035em; color: var(--mx-paper); }
.mx-projects__more-title em { font-family: var(--mx-font-accent); font-style: italic; font-weight: 400; letter-spacing: -0.01em; color: var(--mx-accent); }
.mx-projects__more-cta {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 10px;
  min-height: 46px; padding: 0 20px; border-radius: var(--mx-radius-pill);
  background: var(--mx-accent); color: var(--mx-ink); font: 700 14.5px/1 var(--mx-font);
}

/* Mobile rail footer: progress + swipe cue */
.mx-projects__railfoot { display: none; }

/* Lightbox (GLightbox) -------------------------------------------------------
   The tiles above are the only lightbox on the home page, so its skin lives here:
   a night caption board in the page's type, 48px controls, marigold focus ring. */
.goverlay { background: color-mix(in srgb, var(--mx-night) 95%, transparent); }
.glightbox-container:focus { outline: none; } /* the dialog itself takes focus on pointer opens */
.glightbox-clean .gslide-description { background: var(--mx-night); }
.glightbox-clean .gdesc-inner { padding: 16px 22px 18px; }
.glightbox-clean .gslide-title {
  margin: 0 0 6px; color: var(--mx-paper);
  font: 600 1.35rem/1.2 var(--mx-font-display); letter-spacing: -0.02em;
}
.glightbox-clean .gslide-desc {
  margin: 0; color: var(--mx-on-night-muted);
  font: 700 12px/1.3 var(--mx-font); letter-spacing: .14em; text-transform: uppercase;
}
.glightbox-clean .gclose, .glightbox-clean .gnext, .glightbox-clean .gprev {
  width: 48px; height: 48px; border-radius: 50%;
  background-color: color-mix(in srgb, var(--mx-paper) 14%, transparent);
}
.glightbox-clean .gclose:hover, .glightbox-clean .gnext:hover, .glightbox-clean .gprev:hover { background-color: color-mix(in srgb, var(--mx-paper) 26%, transparent); }
.glightbox-container .gbtn.focused,
.glightbox-container .gbtn:focus-visible { outline: 3px solid var(--mx-accent); outline-offset: 3px; }

/* Tablet: 6-column bento ----------------------------------------------------- */
@media (min-width: 768px) {
  .mx-projects__grid {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-auto-rows: clamp(200px, 27vw, 260px); grid-auto-flow: row dense;
    gap: 16px;
  }
  .mx-projects__item { grid-column: span var(--mc, 3); grid-row: span var(--mr, 1); }
}

/* Desktop: 12-column bento --------------------------------------------------- */
@media (min-width: 1024px) {
  .mx-projects__grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-rows: clamp(188px, 19vw, 292px);
    gap: clamp(16px, 1.7vw, 24px);
  }
  .mx-projects__item { grid-column: span var(--lc, 4); grid-row: span var(--lr, 1); }
  .mx-projects__more.is-filler { display: block; grid-column: span var(--lc, 5); grid-row: span var(--lr, 2); }
  .mx-projects__more.is-filler .mx-projects__more-link { padding: clamp(28px, 3vw, 44px); }
  .mx-projects__more.is-filler .mx-projects__more-title { font-size: clamp(1.9rem, 1.2rem + 1.4vw, 2.6rem); max-width: 12ch; }
}

/* Mobile: horizontal scroll-snap rail ---------------------------------------- */
@media (max-width: 767px) {
  .mx-projects__aside { max-width: none; }

  /* Chips: one swipeable line instead of three wrapped rows */
  .mx-projects__bar { display: block; padding-bottom: 14px; }
  .mx-projects__filters {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain;
    margin-inline: calc(var(--mx-gutter) * -1); padding: 6px var(--mx-gutter) 8px;
    scroll-padding-inline: var(--mx-gutter); scrollbar-width: none;
  }
  .mx-projects__filters::-webkit-scrollbar { display: none; }
  .mx-projects__filter { flex: none; }
  .mx-projects__hint { display: none; }

  .mx-projects__grid {
    display: flex; gap: 12px;
    overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory; scroll-padding-inline: var(--mx-gutter);
    margin-inline: calc(var(--mx-gutter) * -1);
    padding: 8px var(--mx-gutter) 10px;
    scrollbar-width: none;
  }
  .mx-projects__grid::-webkit-scrollbar { display: none; }
  .mx-projects__item, .mx-projects__more { flex: 0 0 82%; aspect-ratio: 4 / 5; scroll-snap-align: start; }
  .mx-projects__more { display: block; }
  /* In the rail, cards arrive by swiping — don't fade them in on vertical scroll */
  .mx-js .mx-projects__item[data-reveal] { opacity: 1; transform: none; }

  .mx-projects__railfoot { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
  .mx-projects__progress {
    position: relative; flex: 1 1 auto; height: 3px; border-radius: 3px;
    background: var(--mx-line); overflow: hidden;
  }
  .mx-projects__swipe { flex: none; display: inline-flex; align-items: center; gap: 7px; font: 600 12.5px/1 var(--mx-font); color: var(--mx-muted); }
  .mx-projects__swipe i { color: var(--mx-brand); }
  .mx-projects__progress span {
    position: absolute; left: 0; top: 0; bottom: 0; width: 30%; border-radius: 3px;
    background: var(--mx-ink); transition: width .25s var(--mx-ease);
  }
}
/* Small tablets and large phones in landscape: two cards across instead of one huge one */
@media (min-width: 560px) and (max-width: 767px) {
  .mx-projects__item, .mx-projects__more { flex-basis: clamp(250px, 44vw, 330px); }
}

@media (prefers-reduced-motion: reduce) {
  .mx-projects__item.is-swap, .mx-projects__more.is-swap { animation: none; }
  .mx-projects__img { transition: none; }
  .mx-projects__tile:hover .mx-projects__img { transform: none; }
}

/* QA polish: zoom badge follows the service colour; one "View all projects" on phones */
.mx-projects__tile:hover .mx-projects__zoom, .mx-projects__tile:focus-visible .mx-projects__zoom { background: var(--svc, var(--mx-accent)); color: var(--svc-ink, var(--mx-ink)); }
@media (max-width: 767px) { .mx-projects__all { display: none; } }

/* ===== Mobile layer (<=1023): m3-story (projects part) ===== */
/* P8: project photos wait on a soft swatch of their service (after the base .mx-projects__tile rule above). */
@media (max-width: 1023px) {
  .mx-projects__tile { background: var(--svc-soft, var(--mx-sand)); }
}
/* ===== /Mobile layer: m3-story (projects part) ===== */

/* ===== Mobile layer (<=1023): m4-work (projects part) ===== */
/* Folded from _mobile-wip/m4-work.css: projects rail P5, M5, M6 (+ M4 tile press). The process half is at the end
   of 05-process.css; the JS halves are at the ends of js/home/04-projects.js and 05-process.js. */
/* Projects: shorter head, swatch-tinted progress, prev/next */
@media (max-width: 767px) {
  .mx-projects__head { margin-bottom: 22px; }
  .mx-projects__aside { gap: 12px; }
  .mx-projects__bar { border-bottom: 0; padding-bottom: 2px; margin-bottom: 0; }
  .mx-projects__railfoot { gap: 12px; margin-top: 4px; }
  .mx-projects__railfoot:has(.mxm-pj-nav) .mx-projects__swipe { display: none; }
  .mx-projects__progress { height: 4px; }
  /* The thumb's length is set once per resize or filter and it moves by transform (04-projects.js), so
     only the tint eases. Class hooks only: a [class*=] + type selector restyled every span on the page. */
  .mx-projects__progress .mx-projects__thumb { transition: background-color .25s var(--mx-ease); }
  .mx-projects__progress.mxm-tint .mx-projects__thumb { background-color: var(--svc); }
  .mx-projects__progress.mxm-all .mx-projects__thumb { background-image: var(--mx-svc-strip); }

  .mxm-pj-nav { display: flex; gap: 8px; flex: none; }
  .mxm-pj-btn {
    display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
    border: 1px solid var(--mx-line-strong); border-radius: 50%;
    background: var(--mx-paper); color: var(--mx-ink); cursor: pointer;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation;
    transition: scale var(--mxm-dur-release, .22s) var(--mx-ease-out), opacity .2s, background-color .2s, border-color .2s;
  }
  .mxm-pj-btn::before { content: ""; width: 9px; height: 9px; border: solid currentColor; border-width: 2px 2px 0 0; border-radius: 1px; transform: translateX(-2px) rotate(45deg); }
  .mxm-pj-btn[data-go="-1"]::before { transform: translateX(2px) rotate(-135deg); }
  .mxm-pj-btn[aria-disabled="true"] { opacity: .4; cursor: default; }
  .mxm-pj-btn:not([aria-disabled="true"]):active { scale: .94; background: var(--mx-sand); transition-duration: var(--mxm-dur-press, .09s); }
  .mx-projects .mxm-pj-btn:focus-visible { outline: 3px solid var(--mx-brand); outline-offset: 2px; }
}
@media (max-width: 767px) and (hover: hover) and (pointer: fine) {
  .mxm-pj-btn:not([aria-disabled="true"]):hover { border-color: var(--mx-ink); background: var(--mx-sand); }
}
/* One card plus a peek; square crops suit the landscape photos */
@media (max-width: 559px) {
  .mx-projects__item, .mx-projects__more { flex-basis: 84%; aspect-ratio: 1; }
  .mx-projects__more-link { padding: 22px 22px 20px; }
  .mx-projects__more-title { font-size: 1.55rem; }
}
/* M6: filtered tiles arrive from the swipe side. P5: one-time nudge */
@media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
  .mx-projects__item.is-swap, .mx-projects__more.is-swap { animation: mxm-pj-in .4s var(--mx-ease-out) both; animation-delay: calc(min(var(--k, 0), 4) * 35ms); }
  .mxm-nudge > :nth-child(-n+3) { animation: mxm-pj-nudge .65s var(--mx-ease); }
}
@keyframes mxm-pj-in { from { opacity: 0; transform: translateX(16px); } }
@keyframes mxm-pj-nudge { 40% { translate: -20px 0; } }
/* M4: the photo eases in under the thumb (it is about to open larger) */
@media (max-width: 1023px) and (pointer: coarse) and (prefers-reduced-motion: no-preference) {
  .mx-projects__img { transition: transform var(--mxm-dur-release, .22s) var(--mx-ease-out); }
  .mx-projects__tile:active .mx-projects__img { transform: scale(1.03); transition-duration: var(--mxm-dur-press, .09s); transition-delay: 50ms; }
}

/* M5: the card at the snap point is full strength; neighbours recede (photos dim, text never) */
@supports (animation-timeline: view()) {
  @media (max-width: 767px) and (prefers-reduced-motion: no-preference) {
    .mx-projects__item, .mx-projects__more { view-timeline: --mxm-pj x; }
    .mx-projects__tile, .mx-projects__more-link, .mx-projects__media, .mx-projects__chip::before { animation: mxm-pj-focus linear both; animation-timeline: --mxm-pj; }
    .mx-projects__media { animation-name: mxm-pj-dim; }
    .mx-projects__chip::before { animation-name: mxm-pj-band; animation-range: cover 25% cover 75%; }
  }
}
@keyframes mxm-pj-focus { 0%, 100% { scale: .94; } 38%, 62% { scale: 1; } }
@keyframes mxm-pj-dim { 0%, 100% { opacity: .74; } 38%, 62% { opacity: 1; } }
@keyframes mxm-pj-band { 0%, 100% { transform: scaleY(.62); } 35%, 65% { transform: none; } }
/* ===== /Mobile layer: m4-work (projects part) ===== */

/* ===== Mobile perf (<=1023): content-visibility ===== */
/* Skipped while far off screen (see 02-intro.css). Measured heights; the rail, its card shadows and the filter
   all stay inside the section box, and the lightbox lives outside it. Desktop (1024+) is untouched. */
@media (max-width: 1023px) { #projects { content-visibility: auto; contain-intrinsic-size: auto 1500px; } html.mx-cv-all #projects { content-visibility: visible; } }
@media (max-width: 767px) { #projects { contain-intrinsic-size: auto 790px; } }
/* ===== /Mobile perf: content-visibility ===== */
