/* marckaiohasler.ch: the chapter "Selected work" and its document viewer.
   Only linked when scripts/build_work.py has written at least one document.
   It uses the tokens of site.css. Part 1 is the cards, part 2 the viewer. */

/* ------------------------------------------------------------ 1 cards */
.work-grid { margin-top: 2rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); gap: 2.5rem 2rem; }
.work-grid > li { display: flex; max-width: 31rem; }
.work-card { display: flex; flex-direction: column; width: 100%; color: inherit; text-decoration: none; border-radius: 6px; -webkit-tap-highlight-color: transparent; }
.work-card:focus-visible { outline-offset: 6px; border-radius: 6px; }

/* One stage for both formats: a portrait paper stands in it, a landscape deck lies in it. */
.work-cover { position: relative; aspect-ratio: 3 / 2; background: var(--surface); border-radius: 6px; overflow: hidden; transition: background 0.3s; }
.work-fit { position: absolute; inset: 10%; display: flex; align-items: center; justify-content: center; }
.work-sheet { position: relative; isolation: isolate; max-width: 100%; max-height: 100%; background: #fff; border-radius: 2px; box-shadow: 0 0 0 1px rgba(34, 48, 58, 0.08), 0 10px 22px -10px rgba(34, 48, 58, 0.4); transition: transform 0.5s var(--ease), box-shadow 0.5s var(--ease); }
.work-sheet.fit-h { height: 100%; }
.work-sheet.fit-w { width: 100%; }
.work-sheet img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 2px; }
/* the pages behind the first one */
.work-sheet::before, .work-sheet::after { content: ""; position: absolute; inset: 0; z-index: -1; background: #fff; border-radius: 2px; box-shadow: 0 0 0 1px var(--border-strong); transition: transform 0.5s var(--ease); }
.work-sheet::before { transform: translate(8px, 7px); }
.work-sheet::after { transform: translate(4px, 3.5px); }
.work-card:hover .work-cover, .work-card:focus-visible .work-cover { background: var(--petrol-tint); }
.work-card:hover .work-sheet, .work-card:focus-visible .work-sheet { transform: translate(-3px, -5px) rotate(-1.2deg); box-shadow: 0 0 0 1px rgba(34, 48, 58, 0.08), 0 20px 30px -14px rgba(34, 48, 58, 0.45); }
.work-card:hover .work-sheet::before, .work-card:focus-visible .work-sheet::before { transform: translate(13px, 10px) rotate(2.4deg); }
.work-card:hover .work-sheet::after, .work-card:focus-visible .work-sheet::after { transform: translate(7px, 5px) rotate(1.2deg); }

.work-kind { margin-top: 1rem; display: flex; align-items: center; gap: 0.625rem; font-family: var(--sans); font-size: 0.8125rem; font-weight: 600; line-height: 1.2; color: var(--petrol); }
.work-kind span { color: var(--muted); font-weight: 400; display: inline-flex; align-items: center; gap: 0.625rem; }
.work-kind span::before { content: ""; width: 0.1875rem; height: 0.1875rem; border-radius: 50%; background: var(--border-strong); }
.work-card h3 { margin-top: 0.4375rem; font-size: 1.4375rem; line-height: 1.2; text-wrap: balance; transition: color 0.2s; }
.work-card:hover h3 { color: var(--petrol); }
.work-ctx { margin-top: 0.3125rem; font-family: var(--sans); font-size: 0.875rem; line-height: 1.4; color: var(--muted); }
.work-sum { margin-top: 0.625rem; font-size: 1.0625rem; line-height: 1.45; max-width: 30em; }
.work-note { margin-top: 0.5rem; font-family: var(--sans); font-size: 0.8125rem; line-height: 1.4; color: var(--muted); }
.work-open { margin-top: auto; padding-top: 0.875rem; display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--sans); font-size: 0.9375rem; font-weight: 600; color: var(--petrol); }
.work-open::after { content: ""; width: 0.4375rem; height: 0.4375rem; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: rotate(45deg); transition: transform 0.25s var(--ease); }
.work-card:hover .work-open::after { transform: translateX(4px) rotate(45deg); }
/* only ever written into preview/ */
.work-flag { margin-top: 0.625rem; align-self: flex-start; font-family: var(--sans); font-size: 0.75rem; font-weight: 600; line-height: 1; padding: 0.3125rem 0.5rem; border-radius: 2px; background: var(--bronze-tint); color: var(--bronze); box-shadow: inset 0 0 0 1px #E6D8B0; }
.work-preview { margin-top: 1.25rem; max-width: 44em; padding: 0.625rem 0.875rem; border-radius: 4px; background: var(--bronze-tint); box-shadow: inset 0 0 0 1px #E6D8B0; font-family: var(--sans); font-size: 0.875rem; line-height: 1.4; color: var(--bronze); }

/* ------------------------------------------------------------ 2 viewer (built by work.js) */
.wv { position: fixed; inset: 0; z-index: 60; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); color: #fff; font-family: var(--sans); --pw: 0px; --ph: 0px; --z: 1; touch-action: pinch-zoom; overscroll-behavior: contain; -webkit-tap-highlight-color: transparent; outline: 0; }
.wv [hidden] { display: none !important; }
.wv-bg { position: absolute; inset: 0; z-index: -1; background: #141C22; }
.wv-head { grid-row: 1; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; min-height: 3.5rem; padding: 0.375rem 0.375rem 0.375rem 1rem; }
.wv-id { min-width: 0; }
.wv-title { font-family: var(--serif); font-size: 1.125rem; font-weight: 500; line-height: 1.25; color: #fff; }
.wv-ctx { font-size: 0.8125rem; line-height: 1.3; color: var(--muted-dark); }
.wv-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.wv-ctx { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wv-tools, .wv-left, .wv-nav { display: flex; align-items: center; gap: 0.25rem; flex: none; }

.wv-b { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; padding: 0; border: 0; border-radius: 50%; background: transparent; color: #fff; cursor: pointer; transition: background 0.15s, opacity 0.15s; }
.wv-b:hover, .wv-b[aria-pressed="true"] { background: rgba(255, 255, 255, 0.14); }
.wv-b:disabled { opacity: 0.28; cursor: default; background: transparent; }
.wv .wv-b:focus-visible, .wv .wv-th:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.wv-b svg { width: 1.375rem; height: 1.375rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.wv-dl { text-decoration: none; }
.wv-dl span { display: none; font-size: 0.875rem; font-weight: 600; white-space: nowrap; }

.wv-prog { grid-row: 2; height: 2px; background: rgba(255, 255, 255, 0.14); }
.wv-prog i { display: block; height: 100%; background: var(--petrol-light); transform: scaleX(0); transform-origin: left; transition: transform 0.4s var(--ease); }

/* The stage only scrolls while zoomed. The auto margin keeps a larger page reachable on every side. */
.wv-stage { grid-row: 3; grid-column: 1; display: flex; overflow: hidden; touch-action: pinch-zoom; overscroll-behavior: contain; cursor: zoom-in; }
.wv.is-zoom .wv-stage { overflow: auto; touch-action: pan-x pan-y pinch-zoom; }
.wv-view { flex: none; margin: auto; display: grid; }
.wv.is-zoom .wv-view { padding: 1rem; }
.wv-spread { grid-area: 1 / 1; display: flex; gap: 2px; }
.wv-page { position: relative; flex: none; width: calc(var(--pw) * var(--z)); height: calc(var(--ph) * var(--z)); background: #fff center / 100% 100% no-repeat; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 20px 50px -14px rgba(0, 0, 0, 0.6); }
/* in a spread no page throws its shadow across the spine, and the fold gets a soft shade instead */
.wv-page:first-child:nth-last-child(2) { clip-path: inset(-5rem 0 -5rem -5rem); }
.wv-page:nth-child(2) { clip-path: inset(-5rem -5rem -5rem 0); }
.wv-page:first-child:nth-last-child(2)::after, .wv-page:nth-child(2)::after { content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 7%; background: linear-gradient(to right, rgba(34, 48, 58, 0), rgba(34, 48, 58, 0.09)); pointer-events: none; }
.wv-page:nth-child(2)::after { right: auto; left: 0; transform: scaleX(-1); }
.wv-page img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
.wv-blank { background: none; box-shadow: none; }

.wv-grid { grid-row: 3; grid-column: 1; z-index: 3; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: 1.125rem 0.875rem; align-content: start; padding: 1.25rem 1rem 2rem; background: #141C22; touch-action: pan-y; overscroll-behavior: contain; }
.wv-th { display: grid; gap: 0.375rem; justify-items: center; padding: 0; border: 0; border-radius: 3px; background: none; color: var(--muted-dark); font-family: var(--sans); font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; }
.wv-th img { width: 100%; background: #fff; border-radius: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16); transition: transform 0.2s var(--ease), box-shadow 0.2s; }
.wv-th:hover img { transform: translateY(-2px); }
.wv-th[aria-current] { color: #fff; }
.wv-th[aria-current] img { box-shadow: 0 0 0 3px var(--petrol-light); }

.wv-foot { grid-row: 4; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; padding: 0.25rem 0.375rem calc(0.25rem + env(safe-area-inset-bottom, 0px)); }
.wv-count { min-width: 5.25rem; text-align: center; font-size: 0.875rem; font-weight: 600; font-variant-numeric: tabular-nums; }

@media (min-width: 40rem) {
  .wv-title { -webkit-line-clamp: 1; }
  .wv-dl { width: auto; gap: 0.5rem; padding: 0 0.875rem 0 0.75rem; border-radius: 999px; display: inline-flex; align-items: center; }
  .wv-dl span { display: inline; }
  .wv-grid { grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 1.5rem 1.25rem; padding: 2rem 2rem 3rem; }
}
@media (min-width: 56.25rem) {
  .wv-head { padding: 0.5rem 0.75rem 0.5rem 1.5rem; }
  .wv-foot { padding-left: 0.75rem; padding-right: 0.75rem; }
  /* previous and next move out to the sides of the stage */
  .wv-prev, .wv-next { position: absolute; top: 50%; width: 3.25rem; height: 3.25rem; margin-top: -1.625rem; background: rgba(20, 28, 34, 0.78); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16); }
  .wv-prev:hover, .wv-next:hover { background: rgba(20, 28, 34, 0.95); }
  .wv-prev:disabled, .wv-next:disabled { opacity: 0; }
  .wv-prev { left: 1.25rem; }
  .wv-next { right: 1.25rem; }
  .wv-prev svg, .wv-next svg { width: 1.5rem; height: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) {
  .work-card:hover .work-sheet, .work-card:focus-visible .work-sheet, .work-card:hover .work-sheet::before, .work-card:hover .work-sheet::after { transform: none; }
  .work-sheet::before { transform: translate(8px, 7px) !important; }
  .work-sheet::after { transform: translate(4px, 3.5px) !important; }
}
@media print { .wv { display: none !important; } }
