/* 4riends Mini App landing v2.
   Atmosphere is inspired by the 2023 night / purple / lime mood.
   That is not brand approval. Official brand is still a draft:
   /workspace/brand/friends-protocol/brand.md
   The two-node mark is the only draft-brand mark used.
   Do not use the paused Web paper canvas or forest-green MainButton. */





:root {
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Roboto", "Apple Color Emoji", "Helvetica Neue", "Noto Sans CJK TC", sans-serif;
  --font-mono: ui-monospace, "Roboto Mono", "Noto Sans Mono", monospace;

  --canvas: #07060c;
  --ink: #f6f3ff;
  --muted: #b9a8c9;
  --hint: #8e7a9e;
  --lime: #c8f000;
  --on-lime: #111111;
  --glass: rgba(92, 36, 168, 0.38);
  --glass-border: rgba(216, 168, 255, 0.38);
  --danger: #ff7b96;
  --mark: #f4f2ec;
  --ring: #c8f000;
  --ball-lime: #c8f000;
  --ball-magenta: #e45cff;
  --ball-violet: #7a4dff;
  --ball-orchid: #c084fc;
  --home-pill: rgba(255, 255, 255, 0.32);
  --skel: rgba(216, 168, 255, 0.18);
  --skel-2: rgba(216, 168, 255, 0.32);

  --inset: 20px;
  --radius-card: 22px;
  --radius-cta: 25px;
  --safe-bottom: 34px;
  --sheet: #16141c;
  --sheet-ink: #f4f4f5;
  --sheet-muted: #a1a1aa;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 400;
  line-height: 22px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color-scheme: dark;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  appearance: none;
  cursor: pointer;
}

img { display: block; max-width: 100%; }

.app {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: var(--canvas);
  color: var(--ink);
}

.glow {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  top: -60px;
  left: 50%;
  width: 160%;
  height: 460px;
  transform: translateX(-50%);
  background:
    radial-gradient(ellipse 70% 60% at 38% 28%, rgba(228, 92, 255, 0.55) 0%, rgba(228, 92, 255, 0) 64%),
    radial-gradient(ellipse 80% 70% at 68% 8%, rgba(122, 77, 255, 0.48) 0%, rgba(122, 77, 255, 0) 62%),
    radial-gradient(ellipse 90% 80% at 50% 0%, rgba(88, 20, 160, 0.55) 0%, rgba(7, 6, 12, 0) 70%);
}

.status,
.nav,
.page,
.mainbar,
.homeind {
  position: relative;
  z-index: 1;
}

.status {
  flex: none;
  height: 44px;
  padding: 0 20px 6px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  color: var(--ink);
  background: transparent;
}

.status .time {
  font-size: 15px;
  font-weight: 600;
  line-height: 18px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.status .sigs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status svg { display: block; }

html[data-platform="android"] .status {
  height: 28px;
  padding: 0 16px;
  align-items: center;
}

html[data-platform="android"] .status .time {
  font-size: 14px;
  line-height: 16px;
}

.nav {
  flex: none;
  min-height: 56px;
  padding: 4px 2px 8px;
  display: flex;
  align-items: center;
  background: transparent;
}

.nav-btn {
  width: 44px;
  height: 44px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  color: var(--ink);
  flex: none;
}

.nav-btn svg { display: block; }

.nav-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  pointer-events: none;
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
}

.mark {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--mark);
}

.wm {
  font-size: 17px;
  font-weight: 600;
  line-height: 22px;
  letter-spacing: -0.02em;
  color: var(--ink);
  white-space: nowrap;
}

.draft-label {
  font-size: 13px;
  font-weight: 400;
  line-height: 16px;
  color: var(--muted);
  white-space: nowrap;
}

