/* card.css - the scrapbook card. (Needs fonts.css, which defines the handwriting font and --hand.) */

.card {
  position: relative;
  width: var(--card-w, 100%);
  aspect-ratio: var(--frame-ratio);
  container-type: inline-size; /* lets the label size itself relative to the card (cqw units) */
  transform: rotate(var(--tilt, 0deg));
  transition: transform 0.25s ease;
  /* The shadow follows the frame's cut-out outline, so it looks like paper lying on the board. */
  filter: drop-shadow(0 5px 7px rgba(50, 35, 20, 0.28)) drop-shadow(0 1px 1.5px rgba(50, 35, 20, 0.3));
}
.card:hover,
.card:focus-within {
  transform: rotate(calc(var(--tilt, 0deg) * 0.25)) scale(1.035);
  z-index: 2;
}

.card-media {
  position: absolute;
  overflow: hidden;
  background: #cfc8b8;
}
.card-media img,
.card-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover; /* fills the window; a slightly different shape is cropped, never stretched */
  display: block;
}
.card-media video {
  opacity: 0;
  transition: opacity 0.4s ease; /* fades in once the loop is really playing */
}
.card-media video.is-playing {
  opacity: 1;
}

.card-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}

.card-label {
  position: absolute;
  margin: 0;
  font-family: var(--hand);
  font-weight: 400; /* her font has one weight; asking for bold would make the browser smear a fake one */
  font-size: calc(17cqw * var(--label-size, 1) * var(--font-scale, 1)); /* each project can scale its text; each font has its own natural size */
  line-height: 0.85;
  overflow-wrap: normal; /* never chop a word in half; if a word is too big for its spot, make the text smaller */
  word-break: normal;
  pointer-events: none;
  /* The text hangs off its spot: pulled up by --anchor (0 = hangs down from the spot, -50% = centred on it,
     -100% = grows upward from it), then tilted around that same point. Its colour, shadow and alignment are set per card. */
  transform: translate(var(--anchor-x, 0%), var(--anchor, -100%)) rotate(var(--rotate, 0deg));
}

/* Alternative text styles. */
.card-label[data-font='label'] {
  font-family: var(--font-label);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  line-height: 1.55;
  --font-scale: 0.6;
}
/* Label-maker "tape": a strip behind every line of letters, like an embossed label. */
.card-label[data-font='label'] .card-label-text {
  background: var(--tape, #1c2133);
  padding: 0.14em 0.55em;
  border-radius: 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.card-label[data-font='typewriter'] {
  font-family: var(--font-typewriter);
  font-weight: 400;
  line-height: 1.1;
  --font-scale: 0.72;
}

/* The three extra handwriting styles. Each has its own natural size, so "size 1" looks about the same across styles. */
.card-label[data-font='apple'] { font-family: var(--font-apple); font-weight: 400; line-height: 1.3; --font-scale: 0.62; }
.card-label[data-font='beanie'] { font-family: var(--font-beanie); font-weight: 400; line-height: 1; --font-scale: 1.15; }
.card-label[data-font='marker'] { font-family: var(--font-marker); font-weight: 400; line-height: 1.15; --font-scale: 0.72; }

.card-open {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.card-open:focus-visible {
  outline: 3px solid #c8452d;
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .card-media video {
    transition: none;
  }
  .card:hover,
  .card:focus-within {
    transform: rotate(var(--tilt, 0deg));
  }
}
