/*
 * Race Telemetry Studio — sci-fi presentation layer (pairs with js/scifi.js).
 * Everything is scoped under html.sf so removing the two includes restores
 * the plain theme.
 */

@property --sf-ang {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

html.sf {
  --sf-cyan: #3ecfff;
  --sf-red: #ff2d4a;
  --sf-line: rgba(62, 207, 255, 0.22);
  --sf-hud: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

/* ── WebGL backdrop ─────────────────────────────────────────── */

.sf-canvas {
  position: fixed;
  inset: 0;
  z-index: -2;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  image-rendering: auto;
}

html.sf-gl body {
  background: transparent;
}

html.sf-gl {
  background: #04060b;
}

/* The shader replaces the CSS grid; keep a faint brand glow on top. */
html.sf-gl .grid-overlay {
  display: none;
}

html.sf-gl .bg-glow {
  opacity: 0.55;
}

/* Keep long reading areas calm above the moving floor. */
html.sf-gl main::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse 62% 70% at 50% 42%, rgba(4, 6, 11, 0.55), transparent 75%);
}

/* ── HUD typography ─────────────────────────────────────────── */

html.sf main {
  counter-reset: sf-sec;
}

html.sf .section-label {
  font-family: var(--sf-hud);
  font-size: 0.74rem;
  letter-spacing: 0.18em;
  color: #7fdcff;
  text-shadow: 0 0 12px rgba(62, 207, 255, 0.55);
}

html.sf main section .section-label::before {
  counter-increment: sf-sec;
  content: counter(sf-sec, decimal-leading-zero) " // ";
  color: rgba(255, 122, 140, 0.95);
}

html.sf .section-label::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 0.45em;
  vertical-align: -0.15em;
  background: currentColor;
  animation: sf-blink 1.1s steps(1) infinite;
}

html.sf .section-head h2,
html.sf .pricing-details h2,
html.sf .download-card h2 {
  background: linear-gradient(180deg, #ffffff 35%, #a9c6e8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(62, 207, 255, 0.18));
}

html.sf .hero h1 > span:first-child {
  text-shadow: 0 0 30px rgba(120, 190, 255, 0.25);
}

html.sf .hero h1 .grad {
  background-size: 220% 100%;
  animation: sf-shimmer 7s ease-in-out infinite;
  filter: drop-shadow(0 0 22px rgba(255, 45, 74, 0.45));
}

html.sf .eyebrow {
  font-family: var(--sf-hud);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  border-color: var(--sf-line);
  background: rgba(62, 207, 255, 0.06);
}

html.sf .hero-meta {
  font-family: var(--sf-hud);
  font-size: 0.78rem;
}

/* ── Nav: HUD bar with a scanning edge ──────────────────────── */

html.sf .nav {
  background: rgba(4, 7, 13, 0.62);
  border-bottom-color: rgba(62, 207, 255, 0.12);
}

html.sf .nav::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--sf-cyan), var(--sf-red), transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: sf-scan-x 6s linear infinite;
  opacity: 0.8;
}

/* ── Buttons ────────────────────────────────────────────────── */

html.sf .btn-primary {
  position: relative;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255, 140, 160, 0.35) inset,
    0 10px 34px rgba(255, 45, 74, 0.45),
    0 0 22px rgba(255, 45, 74, 0.35);
}

html.sf .btn-primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.45) 48%, transparent 62%);
  transform: translateX(-120%);
  animation: sf-sheen 4.5s ease-in-out infinite;
  pointer-events: none;
}

html.sf .btn-secondary {
  border-color: rgba(62, 207, 255, 0.22);
  background: rgba(62, 207, 255, 0.05);
}

html.sf .btn-secondary:hover {
  border-color: rgba(62, 207, 255, 0.55);
  background: rgba(62, 207, 255, 0.1);
  box-shadow: 0 0 22px rgba(62, 207, 255, 0.2);
}

/* ── Hero: holographic rings, scan beam, telemetry strip ───── */

html.sf .hero-visual::before,
html.sf .hero-visual::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

html.sf .hero-visual::before {
  width: min(560px, 95%);
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotateX(68deg);
  background: repeating-conic-gradient(from 0deg, rgba(62, 207, 255, 0.55) 0 2deg, transparent 2deg 9deg);
  -webkit-mask: radial-gradient(circle, transparent 64%, #000 65% 67%, transparent 68%);
  mask: radial-gradient(circle, transparent 64%, #000 65% 67%, transparent 68%);
  animation: sf-spin-tilted 40s linear infinite;
  opacity: 0.7;
}

html.sf .hero-visual::after {
  width: min(640px, 108%);
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotateX(68deg);
  border: 1px solid rgba(255, 45, 74, 0.35);
  box-shadow: 0 0 30px rgba(255, 45, 74, 0.25), inset 0 0 30px rgba(62, 207, 255, 0.15);
  top: 62%;
}

html.sf .layer-1::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(62, 207, 255, 0.0) 40%, rgba(62, 207, 255, 0.28) 50%, rgba(62, 207, 255, 0) 60%, transparent 100%);
  background-size: 100% 260%;
  mix-blend-mode: screen;
  animation: sf-scan-y 4.2s ease-in-out infinite;
  pointer-events: none;
}

