/* ============================================================
   Blood Sugar Ninja — marketing site
   Design tokens mirror the app's Theme/DesignTokens.swift:
   cream surfaces, charcoal ink, sage in-range green, headband red.
   Pastel slate is web-only, per the landing-page brief.
   ============================================================ */

:root {
  /* Surfaces (bsBackground / bsCardMuted / bsCard) */
  --cream: #f5efe3;
  --cream-deep: #ede8d9;
  --card: #ffffff;

  /* Ink (bsText / bsTextMuted / bsTextFaint) — never pure black */
  --ink: #18150f;
  --ink-muted: #6b6258;
  --ink-faint: #9e9487;

  /* Pastel accents */
  --sage: #85bf8f;        /* bsInRange */
  --sage-soft: #e2eee4;
  --slate: #8fa3b8;
  --slate-soft: #e3e9ef;
  --amber-soft: #f2e7cd;
  --rose-soft: #f3e1dc;

  /* Brand red — the ninja's headband. Used sparingly. */
  --red: #d94f3f;

  --divider: #e3dfd5;

  --serif: "Fraunces", "New York", ui-serif, Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  /* Corners echo the app's 22pt continuous card radius */
  --r-card: 22px;
  --r-big: 34px;

  /* Shadows: exceptionally soft, diffuse, low opacity */
  --shadow: 0 30px 70px -30px rgba(62, 52, 38, 0.20);
  --shadow-soft: 0 18px 44px -26px rgba(62, 52, 38, 0.16);

  --container: 1120px;
  --pad: clamp(1.25rem, 4vw, 2.5rem);
}

/* ---------- Reset-ish ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 420;
  line-height: 1.08;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2.5px solid var(--slate);
  outline-offset: 3px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--cream);
  padding: 0.6rem 1rem;
  border-radius: 0 0 12px 0;
  z-index: 100;
}

.skip-link:focus {
  left: 0;
}

.container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--pad);
}

/* ---------- Shared text styles ---------- */

.eyebrow {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 1.1rem;
}

.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 3px;
  background: var(--sage);
}

.eyebrow--slate::before {
  background: var(--slate);
}

.eyebrow--rose::before {
  background: var(--red);
  opacity: 0.55;
}

.lede {
  color: var(--ink-muted);
  font-size: clamp(1.05rem, 1.5vw, 1.2rem);
  max-width: 34em;
}

.section {
  padding-block: clamp(4.5rem, 9vw, 7.5rem);
}

.section-head {
  max-width: 38em;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.section-head h2 {
  font-size: clamp(1.9rem, 3.6vw, 2.8rem);
  margin-bottom: 0.85rem;
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--cream) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--divider) 70%, transparent);
}

.nav {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding-block: 0.85rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 540;
  margin-right: auto;
  white-space: nowrap;
}

.brand img {
  width: 34px;
  height: 34px;
}

.nav-links {
  display: flex;
  gap: 1.75rem;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-muted);
}

.nav-links a {
  text-decoration: none;
  transition: color 0.18s ease;
}

.nav-links a:hover {
  color: var(--ink);
}

.nav-cta {
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  background: var(--ink);
  color: var(--cream);
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  transition: background 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
}

.nav-cta:hover {
  background: var(--red);
}

@media (max-width: 720px) {
  .nav-links {
    display: none;
  }
}

/* ---------- Hero ---------- */

.hero {
  padding-block: clamp(3.5rem, 7vw, 6.5rem) clamp(4rem, 8vw, 7rem);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(0, 0.96fr);
  gap: clamp(2.5rem, 6vw, 5rem);
  align-items: center;
}

.hero h1 {
  font-size: clamp(2.75rem, 5.6vw, 4.35rem);
  margin-bottom: 1.35rem;
}

.hero h1 em {
  font-style: italic;
  font-weight: 380;
  color: var(--ink);
}

.hero .lede {
  margin-bottom: 2.25rem;
}

.hero-ctas {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

.hero-note {
  font-size: 0.85rem;
  color: var(--ink-faint);
}

.text-link {
  font-weight: 600;
  font-size: 0.97rem;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 2px solid var(--sage);
  padding-bottom: 2px;
  transition: border-color 0.18s ease;
}

.text-link:hover {
  border-color: var(--red);
}

/* App Store badge (CSS-drawn; href filled by script.js) */

.appstore-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  border-radius: 14px;
  padding: 0.7rem 1.35rem 0.75rem 1.15rem;
  line-height: 1.15;
  transition: transform 0.2s ease, background 0.2s ease;
}

.appstore-badge:hover {
  transform: translateY(-2px);
  background: #2a241c;
}

.appstore-badge svg {
  width: 26px;
  height: 26px;
  flex: none;
}

