/* How to use: the page where a visitor picks a tool, and the two guides.
   The three pages are one layout. The guide pages show the same two tools on top with the guide open
   below (the owner's note on the canvas: "下面这一长条点击后展开"). Loaded after site.css. */

/* Going from one of these pages to another, the browser carries the page across, and the guide
   unrolls from under the cat. Browsers that cannot do this simply load the next page, and so does
   every browser for someone who has asked for reduced motion. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}

.how {
  --inset: clamp(1.25rem, 5.5vw, 5rem);
  --corner: clamp(1.75rem, 2.8vw, 2.5rem);

  /* A page shorter than the window keeps its footer at the bottom of the window. Only the chooser on a tall
     screen is that short: its first screen stops growing at 50rem (below), and the footer used to end there,
     with empty black under it (found 2026-11-30, when the owner asked "页脚怎么悬空了"). Nothing else moves. */
  display: flex;
  flex-direction: column;
}

.how > .site-footer { margin-block-start: auto; }

/* light in the two upper corners of the first screen, as on the product page */
.how::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%);
}

/* ---- the first screen: headline and the two tools on the left, the cat on the right ---- */

.how-pick {
  /* the width of the cat's head: every part of the cat is measured in it */
  --cat: clamp(13.5rem, 30.5vw, 27.5rem);

  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  column-gap: clamp(1rem, 3vw, 3rem);
  /* the top of an open guide shows under it; on a very tall window it stops growing, so the cat
     does not end up far below the tools */
  min-block-size: min(calc(100svh - 4.6875rem - 8.75rem), 50rem);
  padding: clamp(2rem, 7vh, 4rem) var(--inset) 0;
  overflow-x: clip; /* the light behind the cat is wider than the page; the paws still hang below */
}

/* the floor the cat looks over; on a guide page the guide's top edge takes its place */
.how-pick::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  block-size: 1px;
  background: linear-gradient(90deg, transparent, var(--edge) 12%, var(--edge) 88%, transparent);
}

[data-open] .how-pick::after { opacity: 0; }

.how-choose {
  align-self: start;
  padding-block-end: clamp(2.5rem, 7vh, 4.5rem);
}

.how-title {
  margin: 0;
  max-inline-size: 7.4em;
  font-family: var(--serif);
  font-size: clamp(2.75rem, 1rem + 5vw, 5.5rem);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.how-doors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 20.625rem));
  gap: 1.25rem;
  margin-block-start: clamp(2rem, 7vh, 4rem);
}

/* A tool to pick: a field of colour. Its spaces are whole numbers of one unit: 1 between the name
   and its line, 2 down to the arrow, 2 round the edge. */
.how-door {
  --u: 1rem;

  position: relative;
  z-index: 2;
  display: grid;
  align-content: center;
  justify-items: start;
  min-block-size: 17rem;
  padding: calc(2 * var(--u)) 2.25rem;
  border-radius: 2rem;
  color: var(--black);
  text-decoration: none;
  transition: filter .2s var(--ease-out);
}

