/*
 * Zoey Made — Bubble's Secret Map.
 *
 * The progress surface: a small sheet of maker paper with a dotted pencil route running
 * through six marks, the count in words, an optional clue, and the offer to keep the lot
 * (DISCOVERY-006).
 *
 *   inc/discovery/map.php                 the markup, the positions, the words
 *   assets/js/discovery-map.js            opening, closing, progress, hints, save state
 *   this file                             the paper, the route, the marks, the cards
 *   components/discovery-object.css       the six drawings, which the map reuses whole
 *
 * ## Not a treasure map, and not a dashboard
 *
 * §19 rules out the pirate-map cliché — no tan parchment, no burnt edges, no X, no skulls —
 * and §16 and §69 rule out the other direction just as firmly: this is not a full game
 * screen, not an admin page and not a grid of panels with a meter across the top. What is
 * left is §18's brief, and it is what this file draws: near-white paper, a faint dot grid,
 * Ink linework, restrained pastel objects, and a pencil line that weaves rather than
 * measures.
 *
 * ## No meter, and no green
 *
 * There is no progress bar, ring, percentage or animated counter anywhere in this file, and
 * nothing turns success-green when it is found (§34, §71). Progress is told twice, both times
 * plainly: as a sentence — *3 of 6 secrets found* — and as objects that are there instead of
 * question marks.
 *
 * ## Nunito throughout
 *
 * §70 would allow Caveat for the clue, as a hint annotation. It is not used: the accent face
 * is 47.7 KB, it is currently fetched by no page on this site, and components/homepage.css
 * already declined it for two words on the busiest route with the note that it should earn
 * its place on something doing more work than one line. One hint sentence is not more work.
 * The handwritten feeling comes from the paper, the dot grid and the pencil route instead,
 * and it costs nothing.
 */

/* --- The sheet ---------------------------------------------------------------------- */

/*
 * A real `<dialog>`, so the focus trap, the Escape key and the inertness of the page behind
 * it are the platform's (§17, §80, §81). What this file has to do is undo the user-agent
 * panel — a dialog arrives with its own border, padding and background — and put the Zoey
 * Made surface in its place.
 *
 * `max-block-size` and not `block-size`: §84 rules out a fixed-height map panel, so the sheet
 * is exactly as tall as its contents until it runs out of screen and then scrolls. That is
 * what lets 200% text, WCAG text spacing and a long translation all simply make it taller.
 *
 * `dvh` rather than `vh`, because on a phone the browser chrome comes and goes and `vh` is
 * the tallest of those states — a panel sized to it is a panel whose close control is under
 * the address bar.
 */
.zoey-secret-map {
  --zoey-secret-map-gutter: var(--wp--preset--spacing--40);

  inline-size: min(34rem, calc(100vw - var(--zoey-secret-map-gutter) * 2));
  max-block-size: calc(100dvh - var(--zoey-secret-map-gutter) * 2);
  padding: 0;
  overflow-y: auto;
  border: 1px solid var(--wp--preset--color--border-soft);
  border-radius: var(--wp--custom--radius--large);
  background-color: var(--wp--preset--color--surface);
  box-shadow: var(--wp--preset--shadow--lifted);
  color: var(--wp--preset--color--ink);
  overscroll-behavior: contain;
}

/*
 * On a phone it is a sheet: full width inside the gutters and sitting on the bottom edge,
 * which §16 allows and which puts the whole panel in the reachable half of the screen. A
 * modal dialog is centred by `margin: auto`, so releasing the block-end margin is the whole
 * of it. The safe-area inset resolves to zero wherever it means nothing.
 */
@media (max-width: 47.999em) {
  .zoey-secret-map {
    --zoey-secret-map-gutter: var(--wp--preset--spacing--30);

    margin-block-end: calc(var(--zoey-secret-map-gutter) + env(safe-area-inset-bottom, 0px));
    border-end-start-radius: var(--wp--custom--radius--medium);
    border-end-end-radius: var(--wp--custom--radius--medium);
  }
}

/*
 * A wash rather than a blackout. The page behind stays legible, because the map is a place a
 * visitor stepped into for a moment and not a modal interruption they have to get past.
 */
.zoey-secret-map::backdrop {
  background-color: rgba(51, 47, 61, 0.45);
}

/*
 * The padded interior, and the container everything responsive in here answers to.
 *
 * A container query rather than a media query, for the reason the reveal card gives: the
 * question is how much room the map has, not how wide the screen is, and at 200% text a
 * 390 px phone leaves the field about a third of the `rem` width it had. That is the case the
 * linear fallback at the foot of this file is for, and only a container query in `rem` sees
 * it.
 */
.zoey-secret-map__paper {
  position: relative;
  padding: var(--wp--preset--spacing--50);
  container-type: inline-size;
  /*
   * `anywhere` rather than `break-word`, and it is the whole map rather than one paragraph.
   * Only `anywhere` also lowers an element's *minimum* content width, which is what stops a
   * long word setting a floor the panel cannot get under: at 200% text on a 320 px screen
   * "discoveries" is wider than the account card it sits in, and without this the card
   * overflowed and the sheet grew a horizontal scrollbar (§83, §84, §86). It changes nothing
   * at any ordinary text size — a word that fits is never broken.
   */
  overflow-wrap: anywhere;
}

