/* ============================================
   If/Then Habits — Landing Page
   Visual system ported from Project Cicada
   Tokens
   ============================================ */
:root {
  --bg: #0a0a0a;
  --bg-alt: #0e0e0e;
  --text: #f0f0f0;
  --muted: #a0a0a0;
  --muted-dim: #4a4a4a;
  --accent: #d8d8d8;
  --accent-dim: #55555a;
  --line: rgba(240, 240, 240, 0.09);
  --line-strong: rgba(240, 240, 240, 0.16);
  --ember: #6e93f2;

  --font-display: "Space Grotesk", "Inter", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

html {
  overflow-x: hidden;
  width: 100%;
  touch-action: pan-y;
  scrollbar-gutter: stable;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  width: 100%;
  touch-action: pan-y;
}

a { color: inherit; }

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

::selection { background: var(--accent); color: #0a0a0a; }

/* Scroll progress rail with per-section dots */
.rail {
  position: fixed;
  right: clamp(18px, 3.5vw, 40px);
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.rail__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-dim);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.3s ease, transform 0.3s ease;
}

.rail__dot::after {
  content: attr(data-label);
  position: absolute;
  right: 18px;
  transform: translateX(6px);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.rail__dot { position: relative; }

.rail__dot:hover::after,
.rail__dot:focus-visible::after {
  opacity: 1;
  transform: translateX(0);
}

.rail__dot.is-active {
  background: var(--accent);
  transform: scale(1.6);
}

.rail__dot:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 4px;
}

/* Persistent TestFlight CTA, top-right, above the rail */
.topbar {
  position: fixed;
  top: 20px;
  right: clamp(18px, 3.5vw, 40px);
  z-index: 101;
}

/* ============================================
   Hero
   ============================================ */
.hero {
  position: relative;
  min-height: var(--vh100, 100svh);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  overflow: hidden;
  isolation: isolate;
}

.hero__grid {
  position: absolute;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, black 10%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, black 10%, transparent 75%);
}

.hero__grid::before {
  content: "";
  position: absolute;
  inset: -128px;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 64px 64px;
  animation: grid-drift 40s linear infinite;
}

@keyframes grid-drift {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(64px, 128px, 0); }
}

.hero__glow {
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(180deg, rgba(240, 240, 240, 0.06) 0%, transparent 45%);
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-style: normal;
  font-size: clamp(2.6rem, 9vw, 7rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
  opacity: 0;
  animation: rise 1s ease forwards 0.2s;
}

.hero__title em {
  font-style: normal;
  font-weight: 600;
  color: var(--text);
}

.hero__lede {
  margin-top: 22px;
  font-size: clamp(1.05rem, 1rem + 0.4vw, 1.3rem);
  color: var(--muted);
  max-width: 42ch;
  opacity: 0;
  animation: rise 0.9s ease forwards 0.35s;
}

.hero__byline {
  margin-top: 22px;
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.06em;
  color: var(--muted);
  opacity: 0;
  animation: rise 0.9s ease forwards 0.5s;
}

.hero__byline a {
  text-decoration: none;
  border-bottom: 1px solid var(--muted-dim);
  transition: border-color 0.25s ease, color 0.25s ease;
}

.hero__byline a:hover { color: var(--text); border-color: var(--accent); }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes rise-centered {
  from { opacity: 0; transform: translate(-50%, 14px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.hero__scroll {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: 0;
  animation: rise-centered 0.9s ease forwards 1s;
}

.hero__scroll span {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero__scroll-line {
  width: 1px;
  height: 34px;
  background: linear-gradient(var(--muted-dim), transparent);
  position: relative;
  overflow: hidden;
}

.hero__scroll-line::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 34px;
  background: linear-gradient(var(--text), transparent);
  animation: scroll-drip 2.2s ease-in-out infinite;
}

@keyframes scroll-drip {
  0% { transform: translateY(-34px); }
  70%, 100% { transform: translateY(34px); }
}

/* ============================================
   Feature sections
   ============================================ */
.project {
  position: relative;
  min-height: var(--vh100, 100svh);
  display: flex;
  align-items: center;
  padding: 120px clamp(24px, 6vw, 80px);
  border-top: 1px solid var(--line);
}

.project__inner {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: clamp(40px, 6vw, 96px);
  align-items: center;
}

.project:nth-of-type(even) .project__inner { grid-template-columns: 1.4fr 1fr; }
.project:nth-of-type(even) .project__media { order: 2; }
.project:nth-of-type(even) .project__body { order: 1; }

.project__media {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: #050505;
  width: 100%;
}

.project__media-fallback {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background:
    repeating-linear-gradient(135deg, var(--line) 0, var(--line) 1px, transparent 1px, transparent 14px);
  color: var(--muted-dim);
}

.project__media.no-image .project__media-fallback { display: flex; }

.project__media-fallback code {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: rgba(0,0,0,0.4);
  padding: 4px 10px;
  border-radius: 3px;
}

/* ---------- Phone screenshots in a device frame ---------- */
.project__media--phone {
  aspect-ratio: 1320 / 2868;
  height: clamp(480px, calc(var(--vh100, 100svh) * 0.74), 740px);
  width: auto;
  max-width: 100%;
  margin: 0 auto;
  justify-self: center;
  border: none;
  background: none;
  overflow: visible;
}

.iphone-frame {
  position: relative;
  width: 100%;
  height: 100%;
  padding: 10px;
  border-radius: 46px;
  background: #232325;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.iphone-frame__screen {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 36px;
  overflow: hidden;
  background: #000;
}

.iphone-frame__screen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.iphone-frame__screen img.is-loaded { opacity: 1; }

.iphone-frame__island {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 28%;
  max-width: 92px;
  height: 24px;
  border-radius: 14px;
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  z-index: 2;
}

.iphone-frame__btn {
  position: absolute;
  background: linear-gradient(90deg, #2a2a2c, #46464a);
  border-radius: 3px;
}

.iphone-frame__btn--action { left: -3px; top: 15%; width: 3px; height: 26px; }
.iphone-frame__btn--vol-up { left: -3px; top: 24%; width: 3px; height: 44px; }
.iphone-frame__btn--vol-down { left: -3px; top: 33%; width: 3px; height: 44px; }
.iphone-frame__btn--power { right: -3px; top: 26%; width: 3px; height: 60px; }

.project__index {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.project__index b { color: var(--accent); font-weight: 500; }

.project__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.1rem, 4vw, 3.2rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin-bottom: 20px;
}

.project__desc {
  color: var(--muted);
  font-size: 16.5px;
  max-width: 48ch;
  margin-bottom: 32px;
}

.project__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
}

.project__tags span {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: 0.02em;
}

.project__link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--accent);
  padding-bottom: 4px;
  transition: color 0.25s ease, gap 0.25s ease;
  width: fit-content;
}

.project__link:hover { color: var(--accent); gap: 12px; }

.project__link--cta {
  color: #fff;
  background: var(--ember);
  border: none;
  border-bottom: none;
  border-radius: 6px;
  padding: 10px 18px;
  box-shadow: 0 0 16px 1px rgba(110, 147, 242, 0.45);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.25s ease, gap 0.25s ease, filter 0.25s ease;
}

.project__link--cta::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: shimmer 2.4s ease-in-out infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-120%); }
  55% { transform: translateX(120%); }
  100% { transform: translateX(120%); }
}

