/* ============================================================
   ORBIT — phone screens
   Faithful recreations of the running app, used inside beats 2 & 3.
   Dark Orbit aesthetic lives ONLY in here (matches AppTheme.swift).
   ============================================================ */

:root {
  /* Phone-internal tokens — match AppTheme.swift exactly */
  --p-bg: #07080E;
  --p-bg-top: #0C0E17;
  --p-text: #E8EAF4;
  --p-text-2: #8186A3;
  --p-text-3: rgba(232, 234, 244, 0.42);
  --p-surface: rgba(154, 160, 255, 0.05);
  --p-surface-2: rgba(154, 160, 255, 0.08);
  --p-surface-border: rgba(255, 255, 255, 0.07);
  --p-accent: #9AA0FF;
  --p-accent-soft: rgba(154, 160, 255, 0.13);
  --p-accent-border: rgba(154, 160, 255, 0.32);
  --p-negative: #FF8DA8;
  --p-negative-soft: rgba(255, 141, 168, 0.10);
  --p-negative-border: rgba(255, 141, 168, 0.24);
  --p-positive: #3DD68C;
  --phone-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Geist", system-ui, sans-serif;
}

/* ---------- Phone shell ---------- */
.phone {
  --phone-w: 348px;
  --phone-h: 752px;
  width: var(--phone-w);
  height: var(--phone-h);
  /* isolate the phone UI from page-level text-align (the mobile beat layout
     centers its copy; without this, that leaks in and mis-aligns the app rows) */
  text-align: left;
  background: linear-gradient(to bottom, var(--p-bg-top), var(--p-bg));
  border-radius: 52px;
  position: relative;
  font-family: var(--phone-font);
  color: var(--p-text);
  font-size: 14px;
  letter-spacing: -0.01em;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  box-shadow:
    0 0 0 8px #0b0d16,
    0 0 0 9px rgba(255, 255, 255, 0.12),
    0 44px 90px -30px rgba(0, 0, 0, 0.85),
    0 0 64px -10px rgba(154, 160, 255, 0.16);
  flex-shrink: 0;
}
.phone--lift {
  box-shadow:
    0 0 0 8px #0b0d16,
    0 0 0 9px rgba(255, 255, 255, 0.14),
    0 64px 110px -34px rgba(0, 0, 0, 0.9),
    0 0 84px -8px rgba(154, 160, 255, 0.20);
}

/* stacked screens (for the beat-3 unlock loop) */
.phone-screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transition: opacity 0.7s ease;
}
.phone-screen.active { opacity: 1; pointer-events: auto; }
.phone-screen .me-view,
.phone-screen .orbit-view,
.phone-screen .detail-view { height: auto; flex: 1; min-height: 0; }