@media (max-width: 47.999em) {
  .zoey-secret-map__paper {
    padding: var(--wp--preset--spacing--40);
  }
}

/*
 * `hidden` has to win.
 *
 * Almost everything in this file that the runtime shows and hides sets a `display` of its own
 * — a grid for the mystery mark, a flex row for the account actions — and a class selector
 * beats the user agent's `[hidden] { display: none }` on specificity. Without this rule the
 * attribute is set correctly, reads as hidden to a screen reader and to
 * `querySelectorAll('[hidden]')`, and is still on the screen: every unfound secret's drawing
 * would be sitting there in plain sight, which is the one thing §23 exists to prevent.
 *
 * One rule at the top of the file rather than an `&[hidden]` beside each of nine components,
 * because it is the same reason nine times.
 */
.zoey-secret-map [hidden] {
  display: none;
}

/* --- The head ----------------------------------------------------------------------- */

/*
 * Bubble, once, beside the title (§31, §32). She is the map's keeper — the character who hid
 * all this — and she appears here and nowhere else on the surface, because a Bubble beside
 * every object would cost her the thing that makes her worth putting anywhere.
 */
.zoey-secret-map__head {
  display: flex;
  align-items: center;
  gap: var(--wp--preset--spacing--30);
  /*
   * Room for the close control, expressed as the close control's own size rather than as a
   * spacing step that happens to be about right. At 200% text a fixed step stopped being
   * about right and the × sat on top of the title.
   */
  padding-inline-end: calc(2.75rem + var(--wp--preset--spacing--20));
}

img.zoey-secret-map__bubble {
  flex: none;
  /*
   * Pixels, and the same exception the reveal card documents: everything a visitor *reads* is
   * sized in rem so it grows with their text setting, and a decorative picture is not
   * something they are reading. In rem it would be 112 px at 200% text and would take the
   * width away from the words beside it.
   */
  inline-size: 48px;
  block-size: auto;
}

.zoey-secret-map__title {
  margin-block: 0;
  color: var(--wp--preset--color--ink);
  font-size: var(--wp--preset--font-size--card-title);
  font-weight: 700;
  line-height: 1.25;
}

/*
 * §21's secondary line, and §8's language. Secondary weight, secondary colour, no ring and no
 * bar — the sentence is the whole of the progress display, and §73 requires it to be real
 * readable text rather than something a screen reader has to infer from a picture.
 */
.zoey-secret-map__progress {
  margin-block: var(--wp--preset--spacing--10) 0;
  color: var(--wp--preset--color--ink-soft);
  font-size: var(--wp--preset--font-size--body-small);
  font-weight: 600;
  line-height: 1.4;
}

/*
 * The close control (§17, §82). A real 44 x 44 target in the corner, out of the head's flow
 * so the title never has to make room for it.
 */
.zoey-secret-map__close {
  position: absolute;
  inset-block-start: var(--wp--preset--spacing--20);
  inset-inline-end: var(--wp--preset--spacing--20);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 2.75rem;
  block-size: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: var(--wp--custom--radius--pill);
  background: none;
  color: var(--wp--preset--color--ink-soft);
  font: inherit;
  font-size: var(--wp--preset--font-size--card-title);
  line-height: 1;
  cursor: pointer;
  appearance: none;
}

.zoey-secret-map__close:hover {
  color: var(--wp--preset--color--ink);
}

/* --- The field ---------------------------------------------------------------------- */

/*
 * The paper the six marks sit on. `aspect-ratio` rather than a height, so the composition
 * scales with whatever width it is given and the marks keep their relationship to the route
 * at every one of them.
 *
 * The texture is §65's: a faint dot grid, drawn as one gradient. No image, no SVG file, no
 * request, and nothing that can affect readability — the dots are Border Soft on Surface
 * Soft, which is a difference you notice only when you look for it.
 */
.zoey-secret-map__field {
  position: relative;
  aspect-ratio: 100 / 56;
  margin-block: var(--wp--preset--spacing--40);
  border: 1px solid var(--wp--preset--color--border-soft);
  border-radius: var(--wp--custom--radius--medium);
  background-color: var(--wp--preset--color--surface-soft);
  background-image: radial-gradient(circle, var(--wp--preset--color--border-soft) 1px, transparent 1px);
  background-size: 1.25rem 1.25rem;
  background-position: center;
}

/*
 * The route. Stretched to the field with `preserveAspectRatio="none"`, which distorts
 * geometry and would distort the line with it — `vector-effect` is what keeps the stroke the
 * weight a pencil would have made at any width.
 */
.zoey-secret-map__route {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
}

/*
 * Faint and dotted while there is still something to find; drawn once everything has been
 * found (§33, §56). Two states and no animation between them — a line that redraws itself is
 * a progress meter with better manners, and §34 rules those out.
 */
