/* ==========================================================================
   IPS — project page (project.html?p=<slug>), compact version.
   Loaded after main.css / extra.css / system.css: overrides the original
   project-page rules there (shorter cover, tighter facts, spec rows,
   justified gallery). The page ends: gallery -> CTA -> similar projects ->
   a slim light project navigation bar (previous | all projects | next).
   Phones (<= 760px): title sized to its widest word, still 4:5 cover, facts
   two per row, one-column gallery, similar projects as a swipe row with dots,
   stacked project navigation, a touch-friendly lightbox.
   Lightbox: the photo grows out of the page (project.js), so the lightbox
   does not fade as a whole; its backdrop and bars do.
   ========================================================================== */

/* ---------- Head: crumbs, tags, title + lead ---------- */
.pj-head { padding-bottom: clamp(18px, 2.2vw, 32px); }
.pj-head .crumbs { margin-bottom: clamp(14px, 1.6vw, 22px); }
.pj-head .phero__tags { margin-bottom: clamp(12px, 1.4vw, 20px); }
a.tag { transition: border-color .4s var(--ease); }
a.tag:hover { border-color: var(--ink); }
.pj-title { grid-column: 1 / span 9; font-size: clamp(34px, 5.2vw, 92px); }
.pj-title.pj-title--m { font-size: clamp(32px, 4.4vw, 78px); }
.pj-title.pj-title--l { font-size: clamp(30px, 3.7vw, 66px); }
html[lang="ka"] .pj-title { line-height: 1.04; }
.pj-lead { grid-column: 10 / span 3; color: var(--text-2); font-size: 15px; line-height: 1.6; padding-bottom: .3em; }

.pj-404 { min-height: calc(var(--vh, 1vh) * 56); }
.pj-404__text { max-width: 520px; margin: 18px 0 28px; }

/* ---------- Cover: at most ~72% of the screen height, inside the 10px frame ---------- */
.pj-cover { margin-top: 0; }
.pj-cover .media { height: min(calc(var(--vh, 1vh) * 72), 820px); min-height: 340px; }
.pj-cover .media[data-lb-open] { cursor: zoom-in; }
.pj-cover .media img { position: absolute; left: 0; top: -6%; width: 100%; height: 112%; }
/* touch screens / reduced motion: no parallax, so no overscan either */
.pj-cover--still .media img { top: 0; height: 100%; will-change: auto; }
.pj-cover .noimg-hero { height: min(calc(var(--vh, 1vh) * 40), 420px); min-height: 260px; }

/* ---------- Facts strip ---------- */
.pj-facts { margin-top: clamp(14px, 1.6vw, 24px); }
.pj-facts .fact { padding-top: 14px; padding-bottom: 16px; }
.pj-facts .fact__label { margin-bottom: 8px; }
.pj-facts .fact__value { font-size: 15px; line-height: 1.45; }
.pj-facts .fact--big .fact__value { font-size: clamp(36px, 3.5vw, 58px); line-height: 1; }

/* ---------- Compact rhythm: every block after the facts sits one --sec-tight below the previous one ---------- */
.pj-sec { padding-top: var(--sec-tight); }
.pj-sechead { margin-bottom: var(--head-gap); }

/* ---------- Spec rows: label left, content right ---------- */
.pj-spec { border-top: 1px solid var(--line); }
/* right after the facts strip the rows continue it as one datasheet (the strip's bottom line is the first rule) */
.pj-facts + .pj-sec { padding-top: 0; }
.pj-facts + .pj-sec .pj-spec { border-top: 0; }
.pj-row {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap); align-items: start;
  padding: clamp(18px, 1.9vw, 28px) 0; border-bottom: 1px solid var(--line);
}
.pj-row__head { grid-column: 1 / span 3; padding-right: 16px; }
.pj-row__title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.pj-count { font-family: var(--f-latin); font-weight: 400; font-size: 11px; letter-spacing: .08em; color: var(--text-3); }
.pj-row__link { margin-top: 10px; font-size: 13.5px; font-weight: 400; color: var(--text-2); transition: color .4s var(--ease); }
.pj-row__link:hover { color: var(--ink); }
.pj-row__body { grid-column: 4 / span 9; min-width: 0; }

