.grid-wraper {
  position: relative;
  flex: 1 1 auto;
  min-height: 100vh;
  overflow: hidden;
  background: #f7f6f5;
}

.js-gallery-stage {
  position: relative;
  min-height: 100vh;
}

.js-grid-sources {
  display: none;
}

.journal-desktop-int {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.grid {
  position: fixed;
  top: 0;
  left: 0;
  display: grid;
  width: 150vw;
  height: 180vw;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 80px;
  padding: 0;
  cursor: grab;
  user-select: none;
}

.div-cont-grd {
  position: relative;
  min-height: 0;
}

.embed {
  position: absolute;
  inset: 0;
}

.js-plane {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  margin: 0;
  border-radius: 0;
  background-color: #e9e3db;
  background-position: 50% 50%;
  background-repeat: no-repeat;
  background-size: cover;
  transform: scale(1.04);
  transition: transform 400ms ease;
  will-change: transform;
}

.js-gallery-description-box {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: clamp(1.2rem, 2vw, 2.5rem);
  width: 100%;
  padding: clamp(1.6rem, 2.2vw, 2.4rem) clamp(1.25rem, 4vw, 4rem);
  padding-right: clamp(4.5rem, 7vw, 7rem);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  color: #000;
  background: rgba(247, 246, 245, 0.96) !important;
  backdrop-filter: blur(14px);
  transition:
    transform 220ms ease,
    opacity 220ms ease,
    visibility 220ms ease,
    padding 200ms ease,
    gap 200ms ease,
    box-shadow 200ms ease,
    background-color 200ms ease;
}

body.is-gallery-bar-thin .js-gallery-description-box {
  gap: 0.9rem;
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.07);
}

.gallery-bar-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.9rem;
  padding-right: 3.5rem;
}

.gallery-bar-actions > a {
  display: inline-flex;
  align-self: center;
}

.gallery-bar-close {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  flex: 0 0 auto;
}

.gallery-bar-close:hover,
.gallery-bar-close:focus,
.gallery-bar-close:focus-visible {
  background: transparent;
  box-shadow: none;
}

.gallery-bar-close .js-close-bg {
  fill: #d8ccb0;
}

.gallery-bar-close .js-close-lines {
  fill: #111111;
}

.gallery-bar-toggle {
  position: absolute;
  left: 50%;
  bottom: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  background: rgba(247, 246, 245, 0.98);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
  transform: translate(-50%, 50%);
  cursor: pointer;
}

.gallery-bar-toggle__icon {
  width: 0.7rem;
  height: 0.7rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(10%) rotate(-135deg);
  transition: transform 180ms ease;
}

body.is-gallery-bar-thin .gallery-bar-toggle__icon {
  transform: translateY(-15%) rotate(45deg);
}

