/* ==========================================================================
   PulsaFit - Design System
   ========================================================================== */

:root {
  --background: 213 30% 8%;
  --foreground: 0 0% 100%;
  --card: 210 25% 12%;
  --secondary: 210 20% 16%;
  --muted-foreground: 212 18% 61%;
  --primary: 22 88% 56%;
  --primary-foreground: 0 0% 100%;
  --orange-dark: 18 80% 50%;
  --orange-light: 22 80% 60%;
  --green: 160 64% 52%;
  --border-soft: 255 255 255 / 0.06;
  --border-softer: 255 255 255 / 0.05;
  --border-softest: 255 255 255 / 0.08;
  --radius-pill: 100px;
  --radius-xl: 1.25rem;
  --radius-2xl: 1.5rem;
}

* { -webkit-box-sizing: border-box; box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: 'Instrument Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Instrument Sans', sans-serif;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-weight: 700;
  color: hsl(var(--foreground));
}

a { color: inherit; text-decoration: none; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

img, svg { display: block; max-width: 100%; }

/* ---------- Grain overlay ---------- */
.grain-overlay::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  opacity: 0.03;
  pointer-events: none;
  z-index: 50;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
}

/* ---------- Utilities ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 0 1.5rem; }
.container-sm { max-width: 768px; margin: 0 auto; padding: 0 1.5rem; }
.container-md { max-width: 896px; margin: 0 auto; padding: 0 1.5rem; }
.container-lg { max-width: 1024px; margin: 0 auto; padding: 0 1.5rem; }

.text-center { text-align: center; }
.text-primary { color: hsl(var(--primary)); }
.text-muted { color: hsl(var(--muted-foreground)); }
.text-green { color: hsl(var(--green)); }

.text-gradient-orange {
  background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--orange-light)));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.font-serif-italic {
  font-family: 'Newsreader', Georgia, serif;
  font-style: italic;
}

.font-mono-code {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
}

.orange-glow {
  background: radial-gradient(ellipse at center, hsl(22 88% 56% / 0.15) 0%, transparent 70%);
}
.orange-glow-bottom {
  background: radial-gradient(ellipse at center bottom, hsl(22 88% 56% / 0.12) 0%, transparent 60%);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 2rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 1rem;
  -webkit-transition: background-color 0.2s, color 0.2s, -webkit-transform 0.2s;
  transition: background-color 0.2s, color 0.2s, -webkit-transform 0.2s;
  transition: background-color 0.2s, color 0.2s, transform 0.2s;
  transition: background-color 0.2s, color 0.2s, transform 0.2s, -webkit-transform 0.2s;
  white-space: nowrap;
}
.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.btn-primary:hover { background: hsl(var(--orange-dark)); }

.btn-outline {
  border: 1px solid hsl(var(--border-softest));
  color: hsl(var(--foreground));
}
.btn-outline:hover { background: hsl(var(--secondary) / 0.5); }

.btn-sm { padding: 0.5rem 1.25rem; font-size: 0.875rem; }

/* ---------- Navbar ---------- */
body > header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: hsl(var(--background) / 0.7);
  border-bottom: 1px solid hsl(var(--border-soft));
  -webkit-transition: background 0.2s;
  transition: background 0.2s;
}
body > header.is-scrolled { background: hsl(var(--background) / 0.9); }

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 4rem;
}

.logo-link {
  display: inline-flex;
  align-items: center;
}
.logo-img {
  height: 36px;
  width: auto;
  display: block;
}

.nav-desktop {
  display: none;
  align-items: center;
  gap: 2rem;
}
.nav-desktop a, .nav-desktop button {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  -webkit-transition: color 0.2s;
  transition: color 0.2s;
}
.nav-desktop a:hover, .nav-desktop button:hover { color: hsl(var(--foreground)); }

.nav-desktop .nav-cta,
.nav-mobile-wrap .nav-cta,
a.nav-cta,
button.nav-cta {
  background: hsl(var(--primary));
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-pill);
  -webkit-transition: background 0.2s;
  transition: background 0.2s;
}
.nav-desktop .nav-cta:hover,
.nav-mobile-wrap .nav-cta:hover,
a.nav-cta:hover,
button.nav-cta:hover {
  background: hsl(var(--orange-dark));
  color: #fff;
}

