/* Photo Booth, Regency / Bridgerton theme: powder blue, cream paper,
   gold flourishes, pastel flowers and a wax seal. */

@font-face {
  font-family: "Pinyon Script";
  src: url("fonts/pinyon-script.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("fonts/cormorant-garamond.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Cormorant Garamond";
  src: url("fonts/cormorant-garamond-italic.woff2") format("woff2");
  font-style: italic;
  font-display: swap;
}

:root {
  --navy: #1f2f4d;
  --ink: #33405c;
  --muted: #6b7590;
  --gold: #b8975a;
  --gold-light: #e3cf9f;
  --cream: #fbf7f0;
  --sky: #cddcee;
  --lavender: #e4d9f0;
  --rose: #8f3f60;
  --ok: #5f8a63;
  --script: "Pinyon Script", "Snell Roundhand", cursive;
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--sky);
  background-image: url("img/pattern.svg"), linear-gradient(160deg, #d6e4f3 0%, var(--sky) 45%, var(--lavender) 100%);
  background-attachment: fixed;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* The invitation card */
.paper {
  position: relative;
  width: 100%;
  max-width: 460px;
  padding: 44px 30px 30px;
  background: var(--cream);
  border: 1px solid var(--gold);
  outline: 1px solid var(--gold-light);
  outline-offset: -9px;
  border-radius: 4px;
  box-shadow: 0 18px 40px rgba(31, 47, 77, .18), 0 2px 6px rgba(31, 47, 77, .08);
  text-align: center;
}

.corner {
  position: absolute;
  width: 92px;
  height: 92px;
  pointer-events: none;
  user-select: none;
}
.corner.tl { top: -6px; left: -6px; }
.corner.tr { top: -6px; right: -6px; transform: scaleX(-1); }
.corner.bl { bottom: -6px; left: -6px; transform: scaleY(-1); }
.corner.br { bottom: -6px; right: -6px; transform: scale(-1, -1); }

.masthead { position: relative; }

.kicker {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--gold);
}

h1, h2 {
  font-family: var(--script);
  font-weight: 400;
  color: var(--navy);
  line-height: 1.1;
}
h1 {
  margin: 6px 0 2px;
  font-size: clamp(40px, 12vw, 56px);
  overflow-wrap: anywhere;
}
h2 { margin: 6px 0 8px; font-size: 44px; }

.date {
  margin: 0;
  font-style: italic;
  color: var(--muted);
}

.flourish {
  display: block;
  width: 200px;
  max-width: 70%;
  margin: 14px auto;
}

.view p { margin: 0 0 14px; }

.lead {
  font-style: italic;
  font-size: 22px;
  color: var(--navy);
}

#subtitle {
  font-weight: 600;
  color: var(--navy);
}

.hint {
  font-size: 15px;
  font-style: italic;
  color: var(--muted);
}

/* Name field */
.field {
  display: block;
  margin: 22px 0 18px;
  text-align: left;
}
.field span {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
  letter-spacing: .06em;
  color: var(--muted);
}
.field input {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 19px;
  color: var(--navy);
  background: #fff;
  border: 1px solid #d8cdb5;
  border-radius: 3px;
  appearance: none;
}
.field input:focus {
  outline: 2px solid var(--gold-light);
  border-color: var(--gold);
}
.field input::placeholder { color: #b3b0a8; font-style: italic; }

/* Buttons */
.button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  margin: 6px 0 8px;
  padding: 12px 20px;
  font: inherit;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .03em;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, box-shadow .12s ease;
}
.button svg { width: 26px; height: 26px; flex: none; }
.button:active { transform: scale(.98); }
.button.primary {
  color: var(--cream);
  background: linear-gradient(180deg, #2d416a, var(--navy));
  border: 1px solid var(--navy);
  box-shadow: inset 0 0 0 3px var(--navy), inset 0 0 0 4px var(--gold), 0 6px 14px rgba(31, 47, 77, .25);
}
.button.secondary {
  color: var(--navy);
  background: transparent;
  border: 1px solid var(--gold);
}
.button:focus-visible { outline: 3px solid var(--gold-light); outline-offset: 2px; }

/* Upload queue */
.queue {
  list-style: none;
  margin: 16px 0 10px;
  padding: 0;
  text-align: left;
}
.queue li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #eee4d2;
}
.queue img {
  width: 54px;
  height: 54px;
  flex: none;
  object-fit: cover;
  border: 2px solid #fff;
  outline: 1px solid #d8cdb5;
  border-radius: 2px;
  background: var(--lavender) url("img/seal.svg") center / 60% no-repeat;
}
.queue img.broken { color: transparent; }
.queue li > div { flex: 1; min-width: 0; }
.queue span {
  display: block;
  font-size: 16px;
  font-style: italic;
  color: var(--muted);
}
.queue li.ok span { color: var(--ok); font-style: normal; font-weight: 600; }
.queue li.ok span::before { content: "✓ "; }
.queue li.err span { color: var(--rose); font-style: normal; font-weight: 600; }