/* a readable measure (~70–80 characters a line) instead of the full nine columns */
.pj-about p { font-size: clamp(16px, 1.2vw, 19px); line-height: 1.62; max-width: 42em; color: var(--text-2); }
.pj-about p + p { margin-top: .7em; }
.pj-about .is-key, .pj-about .pj-about__lead { color: var(--ink); }
/* the lead sits beside the title; on phones it moves here (see the 760px block) */
.pj-about__lead, .pj-row--phone { display: none; }
.pj-about .pj-about__lead + p { margin-top: 0; }
/* a lone extra photo (portrait / soft) sits beside the about text */
.pj-about-media { display: grid; grid-template-columns: minmax(0, 1fr) var(--side-w, 300px); gap: clamp(20px, 2.6vw, 44px); align-items: start; }
.pj-side { position: relative; cursor: zoom-in; }
.pj-side .media { aspect-ratio: var(--ar); border-radius: 4px; }
.pj-side img { transition: transform 1.4s var(--ease), opacity .9s var(--ease); }
.pj-about-media .pj-side:hover img { transform: scale(1.04); }

.pj-list { border-top: 0; }
.pj-list li { grid-template-columns: 44px 1fr; padding: 10px 0; font-size: clamp(15px, 1.1vw, 17px); line-height: 1.45; }
.pj-list li:first-child { padding-top: 1px; }
.pj-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.pj-list li span:first-child { padding-top: 3px; }
.pj-list .pj-list__head { display: block; padding: 14px 0 2px; border-bottom: 0; font-size: 12.5px; letter-spacing: .04em; color: var(--text-3); }
.pj-list .pj-list__head:first-child { padding-top: 0; }

.pj-btiles { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.pj-btiles .btile__word { font-size: clamp(13px, 1.02vw, 16px); } /* name fallback sized to these smaller tiles */
/* a definite track, so max-height: 100% resolves and tall logos (Sika) fit the tile instead of overflowing it */
.pj-btiles .btile__logo { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.pj-also { margin-top: 12px; }

/* ---------- Gallery: justified rows ---------- */
.pj-gal { --gg: clamp(6px, .6vw, 10px); display: grid; gap: var(--gg); }
.pj-gal__row { display: flex; align-items: flex-start; gap: var(--gg); }
.pj-gal__item { position: relative; flex: var(--ar) 1 0%; min-width: 0; aspect-ratio: var(--ar); cursor: zoom-in; }
.pj-gal__item .media { height: 100%; border-radius: 4px; }
.pj-gal__item img { transition: transform 1.4s var(--ease), opacity .9s var(--ease); }
.pj-gal .pj-gal__item:hover img { transform: scale(1.04); }
.pj-gal__row--feature .pj-gal__item { aspect-ratio: 21 / 9; }
.pj-gal--solo .pj-gal__item { flex: none; width: min(100%, calc(min(44vw, 560px) * var(--ar))); }

/* ---------- CTA ---------- */
.pj-cta.pcta { padding: clamp(24px, 2.8vw, 40px) 0; }
/* no gallery: the CTA band continues the spec rows (no second rule after an empty gap) */
.pj-sec--spec + .pj-sec--cta { padding-top: 0; }
.pj-sec--spec + .pj-sec--cta .pcta { border-top: 0; }

/* ---------- Project navigation: previous | all projects | next ----------
   A slim bar between two hairlines on the light page (~120px on desktop); a cell fills white on hover. */
.pj-pn { padding-bottom: var(--sec-tight); }
.pj-pn__bar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.pj-pn__link, .pj-pn__all { position: relative; isolation: isolate; outline: none; }
.pj-pn__link::before, .pj-pn__all::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--white); opacity: 0; transition: opacity .6s var(--ease);
}
.pj-pn__link:hover::before, .pj-pn__all:hover::before,
.pj-pn__link:focus-visible::before, .pj-pn__all:focus-visible::before { opacity: 1; }
.pj-pn__link:focus-visible, .pj-pn__all:focus-visible { box-shadow: inset 0 0 0 1px var(--ink); }
.pj-pn__link { display: flex; align-items: center; gap: clamp(14px, 1.4vw, 22px); min-width: 0; padding: 18px clamp(14px, 1.4vw, 22px); }
.pj-pn__link--next { flex-direction: row-reverse; text-align: right; }
.pj-pn__thumb { flex: none; width: clamp(84px, 7.8vw, 112px); aspect-ratio: 4 / 3; border-radius: 4px; }
.pj-pn__thumb img { transition: transform 1.2s var(--ease), opacity .9s var(--ease); }
.pj-pn__link:hover .pj-pn__thumb img { transform: scale(1.07); }
.pj-pn__text { display: grid; gap: 5px; min-width: 0; }
.pj-pn__label { display: flex; align-items: center; gap: 8px; color: var(--text-3); transition: color .4s var(--ease); }
.pj-pn__link--next .pj-pn__label, .pj-pn__link--next .pj-pn__meta { justify-content: flex-end; }
.pj-pn__arr { width: 13px; height: 13px; flex: none; transition: transform .6s var(--ease); }
.pj-pn__link:hover .pj-pn__label { color: var(--ink); }
.pj-pn__link--prev:hover .pj-pn__arr { transform: translateX(-4px); }
.pj-pn__link--next:hover .pj-pn__arr { transform: translateX(4px); }
.pj-pn__name {
  font-weight: 500; font-size: clamp(16px, 1.3vw, 20px); line-height: 1.3; transition: color .4s var(--ease);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.pj-pn__link:hover .pj-pn__name { color: var(--slate); }
.pj-pn__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; color: var(--text-3); }
.pj-pn__meta i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .6; }
.pj-pn__all {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 18px clamp(22px, 3.2vw, 56px); border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  font-size: 13.5px; font-weight: 500; white-space: nowrap;
}
.pj-pn__grid { display: grid; grid-template-columns: repeat(2, 7px); gap: 3px; transition: gap .6s var(--ease), transform .8s var(--ease); }
.pj-pn__grid i { width: 7px; height: 7px; border-radius: 1px; background: currentColor; }
.pj-pn__all:hover .pj-pn__grid { gap: 5px; transform: rotate(90deg); }
/* no similar projects: the bar continues the CTA band (no second rule after an empty gap) */
.pj-sec--cta + .pj-pn { padding-top: 0; }
.pj-sec--cta + .pj-pn .pj-pn__bar { border-top: 0; }