.nav-mobile-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.menu-btn {
  color: hsl(var(--foreground));
  padding: 0.25rem;
}
.menu-btn svg { width: 22px; height: 22px; }
.menu-btn .icon-x { display: none; }
.menu-btn.is-open .icon-menu { display: none; }
.menu-btn.is-open .icon-x { display: block; }

.mobile-menu {
  display: none;
  background: hsl(var(--background) / 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid hsl(var(--border-soft));
  padding: 1rem 1.5rem 1.5rem;
}
.mobile-menu.is-open { display: block; }
.mobile-menu a, .mobile-menu button {
  display: block;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  width: 100%;
  text-align: left;
}
.mobile-menu a:hover, .mobile-menu button:hover { color: hsl(var(--foreground)); }

@media (min-width: 768px) {
  .nav-desktop { display: flex; }
  .nav-mobile-wrap { display: none; }
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 8rem 0 6rem;
  overflow: hidden;
}
.hero-inner {
  position: relative;
  max-width: 896px;
  margin: 0 auto;
  padding: 0 1.5rem;
  text-align: center;
}
.hero .orange-glow {
  position: absolute; inset: 0; pointer-events: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: hsl(var(--secondary) / 0.6);
  border: 1px solid hsl(var(--border-softest));
  border-radius: var(--radius-pill);
  padding: 0.375rem 1rem;
  margin-bottom: 2rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}
.badge-dot {
  position: relative;
  display: inline-flex;
  width: 0.5rem;
  height: 0.5rem;
}
.badge-dot::before {
  content: '';
  position: absolute;
  inset: 0;
  background: hsl(var(--primary));
  border-radius: 9999px;
  opacity: 0.75;
  -webkit-animation: ping 1.5s cubic-bezier(0,0,0.2,1) infinite;
          animation: ping 1.5s cubic-bezier(0,0,0.2,1) infinite;
}
.badge-dot::after {
  content: '';
  position: relative;
  display: inline-flex;
  width: 0.5rem; height: 0.5rem;
  background: hsl(var(--primary));
  border-radius: 9999px;
}
@-webkit-keyframes ping {
  75%, 100% { -webkit-transform: scale(2); transform: scale(2); opacity: 0; }
}
@keyframes ping {
  75%, 100% { -webkit-transform: scale(2); transform: scale(2); opacity: 0; }
}

.hero h1 {
  font-size: clamp(2.25rem, 6vw, 4.5rem);
  font-weight: 700;
  line-height: 1.08;
  margin-bottom: 1.5rem;
}
.hero .lead {
  font-size: clamp(1.125rem, 2vw, 1.25rem);
  color: hsl(var(--muted-foreground));
  max-width: 40rem;
  margin: 0 auto 2.5rem;
  line-height: 1.6;
}
.hero-ctas {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}
@media (min-width: 640px) {
  .hero-ctas { flex-direction: row; }
}

/* ---------- Sections ---------- */
section.section {
  padding: 6rem 0;
}
@media (min-width: 768px) {
  section.section { padding: 8rem 0; }
}
section.section-border {
  border-top: 1px solid hsl(var(--border-soft));
}

.eyebrow {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: hsl(var(--primary));
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.section-title {
  font-size: clamp(1.875rem, 4vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
}

.section-intro {
  color: hsl(var(--muted-foreground));
  max-width: 42rem;
  font-size: 1.125rem;
  line-height: 1.6;
}

.section-header { margin-bottom: 3.5rem; }

/* ---------- Feature grid cards ---------- */
.card-grid {
  display: -ms-grid;
  display: grid;
  gap: 1.25rem;
  -ms-grid-columns: 1fr;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) { .card-grid.cols-2 { -ms-grid-columns: (1fr)[2]; grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px) { .card-grid { -ms-grid-columns: (1fr)[2]; grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .card-grid.cols-3 { -ms-grid-columns: (1fr)[3]; grid-template-columns: repeat(3, 1fr); } }

.feature-card {
  position: relative;
  background: -webkit-gradient(linear, left top, left bottom, from(hsl(var(--secondary) / 0.5)), to(hsl(var(--secondary) / 0.2)));
  background: linear-gradient(to bottom, hsl(var(--secondary) / 0.5), hsl(var(--secondary) / 0.2));
  border: 1px solid hsl(var(--border-softer));
  border-radius: var(--radius-2xl);
  padding: 1.5rem;
  -webkit-transition: -webkit-transform 0.3s, -webkit-box-shadow 0.3s;
  transition: -webkit-transform 0.3s, -webkit-box-shadow 0.3s;
  transition: transform 0.3s, box-shadow 0.3s;
  transition: transform 0.3s, box-shadow 0.3s, -webkit-transform 0.3s, -webkit-box-shadow 0.3s;
}
.feature-card:hover {
  -webkit-transform: translateY(-4px);
          transform: translateY(-4px);
  -webkit-box-shadow: 0 20px 40px -10px hsl(var(--primary) / 0.05);
          box-shadow: 0 20px 40px -10px hsl(var(--primary) / 0.05);
}
.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 1.5rem;
  right: 1.5rem;
  height: 2px;
  background: hsl(var(--primary));
  -webkit-transform: scaleX(0);
          transform: scaleX(0);
  -webkit-transition: -webkit-transform 0.3s;
  transition: -webkit-transform 0.3s;
  transition: transform 0.3s;
  transition: transform 0.3s, -webkit-transform 0.3s;
  border-radius: 9999px;
}
.feature-card:hover::before { -webkit-transform: scaleX(1); transform: scaleX(1); }

.feature-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.75rem;
  background: hsl(var(--primary) / 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  color: hsl(var(--primary));
}
.feature-icon svg { width: 1.25rem; height: 1.25rem; }

.feature-title { font-size: 1.125rem; font-weight: 600; margin-bottom: 0.5rem; }
.feature-desc { font-size: 0.875rem; color: hsl(var(--muted-foreground)); line-height: 1.6; }

/* ---------- Dashboard preview ---------- */
.dashboard-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border-soft));
  border-radius: var(--radius-2xl);
  padding: 1.25rem;
}
@media (min-width: 768px) { .dashboard-card { padding: 2rem; } }

.metric-grid {
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: 1fr;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (min-width: 768px) { .metric-grid { -ms-grid-columns: (1fr)[3]; grid-template-columns: repeat(3, 1fr); } }

.metric-card {
  background: hsl(var(--secondary) / 0.4);
  border: 1px solid hsl(var(--border-softer));
  border-radius: 0.75rem;
  padding: 1.25rem;
}
.metric-label { font-size: 0.75rem; color: hsl(var(--muted-foreground)); font-weight: 500; margin-bottom: 0.25rem; }
.metric-value { font-size: 1.5rem; font-weight: 700; }
.metric-sub { font-size: 0.75rem; color: hsl(var(--muted-foreground)); margin-top: 0.25rem; }

.chart-card {
  background: hsl(var(--secondary) / 0.4);
  border: 1px solid hsl(var(--border-softer));
  border-radius: 0.75rem;
  padding: 1.25rem;
}
.chart-card svg { width: 100%; height: auto; }

/* ---------- Steps (How it works) ---------- */
.steps { display: flex; flex-direction: column; gap: 4rem; }

.step {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}
@media (min-width: 768px) { .step { gap: 2.5rem; } }

.step-num {
  font-family: 'Newsreader', Georgia, serif;
  font-style: italic;
  font-size: 3rem;
  color: hsl(var(--primary) / 0.3);
  line-height: 1;
  -webkit-user-select: none;
     -moz-user-select: none;
      -ms-user-select: none;
          user-select: none;
  flex-shrink: 0;
  width: 4rem;
  text-align: right;
}
@media (min-width: 768px) {
  .step-num { font-size: 4.5rem; width: 6rem; }
}

.step h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
@media (min-width: 768px) { .step h3 { font-size: 1.5rem; } }
.step p { color: hsl(var(--muted-foreground)); line-height: 1.6; }

/* ---------- Code block ---------- */
.code-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border-soft));
  border-radius: var(--radius-2xl);
  padding: 1.5rem;
  overflow-x: auto;
}
@media (min-width: 768px) { .code-card { padding: 2rem; } }
.code-card pre {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.75;
}
.code-card .code-comment { color: hsl(var(--muted-foreground)); }
.code-card .code-primary { color: hsl(var(--primary)); }
.code-card .code-green { color: hsl(var(--green)); }
.code-card .code-fg { color: hsl(var(--foreground)); }

