/* The Download page (/download). The owner's wireframe (下载.png) is the composition: the headline,
   the dried fish that is the Download button with the cat holding on to it, and the setup guide
   link. A stage light falls on the cat from above, onto a floor with the cat's shadow in it, and a
   few sparkles sit round the fish (all chosen by the owner on 2026-11-29). */

.dl {
  --u: clamp(.75rem, 1.6vh, 1rem);
}

/* light in the two upper corners, as on the other pages */
.dl::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  block-size: 100svh;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(44rem 28rem at 0% 0%, rgb(220 111 82 / .42), transparent 70%),
    radial-gradient(38rem 26rem at 100% 0%, rgb(190 216 243 / .24), transparent 70%);
}

/* one screen: on a tall screen the column stands in the middle of it */
.dl-main {
  display: grid;
  justify-items: center;
  align-content: center;
  min-block-size: calc(100svh - 4.6875rem);
  padding: clamp(1rem, 3vh, 2rem) var(--gutter) clamp(1.25rem, 3vh, 2rem);
  overflow-x: clip; /* the beam and the floor are wider than a phone; the page edge cuts them */
  text-align: center;
}

.dl-column {
  position: relative;
  display: grid;
  justify-items: center;
  inline-size: 100%;
}

.dl-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.5rem, 1rem + 4.6vw, 4.5rem);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.dl-lead {
  max-inline-size: 34rem;
  margin-block-start: calc(2 * var(--u));
  color: var(--text-quiet);
  font-size: clamp(1.0625rem, .95rem + .5vw, 1.3125rem);
  line-height: 1.4;
  text-wrap: balance;
}

/* ---- the stage: the fish and the cat, the light on them, the floor under them ---- */

.dl-stage {
  position: relative;
  display: grid;
  justify-items: center;
  inline-size: 100%;
  margin-block-start: calc(4 * var(--u));
}

.dl-scene {
  position: relative;
  z-index: 1;
  /* as wide as fits, so that on a laptop screen the whole page fits without scrolling */
  inline-size: min(100%, 34rem, 55svh);
}

.dl-scene svg { display: block; inline-size: 100%; block-size: auto; overflow: visible; }

/* A beam of light falls from above onto the cat, as a stage light does: the cat is black, and
   only light can show it on a black page. Coral at its heart, light blue at its edge. */
.dl-beam {
  position: absolute;
  z-index: -1; /* behind the headline and the text, which it lights */
  inset-inline-start: 50%;
  inset-block-end: 0;
  inline-size: min(64rem, 140%);
  block-size: 62rem;
  translate: -50% 0;
  pointer-events: none;
  background:
    conic-gradient(from 160deg at 50% 0%, transparent 0deg, rgb(220 111 82 / .62) 12deg, rgb(220 111 82 / .7) 20deg, rgb(220 111 82 / .62) 28deg, transparent 40deg, transparent 360deg),
    conic-gradient(from 155deg at 50% 0%, transparent 0deg, rgb(190 216 243 / .32) 8deg, transparent 18deg, transparent 32deg, rgb(190 216 243 / .32) 42deg, transparent 50deg, transparent 360deg);
  mask-image: linear-gradient(to bottom, transparent 0%, #000 62%, #000 100%);
  filter: blur(18px);
}

/* where the beam meets the floor, and the cat's shadow in it */
.dl-floor {
  position: relative;
  z-index: 0;
  inline-size: 100%;
  block-size: 1px;
  margin-block-start: calc(3 * var(--u));
}

.dl-floor::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 50%;
  inline-size: 100vw;
  block-size: 1px;
  translate: -50% 0;
  background: linear-gradient(90deg, transparent, var(--edge) 15%, var(--edge) 85%, transparent);
}

.dl-pool {
  position: absolute;
  inset-inline-start: 50%;
  inset-block-start: 0;
  inline-size: min(40rem, 120%);
  block-size: 5rem;
  translate: -50% -50%;
  background: radial-gradient(ellipse 50% 50% at 50% 50%, rgb(232 140 112 / .85), rgb(220 111 82 / .4) 45%, transparent 75%);
  filter: blur(10px);
}

