/* ShiftRanks Social — app styles.
 *
 * Motion rules, since "smooth" is the requirement:
 *   - Only transform and opacity are ever animated. Anything touching layout
 *     (width, height, top, margin) is animated off the compositor and drops
 *     frames on a mid-range Android, which is most of this audience.
 *   - One easing curve for entrances, one for exits, so the whole app feels
 *     like a single object rather than a pile of components.
 *   - Every animation is disabled under prefers-reduced-motion. Vestibular
 *     disorders are real and this app slides a lot of things around.
 *
 * Sizing rules:
 *   - 100dvh, not 100vh. On mobile Safari and Chrome, vh includes the
 *     retracting URL bar, so a 100vh app is permanently a bar-height too tall
 *     and the composer sits under the fold.
 *   - Safe-area insets everywhere something touches an edge, so the notch and
 *     home indicator never cover a control.
 *   - Controls are at least 44px. Below that, thumbs miss.
 */

:root {
  /* ShiftRanks palette, taken from templates/base.html on the main site so
     the app and the marketing pages are visibly one product:
       page #0A0A0A · surfaces #111111/#161616/#1c1c1c · borders #1f1f1f-#2e2e2e
       primary #3B82F6 (hover #2563EB) · inputs #1a1a1a on #2a2a2a
     ShiftRanks is dark-only, so this app is too — a light mode here would
     look like a different company. */
  --bg: #0A0A0A;
  --bg-soft: #111111;
  --surface: #161616;
  --surface-2: #1c1c1c;
  --text: #ffffff;
  --text-soft: #94a3b8;
  --line: #242424;
  --line-soft: #1f1f1f;
  --brand: #3B82F6;
  --brand-ink: #ffffff;
  --brand-hover: #2563EB;
  --brand-soft: rgba(59, 130, 246, 0.12);
  --accent: #60a5fa;
  --danger: #f87171;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
  --radius: 16px;
  --radius-sm: 12px;

  --ease-in: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-out: cubic-bezier(0.4, 0, 1, 1);
  --dur: 320ms;
  --dur-fast: 180ms;

  --pad: max(16px, env(safe-area-inset-left));
  --pad-top: max(12px, env(safe-area-inset-top));
  --pad-bottom: max(12px, env(safe-area-inset-bottom));
}

/* No prefers-color-scheme override. The tokens above ARE the dark theme,
   because ShiftRanks is dark-only — a light mode here would look like a
   different company's product. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  /* Stop the whole page rubber-banding; only .scroll and .thread scroll. */
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { overflow: hidden; }