.project__link--cta:hover {
  color: #fff;
  filter: brightness(1.1);
  box-shadow: 0 0 22px 3px rgba(110, 147, 242, 0.6);
  gap: 12px;
}

.project__link--cta:focus-visible {
  outline: 1px solid #fff;
  outline-offset: 3px;
}

.project__link--cta.project__link--small {
  padding: 8px 14px;
  font-size: 12px;
}

.project__features {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 32px;
}

.project__features h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 10px;
}

.project__features ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.project__features li {
  position: relative;
  padding-left: 16px;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.5;
  max-width: 48ch;
}

.project__features li::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 0.75em;
  width: 5px;
  height: 5px;
  margin-top: -2.5px;
  border-radius: 50%;
  background: var(--ember);
}

/* ============================================
   Final CTA — TestFlight beta
   ============================================ */
.cta {
  position: relative;
  min-height: var(--vh100, 100svh);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 120px clamp(24px, 6vw, 80px);
  border-top: 1px solid var(--line);
}

.cta__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 640px;
}

.cta__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 20px;
}

.cta__desc {
  color: var(--muted);
  font-size: 16.5px;
  max-width: 46ch;
  margin: 0 auto 36px;
}

.cta__fineprint {
  margin-top: 22px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted-dim);
}

/* ============================================
   Footer
   ============================================ */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 56px clamp(24px, 6vw, 80px) 44px;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
}

.site-footer__mark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
}

.site-footer__mark em {
  font-style: normal;
  color: var(--text);
}

.site-footer__links {
  display: flex;
  gap: 28px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.site-footer__links a {
  text-decoration: none;
  color: var(--muted);
  transition: color 0.25s ease;
}

.site-footer__links a:hover { color: var(--accent); }

.site-footer__meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted-dim);
  letter-spacing: 0.04em;
}

/* Reveal-on-scroll */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 860px) {
  .project { padding: 90px 24px; }
  .project__inner,
  .project:nth-of-type(even) .project__inner {
    grid-template-columns: 1fr;
  }
  .project:nth-of-type(even) .project__media,
  .project:nth-of-type(even) .project__body {
    order: initial;
  }
  .rail { display: none; }

  .topbar { top: 16px; }
  .topbar .project__link--cta { padding: 8px 14px; font-size: 12px; }

  .project__link {
    display: flex;
    justify-content: center;
    margin-inline: auto;
  }

  .project__tags {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .hero__title { font-size: 2.4rem; }
  .cta__title { white-space: normal; font-size: clamp(1.6rem, 7vw, 2.2rem); }
}