/* the shadow moves with the cat's swing (download.js sets --sway) */
.dl-shadow {
  position: absolute;
  inset-inline-start: 50%;
  inset-block-start: 0;
  inline-size: min(15rem, 46%);
  block-size: 1.375rem;
  translate: calc(-50% + var(--sway, 0px)) -50%;
  border-radius: 50%;
  background: radial-gradient(ellipse 50% 50% at 50% 50%, rgb(0 0 0 / .75), rgb(0 0 0 / .35) 55%, transparent 72%);
  filter: blur(3px);
}

/* a few sparkles round the fish; they light up when the page opens and when the fish is pressed */
.dl-spark { transform-box: fill-box; transform-origin: 50% 50%; }
.dl-spark-white { fill: #fff; }
.dl-spark-blue { fill: var(--blue); }
.dl-spark-coral { fill: #f0a088; }

/* The fish is the Download button. */
.dl-fish { cursor: pointer; }
.dl-fish:focus-visible { outline: none; }
.dl-fish .dl-body { transition: filter .2s var(--ease-out); }
.dl-fish:hover .dl-body { filter: brightness(1.06); }
.dl-fill { fill: url(#dl-blue); }
.dl-blush { fill: url(#dl-blush-coral); }
.dl-label { fill: #000; font: 600 34px/1 var(--sans); letter-spacing: -0.005em; }
.dl-fish-mark { fill: none; stroke: #000; stroke-width: 7; stroke-linecap: round; }

/* its focus ring follows the fish: a black gap, then a white line */
.dl-ring { fill: none; stroke-linejoin: round; visibility: hidden; }
.dl-ring-gap { stroke: #000; stroke-width: 7px; }
.dl-ring-line { stroke: #fff; stroke-width: 11px; }
.dl-fish:focus-visible .dl-ring { visibility: visible; }

.dl-cat, .dl-paws { pointer-events: none; }
.dl-pull, .dl-eyes { transform-box: fill-box; }
.dl-eyes { transform-origin: 50% 50%; }

@media (prefers-reduced-motion: no-preference) {
  .dl-pull, .dl-all { transition: translate .25s var(--ease-out); }

  /* Pointing at the fish, the whole cat pulls itself up: it is not letting go. */
  .dl-scene:has(.dl-fish:hover, .dl-fish:focus-visible) .dl-pull { translate: 0 -7px; }
  /* pressed, fish and cat give a little */
  .dl-scene:has(.dl-fish:active) .dl-all { translate: 0 3px; }

  /* the sparkles light up once when the page opens, and again when the fish is pressed */
  .dl-spark { animation: dl-twinkle .8s var(--d, 0s) var(--ease-out) backwards; }
  .tug .dl-spark { animation: dl-twinkle-again .8s calc(var(--d, 0s) / 3) var(--ease-out) backwards; }
  .tug .dl-eyes { animation: dl-blink .32s .08s ease-in-out; }
}

/* two names for one movement, so that pressing the fish starts it again */
@keyframes dl-twinkle { 0% { scale: 0; rotate: -60deg; } 60% { scale: 1.25; rotate: 8deg; } 100% { scale: 1; rotate: 0deg; } }
@keyframes dl-twinkle-again { 0% { scale: 0; rotate: -60deg; } 60% { scale: 1.3; rotate: 8deg; } 100% { scale: 1; rotate: 0deg; } }
@keyframes dl-blink { 50% { scale: 1 .1; } }

/* ---- after the fish: the next step and the guide ---- */

.dl-next {
  max-inline-size: 34rem;
  margin-block-start: calc(4 * var(--u));
  color: var(--text-quiet);
  font-size: 1.0625rem;
  line-height: 1.5;
  text-wrap: balance;
}

/* the padding makes the link a finger tall (44 px); the margins take the same space back, so the
   text still stands one unit under the line above */
.dl-guide {
  margin-block: calc(var(--u) - .625rem) -.625rem;
  padding-block: .625rem;
  color: var(--white);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .25em;
}

.dl-guide:hover { text-decoration-thickness: 2px; }