.zoey-secret-map__route-line {
  fill: none;
  stroke: var(--wp--preset--color--ink-soft);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-dasharray: 1 5;
  opacity: 0.55;
  vector-effect: non-scaling-stroke;
}

/*
 * The dash pattern is no longer stated here: WORLD-006 gave the completed route a one-time
 * draw along its own length, and the animation owns `stroke-dasharray` for as long as it is
 * applied. What is left is the part that is still a state rather than a moment — the line
 * darkens when there is nothing more to find.
 */
.zoey-secret-map__field.is-complete .zoey-secret-map__route-line {
  opacity: 0.9;
}

/*
 * The pencil line between the key and the door (§30), and the small final mark Bubble leaves
 * when the last secret is found (§56). Both are hidden until they are true, and `display`
 * rather than `opacity` so that neither is a faint shape in forced colors.
 */
.zoey-secret-map__route-link,
.zoey-secret-map__route-final {
  display: none;
  fill: none;
  stroke: var(--wp--preset--color--zoey-purple);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

/*
 * The link was a dashed curve until WORLD-006, which gave it the `connection` primitive's dash
 * reveal instead — and a path cannot be dashed *and* uncovered along its own dashes at once.
 * It is a drawn pencil line now rather than a dotted one, which is the better of the two
 * anyway: the relationship arrives by being drawn, the way somebody joining two marks on paper
 * would draw it.
 */

.zoey-secret-map__field.has-link .zoey-secret-map__route-link,
.zoey-secret-map__field.is-complete .zoey-secret-map__route-final {
  display: block;
}

/* --- The marks ---------------------------------------------------------------------- */

/*
 * A list in registry order, positioned by two custom properties per item.
 *
 * That split is §76 made structural rather than remembered: the document order is the order a
 * screen reader hears, the percentages are the order an eye travels, and neither can drag the
 * other along with it. inc/discovery/map.php owns the numbers.
 */
.zoey-secret-map__marks {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.zoey-secret-map__mark {
  position: absolute;
  inset-inline-start: var(--zoey-map-x, 50%);
  inset-block-start: var(--zoey-map-y, 50%);
  display: grid;
  place-items: center;
  inline-size: 1.75rem;
  block-size: 1.75rem;
  transform: translate(-50%, -50%);
}

/*
 * A found object is drawn by components/discovery-object.css, whole and unmodified — §93 asks
 * the map to reuse the DISCOVERY-005 artwork rather than commission six more drawings of the
 * same six things, and this is that reuse costing one class.
 *
 * The key's bow has a hole painted in the colour of whatever it is sitting on, so the map has
 * to say what that is here. Nothing else needed changing.
 */
.zoey-secret-map__object {
  --zoey-discovery-object-size: 1.5rem;
  --zoey-discovery-object-hole: var(--wp--preset--color--surface-soft);
}

/*
 * The mystery (§23, §24, §26). A question mark in an object-shaped space: the same size as an
 * object, in the same place an object would be, so the map's structure is legible before any
 * of it has been found — and giving away neither the shape nor the name of what is missing.
 *
 * A dashed *border* rather than a tint, for §87 and §72 together: it is a real stroke, so
 * forced colors keeps it, and it holds its contrast without depending on a pastel that may
 * not be there.
 *
 * It is not a control. §75 is explicit that six focusable `???` buttons that do nothing are
 * not an interaction, and the one thing a visitor can do about a missing secret — ask for a
 * hint — is the single button below the field.
 */
.zoey-secret-map__unknown {
  display: grid;
  place-items: center;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  border: 1.5px dashed var(--wp--preset--color--ink-soft);
  border-radius: var(--wp--custom--radius--pill);
  color: var(--wp--preset--color--ink-soft);
  font-size: var(--wp--preset--font-size--body-small);
  font-weight: 700;
  line-height: 1;
}

/* --- The reaction vocabulary (WORLD-006) -------------------------------------------- */

/*
 * Six primitives, and six compositions of them.
 *
 * WORLD-002 §6 replaced what the map used to do — swap a question mark for a drawing, six
 * times — with a small shared vocabulary. Each primitive below is written **once**. What makes
 * a star a star here is which two it is composed from and how much of each it asks for, and
 * nothing else: there is no per-object animation in this file, and an object that wanted one
 * would have to break the rule in public. inc/discovery/map.php owns the composition table.
 *
 * ## The targeting rule, which is what keeps the compositions from colliding
 *
 * `animation` is one property, so two primitives on one element would be one primitive. Each
 * therefore owns a different part of the mark, and the table is chosen so that no object's two
 * ever want the same part:
 *
 *     sketch-in            the object's own paths      (opacity, then fill-opacity)
 *     colour-reveal        the object wrapper           (filter)
 *     restrained-motion    the drawing                  (transform)
 *     stamp                the object wrapper           (transform)
 *     pencil-treatment     the graphite path            (stroke-dashoffset)
 *     connection           the line in the field's SVG  (stroke-dashoffset)
 *
 * Colour-reveal and stamp share the wrapper, and no object composes both. Restrained-motion
 * takes the drawing rather than the wrapper for that reason, and can override the family's
 * `transform` there without losing anything: a map mark is not a control (§75), so none of
 * components/discovery-object.css's hover channels is ever set on one.
 *
 * ## When they play
 *
 * When `is-found` arrives beside them, which for a mark that was already found is the moment
 * the map opens. That is the intent rather than a side effect — the map is the one surface
 * where all six are seen together, and opening it is when a visitor is looking. Every one of
 * them runs once and stops; nothing here loops, and nothing repeats while the sheet is open.
 */

.zoey-secret-map__mark {
  --zoey-map-reaction: 520ms;
}

/*
 * sketch-in — the object arrives as if drawn, line before fill.
 *
 * Staged opacity rather than a per-path dash reveal, and the reason is the scale rather than
 * the effort: a mark is 24 units drawn at 1.5rem, so a stroke uncovering itself along a
 * nine-unit curve is a pixel and a half of travel that nobody sees. What *is* legible at this
 * size is the order — linework, then colour inside it — and that is what this does. The
 * pencil's own graphite is the one place in this system where a dash reveal earns its keep,
 * and it has one, below.
 */
.zoey-secret-map__mark.zoey-map-reaction--sketch-in.is-found .zoey-discovery-object__art {
  animation: zoey-map-sketch-line var(--zoey-map-reaction) ease-out both;
}

.zoey-secret-map__mark.zoey-map-reaction--sketch-in.is-found .zoey-discovery-object__fill,
.zoey-secret-map__mark.zoey-map-reaction--sketch-in.is-found .zoey-discovery-object__accent,
.zoey-secret-map__mark.zoey-map-reaction--sketch-in.is-found .zoey-discovery-object__tip,
.zoey-secret-map__mark.zoey-map-reaction--sketch-in.is-found .zoey-discovery-object__hub,
.zoey-secret-map__mark.zoey-map-reaction--sketch-in.is-found .zoey-discovery-object__hole {
  animation: zoey-map-sketch-fill var(--zoey-map-reaction) ease-out both;
}

@keyframes zoey-map-sketch-line {
  from {
    opacity: 0;
  }

  40% {
    opacity: 1;
  }

  to {
    opacity: 1;
  }
}

@keyframes zoey-map-sketch-fill {
  0%,
  40% {
    fill-opacity: 0;
  }

  to {
    fill-opacity: 1;
  }
}

/*
 * colour-reveal — graphite becomes colour.
 *
 * One filter, desaturating the object to the grey a pencil would have left it and letting its
 * own hue come back. It is the family's palette arriving rather than a colour invented here,
 * which is what keeps this a *reveal* of the object rather than a second paint job on it.
 */
.zoey-secret-map__mark.zoey-map-reaction--colour-reveal.is-found .zoey-secret-map__object {
  animation: zoey-map-colour-reveal 620ms ease-out both;
}

@keyframes zoey-map-colour-reveal {
  from {
    filter: grayscale(1);
  }

  to {
    filter: grayscale(0);
  }
}

/*
 * restrained-motion — one small movement that stops.
 *
 * The vocabulary owns the movement and the object owns the amount: two custom properties, a
 * peak and a resting value, and the composition sets them. That split is the whole reason this
 * is a primitive rather than two animations — the gear's quarter-turn and the star's small
 * rise are the same rule with different numbers.
 *
 * `--zoey-map-turn-rest` exists because the two end differently on purpose. A gear that turned
 * and turned back has not been driven by anything; a star that rose and stayed risen is out of
 * place on the paper. So the gear's rest is its peak and the star's is where it started, and
 * both are one movement that stops.
 */
.zoey-secret-map__mark.zoey-map-reaction--restrained-motion.is-found .zoey-discovery-object__art {
  animation: zoey-map-restrained-motion var(--zoey-map-reaction) cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes zoey-map-restrained-motion {
  from {
    transform: translateY(0) rotate(0deg);
  }

  60% {
    transform: translateY(var(--zoey-map-lift, 0)) rotate(var(--zoey-map-turn, 0deg));
  }

  to {
    transform: translateY(0) rotate(var(--zoey-map-turn-rest, 0deg));
  }
}

/*
 * stamp — a mark pressed onto the map, settling once.
 *
 * It arrives slightly large and slightly off-square, as something pressed by hand does, and
 * settles square. One overshoot and no bounce: a mark that wobbled would be celebrating, and
 * §34 and §56 are clear that nothing on this sheet celebrates louder than the drawing itself.
 */
.zoey-secret-map__mark.zoey-map-reaction--stamp.is-found .zoey-secret-map__object {
  animation: zoey-map-stamp 380ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

@keyframes zoey-map-stamp {
  from {
    opacity: 0;
    transform: scale(1.4) rotate(-7deg);
  }

  65% {
    opacity: 1;
    transform: scale(0.96) rotate(1deg);
  }

  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

/*
 * pencil-treatment — Bubble's own graphite, visibly hers.
 *
 * The one primitive that is not a treatment of the object but a mark *beside* it: the pencil's
 * `__graphite` path, which components/discovery-object.css holds back with a dash offset and
 * WORLD-005 draws on a press. Here it is drawn on arrival and **left drawn**, which is the
 * difference between the two surfaces and is the point of the primitive. Pressing the pencil in
 * the world is a thing you did and it returns to rest; the map is where what you found is
 * remembered, so the mark she made stays made.
 *
 * `100 200` and the `101` offset are WORLD-005's numbers, not new ones — a round cap sitting on
 * a dash boundary leaves a graphite speck, and a gap longer than the path is what holds. This
 * animates between the same two states and inherits the rest from the family stylesheet.
 */
.zoey-secret-map__mark.zoey-map-reaction--pencil-treatment.is-found .zoey-discovery-object__graphite {
  animation: zoey-map-pencil-treatment 700ms cubic-bezier(0.3, 0.7, 0.4, 1) both;
}

@keyframes zoey-map-pencil-treatment {
  from {
    stroke-dashoffset: 101;
  }

  to {
    stroke-dashoffset: 0;
  }
}

/*
 * connection — a line drawn between two marks.
 *
 * The one primitive whose rule is not on a mark, because a connection is not a property of one
 * object. The mark still carries `zoey-map-reaction--connection`, and that class is the
 * *declaration* — it is how the composition table stays readable in the rendered page — while
 * the drawing happens on the line in the field's SVG. Two lines use it and they are one rule:
 * the airplane's flight path, and the pencil link between the key and the door.
 *
 * ## `--zoey-map-draw`, and why `pathLength` could not do this
 *
 * These lines are stroked with `vector-effect: non-scaling-stroke`, so that the route keeps the
 * weight a pencil would have made at any field width. That is load-bearing and stays — but it
 * moves stroking into *screen* space, and a dash array is then measured in rendered pixels
 * while `pathLength` normalises user units. The two do not meet. `pathLength="100"` with a
 * `100 200` dash — which is the pencil's own working reveal in
 * components/discovery-object.css, where there is no non-scaling stroke — draws about a
 * hundred pixels of a line that is six hundred long, and leaves the rest as gaps.
 *
 * That was not a rounding error. It was a broken route, three broken segments and a link in
 * two pieces, and it looked like a stylesheet bug in every part of the file except the one it
 * was in. It is WORLD-004's defect 3 and WORLD-005's graphite speck a third time: **this
 * geometry has to be rendered to be believed.**
 *
 * So each line carries its own dash length in screen pixels, and each number is its measured
 * maximum with a margin. Measured in the browser at the four widths that matter — the field is
 * capped by the sheet, so 544 px is as long as any of them ever gets:
 *
 *     line     320px    390px    544px+   used
 *     route      360      447      639     700
 *     trace      283      351      502     560
 *     link       100      124      178     200
 *
 * A line shorter than its own number finishes drawing before the animation ends and is simply
 * still for the remainder, which is the right way round: every one of these is fully drawn well
 * inside its duration at every width, and none of them is ever caught unfinished.
 *
 * The second dash is 9999 for the reason WORLD-005 wrote down at length: a gap shorter than the
 * path lets the *next* dash arrive from the far end, and the round cap on its boundary is drawn
 * as a half-dot. There is no next dash at this distance.
 */
.zoey-secret-map__connection-line {
  stroke-dasharray: var(--zoey-map-draw) 9999;
  stroke-dashoffset: var(--zoey-map-draw);
}

.zoey-secret-map__route-trace {
  --zoey-map-draw: 560;
}

.zoey-secret-map__route-link {
  --zoey-map-draw: 200;
}

.zoey-secret-map__field.has-trace .zoey-secret-map__route-trace,
.zoey-secret-map__field.has-link .zoey-secret-map__route-link {
  animation: zoey-map-connection 900ms cubic-bezier(0.3, 0.7, 0.4, 1) both;
}

@keyframes zoey-map-connection {
  from {
    stroke-dashoffset: var(--zoey-map-draw);
  }

  to {
    stroke-dashoffset: 0;
  }
}

/*
 * The airplane's flight path: faint, and once.
 *
 * Ink Soft rather than the link's purple, and thinner than the route it lies along, because
 * this is a trace of where something went and not a second route. It is drawn when the plane is
 * found and then it stays, quietly — §33's dotted line is still underneath it, and at this
 * weight the two read as one pencil going over the same ground twice.
 */
.zoey-secret-map__route-trace {
  display: none;
  fill: none;
  stroke: var(--wp--preset--color--ink-soft);
  stroke-width: 1;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.7;
  vector-effect: non-scaling-stroke;
}

.zoey-secret-map__field.has-trace .zoey-secret-map__route-trace {
  display: block;
}

/* --- The six compositions ----------------------------------------------------------- */

/*
 * The amounts, and nothing else. Every rule in this block sets custom properties the
 * vocabulary above reads; none of them declares an animation, a transition or a transform.
 * That is what "compositions, not bespoke systems" means in a file rather than in a sentence,
 * and it is checkable by reading this block for the word `animation`.
 */

/* The star rises a little and settles — the brightest of the six, and the quietest about it. */
.zoey-secret-map__object.zoey-discovery-object--star {
  --zoey-map-lift: -0.16rem;
}

/*
 * The gear turns a quarter and stays turned. 90 degrees rather than the 45 the key turns on a
 * product page: this one drives a second cog and a quarter-turn is a full tooth-to-tooth step,
 * where the key's half-turn is deliberately not enough to throw a bolt that does not exist.
 */
.zoey-secret-map__object.zoey-discovery-object--gear {
  --zoey-map-turn: 90deg;
  --zoey-map-turn-rest: 90deg;
}

/* --- Completion --------------------------------------------------------------------- */

/*
 * §57's words, and §56's restraint. No confetti, no fireworks, no badge and no prize — the
 * whole of the celebration is that every mark is an object now, the route has drawn itself,
 * and Bubble has left one small tick at the end of it (§60).
 */
.zoey-secret-map__complete {
  margin-block: 0 var(--wp--preset--spacing--40);
  color: var(--wp--preset--color--ink);
  font-size: var(--wp--preset--font-size--body-small);
  line-height: 1.5;
}

/*
 * 6 of 6, worth looking at (WORLD-006).
 *
 * §56 already said what completion *is* — every mark is an object, the route has resolved, and
 * Bubble has left one small tick. What it did not do was let anybody watch it happen: the route
 * switched dash patterns between two frames, which is a state change rather than a moment.
 *
 * So the route draws itself, once, along its own length, and the tick arrives after it the way
 * a tick arrives after a line. That is the same `connection` gesture the key and the door get,
 * turned on the whole composition, and it is deliberately the *only* thing added: no confetti,
 * no badge, no prize, no meter counting up to six, and nothing that opens by itself (§34, §55,
 * §60). The sheet a visitor comes back to is the still version of it, because a completed
 * collection stays visible and revisit-able (WORLD-001).
 */
.zoey-secret-map__field.is-complete .zoey-secret-map__route-line {
  --zoey-map-draw: 700;

  animation: zoey-map-route-in 1100ms cubic-bezier(0.3, 0.7, 0.4, 1) both;
}

.zoey-secret-map__field.is-complete .zoey-secret-map__route-final {
  animation: zoey-map-final-in 320ms 1000ms ease-out both;
}

@keyframes zoey-map-route-in {
  from {
    stroke-dasharray: var(--zoey-map-draw) 9999;
    stroke-dashoffset: var(--zoey-map-draw);
  }

  to {
    stroke-dasharray: var(--zoey-map-draw) 9999;
    stroke-dashoffset: 0;
  }
}

@keyframes zoey-map-final-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* --- The one relational moment, in words -------------------------------------------- */

/*
 * The sentence half of the key/door connection (WORLD-002 §6).
 *
 * It reads as a note somebody wrote under the drawing rather than as a notification: the
 * sheet's own body size, the same rhythm as the completion line above it, and no icon, badge,
 * border or colour that would make a decorative observation look like something that happened
 * to the visitor's account.
 */
.zoey-secret-map__connection {
  margin-block: 0 var(--wp--preset--spacing--40);
  color: var(--wp--preset--color--ink);
  font-size: var(--wp--preset--font-size--body-small);
  line-height: 1.5;
}

/* --- The hint ----------------------------------------------------------------------- */

/*
 * §36: a secondary text action. Not a button competing with the account offer, not a primary
 * control, and nothing about tokens, timers or costs anywhere near it.
 */
.zoey-secret-map__hint {
  margin-block-end: var(--wp--preset--spacing--40);
}

.zoey-secret-map__clue {
  margin-block: 0 var(--wp--preset--spacing--20);
  color: var(--wp--preset--color--ink);
  font-size: var(--wp--preset--font-size--body-small);
  line-height: 1.5;
}

/* An empty line takes no room rather than reserving a gap for something never said. */
.zoey-secret-map__clue:empty {
  display: none;
}

.zoey-secret-map__hint-action,
.zoey-secret-map__later,
.zoey-secret-map__retry {
  display: inline-flex;
  align-items: center;
  min-block-size: 2.75rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--wp--preset--color--ink-soft);
  font: inherit;
  font-size: var(--wp--preset--font-size--body-small);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
  appearance: none;
}

.zoey-secret-map__hint-action:hover,
.zoey-secret-map__later:hover,
.zoey-secret-map__retry:hover {
  color: var(--wp--preset--color--ink);
}

/* --- The account card --------------------------------------------------------------- */

/*
 * §42's invitation, and §45's tone. A quiet card inside the map rather than an interruption
 * anywhere else: this is the one place the visitor can see that they now own something worth
 * keeping, which is what makes the offer an offer instead of a signup wall (§41).
 */
.zoey-secret-map__account {
  padding: var(--wp--preset--spacing--40);
  border: 1px solid var(--wp--preset--color--border-soft);
  border-radius: var(--wp--custom--radius--medium);
  background-color: var(--wp--preset--color--zoey-lavender-pale);
}

.zoey-secret-map__account-heading {
  margin-block: 0;
  color: var(--wp--preset--color--ink);
  font-size: var(--wp--preset--font-size--body);
  font-weight: 700;
  line-height: 1.35;
}

.zoey-secret-map__account-note {
  margin-block: var(--wp--preset--spacing--20) 0;
  color: var(--wp--preset--color--ink-soft);
  font-size: var(--wp--preset--font-size--body-small);
  line-height: 1.5;
}

.zoey-secret-map__account-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--wp--preset--spacing--30);
  margin-block: var(--wp--preset--spacing--30) 0;
}

/*
 * The one primary control on the map. It is a link because it goes somewhere — the ordinary
 * WooCommerce account page (§47) — and a control that navigates should say so to everything
 * that reads the page.
 */
.zoey-secret-map__save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /*
   * A flex item's floor is its content, so a pill with 2 rem of padding either side is wider
   * than a narrow card long before its label is. These two let it come down to the room it
   * actually has, and the label wraps inside it rather than out of it.
   */
  min-inline-size: 0;
  max-inline-size: 100%;
  min-block-size: 2.75rem;
  padding-block: var(--wp--preset--spacing--20);
  text-align: center;
  padding-inline: var(--wp--preset--spacing--40);
  border-radius: var(--wp--custom--radius--pill);
  /*
   * The site's own button, and not a new one. theme.json's `elements.button` is Zoey Pink
   * with Ink text and an Ink hover, and it is that way for a measured reason: Ink on Pink is
   * 5.54:1, where the white-on-purple this was first drawn as is 3.37:1 and fails 1.4.3 for
   * text at any weight this size. The map does not get its own primary control language.
   */
  background-color: var(--wp--preset--color--zoey-pink);
  color: var(--wp--preset--color--ink);
  font-size: var(--wp--preset--font-size--body-small);
  font-weight: 700;
  text-decoration: none;
}

.zoey-secret-map__save:hover {
  background-color: var(--wp--preset--color--ink);
  color: var(--wp--preset--color--surface);
}

/* --- Saved, and not saved ----------------------------------------------------------- */

/*
 * §53: no bright green, no badge, no SYNCED. A signed-in visitor's discoveries being kept is
 * supposed to be unremarkable, and the way to say something unremarkable is quietly.
 */
.zoey-secret-map__saved {
  margin-block: 0;
  color: var(--wp--preset--color--ink-soft);
  font-size: var(--wp--preset--font-size--body-small);
  line-height: 1.5;
}

/*
 * §51, and the reason it is not an error treatment: nothing has been lost. The discoveries
 * are still on this device, the anonymous set was never cleared, and the honest sentence is
 * also the reassuring one — so it is a note with a retry beside it rather than a red box.
 */
.zoey-secret-map__failure {
  padding: var(--wp--preset--spacing--30) var(--wp--preset--spacing--40);
  border: 1px solid var(--wp--preset--color--border-soft);
  border-radius: var(--wp--custom--radius--medium);
  background-color: var(--wp--preset--color--surface-soft);
}

.zoey-secret-map__failure-note {
  margin-block: 0;
  color: var(--wp--preset--color--ink);
  font-size: var(--wp--preset--font-size--body-small);
  line-height: 1.5;
}

/* --- When there is no room for a map ------------------------------------------------ */

/*
 * §85: at high zoom the map may become a linear list, and usability wins over preserving the
 * composition. This is that, and the threshold is measured rather than guessed. The field is
 * 15.5 rem at 320 px — the narrowest screen this site supports — where the closest pair of
 * marks is 44 px apart and each mark is 28 px: tight, and still a map. At 200% text the same
 * field is 7.8 rem there and 9.9 rem on a 390 px phone, where the six would be on top of one
 * another. 13 rem sits between the two groups rather than against either, so 320 px keeps the
 * composition, large text gets the list, and neither is one measurement away from flipping.
 *
 * The route goes, because a route between marks that are now in a row is a line pointing at
 * nothing. What is left is the six objects, in registry order, which is what the reading
 * order has been all along.
 */
@container (max-width: 13rem) {
  .zoey-secret-map__field {
    aspect-ratio: auto;
  }

  .zoey-secret-map__route {
    display: none;
  }

  .zoey-secret-map__marks {
    position: static;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--wp--preset--spacing--30);
    padding: var(--wp--preset--spacing--30);
  }

  .zoey-secret-map__mark {
    position: static;
    transform: none;
  }
}