progress {
  display: block;
  width: 100%;
  height: 6px;
  margin-top: 6px;
  border: 0;
  border-radius: 3px;
  background: #efe7d6;
  appearance: none;
  overflow: hidden;
}
progress::-webkit-progress-bar { background: #efe7d6; border-radius: 3px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--gold-light), var(--gold)); border-radius: 3px; }
progress::-moz-progress-bar { background: var(--gold); border-radius: 3px; }
.queue li.ok progress::-webkit-progress-value { background: var(--ok); }
.queue li.ok progress::-moz-progress-bar { background: var(--ok); }
.queue li.err progress { opacity: .35; }

/* Confirmation */
.done .seal {
  display: block;
  width: 116px;
  height: 116px;
  margin: 4px auto 0;
  filter: drop-shadow(0 6px 8px rgba(110, 44, 73, .35));
  animation: stamp .55s cubic-bezier(.2, 1.4, .4, 1) both;
}
@keyframes stamp {
  from { transform: scale(1.8) rotate(-18deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}
#done-text { font-size: 21px; font-weight: 600; color: var(--navy); }

footer .flourish { margin-top: 22px; }
.signature {
  margin: 0;
  font-style: italic;
  color: var(--muted);
}
.signature span {
  font-family: var(--script);
  font-style: normal;
  font-size: 30px;
  color: var(--navy);
}

/* Admin page */
.admin .stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 0 20px;
}
.admin .stat {
  padding: 12px 8px;
  border: 1px solid #e6dcc6;
  border-radius: 3px;
  background: #fff;
}
.admin .stat b {
  display: block;
  font-size: 26px;
  color: var(--navy);
}
.admin .stat small { color: var(--muted); font-size: 14px; }
a.button { text-decoration: none; }
.admin code {
  display: block;
  margin: 6px 0 16px;
  padding: 8px;
  font-size: 13px;
  word-break: break-all;
  background: #fff;
  border: 1px dashed #d8cdb5;
}

/* Printable QR card */
.qr-card .qr {
  display: block;
  width: 260px;
  max-width: 80%;
  margin: 8px auto 14px;
  padding: 10px;
  background: var(--cream);
  border: 1px solid var(--gold);
}
.qr-card .steps { font-size: 18px; }
.print-only { display: none; }
@media print {
  body { background: #fff; padding: 0; }
  .paper { box-shadow: none; max-width: 14cm; margin: 1cm auto; }
  .no-print { display: none !important; }
  .print-only { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .done .seal { animation: none; }
  .button { transition: none; }
}

@media (max-width: 360px) {
  .paper { padding: 40px 20px 26px; }
  .corner { width: 72px; height: 72px; }
}

/* Admin gallery */
.paper.wide { max-width: 1100px; }
.button.small {
  width: auto;
  min-height: 42px;
  margin: 0;
  padding: 8px 18px;
  font-size: 17px;
}
.gallery-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin: 0 0 14px;
}
.filter select {
  min-height: 42px;
  max-width: 100%;
  padding: 6px 12px;
  font: inherit;
  font-size: 17px;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--gold);
  border-radius: 999px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr));
  gap: 12px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}
