/* ============================================================
   Routine Habit — premium redesign
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --paper:            #F0EAE1;
  --paper-deep:       #E4DCC9;
  --paper-hi:         #F5F0E7;
  --ink:              #14110D;
  --ink-soft:         #5C574C;
  --ink-mute:         #8B857A;
  --terracotta:       #903F22;
  --terracotta-hi:    #B4562F;
  --terracotta-deep:  #5A1E09;
  --sand:             #C09E75;
  --sage:             #486846;
  --slate:            #455763;
  --char:             #14110D;
  --glow:             #6EC0E4;

  --nav-h:            64px;
  --wrap-w:           1140px;
  --radius-card:      20px;
  --ease-out:         cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 18px; overflow-x: hidden; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden; /* defensive backstop (#160) — the two overflow root
    causes above are fixed directly, this guards against future decorative/
    rotated elements causing the same class of bug */
}
img { display: block; max-width: 100%; }
a { color: var(--terracotta-deep); }
::selection { background: var(--glow); color: var(--char); }

/* ── Layout utilities ────────────────────────────────────── */
.wrap {
  max-width: var(--wrap-w);
  margin: 0 auto;
  padding: 0 32px;
}

/* ── Eyebrow ─────────────────────────────────────────────── */
.eyebrow {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sage);
  margin-bottom: 16px;
}

/* ── CTA buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  border-radius: 999px;
  transition: transform 0.18s var(--ease-out),
              box-shadow 0.18s var(--ease-out),
              background 0.18s ease;
  cursor: pointer;
  border: none;
}

.btn-primary {
  padding: 16px 36px;
  background: var(--terracotta);
  color: #FFF8F1;
  box-shadow: 0 8px 24px rgba(144, 63, 34, 0.35),
              0 1px 3px rgba(144, 63, 34, 0.2);
}
.btn-primary:hover, .btn-primary:focus-visible {
  background: var(--terracotta-deep);
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(90, 30, 9, 0.38),
              0 2px 6px rgba(90, 30, 9, 0.2);
}

.btn-ghost {
  padding: 14px 28px;
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--paper-deep);
}
.btn-ghost:hover, .btn-ghost:focus-visible {
  border-color: var(--ink-mute);
  color: var(--ink);
  transform: translateY(-1px);
}

.btn:focus-visible { outline: 3px solid var(--glow); outline-offset: 3px; }

/* ── Navigation ──────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--nav-h);
  transition: background 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
}

.nav.scrolled {
  background: rgba(240, 234, 225, 0.82);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  box-shadow: 0 1px 0 rgba(20, 17, 13, 0.08);
}

.nav.hidden {
  transform: translateY(-100%);
}

.nav-inner {
  max-width: var(--wrap-w);
  margin: 0 auto;
  padding: 0 32px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
  font-size: 1rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.nav-logo img {
  height: 30px;
  width: auto;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
  list-style: none;
}

.nav-links a {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.15s;
}
.nav-links a:hover { color: var(--ink); }

.nav-cta {
  font-size: 0.9rem;
  padding: 10px 22px;
}

/* ── Hero ────────────────────────────────────────────────── */
.hero {
  min-height: 100svh;
  padding-top: calc(var(--nav-h) + 60px);
  padding-bottom: 80px;
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--paper-hi) 0%, var(--paper) 55%, #EAE0D3 100%);
  display: flex;
  align-items: center;
}

/* Ambient cairn behind the phone — the signature element */
.hero-cairn-bg {
  position: absolute;
  right: -2%;
  top: 50%;
  transform: translateY(-50%);
  width: 52%;
  max-width: 680px;
  opacity: 0.055;
  pointer-events: none;
  filter: blur(1px);
  user-select: none;
}

/* Grain texture overlay */
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.4;
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 64px;
  align-items: center;
  width: 100%;
}

.hero-text { max-width: 520px; }

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(72, 104, 70, 0.1);
  border: 1px solid rgba(72, 104, 70, 0.22);
  border-radius: 999px;
  padding: 5px 14px 5px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--sage);
  letter-spacing: 0.04em;
  margin-bottom: 28px;
}
.hero-tag svg { flex-shrink: 0; }