/* --- Reduced motion ------------------------------------------------------------------ */

/*
 * Every reaction has a designed still state, *arrived at rather than travelled to*.
 *
 * That phrase is WORLD-006's and it is the whole rule, so it is worth being precise about what
 * it does and does not license. It is not `animation: none` applied to a block of selectors and
 * called handled — several of these primitives carry their meaning in an end position, and
 * switching the animation off without stating that position would leave the gear untried, the
 * pencil's mark undrawn and the two connections invisible. Those are not calmer versions of the
 * reactions; they are the unfound states.
 *
 * So each primitive below says where it ends and stays there:
 *
 *     sketch-in            the object is whole
 *     colour-reveal        the object is in colour
 *     stamp                the mark is settled and square
 *     restrained-motion    the gear is at its quarter-turn, because the position is the meaning
 *     pencil-treatment     Bubble's mark is drawn, and nobody watched it being drawn
 *     connection           both lines are there
 *     completion           the route is drawn and the tick is on it
 *
 * The star's rise is the one thing that genuinely does not survive, and should not: a lift that
 * returns to where it started is travel and nothing else, so the star is simply there, in
 * colour. This is the same reading components/discovery-object.css applies to the door's spill
 * and the pencil's stroke, and the same reason each selector below repeats the one it switches
 * off in full — a reduced-motion rule that loses on specificity is worse than none.
 */