/* each colour runs a little lighter from its upper left and takes a blush of the other in its lower right */
.how-door-quick, .how-sheet-quick {
  background:
    radial-gradient(80% 62% at 100% 100%, rgb(190 216 243 / .28), rgb(190 216 243 / 0) 70%),
    linear-gradient(160deg, #ec9478, var(--coral) 50%, #cf6753);
}

.how-door-full, .how-sheet-full {
  background:
    radial-gradient(85% 65% at 100% 100%, rgb(220 111 82 / .5), rgb(220 111 82 / 0) 70%),
    linear-gradient(165deg, #d6e7f9, var(--blue) 46%, #c7c0cc);
}

.how-door:hover { filter: brightness(1.06); }
.how-door:focus-visible { outline-color: var(--black); outline-offset: -.5rem; }
.how-door ::selection, .how-sheet ::selection { background: var(--black); color: var(--white); }

.how-door-name {
  font-family: var(--serif);
  font-size: clamp(1.75rem, 1.2rem + 1.4vw, 2.25rem);
  line-height: 1.05;
  letter-spacing: -0.015em;
}

/* both lines keep the height of the longer one, so the two names and the two arrows stand level */
.how-door-line {
  min-block-size: 5lh;
  margin-block-start: var(--u);
  color: rgb(0 0 0 / .8);
  font-size: 1.0625rem;
  line-height: 1.45;
  text-wrap: pretty;
}

/* the mark that says "this opens": an arrow in a black disc, as on the owner's wireframe */
.how-door-go {
  display: grid;
  place-items: center;
  inline-size: 2.75rem;
  block-size: 2.75rem;
  margin-block-start: calc(2 * var(--u));
  border-radius: 50%;
  background: var(--black);
  color: var(--white);
}

.how-door-go svg { inline-size: 46%; block-size: 46%; }
.how-door:hover .how-door-go { translate: .375rem 0; }

/* the tool whose guide is open points down at it */
.how-door[aria-current] .how-door-go, .how-door[aria-current]:hover .how-door-go { rotate: 90deg; translate: 0 0; }

/* ---- the cat: the product page's cat, looking over the floor at the tool you point at ---- */

.how-cat {
  position: relative;
  justify-self: end;
  inline-size: calc(1.24 * var(--cat));
  block-size: calc(1.27 * var(--cat));
  margin-inline-end: calc(-.55 * var(--inset));
  pointer-events: none;
}

.how-light, .how-thought, .how-tail, .how-head, .how-paws { position: absolute; }

/* light rises behind it, as on the home page */
.how-light {
  z-index: 0;
  inset-inline-start: calc(.5 * var(--cat));
  inset-block-end: 0;
  inline-size: calc(3.1 * var(--cat));
  block-size: calc(1.2 * var(--cat));
  translate: -50% 0;
  background:
    radial-gradient(ellipse 34% 100% at 42% 100%, rgb(220 111 82) 0%, rgb(220 111 82 / .5) 42%, transparent 100%),
    radial-gradient(ellipse 34% 100% at 66% 100%, rgb(190 216 243 / .92) 0%, rgb(190 216 243 / .4) 42%, transparent 100%);
  filter: blur(22px);
}

/* The head stands on the floor; what is below the floor is cut off. how.js redraws it as it turns. */
.how-head {
  z-index: 1;
  inset-inline-start: calc(.5 * var(--cat));
  inset-block-end: 0;
  inline-size: var(--cat);
  block-size: auto;
  translate: -50% 0;
  overflow: hidden;
}

/* The paws hang over the floor, in front of it and of an open guide's top edge. */
.how-paws {
  z-index: 3;
  inset-inline-start: calc(.5 * var(--cat));
  inset-block-start: 100%;
  inline-size: var(--cat);
  block-size: auto;
  translate: -50% -19.2%;
  overflow: visible;
}

/* its tail, up from behind the floor beside it */
.how-tail {
  z-index: 1;
  inset-inline-start: calc(1.086 * var(--cat));
  inset-block-end: 0;
  inline-size: calc(.291 * var(--cat));
  block-size: calc(.514 * var(--cat));
  translate: -50% 0;
  overflow: hidden;
}

.how-tail path {
  fill: none;
  stroke: var(--black);
  stroke-width: 58;
  stroke-linecap: round;
  transform-box: view-box;
  transform-origin: 40% 100%;
}

/* What it is thinking of: a small fish in a cloud that drifts slowly over its head (the owner's
   idea). The cloud is drawn the way the cat is, as circles that melt into one soft shape. */
.how-thought {
  z-index: 1;
  inset-inline-start: calc(.264 * var(--cat));
  inset-block-end: calc(.541 * var(--cat));
  inline-size: calc(.818 * var(--cat));
  block-size: auto;
  overflow: visible;
}

.how-cloud, .how-puff { transform-box: fill-box; transform-origin: 50% 50%; }
/* The fish swims on the spot: its body swings a little about its head and its tail a little more
   about the place where it joins the body. Both points are in the fish's own drawing units. */
.how-fish { transform-box: view-box; transform-origin: 45px 75px; }
.how-fish-tail { transform-box: view-box; transform-origin: 143px 75px; }

@media (prefers-reduced-motion: no-preference) {
  .how-door-go { transition: translate .25s var(--ease-out), rotate .3s var(--ease-out); }
  .how-cloud { animation: how-drift 7s ease-in-out infinite alternate; }
  .how-puff-1 { animation: how-drift-small 7s ease-in-out -1.2s infinite alternate; }
  .how-puff-2 { animation: how-drift-small 7s ease-in-out -2.4s infinite alternate; }
  .how-fish { animation: how-swim 3.4s ease-in-out infinite alternate; }
  .how-fish-tail { animation: how-wag 1.7s ease-in-out infinite alternate; }
  .how-tail path { animation: sway 2.6s ease-in-out infinite alternate; }

  /* the guide unrolls from its top edge when you arrive from another of these pages */
  .how-sheet { view-transition-name: how-guide; }
  ::view-transition-new(how-guide):only-child { animation: how-unroll .55s var(--ease-out); }
}

@keyframes how-drift { from { transform: translate(-5px, 7px) rotate(-1.2deg); } to { transform: translate(6px, -8px) rotate(1.4deg); } }
@keyframes how-drift-small { from { transform: translate(-3px, 4px); } to { transform: translate(3px, -4px); } }
@keyframes how-swim { from { transform: translateY(2px) rotate(-3.5deg); } to { transform: translateY(-2px) rotate(3.5deg); } }
@keyframes how-wag { from { transform: rotate(-6deg); } to { transform: rotate(6deg); } }
@keyframes how-unroll { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0); } }