@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .lb-bottom { flex-direction: column; gap: 8px; }
  .lb-bottom p { width: 100%; text-align: center; }
}
.grid li { min-width: 0; }
.grid a {
  display: block;
  padding: 6px 6px 4px;
  color: var(--muted);
  text-decoration: none;
  background: #fff;
  border: 1px solid #e6dcc6;
  border-radius: 3px;
  box-shadow: 0 2px 6px rgba(31, 47, 77, .08);
  transition: transform .12s ease, box-shadow .12s ease;
}
.grid a:hover, .grid a:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(31, 47, 77, .16);
  outline: none;
  border-color: var(--gold);
}
.grid img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--lavender);
}
.grid span { margin-top: 4px; color: var(--navy); }
.grid small { font-size: 13px; }
.grid .no-thumb img {
  object-fit: contain;
  padding: 30%;
  content: url("img/seal.svg");
}
.grid span, .grid small {
  display: block;
  font-size: 14px;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Full screen viewer */
body.lb-open { overflow: hidden; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: max(10px, env(safe-area-inset-top)) 10px max(12px, env(safe-area-inset-bottom));
  color: var(--cream);
  background: rgba(17, 25, 43, .96);
}
.lb-top, .lb-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}
.lb-top span { font-size: 16px; letter-spacing: .1em; color: var(--gold-light); }
.lb-bottom p { margin: 0; font-style: italic; font-size: 18px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-bottom .button { color: var(--cream); border-color: var(--gold); flex: none; }
.lb-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: 3px solid var(--cream);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.lb-error { text-align: center; color: var(--gold-light); }
.lb-btn {
  width: 48px;
  height: 48px;
  flex: none;
  font: inherit;
  font-size: 26px;
  line-height: 1;
  color: var(--cream);
  background: rgba(31, 47, 77, .7);
  border: 1px solid var(--gold);
  border-radius: 50%;
  cursor: pointer;
}
.lb-btn:disabled { opacity: .25; cursor: default; }
.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 34px;
}
#lb-prev { left: 4px; }
#lb-next { right: 4px; }
@media (hover: none) {
  /* On phones, swipe; the arrows stay discreet. */
  .lb-nav { opacity: .55; }
}

/* Deletion */
.button.danger {
  color: #fff;
  background: linear-gradient(180deg, #a14d70, var(--rose));
  border: 1px solid var(--rose);
}
.button:disabled { opacity: .45; cursor: default; transform: none; }
.grid.selecting a { cursor: pointer; }
.grid li { position: relative; }
.grid.selecting li::after {
  content: "";
  position: absolute;
  top: 12px;
  right: 12px;
  width: 26px;
  height: 26px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(31, 47, 77, .35);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  pointer-events: none;
}
.grid.selecting li.selected::after {
  content: "✓";
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--rose);
}
.grid li.selected a {
  border-color: var(--rose);
  outline: 2px solid var(--rose);
}
.grid li.selected img { opacity: .8; }

