/* ==========================================================================
   Work library (#/work) — brief §6
   An index, not a feed: one confident statement, a legend that explains the
   honesty labels, a ruled filter bar, then a strict three-column catalogue.
   Scope: .wl (page) · .wl-fallback (shared poster-failure layer, also used by .pj)
   ========================================================================== */

/* ---------- Header ---------- */
.wl-head { padding-block: clamp(32px, 3.8vw, 68px) clamp(36px, 3.8vw, 64px); }
.wl-head__grid { align-items: end; row-gap: 40px; }
.wl-head__title { grid-column: 1 / span 7; display: grid; gap: clamp(18px, 1.9vw, 28px); justify-items: start; }
.wl-head__count { color: var(--fg-2); padding-left: 12px; margin-left: 2px; border-left: 1px solid var(--line); }
.wl-h1 {
  font-size: var(--t-page); line-height: .88; font-weight: 740;
  letter-spacing: -0.04em; font-variation-settings: "wdth" 76; text-wrap: balance; margin-left: -0.04em;
}
.wl-h1 .swipe-word { padding-right: .02em; }
.wl-h1 .swipe { height: .2em; bottom: -.035em; }
.wl-intro { max-width: 24em; }

/* Legend: the three relationship labels, explained once, in plain language (brief §7.5) */
.wl-legend { grid-column: 9 / span 4; padding-bottom: 6px; }
.wl-legend__summary {
  display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; list-style: none;
  border-bottom: 1px solid var(--line); -webkit-tap-highlight-color: transparent;
}
.wl-legend__summary::-webkit-details-marker { display: none; }
.wl-legend__summary::marker { content: ""; }
.wl-legend__title { color: var(--fg); }
.wl-legend__glyphs { display: none; align-items: center; gap: 6px; color: var(--fg); }
.wl-legend__glyphs .status__glyph { display: block; }
.wl-legend__details:not([open]) .wl-legend__glyphs { display: inline-flex; }
.wl-legend__sign { position: relative; flex: none; width: 28px; height: 28px; margin-left: auto; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--ink) 26%, transparent); transition: background-color 160ms var(--ease), border-color 160ms var(--ease); }
.wl-legend__sign::before, .wl-legend__sign::after { content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 1.5px; margin: -.75px 0 0 -5px; background: currentColor; border-radius: 2px; transition: transform 200ms var(--ease); }
.wl-legend__sign::after { transform: rotate(90deg); }
.wl-legend__details[open] .wl-legend__sign::after { transform: rotate(0deg); }
.wl-legend__summary:hover .wl-legend__sign { border-color: var(--ink); background: var(--paper-2); }
.wl-legend__summary:focus-visible { outline-offset: 4px; }
.wl-legend__list { list-style: none; margin: 0; padding: 0; }
/* Label + note share a row while there's room (notes align on the label column) and wrap onto two rows when
   text is enlarged, instead of squeezing the note to a sliver (brief §12.2: no overflow at 200% text). */
.wl-legend__item {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.wl-legend__key { flex: 0 0 10.5rem; min-width: 0; max-width: 100%; } /* a pill a few px wider than the column runs into the gap, as before */
.wl-legend__item .status { transform: translateY(-1px); }
.wl-legend__note { flex: 1 1 14ch; min-width: min(14ch, 100%); font-size: .875rem; line-height: 1.45; color: var(--fg-2); text-wrap: pretty; }

/* ---------- Filter bar ---------- */
.wl-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 32px;
  padding-block: 16px; border-top: 1.5px solid var(--fg); border-bottom: 1px solid var(--line);
}
.wl-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; min-width: 0; }
.wl-filter__label { color: var(--fg); }
.wl-filter__list { position: relative; display: flex; flex-wrap: wrap; gap: 8px; }
.wl-chip {
  position: relative;
  display: inline-flex; align-items: center; gap: 9px; min-height: 44px; padding: 0 14px 0 13px;
  border-radius: var(--r-pill); border: 1px solid color-mix(in srgb, var(--ink) 26%, transparent); background: transparent; color: var(--ink);
  font-size: 1rem; font-weight: 560; line-height: 1; letter-spacing: -0.005em; white-space: nowrap;
  transition: background-color 160ms var(--ease), color 160ms var(--ease), border-color 160ms var(--ease);
}
.wl-chip__mark { flex: none; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid currentColor; transition: background-color 160ms var(--ease), border-color 160ms var(--ease); }
.wl-chip__count { font-family: var(--mono); font-size: .75rem; font-weight: 500; letter-spacing: .02em; color: var(--muted); font-variant-numeric: tabular-nums; transform: translateY(-.5px); }
.wl-chip:hover { border-color: var(--ink); background: var(--paper-2); }
.wl-chip:active { background: var(--paper-3); }
.wl-chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); cursor: default; }
.wl-chip[aria-pressed="true"] .wl-chip__mark { background: var(--tomato); border-color: var(--tomato); box-shadow: 0 0 0 2px color-mix(in srgb, var(--tomato) 28%, transparent); }
.wl-chip[aria-pressed="true"] .wl-chip__count { color: var(--muted-on-ink); }
.wl-chip:focus-visible { outline-offset: 2px; border-radius: var(--r-pill); }