/* ---------- CTA section ---------- */
.cta-section {
  position: relative;
  padding: 6rem 0 9rem;
  overflow: hidden;
}
@media (min-width: 768px) { .cta-section { padding: 9rem 0; } }
.cta-inner {
  position: relative;
  max-width: 768px;
  margin: 0 auto;
  padding: 0 1.5rem;
  text-align: center;
}
.cta-section h2 {
  font-size: clamp(1.875rem, 4vw, 3rem);
  margin-bottom: 1rem;
  line-height: 1.15;
}
.cta-section .lead {
  color: hsl(var(--muted-foreground));
  font-size: 1.125rem;
  margin: 0 auto 2.5rem;
  max-width: 36rem;
}

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid hsl(var(--border-soft));
  padding: 2.5rem 0;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
@media (min-width: 768px) { .footer-inner { flex-direction: row; } }

.footer-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}
.footer-copy { font-size: 0.75rem; color: hsl(var(--muted-foreground)); }

.footer-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}
.footer-links a { -webkit-transition: color 0.2s; transition: color 0.2s; }
.footer-links a:hover { color: hsl(var(--foreground)); }

/* ---------- Content pages (Privacy/Terms/About/Contact) ---------- */
.page-main {
  padding: 7rem 0 5rem;
}
.page-main h1 {
  font-size: clamp(1.875rem, 4vw, 2.5rem);
  margin-bottom: 1.5rem;
}
.page-main p.updated {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-bottom: 2.5rem;
  margin-top: -0.75rem;
}
.prose {
  color: hsl(var(--muted-foreground));
  line-height: 1.7;
}
.prose > * + * { margin-top: 1rem; }
.prose h2 {
  color: hsl(var(--foreground));
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}
.prose h3 {
  color: hsl(var(--foreground));
  font-size: 1rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}
