/*
  Kratex landing page — cinematic scroll experience.
  Colors, spacing, radii and type scale are lifted directly from the app's
  own design tokens (src/constants/theme.ts, dark palette) so the site reads
  as the same product as the app rather than a separate marketing skin.
*/
:root {
  --bg: #080f14;
  --surface: #131a22;
  --surface-elevated: #1d252e;
  --surface-sunken: #030608;
  --border: #2b3745;
  --border-strong: #3a4859;

  --primary: #ff8200;
  --primary-muted: #4a2b0a;
  --on-primary: #17110a;

  --success: #45d39a;
  --info: #6caeff;

  --text-primary: #f3f5f7;
  --text-secondary: #a9b4c2;
  --text-tertiary: #7f8b9b;

  --sp-xs: 4px;
  --sp-sm: 8px;
  --sp-md: 12px;
  --sp-lg: 16px;
  --sp-xl: 24px;
  --sp-2xl: 32px;
  --sp-3xl: 48px;
  --sp-4xl: 72px;
  --sp-5xl: 96px;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 24px;
  --r-pill: 999px;

  --max: 1180px;
  --font:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Inter,
    Roboto, Helvetica, Arial, sans-serif;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

body.home {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body.home .wrap {
  width: min(calc(100% - 32px), var(--max));
  margin: auto;
}

body.home a {
  color: inherit;
}

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

/* ---------- Fixed cinematic frame sequence (z 0) + overlay (z 1) ---------- */
/* Everything real content lives in .cine-content at z-index 10, so it
   always paints above these regardless of DOM order or scroll position.

   The hero "video" is a <canvas> that cinematic.js draws pre-extracted
   still frames onto (see /assets/frames/) as the user scrolls — there is
   no <video> element, so object-fit/object-position don't apply here;
   the equivalent cover-fit + focal-point math is done in JS per frame.
   The .cine-noscript-fallback <img> (JS-disabled clients only) still
   needs real object-fit/object-position, since nothing draws it. */

.cine-video-frame {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  will-change: transform;
}

.cine-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  z-index: 0;
  pointer-events: none;
  display: block;
  background: var(--surface-sunken);
}

.cine-noscript-fallback {
  object-fit: cover;
  object-position: 62% center; /* keeps the athlete in frame; see mobile override below */
}

.cine-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0.55) 55%,
    rgba(0, 0, 0, 0.7) 100%
  );
  opacity: 0.55; /* JS adjusts this per scroll progress; this is the resting/no-JS value */
  transition: opacity 0.2s linear;
}

.cine-content {
  position: relative;
  z-index: 10;
}

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

.kx-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition:
    background 0.3s var(--ease),
    border-color 0.3s var(--ease),
    backdrop-filter 0.3s var(--ease);
}

.kx-header.is-scrolled {
  background: rgba(0, 0, 0, 1);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom-color: var(--border);
}

.kx-nav {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-lg);
}

.kx-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 17px;
}

.kx-nav-links {
  display: none;
  gap: var(--sp-xl);
  align-items: center;
}

.kx-nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}

.kx-nav-links a:hover,
.kx-nav-links a:focus-visible {
  color: var(--text-primary);
}

.kx-nav-cta {
  display: none;
}

.kx-menu-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: rgba(19, 26, 34, 0.7);
  color: var(--text-primary);
}

.kx-mobile-menu {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.kx-mobile-menu.is-open {
  display: block;
}

.kx-mobile-menu .wrap {
  display: flex;
  flex-direction: column;
  padding: var(--sp-lg) 0;
  gap: var(--sp-md);
}

.kx-mobile-menu a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 15px;
  font-weight: 650;
  padding: var(--sp-sm) 0;
}

.kx-logo {
  width: 40px;
  height: 40px;
}

.kx-logo-sm {
  width: 32px;
  height: 32px;
}

