/* ==========================================================================
   Portfolio — filters, project cards, device frames
   ========================================================================== */

.portfolio { background: var(--bg); }
.portfolio::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(50% 30% at 0% 20%, rgba(124, 92, 255, 0.1), transparent 70%),
    radial-gradient(40% 30% at 100% 70%, rgba(71, 123, 255, 0.09), transparent 70%);
  pointer-events: none;
}
.portfolio > .container { position: relative; }

/* ---------- Filters ---------- */

.filters {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.35rem;
  margin-bottom: clamp(2.5rem, 5vw, 4.5rem);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
}
.filter {
  position: relative;
  padding: 0.65rem 1.35rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.4s, background-color 0.4s;
}
.filter:hover { color: var(--text); }
.filter.is-active { color: #fff; background: linear-gradient(135deg, rgba(91, 138, 255, 0.95), rgba(71, 123, 255, 0.85)); box-shadow: 0 6px 24px -6px rgba(71, 123, 255, 0.8); }

/* ---------- Grid ---------- */

.works {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: clamp(1.5rem, 4vw, 5rem);
  row-gap: clamp(3rem, 6vw, 6rem);
  align-items: start;
}
.work { position: relative; }
.work.is-offset { margin-top: clamp(3rem, 9vw, 9rem); }
.work.is-hidden { display: none; }
.work.is-leaving { opacity: 0; transform: scale(0.97); transition: opacity 0.3s, transform 0.3s; }
.work.is-entering { animation: work-in 0.7s var(--ease) both; }
@keyframes work-in { from { opacity: 0; transform: translateY(24px) scale(0.98); } to { opacity: 1; transform: none; } }

@media (max-width: 860px) {
  .works { grid-template-columns: 1fr; }
  .work.is-offset { margin-top: 0; }
}

/* ---------- Stage ---------- */

.work__media {
  --rx: 0;
  --ry: 0;
  position: relative;
  padding: clamp(1.1rem, 3.2vw, 3rem) clamp(1.1rem, 3.2vw, 3rem) clamp(2.6rem, 6vw, 5.4rem);
  border: 1px solid var(--line);
  border-radius: 1.8rem;
  background:
    radial-gradient(80% 70% at 50% 64%, color-mix(in srgb, var(--tint) 40%, transparent), transparent 74%),
    radial-gradient(45% 45% at 0% 0%, color-mix(in srgb, var(--tint) 16%, transparent), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015));
  overflow: hidden;
  transition: border-color 0.6s, background-color 0.6s;
}
.work:hover .work__media { border-color: color-mix(in srgb, var(--tint) 50%, transparent); }

/* image reveal: the stage opens like a shutter */
.js .work__media[data-reveal] {
  opacity: 1;
  transform: none;
  clip-path: inset(14% 10% 14% 10% round 1.8rem);
  transition: clip-path 1.6s var(--ease-io) var(--d, 0s), border-color 0.6s;
}
.js .work__media[data-reveal].is-in { clip-path: inset(0 0 0 0 round 1.8rem); }
.js .work__media[data-reveal] .device { opacity: 0; transition: opacity 1s ease 0.5s, transform 0.8s var(--ease); }
.js .work__media[data-reveal].is-in .device { opacity: 1; }

.work__badge {
  position: absolute;
  bottom: 1rem; left: 1.2rem;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(245, 247, 255, 0.8);
  background: rgba(5, 7, 13, 0.7);
}
.work__badge::before { content: ''; width: 0.35rem; height: 0.35rem; border-radius: 50%; background: var(--tint); }

/* ---------- Devices ---------- */