.prose ul {
  list-style: disc;
  padding-left: 1.25rem;
}
.prose ul li + li { margin-top: 0.25rem; }
.prose p.lead { font-size: 1.125rem; }
.prose strong { color: hsl(var(--foreground)); }

.content-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border-soft));
  border-radius: var(--radius-2xl);
  padding: 1.5rem;
  margin-top: 2.5rem;
}
.content-card h2 { margin-top: 0; }
.content-card ul { list-style: none; padding: 0; }
.content-card ul li { margin-top: 0.75rem; }

.back-link {
  display: inline-block;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid hsl(var(--border-soft));
  font-size: 0.875rem;
  color: hsl(var(--primary));
  width: 100%;
}
.back-link:hover { text-decoration: underline; }

.contact-grid {
  display: -ms-grid;
  display: grid;
  gap: 1.25rem;
  -ms-grid-columns: 1fr;
  grid-template-columns: 1fr;
  margin: 2.5rem 0;
}
@media (min-width: 768px) { .contact-grid { -ms-grid-columns: (1fr)[2]; grid-template-columns: repeat(2, 1fr); } }

.contact-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border-soft));
  border-radius: var(--radius-2xl);
  padding: 1.5rem;
}
.contact-card svg { width: 1.5rem; height: 1.5rem; color: hsl(var(--primary)); margin-bottom: 0.75rem; }
.contact-card h3 { font-weight: 600; margin-bottom: 0.25rem; }
.contact-card p { font-size: 0.875rem; color: hsl(var(--muted-foreground)); margin-top: 0.25rem; }
.contact-card strong { color: hsl(var(--foreground)); }

/* ---------- 404 ---------- */
.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.5rem;
}
.error-page-content { text-align: center; }
.error-page h1 { font-size: 4rem; margin-bottom: 1rem; }
.error-page h2 { font-size: 1.25rem; color: hsl(var(--muted-foreground)); font-weight: 500; margin-bottom: 1rem; }
.error-page p { color: hsl(var(--muted-foreground)); margin-bottom: 2rem; }

/* ---------- Animations ---------- */
.animate-on-scroll {
  opacity: 0;
  -webkit-transform: translateY(24px);
          transform: translateY(24px);
  -webkit-transition: opacity 0.7s ease-out, -webkit-transform 0.7s ease-out;
  transition: opacity 0.7s ease-out, -webkit-transform 0.7s ease-out;
  transition: opacity 0.7s ease-out, transform 0.7s ease-out;
  transition: opacity 0.7s ease-out, transform 0.7s ease-out, -webkit-transform 0.7s ease-out;
}
.animate-on-scroll.is-visible {
  opacity: 1;
  -webkit-transform: translateY(0);
          transform: translateY(0);
}
