:root {
  --ink: #111;
  --muted: #777;
  --line: #e7e7e7;
  --white: #fff;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: #fff;
  font-family:
    Inter, Arial, Helvetica, "Microsoft YaHei", "PingFang SC", sans-serif;
}

button,
a {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

a {
  text-decoration: none;
}

img {
  display: block;
  width: 100%;
  height: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 86px;
  padding: 18px clamp(18px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.logo {
  width: max-content;
  font-size: clamp(24px, 3vw, 42px);
  font-weight: 850;
  font-style: normal;
  letter-spacing: 0;
  line-height: 1;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 22px;
}

.filter {
  width: max-content;
  padding: 7px 0;
  color: #555;
  font-size: 14px;
  font-weight: 750;
  text-align: left;
}

.filter.is-active,
.filter:hover {
  color: #000;
  text-decoration: underline;
  text-underline-offset: 5px;
}

.page {
  padding: 28px clamp(18px, 3vw, 42px) 72px;
  background: #fff;
}

.page-header {
  min-height: calc(100vh - 86px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  align-items: center;
  gap: 40px;
  padding: clamp(56px, 8vw, 120px) 0;
  border-bottom: 1px solid var(--line);
}

.kicker {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.page-header h1 {
  margin: 0;
  font-size: clamp(58px, 10vw, 164px);
  line-height: 0.88;
  letter-spacing: 0;
  font-weight: 950;
}

.page-header h1 span {
  display: block;
  animation: heroRise 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.page-header h1 span:nth-child(2) {
  animation-delay: 0.08s;
}

.page-header h1 span:nth-child(3) {
  animation-delay: 0.16s;
}

.page-header > p {
  margin: 0 0 10px;
  color: #444;
  font-size: 16px;
  line-height: 1.9;
  animation: heroRise 0.9s cubic-bezier(0.22, 1, 0.36, 1) 0.14s both;
}

.product-index {
  padding: 34px 0 46px;
  border-bottom: 1px solid var(--line);
}

.index-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 18px;
}

.index-card {
  display: grid;
  gap: 10px;
  padding: 0;
  text-align: left;
  background: #fff;
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 0.7s ease,
    transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--reveal-delay, 0ms);
}

.index-card.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.index-card img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 0;
  background:
    linear-gradient(110deg, #f4f4f4 8%, #fafafa 18%, #f4f4f4 33%) 0 0 / 220%
      100%,
    #f4f4f4;
  opacity: 1;
  transition:
    background-position 1.2s ease,
    opacity 0.4s ease,
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  animation: mediaSheen 1.5s linear infinite;
}

.index-card img.media-loaded {
  animation: none;
  background: #fff;
  opacity: 1;
}

.index-card:nth-child(2n) img {
  aspect-ratio: 1 / 1;
}

.index-card:nth-child(3n) img {
  aspect-ratio: 1 / 1;
}

.index-card h3 {
  margin: 0;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 850;
}

.gallery-section {
  padding-top: 44px;
}

.gallery-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.gallery-heading h2 {
  margin: 0;
  font-size: clamp(30px, 4vw, 58px);
  line-height: 0.95;
}

.masonry {
  display: grid;
  gap: clamp(12px, 1.4vw, 20px);
}

.mosaic-row {
  display: grid;
  grid-template-columns: 1.04fr 1fr 1fr 1.04fr;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: clamp(12px, 1.4vw, 20px);
  aspect-ratio: 16 / 7;
  min-height: 520px;
}

.project-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  display: block;
  padding: 0;
  overflow: hidden;
  text-align: left;
  background:
    linear-gradient(110deg, #f4f4f4 8%, #fafafa 18%, #f4f4f4 33%) 0 0 / 220%
      100%,
    #f4f4f4;
  opacity: 0;
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  transform: translateY(18px);
  transition:
    opacity 0.75s ease,
    transform 0.75s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--reveal-delay, 0ms);
}

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

.project-card > img,
.project-card > video {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background:
    linear-gradient(110deg, #f4f4f4 8%, #fafafa 18%, #f4f4f4 33%) 0 0 / 220%
      100%,
    #f4f4f4;
  object-fit: cover;
  opacity: 0;
  transition:
    filter 0.35s ease,
    opacity 0.4s ease,
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  animation: mediaSheen 1.5s linear infinite;
}

.project-card > img.media-loaded,
.project-card > video.media-loaded {
  animation: none;
  background: #fff;
  opacity: 1;
}

.project-card.tile-a {
  grid-column: 1;
  grid-row: 1 / 5;
}

.project-card.tile-b {
  grid-column: 2;
  grid-row: 1 / 2;
}

.project-card.tile-c {
  grid-column: 2;
  grid-row: 2 / 4;
}

.project-card.tile-d {
  grid-column: 2;
  grid-row: 4 / 5;
}

.project-card.tile-e {
  grid-column: 3;
  grid-row: 1 / 3;
}

.project-card.tile-f {
  grid-column: 3;
  grid-row: 3 / 5;
}

.project-card.tile-g {
  grid-column: 4;
  grid-row: 1 / 5;
}

.project-card[data-project="Waterproof Retro Bug Zapper"] > img,
.project-card[data-project="Portable Outdoor Mosquito Lamp A"] > img {
  object-position: center;
}

.project-card[data-project="Flame Mist Device"] > img,
.project-card[data-project="Wall-Mounted Bug Zapper"] > img {
  object-position: center top;
}

.project-card[data-project="Outdoor Candle Mosquito Lamp A"] > img,
.project-card[data-project="Outdoor Candle Mosquito Lamp B"] > img {
  object-position: center;
}

.project-card:hover > img,
.project-card:hover > video {
  filter: brightness(1.04);
  transform: perspective(900px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y))
    scale(1.035);
}

.project-caption {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 1;
  display: block;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.88);
  color: #111;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
  opacity: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  transform: translateY(8px);
  transition:
    opacity 0.24s ease,
    transform 0.24s ease;
  white-space: nowrap;
}

.project-card:hover .project-caption {
  opacity: 1;
  transform: translateY(0);
}

.masonry.is-focusing .project-card:not(.is-focused) > img,
.masonry.is-focusing .project-card:not(.is-focused) > video {
  filter: grayscale(0.2) opacity(0.42);
}

.masonry.is-focusing .project-card.is-focused > img,
.masonry.is-focusing .project-card.is-focused > video {
  filter: brightness(1.05);
}

.project-info {
  display: none;
  gap: 8px;
  padding-top: 10px;
}

.project-info h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
  font-weight: 900;
}

.project-info p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  order: 3;
}