/* beat-3 goal detail presented as a full sheet sliding up over the me-view */
.detail-sheet {
  position: absolute; inset: 0; z-index: 4;
  display: flex; flex-direction: column;
  background: linear-gradient(to bottom, var(--p-bg-top), var(--p-bg));
  border-top-left-radius: 46px; border-top-right-radius: 46px;
  box-shadow: 0 -26px 56px -18px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  transform: translateY(101%);
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.detail-sheet.up { transform: translateY(0); }
.detail-sheet .detail-view { height: auto; flex: 1; min-height: 0; }
/* dim the me-view slightly while the sheet is open */
.me-dim {
  position: absolute; inset: 0; z-index: 3;
  background: rgba(0, 0, 0, 0.38);
  opacity: 0; pointer-events: none;
  transition: opacity 0.6s ease;
}
.me-dim.on { opacity: 1; }

/* status bar */
.phone-status {
  display: flex; justify-content: space-between; align-items: center;
  padding: 17px 28px 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  position: relative;
  z-index: 2;
}
.phone-status .icons { display: flex; gap: 6px; align-items: center; }
.phone-status .icons svg { width: 17px; height: 12px; }

/* Orbit "cue" — faint dotted scatter near the top, like the app */
.orbit-cue {
  position: absolute; top: 0; left: 0; right: 0;
  height: 220px;
  pointer-events: none;
  opacity: 0.6;
}
.orbit-cue i {
  position: absolute;
  width: 2px; height: 2px;
  border-radius: 50%;
  background: rgba(232, 234, 244, 0.5);
}
.orbit-cue i:nth-child(1) { top: 64px; left: 16%; }
.orbit-cue i:nth-child(2) { top: 96px; right: 20%; width: 2.5px; height: 2.5px; opacity: 0.8; }
.orbit-cue i:nth-child(3) { top: 140px; left: 62%; opacity: 0.5; }
.orbit-cue i:nth-child(4) { top: 188px; left: 10%; opacity: 0.4; }
.orbit-cue i:nth-child(5) { top: 50px; right: 38%; opacity: 0.35; }

/* app icon chips, shared */
.ic, .ic-tiny {
  display: grid; place-items: center;
  color: #fff; font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
/* real app-icon images sit inside the rounded chips */
.ic > img, .ic-tiny > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-app .icon > img, .unlock-sheet .head-icon > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-app .icon, .unlock-sheet .head-icon { overflow: hidden; }

/* ============================================================
   ORBIT VIEW  (beat 2 — friends see everything)
   ============================================================ */
.orbit-view { padding: 22px 18px 0; height: 100%; display: flex; flex-direction: column; }
.orbit-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.orbit-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, #FF8DA8, #9AA0FF);
  overflow: hidden;
  display: grid; place-items: center;
  color: white; font-weight: 600; font-size: 17px; letter-spacing: -0.02em;
}
.orbit-name {
  font-size: 20px; font-weight: 600; letter-spacing: -0.025em;
  display: flex; align-items: center; gap: 6px;
  flex: 1;
}
.orbit-name svg { width: 13px; height: 13px; opacity: 0.6; }
.orbit-actions { display: flex; gap: 14px; color: var(--p-text-2); }
.orbit-actions svg { width: 21px; height: 21px; }
.orbit-streak {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px; letter-spacing: -0.01em;
  color: var(--p-text-2);
  margin-bottom: 10px;
}
.orbit-streak strong { color: var(--p-accent); font-weight: 600; }
.orbit-streak .flame { color: var(--p-accent); font-size: 15px; }
.orbit-contract {
  font-size: 13.5px;
  font-style: italic;
  color: var(--p-text);
  padding-left: 12px;
  border-left: 2px solid var(--p-accent);
  margin-bottom: 16px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px;
  line-height: 1.35;
}
.orbit-contract svg { width: 13px; height: 13px; color: var(--p-text-2); flex-shrink: 0; }

.orbit-section-label {
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--p-text-2);
  margin: 0 4px 12px;
}