/* ---------- Buttons ---------- */

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  font-family: inherit;
  font-weight: 750;
  font-size: 15px;
  text-decoration: none;
  border-radius: var(--r-pill);
  padding: 14px 26px;
  transition:
    transform 0.18s var(--ease),
    background 0.18s var(--ease),
    border-color 0.18s var(--ease);
  min-height: 48px;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  transform: translateY(-1px);
  background: #ff8f1c;
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  border-color: var(--primary);
  color: var(--primary);
}

.btn[disabled],
.btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-md);
}

.btn-row.center {
  justify-content: center;
}

/* Official "Download on the App Store" badge. Apple's guidelines: keep the
   artwork unmodified and at least 40px tall, with clear space around it. */
.store-badge {
  display: inline-block;
  line-height: 0;
  border-radius: 10px;
  transition: transform 0.18s var(--ease);
}
.store-badge img {
  display: block;
  height: 52px;
  width: auto;
}
/* Header badge: Apple's 40px minimum height, to fit the 64px nav bar. */
.store-badge.kx-nav-cta img {
  height: 40px;
}
.store-badge:hover,
.store-badge:focus-visible {
  transform: translateY(-1px);
}
.store-badge.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Type ---------- */

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--primary);
  margin: 0 0 var(--sp-md);
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.section-head {
  max-width: 640px;
  margin: 0 0 var(--sp-2xl);
}

.section-head h2 {
  font-size: clamp(26px, 4.5vw, 38px);
  line-height: 1.12;
}

.section-head p {
  font-size: 16px;
  color: var(--text-secondary);
  margin: var(--sp-md) 0 0;
}

.section-head.center {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.lede.center {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Story blocks (the cinematic scroll timeline) ---------- */

.cine-story {
  position: relative;
  z-index: 10;
  /* .kx-header is now position:fixed and out of flow (see above), so the
     story needs to push its own content down by the nav's height itself. */
  padding-top: 64px;
}

.story-block {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--sp-4xl) 0;
}

.story-inner {
  width: 100%;
}

.hero-block {
  align-items: center;
  text-align: left;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-sm);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 0 0 var(--sp-lg);
}

.hero-kicker.center {
  justify-content: center;
}

.hero-copy h1 {
  font-size: clamp(34px, 7vw, 60px);
  line-height: 1.04;
  max-width: 620px;
}

.hero-copy h1 span {
  display: block;
}

.hero-copy h1 .accent {
  color: var(--primary);
}

.hero-lead {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 480px;
  margin: var(--sp-lg) 0 var(--sp-xl);
}

.hero-scroll-cue {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: var(--sp-xl);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-xs);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-scroll-cue:hover,
.hero-scroll-cue:focus-visible {
  color: var(--text-primary);
}

.hero-scroll-cue svg {
  animation: hero-bounce 1.8s ease-in-out infinite;
}

@keyframes hero-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(5px);
  }
}

.story-grid {
  display: grid;
  gap: var(--sp-2xl);
  align-items: center;
}

.story-grid.reverse .float-card {
  order: -1;
}

.story-copy h2 {
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.1;
  margin-bottom: var(--sp-md);
}

.story-copy .lede {
  color: var(--text-secondary);
  font-size: 16px;
  margin: 0 0 var(--sp-lg);
  max-width: 460px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-sm);
  list-style: none;
  margin: 0;
  padding: 0;
}

.tag-list li {
  font-size: 13px;
  font-weight: 650;
  color: var(--text-secondary);
  background: rgba(19, 26, 34, 0.7);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 6px 12px;
  backdrop-filter: blur(6px);
}

/* ---------- Floating UI cards ---------- */
/* Solid-ish (not glassy) so they stay legible over a moving video; the
   shadow + border give the "floating in the scene" depth the design wants. */

.float-card {
  border-radius: var(--r-xl);
  border: 1px solid var(--border-strong);
  background: rgba(19, 26, 34, 0.92);
  backdrop-filter: blur(10px);
  padding: var(--sp-lg);
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.65);
  max-width: 420px;
  margin: 0 auto;
}

.mock-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--sp-sm);
}

.mock-title {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: var(--sp-md);
}