.project-meta span {
  color: #777;
  font-size: 11px;
  font-weight: 750;
}

.project-meta span:not(:last-child)::after {
  content: "/";
  margin-left: 6px;
  color: #aaa;
}

.project-dialog {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  padding: 0;
  border: 0;
  background: #fff;
  color: var(--ink);
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  opacity: 0;
  transition: opacity 0.34s ease;
}

.project-dialog[open].is-open {
  opacity: 1;
}

.project-dialog::backdrop {
  background: rgba(255, 255, 255, 0.76);
  backdrop-filter: blur(18px);
  opacity: 0;
  transition: opacity 0.34s ease;
}

.project-dialog[open].is-open::backdrop {
  opacity: 1;
}

.detail-progress {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 999;
  width: 3px;
  height: 100vh;
  background: rgba(0, 0, 0, 0.06);
  pointer-events: none;
}

.detail-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: #111;
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.1s linear;
}

.dialog-shell {
  position: relative;
  display: block;
  min-height: 100vh;
  background: #fff;
}

.close {
  position: fixed;
  top: 18px;
  right: 30px;
  z-index: 1000;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  font-size: 26px;
  line-height: 1;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.06);
}

.dialog-copy {
  width: min(100%, 1440px);
  max-width: none;
  aspect-ratio: 16 / 9;
  min-height: 520px;
  margin: 0 auto;
  padding: clamp(64px, 7vw, 120px) clamp(42px, 8vw, 140px);
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  opacity: 0;
  transform: translateY(-18px);
  transition:
    opacity 0.62s ease,
    transform 0.72s cubic-bezier(0.22, 1, 0.36, 1);
}

.project-dialog.is-open .dialog-copy {
  opacity: 1;
  transform: translateY(0);
}

.dialog-copy .kicker {
  margin-bottom: 22px;
  font-size: clamp(13px, 1vw, 18px);
}

.dialog-copy h2 {
  margin: 0;
  font-size: clamp(58px, 7vw, 128px);
  line-height: 0.95;
  font-weight: 940;
  text-wrap: balance;
}

