/* The contact sheet and the red pencil: the contact sheet of a made-up photographer, Tidemark, on warm paper. Twelve
   black and white frames with a thin black rebate, drawn by the script on canvases; one red for the grease pencil.
   The script lays out the sheet, flies the chosen frame and draws the loop. */
:root {
  --paper: #f2efe8;              /* the page */
  --ink: #161514;                /* the text and the rebate of the frames */
  --grey: #8f897e;               /* the small texts */
  --pencil: #d8341c;             /* the grease pencil */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  overflow: hidden;
}

body {
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Newsreader Variable', 'Newsreader', Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  --pad: clamp(16px, 5vw, 80px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100svh;
  padding: clamp(18px, 3.4vw, 40px) var(--pad) clamp(18px, 3vw, 36px);
}

/* ---------------------------------------------------------------- the top line and the hint */
.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-size: 16px;
}

.top__name {
  font-variation-settings: 'wght' 620, 'opsz' 18;
  letter-spacing: -0.01em;
}

.top__note {
  color: var(--grey);
  font-style: normal;
  font-variation-settings: 'wght' 400, 'opsz' 14;
}

.hint {
  margin: 0;
  font-size: 13px;
  color: var(--grey);
  text-align: center;
}

/* ---------------------------------------------------------------- the sheet */
.sheet {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.frames {
  position: absolute;
  inset: 0;
}

/* a frame: placed and flown by the script; its look is on the child */
.frame {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.frame__print {
  display: block;
  width: 100%;
  height: 100%;
  border: 3px solid var(--ink);
  background: #2a2826;
}

.frame:focus-visible {
  outline: none;
}

.frame:focus-visible .frame__print {
  outline: 1px solid var(--ink);
  outline-offset: 4px;
}

.frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* the grease pencil, over the whole sheet */
.pencil {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 3;
}

.pencil__loop {
  fill: none;
  stroke: var(--pencil);
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the title of the chosen frame, under it when it is big */
.caption {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 4;
  display: grid;
  gap: 4px;
  margin: 0;
  pointer-events: none;
}

.caption__mask {
  display: block;
  overflow: hidden;
  padding-bottom: 0.12em;
}

.caption__title,
.caption__note {
  display: block;
  white-space: nowrap;
}

.caption__title {
  font-size: clamp(18px, 1.7vw, 24px);
  font-variation-settings: 'wght' 460, 'opsz' 24;
  letter-spacing: -0.01em;
}

.caption__note {
  font-size: 13px;
  color: var(--grey);
  font-variant-numeric: tabular-nums;
  font-variation-settings: 'wght' 400, 'opsz' 12;
}

@media (max-width: 640px) {
  .top {
    font-size: 15px;
  }

  .frame__print {
    border-width: 2px;
  }

  .pencil__loop {
    stroke-width: 2.6;
  }
}
