/* WebPigeon - single-screen P2P file sender.
   Dual theme via prefers-color-scheme. One accent (emerald), locked across
   both modes. One radius scale: 16px surfaces, full-pill interactive. Calm
   motion (entrance + feedback only), all gated behind prefers-reduced-motion. */

:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef0ea;
  --fg: #1b1d18;
  --muted: #6b6e64;
  --line: #e3e5dd;
  --line-strong: #d2d5c9;
  --accent: #0f9d76;
  --accent-soft: #e4f5ee;
  --accent-fg: #ffffff;
  --good: #0f9d76;
  --bad: #d1453b;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow-sm: 0 1px 2px rgba(27, 29, 24, 0.04), 0 1px 3px rgba(27, 29, 24, 0.06);
  --shadow-lg: 0 24px 60px rgba(27, 29, 24, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14150f;
    --surface: #1e201a;
    --surface-2: #282b21;
    --fg: #edefe7;
    --muted: #9a9d90;
    --line: #32352a;
    --line-strong: #424636;
    --accent: #3bc99a;
    --accent-soft: #1c2c25;
    --accent-fg: #0f140f;
    --good: #3bc99a;
    --bad: #f0786d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.50);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main {
  width: 100%;
  max-width: 520px;
  padding: 48px 20px 96px;
  display: flex;
  flex-direction: column;
  gap: 36px;
}

/* ── Identity ───────────────────────────────────────────────────────────── */
.who { text-align: center; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  margin-bottom: 32px;
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; color: var(--fg); }
.brand-mark { display: inline-flex; }

