/* The stage: the same cards, laid out as a game's stage-select screen.
   Nothing here applies unless boot.js put class "stage" on <html>. */
.temple { --w-bg: #351c1c; --w-fg: #f7e7cd; --w-ac: #e1c198; }
.life { --w-bg: #e8ece7; --w-fg: #1e2328; --w-ac: #32634b; }
.tofu { --w-bg: #f6efe1; --w-fg: #2b1f18; --w-ac: #9b2a1f; }
.moto { --w-bg: #0e4636; --w-fg: #eef4ee; --w-ac: #ffd35c; }
.car { --w-bg: #f2a93b; --w-fg: #102f3b; --w-ac: #5a3300; }
.clay { --w-bg: #05695a; --w-fg: #f6f7f1; --w-ac: #ffd358; }
.hoop { --w-bg: #102f3b; --w-fg: #f6f7f1; --w-ac: #ff9a4a; }
.letgo { --w-bg: #c8cfb9; --w-fg: #1c241b; --w-ac: #34502b; }
.lift { --w-bg: #f2b705; --w-fg: #1d2a2a; --w-ac: #634400; }
.tuktuk { --w-bg: #1757ad; --w-fg: #f8f5ec; --w-ac: #ffd35c; }
.dog { --w-bg: #5b3a8c; --w-fg: #fbf8ff; --w-ac: #ffc94d; }
.airboat { --w-bg: #ff6a13; --w-fg: #1d2a2a; --w-ac: #4a1a00; }
.boar { --w-bg: #2d6624; --w-fg: #f7f9f0; --w-ac: #ffd84a; }
.drone { --w-bg: #c6e03a; --w-fg: #1d2a2a; --w-ac: #4d5c00; }

html.stage { --s-bg: #351c1c; --s-fg: #f7e7cd; --s-ac: #e1c198; --s-peek: 44px; }   /* --s-peek: what shows of the list under the stage */
html.stage .masthead { position: absolute; top: 0; left: 0; right: 0; z-index: 4; color: var(--s-fg); pointer-events: none; transition: color .45s ease; }
html.stage .masthead .eyebrow { color: var(--s-ac); transition: color .45s ease; }
html.stage .wordmark span { color: var(--s-ac); transition: color .45s ease; display: inline-block; }
/* The first page of a visit opens with the words coming in (main.ts). Until the script is there to bring them in
   they stay out of sight; boot.js takes the class off again if the script does not come. */
html.stage.boot .wordmark, html.stage.boot .intro, html.stage.boot .project-content, html.stage.boot .all-head a { opacity: 0; }
html.stage .works { position: relative; display: block; height: calc(100svh - var(--s-peek)); min-height: calc(560px - var(--s-peek)); overflow: hidden; background: var(--s-bg); color: var(--s-fg); touch-action: pan-y; -webkit-user-select: none; user-select: none; }
html.stage .stage-wipe { position: absolute; inset: 0; z-index: 0; clip-path: circle(0% at 100% 60%); }
html.stage .stage-num { position: absolute; z-index: 0; top: 74px; left: 0; right: 0; color: var(--s-ac); opacity: .17; font-size: 62vw; font-weight: 800; line-height: .8; letter-spacing: -.05em; text-align: center; font-variant-numeric: tabular-nums; pointer-events: none; transition: color .45s ease; }
html.stage .stage-num span { display: inline-block; }
html.stage .stage-canvas { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; opacity: 0; pointer-events: none; transition: opacity .3s ease; }
html.stage .works.has-3d .stage-canvas { opacity: 1; }
html.stage .stage-cover { position: fixed; inset: 0; z-index: 6; clip-path: circle(0% at 50% 80%); pointer-events: none; }

html.stage .project { position: absolute; inset: 0; z-index: 2; display: block; background: none; color: var(--w-fg); visibility: hidden; pointer-events: none; }
html.stage .works:not(.live) .project:first-of-type, html.stage .project.is-active { visibility: visible; }
html.stage .project:focus-visible { outline: none; }
html.stage .project:focus-visible .destination { outline: 3px solid var(--w-fg); outline-offset: 4px; }

/* The zone the page keeps free for the 3D scene. */
html.stage .project .scene, html.stage .stage-load { position: absolute; top: 64px; left: 0; right: 0; bottom: 318px; }
html.stage .project .scene { height: auto; padding: 0; background: none; display: flex; align-items: center; justify-content: center; overflow: visible; }
/* The work's own picture stands there only if the scene cannot come (main.ts sets no-3d). Until then it has no box,
   and a lazy picture without a box is not fetched: a phone on mobile data does not pay for pictures nobody sees. */
html.stage .works:not(.no-3d) .scene img { display: none; }
html.stage .works.no-3d .scene img { animation: stage-fade .4s ease backwards; }
@keyframes stage-fade { from { opacity: 0; } }

/* While the scene is on its way, a mark stands where it will land: the wordmark's dot hopping on a turning ring.
   It is in the page from the first paint and moves by transform and opacity only, which the compositor plays, so it
   keeps moving while the script is busy building the scenes. main.ts takes it out once the scene (or picture) is up. */
html.stage .stage-load { display: block; z-index: 1; pointer-events: none; color: var(--s-fg); transition: opacity .28s ease, transform .28s ease; animation: stage-fade .3s ease backwards; }
html.stage .works.has-3d .stage-load, html.stage .works.no-3d .stage-load { opacity: 0; transform: scale(.8); }
html.stage .stage-load .mark { position: absolute; left: 50%; top: 58%; width: 0; height: 0; }   /* the point on the floor under the dot */
html.stage .stage-load .floor { position: absolute; left: -84px; top: -84px; width: 168px; height: 168px; transform: scaleY(.36); }   /* a circle seen from above and to the side */
html.stage .stage-load svg { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 4; stroke-linecap: round; stroke-dasharray: 13 19.11; opacity: .45; animation: load-turn 7s linear infinite; }
html.stage .stage-load .shade { position: absolute; inset: 24%; border-radius: 50%; background: radial-gradient(closest-side, rgb(0 0 0 / .38), rgb(0 0 0 / .2) 55%, rgb(0 0 0 / 0)); animation: load-shade .4s cubic-bezier(.333, .667, .667, 1) infinite alternate; }
html.stage .stage-load .floor::after { content: ""; position: absolute; inset: 30%; border-radius: 50%; border: 4px solid currentColor; opacity: 0; animation: load-ripple .8s cubic-bezier(.2, .6, .4, 1) infinite; }   /* a ring spreads from each landing */
html.stage .stage-load .ball { position: absolute; left: -13px; top: -26px; width: 26px; height: 26px; animation: load-hop .4s cubic-bezier(.333, .667, .667, 1) infinite alternate; }
html.stage .stage-load .ball::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--s-ac); transform-origin: 50% 100%; animation: load-squash .8s linear infinite; }
html.stage .stage-load span { position: absolute; top: 50px; left: -90px; width: 180px; text-align: center; font-size: 12px; letter-spacing: .5em; text-indent: .5em; opacity: .66; }
@keyframes load-turn { to { transform: rotate(1turn); } }
@keyframes load-hop { to { transform: translateY(-58px); } }   /* up and back down the same curve: a thrown ball */
@keyframes load-ripple { 0% { transform: scale(.3); opacity: .5; } 70%, 100% { transform: scale(1.7); opacity: 0; } }
@keyframes load-shade { to { transform: scale(.6); opacity: .5; } }
@keyframes load-squash { 0%, 100% { transform: scale(1.3, .72); } 9%, 91% { transform: scale(.9, 1.12); } 26%, 74% { transform: none; } }
html.stage .project .scene img { position: static; inset: auto; width: min(80%, 400px); height: auto; max-height: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 18px; transform: none; transition: none; }
html.stage .life .scene img { aspect-ratio: 1056 / 384; width: min(88%, 520px); border-radius: 10px; }

html.stage .project-content { display: block; position: absolute; left: 0; right: 0; bottom: 0; flex: none; padding: 0 6% calc(84px + env(safe-area-inset-bottom)); pointer-events: auto; }
html.stage .project-index { margin-bottom: 8px; font-size: 11px; }
html.stage h2 { margin-bottom: 10px; font-size: clamp(40px, 11.6vw, 60px); white-space: nowrap; }
html.stage .life h2 { font-size: clamp(38px, 10.6vw, 58px); }
html.stage h2 .ch { display: inline-block; will-change: transform; }
html.stage .description { font-size: 14px; line-height: 1.75; }
html.stage .destination { margin-top: 18px; padding: 0 8px 0 24px; height: 56px; border: 0; border-radius: 28px; background: var(--w-fg); color: var(--w-bg); font-size: 13px; letter-spacing: .04em; justify-content: flex-start; }
html.stage .destination::before { content: "開始"; margin-right: auto; font-size: 17px; font-weight: 650; letter-spacing: .28em; }
html.stage .destination .arrow { display: grid; place-items: center; width: 40px; height: 40px; margin-left: 12px; border-radius: 50%; background: var(--w-bg); color: var(--w-fg); font-size: 20px; }

@keyframes stage-go { 0%, 72%, 100% { transform: none; } 84% { transform: scale(1.14); } }
html.stage .project.is-active .destination .arrow { animation: stage-go 2.8s ease-in-out 1.8s infinite; }

html.stage .stage-nav { position: absolute; z-index: 3; left: 6%; right: 6%; bottom: calc(18px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; color: var(--s-fg); transition: color .45s ease; }
html.stage .stage-nav button { -webkit-appearance: none; appearance: none; display: grid; place-items: center; width: 44px; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
html.stage .stage-nav button:focus-visible { outline: 3px solid currentColor; outline-offset: -3px; }
html.stage .stage-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* The arrows and the count keep their size; the dots give way, so every dot and both arrows fit a 320px screen. */
html.stage .stage-nav > button, html.stage .stage-count { flex: none; }
html.stage .stage-dots { display: flex; flex: 0 1 auto; min-width: 0; align-items: center; }
html.stage .stage-dots button { width: 28px; min-width: 0; border-radius: 0; }
/* Fourteen dots of at least 17.5px (iOS's own page dots are 16pt apart; the arrows, a swipe and the list under the
   stage are the full-size ways round): on a phone the nav runs out until the arrows' icons line up with the words at
   6%, and the count gives way; it stays in the page for screen readers, which it tells where they are, and the big
   number behind the scene shows it anyway. Under 360px not even the dots fit: the count comes back in their place. */
@media (max-width: 499px) { html.stage .stage-nav { left: calc(6% - 11px); right: calc(6% - 11px); } }
html.stage .stage-dots i { display: block; width: 8px; height: 8px; border-radius: 4px; background: currentColor; opacity: .34; transition: width .35s ease, opacity .35s ease; }
html.stage .stage-dots button[aria-current="true"] i { width: 22px; opacity: 1; }
html.stage .stage-count { min-width: 44px; font-size: 11px; letter-spacing: .12em; text-align: center; font-variant-numeric: tabular-nums; }
/* after the count's own rule, so its min-width gives way too */
@media (min-width: 360px) and (max-width: 499px) { html.stage .stage-count { position: absolute; width: 1px; min-width: 0; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; } }
@media (max-width: 359px) { html.stage .stage-dots { display: none; } html.stage .stage-nav > button:last-of-type { order: 1; } }   /* ‹ 11 / 12 › */

/* Sound on or off (main.ts adds the button): under the masthead's words, flush with their right edge.
   --s-mast is the masthead's height, measured by main.ts. */
html.stage .stage-sound { -webkit-appearance: none; appearance: none; position: absolute; z-index: 5; top: calc(var(--s-mast, 84px) - 26px); right: calc(4.2% - 11px); display: grid; place-items: center; width: 44px; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--s-fg); opacity: .78; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: opacity .2s ease, color .45s ease; }
html.stage .stage-sound:focus-visible { outline: 3px solid currentColor; outline-offset: -3px; opacity: 1; }
html.stage .stage-sound svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
html.stage .stage-sound[aria-pressed="true"] .off, html.stage .stage-sound[aria-pressed="false"] .on { display: none; }
html.stage .stage-sound[aria-pressed="false"] { opacity: .5; }
@media (max-width: 699px) { html.stage .stage-sound { right: calc(6% - 11px); } }   /* the masthead's own narrow-screen padding (styles.css) */

@media (hover: hover) {
  html.stage .stage-sound:hover { opacity: 1; background: color-mix(in srgb, currentColor 14%, transparent); }
  html.stage .project:hover .scene img { transform: none; }
  html.stage .project-content:hover .arrow { transform: translate(2px, -2px); }
  html.stage .stage-nav button:hover { background: color-mix(in srgb, currentColor 14%, transparent); }
  html.stage .stage-dots button:hover { background: none; }
  html.stage .stage-dots button:hover i { opacity: .7; }
}
html.stage .project:active .scene img { transform: none; }

/* Two columns from 900px: below that (phones, tablets held upright) the words sit under the scene. */
@media (min-width: 900px) {
  html.stage { --s-peek: 48px; }
  html.stage .works { min-height: calc(620px - var(--s-peek)); }
  html.stage .stage-num { top: 13%; left: 42%; right: 2%; font-size: min(30vw, 56vh); }
  html.stage .project .scene, html.stage .stage-load { top: 12%; bottom: 10%; left: 42%; right: 2%; }
  html.stage .stage-load .mark { top: 62%; transform: scale(1.5); }
  html.stage .project .scene img { width: min(76%, 560px); }
  html.stage .project-content { left: 4.2%; right: auto; bottom: 16%; width: min(36%, 520px); padding: 0; }
  html.stage .project-index { margin-bottom: 14px; }
  html.stage h2, html.stage .life h2 { margin-bottom: 18px; font-size: min(5.6vw, 80px); }   /* six characters fit the column */
  html.stage .description { font-size: clamp(15px, 1.15vw, 18px); }
  html.stage .destination { margin-top: 30px; max-width: 420px; height: 60px; border-radius: 30px; }
  html.stage .destination .arrow { width: 44px; height: 44px; }
  html.stage .stage-nav { left: 4.2%; right: auto; bottom: 5%; gap: 6px; justify-content: flex-start; }
}
@media (max-width: 899px) and (max-height: 640px) {
  html.stage .project .scene, html.stage .stage-load { bottom: 296px; }
  html.stage .stage-load .mark { top: 62%; transform: scale(.8); }
  html.stage h2 { font-size: 38px; margin-bottom: 6px; }
  html.stage .description { line-height: 1.6; }
  html.stage .destination { margin-top: 12px; height: 50px; }
  html.stage .destination .arrow { width: 36px; height: 36px; }
}
@media (forced-colors: active) {
  html.stage .destination { border: 1px solid ButtonText; }
  html.stage .all-tile { outline: 1px solid CanvasText; }
}

/* ---- Under the stage, every work at once. The header strip is the bottom --s-peek of the first screen, in the
   stage's colours, so a visitor sees the page goes on; a turn's wipe carries on over it (.all-wipe, main.ts).
   main.ts adds a tile for each card, and the tiles' pictures once the list is on screen. */
html.stage .all-works { display: block; }
html.stage .all-head { position: relative; margin: 0; height: var(--s-peek); font-family: inherit; font-size: 12px; font-weight: 650; line-height: 1; letter-spacing: .26em; white-space: nowrap; background: var(--s-bg); color: var(--s-fg); transition: color .45s ease; }
html.stage .all-wipe { position: absolute; inset: 0; clip-path: circle(0px at 0px 0px); pointer-events: none; }
html.stage .all-head a { position: relative; display: flex; align-items: center; gap: 10px; height: 100%; padding: 0 6%; border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent); }
html.stage .all-head a:focus-visible { outline: 3px solid currentColor; outline-offset: -6px; }
html.stage .all-count { color: var(--s-ac); font-weight: 500; letter-spacing: .12em; font-variant-numeric: tabular-nums; transition: color .45s ease; }
html.stage .all-down { display: inline-block; margin-left: auto; font-size: 17px; font-weight: 400; letter-spacing: 0; animation: all-bob 1.8s ease-in-out 2.6s 3; }
@keyframes all-bob { 0%, 100% { transform: none; } 50% { transform: translateY(4px); } }   /* a few nods towards the list, then still */
html.stage .all-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
html.stage .all-tile { display: flex; flex-direction: column; min-width: 0; background: var(--w-bg); color: var(--w-fg); }
html.stage .all-tile:focus-visible { outline: 3px solid var(--w-fg); outline-offset: -6px; }
html.stage .all-pic { display: block; aspect-ratio: 16 / 10; overflow: hidden; background: color-mix(in srgb, var(--w-fg) 8%, var(--w-bg)); }
html.stage .all-pic img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s ease, transform .45s ease; }
html.stage .all-pic img.in { opacity: 1; }
html.stage .all-tile.life .all-pic { display: grid; place-items: center; background: #cbd9d0; }
html.stage .all-tile.life .all-pic img { width: 90%; height: auto; aspect-ratio: 1056 / 384; image-rendering: pixelated; }
html.stage .all-words { display: block; padding: 12px 8% 14px; }
html.stage .all-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 10px; line-height: 1.5; letter-spacing: .08em; color: var(--w-ac); }
html.stage .all-tile h3 { margin: 4px 0 10px; font-family: "Songti TC", "Noto Serif TC", PMingLiU, serif; font-weight: 600; font-size: clamp(17px, 5.2vw, 22px); line-height: 1.25; letter-spacing: .035em; white-space: nowrap; }
html.stage .all-tile.life h3 { letter-spacing: -.03em; }
html.stage .all-url { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 8px; border-top: 1px solid color-mix(in srgb, currentColor 22%, transparent); font-size: 11px; line-height: 1.5; letter-spacing: .04em; color: var(--w-ac); }
html.stage .all-url span { font-size: 15px; transition: transform .25s ease; }
@media (hover: hover) {
  html.stage .all-tile:hover .all-pic img { transform: scale(1.04); }
  html.stage .all-tile:hover .all-url span { transform: translate(2px, -2px); }
}
@media (min-width: 700px) {
  html.stage .all-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }   /* fourteen works: three full rows of four… */
  html.stage .all-tile h3 { font-size: clamp(17px, 2.2vw, 32px); }
  html.stage .all-words { padding: 16px 8% 18px; }
  html.stage .all-meta { font-size: clamp(11px, .75vw, 14px); }
  html.stage .all-url { font-size: clamp(12px, .8vw, 15px); }
}
@media (min-width: 900px) {
  html.stage .all-head { font-size: 13px; }
  html.stage .all-head a { padding: 0 4.2%; }
  html.stage .all-down { margin-left: 4px; }   /* beside the words, under the nav: one phrase */
}
/* …and a last row of two (only then): each across two columns, its picture beside its words, both as big as in any other
   tile, so the row is full */
@media (min-width: 700px) and (max-width: 1099px) {
  html.stage .all-tile:nth-child(4n+1):nth-last-child(2), html.stage .all-tile:nth-child(4n+2):nth-last-child(1) { grid-column: span 2; flex-direction: row; }
  html.stage .all-tile:nth-child(4n+1):nth-last-child(2) .all-pic, html.stage .all-tile:nth-child(4n+2):nth-last-child(1) .all-pic { flex: none; width: 50%; }
  html.stage .all-tile:nth-child(4n+1):nth-last-child(2) .all-words, html.stage .all-tile:nth-child(4n+2):nth-last-child(1) .all-words { flex: 1; min-width: 0; align-self: center; }
}
@media (min-width: 1100px) {
  html.stage .all-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }   /* two rows of seven from 1100px */
  html.stage .all-tile h3 { font-size: clamp(17px, 1.5vw, 28px); }   /* six characters fit a seventh of the page */
}
