/* Joł — dead simple on purpose.
   One contact per block, big enough to hit with a thumb. No chrome that does not
   earn its place. */

:root {
  color-scheme: dark;
  --bg: #0b0c0f;
  --panel: #15171c;
  --text: #f2f4f8;
  --muted: #8d95a5;
  --line: #262a33;
  --danger: #ff6b6b;
  --radius: 14px;
  /* Height of the tab bar plus the home indicator, so content is never hidden. */
  --tabs: calc(56px + env(safe-area-inset-bottom, 0px));
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4f5f7; --panel: #ffffff; --text: #14161a;
    --muted: #5b6472; --line: #e2e5ea; --danger: #c0392b;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
}

.screen { min-height: 100dvh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

/* ── onboarding ─────────────────────────────────────────────────────────── */

.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 1.25rem calc(2rem + env(safe-area-inset-bottom, 0px));
  max-width: 26rem;
  width: 100%;
  margin: 0 auto;
}

.logo { font-size: 3.5rem; margin: 0; letter-spacing: -0.03em; }
.step h1 { font-size: 1.75rem; margin: 0; }
.lead { color: var(--muted); margin: 0; font-size: 1.05rem; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }
.hint.small { font-size: 0.8rem; }
.error { color: var(--danger); font-size: 0.9rem; margin: 0; }

.stack { display: grid; gap: 0.6rem; }

button, .button {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
button.big { padding: 1.1rem 1rem; font-size: 1.05rem; }
button.ghost { background: transparent; font-weight: 500; }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:active { transform: scale(0.99); }

.field {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 0.9rem;
}
.field .at { color: var(--muted); }
.field input {
  flex: 1;
  font: inherit;
  color: inherit;
  background: transparent;
  border: 0;
  outline: none;
  padding: 0.9rem 0;
  min-width: 0;
}

/* ── app ────────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: calc(0.6rem + env(safe-area-inset-top, 0px)) 1rem 0.6rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
.badge {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}

.topbar-actions { display: flex; align-items: center; gap: 0.4rem; }
.topbar .icon {
  display: grid;
  place-items: center;
  padding: 0.4rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  line-height: 0;
}
.topbar .icon:hover { color: var(--text); }
.topbar .icon:active { transform: scale(0.92); }
/* The refresh button spins while a refetch is in flight, so a slow request does
   not look like a dead button. */
.topbar .icon.spinning { color: var(--text); animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Pull-to-refresh indicator: parked just above the viewport and slid down with
   the finger. --pull is set from app.js. */
.pull {
  position: fixed;
  left: 50%;
  /* Below the notch, so the indicator is never hidden by the status bar. */
  top: env(safe-area-inset-top, 0px);
  z-index: 5;
  transform: translate(-50%, calc(-100% + var(--pull, 0px)));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.78rem;
  color: var(--muted);
  box-shadow: 0 6px 18px rgb(0 0 0 / 0.25);
  pointer-events: none;
  white-space: nowrap;
}
.pull.ready { color: var(--text); border-color: var(--text); }

.view {
  flex: 1;
  padding: 0.75rem;
  padding-bottom: calc(var(--tabs) + 1rem);
  display: grid;
  gap: 0.6rem;
  align-content: start;
}
.view h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.75rem 0 0;
}
.view h2:first-child { margin-top: 0; }

/* A contact is one block. Tap it and they get a Joł. */
.contact {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.15rem;
  min-height: 5.5rem;
  padding: 0.9rem 1.1rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--c, var(--panel));
  color: #0b0c0f;
  text-align: left;
}
.contact .name { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.contact .meta { font-size: 0.8rem; opacity: 0.7; }
.contact.sent { animation: pop 420ms ease; }
@keyframes pop {
  0% { transform: scale(1); }
  35% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

.row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
}
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { color: var(--muted); font-size: 0.82rem; overflow-wrap: anywhere; }
.row button { padding: 0.5rem 0.8rem; font-size: 0.9rem; }

.empty { color: var(--muted); text-align: center; padding: 2rem 1rem; }

/* The sponsor of the day. Deliberately not a .contact block: a friend's block is a
   colour and a name, this one carries a label, a brand, the perk's terms and its
   own button, so it can never be mistaken for somebody who knows you. */
.sponsor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.9rem 1.1rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.sponsor-label {
  align-self: flex-start;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}
.sponsor-brand { display: flex; align-items: center; gap: 0.6rem; }
.sponsor-brand img { width: 2rem; height: 2rem; border-radius: 8px; object-fit: contain; }
.sponsor-brand .name { font-size: 1.25rem; font-weight: 700; }
.sponsor-perk { font-weight: 600; }
.sponsor button.big { width: 100%; }

.code {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.95rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  overflow-wrap: anywhere;
  /* The whole box copies on tap: on a phone it is a far bigger target than the
     button beside it. */
  cursor: pointer;
}
.code:active { border-color: var(--muted); }
.code code { flex: 1; min-width: 0; user-select: all; }
.code button { padding: 0.35rem 0.6rem; font-size: 0.85rem; }

.perk {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.5rem;
}
.perk .title { font-weight: 600; }
.perk .sub { color: var(--muted); font-size: 0.82rem; }
.perk.expired { opacity: 0.6; }

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.25rem;
  padding: 0.4rem 0.5rem calc(0.4rem + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.5rem 0.25rem;
  border-radius: 10px;
}
.tab.active { color: var(--text); background: var(--panel); }

pre, .diag {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.8rem;
  font-size: 0.78rem;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--muted);
}

/* Recovery codes are meant to be written down or pasted into a password manager,
   so they get more room and more contrast than a diagnostic dump. */
#onboard-codes {
  font-size: 0.95rem;
  line-height: 1.7;
  letter-spacing: 0.04em;
  color: var(--text);
  user-select: all;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tabs) + 1rem);
  transform: translateX(-50%);
  z-index: 4;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.3);
  max-width: calc(100vw - 2rem);
}