.wl-status { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; margin-left: auto; }
.wl-count { font-family: var(--mono); font-size: var(--t-meta); letter-spacing: .02em; color: var(--fg-2); font-variant-numeric: tabular-nums; }
.wl-clear {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 4px; border: 0; background: none;
  font-size: .9375rem; font-weight: 600; color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .25em;
  text-decoration-color: color-mix(in srgb, currentColor 40%, transparent);
}
.wl-clear:hover { text-decoration-color: currentColor; }
.wl-clear .icon { width: 16px; height: 16px; }

/* ---------- Grid ---------- */
.wl-lib { padding-bottom: clamp(72px, 8vw, 136px); }
.wl .wl-grid {
  list-style: none; margin: 0; padding: clamp(32px, 3.4vw, 52px) 0 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: var(--gutter); row-gap: clamp(44px, 4.6vw, 76px);
  counter-reset: wl;
}
.wl-item { counter-increment: wl; min-width: 0; }
.wl-item--enter { animation: rise-sm 380ms var(--ease-out) both; animation-delay: calc(var(--enter-i, 0) * 45ms); }

/* catalogue numbering follows the visible order, so it re-flows with the filter */
.wl-item .work-card__brand { display: flex; align-items: baseline; gap: 10px; }
.wl-item .work-card__brand::before {
  content: counter(wl, decimal-leading-zero); content: counter(wl, decimal-leading-zero) / "";
  flex: none; color: var(--fg); font-weight: 500; padding-right: 10px; border-right: 1px solid var(--line);
}
.wl-item .work-card__title { font-size: clamp(1.25rem, 1.12rem + .3vw, 1.4375rem); }
.wl-item .work-card__meta .meta { text-wrap: pretty; }
.wl-item .work-card { gap: 16px; }

/* ---------- Closing tile: fills the last row's gap (never numbered, never filtered) ---------- */
.wl-invite { min-width: 0; }
.wl-invite__link {
  position: relative; display: flex; flex-direction: column; gap: 14px; aspect-ratio: 4 / 5; padding: clamp(20px, 2.2vw, 32px);
  border-radius: var(--r-media); text-decoration: none; color: var(--ink);
  border: 1.5px dashed color-mix(in srgb, var(--ink) 34%, transparent);
  background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--ink) 3.5%, transparent) 0 1px, transparent 1px 11px);
  transition: background-color 200ms var(--ease), color 200ms var(--ease), border-color 200ms var(--ease);
}
.wl-invite__label { color: var(--fg); }
.wl-invite__title {
  margin-top: auto; font-size: clamp(1.75rem, 1.2rem + 1.5vw, 2.625rem); line-height: 1.02; font-weight: 730;
  letter-spacing: -0.026em; font-variation-settings: "wdth" 80; text-wrap: balance; max-width: 11em;
}
.wl-invite__text { font-size: var(--t-small); line-height: 1.45; color: var(--fg-2); max-width: 22em; transition: color 200ms var(--ease); }
.wl-invite__cta { display: inline-flex; align-items: center; gap: 10px; font-weight: 620; font-size: 1.0625rem; padding-top: 16px; margin-top: 6px; border-top: 1px solid currentColor; }
.wl-invite__cta .icon { width: 18px; height: 18px; margin-left: auto; transition: transform 160ms var(--ease); }
.wl-invite__link:hover { background: var(--ink); color: var(--paper); border-color: var(--ink); border-style: solid; }
.wl-invite__link:hover .wl-invite__label, .wl-invite__link:hover .wl-invite__text { color: var(--muted-on-ink); }
.wl-invite__link:hover .wl-invite__cta .icon { transform: translate(2px, -2px); }
.wl-invite__link:active { transform: scale(.995); }
.wl-invite__link:focus-visible { outline-offset: 4px; border-radius: var(--r-media); }

