/*
 * Project names ship cloaked like the contacts: see the cloak notes in
 * assets/global.css. Name effects for data-fx live in glitch.css / glitch.js.
 * Screenshot files are named after their project's data-n without the "="
 * padding (RWx5dHM-01.webp), and each strip is labeled just "Screenshots",
 * so the HTML holds no project name.
 */

/* Custom pages get no padding from <main>, so the gutters live here. The max-width
   adds them back, so the text column is 720px like on the other pages. */
.work-page .page {
  max-width: calc(720px + 3rem);
  margin: 0 auto;
  padding: 2rem 1.5rem calc(2rem + env(safe-area-inset-bottom, 0px));
}

.work-meta {
  margin: -0.5rem 0 0.75rem;
  color: var(--color-text-muted);
}

.work-page .contacts {
  margin: 0 0 2rem;
}

.stack-label {
  color: var(--color-text-muted);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Title with small PDF / MD / COPY actions after it */
.work-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 1.125rem;
}

.work-head h1 {
  margin: 0;
}

.page-actions {
  display: flex;
  gap: 0.375rem;
  margin: 0;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.page-actions :is(a, button) {
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg-secondary);
  color: var(--color-text);
  line-height: 1;
  font: inherit;
  letter-spacing: inherit;
  text-decoration: none;
  cursor: pointer;
}

.page-actions :is(a, button):hover,
.page-actions :is(a, button):focus-visible {
  border-color: var(--color-accent);
  color: var(--color-accent);
  text-decoration: none;
}

/* EN | RU: two joined buttons, the open version filled in. */
.page-lang {
  display: flex;
  margin-left: 0.75rem;
}

.page-lang a {
  position: relative;
}

.page-lang a:hover,
.page-lang a:focus-visible {
  z-index: 1;
}

.page-lang a:first-child {
  border-radius: 4px 0 0 4px;
}

.page-lang a + a {
  margin-left: -1px;
  border-radius: 0 4px 4px 0;
}

.page-actions .page-lang [aria-current] {
  z-index: 1;
  border-color: var(--color-text);
  background: var(--color-text);
  color: var(--color-bg);
  cursor: default;
}

.lede {
  margin-bottom: 1.5rem;
}

.skills {
  margin-bottom: 2.5rem;
}

/* Wider label column for "React Native" */
.skills .stack:has(.stack-label) {
  grid-template-columns: 6.5rem minmax(0, 1fr);
}

/* Projects */
.project {
  position: relative;
  padding: 1.75rem 0 1.5rem;
  border-top: 1px solid var(--color-border);
}

.project-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  margin-bottom: 0.5rem;
}

.page-content .project h2,
.project-when {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.25;
}

