/* ============================================================
   CALCULUS TUTOR — Landing Page
   Design: "Mathematical Precision"
   Dark premium, Apple-inspired, scroll-driven 3D device reveal
   ============================================================ */

/* --- Tokens --- */
:root {
  --black: #030305;
  --surface: #08080d;
  --elevated: #101018;
  --card: #13131c;
  --border: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.1);

  --text-1: #F4F4F6;
  --text-2: #A0A0A8;
  --text-3: #5A5A64;

  --accent: #E8A838;
  --accent-bright: #F5C563;
  --accent-glow: rgba(232, 168, 56, 0.3);
  --accent-soft: rgba(232, 168, 56, 0.1);
  --cyan: #3ABDB5;
  --cyan-glow: rgba(58, 189, 181, 0.2);
  --warm: #E8A838;
  --warm-glow: rgba(232, 168, 56, 0.2);
  --rose: #E06B5E;
  --rose-glow: rgba(224, 107, 94, 0.15);

  --font-display: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 32px;
  --radius-pill: 100px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --max-w: 1120px;
}

/* --- Reset --- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-body);
  background: var(--black);
  color: var(--text-1);
  overflow-x: hidden;
  line-height: 1.6;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input { font-family: inherit; }

/* --- Scroll Progress Bar --- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--cyan), var(--accent));
  z-index: 200;
  transition: none;
  will-change: width;
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* --- Animated Gradient Orbs --- */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.6;
  will-change: transform;
}

.orb-1 {
  width: 650px;
  height: 650px;
  background: radial-gradient(circle, rgba(232, 168, 56, 0.35), transparent 65%);
  top: -10%;
  left: -5%;
  animation: orbit1 8s ease-in-out infinite alternate;
}

.orb-2 {
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, rgba(58, 189, 181, 0.3), transparent 65%);
  top: 35%;
  right: -10%;
  animation: orbit2 10s ease-in-out infinite alternate;
}

.orb-3 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(224, 107, 94, 0.22), transparent 65%);
  bottom: -5%;
  left: 25%;
  animation: orbit3 9s ease-in-out infinite alternate;
}

@keyframes orbit1 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(12vw, 8vh) scale(1.15); }
  100% { transform: translate(4vw, 18vh) scale(0.9); }
}

@keyframes orbit2 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-10vw, -6vh) scale(1.2); }
  100% { transform: translate(-5vw, 10vh) scale(0.95); }
}

@keyframes orbit3 {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(8vw, -12vh) scale(1.1); }
  100% { transform: translate(-6vw, -4vh) scale(1.15); }
}

/* --- Dot Grid Background --- */
.dot-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

/* --- Floating Math Symbols --- */
.math-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.math-sym {
  position: absolute;
  left: var(--x);
  top: var(--y);
  font-family: var(--font-display);
  font-size: calc(52px * var(--s));
  color: rgba(232, 168, 56, 0.1);
  animation: float var(--d) ease-in-out infinite alternate;
  will-change: transform;
  user-select: none;
  text-shadow: 0 0 40px currentColor;
}
.math-sym:nth-child(even) { color: rgba(34, 211, 238, 0.08); }
.math-sym:nth-child(3n) { color: rgba(251, 113, 133, 0.07); }
.math-sym:nth-child(5n) { color: rgba(249, 115, 22, 0.07); }

@keyframes float {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-24px) rotate(8deg); }
}

/* --- Glowing Section Divider --- */
.glow-divider {
  position: relative;
  z-index: 2;
  height: 1px;
  max-width: 800px;
  margin: 0 auto;
  background: linear-gradient(90deg, transparent, var(--accent), var(--cyan), var(--accent), transparent);
  opacity: 0.3;
}
.glow-divider::after {
  content: '';
  position: absolute;
  inset: -8px 20%;
  background: linear-gradient(90deg, transparent, var(--accent-glow), var(--cyan-glow), var(--accent-glow), transparent);
  filter: blur(12px);
  z-index: -1;
}