html.sf .layer {
  border-color: rgba(62, 207, 255, 0.28);
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.55),
    0 0 26px rgba(62, 207, 255, 0.12),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

html.sf .callout-pill {
  font-family: var(--sf-hud);
  letter-spacing: 0.02em;
}

.sf-hud-strip {
  grid-column: 1 / -1;
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1.4rem;
  margin-top: 1.5rem;
  padding: 0.8rem 1.1rem;
  border: 1px solid var(--sf-line);
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(62, 207, 255, 0.07), rgba(4, 8, 14, 0.55) 40%, rgba(255, 45, 74, 0.06));
  backdrop-filter: blur(6px);
  font-family: var(--sf-hud);
  font-size: 0.78rem;
  color: var(--text-muted);
  box-shadow: 0 0 40px rgba(62, 207, 255, 0.08) inset;
}

.sf-hud-strip::before,
.sf-hud-strip::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--sf-cyan);
  pointer-events: none;
}

.sf-hud-strip::before {
  top: -2px;
  left: -2px;
  border-right: 0;
  border-bottom: 0;
}

.sf-hud-strip::after {
  right: -2px;
  bottom: -2px;
  border-left: 0;
  border-top: 0;
  border-color: var(--sf-red);
}

.sf-hud-live {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: #ff8395;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.sf-hud-live i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sf-red);
  box-shadow: 0 0 10px var(--sf-red);
  animation: sf-blink 1.2s steps(1) infinite;
}

.sf-hud-field {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
}

.sf-hud-field b {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
}

.sf-hud-field em {
  min-width: 3.6ch;
  color: #e8f6ff;
  font-style: normal;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
  text-shadow: 0 0 10px rgba(62, 207, 255, 0.45);
}

.sf-hud-field em.is-gain {
  color: #6ee7b7;
  text-shadow: 0 0 10px rgba(52, 211, 153, 0.5);
}

.sf-hud-field small {
  color: var(--text-dim);
  font-size: 0.66rem;
}

.sf-hud-spark {
  flex: 1 1 120px;
  min-width: 90px;
  max-width: 220px;
  height: 26px;
  margin-left: auto;
}

.sf-hud-spark polyline {
  fill: none;
  stroke: var(--sf-cyan);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 4px rgba(62, 207, 255, 0.8));
}

/* ── Cards: glass, HUD corner brackets, holo border, 3D tilt ── */

html.sf .feature-card,
html.sf .toolkit-group,
html.sf .price-card,
html.sf .pricing-detail-grid article,
html.sf .download-card,
html.sf .pill {
  position: relative;
  background-color: rgba(7, 10, 18, 0.72);
  border-color: rgba(62, 207, 255, 0.14);
}

/* Glare + corner brackets share one overlay. */
html.sf .feature-card::after,
html.sf .toolkit-group::after,
html.sf .price-card::after,
html.sf .pricing-detail-grid article::after,
html.sf .download-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 3;
  background:
    radial-gradient(circle at var(--sf-mx, 50%) var(--sf-my, 0%), rgba(160, 225, 255, calc(var(--sf-glare, 0) * 0.13)), transparent 45%),
    linear-gradient(var(--sf-cyan), var(--sf-cyan)) top 8px left 8px / 12px 1.5px no-repeat,
    linear-gradient(var(--sf-cyan), var(--sf-cyan)) top 8px left 8px / 1.5px 12px no-repeat,
    linear-gradient(var(--sf-cyan), var(--sf-cyan)) top 8px right 8px / 12px 1.5px no-repeat,
    linear-gradient(var(--sf-cyan), var(--sf-cyan)) top 8px right 8px / 1.5px 12px no-repeat,
    linear-gradient(var(--sf-red), var(--sf-red)) bottom 8px left 8px / 12px 1.5px no-repeat,
    linear-gradient(var(--sf-red), var(--sf-red)) bottom 8px left 8px / 1.5px 12px no-repeat,
    linear-gradient(var(--sf-red), var(--sf-red)) bottom 8px right 8px / 12px 1.5px no-repeat,
    linear-gradient(var(--sf-red), var(--sf-red)) bottom 8px right 8px / 1.5px 12px no-repeat;
  opacity: 0.75;
  transition: opacity 0.3s;
}