.project-when {
  padding-left: 0.75rem;
  border-left: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

.project-links {
  display: flex;
  gap: 1rem;
  margin: 0 0 0 auto;
  font-size: 0.875rem;
}

.project-links a::after {
  content: "\2009\2197";
  content: "\2009\2197" / "";
}

.project-links a[href^="/"]::after {
  content: "\2009\2192";
  content: "\2009\2192" / "";
}

.project > p {
  margin-bottom: 0.75rem;
}

.stack {
  margin-bottom: 0.25rem;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  line-height: 1.6;
}

.stack:has(.stack-label) {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  align-items: baseline;
  column-gap: 0.5rem;
}

.project ul {
  margin-bottom: 0.75rem;
  padding-left: 1.1em;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.project li {
  margin-bottom: 0.25em;
}

.project li::marker {
  color: var(--color-text-muted);
}

/*
 * Screenshots. Without JS they are a swipeable row under the project text. With JS
 * (.is-drift) they drift slowly back and forth: the scroller below only supplies input
 * and the scroll length, interactive.js animates the images inside windows.
 * When there is room beside the text (.is-wide) the row becomes a strip across the whole
 * page, level with its project, with a window each side of the text column.
 */
.shots {
  margin: 1rem -1.5rem 0;
  padding: 0 1.5rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 1.5rem;
  scrollbar-width: none;
}

.shots::-webkit-scrollbar {
  display: none;
}

.shots-track {
  display: flex;
  gap: 0.75rem;
  width: max-content;
}

.shots img {
  flex: none;
  width: auto;
  height: 15rem;
  border: 1px solid var(--color-border);
  border-radius: 0.875rem;
  scroll-snap-align: start;
  user-select: none;
  -webkit-user-drag: none;
}

.shots.is-drift {
  position: relative;
  height: 15rem;
  padding: 0;
  overflow-y: hidden;
  scroll-snap-type: none;
  cursor: grab;
  user-select: none;
}

.shots.is-drift:active {
  cursor: grabbing;
}

.shots.is-drift:focus-visible {
  outline-offset: -2px;
}

/* The scroll length: the track below stays put while this stretches the scroller. */
.shots.is-drift::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: var(--shots-length, 100%);
  height: 1px;
}

.shots.is-drift .shots-track {
  position: sticky;
  left: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* One visible stretch of the strip. Its edges fade out over --fade-start / --fade-end,
   so an image never has a hard cut at the screen edge or next to the text. The stops
   follow smoothstep, so neither end of a fade shows as a line. */
.shots-window {
  --fade-start: 3rem;
  --fade-end: 3rem;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  overflow: hidden;
  mask-image: linear-gradient(
    90deg,
    rgb(0 0 0 / 0),
    rgb(0 0 0 / 0.07) calc(var(--fade-start) * 0.17),
    rgb(0 0 0 / 0.26) calc(var(--fade-start) * 0.33),
    rgb(0 0 0 / 0.5) calc(var(--fade-start) * 0.5),
    rgb(0 0 0 / 0.74) calc(var(--fade-start) * 0.67),
    rgb(0 0 0 / 0.93) calc(var(--fade-start) * 0.83),
    #000 var(--fade-start),
    #000 calc(100% - var(--fade-end)),
    rgb(0 0 0 / 0.93) calc(100% - var(--fade-end) * 0.83),
    rgb(0 0 0 / 0.74) calc(100% - var(--fade-end) * 0.67),
    rgb(0 0 0 / 0.5) calc(100% - var(--fade-end) * 0.5),
    rgb(0 0 0 / 0.26) calc(100% - var(--fade-end) * 0.33),
    rgb(0 0 0 / 0.07) calc(100% - var(--fade-end) * 0.17),
    rgb(0 0 0 / 0)
  );
}

.shots-pan {
  height: 100%;
  will-change: transform;
}

.shots-row {
  display: flex;
  gap: 1rem;
  width: max-content;
  height: 100%;
  padding: 0 1.5rem;
  will-change: transform;
}

.shots.is-drift img {
  height: 100%;
}

/* Pointing at a screenshot outlines it. */
@media (hover: hover) {
  .shots img {
    transition: border-color 0.3s ease;
  }

  .shots img:hover {
    border-color: var(--color-accent);
  }
}

/* A strip fades out as the page scrolls it off screen, and back in as it returns. */
@supports (animation-timeline: view()) {
  .shots {
    animation: shots-fade linear both;
    animation-timeline: view();
  }
}

@keyframes shots-fade {
  entry 0% {
    opacity: 0;
  }

  entry 100%,
  exit 0% {
    opacity: 1;
  }

  exit 100% {
    opacity: 0;
  }
}

/* Centered on its project by `top` rather than a transform, which the fade above would
   not see. */
.shots.is-wide {
  position: absolute;
  top: calc(50% - max(50% - 1.625rem, 10rem));
  height: max(calc(100% - 3.25rem), 20rem);
  margin: 0;
}

/* Long fades at the screen edges, short ones where the windows meet the text. */
.shots.is-wide .shots-window {
  --fade-start: min(10rem, 35%);
  --fade-end: min(5rem, 20%);
}

.shots.is-wide .shots-window + .shots-window {
  --fade-start: min(5rem, 20%);
  --fade-end: min(10rem, 35%);
}

.project:has(.is-wide) > :not(.shots) {
  position: relative;
  z-index: 1;
}

@media (max-width: 639px) {
  .project-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .project-when {
    padding-left: 0;
    border-left: 0;
  }

  .project-links {
    margin-left: 0;
  }
}