.mock-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-md);
  margin-bottom: var(--sp-sm);
}

.mock-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.mock-row strong {
  color: var(--text-primary);
  font-size: 13px;
}

.mock-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 700;
  background: var(--primary-muted);
  color: var(--primary);
  padding: 3px 8px;
  border-radius: var(--r-pill);
}

.mock-bar {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-elevated);
  overflow: hidden;
  margin-top: var(--sp-xs);
}

.mock-bar span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-pill);
}

.mock-bar.success span {
  background: var(--success);
}

.mock-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-sm);
}

.mock-metric {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
}

.mock-metric small {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.route-visual {
  border-radius: var(--r-lg);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  padding: var(--sp-lg);
}

.route-visual svg {
  width: 100%;
  height: auto;
}

.route-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-md);
  margin-top: var(--sp-lg);
}

.route-stats div {
  text-align: center;
}

.route-stats strong {
  display: block;
  font-size: 20px;
  color: var(--text-primary);
}

.route-stats span {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.macro-list {
  display: grid;
  gap: var(--sp-sm);
}

.macro-row {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.macro-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.macro-row span:nth-of-type(2) {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
}

.macro-row strong {
  font-size: 13px;
  color: var(--text-primary);
}

/* ---------- Nutrition section (mirrors the approved mockup) ---------- */

.tag-list-icons li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--text-primary);
  padding: 10px 15px;
}
.tag-list-icons .tag-icon {
  flex-shrink: 0;
  color: var(--primary);
}
.tag-list-icons .icon-knockout {
  stroke: var(--bg);
}

.nutrition-card {
  padding: var(--sp-xl);
  max-width: 460px;
}
.mock-head {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  margin: 0 0 var(--sp-lg);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.mock-head-icon {
  flex-shrink: 0;
  color: var(--primary);
}
.cal-box {
  background: rgba(8, 15, 20, 0.55);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: var(--sp-lg);
  margin-bottom: var(--sp-xl);
}
.cal-box .mock-bar {
  margin-top: var(--sp-md);
}
.cal-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-md);
}
.cal-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.cal-value {
  font-size: 13px;
  color: var(--text-tertiary);
}
.cal-value strong {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-primary);
}
.nutrition-card .macro-list {
  gap: var(--sp-lg);
}
.nutrition-card .macro-row span:nth-of-type(2) {
  font-size: 15px;
  color: var(--text-primary);
}
.nutrition-card .macro-row strong {
  font-size: 15px;
}
.nutrition-card .macro-dot {
  width: 14px;
  height: 14px;
}
.nutrition-card .mock-bar {
  height: 8px;
}
/* Mockup: each macro bar starts under the label text, not under the dot
   (dot 14px + row gap 8px). */
.nutrition-card .macro-item .mock-bar {
  margin-top: var(--sp-sm);
  margin-left: 22px;
}
.mock-bar.info span {
  background: var(--info);
}

.dot-primary {
  background: var(--primary);
}

.dot-info {
  background: var(--info);
}

.dot-success {
  background: var(--success);
}

/* ---------- Goals ---------- */

.goal-grid {
  display: grid;
  gap: var(--sp-md);
  grid-template-columns: repeat(2, 1fr);
  max-width: 640px;
  margin: 0 auto;
}