/* Rotating holographic rim (replaces the plain top glow line). */
html.sf .feature-card::before,
html.sf .toolkit-group::before {
  inset: 0;
  height: auto;
  padding: 1px;
  pointer-events: none;
  border-radius: inherit;
  background: conic-gradient(from var(--sf-ang), transparent 0 55%, var(--sf-cyan) 70%, var(--sf-red) 82%, transparent 95%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0;
  transition: opacity 0.35s;
}

html.sf .feature-card:hover::before,
html.sf .toolkit-group:hover::before {
  opacity: 1;
  animation: sf-rim 3.2s linear infinite;
}

html.sf .feature-card:hover,
html.sf .toolkit-group:hover,
html.sf .price-card:hover {
  border-color: rgba(62, 207, 255, 0.35);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), 0 0 34px rgba(62, 207, 255, 0.12);
}

html.sf .feature-icon,
html.sf .toolkit-group-icon {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06) inset, 0 0 22px currentColor;
}

html.sf .feature-card:hover .feature-icon,
html.sf .toolkit-group:hover .toolkit-group-icon {
  transform: translateZ(30px);
}

html.sf .pill strong {
  text-shadow: 0 0 12px rgba(255, 45, 74, 0.55);
}

/* Pointer tilt (js adds .sf-tilt on hover-capable, motion-ok devices). */
html.sf.sf-tilt :is(.feature-card, .toolkit-group, .price-card, .pricing-detail-grid article, .pill, .download-card) {
  transform-style: preserve-3d;
  transform: perspective(1000px) rotateX(var(--sf-rx, 0deg)) rotateY(var(--sf-ry, 0deg)) translateZ(0);
  transition:
    transform 0.6s var(--ease),
    opacity 0.8s var(--ease),
    translate 0.9s var(--ease),
    rotate 0.9s var(--ease),
    border-color 0.3s,
    box-shadow 0.3s;
}

html.sf.sf-tilt :is(.feature-card, .toolkit-group, .price-card, .pricing-detail-grid article, .pill, .download-card).sf-tilting {
  transform: perspective(1000px) rotateX(var(--sf-rx, 0deg)) rotateY(var(--sf-ry, 0deg)) translateZ(14px);
  transition:
    transform 0.12s ease-out,
    opacity 0.8s var(--ease),
    translate 0.9s var(--ease),
    rotate 0.9s var(--ease),
    border-color 0.3s,
    box-shadow 0.3s;
}

html.sf .feature-icon,
html.sf .toolkit-group-icon {
  transition: transform 0.4s var(--ease);
}

/* ── 3D scroll reveal: panels swing up out of the floor ──────── */

html.sf .reveal {
  transform: none;
  translate: 0 46px;
  rotate: x 16deg;
  transform-origin: 50% 100%;
  transition:
    opacity 0.8s var(--ease),
    translate 0.9s var(--ease),
    rotate 0.9s var(--ease);
}

html.sf .reveal.visible {
  translate: none;
  rotate: none;
}

html.sf :is(.features-grid, .toolkit-groups, .format-pills, .pricing-grid, .pricing-detail-grid, .container) {
  perspective: 1400px;
}

html.sf .features-grid > .reveal:nth-child(4n + 2),
html.sf .toolkit-groups > .reveal:nth-child(2n) {
  transition-delay: 0.08s;
}

html.sf .features-grid > .reveal:nth-child(4n + 3) {
  transition-delay: 0.16s;
}

html.sf .features-grid > .reveal:nth-child(4n + 4) {
  transition-delay: 0.24s;
}

/* ── Panels: gallery, 3D demo, plans table, download ─────────── */

html.sf .gallery-main {
  border-color: rgba(62, 207, 255, 0.3);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6), 0 0 60px rgba(62, 207, 255, 0.1);
}

html.sf .gallery-main::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 3px),
    linear-gradient(var(--sf-cyan), var(--sf-cyan)) top 14px left 14px / 22px 2px no-repeat,
    linear-gradient(var(--sf-cyan), var(--sf-cyan)) top 14px left 14px / 2px 22px no-repeat,
    linear-gradient(var(--sf-red), var(--sf-red)) bottom 14px right 14px / 22px 2px no-repeat,
    linear-gradient(var(--sf-red), var(--sf-red)) bottom 14px right 14px / 2px 22px no-repeat;
}

html.sf .gallery-thumbs button.active {
  box-shadow: 0 0 18px rgba(255, 45, 74, 0.45);
}

html.sf .track3d-demo-card {
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6), 0 0 70px rgba(62, 207, 255, 0.12);
}