.device {
  position: relative;
  background: #0e121c;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 50px 90px -30px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(0, 0, 0, 0.35);
}
.device__screen { position: relative; overflow: hidden; container-type: inline-size; background: #000; }

.device--desktop {
  width: 90%;
  border-radius: 0.8rem;
  overflow: hidden;
  transform-origin: 50% 70%;
  transition: transform 0.9s var(--ease), translate 0.9s var(--ease), scale 0.9s var(--ease);
}
.device--desktop .device__screen { aspect-ratio: 16 / 10; }
.device__bar {
  display: flex;
  align-items: center;
  gap: 0.38rem;
  height: 1.6rem;
  padding: 0 0.75rem;
  background: #151b29;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.device__bar i { width: 0.42rem; height: 0.42rem; border-radius: 50%; background: rgba(255, 255, 255, 0.22); }
.device__bar span {
  margin: 0 auto;
  transform: translateX(-1.1rem);
  padding: 0.12rem 1rem;
  border-radius: 999px;
  font-size: 0.58rem;
  letter-spacing: 0.02em;
  color: var(--faint);
  background: rgba(255, 255, 255, 0.05);
}

.device--mobile {
  position: absolute;
  right: clamp(1.1rem, 3vw, 2.8rem);
  bottom: clamp(1.1rem, 2.8vw, 2.4rem);
  z-index: 3;
  width: 21%;
  aspect-ratio: 9 / 19;
  padding: 0.28rem;
  border-radius: clamp(1rem, 2.2vw, 1.7rem);
  background: #0a0d15;
  border-color: rgba(255, 255, 255, 0.2);
  transition: transform 1s var(--ease);
}
.device--mobile .device__screen { height: 100%; border-radius: clamp(0.8rem, 1.8vw, 1.4rem); }
.device--mobile::before {
  content: '';
  position: absolute;
  top: 0.55rem; left: 50%;
  z-index: 4;
  width: 26%; height: 0.32rem;
  margin-left: -13%;
  border-radius: 999px;
  background: #000;
}

.work:hover .device--desktop { translate: 0 -6px; scale: 1.012; }
.work:hover .device--mobile { transform: translateY(-14px); }

/* the page inside scrolls by itself while you hover */
.site {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  transition: transform 1.2s var(--ease-io);
}
.work:hover .site { will-change: transform; transform: translateY(calc(-1 * var(--travel, 34cqw))); transition-duration: 4.2s; }

/* ---------- Meta ---------- */

.work__meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 1.2rem;
  padding: 1.4rem 0.2rem 0;
}
.work__index { font-size: 0.7rem; letter-spacing: 0.14em; color: var(--blue-soft); }
.work__title {
  font-family: var(--serif);
  font-weight: 340;
  font-size: clamp(1.5rem, 2.2vw, 2rem);
  letter-spacing: -0.015em;
  line-height: 1.1;
}
.work__type { margin-top: 0.3rem; font-size: 0.88rem; color: var(--muted); }
.work__cat {
  padding: 0.35rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.4s, border-color 0.4s;
}
.work:hover .work__cat { color: var(--text); border-color: color-mix(in srgb, var(--tint) 70%, transparent); }

@media (max-width: 520px) {
  .work__meta { grid-template-columns: auto 1fr; }
  .work__cat { grid-column: 2; justify-self: start; }
  .device--mobile { width: 24%; }
}
@media (hover: none) {
  /* touch screens: show the scrolled state in a gentle loop instead of hover */
  .work .site { animation: site-peek 9s var(--ease-io) infinite; }
  @keyframes site-peek { 0%, 18% { transform: none; } 50%, 68% { transform: translateY(calc(-1 * var(--travel, 34cqw))); } 100% { transform: none; } }
}

/* ---------- Section heading ---------- */

.work-head {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 5vw, 5rem);
  align-items: end;
  margin-bottom: clamp(2.2rem, 4vw, 3.5rem);
}
.work-head__main { display: grid; gap: 1.5rem; justify-items: start; }
.work-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(3.1rem, 7.6vw, 7.4rem);
  line-height: 0.93;
  letter-spacing: -0.028em;
  text-wrap: balance;
}
.work-title em {
  display: inline-block;
  padding-right: 0.06em;
  font-style: italic;
  background: linear-gradient(100deg, #b4cbff 0%, #5b8aff 40%, #477bff 55%, #9a76ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 28px rgba(71, 123, 255, 0.4));
}
.work-head__aside { display: grid; gap: 1.3rem; justify-items: end; }
.work-count { display: flex; align-items: baseline; gap: 0.9rem; }
.work-count__n {
  font-family: var(--serif);
  font-size: clamp(5rem, 10vw, 9.5rem);
  line-height: 0.8;
  letter-spacing: -0.03em;
  color: transparent;
  -webkit-text-stroke: 1px rgba(143, 176, 255, 0.55);
}
.work-count__l { font-size: 0.7rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); }
.work-head__note { max-width: 31ch; font-size: 0.98rem; color: var(--muted); }

@media (max-width: 860px) {
  .work-head { grid-template-columns: 1fr; }
  .work-head__aside { justify-items: start; }
  .work-count__n { font-size: 5rem; }
}
}

/* blueprint grid behind the devices, faded towards the edges */
.work__media::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 2.4rem 2.4rem;
  -webkit-mask-image: radial-gradient(65% 70% at 50% 55%, #000 15%, transparent 100%);
  mask-image: radial-gradient(65% 70% at 50% 55%, #000 15%, transparent 100%);
  pointer-events: none;
}
