/* Feature gallery styles */
/* Gallery: full-bleed width; other sections keep main gutter */
#galleryView {
  margin-inline: calc(-1 * var(--main-gutter));
  width: calc(100% + 2 * var(--main-gutter));
  max-width: 100vw;
  box-sizing: border-box;
}

@media (max-width: 650px) {
  .main-layout {
    --main-gutter: 1rem;
    padding: 1rem;
  }

  .hero-section {
    min-height: auto;
    padding: 1rem 0 1.35rem;
    gap: 0.85rem;
  }
}

.gallery-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 2.2vw, 1.6rem);
  width: 100%;
  max-width: min(1280px, 100%);
  margin-inline: auto;
  align-items: start;
}

.gallery-focus-layout {
  width: min(1660px, 100%);
  margin-inline: auto;
  position: relative;
  isolation: isolate;
}

.gallery-focus-layout::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease, backdrop-filter 0.24s ease, -webkit-backdrop-filter 0.24s ease;
  z-index: 1;
}

.gallery-focus-layout.is-focus-mode::after {
  background: rgba(0, 0, 0, 0.14);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  opacity: 1;
}

.gallery-focus-layout .gallery-list {
  position: relative;
  z-index: 2;
}

.gallery-focus-layout .gallery-project-info {
  z-index: 3;
}

