/* Works page: a curved row of work cards (CSS 3D, laid out by js/works.js) over the star sky (js/stars.js).
   Shares tokens, base type, brand, counter and chips with style.css. */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

html,
body {
  touch-action: pinch-zoom; /* style.css sets none for the homepage cloud */
}

/* the UI layer comes before the stage in the page (Tab order) but must paint above it;
   z-index on the children only, so .ui itself stays a non-stacking box and plus-lighter still blends */
.works-page .brand,
.works-page .counter,
.works-page .tags,
.works-page .hint {
  z-index: 1;
}

/* brand = link back to the homepage */
a.brand {
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
}

.brand-text .name,
.brand-text .role {
  display: block;
}

.brand .role {
  transition: color 300ms;
}

@media (hover: hover) {
  a.brand:hover .role {
    color: var(--accent);
  }
}

a.brand:focus-visible {
  outline-offset: 4px;
}

/* stage: the whole viewport takes drags; the row sits a little below the vanishing point,
   so the row is seen slightly from above and bends towards the viewer at both ends */
.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  perspective-origin: 50% 36%;
  cursor: grab;
  /* one finger turns the row (works.js); two fingers zoom, so small covers and labels can be enlarged */
  touch-action: pinch-zoom;
  -webkit-user-select: none;
  user-select: none;
}

.stage.is-dragging {
  cursor: grabbing;
}

.ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  transform-style: preserve-3d;
}

/* the filter switch fades the stage, never the ring: opacity below 1 on the preserve-3d ring flattens the arc */
.stage {
  transition: opacity 250ms;
}

.stage.is-switching {
  opacity: 0;
}

.card {
  position: absolute;
  top: calc(var(--ch, 200px) / -2);
  left: calc(var(--cw, 320px) / -2);
  width: var(--cw, 320px);
  height: var(--ch, 200px);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* mirror image under each card, fading out downwards (WebKit / Blink; Firefox simply shows none) */
  -webkit-box-reflect: below 14px linear-gradient(transparent 58%, rgba(255, 255, 255, 0.2));
}

/* off the visible arc (and before works.js places it): hidden from sight and pointer, still focusable,
   so Tab and screen readers reach every work; focusing one turns it to the centre */
.card.is-off {
  opacity: 0;
  pointer-events: none;
}

.card-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: #0b0b0d;
  color: inherit;
  text-decoration: none;
  transition: border-color 300ms, box-shadow 300ms;
}

.card-inner img,
.card-inner video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* keyboard focus: a white ring outside the card, distinct from the centred card's accent border
   (mouse and touch never show it; forced-colours mode recolours it) */
.card-inner:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
  border-color: var(--accent);
}

/* number pill (every card) */
.num {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  font-size: 11px;
  color: var(--text);
  transition: opacity 250ms;
}

.num::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
}

/* label (centred card): category, title, arrow when it opens something */
.label {
  position: absolute;
  right: 10px;
  bottom: 10px;
  left: 10px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--accent);
  color: #000;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 250ms, transform 250ms;
}

.label .cat {
  flex: none;
  font-size: 11px;
}

.label .title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.label .arrow {
  flex: none;
}

/* works.js measures the titles with the ellipsis off, so every engine reports the text at its full width */
.ring.is-measuring .label .title {
  text-overflow: clip;
}

/* a title that would be cut on the shared line (works.js sets .is-wrap): category above, title on its own line */
.label.is-wrap {
  flex-wrap: wrap;
  row-gap: 2px;
}

.label.is-wrap .cat {
  flex-basis: 100%;
}

.card.is-active .card-inner {
  border-color: var(--accent);
  box-shadow: 0 0 28px rgba(170, 136, 255, 0.35);
}

.card.is-active .label {
  opacity: 1;
  transform: none;
}

.card.is-active .num {
  opacity: 0;
}

