/* The instant photo button: an Export image button drawn as a small instant camera, on a white page. The print
   comes out of the slot under the camera and develops in a canvas. */
:root {
  --page: #ffffff;          /* the page */
  --body: #a9c2b0;          /* the camera's body */
  --cap: #f1ece1;           /* the cream band along the top of the camera */
  --ink: #17221d;           /* the words on the camera and the ring of the focus */
  --key: #e2603b;           /* the shutter key on top */
  --paper: #fbfaf5;         /* the white border of the print */
  --saved: #2c6b52;         /* the Saved to Downloads line */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Geist Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}

/* ---------------------------------------------------------------- the whole thing */
/* room for the camera, the print under it and the line under the print; at rest the script slides the camera down
   to the middle, and up again as the print comes out, so the whole stays centred */
.snap {
  position: relative;
  width: 260px;
  height: 372px;
}

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

/* ---------------------------------------------------------------- the camera (the real button) */
.cam {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  width: 260px;
  height: 150px;
  padding: 0;
  border: 0;
  border-radius: 26px;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transform-origin: 50% 80%;
}

.cam__body {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 18%, rgba(0, 0, 0, 0) 82%, rgba(0, 0, 0, 0.1)),
    linear-gradient(180deg, color-mix(in srgb, var(--body) 88%, #fff), var(--body) 45%, color-mix(in srgb, var(--body) 86%, #000));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 0 rgba(0, 0, 0, 0.12),
    0 1px 1px rgba(20, 30, 25, 0.18),
    0 10px 18px -8px rgba(20, 30, 25, 0.35),
    0 26px 40px -22px rgba(20, 30, 25, 0.45);
  transition: box-shadow 0.3s;
}

/* the cream band along the top, moulded a little proud of the body */
.cam__cap {
  position: absolute;
  inset: 0 0 auto;
  height: 48px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--cap) 60%, #fff), var(--cap) 70%, color-mix(in srgb, var(--cap) 92%, #000));
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12), 0 2px 2px rgba(0, 0, 0, 0.06);
}

.cam__seam {
  position: absolute;
  left: 0;
  right: 0;
  top: 104px;
  height: 1px;
  background: rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* the viewfinder: a small window of dark glass */
.cam__finder {
  position: absolute;
  left: 22px;
  top: 13px;
  width: 26px;
  height: 18px;
  border-radius: 4px;
  background: linear-gradient(160deg, #3b4a5c 0%, #10151c 55%, #1e2a36 100%);
  box-shadow: 0 0 0 2px #2a2f2c, 0 1px 0 2px rgba(255, 255, 255, 0.6), inset 0 1px 2px rgba(255, 255, 255, 0.25);
}

/* the flash: a fresnel window, and the light that fires behind it */
.cam__flash {
  position: absolute;
  right: 20px;
  top: 11px;
  width: 64px;
  height: 24px;
  overflow: hidden;
  border-radius: 4px;
  background: #e9ebe6;
  box-shadow: 0 0 0 2px #2a2f2c, 0 1px 0 2px rgba(255, 255, 255, 0.6);
}

.cam__fresnel {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 50%, rgba(0, 0, 0, 0.08)),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.09) 0 1px, rgba(255, 255, 255, 0.35) 1px 2px, rgba(0, 0, 0, 0) 2px 4px),
    linear-gradient(90deg, #d7dad4, #f4f5f1 50%, #d2d5cf);
}

.cam__fire {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 140% at 50% 50%, #ffffff 40%, #fff6d8 70%, #ffe3a3);
  opacity: 0;
}

/* the shutter key on top of the camera */
.cam__key {
  position: absolute;
  top: -5px;
  left: 128px;
  width: 36px;
  height: 9px;
  border-radius: 4px 4px 1px 1px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--key) 75%, #fff), var(--key) 60%, color-mix(in srgb, var(--key) 80%, #000));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 1px rgba(0, 0, 0, 0.25);
  transition: transform 0.14s cubic-bezier(0.3, 1.6, 0.5, 1);
}

/* the lens: a big barrel with its glass; the glints on the glass turn a little under the pointer */
.cam__lens {
  position: absolute;
  left: 18px;
  top: 34px;
  width: 102px;
  height: 102px;
  border-radius: 50%;
  box-shadow: 0 6px 10px -4px rgba(0, 0, 0, 0.45), 0 2px 3px rgba(0, 0, 0, 0.25);
}

.cam__lens svg {
  display: block;
  width: 100%;
  height: 100%;
}

.lens__grip {
  fill: none;
  stroke: #2f3431;
  stroke-width: 4;
  stroke-dasharray: 1.1 1.3;
}

.lens__ring {
  fill: none;
  stroke: rgba(120, 140, 200, 0.18);
  stroke-width: 0.8;
}