/* --- Nav --- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 16px 24px;
  transition: background 0.4s, backdrop-filter 0.4s;
}
.nav.scrolled {
  background: rgba(5, 5, 7, 0.8);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #D4883A);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 20px;
  color: white;
  font-weight: 400;
}
.logo-mark.small { width: 28px; height: 28px; font-size: 16px; }
.logo-text {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
}
.nav-links a { transition: color 0.2s; }
.nav-links a:hover { color: var(--text-1); }
.nav-cta {
  background: var(--accent-soft);
  border: 1px solid rgba(108, 108, 255, 0.2);
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  color: var(--accent-bright) !important;
  transition: all 0.2s var(--ease);
}
.nav-cta:hover {
  background: rgba(108, 108, 255, 0.15);
  border-color: rgba(108, 108, 255, 0.35);
  box-shadow: 0 0 20px var(--accent-glow);
}

/* --- Hero --- */
.hero {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 120px 24px 80px;
  text-align: center;
}
.hero-content {
  max-width: 720px;
  position: relative;
}
.hero-content::before {
  content: '';
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 800px;
  height: 600px;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(232, 168, 56, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 60%, rgba(58, 189, 181, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(224, 107, 94, 0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: -1;
  animation: hero-glow 8s ease-in-out infinite alternate;
}

@keyframes hero-glow {
  0% { opacity: 0.7; filter: blur(0px); }
  100% { opacity: 1; filter: blur(10px); }
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  border: 1px solid rgba(108, 108, 255, 0.15);
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-bright);
  margin-bottom: 28px;
  letter-spacing: 0.02em;
}
.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-bright);
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px transparent; }
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(40px, 7vw, 72px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 400;
  margin-bottom: 24px;
}
.hero-accent {
  background: linear-gradient(135deg, var(--accent-bright) 0%, var(--cyan) 60%, #5CD6CE 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-style: italic;
}

.hero-sub {
  font-size: clamp(16px, 2.2vw, 20px);
  color: var(--text-2);
  line-height: 1.6;
  max-width: 540px;
  margin: 0 auto 36px;
}

.hero-form {
  display: flex;
  gap: 10px;
  max-width: 440px;
  margin: 0 auto;
}
.hero-input {
  flex: 1;
  padding: 14px 20px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-light);
  background: var(--elevated);
  color: var(--text-1);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.hero-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.hero-input::placeholder { color: var(--text-3); }

.hero-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
  box-shadow: 0 0 24px var(--accent-glow);
}
.hero-btn:hover {
  background: var(--accent-bright);
  transform: translateY(-1px);
  box-shadow: 0 0 36px var(--accent-glow);
}
.hero-btn:active { transform: translateY(0); }
.btn-icon { display: flex; }

.hero-note {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-3);
}

/* --- 3D iPad Scroll Section --- */
.device-section {
  position: relative;
  z-index: 2;
  height: 300vh; /* scroll space for animation */
}
.device-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.device-scene {
  perspective: 1200px;
  perspective-origin: 50% 40%;
}
.device-ipad {
  transform-style: preserve-3d;
  transform: rotateX(55deg) scale(0.75) translateY(80px);
  will-change: transform;
}
.device-bezel {
  width: min(80vw, 720px);
  aspect-ratio: 1194 / 834;
  background: #1a1a1e;
  border-radius: 24px;
  padding: 14px;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.08),
    0 20px 60px rgba(0,0,0,0.6),
    0 0 120px rgba(108, 108, 255, 0.08);
  position: relative;
}
.device-bezel::before {
  /* Camera dot */
  content: '';
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2a2a30;
  z-index: 2;
}
.device-screen {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #0d0e14;
}
.device-screenshot {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.device-caption {
  margin-top: 40px;
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}
.device-caption.visible {
  opacity: 1;
  transform: translateY(0);
}
.caption-text {
  font-family: var(--font-display);
  font-size: clamp(18px, 3vw, 28px);
  color: var(--text-2);
  font-style: italic;
}

/* --- Sections Common --- */
.section-container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 24px;
}
.section-header {
  text-align: center;
  margin-bottom: 64px;
}
.section-tag {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-bright);
  margin-bottom: 16px;
}
.section-header h2 {
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 400;
}
.text-accent { color: var(--text-2); }