.app {
  position: relative;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

/* On a wide screen the app stays a centred column — a 2000px-wide chat thread
   is unreadable, and this is a phone product that desktop only visits to sign
   up and scan the pairing QR.

   The column has to look DELIBERATE though. The first version used #0A0A0A on
   a #000 page with no border and no vertical margin, which read as a cropped
   page rather than a centred app: two near-identical blacks meeting with no
   edge. So the page behind it is now a distinctly different surface, the app
   sits inset with real margin, and it has a visible border and radius. */
@media (min-width: 720px) {
  body {
    background:
      radial-gradient(1200px 600px at 50% -10%, rgba(59, 130, 246, 0.10), transparent 60%),
      #050505;
  }
  .app {
    max-width: 460px;
    height: min(calc(100dvh - 64px), 880px);
    margin: 32px auto;
    border-radius: 28px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    background: var(--bg);
    /* Keep the rounded corners actually rounded — screens inside are
       absolutely positioned to the edges and would otherwise square them off. */
    overflow: hidden;
  }
}

/* Desktop-only label above the frame, so the narrow column is obviously a
   phone app being previewed rather than a broken page. */
.desktop-note { display: none; }
@media (min-width: 720px) {
  .desktop-note {
    display: block;
    position: fixed;
    top: 10px; left: 0; right: 0;
    text-align: center;
    font-size: 12px;
    letter-spacing: 0.04em;
    color: var(--text-soft);
    pointer-events: none;
    z-index: 5;
  }
  .desktop-note b { color: #fff; font-weight: 700; }
  .desktop-note b span { color: var(--brand); }
}

/* ---------- Screens ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  will-change: transform, opacity;
}

.screen--center {
  justify-content: center;
  padding: var(--pad-top) var(--pad) var(--pad-bottom);
  gap: 28px;
}

.screen--chat { background: var(--bg-soft); }

/* Entrance/exit. Translate is percentage-of-self, so it scales to any screen
   without a media query. */
@keyframes screen-in {
  from { opacity: 0; transform: translate3d(0, 12px, 0) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
@keyframes screen-in-back {
  from { opacity: 0; transform: translate3d(-18px, 0, 0); }
  to   { opacity: 1; transform: none; }
}
@keyframes screen-out {
  from { opacity: 1; transform: none; }
  to   { opacity: 0; transform: translate3d(0, -8px, 0) scale(0.99); }
}

.screen[data-enter] { animation: screen-in var(--dur) var(--ease-in) both; }
.screen[data-enter="back"] { animation: screen-in-back var(--dur) var(--ease-in) both; }
.screen[data-leave] { animation: screen-out var(--dur-fast) var(--ease-out) both; }

.scroll {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 8px var(--pad) calc(var(--pad-bottom) + 24px);
}

/* ---------- Boot ---------- */

.boot {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
}
.boot-mark {
  width: 46px; height: 46px; border-radius: 14px;
  background: var(--brand);
  animation: pulse 1.4s var(--ease-in) infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.86); opacity: 0.65; }
}
.boot-text { color: var(--text-soft); margin: 0; font-size: 14px; }

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--pad-top) + 4px) var(--pad) 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 2;
}
.screen--chat .topbar { background: var(--bg-soft); }
.topbar--home { justify-content: space-between; align-items: flex-start; border-bottom: none; }
.topbar-title { font-size: 18px; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
.eyebrow { margin: 0 0 2px; font-size: 12px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.08em; }

.icon-btn {
  flex: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: none; border-radius: 50%;
  background: transparent; color: var(--text);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-in), background var(--dur-fast) linear;
}
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { transform: scale(0.9); background: var(--surface-2); }
.icon-btn--soft { background: var(--surface-2); }
.icon-btn--mic { background: var(--surface-2); }
.icon-btn--mic[data-recording] { background: var(--danger); color: #fff; animation: mic-pulse 1s infinite; }
@keyframes mic-pulse { 50% { transform: scale(1.08); } }
.icon-btn--send { background: var(--brand); color: var(--brand-ink); }

/* ---------- Hero / welcome ---------- */

.hero { text-align: center; display: grid; justify-items: center; gap: 14px; }
.hero-mark {
  width: 64px; height: 64px; border-radius: 20px;
  background: var(--brand);
  box-shadow: var(--shadow);
}
.hero-title { font-size: clamp(26px, 7vw, 34px); line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
.hero-sub { margin: 0; color: var(--text-soft); max-width: 30ch; }

.stack { display: grid; gap: 10px; }

/* ---------- Buttons ---------- */

.btn {
  min-height: 50px;
  padding: 0 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit; font-weight: 600;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-in), opacity var(--dur-fast) linear;
}
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.btn--primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 8px 24px rgba(59,130,246,0.2); }
.btn--primary:hover { background: var(--brand-hover); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn--block { width: 100%; }
.btn--tiny { min-height: 32px; padding: 0 12px; font-size: 13px; background: var(--surface-2); color: var(--text); }

/* ---------- Plans ---------- */

.plans { display: grid; gap: 12px; padding-top: 8px; }
.plan {
  text-align: left;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  display: grid; gap: 8px;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-in), border-color var(--dur-fast) linear;
}
.plan:active { transform: scale(0.99); }
.plan[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.plan-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.plan-name { font-weight: 700; font-size: 17px; }
.plan-price { font-weight: 700; color: var(--brand); white-space: nowrap; }
.plan-desc { color: var(--text-soft); font-size: 14px; margin: 0; }
.plan-features { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; font-size: 14px; }
.plan-features li { display: flex; gap: 8px; align-items: flex-start; }
.plan-features li::before { content: "✓"; color: var(--brand); font-weight: 700; }
.plan-features li[data-soon]::before { content: "◷"; color: var(--text-soft); }
.plan-features li[data-soon] { color: var(--text-soft); }

/* ---------- Forms ---------- */

.form { display: grid; gap: 16px; padding-top: 12px; }
.field { display: grid; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.field-hint { font-size: 12px; color: var(--text-soft); }
.input, .textarea {
  width: 100%;
  min-height: 50px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  /* 16px minimum, or iOS Safari zooms the whole page on focus. */
  font: inherit; font-size: 16px;
  transition: border-color var(--dur-fast) linear;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus { outline: none; border-color: var(--brand); }
.form-error { color: var(--danger); font-size: 14px; margin: 0; }
.fineprint { color: var(--text-soft); font-size: 12px; text-align: center; margin: 8px 0 0; }

.card-step { display: grid; gap: 8px; padding: 14px; border: 1.5px dashed var(--line); border-radius: var(--radius-sm); }
.card-step-head { display: flex; justify-content: space-between; align-items: center; }
.card-mount { min-height: 44px; }

.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); margin: 0; display: inline-block; }
.pill--muted { background: var(--surface-2); color: var(--text-soft); }
.pill--soon { background: var(--surface-2); color: var(--text-soft); }

/* ---------- Wizard ---------- */

.wizard { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 20px var(--pad); }
.step { display: grid; gap: 14px; animation: screen-in var(--dur) var(--ease-in) both; }
.step-title { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
.step-help { color: var(--text-soft); margin: 0; font-size: 14px; }

.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); }
.progress-fill { display: block; height: 100%; width: 0%; background: var(--brand); transform-origin: left; transition: width var(--dur) var(--ease-in); }