/* ---------- Card media states (shared by .wl and .pj) ---------- */
.wl .work-card__media::before, .pj .work-card__media::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0; transition: opacity 240ms var(--ease);
  background: linear-gradient(105deg, transparent 30%, rgba(244,240,231,.07) 46%, rgba(244,240,231,.12) 50%, rgba(244,240,231,.07) 54%, transparent 70%) 0 0 / 260% 100% no-repeat, var(--ink-2);
}
.wl .work-card__media.is-loading::before, .pj .work-card__media.is-loading::before { opacity: 1; animation: wl-sheen 1.3s linear infinite; }
@keyframes wl-sheen { from { background-position: 130% 0, 0 0; } to { background-position: -130% 0, 0 0; } }

/* preview playing: say so, and that it's muted */
.wl .work-card__media::after, .pj .work-card__media::after {
  content: "Muted preview"; position: absolute; z-index: 3; left: 12px; top: 12px; padding: 5px 8px 5px 22px; border-radius: 3px;
  font-family: var(--mono); font-size: .6875rem; letter-spacing: .04em; color: var(--paper); background: rgba(23,23,22,.62);
  opacity: 0; transform: translateY(-3px); transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}
.wl .work-card__media.is-previewing::after, .pj .work-card__media.is-previewing::after { opacity: 1; transform: none; }
.wl .work-card__media .work-card__play, .pj .work-card__media .work-card__play { transition: background-color 160ms var(--ease), transform 200ms var(--ease-out); }
.wl .work-card__media:hover .work-card__play, .pj .work-card__media:hover .work-card__play { transform: translateY(-2px); }
.wl .work-card__media.is-previewing .work-card__ratio, .pj .work-card__media.is-previewing .work-card__ratio { opacity: 0; }
.wl .work-card__media::after, .pj .work-card__media::after { background-image: radial-gradient(circle at 11px 50%, var(--tomato) 0 3.5px, transparent 4px); }

/* poster failed: a designed placeholder instead of a black rectangle (brief §6.4) */
.wl .work-card__media.is-failed .frame__fit, .wl .work-card__media.is-failed .frame__ambient,
.pj .work-card__media.is-failed .frame__fit, .pj .work-card__media.is-failed .frame__ambient { visibility: hidden; }
.wl .work-card__failed, .pj .work-card__failed { display: none; }
.wl-fallback {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  gap: 6px; padding: 22px 24px 72px; color: var(--paper); text-align: left;
  background:
    repeating-linear-gradient(135deg, rgba(244,240,231,.045) 0 1px, transparent 1px 11px),
    radial-gradient(120% 80% at 20% 10%, var(--ink-3), var(--ink-2));
}
.wl-fallback__note {
  position: absolute; left: 12px; top: 12px; display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: .6875rem; letter-spacing: .04em; text-transform: uppercase; color: var(--muted-on-ink);
}
.wl-fallback__note .icon { width: 14px; height: 14px; }
.wl-fallback__brand { font-size: clamp(2rem, 1.4rem + 1.6vw, 2.75rem); line-height: .95; font-weight: 740; letter-spacing: -0.025em; font-variation-settings: "wdth" 80; }
.wl-fallback__product { font-family: var(--mono); font-size: var(--t-meta); letter-spacing: .02em; color: var(--muted-on-ink); }

