/* components.css: the reusable pieces. Header, buttons, stat buttons,
   screenshot cards, the moving screenshot strip and the receipt viewer. */

/* ---------- Header ---------- */
.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: var(--z-header);
  height: var(--header-h);
  display: flex;
  align-items: center;
  /* Mostly solid on purpose: a dark band keeps nav text readable over anything */
  background: linear-gradient(to bottom, rgba(7, 7, 10, 0.9), rgba(7, 7, 10, 0.6));
  border-bottom: 1px solid transparent;
  transition: background var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.site-header.is-scrolled {
  background: rgba(7, 7, 10, 0.94);
  border-bottom-color: var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
  min-width: 44px;  /* the dot alone is the home link, so give it a full-size tap area */
  min-height: 44px;
}
/* The red dot is the one brand mark: a small light source */
.wordmark::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 14px 2px var(--glow);
}

.nav-links {
  display: flex;
  gap: var(--space-6);
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links a {
  display: inline-block;
  padding: var(--space-2) 0;
  color: var(--text-muted);
  font-size: var(--fs-small);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}
.nav-links a:hover,
.nav-links a[aria-current="true"] { color: var(--text); }

.header-actions { display: flex; align-items: center; gap: var(--space-3); }

/* Thin red line under the header that fills as you scroll */
.scroll-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  transform-origin: 0 50%;
  transform: scaleX(var(--progress, 0));
  background: linear-gradient(90deg, var(--red-deep), var(--red));
  pointer-events: none;
}

/* Phone menu */
.menu-btn {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.menu-btn svg { width: 18px; height: 18px; }
.menu-btn .i-close,
.menu-btn[aria-expanded="true"] .i-open { display: none; }
.menu-btn[aria-expanded="true"] .i-close { display: block; }

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-header) - 1);
  display: grid;
  align-content: center;
  gap: var(--space-5);
  padding: var(--header-h) var(--gutter) var(--space-7);
  background: var(--bg); /* fully solid, so the page behind never ghosts through the menu */
}
.mobile-menu[hidden] { display: none; }
.mobile-menu a:not(.btn) {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 9vw, 3rem);
  letter-spacing: var(--track-tight);
  text-decoration: none;
}
.mobile-menu .btn { justify-self: start; margin-top: var(--space-4); }

@media (max-width: 899px) {
  .nav-links { display: none; }
  .menu-btn { display: inline-flex; }
}

/* ---------- Buttons ---------- */
.btn {
  --btn-h: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--btn-h);
  padding: 0 1.4rem;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    background-color var(--dur-base) var(--ease-out);
}
.btn:active { transform: scale(0.97); }
/* GSAP moves magnetic buttons every frame, so a CSS transform transition would make them lag */
.btn[data-magnetic] { transition-property: box-shadow, border-color, background-color; }
.btn-sm { --btn-h: 40px; padding: 0 1rem; font-size: var(--fs-small); }

/* Primary: brand red fill. Hover only grows the glow, so the text contrast never drops. */
.btn-primary {
  background: var(--red);
  color: var(--on-red);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 10px 30px -12px var(--glow);
}
.btn-primary:hover {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 16px 44px -10px rgba(229, 37, 33, 0.65);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line-strong);
}
.btn-ghost:hover {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.04);
}

.btn .arrow { transition: transform var(--dur-base) var(--ease-out); }
.btn:hover .arrow { transform: translateX(3px); }

/* ---------- Stat button (a number that opens its screenshot) ---------- */
.stat {
  display: grid;
  gap: 0.45rem;
  width: 100%;
  padding: var(--space-2) 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: clamp(1.625rem, 2.6vw, 2.375rem);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.stat-label {
  font-size: var(--fs-small);
  line-height: 1.4;
  color: var(--text-muted);
  max-width: 22ch;
}
.stat-proof {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--red-text);
}
.stat-proof svg { width: 12px; height: 12px; }
.stat:hover .stat-proof,
.stat:focus-visible .stat-proof { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Screenshot card ---------- */
/* One square "screen" per receipt. --focus aims the crop at the number that matters. */
.screen {
  position: relative;
  display: block;
  width: var(--screen-w, 240px);
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  overflow: hidden;
  background: #000;
  cursor: pointer;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.9), 0 0 0 6px rgba(255, 255, 255, 0.02);
  transition: transform var(--dur-slow) var(--ease-out), border-color var(--dur-base) var(--ease-out);
}
.screen img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focus, 50% 10%);
}
.screen.is-light img { filter: brightness(0.86); } /* light screenshots don't flash on a dark page */
/* A soft sheen on top so every screenshot reads as a lit screen */
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), transparent 38%);
  pointer-events: none;
}
.screen:hover { transform: translateY(-4px); border-color: rgba(255, 90, 84, 0.5); }