.gallery-project-info {
  position: absolute;
  z-index: 40;
  width: clamp(190px, 16vw, 240px);
  pointer-events: none;
  color: var(--label-fg);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.gallery-project-info.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.gallery-project-info.is-right {
  border-left: 0 !important;
  padding-left: clamp(0.72rem, 1.3vw, 1rem);
}

.gallery-project-info.is-left {
  border-right: 0 !important;
  padding-right: clamp(0.72rem, 1.3vw, 1rem);
  text-align: right;
}

.gallery-project-info,
.gallery-project-info.is-right,
.gallery-project-info.is-left {
  border: 0 !important;
  box-shadow: none !important;
  outline: 0 !important;
}

.gallery-project-info::before,
.gallery-project-info::after {
  display: none !important;
}

.gallery-project-title {
  margin: 0 0 0.9rem;
  font-size: clamp(1.1rem, 1.6vw, 1.35rem);
  line-height: 1.24;
  color: var(--text);
}

.gallery-project-info.is-text-animating .gallery-project-title,
.gallery-project-info.is-text-animating .gallery-project-meta dt,
.gallery-project-info.is-text-animating .gallery-project-meta dd {
  opacity: 0;
  transform: translateY(8px);
  filter: blur(3px);
  animation: galleryInfoTextIn 0.52s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.gallery-project-info.is-text-animating .gallery-project-title {
  animation-delay: 0.02s;
}

.gallery-project-info.is-text-animating .gallery-project-meta div:nth-child(1) dt,
.gallery-project-info.is-text-animating .gallery-project-meta div:nth-child(1) dd {
  animation-delay: 0.08s;
}

.gallery-project-info.is-text-animating .gallery-project-meta div:nth-child(2) dt,
.gallery-project-info.is-text-animating .gallery-project-meta div:nth-child(2) dd {
  animation-delay: 0.13s;
}

.gallery-project-info.is-text-animating .gallery-project-meta div:nth-child(3) dt,
.gallery-project-info.is-text-animating .gallery-project-meta div:nth-child(3) dd {
  animation-delay: 0.18s;
}

.gallery-project-info.is-text-animating .gallery-project-meta div:nth-child(4) dt,
.gallery-project-info.is-text-animating .gallery-project-meta div:nth-child(4) dd {
  animation-delay: 0.23s;
}

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

.gallery-project-meta div {
  display: grid;
  gap: 0.2rem;
}

.gallery-project-meta dt {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.gallery-project-meta dd {
  margin: 0;
  color: var(--text);
  font-size: 0.88rem;
  line-height: 1.45;
}

@keyframes galleryInfoTextIn {
  from {
    opacity: 0;
    transform: translateY(8px);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

.gallery-item {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  margin: 0 0 clamp(1rem, 2vw, 1.4rem);
  cursor: pointer;
  opacity: 1;
  transform: translateY(0);
  transition:
    transform 0.35s var(--ease-reveal),
    opacity 0.35s var(--ease-reveal),
    filter 0.35s var(--ease-reveal),
    box-shadow 0.35s var(--ease-reveal);
}

.gallery-item.reveal-pending {
  opacity: 0;
  transform: translateY(16px);
}

.gallery-list.is-focus-mode .gallery-item {
  opacity: 0.2;
  filter: brightness(0.82) saturate(0.88);
  transform: scale(0.985);
}

.gallery-list.is-focus-mode .gallery-item.is-hovered {
  opacity: 1;
  filter: none;
  transform: translateY(-4px) scale(1);
}

.gallery-item:nth-child(odd) {
  grid-column: 1;
  width: 100%;
  justify-self: center;
}

.gallery-item:nth-child(even) {
  grid-column: 2;
  width: 92%;
  justify-self: center;
  margin-top: clamp(1rem, 3vw, 2rem);
}

.gallery-item.in-view {
  opacity: 1;
  transform: translateY(0);
}

.gallery-item:hover {
  transform: translateY(-4px);
}

.gallery-item.active {
  opacity: 0.92;
}

.gallery-item.active .gallery-title {
  font-weight: 500;
}

.gallery-media {
  width: 100%;
  overflow: hidden;
  position: relative;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-picture {
  display: block;
  width: 100%;
}

@media (hover: hover) and (pointer: fine) {
  .gallery-item .gallery-media,
  .gallery-item .gallery-media * {
    cursor: none;
  }
}

.gallery-media img {
  width: 100%;
  height: auto;
  max-width: 100%;
  max-height: calc(100vh - 5.8rem);
  object-fit: cover;
  display: block;
  opacity: 0;
  transform: translate3d(var(--img-px, 0px), var(--img-py, 0px), 0) scale(1);
  transition: transform 0.35s var(--ease-reveal), opacity 0.35s ease;
  will-change: transform;
  border-radius: 0;
}

@media (max-width: 760px) {
  .gallery-media img {
    max-height: calc(100vh - 4.4rem);
  }
}

.gallery-media img.is-loaded {
  opacity: 1;
}

.gallery-media img.is-error {
  background: rgba(255, 255, 255, 0.08);
  object-fit: contain;
}

.gallery-item:hover .gallery-media img.is-loaded {
  transform: translate3d(var(--img-px, 0px), var(--img-py, 0px), 0) scale(1.045);
}

.gallery-media-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.05) 28%, rgba(0, 0, 0, 0.42) 100%);
  opacity: 0;
  transition: opacity 0.22s ease;
  pointer-events: none;
}

.gallery-item:hover .gallery-media-overlay {
  opacity: 1;
}

.gallery-media-overlay-label {
  width: clamp(5.6rem, 10.5vw, 7.2rem);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  position: absolute;
  left: var(--overlay-x, 50%);
  top: var(--overlay-y, 50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: #111;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.86);
  transition: opacity 0.26s ease, transform 0.34s var(--ease-reveal), visibility 0.24s ease;
  will-change: transform, left, top;
}

.gallery-item:hover .gallery-media-overlay-label {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.gallery-media-overlay-icon {
  display: inline-flex;
  font-size: clamp(1.55rem, 2.9vw, 2.15rem);
  line-height: 1;
  transform: translateY(-3%);
}

@media (hover: hover) and (pointer: fine) {
  html.has-custom-pointer body,
  html.has-custom-pointer body * {
    cursor: none !important;
  }

  .custom-pointer {
    position: fixed;
    left: 0;
    top: 0;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--text);
    color: #111;
    pointer-events: none;
    z-index: 200;
    opacity: 0;
    transform: translate3d(-50%, -50%, 0) scale(1);
    transform-origin: center;
    will-change: transform, width, height, opacity, background-color, color;
    transition:
      width 0.26s var(--ease-reveal),
      height 0.26s var(--ease-reveal),
      background-color 0.22s ease,
      color 0.22s ease,
      opacity 0.2s ease;
  }

  .custom-pointer.is-visible {
    opacity: 1;
  }

  .custom-pointer.is-project {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.60);
    color: #111;
  }

  .custom-pointer__icon {
    position: absolute;
    left: 50%;
    top: 50%;
    font-size: 1.55rem;
    line-height: 1;
    transform: translate(-50%, -50%) scale(0.72);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.26s var(--ease-reveal);
  }

  .custom-pointer.is-project .custom-pointer__icon {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }

  .gallery-item .gallery-media-overlay-label {
    display: none;
  }
}

.gallery-mobile-info {
  display: none;
}

.gallery-title {
  margin: 0;
  font-size: clamp(1rem, 1.6vw, 1.18rem);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: 0.01em;
  text-align: center;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.gallery-list.is-focus-mode .gallery-item.is-hovered .gallery-title {
  opacity: 0;
  transform: translateY(8px);
}

@media (prefers-reduced-motion: reduce) {
  .gallery-media img {
    transform: none !important;
  }
}

@media (hover: none), (pointer: coarse) {
  .gallery-list.is-mobile-focus-mode .gallery-item {
    opacity: 0.44;
    filter: brightness(0.82) saturate(0.9);
    transform: scale(0.985);
  }

  .gallery-list.is-mobile-focus-mode .gallery-item.is-mobile-active {
    opacity: 1;
    filter: none;
    transform: translateY(-2px) scale(1);
  }

  .gallery-list.is-mobile-focus-mode .gallery-item.is-mobile-active .gallery-title {
    opacity: 0;
    transform: translateY(8px);
  }

  .gallery-list.is-mobile-focus-mode .gallery-item:not(.is-mobile-active) .gallery-media-overlay-label {
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
  }

  .gallery-list.is-mobile-focus-mode .gallery-item.is-mobile-active .gallery-media-overlay-label {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .gallery-media-overlay {
    opacity: 1;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.02) 18%, rgba(0, 0, 0, 0.8) 100%);
    padding: 0.78rem;
    justify-content: space-between;
    flex-direction: column;
    gap: 0.7rem;
  }

  .gallery-media-overlay-label {
    width: clamp(3rem, 11vw, 3.6rem);
    position: static;
    left: auto;
    top: auto;
    background: rgba(255, 255, 255, 0.95);
    color: #111;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
    opacity: 1;
    transform: none;
    margin-left: auto;
  }

  .gallery-media-overlay-icon {
    font-size: clamp(1rem, 3.4vw, 1.25rem);
  }

  .gallery-mobile-info {
    display: grid;
    gap: 0.54rem;
    width: 100%;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.48);
    opacity: 0;
    transform: translateY(12px);
    filter: blur(2px);
    transition: opacity 0.34s ease, transform 0.34s ease, filter 0.34s ease;
  }

  .gallery-mobile-info-title {
    margin: 0;
    font-size: clamp(0.98rem, 3.8vw, 1.12rem);
    line-height: 1.3;
    letter-spacing: 0.01em;
    font-weight: 600;
  }

  .gallery-mobile-info-meta {
    margin: 0;
    display: grid;
    gap: 0.35rem;
  }

  .gallery-mobile-info-meta div {
    display: grid;
    gap: 0.12rem;
  }

  .gallery-mobile-info-meta dt {
    margin: 0;
    font-size: 0.64rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
  }

  .gallery-mobile-info-meta dd {
    margin: 0;
    font-size: clamp(0.74rem, 2.9vw, 0.84rem);
    line-height: 1.38;
    color: #fff;
    font-weight: 500;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .gallery-item.is-mobile-active .gallery-mobile-info {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}


/* Keep first view visible while deferred CSS/JS bootstraps observers. */
body[data-page="feature"] #galleryView.reveal,
body[data-page="feature"] #galleryView.reveal.in-view,
body[data-page="projects"] #indexView.reveal,
body[data-page="projects"] #indexView.reveal.in-view {
  opacity: 1;
  transform: none;
  transition: none;
}

@media (max-width: 960px) {
  .gallery-list {
    gap: 0.95rem;
  }

  .gallery-item:nth-child(odd) {
    width: 100%;
  }

  .gallery-item:nth-child(even) {
    width: 91%;
  }
}

@media (max-width: 1024px) {
  .gallery-focus-layout::after {
    display: none;
  }

  .gallery-project-info {
    display: none;
  }

  .index-wrap {
    grid-template-columns: 1fr;
  }

  .studio-info {
    grid-template-columns: 1fr;
  }

  .skills-grid {
    grid-template-columns: 1fr 1fr;
  }

  .detail-slider {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .gallery-list {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .gallery-item,
  .gallery-item:nth-child(odd),
  .gallery-item:nth-child(even) {
    grid-column: auto;
    width: 100%;
    justify-self: stretch;
    margin-top: 0;
  }
}

@media (max-width: 760px) {
  .header-nav {
    flex-wrap: nowrap;
    gap: 0.45rem;
  }

  .gallery-list {
    gap: 0.8rem;
  }

  .projects-table th:nth-child(3),
  .projects-table td:nth-child(3) {
    display: none;
  }

  .skills-grid {
    grid-template-columns: 1fr;
  }

  .about-si-grid,
  .about-main-grid,
  .about-office-grid {
    grid-template-columns: 1fr;
  }

  #aboutStudioBody {
    column-count: 2;
  }
}

@media (max-width: 420px) {
  .gallery-list {
    gap: 0.72rem;
  }
}