.lens__glints {
  transform-origin: 50px 50px;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.3, 1);
}

.lens__glint {
  fill: none;
  stroke: rgba(255, 255, 255, 0.78);
  stroke-width: 3.2;
  stroke-linecap: round;
}

.lens__glint--soft {
  stroke: rgba(255, 255, 255, 0.28);
  stroke-width: 2.4;
}

.lens__coat {
  fill: none;
  stroke: rgba(196, 120, 255, 0.45);
  stroke-width: 2;
  stroke-linecap: round;
}

.lens__coat--green {
  stroke: rgba(120, 255, 180, 0.35);
}

/* the words, on the right of the lens */
.cam__text {
  position: absolute;
  left: 136px;
  right: 14px;
  top: 58px;
  display: grid;
  gap: 4px;
  text-align: left;
}

.cam__label {
  font-size: 17px;
  font-weight: 640;
  letter-spacing: -0.015em;
  line-height: 1.1;
  white-space: nowrap;
}

.cam__sub {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: color-mix(in srgb, var(--ink) 62%, var(--body));
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* the chin along the bottom, with the slot the print comes out of */
.cam__chin {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 14px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.14));
}

.cam__slot {
  position: absolute;
  left: 34px;
  right: 34px;
  bottom: 3px;
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(180deg, #050706, #1e2421);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4), inset 0 1px 1px rgba(0, 0, 0, 0.6);
}

/* the flash lights the body for an instant */
.cam__sheen {
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 82% 10%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 70%);
  opacity: 0;
  pointer-events: none;
}

/* the light of the flash, out round the camera */
.snap__bloom {
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 3;
  width: 560px;
  height: 560px;
  margin: -280px 0 0 -280px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 244, 214, 0.95), rgba(255, 230, 170, 0.45) 35%, rgba(255, 238, 200, 0) 100%);
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
}

/* hover, focus and press */
@media (hover: hover) and (pointer: fine) {
  .snap:not([data-state='out']) .cam:hover .cam__body {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.55),
      inset 0 -2px 0 rgba(0, 0, 0, 0.12),
      0 1px 1px rgba(20, 30, 25, 0.18),
      0 14px 22px -8px rgba(20, 30, 25, 0.38),
      0 34px 50px -24px rgba(20, 30, 25, 0.5);
  }

  .cam:hover .lens__glints {
    transform: rotate(-14deg);
  }

  .cam:hover .cam__key {
    transform: translateY(-1px);
  }
}

.cam[data-press] .cam__key,
.cam[data-fired] .cam__key {
  transform: translateY(3px);
}

.cam:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 6px;
}

html[data-using='pointer'] .cam:focus-visible {
  outline: none;
}

/* ---------------------------------------------------------------- the print */
.snap__exit {
  position: absolute;
  left: 0;
  right: 0;
  top: 146px;
  z-index: 1;
  height: 220px;
  clip-path: inset(0 -80px -80px -80px);
  pointer-events: none;
}

.print {
  position: absolute;
  top: 0;
  left: 42px;
  display: block;
  width: 176px;
  height: 152px;
  padding: 10px 10px 0;
  border: 0;
  border-radius: 2px;
  background: linear-gradient(180deg, #ffffff, var(--paper));
  box-shadow:
    0 0 0 0.5px rgba(0, 0, 0, 0.12),
    0 1px 1px rgba(0, 0, 0, 0.08),
    0 10px 18px -10px rgba(20, 30, 25, 0.45);
  cursor: pointer;
  transform-origin: 50% 0;
  transform: translateY(-160px);
  visibility: hidden;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.print__frame {
  position: relative;
  display: block;
  width: 156px;
  height: 104px;
  overflow: hidden;
  background: #36443d;
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.25);
}

.print__image {
  display: block;
  width: 100%;
  height: 100%;
}

/* the glossy surface of the print */
.print__gloss {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.09) 42%, rgba(255, 255, 255, 0) 56%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0));
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.18);
}

.print__note {
  display: block;
  margin-top: 13px;
  color: #9a9c95;
  font-size: 10.5px;
  font-weight: 450;
  letter-spacing: 0.02em;
  text-align: center;
}

.print:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
}

html[data-using='pointer'] .print:focus-visible {
  outline: none;
}

/* ---------------------------------------------------------------- Saved to Downloads */
.snap__saved {
  position: absolute;
  left: 0;
  right: 0;
  top: 336px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--saved);
  font-size: 13.5px;
  font-weight: 560;
  letter-spacing: -0.005em;
  opacity: 0;
}

.snap__saved svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (prefers-reduced-motion: reduce) {
  .cam__key,
  .lens__glints,
  .cam__body {
    transition: none;
  }
}
