:root {
  --bg: #0b0b0c;
  --lcd: #121214;
  --ink: #e9e6df;
  --dim: #8a8780;
  --stamp: #ff8a1f;
  --hud: #9fe8c8;
  --serif: "Instrument Serif", "Times New Roman", serif;
  --mono: "VT323", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background: radial-gradient(ellipse at 50% 0%, #1b1a1f 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 20px;
  padding: clamp(10px, 3vw, 32px);
}

/* ---------- film grain + flash ---------- */

.grain {
  position: fixed;
  inset: -50%;
  pointer-events: none;
  z-index: 50;
  opacity: .09;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain .6s steps(4) infinite;
}

@keyframes grain {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-3%, 2%); }
  50%  { transform: translate(2%, -3%); }
  75%  { transform: translate(-2%, -1%); }
  100% { transform: translate(1%, 3%); }
}

.flash {
  position: fixed;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 60;
}

.flash.on { animation: flash .45s ease-out; }

@keyframes flash {
  0%   { opacity: .95; }
  100% { opacity: 0; }
}

/* ---------- the camera screen ---------- */

.lcd {
  position: relative;
  max-width: 1100px;
  min-height: calc(100vh - 2 * clamp(10px, 3vw, 32px));
  margin: 0 auto;
  padding: clamp(18px, 4vw, 44px);
  background: var(--lcd);
  border: 1px solid #222;
  border-radius: 14px;
  box-shadow:
    inset 0 0 120px rgba(0, 0, 0, .7),
    inset 0 0 0 1px rgba(255, 255, 255, .03),
    0 30px 80px rgba(0, 0, 0, .6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* subtle LCD scanlines */
.lcd::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .018) 0 1px, transparent 1px 3px);
}

.corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--ink);
  opacity: .55;
}
.corner.tl { top: 14px; left: 14px; border-right: 0; border-bottom: 0; }
.corner.tr { top: 14px; right: 14px; border-left: 0; border-bottom: 0; }
.corner.bl { bottom: 14px; left: 14px; border-right: 0; border-top: 0; }
.corner.br { bottom: 14px; right: 14px; border-left: 0; border-top: 0; }

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  color: var(--hud);
  letter-spacing: .06em;
  text-shadow: 0 0 6px rgba(159, 232, 200, .45);
}

.hud-bottom { margin-top: auto; padding-top: 2rem; }

.spec { color: var(--dim); text-shadow: none; }

.battery {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border: 2px solid var(--hud);
  position: relative;
}
.battery::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 4px;
  width: 3px;
  height: 6px;
  background: var(--hud);
}
.battery i { width: 6px; height: 10px; background: var(--hud); }
.battery i:last-child { animation: blink 1.4s steps(1) infinite; }

@keyframes blink { 50% { opacity: 0; } }

/* ---------- title ---------- */

.hero {
  text-align: center;
  padding: clamp(24px, 4vw, 48px) 0 clamp(30px, 6vw, 70px);
}

/* ---------- 3D stage ---------- */

.stage {
  position: relative;
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: linear-gradient(#7c8580, #3e4442);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .05), 0 20px 50px rgba(0, 0, 0, .5);
}
/* absolute so the canvas buffer size never feeds back into layout */
.stage canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.stage-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--hud);
  letter-spacing: .14em;
  animation: blink 1.4s steps(1) infinite;
}
.stage.live .stage-msg { display: none; }
.stage.dead { display: none; }

/* title sits over the bottom of the shot like a caption */
.stage + .title { margin-top: -.42em; z-index: 1; }
.stage.dead + .title { margin-top: clamp(16px, 5vw, 60px); }

@media (max-width: 640px) {
  .stage { aspect-ratio: 4 / 5; }
}

.title {
  position: relative;
  display: inline-block;
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(72px, 17vw, 200px);
  line-height: .9;
  letter-spacing: -.02em;
  color: #fff6ea;
  text-shadow: 0 0 30px rgba(255, 220, 180, .25);
}