.footer-bar {
  display: flex; gap: 10px;
  padding: 12px var(--pad) calc(var(--pad-bottom) + 8px);
  border-top: 1px solid var(--line);
  background: var(--bg);
}
.footer-bar .btn { flex: 1; }

.taglist { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  padding: 8px 12px; border-radius: 999px;
  background: var(--surface-2); border: none; color: var(--text);
  font: inherit; font-size: 14px; cursor: pointer;
  display: inline-flex; gap: 6px; align-items: center;
  transition: transform var(--dur-fast) var(--ease-in);
}
.tag:active { transform: scale(0.94); }
.tag-x { color: var(--text-soft); font-weight: 700; }

/* ---------- Home ---------- */

.quota-card {
  display: flex; align-items: center; gap: 18px;
  background: var(--surface); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-top: 8px;
}
.ring { position: relative; width: 96px; height: 96px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring-track { stroke: var(--surface-2); }
.ring-fill {
  stroke: var(--brand);
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  transition: stroke-dashoffset 700ms var(--ease-in);
}
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; }
.ring-label strong { font-size: 28px; line-height: 1; }
.ring-label span { font-size: 12px; color: var(--text-soft); }
.quota-meta { display: grid; gap: 4px; }
.quota-title { margin: 0; font-weight: 650; }
.quota-sub { margin: 0; font-size: 13px; color: var(--text-soft); }

.cta {
  width: 100%; margin-top: 14px;
  display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 18px; border: none; border-radius: var(--radius);
  background: var(--brand);
  color: #fff; cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-in);
}
.cta:active { transform: scale(0.985); }
.cta-icon { width: 44px; height: 44px; border-radius: 14px; background: rgba(255,255,255,0.18); display: grid; place-items: center; flex: none; }
.cta-icon svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; }
.cta-text { display: grid; gap: 2px; }
.cta-text strong { font-size: 17px; }
.cta-text small { opacity: 0.85; font-size: 13px; }