.page {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: transparent;
  padding: 8px var(--inset) 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 20px;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.cluster {
  position: relative;
  width: 220px;
  height: 180px;
  margin: 0 auto 16px;
}

.ball {
  position: absolute;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.ball-hero {
  width: 96px;
  height: 96px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  background: linear-gradient(160deg, #b14cff 0%, #6a1fd8 100%);
  box-shadow: 0 0 0 3px var(--ring);
}

.ball-root {
  width: 96px;
  height: 96px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  background: rgba(12, 8, 22, 0.7);
  box-shadow: 0 0 0 3px var(--ring);
  color: var(--mark);
}

.ball-root .mark {
  width: 48px;
  height: 48px;
}

.s1 { width: 22px; height: 22px; left: 48px; top: 30px; background: var(--ball-lime); }
.s2 { width: 16px; height: 16px; right: 50px; top: 28px; background: var(--ball-magenta); }
.s3 { width: 26px; height: 26px; left: 24px; top: 78px; background: var(--ball-violet); }
.s4 { width: 14px; height: 14px; right: 38px; top: 96px; background: var(--ball-lime); }
.s5 { width: 18px; height: 18px; left: 62px; bottom: 24px; background: var(--ball-orchid); }

.cluster-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.display-name {
  font-size: 22px;
  font-weight: 700;
  line-height: 28px;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.handle {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 400;
  line-height: 20px;
  color: var(--muted);
}

.id-block {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.id-cap {
  font-size: 13px;
  font-weight: 400;
  line-height: 16px;
  color: var(--hint);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 17px;
  font-weight: 400;
  line-height: 22px;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-card);
  padding: 16px 18px 18px;
  text-align: center;
}

.entry {
  font-size: 17px;
  font-weight: 700;
  line-height: 22px;
  color: var(--lime);
}

.entry-amt {
  font-variant-numeric: tabular-nums;
}

.note {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 400;
  line-height: 18px;
  color: var(--muted);
}

.error-copy {
  font-size: 17px;
  font-weight: 600;
  line-height: 22px;
  color: var(--danger);
}

/* Skeleton */
.sk-ball {
  background: var(--skel);
  box-shadow: none;
  color: transparent;
}

.sk-line {
  display: block;
  height: 12px;
  border-radius: 6px;
  margin-left: auto;
  margin-right: auto;
  background: linear-gradient(90deg, var(--skel) 0%, var(--skel-2) 50%, var(--skel) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}

.sk-line.name { width: 120px; height: 18px; margin: 0 auto 10px; }
.sk-line.handle { width: 148px; height: 12px; margin: 0 auto 16px; }
.sk-line.id { width: 100px; height: 14px; margin: 0 auto; }
.sk-entry { width: 108px; height: 16px; margin: 0 auto; }
.sk-card-line { width: 80%; height: 10px; margin: 12px auto 0; }

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sk-line, .spin { animation: none; }
}

.mainbar {
  flex: none;
  padding: 8px 16px 0;
  background: var(--canvas);
}

html[data-platform="android"] .mainbar { padding: 8px 10px 0; }

.cta {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 50px;
  border-radius: var(--radius-cta);
  background: var(--lime);
  color: var(--on-lime);
  font-size: 17px;
  font-weight: 700;
  line-height: 22px;
  letter-spacing: -0.01em;
}

.cta[disabled],
.cta.is-busy {
  opacity: 0.7;
  pointer-events: none;
}

.spin {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(17, 17, 17, 0.25);
  border-top-color: var(--on-lime);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

.homeind {
  flex: none;
  height: var(--safe-bottom);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  background: var(--canvas);
}

.homeind i {
  width: 134px;
  height: 5px;
  border-radius: 3px;
  background: var(--home-pill);
  display: block;
}

html[data-platform="android"] .homeind {
  height: 24px;
  padding-bottom: 10px;
}

html[data-platform="android"] .homeind i {
  width: 96px;
  height: 4px;
}

@media (max-width: 370px) {
  .cluster { width: 200px; height: 168px; }
  .ball-hero, .ball-root { width: 88px; height: 88px; }
  .ball-hero { font-size: 28px; }
}

/* Visibility: view AND state */
.gated { display: none; }

html[data-view="invite"][data-state="ready"] .gated[data-views~="invite"][data-states~="ready"],
html[data-view="invite"][data-state="pending"] .gated[data-views~="invite"][data-states~="pending"],
html[data-view="invite"][data-state="error"] .gated[data-views~="invite"][data-states~="error"],
html[data-view="invite"][data-state="loading"] .gated[data-views~="invite"][data-states~="loading"],
html[data-view="organic"][data-state="ready"] .gated[data-views~="organic"][data-states~="ready"],
html[data-view="organic"][data-state="pending"] .gated[data-views~="organic"][data-states~="pending"],
html[data-view="organic"][data-state="error"] .gated[data-views~="organic"][data-states~="error"],
html[data-view="organic"][data-state="loading"] .gated[data-views~="organic"][data-states~="loading"] {
  display: flex;
}

html[data-view="invite"][data-state="ready"] .card.gated[data-views~="invite"][data-states~="ready"],
html[data-view="invite"][data-state="pending"] .card.gated[data-views~="invite"][data-states~="pending"],
html[data-view="organic"][data-state="ready"] .card.gated[data-views~="organic"][data-states~="ready"],
html[data-view="organic"][data-state="pending"] .card.gated[data-views~="organic"][data-states~="pending"],
html[data-state="error"] .card.gated[data-states~="error"],
html[data-state="loading"] .card.gated[data-states~="loading"] {
  display: flex;
  flex-direction: column;
  align-items: center;
}

html[data-state="ready"] .cta-pay,
html[data-state="error"] .cta-retry,
html[data-state="pending"] .cta-pending {
  display: flex;
}

html[data-state="loading"] .mainbar { display: none; }


/* Language entry — quiet header control, not a second MainButton */
.lang-chip {
  min-width: 44px;
  height: 44px;
  padding: 0 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 16px;
  letter-spacing: 0.02em;
  flex: none;
}
.backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 3, 8, 0.58);
  z-index: 2;
  pointer-events: auto;
}
.backdrop.gated { display: none; }
.backdrop.gated.is-on { display: block; }
.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--safe-bottom) + 58px);
  z-index: 4;
  background: var(--sheet, #16141c);
  border-radius: 20px 20px 0 0;
  padding: 8px 20px 16px;
  color: var(--sheet-ink, #f4f4f5);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.4);
  display: none;
}
.sheet.gated.is-on { display: block; }
.sheet-handle {
  width: 36px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.22);
  margin: 4px auto 14px;
}
.sheet-kicker {
  font-size: 13px;
  font-weight: 600;
  line-height: 16px;
  color: var(--sheet-muted, #a1a1aa);
  margin-bottom: 8px;
}
.lang-row {
  width: 100%;
  min-height: 52px;
  padding: 8px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--sheet-ink, #f4f4f5);
  font-size: 17px;
  font-weight: 600;
  line-height: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: left;
}
.lang-check {
  width: 18px;
  height: 18px;
  flex: none;
  display: none;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M3.5 9.5 7.2 13 14.5 5'/%3E%3C/svg%3E") center / 18px 18px no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M3.5 9.5 7.2 13 14.5 5'/%3E%3C/svg%3E") center / 18px 18px no-repeat;
}
html[data-lang="en"] .lang-check[data-lang-check="en"],
html[data-lang="zh-Hans"] .lang-check[data-lang-check="zh-Hans"],
html[data-lang="zh-Hant"] .lang-check[data-lang-check="zh-Hant"] { display: block; }