.orbit-member {
  background: var(--p-surface);
  border: 1px solid var(--p-surface-border);
  border-radius: 16px;
  padding: 13px 15px 14px;
}
.orbit-member + .orbit-member { margin-top: 10px; }
.orbit-member-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 13px;
}
.member-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 600; font-size: 17px;
  color: white;
}
.member-avatar.blue { background: #62A9F0; }
.member-avatar.violet { background: #B8A8F0; }
.member-avatar.pink { background: #F0A8B8; }
.member-avatar.teal { background: #5FC9C0; }
/* pfp-style gradient avatars (swap background for a real photo) */
.member-avatar.p1 { background: linear-gradient(145deg, #FFB27A, #FF5E8A); }
.member-avatar.p2 { background: linear-gradient(145deg, #74B6FF, #5A61D9); }
.member-avatar.p3 { background: linear-gradient(145deg, #57D9A3, #2BA39B); }
.member-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.member-meta { flex: 1; min-width: 0; }
.member-name { font-size: 17px; font-weight: 600; letter-spacing: -0.025em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-status { font-size: 12.5px; color: var(--p-text-2); margin-top: 1px; }
.member-status.scrolling { color: var(--p-negative); }
.member-status.focus { color: var(--p-accent); }
.member-status.unlocked { color: var(--p-accent); }
.member-status.broke { color: var(--p-negative); }
.member-meta-chev { color: var(--p-text-2); }
.member-meta-chev svg { width: 8px; height: 14px; }

.member-goal {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px;
  padding: 5px 0;
}
.member-goal .ic-tiny {
  width: 19px; height: 19px;
  border-radius: 5px;
  font-size: 9px;
}
.member-goal .name { flex: 1; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-goal .mins { font-size: 12.5px; color: var(--p-text-2); margin-right: 10px; white-space: nowrap; }
.member-goal .mins.unlocked { color: var(--p-accent); font-weight: 500; }
/* a friend's app currently unlocked — highlighted row, like the app */
.member-goal.unlocked-row {
  background: var(--p-accent-soft);
  border: 1px solid var(--p-accent-border);
  border-radius: 10px;
  padding: 7px 9px;
  margin: 3px -9px;
}
.member-goal .bar {
  width: 30px; height: 3px;
  background: var(--p-surface-border);
  border-radius: 2px;
  position: relative; flex-shrink: 0;
}
.member-goal .bar i {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--p-accent);
  border-radius: 2px;
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.member-goal .bar i.pink { background: var(--p-negative); }
/* "+ N more" footer on a member with many apps */
.orbit-more {
  font-size: 12.5px; color: var(--p-text-2);
  margin-top: 12px; padding-top: 11px;
  border-top: 1px solid var(--p-surface-border);
}

/* tab bar (shared by me + orbit views) */
.phone-tabbar {
  margin-top: 8px;
  display: flex;
  justify-content: space-around;
  padding: 14px 0 22px;
  font-size: 11px;
  font-weight: 500;
}
.phone-tab {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  color: var(--p-text-2);
}
.phone-tab.active { color: var(--p-accent); }
.phone-tab svg { width: 23px; height: 23px; }

/* ============================================================
   ME VIEW  (beat 3 — your own limits)
   ============================================================ */
.me-view { padding: 22px 18px 0; height: 100%; display: flex; flex-direction: column; }
.me-header {
  display: flex; align-items: center; justify-content: center;
  gap: 12px; position: relative;
  margin-bottom: 12px;
}
.me-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, #6D74E8, #9AA0FF);
  overflow: hidden;
  display: grid; place-items: center;
  color: white; font-weight: 600; font-size: 16px;
  letter-spacing: -0.02em;
}
.me-name { font-size: 17px; font-weight: 600; letter-spacing: -0.025em; }
.me-list-icon { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); color: var(--p-text-2); }
.me-list-icon svg { width: 22px; height: 22px; }
.me-date {
  text-align: center;
  font-size: 12px; color: var(--p-text-2);
  margin-bottom: 18px; letter-spacing: -0.01em;
}
.me-date u { text-decoration: none; }
.me-date strong { color: var(--p-text); font-weight: 600; }

.me-section-label {
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--p-text-2);
  margin: 18px 4px 12px;
}
.me-section-label:first-of-type { margin-top: 0; }
.me-section-label.blocked { color: var(--p-negative); }

.me-card {
  background: var(--p-surface);
  border: 1px solid var(--p-surface-border);
  border-radius: 14px;
  padding: 9px 13px 10px;
  position: relative;
  overflow: hidden;
}
.me-card + .me-card { margin-top: 8px; }
.me-card-eyebrow {
  font-size: 9px; font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--p-text-2);
  margin-bottom: 5px;
}
.me-card-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.me-card-name { font-size: 15px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.1; }
.me-card-stat { text-align: right; white-space: nowrap; }
.me-card-stat .num { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; color: var(--p-text); }
.me-card-stat .num.pink { color: var(--p-negative); }
.me-card-stat .num.purple { color: var(--p-accent); }
.me-card-stat .denom { font-size: 12px; color: var(--p-text-2); font-weight: 500; }
.me-card-stat .stat-sub { font-size: 11px; color: var(--p-text-2); margin-top: 3px; }
.me-card-stat .stat-sub.pink { color: var(--p-negative); }
.me-card-stat .stat-sub.purple { color: var(--p-accent); }
.me-card-icons { display: flex; gap: 6px; margin-top: 7px; align-items: center; }
.me-card-icons .ic { width: 19px; height: 19px; border-radius: 5px; font-size: 11px; }
.me-card-bar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 2.5px;
  background: var(--p-surface-border);
}
.me-card-bar > i {
  display: block; height: 100%;
  background: var(--p-accent);
  width: 60%;
  transition: width 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.me-card-bar > i.pink { background: var(--p-negative); }
.me-card.depleted .me-card-bar > i { width: 100% !important; }

.me-actions { display: flex; gap: 11px; margin: auto 0 0; }
.me-action {
  flex: 1;
  background: var(--p-surface);
  border: 1px solid var(--p-surface-border);
  border-radius: 16px;
  padding: 15px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14.5px; font-weight: 600;
  color: var(--p-accent);
  letter-spacing: -0.015em;
}
.me-action.compact { flex: 0 0 104px; }
.me-action svg { width: 17px; height: 17px; }

/* ============================================================
   GOAL DETAIL + UNLOCK  (beat 3 — the act of unlocking)
   ============================================================ */
.detail-view { padding: 22px 18px 0; height: 100%; display: flex; flex-direction: column; position: relative; }
.detail-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
  color: var(--p-text-2);
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
}
.detail-header .back { display: flex; align-items: center; gap: 3px; color: var(--p-text-2); }
.detail-header .back svg { width: 16px; height: 16px; }
.detail-header .crumb { font-size: 10.5px; font-weight: 600; letter-spacing: 0.2em; color: var(--p-text-2); }
.detail-header .edit svg { width: 16px; height: 16px; }
.detail-app {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.detail-app .icon { width: 40px; height: 40px; border-radius: 10px; }
.detail-app .name { font-size: 23px; font-weight: 600; letter-spacing: -0.025em; }
.detail-ring {
  position: relative;
  width: 248px; height: 248px;
  margin: 6px auto 20px;
  display: grid; place-items: center;
}
.detail-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.detail-ring .ring-track { stroke: rgba(154, 160, 255, 0.16); fill: none; stroke-width: 2.5; }
.detail-ring .ring-fill { stroke: var(--p-accent); fill: none; stroke-width: 2.5; stroke-linecap: round; transition: stroke-dashoffset 0.7s cubic-bezier(0.22, 1, 0.36, 1), stroke 0.4s ease; }
.detail-ring-num { font-size: 58px; font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
.detail-ring-sub { font-size: 13.5px; color: var(--p-text-2); margin-top: 6px; text-align: center; }

.detail-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; margin-bottom: 18px; }
.detail-stat {
  background: var(--p-surface);
  border: 1px solid var(--p-surface-border);
  border-radius: 12px;
  padding: 11px 12px;
}
.detail-stat .label { font-size: 9.5px; font-weight: 600; letter-spacing: 0.14em; color: var(--p-text-2); }
.detail-stat .value { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; margin-top: 7px; }
.detail-stat .value.purple { color: var(--p-accent); }

.detail-log-label { font-size: 10.5px; font-weight: 600; letter-spacing: 0.18em; color: var(--p-text-2); margin: 4px 4px 6px; }
.detail-log-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 4px;
  font-size: 14px;
  border-bottom: 1px solid var(--p-surface-border);
}
.detail-log-row .left { display: flex; align-items: center; gap: 11px; }
.detail-log-row .lock { color: var(--p-accent); display: grid; place-items: center; }
.detail-log-row .lock svg { width: 17px; height: 17px; }
.detail-log-row .time { color: var(--p-text-2); font-size: 12.5px; }

.detail-bottom {
  position: absolute;
  left: 16px; right: 16px; bottom: 18px;
  background: var(--p-surface);
  border: 1px solid var(--p-accent-border);
  color: var(--p-accent);
  border-radius: 16px;
  padding: 16px;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  transition: opacity 0.4s ease;
}
.detail-bottom svg { width: 17px; height: 17px; }

/* ---------- Unlock bottom sheet ---------- */
.unlock-sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: #0B0D15;
  border-top-left-radius: 28px;
  border-top-right-radius: 28px;
  padding: 14px 18px 22px;
  box-shadow: 0 -34px 64px -12px rgba(0, 0, 0, 0.55);
  z-index: 3;
  transition: transform 0.62s cubic-bezier(0.22, 1, 0.36, 1);
}
.unlock-sheet.closed { transform: translateY(112%); }
.unlock-sheet-grip { width: 38px; height: 5px; background: rgba(232, 234, 244, 0.22); border-radius: 3px; margin: 0 auto 16px; }
.unlock-sheet .head-icon {
  width: 44px; height: 44px; border-radius: 11px;
  background: linear-gradient(135deg, #fdf497 0%, #fd5949 45%, #d6249f 65%, #285AEB 100%);
  margin: 0 auto 13px;
}
.unlock-sheet h3 { text-align: center; margin: 0 0 5px; font-size: 19px; font-weight: 600; letter-spacing: -0.025em; }
.unlock-sheet .desc { text-align: center; font-size: 13px; color: var(--p-text-2); margin-bottom: 18px; }
.unlock-sheet .pool-bar {
  height: 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  position: relative; margin-bottom: 11px; overflow: hidden;
}
.unlock-sheet .pool-bar .used { position: absolute; left: 0; top: 0; bottom: 0; background: rgba(154, 160, 255, 0.35); border-radius: 4px 0 0 4px; }
.unlock-sheet .pool-bar .req { position: absolute; top: 0; bottom: 0; background: var(--p-accent); border-radius: 4px; transition: width 0.4s ease, left 0.4s ease; }
.unlock-sheet .pool-meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--p-text-2); letter-spacing: -0.005em; margin-bottom: 18px; }
.unlock-sheet .pool-meta .mid { color: var(--p-accent); font-weight: 600; }
.unlock-sheet .stepper { display: flex; align-items: center; justify-content: center; gap: 26px; margin-bottom: 7px; }
.unlock-sheet .stepper button { width: 40px; height: 40px; border-radius: 99px; background: rgba(255, 255, 255, 0.06); border: 0; color: var(--p-text); font-size: 21px; display: grid; place-items: center; }
.unlock-sheet .stepper .big-num { font-size: 52px; font-weight: 600; letter-spacing: -0.04em; line-height: 1; min-width: 72px; text-align: center; transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1); }
.unlock-sheet .stepper-sub { text-align: center; font-size: 11.5px; color: var(--p-text-2); margin-bottom: 16px; }
.unlock-sheet .presets { display: flex; gap: 7px; margin-bottom: 16px; justify-content: center; }
.unlock-sheet .preset { font-size: 12px; font-weight: 600; letter-spacing: -0.005em; padding: 7px 13px; border-radius: 99px; border: 1px solid var(--p-surface-border); color: var(--p-text-2); background: transparent; transition: all 0.25s ease; }
.unlock-sheet .preset.active { border-color: var(--p-accent-border); color: var(--p-accent); background: var(--p-accent-soft); }
.unlock-sheet .confirm {
  width: 100%;
  background: var(--p-accent);
  border: 0; color: #0A0B12;
  padding: 16px; border-radius: 16px;
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
}
.unlock-sheet .cancel { display: block; width: 100%; text-align: center; background: transparent; border: 0; color: var(--p-text-2); font-size: 13.5px; padding: 13px; }

/* a soft confirm flash on the sheet */
.unlock-sheet.flash .confirm { animation: confirmFlash 0.5s ease; }
@keyframes confirmFlash {
  0% { transform: scale(1); }
  40% { transform: scale(0.97); filter: brightness(1.12); }
  100% { transform: scale(1); }
}

/* On narrow screens we DON'T reflow the phone (its internals are pixel-tuned
   for a 348px frame). Instead we scale it down uniformly so every proportion is
   preserved and text stays sharp. We use transform:scale (not CSS zoom) because
   zoom renders inconsistently on iOS Safari.

   Two things move the phone, so we compose both through CSS variables here
   rather than letting either set `transform` directly (which would clobber the
   other): motion.js feeds --ps (fit-to-width scale) and --py (parallax offset).
   The .reveal rise stays on .beat-stage, a different element, so no collision. */
.beat .phone {
  transform: translateY(var(--py, 0px)) scale(var(--ps, 1));
  transform-origin: top center;
}
@media (max-width: 480px) {
  /* reclaim the empty space the scale-down leaves below the 752px-tall box */
  .beat .phone { margin-bottom: calc(752px * (var(--ps, 1) - 1)); }
}