.tile {
  margin-top: 12px; padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.tile small { display: block; color: var(--text-soft); font-size: 13px; margin-top: 2px; }
.tile--soon { opacity: 0.85; }

/* ---------- Chat ---------- */

.thread {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px var(--pad) 8px;
  display: flex; flex-direction: column; gap: 10px;
}

.bubble {
  max-width: min(78%, 460px);
  padding: 11px 14px;
  border-radius: 20px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  animation: bubble-in 340ms var(--ease-in) both;
}
@keyframes bubble-in {
  from { opacity: 0; transform: translate3d(0, 10px, 0) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
.bubble--in { align-self: flex-start; background: var(--surface); border-bottom-left-radius: 7px; box-shadow: var(--shadow); }
.bubble--out { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 7px; }
.bubble--summary { border: 1.5px solid var(--brand); }
.bubble img { max-width: 100%; border-radius: 12px; display: block; margin-top: 6px; }
.bubble-tag { display: block; font-size: 11px; opacity: 0.7; margin-bottom: 3px; }

.typing { align-self: flex-start; display: flex; gap: 4px; padding: 14px; background: var(--surface); border-radius: 20px; border-bottom-left-radius: 7px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-soft); animation: blink 1.3s infinite; }
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.composer {
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 8px var(--pad) calc(var(--pad-bottom) + 6px);
}
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.composer-input {
  flex: 1;
  min-height: 44px; max-height: 132px;
  padding: 11px 14px;
  border-radius: 22px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 16px;
  resize: none; overflow-y: auto;
}
.composer-input:focus { outline: none; border-color: var(--brand); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 9px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface);
  color: var(--text); font: inherit; font-size: 14px; cursor: pointer;
  animation: bubble-in 260ms var(--ease-in) both;
  transition: transform var(--dur-fast) var(--ease-in);
}
.chip:active { transform: scale(0.94); }

.recording { display: flex; align-items: center; gap: 10px; padding: 10px 4px 2px; font-variant-numeric: tabular-nums; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
.rec-wave { display: flex; gap: 3px; align-items: center; flex: 1; height: 22px; }
.rec-wave i { flex: 1; max-width: 4px; background: var(--brand); border-radius: 2px; height: 30%; animation: wave 900ms ease-in-out infinite; }
.rec-wave i:nth-child(2) { animation-delay: 120ms; }
.rec-wave i:nth-child(3) { animation-delay: 240ms; }
.rec-wave i:nth-child(4) { animation-delay: 360ms; }
.rec-wave i:nth-child(5) { animation-delay: 480ms; }
@keyframes wave { 50% { height: 100%; } }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%; bottom: calc(var(--pad-bottom) + 20px);
  transform: translate3d(-50%, 120%, 0);
  max-width: min(90vw, 420px);
  background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 14px;
  font-size: 14px; text-align: center;
  z-index: 50; pointer-events: none;
  transition: transform var(--dur) var(--ease-in), opacity var(--dur) linear;
  opacity: 0;
}
.toast[data-show] { transform: translate3d(-50%, 0, 0); opacity: 1; }

/* ---------- Motion off ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- Install / pairing ---------- */

.qr-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px;
  display: grid; justify-items: center; gap: 10px;
  margin: 16px 0; box-shadow: var(--shadow);
  animation: screen-in var(--dur) var(--ease-in) both;
}
/* The QR is server-rendered SVG with no fill of its own, so it inherits the
   theme — a dark-mode QR on a white plate still scans. */
.qr {
  width: min(220px, 60vw); aspect-ratio: 1;
  background: #fff; border-radius: 12px; padding: 10px;
  display: grid; place-items: center;
}
.qr svg { width: 100%; height: 100%; shape-rendering: crispEdges; }
.qr-help { margin: 0; font-size: 14px; color: var(--text-soft); text-align: center; }
.qr-origin { margin: 0; font-size: 12px; font-weight: 600; color: var(--text); }
.qr-expiry { margin: 0; font-size: 12px; color: var(--text-soft); font-variant-numeric: tabular-nums; }

.linked {
  display: grid; justify-items: center; gap: 6px;
  padding: 22px; margin: 16px 0;
  border-radius: var(--radius); background: var(--brand-soft);
  animation: bubble-in 400ms var(--ease-in) both;
}
.linked-tick {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 22px; font-weight: 700;
}
.linked small { color: var(--text-soft); }

/* ---------- ShiftRanks wordmark ---------- */
/* Same lockup as the main site's nav: blue "Shift", white "Ranks", black 900
   weight, tight tracking. This is the single strongest cue that the app and
   shiftranks.com are the same product. */
.wordmark {
  margin: 0;
  font-size: clamp(28px, 8vw, 36px);
  font-weight: 900;
  letter-spacing: -0.03em;
  color: #ffffff;
  line-height: 1;
}
.wordmark span { color: var(--brand); }