/* --- Features --- */
.features {
  position: relative;
  z-index: 2;
  padding: 120px 0;
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.feature-card {
  padding: 32px 28px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(20, 20, 30, 0.9), rgba(16, 16, 24, 0.95));
  border: 1px solid var(--border-light);
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s;
  position: relative;
  overflow: hidden;
}
.feature-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232, 168, 56, 0.3), transparent);
}
.feature-card:hover {
  border-color: rgba(232, 168, 56, 0.2);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4), 0 0 60px rgba(232, 168, 56, 0.06);
  transform: translateY(-4px);
}
.feature-card:nth-child(2)::before { background: linear-gradient(90deg, transparent, rgba(58, 189, 181, 0.3), transparent); }
.feature-card:nth-child(2):hover { border-color: rgba(58, 189, 181, 0.2); box-shadow: 0 8px 40px rgba(0,0,0,0.4), 0 0 60px rgba(58, 189, 181, 0.06); }
.feature-card:nth-child(3)::before { background: linear-gradient(90deg, transparent, rgba(224, 107, 94, 0.3), transparent); }
.feature-card:nth-child(3):hover { border-color: rgba(224, 107, 94, 0.2); box-shadow: 0 8px 40px rgba(0,0,0,0.4), 0 0 60px rgba(224, 107, 94, 0.06); }
.feature-card:nth-child(4)::before { background: linear-gradient(90deg, transparent, rgba(232, 168, 56, 0.3), transparent); }
.feature-card:nth-child(4):hover { border-color: rgba(232, 168, 56, 0.2); }
.feature-card:nth-child(5)::before { background: linear-gradient(90deg, transparent, rgba(58, 189, 181, 0.3), transparent); }
.feature-card:nth-child(6)::before { background: linear-gradient(90deg, transparent, rgba(52, 211, 153, 0.3), transparent); }
.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  color: var(--accent-bright);
}
.feature-card:nth-child(1) .feature-icon { background: var(--accent-soft); color: var(--accent-bright); }
.feature-card:nth-child(2) .feature-icon { background: var(--cyan-glow); color: var(--cyan); }
.feature-card:nth-child(3) .feature-icon { background: var(--rose-glow); color: var(--rose); }
.feature-card:nth-child(4) .feature-icon { background: rgba(232, 168, 56, 0.12); color: #F5C563; }
.feature-card:nth-child(5) .feature-icon { background: rgba(58, 189, 181, 0.12); color: #5CD6CE; }
.feature-card:nth-child(6) .feature-icon { background: rgba(52, 211, 153, 0.12); color: #34D399; }
.feature-card h3 {
  font-family: var(--font-display);
  font-size: 22px;
  margin-bottom: 10px;
  font-weight: 400;
}
.feature-card p {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-2);
}

/* --- How It Works --- */
.how-it-works {
  position: relative;
  z-index: 2;
  padding: 100px 0 120px;
}
.steps {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.step {
  display: flex;
  gap: 28px;
  align-items: flex-start;
  padding: 32px 0;
}
.step-number {
  font-family: var(--font-display);
  font-size: 52px;
  color: var(--accent);
  opacity: 0.5;
  line-height: 1;
  flex-shrink: 0;
  width: 64px;
  text-align: right;
  text-shadow: 0 0 30px var(--accent-glow);
}
.step:nth-child(3) .step-number { color: var(--cyan); text-shadow: 0 0 30px var(--cyan-glow); }
.step:nth-child(5) .step-number { color: var(--rose); text-shadow: 0 0 30px var(--rose-glow); }
.step-content h3 {
  font-family: var(--font-display);
  font-size: 24px;
  margin-bottom: 8px;
  font-weight: 400;
}
.step-content p {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.65;
}
.step-line {
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, var(--border-light), transparent);
  margin-left: 84px;
}

/* --- Waitlist CTA --- */
.waitlist {
  position: relative;
  z-index: 2;
  padding: 60px 0 120px;
}
.waitlist-card {
  position: relative;
  max-width: 640px;
  margin: 0 auto;
  padding: 56px 48px;
  border-radius: var(--radius-xl);
  background: var(--card);
  border: 1px solid var(--border-light);
  text-align: center;
  overflow: hidden;
}
.waitlist-glow {
  position: absolute;
  top: -60%;
  left: 50%;
  transform: translateX(-50%);
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(232, 168, 56, 0.18) 0%, rgba(58, 189, 181, 0.08) 40%, transparent 70%);
  pointer-events: none;
  animation: pulse-glow 4s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
  0% { opacity: 0.4; transform: translateX(-50%) scale(1); }
  100% { opacity: 0.7; transform: translateX(-50%) scale(1.1); }
}
.waitlist-card h2 {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 40px);
  margin-bottom: 12px;
  font-weight: 400;
  position: relative;
}
.waitlist-desc {
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.65;
  margin-bottom: 32px;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
  position: relative;
}
.waitlist-form {
  display: flex;
  gap: 10px;
  max-width: 420px;
  margin: 0 auto;
  position: relative;
}
.waitlist-input {
  flex: 1;
  padding: 14px 20px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-light);
  background: var(--elevated);
  color: var(--text-1);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.waitlist-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.waitlist-input::placeholder { color: var(--text-3); }
.waitlist-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  white-space: nowrap;
  box-shadow: 0 0 24px var(--accent-glow);
}
.waitlist-btn:hover {
  background: var(--accent-bright);
  transform: translateY(-1px);
}
.waitlist-count {
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-3);
  position: relative;
}

/* --- Footer --- */
.footer {
  position: relative;
  z-index: 2;
  border-top: 1px solid var(--border);
  padding: 24px;
}
.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.footer-brand {
  font-weight: 600;
  font-size: 14px;
}
.footer-copy {
  font-size: 13px;
  color: var(--text-3);
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 14px 24px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: white;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px var(--accent-glow);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Scroll Reveal --- */
[data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}
[data-reveal].revealed {
  opacity: 1;
  transform: translateY(0);
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .nav-links a:not(.nav-cta) { display: none; }
}
@media (max-width: 640px) {
  .features-grid {
    grid-template-columns: 1fr;
  }
  .hero-form, .waitlist-form {
    flex-direction: column;
  }
  .hero-btn, .waitlist-btn {
    justify-content: center;
  }
  .step { gap: 16px; }
  .step-number { width: 40px; font-size: 36px; }
  .step-line { margin-left: 48px; }
  .device-bezel { border-radius: 16px; padding: 8px; }
  .waitlist-card { padding: 40px 24px; }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .device-ipad { transform: none !important; }
  [data-reveal] { opacity: 1; transform: none; }
}