html.sf .plans-table-wrap {
  background: linear-gradient(160deg, rgba(14, 22, 36, 0.78), rgba(6, 9, 16, 0.86));
  backdrop-filter: blur(10px);
  border-color: rgba(62, 207, 255, 0.2);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.5), 0 0 50px rgba(62, 207, 255, 0.07);
}

html.sf .plans-group-row th {
  font-family: var(--sf-hud);
  color: #7fdcff;
}

html.sf .plans-yes {
  box-shadow: 0 0 12px currentColor;
}

html.sf .price-value strong {
  text-shadow: 0 0 30px rgba(255, 255, 255, 0.25);
}

html.sf .price-code,
html.sf .tier-badge {
  font-family: var(--sf-hud);
}

html.sf .download-card {
  background:
    radial-gradient(ellipse 80% 80% at 100% 0%, rgba(255, 45, 74, 0.2), transparent 50%),
    radial-gradient(ellipse 60% 70% at 0% 100%, rgba(62, 207, 255, 0.12), transparent 55%),
    linear-gradient(145deg, rgba(16, 22, 36, 0.82), rgba(6, 9, 16, 0.9));
}

html.sf .footer {
  position: relative;
  background: rgba(3, 5, 9, 0.72);
  backdrop-filter: blur(8px);
}

html.sf .footer::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(62, 207, 255, 0.6), rgba(255, 45, 74, 0.6), transparent);
}

/* ── Section progress rail (wide screens) ───────────────────── */

.sf-rail {
  position: fixed;
  top: 50%;
  right: 22px;
  z-index: 50;
  display: none;
  flex-direction: column;
  gap: 1.15rem;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.4s;
}

.sf-rail.is-visible {
  opacity: 1;
}

.sf-rail-track {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 5px;
  width: 1px;
  background: rgba(62, 207, 255, 0.18);
}

.sf-rail-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--sf-cyan), var(--sf-red));
  transform-origin: top;
  transform: scaleY(0);
  box-shadow: 0 0 8px var(--sf-cyan);
}

.sf-rail-dot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  padding-right: 20px;
  font: 600 0.68rem/1 var(--sf-hud, monospace);
  letter-spacing: 0.12em;
  color: var(--text-dim);
}

.sf-rail-dot::after {
  content: "";
  position: absolute;
  right: 1px;
  width: 9px;
  height: 9px;
  border: 1px solid rgba(62, 207, 255, 0.5);
  background: #04060b;
  transform: rotate(45deg);
  transition: background 0.25s, box-shadow 0.25s;
}

.sf-rail-label {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transition: max-width 0.35s var(--ease), opacity 0.25s;
}

.sf-rail-dot:hover .sf-rail-label,
.sf-rail-dot.is-active .sf-rail-label {
  max-width: 12rem;
  opacity: 1;
}

.sf-rail-dot.is-active {
  color: #bfeeff;
  text-shadow: 0 0 10px rgba(62, 207, 255, 0.6);
}

.sf-rail-dot.is-active::after {
  background: var(--sf-cyan);
  box-shadow: 0 0 12px var(--sf-cyan);
}

@media (min-width: 1600px) {
  .sf-rail {
    display: flex;
  }
}

/* ── Keyframes ──────────────────────────────────────────────── */

@keyframes sf-blink {
  50% { opacity: 0; }
}

@keyframes sf-shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes sf-scan-x {
  from { background-position: -40% 0; }
  to { background-position: 140% 0; }
}

@keyframes sf-scan-y {
  0% { background-position: 0 100%; }
  100% { background-position: 0 0%; }
}

@keyframes sf-sheen {
  0%, 60% { transform: translateX(-120%); }
  85%, 100% { transform: translateX(120%); }
}

@keyframes sf-spin-tilted {
  to { transform: translate(-50%, -50%) rotateX(68deg) rotateZ(360deg); }
}

@keyframes sf-rim {
  to { --sf-ang: 360deg; }
}

/* ── Small screens / reduced motion ─────────────────────────── */

@media (max-width: 760px) {
  .sf-hud-strip {
    gap: 0.35rem 0.9rem;
    margin-top: 2rem;
    font-size: 0.72rem;
  }

  .sf-hud-spark {
    display: none;
  }

  html.sf .hero-visual::after {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.sf .reveal {
    opacity: 1;
    translate: none;
    rotate: none;
    transition: none;
  }

  html.sf .section-label::after,
  html.sf .nav::after,
  html.sf .btn-primary::after,
  html.sf .hero h1 .grad,
  html.sf .hero-visual::before,
  html.sf .layer-1::after,
  .sf-hud-live i {
    animation: none;
  }

  html.sf .btn-primary::after,
  html.sf .layer-1::after {
    display: none;
  }
}

/* Links inside cards sit above the rim / glare overlays. */
html.sf .feature-demo {
  position: relative;
  z-index: 4;
}