/* chromatic aberration */
.title::before,
.title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  mix-blend-mode: screen;
  pointer-events: none;
}
.title::before { color: rgba(255, 40, 80, .6); transform: translate(-3px, 1px); }
.title::after  { color: rgba(40, 200, 255, .55); transform: translate(3px, -1px); }

.sub {
  margin: 1rem 0 0;
  color: var(--dim);
  font-size: 22px;
  letter-spacing: .12em;
  text-wrap: balance;
}

/* ---------- date stamp ---------- */

.stamp {
  font-family: var(--mono);
  color: var(--stamp);
  letter-spacing: .08em;
  text-shadow:
    0 0 2px #ff5a00,
    0 0 8px rgba(255, 120, 20, .7);
}

/* ---------- photo roll ---------- */

.roll {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: clamp(14px, 2.5vw, 26px);
}

.shot {
  all: unset;
  cursor: pointer;
  display: block;
  background: #f4f1ea;
  padding: 10px 10px 34px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  transform: rotate(var(--tilt, 0deg));
  transition: transform .25s ease;
  position: relative;
}
.shot:hover,
.shot:focus-visible { transform: rotate(0deg) scale(1.03); }
.shot:focus-visible { outline: 2px solid var(--stamp); outline-offset: 4px; }

.frame {
  position: relative;
  overflow: hidden;
  background: #000;
}

.shot .frame { aspect-ratio: 4 / 3; }

.frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* cheap CCD: punchy, warm, slightly blown */
  filter: contrast(1.08) saturate(1.18) brightness(1.04) sepia(.08);
}

/* vignette + highlight bloom */
.frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, .35) 100%);
  box-shadow: inset 0 0 18px rgba(255, 255, 255, .08);
}

.frame .stamp {
  position: absolute;
  right: 8px;
  bottom: 6px;
  z-index: 1;
  font-size: 18px;
}

.shot .label {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 8px;
  color: #2a2724;
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- empty card ---------- */

.empty {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  gap: .4rem;
  padding: 60px 20px;
  border: 1px dashed #333;
  color: var(--hud);
  text-align: center;
  text-shadow: 0 0 6px rgba(159, 232, 200, .45);
}
.empty strong {
  font-weight: 400;
  font-size: 34px;
  letter-spacing: .14em;
  animation: blink 1.4s steps(1) infinite;
}
.empty span { color: var(--dim); text-shadow: none; }

/* ---------- playback viewer ---------- */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(6, 6, 7, .96);
  display: grid;
  place-items: center;
  padding: 56px 16px 24px;
}
.viewer[hidden] { display: none; }

.viewer-hud {
  position: absolute;
  top: 16px;
  left: 20px;
  right: 64px;
  display: flex;
  justify-content: space-between;
  color: var(--hud);
  letter-spacing: .06em;
}

.viewer figure { margin: 0; max-width: min(1000px, 100%); }

/* hug the image so the stamp lands on the photo, not the letterbox */
.viewer .frame { width: fit-content; margin: 0 auto; }

.viewer .frame img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 78vh;
  margin: 0 auto;
}

.viewer .frame .stamp { font-size: clamp(18px, 2.4vw, 28px); right: 14px; bottom: 10px; }

.viewer figcaption {
  margin-top: 12px;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--ink);
}
.viewer figcaption small {
  display: block;
  font-family: var(--mono);
  font-style: normal;
  font-size: 16px;
  color: var(--dim);
  letter-spacing: .08em;
}

.viewer button {
  all: unset;
  cursor: pointer;
  color: var(--hud);
  font-family: var(--mono);
  padding: 10px 14px;
}
.viewer button:focus-visible { outline: 1px solid var(--hud); }
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: 30px; }
.viewer .prev { left: 4px; }
.viewer .next { right: 4px; }
.viewer .close { position: absolute; top: 4px; right: 8px; font-size: 36px; }

/* ---------- calm mode ---------- */

@media (prefers-reduced-motion: reduce) {
  .grain,
  .stage-msg,
  .battery i:last-child,
  .empty strong { animation: none; }
  .flash.on { animation: none; }
  .shot { transition: none; }
}

