/* ════════════════════════════════════════════════════════════════════
   RallyPro shared component layer (design-language v2).
   Loaded ONLY by pages migrated to the refreshed design, alongside
   _tokens.css. Tokens live in _tokens.css; this file is structure +
   components: buttons, marketing header/footer, status pill, section
   heads, scroll-reveal + hero-enter motion. Safe to add to a page
   without touching the others — un-migrated pages never link it.
   Curves/timings reference the v2 motion tokens in _tokens.css.
   ════════════════════════════════════════════════════════════════════ */

/* ── Layout helper ──────────────────────────────────────────────────── */
.wrap { max-width: 1120px; margin-inline: auto; padding-inline: 24px; }

/* ── Buttons (require the .btn base; scale-on-press feedback) ────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; border-radius: var(--r-pill); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; user-select: none; text-decoration: none;
  transition: background var(--d-pop) var(--e-out), border-color var(--d-pop) var(--e-out),
              transform var(--d-press) var(--e-press), box-shadow var(--d-pop) var(--e-out);
}
.btn:active { transform: scale(0.97); }
.btn-lg { padding: 14px 26px; font-size: 16px; }
.btn-md { padding: 10px 18px; font-size: 14px; }
.btn-sm { padding: 9px 16px; font-size: 13px; }
.btn-primary { background: var(--accent); color: var(--accent-text); box-shadow: 0 1px 0 rgba(255,255,255,0.18) inset; }
.btn-primary:hover { background: var(--accent-bright); box-shadow: 0 10px 30px -12px var(--accent); }
.btn-ghost { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-active); border-color: var(--border-strong); }
.btn-gold { background: var(--gold); color: var(--accent-text); }
.btn-gold:hover { background: var(--gold-bright); }
.btn .arr { transition: transform var(--d-pop) var(--e-out); }
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover .arr, .link-arrow:hover .arr { transform: translateX(3px); }
}
.link-arrow { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; }

/* ── Marketing header ───────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg-grad-to) 72%, transparent);
  backdrop-filter: blur(16px) saturate(160%); -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid transparent;
  transition: border-color var(--d-pop) var(--e-out);
}
.header.scrolled { border-bottom-color: var(--border); }
.header-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 14px; position: relative; }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand .mark { width: 34px; height: 34px; border-radius: 9px; display: block; }
.wordmark { font-weight: 600; letter-spacing: -0.02em; font-size: 18px; }
.nav-pill {
  display: inline-flex; align-items: center; gap: 2px; padding: 4px; border-radius: var(--r-pill);
  background: var(--surface-hover); border: 1px solid var(--border);
}
.nav-link {
  font-size: 14px; font-weight: 500; color: var(--text-muted); padding: 7px 14px; border-radius: var(--r-pill);
  transition: color var(--d-pop) var(--e-out), background var(--d-pop) var(--e-out);
}
.nav-link:hover { color: var(--text); background: var(--surface-hover); }
.nav-link.active { color: var(--text); background: var(--surface-hover); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; background: var(--surface-hover); border: 1px solid var(--border);
  color: var(--text-muted); display: grid; place-items: center; cursor: pointer;
  transition: color var(--d-pop) var(--e-out), border-color var(--d-pop) var(--e-out), transform var(--d-press) var(--e-press);
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(0.94); }
html:not(.theme-light) .icon-sun { display: none; }
html.theme-light .icon-moon { display: none; }
.mobile-toggle { display: none; }
@media (max-width: 820px) { .mobile-toggle { display: grid; } .nav-pill, .header .btn-desktop { display: none; } }
.mobile-menu {
  display: none; position: absolute; left: 16px; right: 16px; top: calc(100% + 8px);
  background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: var(--r-xl);
  padding: 8px; z-index: 31; box-shadow: 0 24px 60px -20px rgba(0,0,0,0.5);
  opacity: 0; transform: translateY(-8px) scale(0.98); transform-origin: top right;
  transition: opacity var(--d-pop) var(--e-out), transform var(--d-pop) var(--e-out);
}
.mobile-menu.is-open { display: block; opacity: 1; transform: translateY(0) scale(1); }
.mobile-menu a { display: block; padding: 13px 14px; border-radius: var(--r-md); font-size: 16px; font-weight: 500; color: var(--text); text-decoration: none; }
.mobile-menu a:hover, .mobile-menu a.active { background: var(--surface-hover); }
.mobile-menu .sep { height: 1px; background: var(--border); margin: 6px 4px; }

/* ── Section heads + status pill ────────────────────────────────────── */
.section { padding-block: 40px; }
.section-head { max-width: 42rem; }
.section-head.center { margin-inline: auto; text-align: center; }
.section-head h2 { font-size: clamp(1.7rem, 3.2vw, 2.3rem); font-weight: 700; letter-spacing: -0.025em; }
.section-head p { margin-top: 12px; color: var(--text-muted); line-height: 1.6; }
.status-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 10px; border-radius: var(--r-pill);
  background: var(--surface-hover); border: 1px solid var(--border); font-size: 12.5px; font-weight: 500; color: var(--text-muted);
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); position: relative; }
.status-pill .dot::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1.5px solid var(--accent); opacity: 0; animation: rp-ping 2.4s var(--e-out) infinite; }
@keyframes rp-ping { 0% { transform: scale(0.6); opacity: 0.8; } 80%,100% { transform: scale(1.8); opacity: 0; } }