.you-are {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.who h1 {
  margin: 6px 0 0;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.05;
}
.room-hint {
  margin: 12px auto 0;
  max-width: 34ch;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* ── Notice ─────────────────────────────────────────────────────────────── */
.notice {
  margin: 0;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--fg);
  font-size: 13.5px;
  text-align: center;
}

/* ── Drop zone ──────────────────────────────────────────────────────────── */
.drop {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}
.drop-inner { padding: 40px 22px; text-align: center; }
.drop-icon {
  display: inline-flex;
  color: var(--muted);
  margin-bottom: 14px;
  transition: color 0.18s ease, transform 0.18s ease;
}
.drop.over {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  transform: scale(1.01);
}
.drop.over .drop-icon { color: var(--accent); transform: translateY(-2px); }
.drop-title { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.drop-sub { margin: 6px 0 20px; font-size: 13px; color: var(--muted); }

/* Dim the send area until a recipient is chosen. */
.drop.needs-target .drop-icon { opacity: 0.55; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-ghost, .btn-primary {
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  border-radius: 999px;
  padding: 10px 20px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.16s ease, border-color 0.16s ease, filter 0.16s ease;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--fg);
}
.btn-ghost:hover { border-color: var(--muted); background: var(--surface-2); }
.btn-primary {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--accent-fg);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost:active, .btn-primary:active { transform: scale(0.97); }
.btn-ghost:focus-visible, .btn-primary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Section titles ─────────────────────────────────────────────────────── */
.section-title {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Avatar ─────────────────────────────────────────────────────────────── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #fff;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  flex: none;
  box-shadow: var(--shadow-sm);
}

/* ── Radar ──────────────────────────────────────────────────────────────── */
.radar-wrap { text-align: center; }
.radar-prompt {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.2s ease;
}
.radar-prompt.ready { color: var(--accent); }

.radar {
  position: relative;
  width: 100%;
  max-width: 360px;
  margin: 8px auto 0;
  aspect-ratio: 1;
}

/* Static guide rings: the radar "grid" the pings travel across. */
.radar-rings { position: absolute; inset: 0; }
.radar-rings span {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.radar-rings span:nth-child(1) { width: 34%; height: 34%; }
.radar-rings span:nth-child(2) { width: 67%; height: 67%; }
.radar-rings span:nth-child(3) { width: 100%; height: 100%; }

/* Beacon: waves continuously expand from the center and fade, staggered so a
   ping is always travelling outward, like a real radar sweep. */
.radar-ping { position: absolute; inset: 0; }
.radar-ping span {
  position: absolute;
  top: 50%; left: 50%;
  width: 100%; height: 100%;
  border-radius: 999px;
  border: 1.5px solid var(--accent);
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  animation: radar-ping 3.3s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}
.radar-ping span:nth-child(2) { animation-delay: 1.1s; }
.radar-ping span:nth-child(3) { animation-delay: 2.2s; }
/* When no peers are present, the beacon glows a touch stronger (actively scanning). */
.radar.waiting .radar-ping span { border-color: var(--accent); }

.radar-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.avatar-self { width: 60px; height: 60px; font-size: 24px; }
.radar-you { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

/* Peers are absolutely positioned around the rings (placement set inline). */
.radar-peers { list-style: none; margin: 0; padding: 0; }
.radar-peers li {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 84px;
  cursor: pointer;
  user-select: none;
  animation: peer-pop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.radar-peers .avatar {
  width: 52px; height: 52px; font-size: 21px;
  border: 2px solid transparent;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.radar-peers li:hover .avatar { transform: scale(1.06); }
.radar-peers li:active .avatar { transform: scale(0.96); }
.radar-peers li.selected .avatar {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.radar-peer-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg);
  max-width: 84px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color 0.15s ease;
}
.radar-peers li.selected .radar-peer-name { color: var(--accent); font-weight: 600; }
.radar-peers li:focus-visible { outline: none; }
.radar-peers li:focus-visible .avatar { outline: 2px solid var(--accent); outline-offset: 2px; }

.radar-name { margin: 18px 0 0; font-size: 13.5px; color: var(--muted); }
.radar-name strong { color: var(--fg); font-weight: 600; }
.radar-empty {
  margin: 12px auto 0;
  max-width: 32ch;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* ── Transfer log ───────────────────────────────────────────────────────── */
.log ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.log li {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name status" "bar bar";
  gap: 7px 12px;
  align-items: center;
  font-size: 13.5px;
  animation: row-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.log .name { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.log .status { grid-area: status; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.log .progress {
  grid-area: bar;
  height: 6px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden;
}
.log .progress > span {
  display: block; height: 100%; width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}
.log .status.done { color: var(--good); font-weight: 600; }
.log .status.failed { color: var(--bad); font-weight: 600; }
/* A finished or failed row no longer needs the track to draw attention. */
.log li.is-done .progress, .log li.is-failed .progress { opacity: 0.45; }
.log li.is-failed .progress > span { background: var(--bad); }

/* ── Incoming dialog ────────────────────────────────────────────────────── */
dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  max-width: 380px;
  width: calc(100% - 40px);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-lg);
}
dialog[open] { animation: dialog-in 0.26s cubic-bezier(0.16, 1, 0.3, 1) both; }
dialog::backdrop { background: rgba(20, 21, 15, 0.5); backdrop-filter: blur(2px); }
.dialog-eyebrow { margin: 0 0 12px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.dialog-from { margin: 0; font-size: 15px; line-height: 1.5; }
.dialog-summary { margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ── Motion ─────────────────────────────────────────────────────────────── */
/* peer-pop animates opacity only; the li keeps its translate(-50%,-50%) for
   positioning, while the avatar inside does the spring-scale. */
@keyframes peer-pop { from { opacity: 0; } to { opacity: 1; } }
@keyframes avatar-pop { from { transform: scale(0.4); } to { transform: scale(1); } }
.radar-peers li .avatar { animation: avatar-pop 0.42s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes row-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
/* A wave grows from the center to the full radar and fades as it expands. */
@keyframes radar-ping {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  10%  { opacity: 0.5; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}
@keyframes radar-nudge {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}
.radar.nudge { animation: radar-nudge 0.4s ease; }

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