/* ---- the guide ---- */

.how-guide {
  position: relative;
  z-index: 2; /* in front of the cat's head and tail, behind its paws */
  margin-inline: var(--inset);
  padding-block-end: clamp(3.5rem, 11vh, 6rem);
  /* arriving at #guide leaves the cat's head in view above it */
  scroll-margin-block-start: clamp(10rem, 42vh, 24rem);
}

.how-sheet {
  border-radius: var(--corner);
  color: var(--black);
}

.how-sheet :focus-visible { outline-color: var(--black); }

/* Every space in the guide is a whole number of one unit (the owner's rule): 1 between a step's
   name and its text, 2 inside a group, 4 between steps and between groups, 7 round the edge. */
.how-sheet-in {
  --u: .75rem;

  display: grid;
  grid-template-columns: minmax(0, 25rem) minmax(0, 1fr);
  column-gap: clamp(2rem, 6.7vw, 6rem);
  padding: calc(7 * var(--u)) clamp(1.5rem, 6.7vw, 6rem);
}

.how-guide-head {
  display: grid;
  align-content: start;
  justify-items: start;
}

/* the padding makes the link a finger tall; the margins take the same space back */
.how-back {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  margin: -.75rem 0 -.75rem -.25rem;
  padding-block: .75rem;
  color: rgb(0 0 0 / .8);
  font-size: .9375rem;
  font-weight: 500;
  text-decoration: none;
}

.how-back svg { inline-size: 1.125rem; block-size: 1.125rem; }
.how-back:hover { color: var(--black); text-decoration: underline; text-underline-offset: 3px; }

.how-guide-title {
  margin: calc(4 * var(--u)) 0 0;
  font-family: var(--serif);
  font-size: clamp(2.25rem, 1.3rem + 2.5vw, 3.5rem);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.how-guide-lead {
  margin-block-start: calc(2 * var(--u));
  color: rgb(0 0 0 / .8);
  font-size: 1.1875rem;
  line-height: 1.45;
  text-wrap: pretty;
}

.how-guide-head .button { margin-block-start: calc(4 * var(--u)); }

.how-steps {
  display: grid;
  gap: calc(4 * var(--u));
  margin: 0;
  padding: 0;
  list-style: none;
}

.how-steps > li {
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr);
}

.how-steps .n, .how-steps h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.625rem, 1.2rem + 1vw, 2.125rem);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.015em;
}

.how-steps .n { color: rgb(0 0 0 / .62); }

.how-steps p {
  max-inline-size: 60ch;
  margin-block-start: var(--u);
  color: rgb(0 0 0 / .8);
  font-size: 1.125rem;
  line-height: 1.5;
  text-wrap: pretty;
}

.how-steps .button { margin-block-start: calc(2 * var(--u)); }

/* a file or folder name inside a sentence */
.how-sheet b { color: var(--black); font-weight: 600; }

.how-after {
  display: grid;
  gap: var(--u);
  margin-block-start: calc(4 * var(--u));
  padding-inline-start: 3.5rem;
  color: rgb(0 0 0 / .8);
  font-size: 1.125rem;
  line-height: 1.5;
}

/* ---- narrower screens: the tools first, the cat under them, the guide in one column ---- */

@media (max-width: 60rem) {
  .how-pick {
    --cat: clamp(11rem, 40vw, 17rem);
    grid-template-columns: minmax(0, 1fr);
    min-block-size: 0;
  }

  .how-choose { padding-block-end: clamp(1.5rem, 5vw, 2.5rem); }
  .how-cat { justify-self: center; margin-inline-end: 0; }

  .how-sheet-in {
    grid-template-columns: minmax(0, 1fr);
    row-gap: calc(4 * var(--u));
    padding: calc(5 * var(--u)) clamp(1.5rem, 6vw, 3rem);
  }
}

@media (max-width: 34rem) {
  .how-doors { grid-template-columns: minmax(0, 1fr); }
  .how-door { min-block-size: 0; padding-inline: 1.5rem; border-radius: 1.5rem; }
  .how-door-line { min-block-size: 0; }
  .how-steps > li { grid-template-columns: 2.5rem minmax(0, 1fr); }
  .how-after { padding-inline-start: 2.5rem; }
}

/* Windows high contrast and other forced palettes */
@media (forced-colors: active) {
  .how-door, .how-sheet { border: 1px solid CanvasText; }
}