.screen-cap {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 1;
  padding: 0.45rem 0.65rem;
  border-radius: var(--radius-sm);
  background: rgba(7, 7, 10, 0.82);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.04em;
  color: var(--text);
  text-align: left;
}

/* ---------- Moving screenshot strip ---------- */
.strip { position: relative; z-index: var(--z-content); padding-block: var(--space-7); }
.strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}
.strip-viewport {
  overflow: hidden;
  /* fade the edges so cards drift in and out of view */
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.strip-track {
  display: flex;
  width: max-content;
  animation: strip-scroll 70s linear infinite;
}
.strip-track > li { margin-right: var(--space-4); } /* margin, not gap, so -50% lines up exactly */
.strip-viewport:hover .strip-track,
.strip-viewport:focus-within .strip-track,
.strip.is-paused .strip-track { animation-play-state: paused; }
@keyframes strip-scroll { to { transform: translateX(-50%); } }

.toggle-motion {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  background: rgba(7, 7, 10, 0.6);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
}
.toggle-motion:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.3); }

/* Reduced motion: the strip stops and can be scrolled by hand instead */
@media (prefers-reduced-motion: reduce) {
  .strip-track { animation: none; }
  .strip-viewport { overflow-x: auto; mask-image: none; }
  .strip-track [aria-hidden="true"] { display: none; }
  .toggle-motion { display: none; }
}
html.motion-off .strip-track { animation: none; }
html.motion-off .strip-viewport { overflow-x: auto; mask-image: none; }
html.motion-off .strip-track [aria-hidden="true"],
html.motion-off .toggle-motion { display: none; }

/* ---------- Receipt viewer (native dialog) ---------- */
.receipt-viewer {
  width: min(92vw, 480px);
  max-height: 92dvh;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  overflow: visible;
}
.receipt-viewer::backdrop { background: rgba(4, 4, 6, 0.88); }
.receipt-viewer[open] { animation: viewer-in var(--dur-slow) var(--ease-out); }
@keyframes viewer-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }

.rv-frame {
  display: grid;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 40px 120px -20px rgba(0, 0, 0, 0.8), 0 0 80px -30px var(--glow);
}
.rv-media {
  max-height: min(68dvh, 760px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #000;
}
.rv-media img { width: 100%; height: auto; }
.rv-body {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5) var(--space-5);
}
.rv-caption { font-size: var(--fs-small); line-height: 1.55; color: var(--text); }
.rv-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  color: var(--text-faint);
}
.rv-nav { display: flex; gap: var(--space-2); }
.rv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.rv-btn:hover { border-color: rgba(255, 90, 84, 0.6); color: var(--red-text); }
.rv-btn svg { width: 16px; height: 16px; }
.rv-close {
  position: absolute;
  top: -14px;
  right: -14px;
  background: var(--surface-2);
  z-index: 1;
}
.rv-nav[hidden] { display: none; }

/* Wider viewer for dashboards and videos */
.receipt-viewer.is-image { width: min(94vw, 1100px); }
.receipt-viewer.is-video { width: min(94vw, 980px); }
.receipt-viewer.is-video .rv-media { max-height: none; overflow: visible; }
.rv-video { position: relative; aspect-ratio: 16 / 9; background: #000; }
.rv-video iframe,
.rv-video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* While a video player loads: its thumbnail, a spinner and a note, so it never looks broken */
.rv-video { background-position: center; background-size: cover; background-repeat: no-repeat; }
.rv-video iframe { opacity: 0; transition: opacity var(--dur-slow) var(--ease-out); }
.rv-video.is-loaded iframe { opacity: 1; }
.rv-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--space-3);
  background: rgba(7, 7, 10, 0.62);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}
.rv-video.is-loaded .rv-loading { display: none; }
.rv-spinner {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: rv-spin 0.9s linear infinite;
}
@keyframes rv-spin { to { transform: rotate(360deg); } }
.rv-meta a { color: var(--red-text); text-decoration: none; white-space: nowrap; }
.rv-meta a:hover { text-decoration: underline; text-underline-offset: 3px; }
.rv-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  padding: var(--space-6);
  text-align: center;
  color: var(--text-muted);
}
.rv-fallback a { color: var(--red-text); }

/* A number inside a sentence that opens its screenshot */
.inline-receipt {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: rgba(255, 90, 84, 0.6);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}
.inline-receipt:hover { text-decoration-color: var(--red-text); }