@media (hover: hover) {
  .stage:not(.is-dragging) .card:not(.is-active) .card-inner:hover {
    border-color: rgba(255, 255, 255, 0.4);
  }
}

/* empty frames while there are no works yet */
.card.is-blank .card-inner {
  border-color: rgba(255, 255, 255, 0.12);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015) 60%);
}

.card.is-blank.is-active .card-inner {
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: none;
}

/* the hint fades out after the first drag / scroll */
.hint {
  position: absolute;
  right: 0;
  bottom: var(--bottom);
  left: 0;
  font-size: 11px;
  text-align: center;
  color: var(--muted);
  mix-blend-mode: plus-lighter;
  transition: opacity 600ms;
}

.hint.is-hidden {
  opacity: 0;
}

/* chips: one sideways-scrolling row at the bottom on narrow and short frames (classes from js/frame.js;
   below 600px of height the two chip rows would reach the top of the edge cards) */
.w-760 .tags,
.h-600 .tags {
  top: auto;
  right: 0;
  left: 0;
  bottom: calc(var(--bottom) - 3px);
  flex-wrap: nowrap;
  width: auto;
  /* 3px above and below: room for the focus outline inside the scrolling row */
  padding: 3px var(--right) 3px var(--left);
  overflow-x: auto;
  overscroll-behavior: contain;
  scroll-padding-inline: var(--left) var(--right); /* a chip reached with Tab scrolls fully into view */
  scrollbar-width: none;
  pointer-events: auto;
  touch-action: pan-x;
}

.w-760 .tags::-webkit-scrollbar,
.h-600 .tags::-webkit-scrollbar {
  display: none;
}

.w-760 .chip,
.h-600 .chip {
  flex: none;
}

.w-760 .hint,
.h-600 .hint {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .stage,
  .label,
  .num,
  .card-inner {
    transition: none;
  }
}

/* chips with no works are hidden by works.js once there are works */
.chip[hidden] {
  display: none;
}

/* js/works-data.js has an error: shown on the owner's local preview only (works.js) */
.data-error {
  position: fixed;
  right: var(--right);
  bottom: calc(var(--bottom) + 48px);
  left: var(--left);
  z-index: 2;
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  text-transform: none;
  color: #ff6b6b;
}

/* JavaScript off: the works cannot be shown */
.nojs {
  position: absolute;
  top: 50%;
  right: var(--right);
  left: var(--left);
  margin: 0;
  text-align: center;
  color: var(--muted);
}

