/* ---------------------------------------------------
   Work grid
--------------------------------------------------- */

/* work.html only — content now scrolls up behind the fixed navbar
   (sticky toolbar/titles sit right underneath it), so it needs an
   opaque backing instead of the site-wide transparent nav. */
.nav {
  background: var(--bg);
}

.work-toolbar {
  display: flex;
  gap: 16px;
  padding-top: 20px;
  padding-bottom: 20px;
  position: sticky;
  top: var(--nav-h);
  z-index: 90;
  background: var(--bg);
  transition: transform 0.4s var(--ease);
}

/* extends the background upward behind the navbar (which sits above it
   at z-index 100) so sub-pixel rounding or any desync during the
   navbar's hide/show animation can never expose a sliver of the
   scrolling content between the two. */
.work-toolbar::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: -100vw;
  right: -100vw;
  height: var(--nav-h);
  background: var(--bg);
}

/* inset to match the width of the project rows' own dividers below,
   instead of running the full edge-to-edge width of the toolbar box. */
.work-toolbar::after {
  content: '';
  position: absolute;
  left: 40px;
  right: 40px;
  bottom: 0;
  height: 1px;
  background: var(--border);
}

@media (max-width: 900px) {
  .work-toolbar::after {
    left: 24px;
    right: 24px;
  }
}

/* rise together with the navbar when it hides itself on scroll down,
   landing flush at the very top of the page instead of leaving a gap. */
body:has(.nav.is-hidden) .work-toolbar {
  transform: translateY(calc(-1 * var(--nav-h)));
}

.work-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 48px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(245, 241, 232, 0.04);
  color: var(--fg-muted);
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
  transition: background 0.4s var(--ease), box-shadow 0.4s var(--ease);
}

.work-search:focus-within {
  background: rgba(245, 241, 232, 0.09);
  box-shadow: 0 2px 10px 2px rgba(255, 255, 255, 0.14);
}

.work-search svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.work-search__input {
  flex: 1;
  height: 100%;
  border: 0;
  background: none;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--fg);
  outline: none;
}

.work-search__input::placeholder {
  color: var(--fg-muted);
}

.work-filters {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.work-filter {
  height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  transition: background 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease);
}

.work-filter:hover {
  color: var(--fg);
}

.work-filter.is-active {
  background: var(--fg);
  border-color: var(--fg);
  color: var(--bg);
}

@media (max-width: 700px) {
  .work-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

.work-list {
  display: flex;
  flex-direction: column;
  padding-bottom: 120px;
}

.work-row {
  padding: 48px 0;
  border-top: 1px solid var(--border);
}

.work-row:last-child {
  border-bottom: 1px solid var(--border);
}

.work-row.is-hidden {
  display: none;
}

.work-row__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(20px, 2.4vw, 28px);
  text-transform: none;
  letter-spacing: -0.01em;
  margin-bottom: 24px;
}

.work-row__body {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 32px;
  max-width: 1020px;
}

/* groups the title with its preview so the title's sticky range is
   bound to the preview's own height, not the (possibly taller)
   details column — it releases exactly at the preview's bottom edge.
   Always anchored to the top of the row (align-self: flex-start)
   regardless of the details column's own height, so its sticky trigger
   point stays consistent from project to project. */
.work-row__sticky-col {
  flex: 0 0 480px;
  align-self: flex-start;
}

.work-row__media {
  display: block;
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 3;
  overflow: hidden;
  transition: transform 0.6s var(--ease);
}

.work-row__media::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.5);
  mix-blend-mode: overlay;
  pointer-events: none;
}

/* hover — a full-opacity line traces the frame on hover, starting at
   the top-left corner and running clockwise all the way around. */
.work-row__frame-line {
  position: absolute;
  z-index: 2;
  background: #fff;
  mix-blend-mode: overlay;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s linear;
}

.work-row__frame-line--top {
  top: 0;
  left: 0;
  width: 0;
  height: 1px;
  transition: width 0.25s var(--ease) 0s, opacity 0.1s linear 0s;
}

.work-row__frame-line--right {
  top: 0;
  right: 0;
  width: 1px;
  height: 0;
  transition: height 0.25s var(--ease) 0.25s, opacity 0.1s linear 0s;
}

.work-row__frame-line--bottom {
  bottom: 0;
  right: 0;
  width: 0;
  height: 1px;
  transition: width 0.25s var(--ease) 0.5s, opacity 0.1s linear 0s;
}

.work-row__frame-line--left {
  bottom: 0;
  left: 0;
  width: 1px;
  height: 0;
  transition: height 0.25s var(--ease) 0.75s, opacity 0.1s linear 0s;
}

.work-row__media:hover .work-row__frame-line {
  opacity: 1;
}

.work-row__media:hover .work-row__frame-line--top {
  width: 100%;
}

.work-row__media:hover .work-row__frame-line--right {
  height: 100%;
}

.work-row__media:hover .work-row__frame-line--bottom {
  width: 100%;
}

.work-row__media:hover .work-row__frame-line--left {
  height: 100%;
}

.work-row__media video,
.work-row__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s var(--ease);
}

.work-row__media:hover {
  transform: scale(1.03);
}

.work-row__media:hover video,
.work-row__media:hover img {
  transform: scale(1.03);
}

.work-row__media.tone-2 { background: linear-gradient(150deg, #ff8a3d, #7a1f8f); }
.work-row__media.tone-3 { background: linear-gradient(150deg, #3dd6ff, #1a2a8f); }
.work-row__media.tone-4 { background: linear-gradient(150deg, #ff3d8a, #2a0a3a); }
.work-row__media.tone-6 { background: linear-gradient(150deg, #f5d33d, #8f2a1a); }

.work-row__details {
  flex: 1 1 0;
  align-self: flex-end;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px 20px;
  align-content: end;
}

.work-row__field--wide {
  grid-column: 1 / -1;
}

.work-row__field h3 {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-bottom: 8px;
}

.work-row__field p {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--fg-muted);
}

.work-row__field--wide p {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--fg-muted);
  line-height: 1.5;
}

@media (max-width: 900px) {
  .work-row__body {
    flex-direction: column;
  }

  .work-row__sticky-col {
    width: 100%;
    flex: none;
  }

  .work-row__details {
    grid-template-columns: 1fr;
  }
}
