/* ============ MathLabs — shared styles ============ */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Caveat:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@300;400&display=swap');

:root {
  --cream: #faf6f1;
  --cream-2: #f4ece1;
  --navy: #1d2547;
  --navy-2: #2a3358;
  --rose: #e9b4b4;
  --rose-soft: #f5d4d4;
  --rose-pale: #fbe9e9;
  --gold: #c8a96a;
  --ink: #1d2547;
  --ink-muted: #5a6285;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 400;
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(233,180,180,0.04) 0, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(29,37,71,0.03) 0, transparent 40%);
  z-index: 0;
}

.serif { font-family: 'Cormorant Garamond', serif; }
.script { font-family: 'Caveat', cursive; }
.mono { font-family: 'JetBrains Mono', monospace; }

/* ----- Top bar ----- */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(250,246,241,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(29,37,71,0.06);
  transition: padding .3s, background .3s;
}
.topbar.scrolled { padding: 10px 20px; background: rgba(250,246,241,0.95); }

.brand-mini {
  display: flex; align-items: baseline; gap: 2px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.02em;
}
.brand-mini .lab {
  font-family: 'Caveat', cursive;
  color: var(--rose);
  font-size: 26px;
  font-weight: 600;
  font-style: normal;
  margin-left: 1px;
}

.lang-toggle {
  display: flex;
  background: var(--cream-2);
  border-radius: 999px;
  padding: 3px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.lang-toggle button {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  transition: all .25s;
}
.lang-toggle button.active {
  background: var(--navy);
  color: var(--cream);
}

/* ----- Common ----- */
.section {
  position: relative;
  padding: 80px 24px;
  max-width: 560px;
  margin: 0 auto;
  z-index: 1;
}

.eyebrow {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 600;
  margin-bottom: 16px;
}

.h-display {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: clamp(36px, 9vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--navy);
}

.brush-pill {
  display: inline-block;
  position: relative;
  padding: 8px 22px;
  font-family: 'Caveat', cursive;
  font-size: 22px;
  color: var(--navy);
  font-weight: 600;
}
.brush-pill::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--rose);
  border-radius: 50% 40% 55% 45% / 60% 50% 70% 40%;
  z-index: -1;
  transform: rotate(-1deg);
  opacity: 0.85;
}

.underline-rose {
  position: relative;
  display: inline-block;
}
.underline-rose svg {
  position: absolute;
  left: -4px; right: -4px;
  bottom: -10px;
  width: calc(100% + 8px);
  height: 12px;
  stroke: var(--rose);
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
}

.sticky {
  background: var(--rose-soft);
  padding: 16px 18px;
  border-radius: 2px 14px 6px 18px;
  box-shadow: 2px 4px 10px rgba(29,37,71,0.08), inset 0 1px 0 rgba(255,255,255,0.4);
  font-family: 'Caveat', cursive;
  font-size: 18px;
  color: var(--navy);
  line-height: 1.3;
  position: relative;
}
.sticky.yellow { background: #f8e9b8; }
.sticky.pink   { background: var(--rose-pale); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 28px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 999px;
  cursor: pointer;
  border: 0;
  transition: transform .2s, box-shadow .25s, background .25s;
}
.btn-primary {
  background: var(--navy);
  color: var(--cream);
  box-shadow: 0 6px 18px rgba(29,37,71,0.18);
}
.btn-primary:hover, .btn-primary:active {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(29,37,71,0.25);
  background: var(--navy-2);
}
.btn-ghost {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--navy);
}

.sparkle {
  display: inline-block;
  color: var(--gold);
  font-size: 14px;
  animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .9s cubic-bezier(.22,.61,.36,1), transform .9s cubic-bezier(.22,.61,.36,1);
}
.reveal.in { opacity: 1; transform: translateY(0); }

.reveal-rotate {
  opacity: 0;
  transform: rotate(-8deg) translateY(40px) scale(0.9);
  transition: opacity .8s cubic-bezier(.34,1.56,.64,1), transform .8s cubic-bezier(.34,1.56,.64,1);
}
.reveal-rotate.in { opacity: 1; transform: rotate(var(--final-rotate, 0deg)) translateY(0) scale(1); }

.draw-path {
  stroke-dasharray: var(--len, 1000);
  stroke-dashoffset: var(--len, 1000);
  transition: stroke-dashoffset 1.6s ease-out;
}
.draw-path.in { stroke-dashoffset: 0; }

.formula-bg {
  position: absolute;
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: rgba(29,37,71,0.10);
  font-size: 26px;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
}

@media (min-width: 720px) {
  .section { padding: 100px 32px; }
}

html[dir="rtl"] body { font-family: 'Inter', 'Tajawal', sans-serif; }
html[dir="rtl"] .brush-pill::before { transform: rotate(1deg); }