@media (forced-colors: active) {
  .hint {
    mix-blend-mode: normal; /* see the forced-colours note in style.css */
  }

  .chip.is-active {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

/* the entrance (works.js): the ring is first seen from outside, so the backs of its near cards show too;
   the label and the numbers come in once it has landed */
.ring.is-intro .card {
  backface-visibility: visible;
  -webkit-backface-visibility: visible;
}

.ring.is-intro .label,
.ring.is-intro .num {
  opacity: 0;
}

/* the copies that close the ring during the entrance are only seen, never used */
.card.is-clone {
  pointer-events: none;
}

/* the work viewer (works.js): a work's detail images one under another over the dimmed page. It opens like the
   homepage's resume viewer (style.css has the keyframes): the backdrop fades in, the images rise into place while
   a light line scans down the view and reveals it, then the bar's items fade in one after another. */
.viewer {
  /* the width the work is shown at: about 1.1 times the frame's height (at most 1100px), so a screen holds a good
     part of the work, not a slice of it. Phones keep the full width (below): their text needs it */
  --sheet-w: min(1100px, var(--frame-h, 100dvh) * 1.1);
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 280ms ease;
}

.viewer[hidden] {
  display: none;
}

@media (pointer: coarse) {
  .h-600 .viewer {
    --sheet-w: 1200px;
  }
}

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

.viewer.is-closing {
  opacity: 0;
  transition-duration: 220ms;
}

.viewer-bar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 28px;
  padding: calc(var(--top) - 8px) var(--right) 4px var(--left);
  color: var(--text);
}

.viewer-heading {
  display: flex;
  flex: 1;
  gap: 14px;
  align-items: baseline;
  min-width: 0;
  margin: 0;
  white-space: nowrap;
}

.viewer-num {
  flex: none;
  color: var(--accent);
}

.viewer-title {
  min-width: 0;
  overflow: hidden;
  color: #fff;
  text-overflow: ellipsis;
}

.viewer-meta {
  flex: none;
  color: var(--muted);
}

.viewer-pdf,
.viewer-link,
.viewer-code,
.viewer-close {
  flex: none;
  padding: 8px 0;
  border: 0;
  background: none;
  color: #fff;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: opacity 300ms;
}

.viewer-pdf[hidden],
.viewer-link[hidden],
.viewer-code[hidden] {
  display: none;
}

/* the invitation code, right after the link it belongs to (half the bar's gap): 邀请码 molda7.
   The code keeps its own letter case (the page is set in capitals, a code may be case-sensitive); a dotted
   underline, as it copies rather than opens; "已复制" in its place for a moment after a click (works.js) */
.viewer-code {
  margin-left: -14px;
  text-decoration: none;
  white-space: nowrap;
}

.viewer-code-label {
  color: var(--muted);
}

/* the code and "已复制" share one grid cell: the button keeps the width of the wider one, so nothing in the bar
   moves while "已复制" shows */
.viewer-code-value {
  display: inline-grid;
  text-transform: none;
}

.viewer-code-value > span {
  grid-area: 1 / 1;
}

.viewer-code-text {
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  -webkit-user-select: all;
  user-select: all;
}

.viewer-code-done,
.viewer-code.is-copied .viewer-code-text {
  visibility: hidden;
}

.viewer-code.is-copied .viewer-code-done {
  visibility: visible;
}

/* narrow frames (phones): the bar's items closer together, so title, link, code and Close fit side by side; on the
   narrowest (a 4-inch iPhone) the link gives way first, ending in …, and the work's title keeps room for a short name */
.w-760 .viewer-bar {
  gap: 20px;
}

.w-760 .viewer-code {
  margin-left: -10px;
}

.w-760 .viewer-link {
  flex: 0 1 auto;
  min-width: 0;
}

.w-760 .viewer-heading {
  min-width: 8em;
}

/* the link says what it is, muted like the category, then where it goes, underlined:
   交互演示 -> VISENSE.JIANGYUXUAN.CN ↗ (works.js). A long one ends in … rather than pushing the bar off screen: the
   end of the address goes first, then the end of an explanation too long for the space. */
.viewer-link {
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.viewer-link-note {
  color: var(--muted);
}

.viewer-link-url {
  text-decoration: underline;
}

/* a narrow frame (the category is hidden there) without the PDF button has room for the whole link
   (280px; 40 % of an iPhone SE's frame is 248px) */
.w-760 .viewer-pdf[hidden] + .viewer-link {
  max-width: 50%;
}

/* frames up to 1100px wide that show the PDF button too: the link keeps only what it is, white and underlined like
   the buttons beside it (交互演示 ↗), so the work's title still fits on a phone; the address stays in its tooltip */
.w-1100 .viewer-pdf:not([hidden]) + .viewer-link {
  text-decoration: underline;
}

.w-1100 .viewer-pdf:not([hidden]) + .viewer-link .viewer-link-note {
  color: inherit;
}

.w-1100 .viewer-pdf:not([hidden]) + .viewer-link .viewer-link-sep,
.w-1100 .viewer-pdf:not([hidden]) + .viewer-link .viewer-link-host {
  display: none;
}

@media (hover: hover) {
  .viewer-pdf:hover,
  .viewer-link:hover,
  .viewer-code:hover,
  .viewer-close:hover {
    opacity: 0.7;
  }
}

/* narrow frames: the category and year give way to the title */
.w-760 .viewer-meta {
  display: none;
}

.viewer-body {
  position: relative;
  flex: 1;
  min-height: 0;
}

.viewer-scroll {
  position: absolute;
  inset: 0;
  overflow: auto; /* both ways: zoomed in, the work is wider than the view */
  overscroll-behavior: contain;
  /* at the bottom, room for the zoom buttons: the end of the work scrolls up clear of them */
  padding: 12px var(--right) calc(var(--bottom) + 48px) var(--left);
  outline: none;
  scrollbar-color: #555 transparent;
  scrollbar-width: thin;
}

/* phones and tablets: works.js moves and zooms the work by hand (one finger moves it, two fingers zoom it), so the
   browser neither scrolls a turned page along the screen's axes nor zooms the whole page */
.viewer.is-touch,
.viewer.is-touch .viewer-scroll {
  touch-action: none;
}

/* --zoom (works.js): 1 is the usual size, 100 %. Positioned, so that the names, notes and screenshots of a collection
   measure from its top (works.js, workPoint) */
.viewer-sheet {
  position: relative;
  width: calc(min(var(--sheet-w), 100%) * var(--zoom, 1));
  margin: 0 auto;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

/* until it has loaded, an image keeps the place of the first one loaded (works.js), or of a typical part */
.viewer-part {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: var(--part-ratio, 4 / 5);
  background: #141414;
  opacity: 0;
  transition: opacity 400ms ease;
}

.viewer-part.is-loaded {
  aspect-ratio: auto;
  background: none;
  opacity: 1;
}

.viewer-missing {
  margin: 0;
  padding: 24px;
  background: #1a0d0d;
  color: #ff6b6b;
  text-transform: none;
}

/* a collection (works.js, `items`: the Vibe Coding card): a block for each work in it. Its number, name and link
   on one line, set like the bar above (the link moves under the name when there is no room), what it is, then its
   screenshot. The blocks stand well apart; the shadow falls under each screenshot rather than around the text. */
.viewer-sheet.is-collection {
  box-shadow: none;
}

.viewer-item + .viewer-item {
  margin-top: 72px;
}

.viewer-item-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 28px;
}

.viewer-item-name {
  display: flex;
  gap: 14px;
  align-items: baseline;
  min-width: 0;
  margin: 0;
  padding: 8px 0;
  font: inherit;
}

.viewer-item-num {
  flex: none;
  color: var(--accent);
}

.viewer-item-title {
  min-width: 0;
  color: #fff;
  overflow-wrap: anywhere;
}

/* 交互演示 -> SPIDER.JIANGYUXUAN.CN ↗: the muted explanation and the underlined address of .viewer-link-note and
   .viewer-link-url above; a long one ends in … */
.viewer-item-link {
  max-width: 100%;
  overflow: hidden;
  padding: 8px 0;
  color: #fff;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 300ms;
}

.viewer-item-note {
  margin: 4px 0 16px;
  color: var(--muted);
  line-height: 1.6;
  text-transform: none;
}

.viewer-item-head + .viewer-part {
  margin-top: 8px;
}

.viewer-item .viewer-part {
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

@media (hover: hover) {
  .viewer-item-link:hover {
    opacity: 0.7;
  }
}

/* the scan line: a bright line at the bottom edge of a box as tall as the view and as wide as the work, with a
   soft trail above it */
.viewer-scan {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: min(var(--sheet-w) * var(--zoom, 1), (100% - var(--left) - var(--right)) * var(--zoom, 1), 100% - var(--left) - var(--right));
  margin: 0 auto;
  opacity: 0;
  background: linear-gradient(to bottom, rgba(170, 136, 255, 0) calc(100% - 90px), rgba(170, 136, 255, 0.24) calc(100% - 2px), #e8deff calc(100% - 2px));
  pointer-events: none;
}

.viewer.is-open .viewer-sheet {
  animation: resume-rise 700ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.viewer.is-open .viewer-scroll {
  animation: resume-reveal 820ms cubic-bezier(0.65, 0, 0.35, 1) both;
}

.viewer.is-open .viewer-scan {
  animation: resume-scan 820ms cubic-bezier(0.65, 0, 0.35, 1) both;
}

.viewer.is-open .viewer-bar > * {
  animation: resume-fade 420ms ease 160ms both;
}

.viewer.is-open .viewer-bar > :nth-child(2) {
  animation-delay: 220ms;
}

.viewer.is-open .viewer-bar > :nth-child(3) {
  animation-delay: 280ms;
}

.viewer.is-open .viewer-bar > :nth-child(4) {
  animation-delay: 340ms;
}

.viewer.is-open .viewer-bar > :nth-child(5) {
  animation-delay: 400ms;
}

/* zoom buttons over the bottom right of the work: − 100% + (works.js; the percentage goes back to 100 %) */
.viewer-zoom {
  position: absolute;
  right: var(--right);
  bottom: max(12px, var(--bottom) - 8px, var(--inset-bottom, 0px));
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.viewer-zoom button {
  min-width: 38px;
  height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: #fff;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  transition: color 200ms, opacity 200ms;
}

.viewer-zoom .viewer-zoom-reset {
  min-width: 58px;
  font-variant-numeric: tabular-nums;
}

/* at 30 % / 300 %: dimmed but still focusable (aria-disabled), so keyboard focus is never dropped. Only the sign is
   dimmed: with opacity, the focus ring would fade with it */
.viewer-zoom button[aria-disabled="true"] {
  color: rgba(255, 255, 255, 0.35);
  cursor: default;
}

/* a finger needs a bigger target */
@media (pointer: coarse) {
  .viewer-zoom button {
    position: relative;
    min-width: 44px;
    height: 44px;
  }

  .viewer-zoom .viewer-zoom-reset {
    min-width: 62px;
  }

  /* a button takes a finger anywhere in its box: drawn round, it would leave its corners, between two buttons, dead */
  .viewer-zoom button::after {
    content: "";
    position: absolute;
    inset: 0;
  }

  /* and a finger that lands just beside the buttons neither closes the work nor moves it. The buttons above are
     positioned (relative) so that they lie over this ring: otherwise it would take their taps as well */
  .viewer-zoom::before {
    content: "";
    position: absolute;
    inset: -12px;
    border-radius: inherit;
  }
}

/* forced colours: the theme's own colour for what cannot be used (it replaces the dimming above) */
@media (forced-colors: active) {
  .viewer-zoom button[aria-disabled="true"] {
    color: GrayText;
  }
}

@media (hover: hover) {
  .viewer-zoom button:not([aria-disabled="true"]):hover {
    color: var(--accent);
  }
}

.viewer.is-open .viewer-zoom {
  animation: resume-fade 420ms ease 400ms both;
}

.viewer.is-closing .viewer-sheet {
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  transition: opacity 220ms ease, transform 220ms ease;
}

/* WeChat: how to download (works.js); above the zoom buttons (46px high on a phone, and a gap) */
.viewer-hint {
  position: absolute;
  bottom: calc(max(12px, var(--bottom) - 8px, var(--inset-bottom, 0px)) + 58px);
  left: 50%;
  max-width: calc(100% - var(--left) - var(--right));
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  line-height: 1.6;
  text-transform: none;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 200ms, transform 200ms;
  pointer-events: none;
}

.viewer-hint.is-shown {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
  .viewer.is-open .viewer-sheet,
  .viewer.is-open .viewer-scroll,
  .viewer.is-open .viewer-bar > *,
  .viewer.is-open .viewer-zoom {
    animation: none;
  }

  .viewer-scan {
    display: none;
  }

  .viewer.is-closing .viewer-sheet {
    transform: none;
  }
}

@media (forced-colors: active) {
  .viewer-scan {
    display: none;
  }
}
