:root {
  color-scheme: light;
  font-family: "Jolligram Inter UI", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #fff8ed;
  color: #19151f;
  font-synthesis: none;
}

* { box-sizing: border-box; }

/*
 * The recipient view is a fixed, non-scrolling screen: the card scales to fit
 * instead of the page scrolling, so a finger on or near the card never moves
 * the page and Safari never rubber-bands it. Panning and pinch-zoom stay
 * available; double-tap zoom does not.
 */
html {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at 15% 5%, rgb(255 196 223 / 0.55), transparent 34rem),
    radial-gradient(circle at 85% 20%, rgb(174 229 255 / 0.65), transparent 30rem),
    #fff8ed;
}

button, a { font: inherit; }

[hidden] { display: none !important; }

.greeting-shell {
  display: flex;
  flex-direction: column;
  width: min(100%, 38rem);
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  padding:
    max(0.5rem, env(safe-area-inset-top))
    max(1rem, env(safe-area-inset-right))
    max(0.75rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

.greeting-header { display: flex; flex: none; justify-content: center; margin-bottom: 0.25rem; }

.greeting-brand {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  gap: 0.45rem;
  color: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  text-decoration: none;
}

.greeting-brand img { width: 1.5rem; height: 1.5rem; }

.greeting-panel { text-align: center; }

.greeting-panel h1 {
  margin: 0;
  font-size: clamp(1.35rem, 5.5vw, 1.75rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.greeting-panel .greeting-invite {
  margin: 0 0 0.7rem;
  color: #3a3045;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.greeting-panel > p { margin: 0.5rem 0 1rem; color: #625b69; }

.greeting-ready {
  display: grid;
  flex: 1 1 auto;
  /* A stray double tap near the card must not start a text selection. */
  -webkit-user-select: none;
  user-select: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  min-height: 0;
}

/* The space left for the card; the card fits inside it at exactly 9:16. */
.greeting-stage {
  display: grid;
  width: 100%;
  min-height: 0;
  place-items: center;
  container-type: size;
}

.greeting-canvas {
  position: relative;
  width: min(100%, calc((100dvh - 10rem) * 0.5625));
  width: min(100cqw, 100cqh * 9 / 16);
  aspect-ratio: 9 / 16;
  overflow: hidden;
  border: 1px solid rgb(25 21 31 / 0.1);
  border-radius: 1.5rem;
  background: #fff;
  box-shadow: 0 1rem 3rem rgb(79 52 101 / 0.18);
  /* The card owns every touch that starts on it: no scroll, zoom, callout,
     selection, or tap flash. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.greeting-artwork, .greeting-canvas canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

/* The finished greeting stays hidden until the opaque coating is painted. */
.greeting-canvas:not(.is-coated) .greeting-artwork { visibility: hidden; }

/* The coating is the element touches actually hit, so it declares its own
   touch-action instead of relying on inheritance from the card. */
.greeting-canvas .greeting-coating {
  pointer-events: auto;
  touch-action: none;
  transition: opacity 420ms ease;
}

.greeting-canvas.is-fully-revealed .greeting-coating { opacity: 0; }

.greeting-actions {
  display: grid;
  justify-items: center;
  gap: 0.25rem;
  min-height: 3rem;
  margin: 0.6rem auto 0;
  width: min(100%, 24rem);
}

.greeting-actions .greeting-button { width: 100%; }

.greeting-button, .greeting-quiet-button, .greeting-brand { touch-action: manipulation; }

.greeting-button {
  display: inline-flex;
  min-height: 3rem;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1.1rem;
  border: 0;
  border-radius: 999px;
  background: #201827;
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.greeting-quiet-button {
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #5b5166;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 650;
  text-decoration: underline;
  text-decoration-color: rgb(91 81 102 / 0.4);
  text-underline-offset: 0.2em;
}

.greeting-quiet-button:hover { color: #201827; }

.greeting-button:focus-visible,
.greeting-quiet-button:focus-visible,
.greeting-brand:focus-visible {
  outline: 3px solid #6f5cff;
  outline-offset: 3px;
}

.greeting-state {
  display: grid;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  place-content: center;
  padding: 2rem 1rem;
}

.greeting-state p { max-width: 26rem; }

.greeting-spinner {
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto 1rem;
  border: 4px solid rgb(32 24 39 / 0.15);
  border-top-color: #6f5cff;
  border-radius: 50%;
  animation: greeting-spin 800ms linear infinite;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes greeting-spin { to { transform: rotate(1turn); } }

@media (prefers-reduced-motion: reduce) {
  .greeting-spinner { animation: none; }
  .greeting-canvas .greeting-coating { transition: none; }
}

@media (orientation: landscape) and (max-height: 34rem) {
  .greeting-shell {
    position: relative;
    width: min(100%, 62rem);
    padding-block: max(0.5rem, env(safe-area-inset-top)) max(0.5rem, env(safe-area-inset-bottom));
  }
  .greeting-header {
    position: absolute;
    z-index: 1;
    top: max(0.25rem, env(safe-area-inset-top));
    right: max(1rem, env(safe-area-inset-right));
    margin: 0;
  }
  .greeting-ready {
    grid-template-columns: minmax(0, 1fr) minmax(12rem, 18rem);
    grid-template-rows: 1fr auto auto 1fr;
    column-gap: 1.5rem;
  }
  .greeting-stage { grid-column: 1; grid-row: 1 / -1; height: 100%; }
  .greeting-panel .greeting-invite { grid-column: 2; grid-row: 2; margin: 0 0 0.4rem; }
  .greeting-actions { grid-column: 2; grid-row: 3; margin: 0; }
}