.is-gallery .js-gallery {
  position: fixed !important;
  inset: 0;
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.is-gallery .grid-wraper {
  min-height: 0;
  touch-action: none;
}

@media (max-width: 991px) {
  .is-gallery .js-gallery {
    overflow-y: auto;
  }

  .is-gallery .grid-wraper {
    touch-action: auto;
  }
}

.js-gallery-title {
  flex: 0 0 auto;
  margin: 0;
  font-size: clamp(2rem, 2.6vw, 2.8rem);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  transition: font-size 200ms ease;
}

body.is-gallery-bar-thin .js-gallery-title {
  font-size: clamp(1.4rem, 1.8vw, 1.8rem);
}

.js-gallery-description {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: clamp(1rem, 1.8vw, 1.75rem);
  font-size: clamp(1rem, 1.1vw, 1.2rem);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

body.is-gallery-bar-thin .js-gallery-description {
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.js-gallery-description-box > a {
  flex: 0 0 auto;
}

.js-gallery-description-box .js-ask {
  display: inline-block;
  padding: 0.8rem 1.8rem;
  font-size: 1.1rem;
  font-weight: 700;
  border-radius: 3px;
  color: #fff;
}

@media (max-width: 991px) {
  .js-gallery-description-box {
    align-items: flex-start;
    flex-wrap: wrap;
    padding-right: clamp(4rem, 11vw, 5rem);
  }

  .js-gallery-title,
  .js-gallery-description {
    flex-basis: 100%;
  }

  .gallery-bar-actions {
    width: 100%;
    justify-content: space-between;
    padding-right: 2.6rem;
  }

  body.is-gallery-bar-thin .js-gallery-description-box {
    gap: 0.55rem;
  }

  body.is-gallery-bar-thin .js-gallery-description {
    display: none;
  }

  .grid-wraper {
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #f7f6f5;
  }

  .js-gallery-stage {
    min-height: 0;
  }

  .journal-desktop-int {
    display: none !important;
  }

  .js-grid-sources {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 10px;
  }

  .js-grid-sources .grid-source-wrap {
    position: relative;
    aspect-ratio: 3 / 4;
    overflow: hidden;
    border-radius: 8px;
    background-color: #e9e3db;
  }

  .js-grid-sources .js-grid-source {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
  }
}

@media (max-width: 767px) {
  .js-gallery-description-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "title actions"
      "desc desc";
    align-items: start;
    column-gap: 0.75rem;
    row-gap: 0.75rem;
    padding: 0.9rem 1rem 1.75rem;
  }

  .js-gallery-title {
    grid-area: title;
    flex: none;
    max-width: 100%;
    font-size: clamp(1.65rem, 8vw, 2rem);
    line-height: 0.95;
  }

  .js-gallery-description {
    grid-area: desc;
    margin-left: 0;
    font-size: 0.92rem;
    line-height: 1.35;
  }

  .gallery-bar-actions {
    grid-area: actions;
    width: auto;
    gap: 0.5rem;
    padding-right: 0;
    justify-content: flex-end;
    align-items: center;
  }

  .gallery-bar-close {
    width: 2rem;
    height: 2rem;
  }

  .gallery-bar-toggle {
    width: 1.9rem;
    height: 1.9rem;
  }

  .gallery-bar-toggle__icon {
    width: 0.55rem;
    height: 0.55rem;
  }

  .js-grid-sources {
    gap: 8px;
    padding: 8px;
  }

  body.is-gallery-bar-thin .js-gallery-description-box {
    grid-template-areas: "title actions";
    align-items: center;
    row-gap: 0;
    padding-top: 0.7rem;
    padding-bottom: 0.9rem;
  }

  body.is-gallery-bar-thin .js-gallery-title {
    font-size: 1.3rem;
  }

  body.is-gallery-bar-thin .gallery-bar-actions > a,
  body.is-gallery-bar-thin .js-gallery-description {
    display: none;
  }
}

/* ── View Project hover overlay (desktop: JS-driven) ── */

.grid-hover-overlay {
  position: absolute;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  /* background: rgba(0, 0, 0, 0.35); */
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
}

.grid-hover-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
  cursor: pointer;
}

.grid-hover-overlay__btn {
  display: inline-block;
  padding: 0.7rem 1.8rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: #4a6cf7;
  border-radius: 999px;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 16px rgba(74, 108, 247, 0.35);
  transform: translateY(8px);
  transition: transform 250ms ease;
}

.grid-hover-overlay.is-visible .grid-hover-overlay__btn {
  transform: translateY(0);
}

/* ── View Project hover overlay (mobile: CSS-driven) ── */

.grid-source-wrap {
  position: relative;
  cursor: pointer;
}

.grid-item-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  opacity: 0;
  transition: opacity 250ms ease;
  pointer-events: none;
}

.grid-source-wrap:hover .grid-item-overlay,
.grid-source-wrap:active .grid-item-overlay {
  opacity: 1;
}

body.is-gallery-brands .grid-source-wrap:hover .grid-item-overlay,
body.is-gallery-brands .grid-source-wrap:active .grid-item-overlay {
  opacity: 0;
  pointer-events: none;
}

.grid-item-overlay__btn {
  display: inline-block;
  padding: 0.7rem 1.8rem;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: #4a6cf7;
  border-radius: 999px;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 16px rgba(74, 108, 247, 0.35);
  transform: translateY(8px);
  transition: transform 250ms ease;
}

.grid-source-wrap:hover .grid-item-overlay__btn {
  transform: translateY(0);
}

@media (max-width: 991px) {
  .grid-source-wrap .js-grid-source {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 8px;
    background-color: #e9e3db;
  }

  .grid-source-wrap .grid-item-overlay {
    border-radius: 8px;
  }

  /* Hide "View Project" overlay on mobile for non-brands (accordion replaces it) */
  body:not(.is-gallery-brands) .grid-source-wrap .grid-item-overlay {
    display: none;
  }
}

/* ── Gallery image popup / lightbox ── */

.gallery-popup {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 300ms ease,
    visibility 300ms ease;
}

.gallery-popup.is-open {
  opacity: 1;
  visibility: visible;
}

.gallery-popup__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  cursor: pointer;
}

.gallery-popup__card {
  position: relative;
  z-index: 1;
  width: 90vw;
  max-width: 860px;
  background: #f7f6f5 url(../ui/assets/images/pattern.png) repeat;
  background-size: calc(80px + 8vw);
  border-radius: 16px;
  padding: clamp(2rem, 4vw, 3.5rem);
  color: #111;
  transform: scale(0.92);
  transition: transform 300ms ease;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.gallery-popup.is-open .gallery-popup__card {
  transform: scale(1);
}

.gallery-popup__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  color: #111;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 200ms ease;
}