.goal-card {
  background: rgba(19, 26, 34, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  text-align: center;
}

.goal-card strong {
  display: block;
  font-size: 24px;
  color: var(--primary);
  margin-bottom: 4px;
}

.goal-card span {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ---------- Final CTA ---------- */

.final-cta {
  text-align: center;
  align-items: center;
}

.final-cta h2 {
  font-size: clamp(30px, 6vw, 50px);
  margin-bottom: var(--sp-md);
}

.final-cta .lede {
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Epilogue: solid ground after the story ends ---------- */

.epilogue {
  position: relative;
  background: var(--bg);
  padding: var(--sp-4xl) 0;
}

.trust-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-2xl);
  display: grid;
  gap: var(--sp-xl);
}

.trust-title {
  font-size: 28px;
}

.download-card {
  margin-bottom: var(--sp-xl);
}

.download-actions {
  margin-top: var(--sp-xl);
}

.download-qr {
  display: none;
  margin: 0;
  text-align: center;
}
.download-qr img {
  display: block;
  width: 152px;
  height: 152px;
  border-radius: var(--r-md);
  background: #fff;
}
.download-qr figcaption {
  margin-top: var(--sp-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.trust-lede {
  color: var(--text-secondary);
  margin-top: var(--sp-md);
}

.trust-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-lg);
}

.trust-links a {
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 2px;
}

.trust-links a:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.kx-footer {
  border-top: 1px solid var(--border);
  padding-top: var(--sp-3xl);
  padding-bottom: var(--sp-2xl);
}

.footer-grid {
  display: grid;
  gap: var(--sp-2xl);
  grid-template-columns: 1fr;
  margin-bottom: var(--sp-2xl);
}

.footer-brand .kx-brand {
  margin-bottom: var(--sp-sm);
}

.footer-brand p {
  color: var(--text-tertiary);
  font-size: 13px;
  max-width: 260px;
  margin: 0;
}

.footer-col h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin: 0 0 var(--sp-md);
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-sm);
}

.footer-col a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
}

.footer-col a:hover {
  color: var(--text-primary);
}

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: var(--sp-xl);
  color: var(--text-tertiary);
  font-size: 12px;
}

/* ---------- Utilities (kept out of inline style="" for CSP style-src 'self') ---------- */

.w-72 {
  width: 72%;
}
.w-76 {
  width: 76%;
}
.w-63 {
  width: 63%;
}
.w-50 {
  width: 50%;
}

/* ---------- Scroll reveal defaults ---------- */
/* [data-cine-reveal] elements are animated via JS (continuous, scroll-linked
   opacity/transform). This is the resting state used before JS runs and
   whenever JS never touches the element (no-JS, or reduced motion) — so the
   page is fully visible and correct without any script. */

[data-cine-reveal] {
  opacity: 1;
}

.trust-card.pre-reveal {
  opacity: 0;
  transform: translateY(18px);
  transition:
    opacity 0.6s var(--ease),
    transform 0.6s var(--ease);
}

.trust-card.pre-reveal.in-view {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  /* cinematic.js only preloads and draws frame 1 under reduced motion (and
     never scrubs further), so the canvas just holds a static first frame —
     no separate poster element needed, and no bandwidth spent on the other
     89 frames these users will never see move. */
  .cine-overlay {
    opacity: 0.6;
    transition: none;
  }
  .hero-scroll-cue svg {
    animation: none;
  }
  .trust-card.pre-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .btn-primary:hover {
    transform: none;
  }
}

@media (max-width: 640px) {
  /* Canvas focal point for this width is set in cinematic.js (mirrors this
     breakpoint); this rule only covers the no-JS <img> fallback. */
  .cine-noscript-fallback {
    object-position: 74% center;
  }
}

/* ---------- Tablet ---------- */

@media (min-width: 720px) {
  .kx-nav-links {
    display: flex;
  }
  .kx-nav-cta {
    display: inline-flex;
  }
  .kx-menu-btn {
    display: none;
  }

  .goal-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* The QR code is for desktop visitors; phones just tap the badge. */
@media (min-width: 720px) and (hover: hover) and (pointer: fine) {
  .download-card {
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: var(--sp-3xl);
  }
  .download-qr {
    display: block;
  }
}

/* ---------- Desktop ---------- */

@media (min-width: 1040px) {
  .story-grid {
    grid-template-columns: 1fr 1fr;
  }
  .story-grid.story-grid-wide {
    grid-template-columns: 1.4fr 1fr;
  }

  .float-card {
    max-width: 460px;
  }

  .goal-grid {
    grid-template-columns: repeat(6, 1fr);
    max-width: none;
  }

  .footer-grid {
    grid-template-columns: 1.4fr repeat(3, 1fr);
  }
}