body.select-open { padding-bottom: 110px; }
.select-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: var(--cream);
  border-top: 1px solid var(--gold);
  box-shadow: 0 -6px 18px rgba(31, 47, 77, .15);
}
.select-bar span { font-style: italic; color: var(--navy); }
.select-bar div { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.lb-actions { display: flex; gap: 8px; flex: none; }
.lb-bottom .button.danger { color: #fff; border-color: var(--rose); }

dialog.confirm {
  /* .paper is position: relative, a modal must stay fixed and centred. */
  position: fixed;
  inset: 0;
  width: min(420px, calc(100vw - 32px));
  max-width: none;
  height: fit-content;
  max-height: calc(100dvh - 32px);
  overflow: auto;
  margin: auto;
  padding: 28px 24px 22px;
}
dialog.confirm::backdrop { background: rgba(17, 25, 43, .7); }
dialog.confirm .seal { display: block; width: 64px; height: 64px; margin: 0 auto; }
dialog.confirm h2 { font-size: 36px; margin: 4px 0 6px; }
dialog.confirm p { margin: 0 0 10px; }
dialog.confirm .field { margin: 14px 0 6px; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: center;
  margin: 0;
  padding: 10px 20px;
  color: var(--cream);
  background: var(--navy);
  border: 1px solid var(--gold);
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .25);
}
.toast.error { background: var(--rose); }
body.select-open .toast { bottom: 120px; }
/* In the viewer, keep the buttons at the bottom visible. */
body.lb-open .toast { top: max(70px, env(safe-area-inset-top)); bottom: auto; }

/* Notes for the person celebrated */
.admin .stat.wide-stat { grid-column: 1 / -1; }
.notes {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 14px;
  text-align: left;
}
.letter {
  position: relative;
  padding: 18px 18px 12px;
  background: #fff url("img/pattern.svg") repeat;
  background-color: #fffdf8;
  border: 1px solid #e6dcc6;
  border-left: 3px solid var(--gold);
  border-radius: 3px;
  box-shadow: 0 2px 6px rgba(31, 47, 77, .08);
}
.letter-text {
  margin: 0 0 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 19px;
  color: var(--ink);
}
.letter-sign {
  margin: 0;
  font-family: var(--script);
  font-size: 26px;
  color: var(--navy);
  text-align: right;
}
.letter-sign small {
  display: block;
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
  color: var(--muted);
}
.letter-delete {
  position: absolute;
  bottom: 12px;
  left: 12px;
  padding: 2px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--rose);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  opacity: .7;
}
.letter-delete:hover, .letter-delete:focus-visible { opacity: 1; border-color: var(--rose); outline: none; }

/* Counter of what this phone shared */
.tally {
  margin: 4px 0 0;
  padding: 8px 14px;
  font-size: 16px;
  color: var(--ok);
  background: #f1f6ef;
  border: 1px solid #cfe0cb;
  border-radius: 18px;
}
.tally::before { content: "✓ "; font-weight: 700; }
#done-tally { margin-bottom: 14px; }

/* Optional note */
.note {
  margin: 0 0 18px;
  text-align: left;
  border: 1px solid #e6dcc6;
  border-radius: 3px;
  background: #fffdf8;
}
.note summary {
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  font-size: 18px;
  color: var(--navy);
}
.note summary::-webkit-details-marker { display: none; }
.note summary::before { content: "✒ "; color: var(--gold); }
.note summary em { color: var(--muted); font-size: 15px; }
.note[open] summary { border-bottom: 1px dashed #e6dcc6; }
.note textarea {
  display: block;
  width: calc(100% - 28px);
  margin: 12px 14px 4px;
  padding: 10px 12px;
  font: inherit;
  font-size: 18px;
  color: var(--navy);
  background: #fff;
  border: 1px solid #d8cdb5;
  border-radius: 3px;
  resize: vertical;
}
.note textarea:focus { outline: 2px solid var(--gold-light); border-color: var(--gold); }
.note textarea::placeholder { color: #b3b0a8; font-style: italic; }
.note .note-help { margin: 0 14px 8px; font-size: 14px; }
.note .button { margin: 0 14px 14px; }
.note-ok, .note-status, #done-note { margin: 0 14px 14px; font-size: 16px; color: var(--ok); }
.note-status, #done-note { margin: 0 0 12px; }
.note-ok.error, .note-status.error, #done-note.error { color: var(--rose); }

/* Add to the home screen */
.button.install { margin: 18px auto 0; gap: 8px; }
.button.install svg { width: 20px; height: 20px; }
.install-help { text-align: left; }
.install-help h2 { text-align: center; font-size: 34px; }
.install-help .app-icon {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 4px;
  border-radius: 16px;
  box-shadow: 0 4px 12px rgba(31, 47, 77, .25);
}
.install-help ol { margin: 6px 0 12px; padding-left: 22px; }
.install-help li { margin: 0 0 10px; }
.install-help .hint { text-align: center; }
.inline-icon {
  width: 22px;
  height: 22px;
  vertical-align: -5px;
  color: #2f6fdb;
}
