/* Corner-peel stickers, shared by the landing page's desktop canvas
   (.desktop-landing) and the "more projects" ending of every project
   page (.cards-canvas): both are the same 1440x900 coordinate space, so
   one set of positions serves both. */

/* decorative sticker on the desktop canvas: plain, slight tilt; a
   small "coming soon" plate appears on hover (the project page isn't
   published yet). The tilt lives on the image so the plate stays level. */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-pasamontana,
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-easyquizy,
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-hood,
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-molnia,
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-random,
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-ether,
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-innovobot {
  position: absolute;
  z-index: 4;
}
:is(.desktop-landing, .cards-canvas) .sticker-pasamontana { left: 1239px; top: 618px; width: 52px; }
:is(.desktop-landing, .cards-canvas) .sticker-hood { left: 111px; top: 594px; width: 112px; }
:is(.desktop-landing, .cards-canvas) .sticker-easyquizy { left: 217px; top: 175px; width: 88px; }
:is(.desktop-landing, .cards-canvas) .sticker-innovobot { left: 348px; top: 555px; width: 110px; }
:is(.desktop-landing, .cards-canvas) .sticker-molnia { left: 1188px; top: 105px; width: 80px; }
:is(.desktop-landing, .cards-canvas) .sticker-random { left: 1078px; top: 484px; width: 64px; }
:is(.desktop-landing, .cards-canvas) .sticker-ether { left: 1263px; top: 304px; width: 76px; }

/* stickers with .sticker-peel: peel on hover, pure CSS.
   A fold line n.p = --d cuts off one corner/edge of the sticker (n is the
   unit normal pointing toward the part that peels, p is in px from the
   box's top-left); the cut-off part is re-drawn mirrored across that line
   as a pale paper-back flap. Per-sticker variables:
     --nx / --ny   the normal, e.g. (.7071, .7071) = bottom-right corner,
                   (.7071, -.7071) = top-right, (.342, -.940) = top edge
                   tilted 20deg
     --w / --h     box size in px (width set on the element, height from
                   the image's aspect ratio)
     --d0          where the fold line just touches the artwork's outermost
                   opaque pixel at rest: max(n.p) over opaque pixels, scaled
                   to the box (read from the image's alpha), so nothing is
                   cut at rest
     --q-hover     how far the line moves in on hover (peel depth)
     --ga / --goff the flap gradient's CSS angle (deg) and the offset that
                   puts its crease on the fold line: L/2 - (w/2*nx + h/2*ny)
                   with L = w*|nx| + h*|ny|
     --rot / --rot-hover   tilt at rest / on hover
     --peel-img    the artwork, used as the flap's alpha mask
   If an image changes, re-measure --d0, --w and --h. */
