/* ============================================================
   SGNC-TAP — mobile-first stylesheet
   One file, no framework. Theme colour is injected per-card
   through the --brand custom property.
   ============================================================ */

/* ---------- tokens ---------- */
:root {
  --brand: #0f5132;
  --brand-ink: #ffffff;

  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #e4e8ed;
  --ink: #16191d;
  --ink-2: #5a6472;
  --ink-3: #8b94a3;

  --ok: #12805c;
  --warn: #b25e09;
  --err: #c0392b;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;

  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-2: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-3: 0 12px 40px rgba(16, 24, 40, .14);

  --ease: cubic-bezier(.32, .72, .26, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101216;
    --surface: #1a1d22;
    --surface-2: #22262c;
    --line: #2d323a;
    --ink: #e9ecf0;
    --ink-2: #a2abb8;
    --ink-3: #737d8b;
    --shadow-1: none;
    --shadow-2: 0 4px 16px rgba(0, 0, 0, .3);
    --shadow-3: 0 12px 40px rgba(0, 0, 0, .45);
  }
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  /* Respect the notch and the home indicator. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

img { max-width: 100%; display: block; }
button, input, textarea { font: inherit; color: inherit; }

h1, h2, h3, p { margin: 0; }

a { color: var(--brand); }

/* Visible focus for keyboard users only. */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

.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;
}

/* ---------- layout ---------- */
.wrap {
  width: 100%;
  max-width: 480px;
  margin-inline: auto;
  padding: 16px 16px 40px;
}

.stack > * + * { margin-top: var(--gap, 14px); }

/* ============================================================
   Digital name card
   ============================================================ */
.card-hero {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--shadow-2);
}

.card-hero__banner {
  height: 116px;
  background:
    radial-gradient(120% 140% at 15% 0%,
      color-mix(in srgb, var(--brand) 78%, white) 0%,
      var(--brand) 55%,
      color-mix(in srgb, var(--brand) 82%, black) 100%);
}

.card-hero__body {
  padding: 0 22px 24px;
  text-align: center;
}

.avatar {
  width: 104px; height: 104px;
  margin: -54px auto 14px;
  border-radius: 50%;
  border: 4px solid var(--surface);
  background: var(--surface-2);
  object-fit: cover;
  box-shadow: var(--shadow-2);
}

/* Initials placeholder when there is no photo. */
.avatar--initials {
  display: grid; place-items: center;
  font-size: 36px; font-weight: 600; letter-spacing: .02em;
  color: var(--brand-ink);
  background: var(--brand);
}

.card-hero__name {
  font-size: 23px; font-weight: 650;
  letter-spacing: -.02em; line-height: 1.25;
}

.card-hero__title { margin-top: 4px; color: var(--ink-2); font-size: 15px; }
.card-hero__org   { margin-top: 2px; color: var(--ink-3); font-size: 14px; }

.card-hero__bio {
  margin-top: 14px;
  font-size: 14.5px; line-height: 1.6;
  color: var(--ink-2);
  text-align: left;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* ---------- contact rows ---------- */
.rows {
  margin-top: 14px;
  background: var(--surface);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}

.row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px;
  text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--line);
  transition: background .15s var(--ease);
}
.row:last-child { border-bottom: 0; }
.row:active { background: var(--surface-2); }

.row__icon {
  flex: 0 0 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 11px;
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  color: var(--brand);
  font-size: 17px;
}