h1.hero-headline {
  font-family: 'Inter', sans-serif;
  font-size: clamp(2.4rem, 5vw, 3.9rem);
  font-weight: 900;
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin-bottom: 24px;
}

h1.hero-headline em {
  font-style: normal;
  color: var(--terracotta);
}

.hero-subhead {
  font-size: 1.1rem;
  line-height: 1.65;
  color: var(--ink-soft);
  max-width: 44ch;
  margin-bottom: 36px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

.trust-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(240, 234, 225, 0.9);
  border: 1px solid var(--paper-deep);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.77rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.badge svg { color: var(--sage); flex-shrink: 0; }

/* Hero phone visual */
.hero-visual {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.phone-primary {
  width: 260px;
  border-radius: 38px;
  box-shadow:
    0 40px 80px rgba(20, 17, 13, 0.28),
    0 8px 20px rgba(20, 17, 13, 0.14),
    0 0 0 1px rgba(20, 17, 13, 0.06);
  position: relative;
  z-index: 2;
  animation: float-phone 5s ease-in-out infinite;
}

.phone-secondary {
  width: 200px;
  border-radius: 30px;
  box-shadow:
    0 20px 40px rgba(20, 17, 13, 0.2),
    0 4px 10px rgba(20, 17, 13, 0.1);
  position: absolute;
  z-index: 1;
  animation: float-phone-secondary 6s ease-in-out infinite;
}

.phone-secondary.left {
  left: -60px;
  transform: rotate(-7deg) translateY(20px);
}

.phone-secondary.right {
  right: -60px;
  transform: rotate(7deg) translateY(20px);
}

@keyframes float-phone {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-12px); }
}

@keyframes float-phone-secondary {
  0%, 100% { transform: rotate(-7deg) translateY(20px); }
  50%       { transform: rotate(-7deg) translateY(8px); }
}

.phone-secondary.right {
  animation: float-phone-right 6.5s ease-in-out infinite;
}

@keyframes float-phone-right {
  0%, 100% { transform: rotate(7deg) translateY(20px); }
  50%       { transform: rotate(7deg) translateY(10px); }
}

/* ── Section shared ──────────────────────────────────────── */
.section {
  padding: 100px 0;
  border-top: 1px solid var(--paper-deep);
}

.section-header {
  margin-bottom: 64px;
}

.section-title {
  font-family: 'Inter', sans-serif;
  font-size: clamp(1.8rem, 3.5vw, 2.5rem);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 16px;
  max-width: 22ch;
}

.section-lede {
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 52ch;
  line-height: 1.7;
}

/* ── Science ─────────────────────────────────────────────── */
.science-section {
  background: var(--paper);
}

.science-inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 80px;
  align-items: start;
}

.phase-spine {
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  padding-left: 52px;
}

/* Vertical line running through the phases */
.phase-spine::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 14px;
  bottom: 14px;
  width: 2px;
  background: linear-gradient(to bottom, var(--terracotta) 0%, var(--sand) 50%, var(--sage) 100%);
  opacity: 0.3;
}

.phase-item {
  position: relative;
  padding-bottom: 48px;
}

.phase-item:last-child { padding-bottom: 0; }

/* Painted-stone node */
.phase-node {
  position: absolute;
  left: -52px;
  top: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  box-shadow:
    0 3px 8px rgba(20, 17, 13, 0.2),
    inset 0 -3px 5px rgba(0,0,0,0.15),
    inset 0 2px 3px rgba(255,255,255,0.35);
}