@media (prefers-reduced-motion: reduce) {
  .zoey-secret-map__mark.zoey-map-reaction--sketch-in.is-found .zoey-discovery-object__art,
  .zoey-secret-map__mark.zoey-map-reaction--sketch-in.is-found .zoey-discovery-object__fill,
  .zoey-secret-map__mark.zoey-map-reaction--sketch-in.is-found .zoey-discovery-object__accent,
  .zoey-secret-map__mark.zoey-map-reaction--sketch-in.is-found .zoey-discovery-object__tip,
  .zoey-secret-map__mark.zoey-map-reaction--sketch-in.is-found .zoey-discovery-object__hub,
  .zoey-secret-map__mark.zoey-map-reaction--sketch-in.is-found .zoey-discovery-object__hole {
    animation: none;
    opacity: 1;
    fill-opacity: 1;
  }

  .zoey-secret-map__mark.zoey-map-reaction--colour-reveal.is-found .zoey-secret-map__object {
    animation: none;
    filter: none;
  }

  .zoey-secret-map__mark.zoey-map-reaction--stamp.is-found .zoey-secret-map__object {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .zoey-secret-map__mark.zoey-map-reaction--restrained-motion.is-found .zoey-discovery-object__art {
    animation: none;
    transform: rotate(var(--zoey-map-turn-rest, 0deg));
  }

  .zoey-secret-map__mark.zoey-map-reaction--pencil-treatment.is-found .zoey-discovery-object__graphite {
    animation: none;
    stroke-dashoffset: 0;
  }

  .zoey-secret-map__field.has-trace .zoey-secret-map__route-trace,
  .zoey-secret-map__field.has-link .zoey-secret-map__route-link {
    animation: none;
    stroke-dashoffset: 0;
  }

  /*
   * The route states its dash as well as its offset, because without the animation applied it
   * would otherwise fall back to §33's `1 5` dotted pattern — which is the *unfinished* line,
   * and would leave a completed map looking like an incomplete one for exactly the visitor
   * least able to tell the two apart by watching.
   */
  .zoey-secret-map__field.is-complete .zoey-secret-map__route-line {
    animation: none;
    stroke-dasharray: var(--zoey-map-draw) 9999;
    stroke-dashoffset: 0;
  }

  .zoey-secret-map__field.is-complete .zoey-secret-map__route-final {
    animation: none;
    opacity: 1;
  }
}

/* --- Forced colors ------------------------------------------------------------------ */

/*
 * §87: found and unfound have to stay different when every pastel in this file is replaced by
 * the system's two colours. They do, and by construction rather than by adjustment — the
 * difference between the two states is an *object* and a *question mark in a dashed ring*,
 * which are two shapes and two pieces of text, neither of which a colour scheme can flatten.
 *
 * What this block does is the surrounding: the sheet needs a border it did not need against
 * white, the paper texture is a colour effect with nothing to say here, and the route and its
 * two annotations have to be repainted in the system's ink.
 */
@media (forced-colors: active) {
  .zoey-secret-map {
    border: 1px solid CanvasText;
  }

  .zoey-secret-map__field {
    border-color: CanvasText;
    background-image: none;
  }

  .zoey-secret-map__route-line {
    stroke: CanvasText;
    opacity: 1;
  }

  .zoey-secret-map__route-link,
  .zoey-secret-map__route-trace,
  .zoey-secret-map__route-final {
    stroke: CanvasText;
    opacity: 1;
  }

  /*
   * The colour reveal has nothing left to reveal when there are two colours in the world, and
   * a `grayscale()` filter over a forced palette is a way to make one of them wrong. It stands
   * down, and the object simply arrives — which is what the other five primitives already do
   * here, because shape, position and stroke all survive a forced palette and only this one
   * was ever about hue.
   */
  .zoey-secret-map__mark.zoey-map-reaction--colour-reveal.is-found .zoey-secret-map__object {
    animation: none;
    filter: none;
  }

  .zoey-secret-map__unknown {
    border-color: CanvasText;
  }

  .zoey-secret-map__account,
  .zoey-secret-map__failure {
    border-color: CanvasText;
  }

  /*
   * A link styled as a filled button loses its fill here, so it needs an outline to stay a
   * control rather than becoming a line of text among other lines of text.
   */
  .zoey-secret-map__save {
    border: 1px solid LinkText;
  }
}
