/* Shared components: buttons, header, tab bar, orb, overlays, charts. */

/* ---- screen scaffolding --------------------------------------------------- */
.screen { min-height: 100%; }
.screen.dark { color: #fff; min-height: 100vh; }
/* Aura tab inherits the body's cream background — no custom backdrop on
   the screen itself. Onboarding/scanning still use the dark grad-ink-night
   via their `.screen.dark` selector below. */
.screen.score { color: var(--ink); }
.screen.onboarding, .screen.scanning { position: relative; background: var(--grad-ink-night); }
.center-col { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 40px 24px; min-height: 70vh; }
.empty-title { font-size: 30px; margin-top: 8px; }
.empty-sub { color: var(--text-muted); max-width: 30ch; }
.dark .empty-sub { color: var(--white-70); }
.bg-aura { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.bg-aura::before, .bg-aura::after { content: ""; position: absolute; border-radius: 50%; filter: blur(30px); }
.bg-aura::before { width: 400px; height: 400px; background: rgba(255,77,184,0.5); top: -120px; right: -120px; }
.bg-aura::after { width: 350px; height: 350px; background: rgba(77,214,255,0.4); bottom: -120px; left: -120px; }

/* ---- PillButton ----------------------------------------------------------- */
.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 28px; border: none; border-radius: var(--r-pill);
  font-family: var(--font-body); font-size: 17px; font-weight: 700; cursor: pointer;
  transition: transform 0.12s var(--ease-pop), opacity 0.15s; box-shadow: 0 8px 12px rgba(26,13,46,0.18);
}
.pill.full { width: 100%; }
.pill:active:not(:disabled) { transform: scale(0.97); }
.pill:disabled { opacity: 0.4; cursor: default; box-shadow: none; }
.pill svg { flex: 0 0 auto; }
.pill-primary { background: var(--ink); color: var(--lemon); box-shadow: 0 8px 12px rgba(26,13,46,0.25); }
.pill-lemon { background: var(--lemon); color: var(--ink); }
.pill-aura { background: var(--grad-aura-ribbon); color: #fff; box-shadow: 0 8px 12px rgba(138,92,246,0.35); }
.pill-ghost { background: transparent; border: 1.5px solid var(--ink); color: var(--ink); box-shadow: none; }
.dark .pill-ghost { border-color: var(--white-35); color: #fff; }
.pill-cream { background: var(--paper); border: 1px solid var(--ink-10); color: var(--ink); box-shadow: none; }
.pill-danger { background: var(--coral); color: #fff; }

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

/* ---- icon buttons --------------------------------------------------------- */
.icon-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; border: none; background: transparent; color: var(--ink); cursor: pointer; border-radius: var(--r-pill); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.circle { width: 40px; height: 40px; min-width: 40px; min-height: 40px; background: var(--ink-06); }
.icon-btn.circle.dark, .dark .icon-btn.circle { background: var(--white-10); color: #fff; }
/* lemon icon buttons (e.g. download) match the lemon "download resume" pill.
   The extra selector wins over the dark-context background rule. */
.icon-btn.lemon,
.dark .icon-btn.circle.lemon { background: var(--lemon); color: var(--ink); }
.icon-btn:disabled { opacity: 0.4; }
.icon-btn.circle.danger { color: var(--coral); }

.link-btn { background: none; border: none; color: var(--violet); font-weight: 600; font-size: 14px; cursor: pointer; padding: 6px 8px; }

/* ---- PhoneHeader ---------------------------------------------------------- */
.phone-header { padding: calc(4px + env(safe-area-inset-top)) 16px 10px; }
.phone-header.center { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 8px; }
.phone-header.center .hdr-center { text-align: center; }
.phone-header.center .hdr-right { display: flex; justify-content: flex-end; }
/* All four tab headers (aura · edit · history · me) share one top inset. */
.phone-header.leading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-top: calc(28px + env(safe-area-inset-top)); }
/* The lead column shrinks/truncates; the action icons keep their size and stay
   pinned to the right edge so they never get pushed out of view (#8). */
.phone-header.leading .hdr-lead { flex: 1 1 auto; min-width: 0; }
.phone-header.leading .hdr-stack { min-width: 0; }
.phone-header.leading .hdr-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone-header.leading .hdr-right { display: flex; gap: 8px; flex: 0 0 auto; }
.hdr-title { font-size: 17px; font-weight: 700; }
.phone-header.dark .hdr-title { color: #fff; }
.hdr-sub { margin-bottom: 2px; }
.phone-header.dark .hdr-sub { color: var(--white-60); }
.hdr-back { width: 40px; height: 40px; border: none; border-radius: 50%; background: var(--ink-06); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.hdr-spacer { display: inline-block; width: 40px; height: 40px; }

/* ---- Segmented ------------------------------------------------------------ */
.segmented { display: flex; gap: 4px; padding: 4px; border: none; margin: 0; background: var(--field-bg); border-radius: var(--r-pill); }
.seg-item { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: var(--r-pill); color: var(--text-muted); font-weight: 600; font-size: 14px; cursor: pointer; }
.seg-item.active { background: var(--ink); color: var(--lemon); }

/* ---- Chip ----------------------------------------------------------------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; }
.chip { display: inline-flex; padding: 6px 12px; border-radius: var(--r-pill); background: var(--field-bg); color: var(--ink); font-size: 12px; font-weight: 600; border: none; cursor: pointer; }
.chip-li { list-style: none; }

/* ---- Error views ---------------------------------------------------------- */
.error-full { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 12px; padding: 24px; }
.error-full .ev-tri { color: var(--coral); }
.ev-title { font-size: 28px; }
.error-full.dark .ev-title { color: #fff; }
.ev-msg { color: var(--text-muted); max-width: 34ch; font-size: 14px; }
.error-full.dark .ev-msg { color: var(--white-70); }
.ev-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 320px; margin-top: 8px; }
.error-inline { background: rgba(255,138,122,0.08); border: 1px solid rgba(255,138,122,0.25); border-radius: var(--r-14); padding: 14px; }
.error-inline .ev-row { display: flex; align-items: center; gap: 8px; color: var(--coral); font-weight: 700; }
.error-inline .ev-msg { color: var(--text-muted); margin-top: 4px; }

/* ---- Aura Orb ------------------------------------------------------------- */
/* `contain: paint` was tried here to skip GPU repaints on resume switch, but
   it clips overflow to the element's padding box and the halo + sparkles
   extend OUTSIDE the orb — so the issues tab saw a square frame cutting the
   circle off. Reverted to plain `overflow: visible`; the proper fix is
   targeted DOM updates on resume switch instead of the whole-screen
   `innerHTML` swap. */
.aura-orb { position: relative; display: inline-block; overflow: visible; }
.orb-halo { position: absolute; inset: 0; border-radius: 50%; background: var(--grad-conic); filter: blur(calc(var(--orb-size) * 0.06)); }
.aura-orb.animated .orb-halo { animation: orb-spin 18s linear infinite; }
.orb-disc { position: absolute; inset: 9%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #F6EDFF 55%, #E8D5FF);
  box-shadow: 0 0 calc(var(--orb-size) * 0.16) var(--orb-glow), inset 0 0 12px rgba(255,255,255,0.6); }
.orb-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.orb-score { color: var(--ink); line-height: 1; }
.orb-caption { margin-top: 4px; }
.orb-stars { position: absolute; inset: 0; }
.aura-orb.animated .orb-stars { animation: orb-spin 22s linear infinite reverse; }
.orb-star { position: absolute; }
.orb-star .sparkle { width: 100%; height: 100%; }
@keyframes orb-spin { to { transform: rotate(360deg); } }
.aura-orb.animated { animation: orb-float 3s ease-in-out infinite alternate; }
@keyframes orb-float { from { transform: translateY(-4px); } to { transform: translateY(4px); } }

/* score hero mount + one-shot pop */
.orb-mount { animation: orb-mount 0.6s var(--ease-pop) 0.1s both; }
.orb-mount.pop { animation: orb-pop 0.55s var(--ease-pop) both; }
@keyframes orb-mount { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }
@keyframes orb-pop { from { transform: scale(0.4); } to { transform: scale(1); } }

/* First-reveal sequence inside an `.orb-mount.pop` orb: the disc/halo land
   first (0ms — they ride the parent's pop), the score number scales in at
   180ms, then each sparkle star pops with a 40ms stagger starting at 320ms.
   `aria-hidden`-style: pure CSS, no JS, runs once on first paint. */
.orb-mount.pop .orb-score { animation: orb-num-pop 0.45s var(--ease-pop) 0.18s both; transform-origin: center; }
.orb-mount.pop .orb-caption { animation: orb-num-pop 0.45s var(--ease-pop) 0.24s both; transform-origin: center; }
.orb-mount.pop .orb-stars .orb-star { animation: orb-star-pop 0.42s var(--ease-pop) both; transform-origin: center; opacity: 0; }
.orb-mount.pop .orb-stars .orb-star:nth-child(1)  { animation-delay: 0.32s; }
.orb-mount.pop .orb-stars .orb-star:nth-child(2)  { animation-delay: 0.36s; }
.orb-mount.pop .orb-stars .orb-star:nth-child(3)  { animation-delay: 0.40s; }
.orb-mount.pop .orb-stars .orb-star:nth-child(4)  { animation-delay: 0.44s; }
.orb-mount.pop .orb-stars .orb-star:nth-child(5)  { animation-delay: 0.48s; }
.orb-mount.pop .orb-stars .orb-star:nth-child(6)  { animation-delay: 0.52s; }
.orb-mount.pop .orb-stars .orb-star:nth-child(7)  { animation-delay: 0.56s; }
.orb-mount.pop .orb-stars .orb-star:nth-child(8)  { animation-delay: 0.60s; }
.orb-mount.pop .orb-stars .orb-star:nth-child(n+9){ animation-delay: 0.64s; }
@keyframes orb-num-pop  { from { opacity: 0; transform: scale(0.5); } 60% { transform: scale(1.06); } to { opacity: 1; transform: scale(1); } }
@keyframes orb-star-pop { from { opacity: 0; transform: scale(0.2); } 70% { transform: scale(1.18); } to { opacity: 1; transform: scale(1); } }

/* ---- Aura spinner (72%-trim ring) ----------------------------------------- */
.aura-spinner {
  width: var(--spin-size, 36px); height: var(--spin-size, 36px); border-radius: 50%;
  background: conic-gradient(from 0deg, var(--magenta), var(--violet), var(--cyan) 72%, transparent 72% 100%);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(50% - 4px), #000 calc(50% - 3px));
  mask: radial-gradient(farthest-side, transparent calc(50% - 4px), #000 calc(50% - 3px));
  animation: orb-spin 1.8s linear infinite; flex: 0 0 auto;
}

/* ---- Pending card --------------------------------------------------------- */
.pending-card.full { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  background: var(--white-06); border: 1px solid var(--white-10); border-radius: var(--r-20); padding: 28px; }
.pending-card.full .pending-title { font-size: 22px; color: #fff; }
.pending-card.full .eyebrow.light { color: var(--white-60); }
.pending-card.full .pending-file { color: var(--white-60); font-size: 12px; }
.pending-card.row { display: flex; align-items: center; gap: 12px; background: var(--paper); border: 1px solid rgba(138,92,246,0.25); border-radius: var(--r-16); padding: 12px 14px; }
.pending-card.row .pending-meta { flex: 1; }
.pending-card.row .pending-file { color: var(--text-muted); font-size: 12px; }
.pending-tag { color: var(--violet); font-size: 11px; font-weight: 700; }

/* ---- Toasts + banner ------------------------------------------------------ */
#toast-root, #alert-root { position: fixed; left: 0; right: 0; bottom: calc(80px + env(safe-area-inset-bottom)); display: flex; justify-content: center; pointer-events: none; z-index: 2000; padding: 0 16px; }
#alert-root { bottom: calc(140px + env(safe-area-inset-bottom)); }
.toast { display: flex; align-items: center; gap: 10px; max-width: 460px; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--r-pill); box-shadow: var(--shadow-toast); pointer-events: auto; transform: translateY(20px); opacity: 0; transition: transform 0.26s var(--ease-pop), opacity 0.26s; font-size: 14px; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast-msg { font-weight: 500; }
.toast-action { background: none; border: none; color: var(--lemon); font-weight: 700; cursor: pointer; padding: 4px 6px; }
.toast-error .toast-ic { color: var(--coral); }
.toast-error .toast-action { color: var(--coral); }
.toast-close { background: none; border: none; color: var(--white-60); cursor: pointer; }
.ready-banner { position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 50%; transform: translate(-50%, -16px); display: flex; align-items: center; gap: 10px; background: var(--ink); border: 1px solid var(--white-08); color: #fff; padding: 10px 16px; border-radius: var(--r-pill); box-shadow: var(--shadow-toast); cursor: pointer; opacity: 0; transition: transform 0.26s var(--ease-pop), opacity 0.26s; z-index: 2100; }
.ready-banner.show { transform: translate(-50%, 0); opacity: 1; }
.ready-banner .rb-ic { color: var(--lemon); }
.ready-banner .rb-msg { font-size: 14px; font-weight: 600; }
.ready-banner .rb-cta { color: var(--lemon); font-weight: 700; }

/* ---- Tab bar -------------------------------------------------------------- */
#tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--paper); border-top: 1px solid var(--ink-06); padding-bottom: env(safe-area-inset-bottom); z-index: 900; }
#tabbar[hidden] { display: none; }
.tablist { display: flex; max-width: 520px; margin: 0 auto; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 56px; padding: 8px 0; border: none; background: none; color: var(--text-muted); cursor: pointer; }
.tab-ic { display: flex; padding: 4px 14px; border-radius: var(--r-pill); transition: background 0.2s; }
.tab-label { font-size: 9px; letter-spacing: 0.8px; text-transform: lowercase; }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"] .tab-ic { background: rgba(250,225,75,0.4); }
.tab[aria-selected="true"] svg { stroke-width: 2.4; }

/* ---- Sparkline + Distribution -------------------------------------------- */
.sparkline { width: 100%; height: auto; }
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 5px; flex: 0 0 auto; }
.dist-card { display: flex; gap: 16px; background: var(--white-06); border: 1px solid var(--white-10); border-radius: var(--r-22); padding: 18px; }
.dist-left { width: 132px; flex: 0 0 auto; }
.dist-bignum { display: flex; align-items: baseline; gap: 2px; }
.dist-bignum .display { font-size: 56px; color: var(--mint-dark); line-height: 1; }
.dist-out { color: var(--white-55); font-size: 13px; }
.dist-legend { margin: 12px 0; display: flex; flex-direction: column; gap: 6px; }
.dist-legrow { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--white-70); }
.dist-about { display: inline-flex; align-items: center; gap: 4px; background: none; border: none; color: var(--violet); font-size: 13px; font-weight: 600; cursor: pointer; padding: 0; }
.dist-plot { position: relative; flex: 1; min-height: 120px; }
.dist-svg { width: 100%; height: 100px; display: block; }
.dist-marker { position: absolute; top: 0; bottom: 22px; width: 0; }
.dist-line { position: absolute; top: 6px; bottom: 0; left: 0; width: 2px; background: var(--violet); transform: translateX(-1px); }
.dist-dot { position: absolute; top: 0; left: 0; width: 14px; height: 14px; border-radius: 50%; background: var(--violet); border: 3px solid var(--paper); transform: translate(-7px, -2px); cursor: pointer; padding: 0; }
.dist-axis { position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between; color: var(--white-55); font-size: 11px; }
.dist-tooltip { position: absolute; bottom: 30px; transform: translate(-50%, 6px); background: rgba(26,13,46,0.92); border-radius: var(--r-10); padding: 6px 10px; display: flex; flex-direction: column; opacity: 0; transition: transform 0.2s var(--ease-pop), opacity 0.2s; white-space: nowrap; }
.dist-tooltip.show { opacity: 1; transform: translate(-50%, 0); }
.tip-band { color: var(--lemon); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.tip-pct { color: #fff; font-size: 12px; font-weight: 600; }