.phase-node.n1 { background: radial-gradient(circle at 34% 28%, #C96040, var(--terracotta) 55%, var(--terracotta-deep)); }
.phase-node.n2 { background: radial-gradient(circle at 34% 28%, #E9DBBB, var(--sand) 60%, #A79A82); }
.phase-node.n3 { background: radial-gradient(circle at 34% 28%, #94A287, var(--sage) 60%, #3D5A3B); }

.phase-range {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--terracotta-deep);
  margin-bottom: 6px;
}

.phase-name {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 10px;
}

.phase-desc {
  font-size: 0.97rem;
  color: var(--ink-soft);
  line-height: 1.65;
  max-width: 40ch;
}

/* ── Gallery ─────────────────────────────────────────────── */
.gallery-section {
  background: var(--paper-hi);
}

.gallery-cluster {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 24px;
  padding: 20px 0 40px;
}

.gallery-cluster img {
  border-radius: 28px;
  box-shadow:
    0 30px 60px rgba(20, 17, 13, 0.24),
    0 6px 16px rgba(20, 17, 13, 0.12),
    0 0 0 1px rgba(20, 17, 13, 0.06);
}

.gallery-cluster img:nth-child(1) {
  width: 220px;
  transform: rotate(-5deg) translateY(16px);
  opacity: 0.92;
}

.gallery-cluster img:nth-child(2) {
  width: 280px;
  z-index: 2;
  box-shadow:
    0 50px 100px rgba(20, 17, 13, 0.3),
    0 10px 30px rgba(20, 17, 13, 0.16),
    0 0 0 1px rgba(20, 17, 13, 0.07);
}

.gallery-cluster img:nth-child(3) {
  width: 220px;
  transform: rotate(5deg) translateY(16px);
  opacity: 0.92;
}

/* Mid-page CTA section */
.mid-cta-section {
  background: var(--paper);
  text-align: center;
}

.mid-cta-section .section-title {
  margin: 0 auto 16px;
  text-align: center;
  max-width: 28ch;
}

.mid-cta-section .section-lede {
  margin: 0 auto 36px;
  text-align: center;
}

/* ── Features ────────────────────────────────────────────── */
.features-section {
  background: var(--paper);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.feature-card {
  background: var(--paper-hi);
  border: 1px solid var(--paper-deep);
  border-radius: var(--radius-card);
  padding: 28px;
  transition: transform 0.22s var(--ease-out),
              box-shadow 0.22s var(--ease-out),
              border-color 0.22s ease;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(20, 17, 13, 0.1),
              0 4px 10px rgba(20, 17, 13, 0.06);
  border-color: rgba(192, 158, 117, 0.5);
}

.feature-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  font-size: 1.3rem;
}

.feature-card:nth-child(1) .feature-icon { background: rgba(144, 63, 34, 0.12); }
.feature-card:nth-child(2) .feature-icon { background: rgba(192, 158, 117, 0.2); }
.feature-card:nth-child(3) .feature-icon { background: rgba(72, 104, 70, 0.12); }
.feature-card:nth-child(4) .feature-icon { background: rgba(69, 87, 99, 0.12); }
.feature-card:nth-child(5) .feature-icon { background: rgba(144, 63, 34, 0.08); }
.feature-card:nth-child(6) .feature-icon { background: rgba(72, 104, 70, 0.08); }

/* ── IAP tier icon (support page) ───────────────────────── */
.tier-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  margin-bottom: 18px;
  box-shadow: 0 8px 20px rgba(20, 17, 13, 0.14),
              0 2px 6px rgba(20, 17, 13, 0.08);
}

.feature-title {
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 8px;
}

.feature-desc {
  font-size: 0.92rem;
  color: var(--ink-soft);
  line-height: 1.65;
}

/* ── Final CTA ───────────────────────────────────────────── */
.final-cta-section {
  background: var(--char);
  padding: 120px 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.final-cta-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 70% at 50% 50%, rgba(144, 63, 34, 0.18) 0%, transparent 70%);
  pointer-events: none;
}

.final-cairn {
  height: 90px;
  width: auto;
  margin: 0 auto 28px;
  opacity: 0.85;
  mix-blend-mode: screen;
}

.final-cta-section h2 {
  font-family: 'Inter', sans-serif;
  font-size: clamp(1.9rem, 3.5vw, 2.8rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: #FFF8F1;
  margin-bottom: 16px;
  position: relative;
}

.final-cta-section p {
  font-size: 1.05rem;
  color: rgba(239, 233, 220, 0.65);
  margin-bottom: 40px;
  position: relative;
}

.final-cta-section .btn-primary {
  background: var(--terracotta);
  box-shadow: 0 12px 32px rgba(144, 63, 34, 0.45);
  position: relative;
}
.final-cta-section .btn-primary:hover {
  background: var(--terracotta-hi);
  box-shadow: 0 16px 40px rgba(144, 63, 34, 0.55);
}

/* ── Footer ──────────────────────────────────────────────── */
footer {
  background: #0F0D0A;
  color: #EFE9DC;
  padding: 60px 0 44px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.footer-logo img {
  height: 36px;
  width: auto;
  mix-blend-mode: screen;
}

.footer-logo-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: #FFF8F1;
  letter-spacing: -0.01em;
}

.footer-tagline {
  color: rgba(239, 233, 220, 0.45);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
  font-size: 0.88rem;
  margin-top: 28px;
}

.footer-links a {
  color: var(--sand);
  text-decoration: none;
  border-bottom: 1px solid rgba(192, 158, 117, 0.3);
  padding-bottom: 1px;
  transition: color 0.15s, border-color 0.15s;
}

.footer-links a:hover {
  color: #FFF8F1;
  border-color: rgba(255, 248, 241, 0.5);
}

.copyright {
  margin-top: 28px;
  color: rgba(239, 233, 220, 0.28);
  font-size: 0.8rem;
}

/* ── Scroll-triggered fade-in ────────────────────────────── */
.fade-in {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.65s var(--ease-out), transform 0.65s var(--ease-out);
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

.fade-in.delay-1 { transition-delay: 0.1s; }
.fade-in.delay-2 { transition-delay: 0.2s; }
.fade-in.delay-3 { transition-delay: 0.3s; }
.fade-in.delay-4 { transition-delay: 0.4s; }
.fade-in.delay-5 { transition-delay: 0.5s; }

@media (prefers-reduced-motion: reduce) {
  .fade-in { opacity: 1; transform: none; transition: none; }
  .phone-primary, .phone-secondary { animation: none !important; }
  .cairn-mark { animation: none !important; }
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 960px) {
  .hero-inner {
    grid-template-columns: 1fr;
    gap: 56px;
    text-align: center;
  }

  .hero-text { max-width: 100%; }
  .hero-subhead { max-width: 100%; }
  .hero-actions { justify-content: center; }
  .trust-badges { justify-content: center; }

  /* Deliberately no order: -1 here (#160) — a first-time visitor on mobile
     should see the headline/value prop before the phone screenshots, since
     they don't yet know what the app is. Source order (text, then visual)
     is already correct; keep it. */

  .phone-secondary.left  { left: -40px; }
  .phone-secondary.right { right: -40px; }

  .science-inner {
    grid-template-columns: 1fr;
    gap: 48px;
  }

  .science-cairn-wrap {
    display: none !important;
  }

  .feature-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  html { font-size: 16px; }

  .wrap { padding: 0 20px; }
  .nav-inner { padding: 0 20px; }
  .nav-links { display: none; }

  .hero { padding-top: calc(var(--nav-h) + 32px); padding-bottom: 56px; }

  .phone-primary { width: 200px; }
  .phone-secondary { width: 150px; }
  .phone-secondary.left  { left: -24px; }
  .phone-secondary.right { right: -24px; }

  .section { padding: 72px 0; }

  /* #160: the desktop cluster is a non-wrapping flex row with fixed pixel
     widths + rotation, which forced page-level horizontal scroll on phones
     (three images totalling 548px+ into ~335px of available width). Wrap
     onto two rows instead — primary screenshot on top, the two secondary
     ones below — and size everything with min(px, vw) so it can never
     exceed the viewport regardless of exact device width. */
  .gallery-cluster {
    flex-wrap: wrap;
    row-gap: 20px;
  }

  .gallery-cluster img:nth-child(2) {
    order: -1;
    width: min(220px, 58vw);
    margin: 0 auto;
  }

  .gallery-cluster img:nth-child(1),
  .gallery-cluster img:nth-child(3) {
    width: min(150px, 38vw);
    transform: none;
  }

  .feature-grid { grid-template-columns: 1fr; }

  .science-inner { gap: 40px; }
}

@media (max-width: 420px) {
  h1.hero-headline { font-size: 2rem; }

  .phone-secondary { display: none; }
  .phone-primary { width: 220px; }
}
