/* Points of interest on the scene: dots, footsteps, dust, the brush, pictures, outlines, tracing */

/* Point of interest: a glowing dot with a slow pulse */
.poi-dot {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  padding: 0;
  border: 2px solid rgba(241, 232, 207, 0.9);
  border-radius: 50%;
  background: radial-gradient(circle, var(--sunlight) 0%, rgba(217, 182, 92, 0.6) 60%, transparent 100%);
  /* thin dark ring so the dot also stands out on bright backgrounds */
  box-shadow: 0 0 0 2px rgba(12, 19, 14, 0.7), 0 0 8px rgba(217, 182, 92, 0.6), 0 2px 4px rgba(0, 0, 0, 0.6);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* A point marked by a small picture instead of a dot (e.g. footsteps for the way back). The picture is
   drawn in black: it's turned to the palette's light stone colour, with a thin dark outline and a soft
   shadow so it reads on dark and bright ground alike; hovered, it warms to sunlight and glows */
.poi-dot.poi-marker {
  width: 30px;
  height: 38px; /* the footsteps picture's shape (108 x 136) */
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
}

.poi-dot.poi-marker::after {
  display: none;
}

.poi-marker img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: invert(62%) sepia(25%) drop-shadow(0 0 1px rgba(12, 19, 14, 0.9)) drop-shadow(0 0 1px rgba(12, 19, 14, 0.9)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
  transition: filter 0.2s ease;
}

.poi-dot.poi-marker:hover,
.poi-dot.poi-marker:focus-visible {
  transform: translate(-50%, -50%) scale(1.12);
  box-shadow: none;
}

.poi-marker:hover img,
.poi-marker:focus-visible img {
  filter: invert(80%) sepia(70%) saturate(160%) drop-shadow(0 0 1px rgba(12, 19, 14, 0.9)) drop-shadow(0 0 8px rgba(217, 182, 92, 0.8));
}

/* Investigating: it glows like the dots */
.scene.is-investigating .poi-dot.poi-marker {
  animation: investigate-marker 2.4s ease-in-out;
}

@keyframes investigate-marker {
  0%, 100% { filter: none; }
  20%, 70% { filter: drop-shadow(0 0 10px rgba(255, 214, 120, 0.9)); }
}

/* Soft ring that keeps expanding outwards to draw the eye */
.poi-dot::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid rgba(217, 182, 92, 0.7);
  animation: poi-pulse 2.4s ease-out infinite;
  pointer-events: none;
}

@keyframes poi-pulse {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(2.4); opacity: 0; }
}

.poi-dot:hover,
.poi-dot:focus-visible {
  transform: translate(-50%, -50%) scale(1.3);
  box-shadow: 0 0 0 2px rgba(12, 19, 14, 0.7), 0 0 16px rgba(217, 182, 92, 0.9), 0 3px 6px rgba(0, 0, 0, 0.6);
  outline: none;
}

.poi-dot:active {
  transform: translate(-50%, -50%) scale(0.9);
  transition-duration: 0.08s;
}

/* Something new at this point: bigger, brighter, with a stronger pulse, until opened */
.poi-dot.is-highlighted {
  width: 26px;
  height: 26px;
  background: radial-gradient(circle, #fff3cf 0%, var(--sunlight) 45%, rgba(217, 182, 92, 0.5) 100%);
  box-shadow: 0 0 0 2px rgba(12, 19, 14, 0.7), 0 0 22px 6px rgba(255, 214, 120, 0.85), 0 2px 4px rgba(0, 0, 0, 0.6);
}

.poi-dot.is-highlighted:not(:hover) {
  animation: dot-shine 1.6s ease-in-out infinite;
}

@keyframes dot-shine {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.25); }
}

.poi-dot.is-highlighted::after {
  border-width: 3px;
  border-color: rgba(255, 214, 120, 0.9);
  animation-duration: 1.6s;
}

/* ---- Dust over parts of the scene, drawn on a canvas and brushed away (see renderSceneDust, brushOver) ---- */
.scene-dust {
  position: absolute;
  overflow: hidden;
}

.scene-dust canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* An outline still under its dust: not clickable, not even its edge reaching past the dust */
.poi-shape.is-under-dust {
  pointer-events: none;
}

/* In the dark (its lamp not lit yet): out of reach */
.scene-dust.is-dark {
  pointer-events: none;
}

/* Mostly brushed away: what's under it can already be clicked */
.scene-dust.is-thin {
  pointer-events: none;
}

/* Little dust left: the rest lifts and thins out */
.scene-dust.is-clearing {
  pointer-events: none;
  animation: dust-blow 0.9s ease-out forwards;
}

@keyframes dust-blow {
  0% { opacity: 1; filter: blur(0); }
  100% { opacity: 0; filter: blur(4px); }
}

/* ---- The brush: held, it follows the mouse (its bristle tips on the pointer) and wiggles as it rubs ---- */
.icon-brush:hover img,
.icon-brush:focus-visible img {
  transform: translateY(-3px) scale(1.08) rotate(-8deg);
}

.icon-brush[aria-pressed="true"] img {
  opacity: 0.25;
}

body.is-brushing,
body.is-brushing * {
  cursor: none !important;
}

.brush-follower {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 50;
  width: 34px;
  margin: -58px 0 0 -10px; /* the bristle tips on the pointer */
  pointer-events: none;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.7));
}

.brush-follower[hidden] {
  display: none;
}

/* Rubbing: a couple of soft side-to-side swooshes, back to rest at the end of each */
.brush-follower.is-scrubbing {
  animation: brush-scrub 0.7s ease-in-out infinite;
  transform-origin: 50% 20%;
}