/* ---------- Empty state (no matching results) ---------- */
.wl-empty { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px 48px; align-items: center; padding: clamp(32px, 4vw, 56px) 0 0; }
.wl-empty__art { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.wl-empty__art span { aspect-ratio: 4 / 5; border-radius: var(--r-media); border: 1.5px dashed color-mix(in srgb, var(--ink) 30%, transparent); background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--ink) 4%, transparent) 0 1px, transparent 1px 10px); }
.wl-empty__art span:nth-child(2) { transform: translateY(-14px); }
.wl-empty__copy { display: grid; gap: 14px; justify-items: start; max-width: 32em; }
.wl-empty__title { font-size: var(--t-sub); line-height: 1.15; font-weight: 680; letter-spacing: -0.015em; font-variation-settings: "wdth" 88; }
.wl-empty__text { color: var(--fg-2); }
.wl-empty__copy .btn { margin-top: 6px; }

/* ---------- Closing invitation ---------- */
.wl-end { padding-bottom: var(--section); }
.wl-end__grid { border-top: 1.5px solid var(--fg); padding-top: clamp(28px, 3vw, 44px); row-gap: 24px; align-items: start; }
.wl-end__title { grid-column: 1 / span 6; font-size: var(--t-section); line-height: 1.04; font-weight: 720; letter-spacing: -0.024em; font-variation-settings: "wdth" var(--wdth-display); text-wrap: balance; }
.wl-end__copy { grid-column: 8 / span 5; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; padding-top: 6px; }
.wl-end__copy em { font-style: normal; font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 1199px) {
  .wl-head__title { grid-column: 1 / span 7; }
  .wl-legend { grid-column: 8 / span 5; }
}
@media (max-width: 1023px) {
  .wl-head__title { grid-column: 1 / -1; }
  .wl-legend { grid-column: 1 / -1; }
  /* three columns across the tablet header; the rem-based minimum drops to fewer columns when text is enlarged */
  .wl-legend__list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); column-gap: var(--gutter); border-top: 0; }
  .wl-legend__item { gap: 10px; border-top: 1px solid var(--line); border-bottom: 0; padding: 14px 0 0; align-content: flex-start; }
  .wl-legend__key, .wl-legend__note { flex-basis: 100%; }
  .wl .wl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wl-end__title { grid-column: 1 / -1; }
  .wl-end__copy { grid-column: 1 / span 6; }
  .wl-empty { grid-template-columns: 1fr; }
  .wl-empty__art { max-width: 360px; }
}
@media (max-width: 767px) {
  .wl-head { padding-bottom: 20px; }
  .wl-head__grid { row-gap: 22px; }
  .wl-legend { padding-bottom: 0; }
  .wl-legend__summary { border-top: 1px solid var(--line); }
  .wl-legend__details:not([open]) .wl-legend__summary { border-bottom: 0; }
  .wl-legend__list { grid-template-columns: 1fr; }
  .wl-legend__item { gap: 4px 12px; border-top: 0; border-bottom: 1px solid var(--line); padding: 11px 0; }
  .wl-legend__key { flex-basis: 9.75rem; }
  .wl-legend__note { flex-basis: 14ch; font-size: .8125rem; }
  .wl-bar { padding-block: 12px 8px; row-gap: 4px; }
  .wl-filter { display: block; width: 100%; }
  .wl-filter__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* one swipeable rail that bleeds to the screen edges instead of three rows of chips */
  .wl-filter__list {
    flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none;
    margin-inline: calc(var(--margin) * -1); padding: 2px var(--margin) 4px; scroll-padding-inline: var(--margin);
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--margin), #000 calc(100% - 28px), transparent);
            mask-image: linear-gradient(90deg, transparent 0, #000 var(--margin), #000 calc(100% - 28px), transparent);
  }
  .wl-filter__list::-webkit-scrollbar { display: none; }
  .wl-chip { flex: none; scroll-snap-align: start; padding: 0 13px 0 12px; font-size: .9375rem; gap: 8px; }
  .wl-status { margin-left: 0; width: 100%; justify-content: space-between; min-height: 44px; }
  .wl-end__copy { grid-column: 1 / -1; }
  .wl-end__copy .btn { width: 100%; white-space: normal; text-align: center; line-height: 1.15; padding-block: 10px; }
}
@media (max-width: 559px) {
  .wl .wl-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 379px) {
  .wl-legend__item { gap: 6px; }
  .wl-legend__key, .wl-legend__note { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .wl .work-card__media.is-loading::before, .pj .work-card__media.is-loading::before { animation: none; background: var(--ink-2); }
  .wl-item--enter { animation: none; }
}