.appstore-badge .small {
  display: block;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  opacity: 0.85;
}

.appstore-badge .big {
  display: block;
  font-size: 1.18rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Hero illustration stage: seeded with the app's mascot on a CSS
   isometric plinth, until the commissioned isometric scene lands. */

.hero-stage {
  position: relative;
  min-height: clamp(360px, 42vw, 520px);
  display: grid;
  place-items: center;
}

.hero-stage .tile {
  position: absolute;
  border-radius: 26%;
  transform: rotate(45deg) scaleY(0.58);
}

.tile-1 {
  width: min(78%, 380px);
  aspect-ratio: 1;
  background: var(--sage-soft);
  bottom: 4%;
}

.tile-2 {
  width: min(56%, 270px);
  aspect-ratio: 1;
  background: var(--slate-soft);
  bottom: 12%;
  left: 2%;
}

.hero-ninja {
  position: relative;
  width: min(62%, 330px);
  filter: drop-shadow(0 26px 28px rgba(62, 52, 38, 0.22));
}

/* Floating UI chips around the mascot */

.chip {
  position: absolute;
  background: var(--card);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.5rem 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
}

.chip .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--sage);
  flex: none;
}

.chip--reading {
  top: 12%;
  right: 4%;
  animation: floaty 5.5s ease-in-out infinite;
}

.chip--feeling {
  bottom: 22%;
  left: 0;
  animation: floaty 6.5s ease-in-out 0.8s infinite;
}

.chip--guess {
  top: 13%;
  left: 0;
  background: var(--ink);
  color: var(--cream);
  font-weight: 500;
  animation: floaty 6s ease-in-out 1.6s infinite;
}

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}

/* ---------- Ninja sprite animation ----------
   Horizontal 13-frame strips built by scripts/build_sprite_sheets.py.
   Frame 0 is the calm rest pose, so with no JS (or under Reduce Motion)
   the ninja simply stands still. script.js steps background-position to
   play the same palindrome sweeps as the app's NinjaSprite. */

.sprite {
  aspect-ratio: 1 / 1;
  background-repeat: no-repeat;
  background-size: 1300% 100%;
  background-position: 0% 0%;
}

.cta-sprite {
  width: clamp(150px, 18vw, 230px);
  padding: 1.25rem;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--sage-soft) 78%, transparent 80%);
  position: relative;
}

.cta-sprite .sprite {
  width: 100%;
}

/* Celebration sparkle burst — flung outward like the app's reveal. */
.sparkle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 11px;
  height: 11px;
  background: var(--red);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  transform: translate(-50%, -50%) scale(0.2);
  animation: sparkle-fling 0.9s ease-out forwards;
  pointer-events: none;
}

@keyframes sparkle-fling {
  to {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(var(--scale));
    opacity: 0;
  }
}

/* ---------- Art-slot placeholders (commission briefs) ---------- */

.art-slot {
  margin: 0;
  background: var(--tint, var(--sage-soft));
  border: 1.5px dashed color-mix(in srgb, var(--ink) 22%, transparent);
  border-radius: var(--r-card);
  display: grid;
  place-content: center;
  gap: 0.5rem;
  text-align: center;
  padding: 1.25rem;
}

.art-slot .tag {
  justify-self: center;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  border: 1px solid color-mix(in srgb, var(--ink) 16%, transparent);
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
}

.art-slot .brief {
  font-size: 0.84rem;
  color: var(--ink-muted);
  max-width: 22em;
  line-height: 1.45;
}

.art-slot--step {
  width: 96px;
  height: 96px;
  flex: none;
  padding: 0.5rem;
  border-radius: 18px;
}

.art-slot--step .brief {
  font-size: 0.62rem;
  line-height: 1.35;
}

/* ---------- How it works ---------- */

.how {
  background: var(--card);
  border-radius: var(--r-big);
  margin-inline: max(0.75rem, calc((100vw - var(--container) - 4rem) / 2 - 2rem));
  box-shadow: var(--shadow-soft);
}

.how-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: clamp(2.5rem, 6vw, 5.5rem);
  align-items: center;
}

.phone {
  width: min(290px, 78%);
  margin-inline: auto;
  background: #11161c; /* app dark surface */
  border-radius: 46px;
  padding: 11px;
  box-shadow: var(--shadow);
}

.phone img {
  border-radius: 36px;
}

.steps {
  display: grid;
  gap: 2.1rem;
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
}

.step {
  display: flex;
  gap: 1.35rem;
  align-items: flex-start;
}

.step-body h3 {
  font-size: 1.45rem;
  margin-bottom: 0.45rem;
}

.step-body h3::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--red);
  display: block;
  margin-bottom: 0.4rem;
}

.step-body p {
  color: var(--ink-muted);
  font-size: 0.99rem;
}