@keyframes brush-scrub {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  25% { translate: -22px 0; rotate: 10deg; }
  50% { translate: 3px 0; rotate: 0deg; }
  75% { translate: 22px 0; rotate: -10deg; }
}

/* ---- Points of interest as pictures on the scene (the summoning light) ---- */
/* Placed by its centre and bottom edge; the picture is the button */
.poi-picture {
  position: absolute;
  z-index: 1;
  aspect-ratio: 151 / 321;
  padding: 0;
  background: none;
  border: none;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  cursor: pointer;
  transition: transform 0.3s ease, filter 0.3s ease;
}

/* The light sways and stretches a little from its base (the stone stays put), and flickers with a
   soft glow in its own colour, like a magical flame */
.poi-picture img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: 50% 100%;
  animation: magic-light 3.6s ease-in-out infinite;
}

@keyframes magic-light {
  0%, 100% {
    transform: scaleY(1) skewX(0deg);
    filter: brightness(1) drop-shadow(0 0 6px rgba(140, 230, 255, 0.55));
  }
  25% {
    transform: scaleY(1.04) skewX(-2deg);
    filter: brightness(1.12) drop-shadow(0 0 12px rgba(140, 230, 255, 0.8));
  }
  50% {
    transform: scaleY(0.98) skewX(1.5deg);
    filter: brightness(0.95) drop-shadow(0 0 7px rgba(140, 230, 255, 0.6));
  }
  75% {
    transform: scaleY(1.05) skewX(-1deg);
    filter: brightness(1.15) drop-shadow(0 0 14px rgba(140, 230, 255, 0.85));
  }
}

/* Hovered: it holds still where it is and comes closer, glowing brighter; when the mouse leaves it
   carries on moving from that same moment */
.poi-picture:hover,
.poi-picture:focus-visible {
  transform: translateX(-50%) scale(1.15);
  filter: brightness(1.15) drop-shadow(0 0 10px rgba(140, 230, 255, 0.7));
  outline: none;
}

.poi-picture:hover img,
.poi-picture:focus-visible img {
  animation-play-state: paused;
}

/* Just appeared (something new): a stronger glow around it until the moment passes */
.poi-picture.is-highlighted {
  filter: drop-shadow(0 0 14px rgba(140, 230, 255, 0.85));
}

/* ---- Points of interest as traced outlines: invisible until hovered, then the object glows ---- */
/* One SVG layer the size of the picture; only the outlines themselves catch the mouse */
.poi-shapes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.poi-shape {
  fill: transparent;
  stroke: transparent;
  stroke-width: 2px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke; /* the same line width at any picture size */
  pointer-events: all;
  cursor: pointer;
  outline: none;
  transition: fill 0.25s ease, stroke 0.25s ease, filter 0.25s ease;
}

/* Hovered: a warm light on the object and along its edge */
.poi-shape:hover,
.poi-shape.is-hovered,
.poi-shape:focus-visible {
  fill: rgba(255, 226, 150, 0.14);
  stroke: rgba(255, 226, 150, 0.9);
  filter: drop-shadow(0 0 4px rgba(255, 214, 120, 0.9)) drop-shadow(0 0 10px rgba(255, 214, 120, 0.5));
}

.poi-shape:active {
  fill: rgba(255, 226, 150, 0.24);
}

/* Something new there: it shimmers on its own until opened */
.poi-shape.is-highlighted:not(:hover) {
  animation: shape-shine 2.4s ease-in-out infinite;
}

@keyframes shape-shine {
  0%, 100% { stroke: rgba(255, 226, 150, 0.15); fill: transparent; }
  50% { stroke: rgba(255, 226, 150, 0.75); fill: rgba(255, 226, 150, 0.08); }
}

/* Debug: every outline drawn faintly, and the one just traced dashed */
body.show-shapes .poi-shape:not(:hover),
.poi-shape.is-traced:not(:hover) {
  stroke: rgba(120, 220, 255, 0.8);
  stroke-dasharray: 4 3;
}

/* Debug: tracing an outline on the picture */
.trace-layer {
  position: absolute;
  inset: 0;
  z-index: 30;
  width: 100%;
  height: 100%;
  overflow: visible;
  cursor: crosshair;
}

.trace-line {
  fill: none;
  stroke: #7fdcff;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}

.trace-line.is-rubber {
  stroke-dasharray: 4 3;
  opacity: 0.7;
}

/* Each point clicked (in a non-uniform 0-100 space, so small radii on both axes) */
.trace-dot {
  rx: 0.25px;
  ry: 0.45px;
  fill: #7fdcff;
}

.trace-dot.is-first {
  rx: 0.4px;
  ry: 0.7px;
  fill: #ffe08a;
}

.trace-hint,
.trace-result {
  position: fixed;
  left: 50%;
  z-index: 70;
  transform: translateX(-50%);
  padding: 8px 14px;
  font: 0.85rem/1.4 system-ui, sans-serif;
  color: #f1e8cf;
  background: rgba(14, 18, 14, 0.94);
  border: 1px solid rgba(241, 232, 207, 0.3);
  border-radius: 6px;
}

.trace-hint {
  top: 12px;
  pointer-events: none;
}

.trace-result {
  bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: min(640px, calc(100vw - 32px));
}

.trace-result p {
  flex-basis: 100%;
  margin: 0;
}

.trace-result textarea {
  flex: 1;
  min-height: 3.2em;
  font: 0.8rem/1.3 ui-monospace, monospace;
  color: inherit;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(241, 232, 207, 0.25);
  resize: vertical;
}