/* ---------- guestbook ---------- */

.guestbook { margin-top: clamp(40px, 7vw, 80px); }
.guestbook-head { margin-bottom: 20px; }

.hud-btn {
  all: unset;
  cursor: pointer;
  color: var(--hud);
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: .08em;
  padding: 4px 10px;
  border: 1px solid rgba(159, 232, 200, .4);
  text-shadow: 0 0 6px rgba(159, 232, 200, .45);
}
.hud-btn:hover, .hud-btn:focus-visible { background: rgba(159, 232, 200, .12); }
.hud-btn:disabled { opacity: .4; cursor: wait; }
.hud-btn.big { font-size: 24px; padding: 6px 16px; }

.guest { cursor: default; padding-bottom: 12px; margin: 0; }
.guest .label { position: static; display: block; margin-top: 8px; white-space: normal; line-height: 1.15; overflow-wrap: anywhere; }
.guest .label small {
  display: block;
  font-family: var(--mono);
  font-style: normal;
  font-size: 15px;
  color: #6d6862;
}
.guests-empty { grid-column: 1 / -1; color: var(--dim); text-align: center; margin: 10px 0 0; }

/* ---------- booth ---------- */

.booth {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(6, 6, 7, .94);
}
.booth[hidden] { display: none; }

.booth-lcd {
  width: min(560px, 100%);
  background: var(--lcd);
  border: 1px solid #2a2a2e;
  border-radius: 14px;
  padding: 14px;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, .6), 0 30px 80px rgba(0, 0, 0, .7);
  display: grid;
  gap: 12px;
}

.booth-hud { display: flex; justify-content: space-between; align-items: center; color: var(--hud); }
.booth-hud .hud-btn { border: 0; font-size: 30px; padding: 0 6px; }

.booth-screen {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 4px;
  overflow: hidden;
}
.booth-screen video,
.booth-screen img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.booth-screen video { transform: scaleX(-1); }

.booth-count {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 120px;
  color: #fff;
  text-shadow: 0 0 20px rgba(0, 0, 0, .6);
  pointer-events: none;
}

.booth-intro, .booth-sent {
  position: absolute;
  inset: 0;
  display: none;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  color: var(--ink);
  font-size: 24px;
}
.booth-intro p, .booth-sent p { margin: 0; }
.fine { color: var(--dim); font-size: 18px; }
.booth-sent p:first-child { color: var(--hud); font-size: 40px; letter-spacing: .14em; }

.shutter {
  all: unset;
  cursor: pointer;
  justify-self: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #e9e6df;
  box-shadow: 0 0 0 4px var(--lcd), 0 0 0 6px #e9e6df;
  display: none;
}
.shutter:active { transform: scale(.94); }
.shutter:focus-visible { box-shadow: 0 0 0 4px var(--lcd), 0 0 0 6px var(--stamp); }

.booth-form { display: none; gap: 10px; }
.booth-form input,
.booth-form textarea {
  width: 100%;
  background: #0b0b0c;
  border: 1px solid #333;
  color: var(--ink);
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  padding: 8px 10px;
  resize: none;
}
.booth-form input:focus, .booth-form textarea:focus { outline: 1px solid var(--hud); }
.booth-form .msg { position: relative; }
.booth-form .msg span { position: absolute; right: 8px; bottom: 6px; color: var(--dim); font-size: 16px; }
.booth-form .row { display: flex; justify-content: space-between; }

.booth-err { margin: 0; min-height: 1em; color: var(--stamp); text-align: center; }
.booth-err:empty { display: none; }

/* states */
.booth[data-state="intro"] .booth-intro,
.booth[data-state="sent"] .booth-sent { display: grid; }
.booth[data-state="live"] video,
.booth[data-state="count"] video { display: block; }
.booth[data-state="live"] .shutter { display: block; }
.booth[data-state="review"] img { display: block; }
.booth[data-state="review"] .booth-form { display: grid; }

/* the screen flash that actually lights the face */
.booth-white {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.booth-white.on { opacity: 1; }
