/*
 * Opened by a phone camera pointed at a printed card, outdoors, for about ten seconds.
 * The design borrows the card's own vocabulary: sticker lettering, sparkles, and a white
 * photo border, so the page reads as a continuation of the thing in the viewer's hand.
 */
@font-face {
  font-family: Fredoka;
  src: url('/fonts/fredoka-latin.woff2') format('woff2-variations');
  font-weight: 500 700;
  font-display: swap;
}

:root {
  --pitch: #0a1f4b;
  --royal: #1854a2;
  --chalk: #ffffff;
  --strike: #d81e27;   /* 5.08:1 with white text */
  --sun: #ffc300;
  --card-radius: 10px;
  --sheet: min(420px, 100%);
}

* { box-sizing: border-box; }

/* Class selectors below would otherwise beat the user agent's [hidden] rule and show every state at once. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: max(28px, env(safe-area-inset-top)) 20px calc(32px + env(safe-area-inset-bottom));
  background: var(--pitch);
  color: var(--chalk);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

/* Sparkles from the frame art, scattered asymmetrically behind the card. */
.sparkles {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  fill: var(--sun);
  opacity: 0.22;
  pointer-events: none;
}
.sparkles .small { opacity: 0.6; }

#app {
  position: relative;
  width: var(--sheet);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 22px;
}

.title {
  font-family: Fredoka, system-ui, sans-serif;
  font-weight: 700;
  font-size: clamp(38px, 13vw, 52px);
  line-height: 0.95;
  letter-spacing: -0.015em;
  margin: 0;
  text-align: center;
  transform: rotate(-2deg);
  /* Chunky offset shadow, echoing the outlined lettering printed on the card. */
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.28);
}

.stage { display: flex; flex-direction: column; gap: 18px; margin: 0; }

/* The clip, dressed as the printed postcard it came from. */
.card {
  margin: 0;
  padding: 10px 10px 42px;
  background: var(--chalk);
  border-radius: var(--card-radius);
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.42);
  transform: rotate(-1.3deg);
}
/* The clip sets the card's height, so nothing is cropped: these are people's faces. */
.card video, .card img {
  width: 100%;
  height: auto;
  aspect-ratio: 1080 / 1350;
  display: block;
  border-radius: 3px;
  background: var(--pitch);
}
.card.is-empty {
  display: grid;
  place-items: center;
  aspect-ratio: 1080 / 1430;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: none;
  border: 2px dashed rgba(255, 255, 255, 0.28);
}

#state-ready .card { animation: settle 420ms cubic-bezier(0.2, 1.1, 0.35, 1) both; }
@keyframes settle {
  from { opacity: 0; transform: rotate(-5deg) scale(0.94); }
  to { opacity: 1; transform: rotate(-1.3deg) scale(1); }
}

.loading-bar {
  width: 46%;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  animation: breathe 1.4s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: 0.35; } }

/* The loading placeholder stands in for the clip, so it keeps the card's size.
   A failure should not: it shrinks to a note, leaving room for what to do next. */
#state-missing .card.is-empty {
  aspect-ratio: auto;
  padding: 26px;
  transform: rotate(-1deg);
}
.missing-mark {
  font-family: Fredoka, system-ui, sans-serif;
  font-size: 44px;
  line-height: 1;
  font-weight: 700;
  opacity: 0.55;
}

.heading {
  font-family: Fredoka, system-ui, sans-serif;
  font-weight: 600;
  font-size: 22px;
  margin: 0;
  text-align: center;
}
.status { margin: 0; text-align: center; opacity: 0.8; max-width: 34ch; align-self: center; }

.button {
  font-family: Fredoka, system-ui, sans-serif;
  font-weight: 600;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 58px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  color: var(--chalk);
}
.button:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }
.button:active { transform: translateY(1px); }

/* One loud element on the page; everything else stays quiet. */
.loud {
  background: var(--strike);
  box-shadow: 0 10px 22px rgba(216, 30, 39, 0.36);
}
.loud[disabled] { opacity: 0.75; cursor: default; }
.quiet {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.4);
  font-size: 16px;
  min-height: 50px;
}

.marks { display: inline-flex; gap: 7px; }
.marks svg { width: 21px; height: 21px; display: block; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.how { font-size: 15px; }
.how summary {
  cursor: pointer;
  font-family: Fredoka, system-ui, sans-serif;
  font-weight: 500;
  padding: 6px 0;
  opacity: 0.9;
}
.how summary:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; border-radius: 4px; }
.how ul { margin: 6px 0 0; padding-left: 18px; opacity: 0.85; }
.how li { margin-bottom: 7px; }
.how b { font-weight: 650; }

.meta { margin: 0; text-align: center; font-size: 13px; opacity: 0.55; }

@media (prefers-reduced-motion: reduce) {
  #state-ready .card { animation: none; }
  .loading-bar { animation: none; }
  .button:active { transform: none; }
}
