@font-face {
  font-family: Badeen;
  src: url("assets/badeen.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: Nunito;
  src: url("assets/nunito.ttf") format("truetype");
  font-weight: 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  -webkit-tap-highlight-color: transparent;
  --body: #ccffbc;
  --tray: #9dd28d;
  --rim: #87b479;
  --paper-top: #faf9f2;
  --paper-bottom: #e7e5da;
  --round-font: "SF Pro Rounded", ui-rounded, Nunito, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; background: #000000; }
body { color: #000; font-family: var(--round-font); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
:focus { outline: none; }
[hidden] { display: none !important; }

.shell {
  width: min(100%, 402px);
  height: 100dvh;
  margin-inline: auto;
  background: var(--body);
  position: relative;
  container-type: inline-size;
  overflow: hidden;
  isolation: isolate;
}

.machine {
  --u: calc(100cqw / 402);
  --travel: 0px;
  --tray-inset: calc(60 * var(--u));
  --open: 0;
  position: absolute;
  inset: 0;
  background: var(--body);
  overflow: hidden;
  touch-action: manipulation;
}

.machine::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: .17;
  mix-blend-mode: multiply;
  background: url("assets/grain.svg");
}

.camera-housing {
  position: absolute;
  inset: calc(-60 * var(--u)) 0 auto;
  height: calc(402 * var(--u) - var(--travel));
  background: #000;
  border-bottom: 2px solid var(--body);
  border-radius: calc(60 * var(--u));
  box-shadow: 0 3px 6px #0004;
  overflow: hidden;
  z-index: 2;
}

.viewfinder {
  position: absolute;
  top: calc(60 * var(--u));
  left: 50%;
  translate: -50%;
  width: calc(282 * var(--u));
  height: max(0px, calc(282 * var(--u) - var(--travel)));
  border-radius: calc(30 * var(--u));
  overflow: hidden;
  background: #000;
  opacity: calc(1 - var(--open));
  display: grid;
  place-content: center;
  justify-items: center;
}

.viewfinder[data-ready]::after {
  position: absolute;
  inset: 0;
  content: "";
  border: 2px solid #1b1b1b;
  box-shadow: inset 0 3px 6px #0004;
  border-radius: inherit;
  pointer-events: none;
}

.preview-feed {
  position: absolute;
  width: 100%;
  height: calc(282 * var(--u));
  inset: 0;
}

.preview-feed video, .preview-feed canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.preview-feed canvas { background: #000; }
.camera-request {
  z-index: 1;
  border: 1px solid #ffffff80;
  padding: 9px 13px;
  border-radius: 20px;
  background: #0008;
  color: #fff;
}
.camera-note { z-index: 1; max-width: 196px; margin: 10px 12px 0; color: #fff; text-align: center; font-size: 13px; }

.slot {
  position: absolute;
  z-index: 6;
  top: calc(365 * var(--u) - var(--travel));
  left: 50%;
  translate: -50%;
  width: calc(282 * var(--u));
  height: calc(8 * var(--u));
  border: 2px solid var(--body);
  border-radius: 9px;
  background: #000;
  box-shadow: 0 3px 6px #0004;
  pointer-events: none;
}

.controls {
  position: absolute;
  top: calc(396 * var(--u) - var(--travel));
  left: calc(50% - 110 * var(--u));
  width: calc(220 * var(--u));
  height: calc(80 * var(--u));
  z-index: 5;
}

.control {
  --button-face: #3a3a3a;
  position: absolute;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: 50%;
}
.control::before {
  content: "";
  position: absolute;
  inset: calc(-2 * var(--u));
  border: 2px solid transparent;
  border-radius: inherit;
  background:
    linear-gradient(var(--button-face), var(--button-face)) padding-box,
    linear-gradient(#ccffbc 75%, #abd69f) border-box;
  box-shadow: inset 0 3px 4px #ffffff3d, 0 3px 6px #0004;
  pointer-events: none;
}
.control svg { position: relative; width: calc(20 * var(--u)); height: calc(20 * var(--u)); pointer-events: none; }
.control:active:not(:disabled) { translate: 0 2px; }
.control:has(+ .haptic-target:active) { translate: 0 2px; }
.flash, .flip { width: calc(40 * var(--u)); height: calc(40 * var(--u)); }
.flash { left: 0; top: 25%; }
.flip { right: 0; top: 27.5%; }
.shutter { --button-face: #fc4242; width: calc(80 * var(--u)); height: calc(80 * var(--u)); top: 0; left: calc(70 * var(--u)); }
.haptic-target {
  position: absolute;
  z-index: 1;
  border-radius: 50%;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  user-select: none;
}
.control:is(:disabled, [hidden], [aria-disabled="true"]) + .haptic-target { display: none; }
.haptic-switch {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.flash[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 2px solid #ffdb57;
  box-shadow: 0 0 9px #ffce3cb0;
}

.wordmark {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: calc(501 * var(--u) - var(--travel));
  translate: -50%;
  height: calc(45 * var(--u));
  padding: 0 4px;
  border: 0;
  background: linear-gradient(var(--tray) 33%, var(--body));
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 -1px 0 #50794680) drop-shadow(0 1px 0 #e5ffda7a);
  font: calc(32 * var(--u)) / 1.4 Badeen, fantasy;
}

.gallery {
  position: absolute;
  inset: calc(559 * var(--u) - var(--travel)) var(--tray-inset) 0;
  border: 2px solid var(--rim);
  border-bottom: 0;
  border-radius: calc(30 * var(--u)) calc(30 * var(--u)) 0 0;
  background: linear-gradient(var(--tray) 57.55%, var(--body) 148.34%);
  box-shadow: inset 0 1px 3px #0004;
  overflow: hidden;
  overscroll-behavior: contain;
  scrollbar-width: none;
  touch-action: none;
}
.machine[data-expanded] .gallery { overflow-y: auto; touch-action: pan-y; }
.empty { text-align: center; margin: 32px 10px; color: #2e4c27; font-size: 14px; }
.photos {
  display: grid;
  grid-template-columns: repeat(2, calc((95 + 21.5 * var(--open)) * var(--u)));
  justify-content: space-between;
  row-gap: calc((20 + 10 * var(--open)) * var(--u));
  padding: calc((20 + 20 * var(--open)) * var(--u)) calc((27 + 12 * var(--open)) * var(--u)) 42px;
}
.paper {
  border: 0;
  border-radius: 2.5px;
  background: linear-gradient(var(--paper-top), var(--paper-bottom));
  aspect-ratio: 268 / 309;
  user-select: none;
}
.paper-window { position: absolute; overflow: hidden; background: #e4e2d9; aspect-ratio: 1; }
.paper-window img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumbnail {
  position: relative;
  width: 100%;
  padding: 0;
  transform: rotate(-2.5deg);
  box-shadow: 0 3px 3px #0002;
}
.thumbnail:is(:nth-child(4n + 2), :nth-child(4n + 3)) { transform: rotate(5.26deg); }
.thumbnail[data-viewing] { opacity: 0; }
.thumbnail .paper-window { inset: calc(10 * var(--u)) calc(10 * var(--u)) auto; }

.print-gate {
  position: absolute;
  inset: calc(369 * var(--u) - var(--travel)) 0 0;
  z-index: 7;
  overflow: hidden;
  perspective: 850px;
  pointer-events: none;
}
.printer-paper {
  position: absolute;
  width: calc(268 * var(--u));
  left: 50%;
  top: 0;
  margin-left: calc(-134 * var(--u));
  transform-origin: center top;
  box-shadow: 0 6px 12px #22302359;
}
.printer-paper .paper-window { inset: 10px 10px auto; background: #e8e6dc; }

.viewer {
  --viewer-strength: 1;
  --hero-width: min(66.66cqw, calc((100dvh - 200px) * .78));
  --hero-height: calc(var(--hero-width) * 309 / 268);
  --hero-top: max(18px, calc(50dvh - 16.84cqw - var(--hero-height) / 2));
  position: fixed;
  inset: 0;
  width: min(100%, 402px);
  height: 100dvh;
  max-width: none;
  max-height: none;
  padding: 0;
  margin: 0 auto;
  border: 0;
  overflow: hidden;
  background: transparent;
  color: #000;
}
.viewer::backdrop { background: transparent; }
.viewer::before {
  content: "";
  position: absolute;
  inset: 0;
  backdrop-filter: blur(calc(25px * var(--viewer-strength)));
  -webkit-backdrop-filter: blur(calc(25px * var(--viewer-strength)));
  background: rgb(255 255 255 / calc(.3 * var(--viewer-strength)));
  animation: appear .32s both;
  pointer-events: none;
}
.hero-paper {
  position: absolute;
  top: var(--hero-top);
  left: 50%;
  width: var(--hero-width);
  margin-left: calc(var(--hero-width) / -2);
  transform: rotate(-2.5deg);
  z-index: 1;
  touch-action: none;
  box-shadow: 0 1.25px 2.5px #1e285729, 0 6.25px 11.25px #1d28594d;
}
.hero-paper .paper-window { inset: calc(var(--hero-width) * .0373) calc(var(--hero-width) * .0373) auto; }
.hero-paper img { -webkit-user-drag: none; }
.hero-paper.revealing img { animation: develop 10s linear var(--develop-delay, .49s) both; }
.actions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--hero-top) + var(--hero-height) + min(9cqw, 36px));
  display: grid;
  justify-items: center;
  opacity: var(--viewer-strength);
}
.viewer.settling-photo::before { transition: background-color .26s, backdrop-filter .26s, -webkit-backdrop-filter .26s; }
.viewer.settling-photo .actions { transition: opacity .26s; }
.actions button {
  display: flex;
  align-items: center;
  gap: 5px;
  border: 0;
  padding: 0 5px;
  min-height: clamp(33px, 10.95cqw, 44px);
  background: transparent;
  font: 800 clamp(17px, 5.47cqw, 22px) / 1 var(--round-font);
  letter-spacing: -.035em;
  animation: appear .3s .2s both;
}
.actions button svg { width: 1.08em; height: 1.08em; }
.actions [data-action="delete"] { color: #fc4242; }
.actions button[aria-disabled="true"] { opacity: .5; }
.actions button:active { scale: .96; }

.exposure, .notice { position: fixed; }
.exposure {
  inset: 0;
  background: white;
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 90ms;
}
.exposure[data-light] { opacity: 1; }
.notice {
  inset: auto 12px max(14px, env(safe-area-inset-bottom));
  z-index: 11;
  margin: 0 auto;
  width: fit-content;
  max-width: min(90vw, 365px);
  padding: 10px 15px;
  color: white;
  background: #171d16;
  border-radius: 16px;
  text-align: center;
  font-size: 14px;
}

@keyframes appear { from { opacity: 0; } to { opacity: 1; } }
@keyframes develop {
  0% { opacity: 0; filter: brightness(1.52) saturate(.16) contrast(.58) blur(3px); }
  20% { opacity: .21; filter: brightness(1.48) saturate(.24) contrast(.65) blur(2px); }
  65% { opacity: .76; filter: brightness(1.16) saturate(.7) contrast(.85) blur(.6px); }
  100% { opacity: 1; filter: none; }
}

@media (max-height: 660px) {
  .viewer { --hero-width: min(66.66cqw, calc((100dvh - 195px) * .62)); }
  .actions { top: calc(var(--hero-top) + var(--hero-height) + 18px); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-paper { --develop-delay: 0s; }
  .viewer::before, .actions button { animation-duration: 0s; }
  .viewer.settling-photo::before, .viewer.settling-photo .actions { transition: none; }
}