/* ---------- Lightbox ----------
   The backdrop is its own layer (.lb__bg), so pulling a photo down can fade it without fading the photo.
   The stage is a definite cell: the photo is contained in it whatever the bars measure. One finger never
   pans the page here (project.js turns swipes into next / previous / close); pinch-zoom stays available. */
.lb { background: none; touch-action: pinch-zoom; opacity: 1; visibility: hidden; transition: visibility 0s .6s; }
.lb.is-open { visibility: visible; transition: none; }
.lb.is-zoomed { touch-action: auto; }
.lb__bg { position: absolute; inset: 0; z-index: -1; background: rgba(14, 20, 33, .96); }
/* the photo grows out of the page on its own (project.js); the backdrop and the bars fade around it */
.lb__bg, .lb__top, .lb__bot { opacity: 0; transition: opacity .5s var(--ease); }
.lb.is-open .lb__bg, .lb.is-open .lb__top, .lb.is-open .lb__bot { opacity: 1; }
.lb__top { gap: 16px; padding-top: max(18px, env(safe-area-inset-top)); }
.lb__top > span { min-width: 0; }
.lb__bot { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.lb__btn { flex: none; }
.lb__stage { grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
.lb__img { max-height: 100%; }
.lb.is-open .lb__img { will-change: transform; }

/* progress dots under the phone swipe row (shown in the 760px block) */
.rail-dots { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .pj-title { grid-column: 1 / -1; }
  .pj-lead { grid-column: 1 / -1; max-width: 600px; margin-top: 14px; padding-bottom: 0; }
  .pj-row__head, .pj-row__body { grid-column: 1 / -1; }
  .pj-row__head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 16px; padding-right: 0; margin-bottom: 12px; }
  .pj-row__link { margin-top: 0; }
  /* facts: 2 columns with continuous hairlines (each fact draws its own bottom line) */
  .pj-facts .facts { column-gap: 0; border-bottom: 0; }
  .pj-facts .fact { padding-right: 16px; }
  .pj-facts .fact--fill { grid-column: 1 / -1 !important; }
}
@media (max-width: 1024px) and (min-width: 761px) {
  .pj-similar > :nth-child(3) { display: none; }
  /* tablets: the side cells get the room for the names (no meta line, narrower centre) */
  .pj-pn__meta { display: none; }
  .pj-pn__thumb { width: 76px; }
  .pj-pn__all { padding-left: 16px; padding-right: 16px; max-width: 132px; white-space: normal; text-align: center; line-height: 1.3; }
}

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  /* head: crumbs and tags stay on one line each; every link gets a 44px tap height without moving anything */
  .pj-head .crumbs { margin-bottom: 18px; }
  .pj-head .crumbs a { padding: 12px 0; margin: -12px 0; }
  .pj-head .phero__tags { gap: 6px; margin-bottom: 14px; }
  .pj-head .tag { height: 30px; padding: 0 10px; font-size: 12.5px; }
  .pj-head a.tag { position: relative; gap: 7px; padding-left: 5px; }
  .pj-head a.tag::after { content: ""; position: absolute; inset: -7px -3px; }
  .pj-head .tag img { width: 20px; height: 20px; }
  /* "Project 30 / 87" shows as "30 / 87" (the word stays for screen readers), so the row never wraps */
  .pj-tag-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* title: as large as the widest word allows (--tw: that word's width in em, measured by project.js) */
  .pj-title { --fit: calc((100vw - 2 * var(--pad)) / var(--tw, 11)); font-size: min(11.4vw, 46px, var(--fit)); }
  .pj-title.pj-title--m { font-size: min(9.6vw, 40px, var(--fit)); }
  .pj-title.pj-title--l { font-size: min(8.4vw, 34px, var(--fit)); }
  .pj-lead { display: none; }

  /* cover: a still 4:5 frame (the full photo opens in the lightbox) */
  .pj-cover .media { height: auto; min-height: 0; aspect-ratio: 4 / 5; max-height: calc(var(--vh, 1vh) * 64); }
  .pj-cover .noimg-hero { aspect-ratio: auto; height: 300px; }

  /* facts: two per row (the area takes a whole row); the direction link gets a 44px tap height */
  .pj-facts .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pj-facts .fact__value { overflow-wrap: anywhere; }
  .pj-facts .fact__value a { position: relative; }
  .pj-facts .fact__value a::after { content: ""; position: absolute; inset: -11px -8px; }

  /* spec rows */
  .pj-about .pj-about__lead { display: block; }
  .pj-about .pj-about__lead + p { margin-top: .7em; }
  .pj-row--phone { display: grid; }
  .pj-about-media { grid-template-columns: minmax(0, 1fr); }
  .pj-row__link { padding: 12px 0; margin: -12px 0; }
  .pj-btiles { grid-template-columns: repeat(auto-fill, minmax(min(100%, 96px), 1fr)); }
  .pj-btiles .btile { padding: 12% 6%; }
  .pj-btiles .btile__word { font-size: 13px; letter-spacing: 0; }

  /* gallery: one photo per line, each in its own proportions (portraits 4:5 at most, panoramas 16:9) */
  .pj-gal { --gg: 8px; grid-template-columns: minmax(0, 1fr); }
  .pj-gal__row { display: contents; }
  .pj-gal__item, .pj-gal__row--feature .pj-gal__item, .pj-gal--solo .pj-gal__item { flex: none; width: auto; aspect-ratio: var(--arm, 1.5); }

  .pj-cta .pcta__text { grid-column: 1 / -1; }
  .pj-sim .btn--sm { height: 44px; }

  /* similar projects: a swipe row with progress dots (the home page pattern), so the end of the page stays short */
  .cards.pj-similar {
    display: flex; gap: 10px; margin: 0 calc(var(--pad) * -1); padding: 0 0 4px var(--pad);
    overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; scroll-snap-type: x mandatory; scroll-padding-inline: var(--pad);
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .cards.pj-similar::-webkit-scrollbar { display: none; }
  .cards.pj-similar > .pcard { flex: 0 0 min(calc((100% - var(--pad)) * .82), 420px); scroll-snap-align: start; }
  /* end spacer: the last card stops one page margin from the edge in every browser (end padding is not reliable) */
  .cards.pj-similar::after { content: ""; flex: 0 0 calc(var(--pad) - 10px); }
  .rail-dots { display: flex; justify-content: center; gap: 6px; margin-top: 14px; }
  .rail-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--mist-2); transition: background-color .3s, transform .3s var(--ease); }
  .rail-dots i.is-on { background: var(--ink); transform: scale(1.25); }

  /* project navigation stacks: previous, next (thumbnail left in both), then all projects */
  .pj-pn__bar { grid-template-columns: minmax(0, 1fr); }
  .pj-pn__link, .pj-pn__link--next { flex-direction: row; text-align: left; gap: 14px; padding: 14px 0; }
  .pj-pn__link--next .pj-pn__label, .pj-pn__link--next .pj-pn__meta { justify-content: flex-start; }
  .pj-pn__link--next { order: 2; border-top: 1px solid var(--line); }
  .pj-pn__all { order: 3; flex-direction: row; gap: 12px; min-height: 52px; padding: 14px 0; border: 0; border-top: 1px solid var(--line); }
  .pj-pn__thumb { width: 84px; }
  .pj-pn__name { font-size: 16px; }

  /* lightbox: opaque backdrop, edge-to-edge photo, slimmer bars clear of the notch and the home indicator */
  .lb__bg { background: rgb(14, 20, 33); }
  .lb__top { padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: 10px; }
  .lb__bot { padding-top: 10px; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .lb__stage { padding: 0; }
  .lb__img { border-radius: 0; }
}