.row__text { min-width: 0; flex: 1; }
.row__label { font-size: 12px; color: var(--ink-3); letter-spacing: .02em; }
.row__value {
  font-size: 15px; font-weight: 500; margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row__chev { color: var(--ink-3); font-size: 18px; flex: 0 0 auto; }

/* ---------- socials ---------- */
.socials {
  display: flex; justify-content: center; gap: 12px;
  margin-top: 16px; flex-wrap: wrap;
}
.social {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  text-decoration: none; font-size: 19px;
  transition: transform .15s var(--ease);
}
.social:active { transform: scale(.93); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%;
  padding: 15px 20px;
  border: 0; border-radius: var(--r-md);
  background: var(--brand); color: var(--brand-ink);
  font-size: 15.5px; font-weight: 600;
  text-decoration: none; cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: transform .12s var(--ease), opacity .12s var(--ease);
  /* Kill the 300ms tap delay and the grey flash on iOS. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.985); opacity: .92; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn--ghost {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn--subtle {
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  color: var(--brand);
  box-shadow: none;
}

.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ============================================================
   Share screen
   ============================================================ */
.panel {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-1);
}

.panel__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.panel__title { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.panel__hint  { font-size: 12.5px; color: var(--ink-3); }

/* ---------- status chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 500;
  box-shadow: var(--shadow-1);
}
.chip__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ink-3); flex: 0 0 auto;
}
.chip--on  .chip__dot { background: var(--ok);  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 18%, transparent); }
.chip--off .chip__dot { background: var(--err); }
.chip--na  { opacity: .55; }

/* ---------- QR ---------- */
.qr-stage {
  display: grid; place-items: center;
  padding: 18px;
  background: #fff;                 /* always white — scanners need contrast */
  border-radius: var(--r-lg);
  position: relative;
}
.qr-stage canvas { border-radius: 8px; }

/* Rotation countdown ring. */
.qr-timer {
  --pct: 100;
  width: 100%; height: 4px;
  margin-top: 14px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.qr-timer__fill {
  height: 100%;
  width: calc(var(--pct) * 1%);
  background: var(--brand);
  border-radius: inherit;
  transition: width 1s linear;
}

/* ---------- pair code ---------- */
.paircode {
  display: flex; justify-content: center; gap: 8px;
  margin-top: 4px;
}
.paircode__ch {
  width: 42px; height: 54px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 24px; font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

/* ---------- live feed ---------- */
.feed { --gap: 8px; }

.feed__empty {
  text-align: center; padding: 26px 16px;
  color: var(--ink-3); font-size: 14px;
}

.event {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  animation: slide-in .32s var(--ease) both;
}

.event__icon {
  flex: 0 0 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ok) 14%, transparent);
  color: var(--ok); font-size: 15px;
}
.event__main { flex: 1; min-width: 0; }
.event__title { font-size: 14px; font-weight: 550; }
.event__meta  { font-size: 12px; color: var(--ink-3); margin-top: 1px; }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================
   Receive screen
   ============================================================ */
.scanner {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #000;
}
.scanner video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* Corner brackets framing the scan area. */
.scanner__frame {
  position: absolute; inset: 16%;
  border-radius: 14px;
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .42);
}
.scanner__frame::before,
.scanner__frame::after {
  content: ""; position: absolute;
  width: 32px; height: 32px;
  border: 3px solid #fff;
}
.scanner__frame::before {
  top: -2px; left: -2px;
  border-right: 0; border-bottom: 0;
  border-radius: 12px 0 0 0;
}
.scanner__frame::after {
  bottom: -2px; right: -2px;
  border-left: 0; border-top: 0;
  border-radius: 0 0 12px 0;
}

.code-input {
  width: 100%;
  padding: 16px;
  text-align: center;
  font-size: 26px; font-weight: 650;
  letter-spacing: .34em; text-indent: .34em;
  text-transform: uppercase;
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  transition: border-color .15s var(--ease);
}
.code-input:focus { outline: 0; border-color: var(--brand); }
.code-input::placeholder { letter-spacing: .2em; color: var(--ink-3); opacity: .6; }

/* ============================================================
   Forms
   ============================================================ */
.field { --gap: 6px; }
.field__label { font-size: 13px; font-weight: 550; color: var(--ink-2); }
.input {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  /* 16px minimum stops iOS zooming the viewport on focus. */
  font-size: 16px;
  transition: border-color .15s var(--ease);
}
.input:focus { outline: 0; border-color: var(--brand); }
textarea.input { resize: vertical; min-height: 84px; }

/* ============================================================
   Sheet / modal
   ============================================================ */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 13, 18, .5);
  backdrop-filter: blur(3px);
  display: grid; align-items: end;
  animation: fade .2s var(--ease) both;
}
.sheet {
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  max-height: 88dvh; overflow-y: auto;
  animation: rise .3s var(--ease) both;
}
.sheet__grip {
  width: 38px; height: 4px; border-radius: 999px;
  background: var(--line);
  margin: -6px auto 16px;
}
@media (min-width: 540px) {
  .sheet-backdrop { align-items: center; padding: 20px; }
  .sheet { border-radius: var(--r-xl); max-width: 440px; margin-inline: auto; }
}

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes rise { from { transform: translateY(18px); opacity: .6 } to { transform: none; opacity: 1 } }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  max-width: calc(100% - 32px);
  padding: 13px 18px;
  border-radius: 999px;
  background: #1d2129; color: #fff;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-3);
  animation: toast-in .28s var(--ease) both;
}
.toast--err { background: var(--err); }
.toast--ok  { background: var(--ok); }

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px) }
  to   { opacity: 1; transform: translate(-50%, 0) }
}

/* ============================================================
   Misc
   ============================================================ */
.hint {
  display: flex; gap: 10px;
  padding: 13px 15px;
  background: color-mix(in srgb, var(--brand) 7%, transparent);
  border-radius: var(--r-md);
  font-size: 13.5px; line-height: 1.5;
  color: var(--ink-2);
}
.hint__icon { flex: 0 0 auto; }

.muted   { color: var(--ink-3); font-size: 13px; }
.center  { text-align: center; }
.divider {
  display: flex; align-items: center; gap: 12px;
  color: var(--ink-3); font-size: 12.5px;
  margin-block: 4px;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--line);
}

.spinner {
  width: 17px; height: 17px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* ============================================================
   Accounts — register / sign in
   ============================================================ */
.auth-head  { text-align: center; padding: 22px 0 2px; }
.auth-title { font-size: 22px; font-weight: 680; letter-spacing: -.025em; }
.auth-sub   { margin-top: 6px; color: var(--ink-3); font-size: 14px; }
.auth-alt   { text-align: center; color: var(--ink-3); font-size: 14px; }
.auth-alt a { color: var(--brand); font-weight: 560; }

/* Optional-field note, and the divider above it. */
.field__hint { color: var(--ink-3); font-size: 13px; }
.field__label em {
  float: right;
  font-style: normal; font-weight: 450;
  color: var(--ink-3);
}
.rule { border: 0; border-top: 1px solid var(--line); margin: 2px 0; }

.alert {
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: 14px; line-height: 1.5;
}
.alert p + p { margin-top: 4px; }
.alert--err {
  background: #fdecec;
  color: #8a1c1c;
  border: 1px solid #f5c8c8;
}
@media (prefers-color-scheme: dark) {
  .alert--err { background: #3a1616; color: #ffb4b4; border-color: #5c2020; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
