/* ============================================================
   HOLO STICKERS (about page, under the intro)
   ============================================================
   A row of logo stickers made like a clear holographic vinyl sticker:
   a clear die-cut edge (same 6px outline as every sticker on the
   site), the logo in its own colours, and a layer of holo "shards"
   blended over the logo that catch the light as the sticker tilts.

   js/stickers.js draws each sticker on a canvas from the <img> inside
   it (so without JS the plain logos still show). Tilt follows the
   cursor on desktop and the phone's gyroscope on mobile (iPhone asks
   for motion access on the first tap in the rows' sections; until then,
   and if it is declined, the shimmer follows scrolling). Stickers are
   'stuck on the paper': not clickable, no lift, only a slight lean.

   Placement: every row (Experience / Education / Awards) has its
   company or award sticker in a column on the left.
   Markup, as the last child of a .row:
     <span class="sticker" style="--r:-7deg;--dx:6px;--dy:-3px">
       <img src="assets/about/logos/x.svg" alt="X" style="--h:24px">
     </span>
   --r tilts it, --dx/--dy nudge it off-centre, --h is the logo height,
   data-tag="TECHOPS" on .sticker adds a small label tag; data-tile marks a logo
   printed on its own coloured square (keeps its colours in dark mode, softer holo);
   add data-soft too for a photo sticker (only a faint sheen, so the photo reads);
   data-plain makes a classic white vinyl die-cut with no holo (the intro pile);
   add data-holo to a plain one to keep the holo (the photo polaroid stickers).
   ============================================================ */

:root {
  --sticker-white:       #ffffff;
  --sticker-white-rim:   rgba(35, 39, 66, 0.10);
  --sticker-clear-fill:  rgba(35, 39, 66, 0.045);
  --sticker-clear-rim:   rgba(35, 39, 66, 0.26);
  --sticker-clear-gloss: rgba(255, 255, 255, 0.55);
  --sticker-shadow:      rgba(35, 39, 66, 0.20);
  --sticker-tag-bg:      #BFE3F6;
  --sticker-tag-ink:     #14172A;
  /* dark ink prints in this colour in dark mode (like a white-ink print) */
  --sticker-ink-print:   transparent;
}

[data-theme="dark"],
:root:has(> body[data-theme="dark"]) {
  --sticker-white:       #F4F1EC;
  --sticker-white-rim:   rgba(0, 0, 0, 0.18);
  --sticker-clear-fill:  rgba(255, 255, 255, 0.07);
  --sticker-clear-rim:   rgba(255, 255, 255, 0.42);
  --sticker-clear-gloss: rgba(255, 255, 255, 0.22);
  --sticker-shadow:      rgba(0, 0, 0, 0.50);
  --sticker-tag-bg:      #BFE3F6;
  --sticker-tag-ink:     #14172A;
  --sticker-ink-print:   #F4F1EC;
}

/* Every row carries its company / award sticker in a column on the left;
   the role and company follow, the date stays on the right. */
.row:has(> .sticker) {
  --sticker-col: 140px;
  grid-template-columns: var(--sticker-col) minmax(0, 1fr) auto;
  align-items: center;
}
.row:has(> .sticker) .row-title { grid-column: 2; grid-row: 1; align-self: end; }
.row:has(> .sticker) .row-sub   { grid-column: 2; grid-row: 2; align-self: start; }
.row:has(> .sticker) .row-date  { grid-column: 3; grid-row: 1; align-self: end; }

.sticker {
  --r: 0deg;
  grid-column: 1;
  grid-row: 1 / span 2;
  justify-self: center;
  align-self: center;
  /* hand-placed: each sticker has its own angle and a small offset (set inline per row) */
  transform: translate(var(--dx, 0px), var(--dy, 0px)) rotate(var(--r));
  line-height: 0;
  position: relative;
  z-index: 1;
}

/* Phones: a narrower sticker column, text stacked beside it, stickers a bit smaller */
@media (max-width: 640px) {
  .row:has(> .sticker) {
    --sticker-col: 96px;
    display: grid;
    grid-template-columns: var(--sticker-col) minmax(0, 1fr);
    column-gap: 20px;
  }
  .row:has(> .sticker) .row-title { grid-column: 2; grid-row: 1; }
  .row:has(> .sticker) .row-sub   { grid-column: 2; grid-row: 2; }
  .row:has(> .sticker) .row-date  { grid-column: 2; grid-row: 3; align-self: start; }
  .sticker { grid-row: 1 / span 3; transform: translate(calc(var(--dx, 0px) * 0.5), calc(var(--dy, 0px) * 0.6)) rotate(var(--r)); }
  .sticker img { height: calc(var(--h, 32px) * 0.68) !important; }
}

/* Decorative stickers (scrapbook pile): stuck onto the intro photo pile
   ("on-pile") and loose in the empty middle of each section ("in-section").
   Placed by --x / --y (centre point, % of the parent), tilted by --r.
   Pure decoration: hidden from screen readers, never take clicks.
   Pile stickers show on phones too (scaled down); section ones are desktop only. */
.sticker.is-deco {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  transform: translate(-50%, -50%) rotate(var(--r, 0deg));
  pointer-events: none;
}
.sticker.is-deco.on-pile { z-index: 200; }          /* above the prints (they go up to 100) */
.section:has(> .sticker.is-deco) { position: relative; }
.sticker.is-deco.in-section { z-index: 1; }          /* under the clickable rows */
@media (max-width: 960px) { .sticker.is-deco.in-section { display: none; } }
/* phones: the pile is smaller, so its stickers scale down with it */
@media (max-width: 640px) { .sticker.is-deco.on-pile img { height: calc(var(--h, 32px) * 0.56) !important; } }

/* Before the script runs (or without JS): the plain logo */
.sticker img { display: block; height: var(--h, 32px); width: auto; }
.sticker img[hidden] { display: none; }   /* once the canvas sticker is drawn */
/* While the script builds a sticker, its plain logo keeps the space but stays
   hidden, and the finished sticker fades in (no pop, no flash of plain logos). */
.sticker img { visibility: hidden; }
.sticker.is-ready img { visibility: visible; }
.sticker canvas { opacity: 0; transition: opacity 0.35s ease; }
.sticker.is-ready canvas { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .sticker canvas { transition: none; } }

.sticker canvas {
  display: block;
  /* the shadow is drawn into the canvas (a CSS filter here made Safari flicker) */
  /* keep each sticker on its own stable layer, so the hover tilt starting and
     stopping doesn't make Safari re-layer (and flash) it */
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.sticker canvas:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 4px; border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
  .sticker canvas { transform: none !important; }
}
