/* ==========================================================================
   07 Missions: infinite canvas archive + the project viewer (image / book / link)
   Same light HUD language: hairlines, bracket corners, mono labels, red accents.
   ========================================================================== */

main { overflow-x: clip; }            /* the full-bleed stage must not add a sideways scroll */

/* --------------------------------------------------------------------------
   Stage: sticky inside a tall wrapper; scrolling the wrapper dives the camera
   -------------------------------------------------------------------------- */
.archive {
  position: relative;
  width: 100vw;
  margin: clamp(36px, 6vh, 72px) 0 0 calc(50% - 50vw);
  height: calc(var(--vh) * 3.4);
  text-align: left;
}
.archive__stage { position: sticky; top: 0; height: var(--vh); overflow: hidden; background: var(--bg); }
.archive__gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: grab; -webkit-user-select: none; user-select: none; }
.archive.is-grabbing .archive__gl { cursor: grabbing; }
.archive.is-hovering:not(.is-grabbing) .archive__gl { cursor: pointer; }

/* soft edges so the stage melts into the page above and below */
.archive__veil {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(to bottom, var(--bg) 0, rgba(222,222,222,0) 14%, rgba(222,222,222,0) 86%, var(--bg) 100%),
    radial-gradient(ellipse 75% 70% at 50% 50%, rgba(222,222,222,0) 60%, rgba(222,222,222,.7) 100%);
}

/* HUD readouts in the corners */
.archive__hud { position: absolute; inset: 0; pointer-events: none; font: 500 10px/1.4 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }
.archive__hud > span { position: absolute; display: flex; align-items: center; gap: 8px; }
.archive__tl { left: var(--edge); top: calc(var(--wtop-b, 123px) + 16px); }
.archive__tl b { color: var(--red); font-weight: 500; }
.archive__tr { right: var(--edge); top: calc(var(--wtop-b, 123px) + 16px); font-variant-numeric: tabular-nums; }
.archive__bl { left: var(--edge); bottom: 26px; }
.archive__br { right: var(--edge); bottom: 26px; color: var(--red); }
.archive__tl::before, .archive__br::before { content: ""; width: 6px; height: 6px; background: var(--red); }

