/* ============================================================================
   Isaac Lee — the holo card in the lead (holo.js builds it).

   The one object on the page with a shadow and rounded corners, because it
   is a card, and a card without them is a sticker. The page's mat rules stop
   at the figure's edge: the figure loses its hairline and paper margin when
   the card is up, and keeps its mono caption. It has two faces, and turning
   it over is driven from holo.js on the rotor.
   ========================================================================== */

.portrait--holo { --hc-shadow: rgba(26, 26, 23, .3); }
:root[data-theme="dark"] .portrait--holo { --hc-shadow: rgba(0, 0, 0, .55); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .portrait--holo { --hc-shadow: rgba(0, 0, 0, .55); }
}

/* The mat goes once the card replaces the print. */
.portrait--live {
  padding: 0;
  border: 0;
  background: none;
  overflow: visible;
}
.portrait--live figcaption { margin: .8rem .1rem 0; }

.holo-card {
  --hc-radius: 14px;
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 63 / 88;
  border-radius: var(--hc-radius);
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
  opacity: 0;
  transition: opacity .4s ease;
}
.holo-card[data-ready] { opacity: 1; }

/* Once it has a back it is a control: holo.js makes it a button. */
.holo-card[role="button"] { cursor: pointer; }
.holo-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 6px; }

.holo-card__shadow {
  position: absolute;
  inset: 10% 7% -4%;
  border-radius: var(--hc-radius);
  background: var(--hc-shadow);
  filter: blur(26px);
  pointer-events: none;
  will-change: transform;
}

.holo-card__rotor {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

/* Two faces back to back in the rotor's 3D space; each hides when it turns
   away, so only one is ever seen. */
.holo-card__face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--hc-radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.holo-card__face--back { transform: rotateY(180deg); }
/* The foil is its own GPU layer, and a browser that lets it through the
   backface rule would show it on the back of the card. data-turned changes
   at the moment the card is edge-on, so this is never seen as a cut. */
.holo-card[data-turned] .holo-card__face:not(.holo-card__face--back),
.holo-card:not([data-turned]) .holo-card__face--back { visibility: hidden; }

/* The drawn card underneath, the foil on top. The foil only shows while
   the pointer is on the card (data-hover, set by holo.js) and fades out
   when it leaves, so at rest the card is the plain print. Without WebGL2
   the foil canvas never gets data-foil and stays out of the way. */
.holo-card__face canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.holo-card__face canvas + canvas { opacity: 0; transition: opacity .5s ease; }
.holo-card[data-foil][data-hover] .holo-card__face canvas + canvas { opacity: 1; }

/* Stacked under the ask on a narrow screen, the card gets a little more
   room than the print had: a card at 16rem is a sticker. */
@media (max-width: 59.99rem) {
  .portrait--holo { max-width: 19rem; }
}

@media (prefers-reduced-motion: reduce) {
  .holo-card, .holo-card__face canvas + canvas { transition: none; }
}