.dialog-copy p:not(.kicker) {
  max-width: 980px;
  margin: clamp(26px, 2.5vw, 42px) auto;
  color: #444;
  font-size: clamp(18px, 1.35vw, 26px);
  line-height: 1.85;
  text-wrap: pretty;
}

.spec-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(16px, 2vw, 28px);
  width: min(100%, 1160px);
  margin: clamp(34px, 3.5vw, 58px) auto 0;
}

.spec-list div {
  display: grid;
  gap: 14px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.spec-list dt {
  color: var(--muted);
  font-size: clamp(14px, 1vw, 18px);
}

.spec-list dd {
  margin: 0;
  font-size: clamp(18px, 1.35vw, 26px);
  font-weight: 800;
  text-wrap: balance;
}

.dialog-gallery {
  display: grid;
  justify-items: center;
  gap: clamp(56px, 4vw, 88px);
  padding: clamp(32px, 4vw, 64px) clamp(18px, 3vw, 56px)
    clamp(64px, 8vw, 120px);
  background: #fff;
}

.dialog-gallery img,
.dialog-gallery video {
  display: block;
  width: min(100%, 1680px);
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
  background: #fff;
  object-fit: cover;
  opacity: 0;
  --reveal-y: 24px;
  --parallax-y: 0px;
  --focus-scale: 1;
  cursor: zoom-in;
  transform: translateY(calc(var(--reveal-y) + var(--parallax-y)))
    scale(var(--focus-scale));
  transition:
    filter 0.35s ease,
    opacity 0.78s ease,
    transform 0.84s cubic-bezier(0.22, 1, 0.36, 1);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: transform;
}

.dialog-gallery img.is-visible,
.dialog-gallery video.is-visible {
  opacity: 1;
  --reveal-y: 0px;
}

@keyframes heroRise {
  from {
    opacity: 0;
    transform: translateY(24px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes mediaSheen {
  from {
    background-position: 120% 0;
  }

  to {
    background-position: -120% 0;
  }
}

.lightbox {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  padding: clamp(22px, 4vw, 56px);
  border: 0;
  background: rgba(255, 255, 255, 0.96);
  opacity: 0;
  transition: opacity 0.26s ease;
}

.lightbox.is-open {
  opacity: 1;
}

.lightbox::backdrop {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(20px);
}

.lightbox-stage {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
}

.lightbox-stage img,
.lightbox-stage video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  background: #fff;
}

.lightbox-close,
.lightbox-nav {
  position: fixed;
  z-index: 2;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.08);
}

.lightbox-close {
  top: 18px;
  right: 30px;
  width: 42px;
  height: 42px;
  font-size: 28px;
}

.lightbox-nav {
  top: 50%;
  width: 44px;
  height: 44px;
  color: #111;
  font-size: 34px;
  transform: translateY(-50%);
}

.lightbox-prev {
  left: 24px;
}

.lightbox-next {
  right: 24px;
}

@media (max-width: 1080px) {
  .index-grid {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .mosaic-row {
    min-height: 420px;
  }
}

@media (max-width: 760px) {
  .page-header {
    grid-template-columns: 1fr;
  }

  .page-header {
    min-height: auto;
  }

  .index-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery-heading {
    display: block;
  }

  .dialog-copy {
    aspect-ratio: auto;
    min-height: 78vh;
    padding: 72px 24px 48px;
  }

  .spec-list {
    grid-template-columns: 1fr;
  }

  .mosaic-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    aspect-ratio: auto;
    min-height: 0;
  }

  .project-card,
  .project-card.tile-a,
  .project-card.tile-b,
  .project-card.tile-c,
  .project-card.tile-d,
  .project-card.tile-e,
  .project-card.tile-f,
  .project-card.tile-g {
    grid-column: auto;
    grid-row: auto;
    aspect-ratio: 4 / 3;
  }

  .project-card.tile-a,
  .project-card.tile-g {
    aspect-ratio: 3 / 4;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }

  .index-card,
  .project-card,
  .project-dialog,
  .lightbox,
  .dialog-copy,
  .dialog-gallery img,
  .dialog-gallery video {
    opacity: 1;
    --parallax-y: 0px;
    --reveal-y: 0px;
    --focus-scale: 1;
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .topbar nav {
    justify-content: flex-start;
  }

  .page {
    padding-inline: 14px;
  }

  .mosaic-row {
    grid-template-columns: 1fr;
  }
}
