/* The share page in LoomaKit's look (Sakura Night): OLED black, sakura as the one accent, glass
   cards, LoomaMotion's springs as easing. Colours from LoomaKit/Tokens/LoomaPalette.swift. */

@font-face {
  font-family: "Looma Rounded";
  src: url("/fonts/rounded-bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Looma Rounded";
  src: url("/fonts/rounded-black.woff2") format("woff2");
  font-weight: 900;
  font-display: swap;
}

:root {
  --sakura: #ff5fa2;
  --sakura-deep: #e8338a;
  --lilac: #b57cff;
  --spark: #7ae7ff;
  --mint: #6cf2c2;
  --peach: #ffb86b;
  --lemon: #f3e37a;
  --ember: #ff6a3d;
  --on-accent: #2a0618;
  --text: #fff4f8;
  --text-2: #d8c7e4;
  --text-3: #9b89ad;
  --glass: rgba(255, 255, 255, 0.05);
  --glass-strong: rgba(255, 255, 255, 0.13);
  --hairline: rgba(255, 255, 255, 0.1);
  /* LoomaMotion springs, approximated as curves */
  --jelly: cubic-bezier(0.34, 1.56, 0.64, 1);
  --bloom: cubic-bezier(0.22, 1.3, 0.36, 1);
  --press: cubic-bezier(0.3, 1.4, 0.5, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: #000;
  color: var(--text);
  font-family: "Looma Rounded", ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif;
  font-weight: 700;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: -60%;
  z-index: -1;
  background:
    radial-gradient(40% 35% at 20% 10%, rgba(255, 95, 162, 0.16), transparent 70%),
    radial-gradient(45% 40% at 85% 90%, rgba(181, 124, 255, 0.14), transparent 70%);
  animation: drift 24s ease-in-out infinite alternate;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px 32px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.brand {
  font-weight: 900;
  font-size: 22px;
  background: linear-gradient(90deg, var(--sakura), var(--lilac));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

h1 { font-size: clamp(24px, 6vw, 32px); font-weight: 900; margin: 20px 0 6px; }
h2 { font-size: 20px; font-weight: 900; margin: 0 0 12px; }
.quiet { color: var(--text-2); margin: 4px 0; }
.small { font-size: 13px; color: var(--text-3); }
.center { display: flex; flex-direction: column; align-items: center; text-align: center; min-height: 60vh; justify-content: center; }
.center-text { text-align: center; }

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
  transition: transform 0.22s var(--press), background 0.2s;
}
button:active { transform: scale(0.94); }
button:focus-visible { outline: 3px solid var(--spark); outline-offset: 2px; }

.pill {
  background: var(--glass-strong);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 15px;
}
.pill:disabled { opacity: 0.7; cursor: default; }

/* Waiting: the QR and its draining ring */
.qr-card {
  position: relative;
  width: min(78vw, 360px);
  aspect-ratio: 1;
  padding: 14px;
  border-radius: 28px;
  background: var(--glass);
  border: 1px solid var(--hairline);
  box-shadow: 0 0 60px rgba(255, 95, 162, 0.25);
}
.ring { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ring rect {
  fill: none;
  stroke: var(--sakura);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
  filter: drop-shadow(0 0 6px var(--sakura));
}
@keyframes drain { to { stroke-dashoffset: 100; stroke: var(--ember); } }
#qr { position: relative; width: 100%; height: 100%; }
#qr svg { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 16px; }
#qr svg.arriving { animation: bloom-in 0.6s var(--bloom) both; }
#qr svg.leaving { animation: fade-out 0.3s ease both; }
@keyframes bloom-in { from { transform: scale(0.6) rotate(-6deg); opacity: 0; filter: blur(6px); } }
@keyframes fade-out { to { transform: scale(1.08); opacity: 0; filter: blur(8px); } }

/* The bud: connecting, claimed, ended */
.bud {
  width: 96px;
  height: 96px;
  border-radius: 50% 50% 50% 10%;
  transform: rotate(-45deg);
  background: radial-gradient(circle at 35% 35%, var(--sakura), var(--sakura-deep) 70%);
  box-shadow: 0 0 50px rgba(255, 95, 162, 0.5);
  animation: breathe 1.6s ease-in-out infinite;
}
.bud.open { background: radial-gradient(circle at 35% 35%, var(--mint), var(--spark) 80%); box-shadow: 0 0 60px rgba(108, 242, 194, 0.5); animation: bloom-in 0.7s var(--bloom) both, breathe 1.6s 0.7s ease-in-out infinite; }
.bud.closed { background: radial-gradient(circle at 35% 35%, var(--lilac), #5b3a8a 80%); box-shadow: 0 0 40px rgba(181, 124, 255, 0.4); animation: none; }
body.refused .bud.closed { background: radial-gradient(circle at 35% 35%, var(--ember), #8a2a12 80%); box-shadow: 0 0 40px rgba(255, 106, 61, 0.5); }
@keyframes breathe { 50% { transform: rotate(-45deg) scale(1.08); } }

/* Live: who is connected, the emoji, the time left */
.who {
  text-align: center;
  padding: 18px;
  border-radius: 24px;
  background: var(--glass);
  border: 1px solid var(--hairline);
  margin-bottom: 18px;
}
.emoji-row { display: flex; justify-content: center; gap: 14px; margin: 12px 0 6px; }
.emoji {
  font-size: clamp(40px, 12vw, 56px);
  line-height: 1;
  animation: pop-in 0.5s var(--jelly) both;
  animation-delay: calc(var(--i) * 90ms);
}
@keyframes pop-in { from { transform: scale(0.2) translateY(20px); opacity: 0; } }

.capsule {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  background: var(--glass-strong);
  color: var(--text);
  transition: color 0.4s, box-shadow 0.4s;
}
.capsule[data-unit="hour"] { color: var(--peach); }
.capsule[data-unit="minute"] { color: var(--sakura); }
.capsule[data-unit="second"] { color: var(--ember); box-shadow: 0 0 18px rgba(255, 106, 61, 0.45); animation: throb 1s ease-in-out infinite; }
@keyframes throb { 50% { transform: scale(1.06); } }

#list { display: flex; flex-direction: column; gap: 14px; margin: 14px 0 22px; }
.card {
  padding: 18px;
  border-radius: 24px;
  background: linear-gradient(160deg, rgba(255, 95, 162, 0.12), rgba(181, 124, 255, 0.06)), var(--glass);
  border: 1px solid var(--hairline);
}
.card h2 { display: flex; align-items: center; gap: 10px; }
.in-clipboard { font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--mint); color: #062a1e; animation: pop-in 0.4s var(--jelly) both; }
.card.drop { animation: drop 0.65s var(--jelly) both; }
@keyframes drop { from { transform: translateY(-60px) scale(0.85); opacity: 0; } }
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: "label label label" "value reveal copy";
  align-items: center;
  gap: 4px 8px;
  padding: 10px 0;
  border-top: 1px solid var(--hairline);
}
.row .label { grid-area: label; font-size: 13px; color: var(--text-3); }
.row .value { grid-area: value; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 17px; overflow-wrap: anywhere; user-select: all; }
.row .value.masked { letter-spacing: 2px; color: var(--text-2); user-select: none; }
.row .ghost { grid-area: reveal; }
.row .copy { grid-area: copy; }

.copy {
  background: var(--sakura);
  color: var(--on-accent);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 900;
}
.copy.pulse { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(255, 95, 162, 0); transform: scale(1.06); } 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 95, 162, 0.6); } }
.ghost { background: var(--glass-strong); border-radius: 14px; padding: 10px 12px; }
.ghost.wide { width: 100%; padding: 14px; color: var(--text-2); }

.note {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  color: var(--peach);
  background: rgba(255, 184, 107, 0.1);
  border: 1px solid rgba(255, 184, 107, 0.3);
  max-width: 420px;
}

#toasts { position: fixed; left: 0; right: 0; bottom: max(20px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 900;
  background: var(--mint);
  color: #062a1e;
  animation: pop-in 0.45s var(--jelly) both;
  transition: opacity 0.5s, transform 0.5s;
}
.toast.peach { background: var(--peach); color: #2e1500; }
.toast.ember { background: var(--ember); color: #2b0a00; }
.toast.out { opacity: 0; transform: translateY(12px); }

.petal {
  position: fixed;
  width: 14px;
  height: 14px;
  border-radius: 50% 0 50% 50%;
  background: var(--sakura);
  pointer-events: none;
  z-index: 10;
  animation: fall 1.2s cubic-bezier(0.2, 0.7, 0.4, 1) forwards;
}
.petal:nth-child(3n) { background: var(--lilac); }
.petal:nth-child(4n) { background: #ffd1e5; }
@keyframes fall { to { transform: translate(var(--dx), var(--dy)) rotate(var(--r)) scale(0.4); opacity: 0; } }
@keyframes drift { to { transform: translate(4%, -3%) rotate(3deg); } }

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
