/* hiandrea.love — plain CSS, no build step.
   One wordless composition: a picture set off-centre on a bare field,
   two scribbled lines that loop over its corner, and a few small marks. */

/* The page is always white with black ink. Dark mode only changes the picture
   (to a dusk sky, inside photo.svg) and swaps the asterisks for moons. */
:root {
  color-scheme: light dark;
  --paper: #ffffff;
  --ink: #0c0c0c;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

/* ---------- stage ---------- */

.stage {
  /* --u is one percent of the viewport height; everything is placed from these four values. */
  --u: 1vh;
  --photo-left: 40vw;
  --photo-top: calc(21 * var(--u));
  --photo-h: calc(44 * var(--u));

  /* the scribble: its size, and where the knot in the middle of it sits */
  --scribble: calc(110 * var(--u));
  --knot-x: calc(var(--photo-left) - 9 * var(--u));
  --knot-y: calc(var(--photo-top) + var(--photo-h) - 1 * var(--u));

  position: relative;
  display: block;
  height: calc(100 * var(--u));
  overflow: hidden;
}

@supports (height: 1svh) {
  .stage {
    --u: 1svh;
  }
}

/* tall, narrow screens: the picture sits higher and reaches further left */
@media (max-aspect-ratio: 4 / 5) {
  .stage {
    --photo-left: 30vw;
    --photo-top: calc(17 * var(--u));
    --photo-h: calc(36 * var(--u));
    --scribble: calc(84 * var(--u));
    --knot-x: 37vw;
    --knot-y: calc(var(--photo-top) + var(--photo-h) + 8 * var(--u));
  }
}

/* ---------- picture ---------- */

.photo {
  position: absolute;
  top: var(--photo-top);
  left: var(--photo-left);
  right: 0;
  height: var(--photo-h);
  margin: 0;
}

.photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 100%; /* keep the meadow in frame when the picture is cropped */
}

/* 404: the frame with nothing in it */
.photo.missing {
  border: 1px solid var(--ink);
  border-right: 0;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

/* ---------- scribble ---------- */

.scribble {
  /* The knot's centre is at 50% / 63.33% of this box. By default it sits just
     outside the picture's bottom-left corner, so the loops cross into it. */
  position: absolute;
  top: calc(var(--knot-y) - 0.6333 * var(--scribble));
  left: calc(var(--knot-x) - 0.25 * var(--scribble));
  width: calc(0.5 * var(--scribble));
  height: var(--scribble);
  overflow: visible;
  fill: none;
  stroke: var(--ink);
  stroke-width: clamp(1.6px, 0.3vmin, 3px);
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.scribble path {
  vector-effect: non-scaling-stroke;
}

/* small breaks in one of the lines, where the pen skipped */
.scribble .skip {
  stroke-dasharray: 610 9 5 9 470 7 12 8 3000;
}

/* ---------- small marks ---------- */

.mark {
  position: absolute;
  overflow: visible;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1;
  stroke-linecap: round;
  pointer-events: none;
}

.mark .solid {
  fill: var(--ink);
  stroke: none;
}

.ticks {
  top: calc(var(--photo-top) + var(--photo-h) + 4 * var(--u));
  left: calc(var(--photo-left) + (100vw - var(--photo-left)) * 0.14);
  width: calc((100vw - var(--photo-left)) * 0.72);
  max-width: 34rem;
}

.rosettes {
  top: calc(var(--photo-top) - 5.4vmin);
  left: calc(var(--photo-left) + (100vw - var(--photo-left)) * 0.62);
  width: 6.4vmin;
  min-width: 2.6rem;
}

.stars {
  top: calc(var(--photo-top) + var(--photo-h) + 12 * var(--u));
  left: calc(var(--photo-left) + (100vw - var(--photo-left)) * 0.52);
  width: 5vmin;
  min-width: 2.2rem;
  stroke-width: 1.4;
}

.moons {
  display: none;
  top: calc(var(--photo-top) - 15 * var(--u));
  left: calc(var(--photo-left) + (100vw - var(--photo-left)) * 0.3);
  width: 14vmin;
  min-width: 5rem;
}

/* by night the asterisks give way to moons */
@media (prefers-color-scheme: dark) {
  .stars {
    display: none;
  }

  .moons {
    display: block;
  }
}
