@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600&family=Caveat:wght@500;700&display=swap');

:root {
  --paper: #f3eee6;
  --paper-2: #ebe4d8;
  --card: #fffdf9;
  --ink: #1b1714;
  --ink-2: #4a423b;
  --muted: #8a7f75;
  --line: rgba(27, 23, 20, 0.12);
  --accent: #e2502c;
  --accent-ink: #fff;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(27,23,20,.06), 0 8px 24px rgba(27,23,20,.10);
  --shadow-lg: 0 2px 4px rgba(27,23,20,.08), 0 24px 60px rgba(27,23,20,.22);
  --serif: 'Instrument Serif', Georgia, serif;
  --sans: 'DM Sans', system-ui, sans-serif;
  --hand: 'Caveat', 'Segoe Print', cursive;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }

.brand {
  font-family: var(--serif);
  font-size: 28px;
  letter-spacing: -0.01em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand i { font-style: italic; color: var(--accent); }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }

/* ---------- buttons & inputs ---------- */
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ink);
  color: var(--paper);
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
  text-decoration: none;
  min-height: 50px;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.accent { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.block { width: 100%; }
.btn.small { padding: 8px 14px; min-height: 38px; font-size: 14px; }
.btn:focus-visible, .field input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }

.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  background: var(--card);
  font-size: 16px; /* stops iOS zoom */
}
.field input:focus { border-color: var(--ink); outline: none; }
.hint { font-size: 13px; color: var(--muted); }
.error { color: var(--danger); font-size: 14px; min-height: 20px; margin: 4px 0 10px; }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- the instant-photo frame ---------- */
.instant {
  background: var(--card);
  padding: 6% 6% 0;
  border-radius: 3px;
  box-shadow: var(--shadow);
  position: relative;
}
.instant .photo {
  aspect-ratio: 4 / 5;
  background: #26211d;
  overflow: hidden;
  position: relative;
}
.instant .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.instant .caption {
  font-family: var(--hand);
  font-weight: 500;
  color: #2a2420;
  text-align: center;
  height: 22%;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1.05;
  overflow: hidden;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { background: none; border: 0; color: var(--accent); font-weight: 700; margin-left: 10px; cursor: pointer; padding: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- back of the print (QR screen + their card) ---------- */
.print-back {
  position: relative;
  aspect-ratio: 88 / 107;
  border-radius: 4px;
  background:
    repeating-linear-gradient(115deg, rgba(255,255,255,.018) 0 2px, transparent 2px 6px),
    linear-gradient(160deg, #2e2a27, #1a1817);
  color: #d8cec3;
  box-shadow: 0 2px 6px rgba(0,0,0,.35), 0 30px 70px rgba(0,0,0,.45);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4%;
  padding: 9% 9% 12%;
  text-align: center;
  overflow: hidden;
}
.pb-top {
  position: absolute; top: 5%; left: 7%; right: 7%;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 10px; letter-spacing: .24em; text-transform: uppercase; color: #8d8278;
}
.pb-dot { width: 7px; height: 7px; border-radius: 50%; background: #ff7a50; }
.pb-qr { background: #fff; padding: 5%; border-radius: 6px; width: 64%; aspect-ratio: 1; line-height: 0; }
.pb-qr svg { width: 100%; height: 100%; display: block; }
.pb-qr svg path, .pb-qr svg rect[fill="black"] { fill: #1b1714; }
.pb-occasion {
  font-family: var(--hand); font-weight: 700; color: #f3eee6;
  font-size: clamp(26px, 8vw, 38px); line-height: 1; max-width: 100%;
  overflow-wrap: anywhere;
}
.pb-occasion.empty { color: #8d8278; font-weight: 500; }
.pb-stamp {
  display: flex; gap: 14px; justify-content: center;
  font-family: ui-monospace, 'Courier New', monospace; font-size: 13px; letter-spacing: .08em;
  color: #ff9a76; text-transform: uppercase;
}
.pb-from { font-family: var(--serif); font-style: italic; font-size: 17px; color: #b8ada2; }
.pb-stripes { position: absolute; bottom: 6%; left: 10%; right: 10%; height: 3px; background: repeating-linear-gradient(90deg, rgba(255,255,255,.1) 0 10px, transparent 10px 16px); }
.tap {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 2%;
  font-size: 14px; font-weight: 600; color: #f3eee6;
  background: rgba(255,255,255,.08); padding: 8px 14px; border-radius: 999px;
}
.tap i { width: 8px; height: 8px; border-radius: 50%; background: #ff8a65; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.6); opacity: .4; } }

.dark-stage {
  background: radial-gradient(120% 80% at 50% 30%, #2a221d 0%, #141110 60%, #0d0b0a 100%);
  color: #f3eee6;
}
.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; padding: 8px 14px; border-radius: 999px;
  background: rgba(255,255,255,.08); color: #f3eee6;
}
.status-pill .spinner { width: 14px; height: 14px; border-width: 2px; }
.status-pill.ok { background: rgba(120, 200, 140, .16); color: #b9f0c6; }
.status-pill.bad { background: rgba(255, 90, 70, .18); color: #ffb4a6; }