/* ── Logged-in user menu (avatar + popover) ─────────────────────────── */
.user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text); font-weight: 700; font-size: 15px;
  display: grid; place-items: center; overflow: hidden; cursor: pointer; border: 0;
  transition: transform var(--d-press) var(--e-press);
}
.user-avatar:active { transform: scale(0.94); }
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-pop {
  position: absolute; right: 0; top: calc(100% + 8px); width: 224px;
  background: var(--surface-solid); border: 1px solid var(--border-strong); border-radius: var(--r-lg);
  padding: 4px; z-index: 40; box-shadow: 0 20px 50px -16px rgba(0,0,0,0.5);
  opacity: 0; transform: translateY(-6px) scale(0.98); transform-origin: top right; pointer-events: none;
  transition: opacity var(--d-pop) var(--e-out), transform var(--d-pop) var(--e-out);
}
.user-pop.is-open { opacity: 1; transform: none; pointer-events: auto; }
.user-pop a, .user-pop button {
  display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: var(--r-md);
  font-size: 14px; color: var(--text); background: transparent; border: 0; cursor: pointer; text-decoration: none;
}
.user-pop a:hover, .user-pop button:hover { background: var(--surface-hover); }
.user-pop .pop-header { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-pop .pop-name { font-size: 14px; font-weight: 600; color: var(--text); }
.user-pop .pop-email { font-size: 12px; color: var(--text-faint); }

/* ── Footer ─────────────────────────────────────────────────────────── */
.footer { border-top: 1px solid var(--border); margin-top: 36px; }
.footer-in { padding-block: 32px; display: flex; flex-direction: column; gap: 20px; }
.footer-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.footer-meta { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--text-faint); }
.footer-meta a { color: var(--text-muted); }
.footer-nav { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; }
.footer-nav a { color: var(--text-muted); }
.footer-nav a:hover { color: var(--text); }

/* ── Scroll reveal + hero entrance ──────────────────────────────────────
   Reveal ENHANCES an already-visible default: the hidden initial state is
   gated behind (prefers-reduced-motion: no-preference) AND .js, so if JS
   never runs or motion is reduced, content is visible. .in is added by an
   IntersectionObserver on the page. */
.reveal > * { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .js .reveal:not(.in) > .r-item { opacity: 0; transform: translateY(16px); }
  .reveal > .r-item { transition: opacity var(--d-reveal) var(--e-out), transform var(--d-reveal) var(--e-out); }
  .reveal.in > .r-item { opacity: 1; transform: none; }
  .reveal.in > .r-item:nth-child(2) { transition-delay: 60ms; }
  .reveal.in > .r-item:nth-child(3) { transition-delay: 120ms; }
  .reveal.in > .r-item:nth-child(4) { transition-delay: 180ms; }
  .reveal.in > .r-item:nth-child(5) { transition-delay: 240ms; }
  .reveal.in > .r-item:nth-child(6) { transition-delay: 300ms; }
  /* Animation FILL carries the hidden→visible state (both = backwards
     fill during the delay, forwards after). Crucially we do NOT set a
     persistent opacity:0 base, so if the `animation` shorthand ever
     fails to parse (missing token / stale cache), the element simply
     stays visible instead of vanishing. */
  .js .hero-enter { animation: rp-heroIn var(--d-reveal) var(--e-out) both; }
  .js .hero-enter.d1 { animation-delay: 80ms; }
  .js .hero-enter.d2 { animation-delay: 160ms; }
  .js .hero-enter.d3 { animation-delay: 240ms; }
  .js .hero-enter.d4 { animation-delay: 320ms; }
  @keyframes rp-heroIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
}