@property --q { syntax: '<length>'; inherits: true; initial-value: 0px; }
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-peel {
  --q: 0px;
  --d: calc(var(--d0) - var(--q));
  --px: calc(var(--d) * var(--nx));
  --py: calc(var(--d) * var(--ny));
  --L: 400px;
  --crease: 10px;
  transition: --q .5s cubic-bezier(.2, .8, .2, 1), opacity .3s ease, filter .3s ease,
              scale .45s cubic-bezier(.2, .8, .2, 1);
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-peel:hover { --q: var(--q-hover); }
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-peel .sticker-body {
  position: relative;
  transform: rotate(var(--rot));
  transition: transform .5s cubic-bezier(.2, .8, .2, 1);
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-peel:hover .sticker-body {
  transform: rotate(var(--rot-hover)) scale(1.05);
}
/* image: keep the side of the fold line away from the peeling part */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-peel .sticker {
  transform: none;
  clip-path: polygon(
    calc(var(--px) + var(--L) * (var(--ny) * -1)) calc(var(--py) + var(--L) * var(--nx)),
    calc(var(--px) + var(--L) * var(--ny)) calc(var(--py) - var(--L) * var(--nx)),
    calc(var(--px) + var(--L) * (var(--ny) - var(--nx))) calc(var(--py) - var(--L) * (var(--nx) + var(--ny))),
    calc(var(--px) - var(--L) * (var(--ny) + var(--nx))) calc(var(--py) + var(--L) * (var(--nx) - var(--ny))));
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-peel .sticker-flap {
  position: absolute; inset: 0;
  pointer-events: none;
  /* crease is a touch darker, fading to bright paper at the tip */
  background: linear-gradient(calc(var(--ga) * 1deg),
    #b4b4b4 calc(var(--d) + var(--goff)),
    #fbfbfb calc(var(--d) + var(--goff) + var(--crease)),
    #ececec 100%);
  -webkit-mask: var(--peel-img) center / 100% 100% no-repeat;
          mask: var(--peel-img) center / 100% 100% no-repeat;
  /* the peeling side of the fold line */
  clip-path: polygon(
    calc(var(--px) + var(--L) * (var(--ny) * -1)) calc(var(--py) + var(--L) * var(--nx)),
    calc(var(--px) + var(--L) * var(--ny)) calc(var(--py) - var(--L) * var(--nx)),
    calc(var(--px) + var(--L) * (var(--ny) + var(--nx))) calc(var(--py) + var(--L) * (var(--ny) - var(--nx))),
    calc(var(--px) + var(--L) * (var(--nx) - var(--ny))) calc(var(--py) + var(--L) * (var(--nx) + var(--ny))));
  /* mirror across n.p = d: translate(2d*n) after the reflection matrix */
  transform-origin: 0 0;
  transform:
    translate(calc(2 * var(--px)), calc(2 * var(--py)))
    matrix(calc(1 - 2 * var(--nx) * var(--nx)), calc(-2 * var(--nx) * var(--ny)),
           calc(-2 * var(--nx) * var(--ny)), calc(1 - 2 * var(--ny) * var(--ny)), 0, 0);
}
@media (prefers-reduced-motion: reduce) {
  :is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-peel,
  :is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-peel .sticker-body { transition: none; }
}

/* hood: 400x329 PNG, peels from the bottom-right corner */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-hood {
  --w: 112px;
  --h: 92.12px;
  --nx: .70711;
  --ny: .70711;
  --d0: 137.6px;
  --q-hover: 18.4px;
  --ga: 135;
  --goff: 0px;
  --rot: 8deg;
  --rot-hover: 6deg;
  --peel-img: url(../assets/images/angry-hood.png);
}
/* easyquizy: 256x256 PNG (downsized from 1024), peels from the top-left
   corner, no tilt. d0 is negative here because the normal points up-left,
   away from the box origin. */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-easyquizy {
  --w: 88px;
  --h: 88px;
  --nx: -.70711;
  --ny: -.70711;
  --d0: -3.65px;
  --q-hover: 15.6px;
  --ga: -45;
  --goff: 124.45px;
  --crease: 8px;
  --rot: 0deg;
  --rot-hover: 0deg;
  --peel-img: url(../assets/images/easyquizy.png);
}
/* molnia: 256x256 PNG (round logo, downsized from 464), peels from the
   bottom-left, slight tilt to the left */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-molnia {
  --w: 80px;
  --h: 80px;
  --nx: -.70711;
  --ny: .70711;
  --d0: 40px;
  --q-hover: 14px;
  --ga: 225;
  --goff: 56.57px;
  --crease: 8px;
  --rot: -6deg;
  --rot-hover: -4deg;
  --peel-img: url(../assets/images/molnia-sticker.png);
}
/* random: 88x98 SVG (the house from the RANDOM symbol, no background),
   peels from the top-right, the roof's tip; d0 is that tip's n.p; no tilt */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-random {
  --w: 64px;
  --h: 71.27px;
  --nx: .70711;
  --ny: -.70711;
  --d0: 43.97px;
  --q-hover: 12px;
  --ga: 45;
  --goff: 50.4px;
  --crease: 7px;
  --rot: 0deg;
  --rot-hover: 0deg;
  --peel-img: url(../assets/images/random-sticker.svg);
}
/* ether: 500x500 SVG (navy square, corners rounded for the sticker),
   peels from the right edge tilted 20deg down; d0 is the bottom-right
   corner arc's outermost point */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-ether {
  --w: 76px;
  --h: 76px;
  --nx: .93969;
  --ny: .34202;
  --d0: 95.7px;
  --q-hover: 14px;
  --ga: 110;
  --goff: 0px;
  --crease: 8px;
  --rot: -4deg;
  --rot-hover: -2deg;
  --peel-img: url(../assets/images/ether-sticker.svg);
}
/* innovobot: 332x172 PNG (the Innovobot badge from the case cover, corners
   rounded), peels from the left edge tilted 20deg up */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-innovobot {
  --w: 110px;
  --h: 56.99px;
  --nx: -.93969;
  --ny: -.34202;
  --d0: -1.77px;
  --q-hover: 14px;
  --ga: 290;
  --goff: 122.86px;
  --crease: 8px;
  --rot: 4deg;
  --rot-hover: 2deg;
  --peel-img: url(../assets/images/innovobot-sticker.png);
}
/* pasamontana: 85x128 SVG, peels from the top (edge tilted 20deg, the fold
   starts at the right side of the dome) */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-pasamontana {
  --w: 52px;
  --h: 78.31px;
  --nx: .34202;
  --ny: -.93969;
  --d0: 10.9px;
  --q-hover: 11px;
  --ga: 20;
  --goff: 73.58px;
  --crease: 6px;
  --rot: 11deg;
  --rot-hover: 9deg;
  --peel-img: url(../assets/images/pasamontana.svg);
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker {
  display: block; width: 100%; height: auto;
  transform: rotate(-11deg);
  user-select: none;
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-tip {
  position: absolute;
  left: 50%; top: calc(100% + 8px);
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 5px 8px;
  background: #fff;
  border: 1px solid var(--ink);
  font-family: 'B612 Mono', ui-monospace, monospace;
  font-size: 11px; letter-spacing: 0.3px; color: var(--ink);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-pasamontana:hover .sticker-tip,
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-hood:hover .sticker-tip { opacity: 1; }

/* Hover callouts (home page): a blueprint-style pointer from the sticker
   to a label, after sutera.ch. A small square marker sits next to the
   sticker, a line runs out and up, and ends either under a short label
   (coming soon) or at a window box with a title bar and a
   cut corner (EasyQuizy). Coordinates are px from the sticker's top-left,
   written per sticker in the markup. The line draws itself on hover
   (pathLength=1), then the label fades in. */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-peel:hover,
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-peel:focus-visible { z-index: 7; }
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-callout {
  position: absolute; inset: 0;
  pointer-events: none;
  font-family: 'B612 Mono', ui-monospace, monospace;
  font-size: 11px; line-height: 1.35; letter-spacing: 0.3px;
  text-transform: uppercase; color: var(--ink);
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-callout > svg {
  position: absolute; left: 0; top: 0;
  width: 1px; height: 1px; overflow: visible;
  fill: none; stroke: var(--ink); stroke-width: 1;
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-callout .co-marker {
  opacity: 0; transition: opacity .15s ease;
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-callout .co-marker .co-dot { fill: var(--ink); stroke: none; }
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-callout .co-marker .co-ring { fill: #fff; }
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-callout .co-line {
  stroke-dasharray: 1; stroke-dashoffset: 1;
  transition: stroke-dashoffset .15s ease;
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-callout .co-box {
  opacity: 0; transition: opacity .15s ease, transform .15s ease;
}
/* on: marker, then the line, then the box */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-peel:is(:hover, :focus-visible) .co-marker {
  opacity: 1; transition: opacity .15s ease;
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-peel:is(:hover, :focus-visible) .co-line {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset .35s cubic-bezier(.45, 0, .2, 1) .08s;
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-peel:is(:hover, :focus-visible) .co-box {
  opacity: 1; transform: none;
  transition: opacity .25s ease .38s, transform .3s cubic-bezier(.2, .8, .2, 1) .38s;
}

/* window box: 1px ink frame with the bottom-right corner cut off. The
   frame is the outer element's ink background showing through a 1px gap
   around the white inner element; both are clipped to the same chamfer,
   so the diagonal edge gets its line too. */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .co-box {
  --cut: 14px;
  position: absolute;
  width: 210px;
  padding: 1px;
  background: var(--ink);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%);
  transform: translateY(4px);
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .co-box-inner {
  display: block;
  padding: 10px 12px 14px;
  background: #fff;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--cut) + .41px), calc(100% - var(--cut) + .41px) 100%, 0 100%);
}
/* same text styles as the project frames' hover card (.info-row,
   .info-label, .frame-desc in landing.css) */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .co-title {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .co-meta {
  display: block; padding-top: 6px;
  color: var(--muted);
}
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .co-desc {
  display: block; margin-top: 8px;
  font-family: 'IBM Plex Sans', Helvetica, Arial, sans-serif;
  text-transform: none;
  font-size: 11px; line-height: 1.4; letter-spacing: 0.1px; color: var(--muted);
}

/* one placement for every callout: the marker sits on the sticker's
   upper-right corner and the line runs right, then up, into the box
   beside it (.co-right); a sticker too close to the right edge
   mirrors this to its upper-left corner (.co-left). Boxes may cover a
   neighbour while they're open; they never go above or below. */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-callout.co-right > svg { left: 100%; }
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .co-right .co-box { left: calc(100% + 41px); top: -45px; }
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .co-left .co-box { right: calc(100% + 41px); top: -45px; }
/* "Coming soon": the same box, just one line and as wide as its text */
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .co-box--soon { --cut: 10px; width: auto; white-space: nowrap; }
:is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .co-box--soon .co-box-inner { padding: 10px 12px; }

@media (prefers-reduced-motion: reduce) {
  :is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-callout *,
  :is(.desktop-landing, .cards-canvas, .m-list, .m-stickers) .sticker-peel:is(:hover, :focus-visible) .sticker-callout * { transition: none !important; }
}