/* hover reticle: 4 red corners around the plane + a label chip */
.archive__reticle { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; opacity: 0; transition: opacity .18s; will-change: transform; }
.archive__reticle.is-on { opacity: 1; }
.archive__reticle i { position: absolute; width: 14px; height: 14px; border: 0 solid var(--red); }
.archive__reticle i:nth-child(1) { left: -7px; top: -7px; border-left-width: 2px; border-top-width: 2px; }
.archive__reticle i:nth-child(2) { right: -7px; top: -7px; border-right-width: 2px; border-top-width: 2px; }
.archive__reticle i:nth-child(3) { left: -7px; bottom: -7px; border-left-width: 2px; border-bottom-width: 2px; }
.archive__reticle i:nth-child(4) { right: -7px; bottom: -7px; border-right-width: 2px; border-bottom-width: 2px; }
.archive__chip { position: absolute; left: -7px; bottom: calc(100% + 12px); display: flex; flex-direction: column; gap: 3px; min-width: 150px; max-width: 280px; padding: 7px 10px 8px; background: rgba(17,17,17,.88); color: #fff; white-space: nowrap; }
.archive__chip b { font: 500 9px/1.2 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: #ff6a5c; }
.archive__chip em { overflow: hidden; text-overflow: ellipsis; font: 400 17px/1 var(--display); font-style: normal; text-transform: uppercase; letter-spacing: .02em; }

/* filters: in the top bar next to the view switch (.wtop) */
.archive__filters {
  position: relative;
  display: flex; gap: 2px; padding: 5px;
  overflow-x: auto; scrollbar-width: none;
  background: rgba(236,237,239,.74); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.archive__filters::-webkit-scrollbar { display: none; }
.archive__filters::before, .archive__filters::after { content: ""; position: absolute; width: 10px; height: 10px; border: 0 solid var(--red); pointer-events: none; }
.archive__filters::before { left: -6px; top: -6px; border-left-width: 2px; border-top-width: 2px; }
.archive__filters::after { right: -6px; bottom: -6px; border-right-width: 2px; border-bottom-width: 2px; }
.af {
  flex: none; display: inline-flex; align-items: flex-start; gap: 5px; padding: 10px 14px;
  border: 1px solid transparent; background: none; color: var(--ink-2); cursor: pointer;
  font: 500 10.5px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase;
  transition: color .2s, background-color .2s, border-color .2s;
}
.af sup { font-size: 8px; line-height: 1; letter-spacing: .06em; color: var(--ink-3); transition: color .2s; }
.af:hover, .af:focus-visible { color: var(--ink); border-color: var(--line); outline: none; }
.af[aria-pressed="true"] { background: var(--ink); color: #fff; }
.af[aria-pressed="true"] sup { color: #ff6a5c; }

/* loading readout */
.archive__loading { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; font: 500 10px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--ink-2); transition: opacity .4s; }
.archive__loading span { color: var(--red); }
.archive__loading.is-done { opacity: 0; }

/* index: hidden list for keyboards / screen readers; a plain grid if WebGL fails */
.archive__index { margin: 0; padding: 0; list-style: none; }
.archive__index:not(.sr-only) button:focus-visible { outline: 1px dashed var(--red); outline-offset: 3px; }
.archive.is-fallback { height: auto; }
.archive.is-fallback .archive__stage { position: relative; height: auto; overflow: visible; padding: calc(var(--wtop-b, 123px) + 40px) var(--edge) 160px; }
.archive.is-fallback .archive__gl, .archive.is-fallback .archive__veil, .archive.is-fallback .archive__reticle, .archive.is-fallback .archive__tr { display: none; }
.archive.is-fallback .archive__index { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; max-width: var(--sec-max); margin: 0 auto; }
.archive.is-fallback .archive__index button { display: grid; gap: 6px; width: 100%; padding: 0 0 10px; border: 1px solid var(--line); background: var(--panel); text-align: left; cursor: pointer; font: 500 10px/1.3 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.archive.is-fallback .archive__index img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.archive.is-fallback .archive__index span { padding: 0 10px; }
.archive.is-fallback .ai__title { font: 400 22px/1 var(--display); color: var(--ink); }
.archive.is-fallback .ai__no { color: var(--red); }
.archive__index li[hidden] { display: none; }
.archive__index.sr-only img { display: none; }

/* --------------------------------------------------------------------------
   work.html: the archive is the whole page (the wheel dives, nothing scrolls)
   -------------------------------------------------------------------------- */
html.archive-page, html.archive-page body { height: 100%; overflow: hidden; overscroll-behavior: none; }
.archive-page .nav { opacity: 1; padding-top: 12px; background: rgba(226, 227, 229, .72); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-bottom-color: var(--line); }
.archive--page { position: fixed; inset: 0; width: auto; height: auto; margin: 0; }
.archive--page .archive__stage { position: absolute; inset: 0; height: auto; }
.archive--page .archive__gl { touch-action: none; }
.archive--page .archive__veil { background: radial-gradient(ellipse 80% 75% at 50% 50%, rgba(222,222,222,0) 62%, rgba(222,222,222,.65) 100%); }
html.archive-page:has(.archive.is-fallback), html.archive-page:has(.archive.is-fallback) body { height: auto; overflow: auto; }
.archive--page.is-fallback { position: relative; inset: auto; }

/* --------------------------------------------------------------------------
   Viewer
   -------------------------------------------------------------------------- */
html.pv-open .nav { pointer-events: none; }
.pv { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; }
.pv[hidden] { display: none; }
.pv__backdrop { position: absolute; inset: 0; background: rgba(214,215,217,.56); -webkit-backdrop-filter: blur(18px) saturate(.85); backdrop-filter: blur(18px) saturate(.85); }
.pv__close {
  position: absolute; top: 18px; right: var(--edge); z-index: 3;
  display: inline-flex; align-items: center; gap: 10px; padding: 11px 14px;
  border: 1px solid var(--line); background: rgba(236,237,239,.85); color: var(--ink); cursor: pointer;
  font: 500 10.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase;
  transition: color .2s, border-color .2s;
}
.pv__close i { position: relative; width: 12px; height: 12px; }
.pv__close i::before, .pv__close i::after { content: ""; position: absolute; left: -2px; right: -2px; top: 50%; height: 1.5px; background: currentColor; transform: rotate(45deg); }
.pv__close i::after { transform: rotate(-45deg); }
.pv__close:hover, .pv__close:focus-visible { color: var(--red); border-color: var(--red); outline: none; }

.pv__body {
  position: relative; z-index: 2;
  width: min(1360px, calc(100vw - 2 * var(--edge))); height: min(calc(var(--vh) - 150px), 880px);
  margin-top: 40px;
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: clamp(18px, 2.4vw, 36px); align-items: center;
  pointer-events: none;
}
.pv__body > * { pointer-events: auto; }
.pv__media { position: relative; height: 100%; margin: 0; display: grid; place-items: center; pointer-events: none; }
.pv__img { display: block; max-width: none; background: #cfd2d6; box-shadow: 0 40px 90px -40px rgba(17,17,17,.45); pointer-events: auto; will-change: transform; }
.pv__img[hidden] { display: none; }
.pv__book { display: grid; place-items: center; width: 100%; height: 100%; pointer-events: auto; }
.pv__book[hidden] { display: none; }
.pv__flip { box-shadow: none; }   /* the empty half next to the cover must stay invisible */

.pv__info {
  position: relative; display: flex; flex-direction: column; gap: 12px; padding: 22px 22px 24px;
  background: rgba(236,237,239,.84); border: 1px solid var(--line);
}
.pv__info::before, .pv__info::after { content: ""; position: absolute; width: 12px; height: 12px; border: 0 solid var(--red); }
.pv__info::before { left: -6px; top: -6px; border-left-width: 2px; border-top-width: 2px; }
.pv__info::after { right: -6px; bottom: -6px; border-right-width: 2px; border-bottom-width: 2px; }
.pv__meta { display: flex; justify-content: space-between; gap: 10px; margin: 0; font: 500 9.5px/1.4 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }
.pv__no { color: var(--red); }
.pv__badge { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; margin: 2px 0 0; padding: 6px 9px; border: 1px solid rgba(253,31,15,.55); color: var(--red); font: 500 9.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; }
.pv__badge[hidden] { display: none; }
.pv__badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--red); animation: pv-blink 1.1s steps(2, start) infinite; }
@keyframes pv-blink { to { visibility: hidden; } }
.pv__title { margin: 0; font: 400 clamp(32px, 3.2vw, 52px)/.92 var(--display); text-transform: uppercase; color: var(--ink); overflow-wrap: anywhere; }
.pv__fields { margin: 0; font: 500 9.5px/1.6 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.pv__fields:empty, .pv__summary:empty { display: none; }
.pv__summary { margin: 0; font: 400 12.5px/1.65 var(--mono); color: var(--ink-body); }

.pv__nav { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.pv__nav[hidden] { display: none; }
.pv__prev, .pv__next { width: 40px; height: 34px; border: 1px solid var(--line); background: none; color: var(--ink); cursor: pointer; font: 500 14px/1 var(--mono); transition: color .2s, border-color .2s; }
.pv__prev:hover, .pv__next:hover, .pv__prev:focus-visible, .pv__next:focus-visible { color: var(--red); border-color: var(--red); outline: none; }
.pv__count { margin-left: 6px; font: 500 10px/1 var(--mono); letter-spacing: .14em; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.pv__cta { align-self: flex-start; margin-top: 4px; }
.pv__cta[hidden], .pv__note[hidden], .pv__hint[hidden] { display: none; }
.pv__hint { margin: -4px 0 0; font: 500 9px/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.pv__note { align-self: flex-start; margin: 4px 0 0; padding: 5px 9px; border: 1px dashed var(--ink-3); font: 500 9px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }

/* book: the spread takes the stage, the info becomes a bar under it */
.pv[data-type="book"] .pv__body, .pv[data-type="slides"] .pv__body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; align-items: stretch; }
.pv[data-type="book"] .pv__info, .pv[data-type="slides"] .pv__info { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 22px; padding: 14px 18px; }
.pv[data-type="book"] .pv__title, .pv[data-type="slides"] .pv__title { font-size: clamp(24px, 2.2vw, 34px); }
.pv[data-type="book"] .pv__summary, .pv[data-type="slides"] .pv__summary { display: none; }

@media (max-width: 860px) {
  .archive__bl { display: none; }
  .af { padding: 9px 11px; }
  .pv__close { top: 12px; }
  .pv__body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; height: calc(var(--vh) - 84px); margin-top: 48px; gap: 14px; align-items: stretch; }
  .pv__info { gap: 9px; padding: 14px 16px 16px; max-height: 44vh; overflow-y: auto; }
  .pv__title { font-size: 30px; }
  .pv__summary { font-size: 11.5px; }
}
@media (prefers-reduced-motion: reduce) {
  .pv__badge i { animation: none; }
}

/* viewer: loading readout while the full image / the book pages come in */
.pv__loading { position: absolute; left: 50%; top: 50%; z-index: 2; display: flex; align-items: center; gap: 12px; margin: 0; padding: 9px 12px; transform: translate(-50%, -50%); background: rgba(236,237,239,.9); border: 1px solid var(--line); font: 500 9.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); pointer-events: none; }
.pv__loading[hidden] { display: none; }
.pv__loading i { position: relative; width: 56px; height: 2px; overflow: hidden; background: rgba(17,17,17,.12); }
.pv__loading i::after { content: ""; position: absolute; inset: 0; background: var(--red); animation: pv-load 1s cubic-bezier(.45,0,.55,1) infinite; }
@keyframes pv-load { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .pv__loading i::after { animation: none; transform: none; } }

/* flip-book pages (HTML pages with lazy images) */
.pv__page { background: #fff; overflow: hidden; }
.pv__page img { display: block; width: 100%; height: 100%; object-fit: contain; -webkit-user-select: none; user-select: none; pointer-events: none; }

/* slides: one 16:9 page at a time; click right / left (or swipe) to move */
.pv[data-type="slides"] .pv__img { cursor: pointer; touch-action: none; }

/* confidential: the access-code form */
.pv__lock { display: grid; gap: 10px; margin: 4px 0 0; }
.pv__lock[hidden] { display: none; }
.pv__locklabel { font: 500 9.5px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--ink-2); }
.pv__lockrow { display: flex; gap: 10px; align-items: stretch; }
.pv__code { width: 9.5em; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 0; background: #fff; color: var(--ink); font: 500 18px/1 var(--mono); letter-spacing: .45em; text-align: center; outline: none; transition: border-color .2s; }
.pv__code::placeholder { color: var(--ink-3); letter-spacing: .2em; }
.pv__code:focus { border-color: var(--red); }
.pv__unlock { padding: 10px 18px; }
.pv__lockmsg { margin: 0; font: 500 9.5px/1.5 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.pv__lock.is-busy { opacity: .6; pointer-events: none; }
.pv__lock.is-wrong .pv__lockrow { animation: pv-shake .42s cubic-bezier(.36,.07,.19,.97); }
.pv__lock.is-wrong .pv__lockmsg { color: var(--red); }
.pv__lock.is-wrong .pv__code { border-color: var(--red); }
@keyframes pv-shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .pv__lock.is-wrong .pv__lockrow { animation: none; } }

/* --------------------------------------------------------------------------
   work.html top bar: the view switch (Space / Grid) and the filters, side by side.
   Fixed, in exactly the same place in both views. When the screen is too narrow
   the filters drop under the switch (and scroll sideways on a phone).
   --wtop-b (set by archive.js) is the bar's bottom edge: what sits under it follows it.
   -------------------------------------------------------------------------- */
.wtop {
  position: fixed; z-index: 45; left: 50%; top: 78px; transform: translateX(-50%);
  display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: 8px;
  width: max-content; max-width: calc(100vw - 2 * var(--edge));
}
.wview {
  flex: none; display: flex; align-items: stretch; gap: 2px; padding: 4px;
  background: rgba(236,237,239,.82); border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.wview__b {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 13px;
  border: 1px solid transparent; background: none; color: var(--ink-2); cursor: pointer;
  font: 500 10px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; transition: color .2s, background-color .2s, border-color .2s;
}
.wview__b:hover, .wview__b:focus-visible { color: var(--ink); border-color: var(--line); outline: none; }
.wview__b[aria-pressed="true"] { background: var(--ink); color: #fff; }
.wview__ico { position: relative; width: 11px; height: 11px; flex: none; }
.wview__ico--grid { background:
  linear-gradient(currentColor, currentColor) 0 0 / 4px 4px no-repeat, linear-gradient(currentColor, currentColor) 100% 0 / 4px 4px no-repeat,
  linear-gradient(currentColor, currentColor) 0 100% / 4px 4px no-repeat, linear-gradient(currentColor, currentColor) 100% 100% / 4px 4px no-repeat; }
.wview__ico--space { border: 1px solid currentColor; transform: rotate(45deg) scale(.85); }
.wview__ico--space::after { content: ""; position: absolute; inset: 3px; background: currentColor; }
.wtop .archive__filters { position: relative; left: auto; top: auto; transform: none; flex: 0 1 auto; min-width: 0; max-width: 100%; }
.wtop .af { padding: 10px 11px; letter-spacing: .12em; }
/* grid view: a band behind the bar so the cards scroll away under it (it stops at the nav) */
.is-grid .wtop::before { content: ""; position: absolute; z-index: -1; left: 50%; top: -12px; bottom: -12px; width: 100vw; transform: translateX(-50%); background: var(--bg); border-bottom: 1px solid rgba(17,17,17,.1); }

/* grid view: the page scrolls, the canvas is gone (and stops rendering) */
html.archive-page.is-grid { height: auto; overflow-x: hidden; overflow-y: auto; }
html.archive-page.is-grid body { height: auto; overflow: visible; }   /* the page scrolls on html, not on body */
.archive-page.is-grid .archive { display: none; }
.wgrid { position: relative; max-width: var(--sec-max); margin: 0 auto; padding: calc(var(--wtop-b, 123px) + 44px) var(--edge) 140px; text-align: center; }
.wgrid[hidden] { display: none; }
.wgrid .sec-sub b { color: var(--red); font-weight: 500; }
.wgrid__list { margin-top: 44px; }
.wgrid .mission[hidden] { display: none; }
.wgrid .mission__link { border: 0; padding: 0; margin: 0; background: none; cursor: pointer; }
.wgrid .mission__media img { background: #cfd2d6; }
.wgrid .mission__line { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wgrid .mission--locked .mission__tag { color: var(--red); border-color: rgba(253,31,15,.5); }
@media (max-width: 1439px) {   /* laptops: tighter buttons so the switch and the filters still fit on one line */
  .wtop .af { padding: 10px 8px; letter-spacing: .08em; }
  .wview__b { padding: 8px 10px; gap: 7px; letter-spacing: .12em; }
}
@media (max-width: 860px) {
  .wtop { top: 86px; }
}
@media (max-width: 640px) {
  .archive__hud .archive__tr { display: none; }   /* no room for the coordinates next to the file count */
}