/* ---------- Features ---------- */

.features-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1.25rem, 2.5vw, 2rem);
}

.feature-card {
  background: var(--card);
  border-radius: var(--r-card);
  padding: clamp(1.5rem, 2.6vw, 2.1rem);
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 1.35rem;
}

.feature-card .art-slot {
  aspect-ratio: 5 / 2.6;
}

.feature-card h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.feature-card p {
  color: var(--ink-muted);
  font-size: 0.99rem;
}

/* ---------- Founder letter ---------- */

.why {
  text-align: center;
}

.letter {
  max-width: 41em;
  margin-inline: auto;
}

.letter .avatar {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: var(--cream-deep);
  object-fit: cover;
  object-position: center;
  margin: 0 auto 1.75rem;
  border: 4px solid var(--card);
  box-shadow: var(--shadow-soft);
}

.letter h2 {
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  margin-bottom: 1.6rem;
}

.letter p {
  color: var(--ink-muted);
  font-size: clamp(1.02rem, 1.4vw, 1.13rem);
  line-height: 1.75;
  margin-bottom: 1.2rem;
}

.letter .sign {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--ink);
  margin-top: 1.9rem;
  margin-bottom: 0.2rem;
}

.letter .sign-sub {
  font-size: 0.85rem;
  color: var(--ink-faint);
}

/* ---------- Closing CTA band ---------- */

.cta-band {
  background: var(--cream-deep);
  border-radius: var(--r-big);
  padding: clamp(2.5rem, 5.5vw, 4.5rem);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(1.75rem, 4.5vw, 4rem);
  align-items: center;
}


.cta-band h2 {
  font-size: clamp(1.9rem, 3.6vw, 2.7rem);
  margin-bottom: 0.7rem;
}

.cta-band p {
  color: var(--ink-muted);
  margin-bottom: 1.75rem;
  max-width: 30em;
}

.cta-meta {
  display: block;
  margin-top: 0.95rem;
  font-size: 0.84rem;
  color: var(--ink-faint);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--divider);
  padding-block: 3rem 3.5rem;
  margin-top: clamp(3rem, 7vw, 5.5rem);
}

.footer-row {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.footer-links {
  display: flex;
  gap: 1.6rem;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--ink-muted);
  margin-left: auto;
}

.footer-links a {
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--red);
}

.fineprint {
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--ink-faint);
  max-width: 62em;
}

.fineprint + .fineprint {
  margin-top: 0.8rem;
}

/* ---------- Legal / support article pages ---------- */

.article {
  max-width: 44em;
  margin-inline: auto;
  padding-block: clamp(3rem, 6vw, 5rem) clamp(4rem, 7vw, 6rem);
}

.article h1 {
  font-size: clamp(2.2rem, 4.5vw, 3.1rem);
  margin-bottom: 0.9rem;
}

.article .updated {
  color: var(--ink-faint);
  font-size: 0.88rem;
  margin-bottom: 2.75rem;
}

.article h2 {
  font-size: 1.55rem;
  margin: 2.6rem 0 0.8rem;
}

.article p,
.article li {
  color: var(--ink-muted);
  margin-bottom: 0.9rem;
}

.article ul {
  padding-left: 1.2rem;
  margin: 0 0 0.9rem;
}

.article a {
  color: var(--ink);
  text-decoration-color: var(--sage);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.article a:hover {
  text-decoration-color: var(--red);
}

.callout {
  background: var(--sage-soft);
  border-radius: var(--r-card);
  padding: 1.4rem 1.6rem;
  margin: 1.75rem 0;
}

.callout p {
  color: var(--ink);
  margin: 0;
}

.callout--rose {
  background: var(--rose-soft);
}

/* ---------- Scroll reveals (gentle, reduced-motion aware) ---------- */

.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.js .reveal.in {
  opacity: 1;
  transform: none;
}

/* Reduce Motion: keep the crossfade delight, drop the travel. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .js .reveal {
    transform: none;
  }

  .chip--reading,
  .chip--feeling,
  .chip--guess {
    animation: none;
  }

  /* script.js also skips sprite sweeps and sparkle spawning. */
  .sparkle {
    display: none;
  }

  .appstore-badge:hover {
    transform: none;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 880px) {
  .hero-grid,
  .how-grid,
  .features-grid {
    grid-template-columns: 1fr;
  }

  .hero-stage {
    order: -1;
    min-height: 330px;
  }

  .how {
    margin-inline: 0.75rem;
  }

  .how-grid .phone-col {
    order: 2;
  }

  .cta-band {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .cta-sprite {
    margin-inline: auto;
  }

  .cta-band .hero-ctas {
    justify-content: center;
  }

  .footer-links {
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .site-header .nav-cta {
    display: none;
  }
}