.gallery-popup__close:hover {
  background: rgba(0, 0, 0, 0.15);
}

.gallery-popup__body {
  display: flex;
  gap: clamp(1.5rem, 3vw, 3rem);
  align-items: flex-start;
}

.gallery-popup__info {
  flex: 1 1 55%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.gallery-popup__header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.gallery-popup__title {
  margin: 0;
  font-size: clamp(1.6rem, 2.5vw, 2.2rem);
  font-weight: 700;
  line-height: 1.15;
  color: #111;
}

.gallery-popup__tag {
  display: inline-block;
  padding: 0.35rem 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  background: #e53935;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.gallery-popup__desc {
  margin: 0;
  font-size: clamp(0.92rem, 1.1vw, 1.05rem);
  line-height: 1.6;
  color: rgba(0, 0, 0, 0.7);
}

.gallery-popup__cta {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.7rem 1.6rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  background: #e53935;
  border-radius: 6px;
  text-decoration: none;
  align-self: flex-start;
  transition: background 200ms ease;
}

.gallery-popup__cta:hover {
  background: #c62828;
}

.gallery-popup__preview {
  flex: 0 0 40%;
  max-width: 40%;
}

.gallery-popup__slider {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: #d5d5d5;
}

.gallery-popup__slides {
  display: flex;
  transition: transform 350ms ease;
}

.gallery-popup__slide {
  flex: 0 0 100%;
  min-width: 0;
}

.gallery-popup__img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #d5d5d5;
}

.gallery-popup__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background 200ms ease;
}

.gallery-popup__arrow:hover {
  background: rgba(0, 0, 0, 0.7);
}

.gallery-popup__arrow--prev {
  left: 0.5rem;
}

.gallery-popup__arrow--next {
  right: 0.5rem;
}

.gallery-popup--has-slides .gallery-popup__arrow {
  display: flex;
}

.gallery-popup__dots {
  display: none;
  justify-content: center;
  gap: 0.45rem;
  padding-top: 0.7rem;
}

.gallery-popup--has-slides .gallery-popup__dots {
  display: flex;
}

.gallery-popup__dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition:
    background 200ms ease,
    transform 200ms ease;
}

.gallery-popup__dot.is-active {
  background: #111;
  transform: scale(1.25);
}

@media (max-width: 640px) {
  .gallery-popup__body {
    flex-direction: column;
  }

  .gallery-popup__preview {
    flex: none;
    max-width: 100%;
    width: 100%;
  }

  .gallery-popup__img {
    aspect-ratio: 16 / 10;
  }

  .gallery-popup__card {
    max-height: 90vh;
    overflow-y: auto;
  }
}

/* ── Mobile accordion (non-brands project galleries) ── */

@media (max-width: 991px) {
  .grid-accordion {
    grid-column: 1 / -1;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    margin: -2px 0 6px;
  }

  .grid-accordion__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.1rem;
    cursor: pointer;
    user-select: none;
  }

  .grid-accordion__title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
    color: #111;
  }

  .grid-accordion__toggle {
    flex: 0 0 auto;
    width: 1.6rem;
    height: 1.6rem;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
    color: #111;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .grid-accordion__body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 350ms ease;
  }

  .grid-accordion.is-open .grid-accordion__body {
    max-height: 2000px;
  }

  .grid-accordion__desc {
    margin: 0;
    padding: 0 1.1rem 1rem;
    font-size: 0.92rem;
    line-height: 1.55;
    color: #333;
  }

  .grid-accordion__cta {
    display: inline-block;
    margin: 0 1.1rem 1rem;
    padding: 0.6rem 1.4rem;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    background: #e53935;
    border-radius: 6px;
    text-decoration: none;
  }

  .grid-accordion__image {
    padding: 0 1.1rem 1.1rem;
  }

  .grid-accordion__image img {
    display: block;
    width: 100%;
    border-radius: 8px;
    object-fit: cover;
  }

  /* highlight the active grid item */
  .grid-source-wrap.is-accordion-active {
    outline: 3px solid #4a6cf7;
    outline-offset: -3px;
    border-radius: 8px;
  }
}

/* â"€â"€ Brands gallery: smaller cells so 12+ logos are visible â"€â"€ */

body.is-gallery-brands .grid {
  width: 105vw;
  height: 105vw;
  gap: 40px;
}

@media (max-width: 991px) {
  body.is-gallery-brands .js-grid-sources {
    grid-template-columns: repeat(3, 1fr);
  }
}
