/* ═══════════════════════════════════════════════════════════════
   CostaCraft Motion System — Premium Experience Layer
   Inspired by Apple, Stripe, Linear, Vercel, Cloudflare
   Every animation has a purpose: communicate trust & quality
═══════════════════════════════════════════════════════════════ */

/* ── 1. SCROLL-DRIVEN CINEMATIC HERO LOCK ── */
.scroll-stage {
  position: relative;
}
.scroll-pin {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── 2. IMAGE SEQUENCE SCRUBBER (Apple-style) ── */
#mc-scrub-section {
  position: relative;
  /* height set by JS based on frameCount */
}
#mc-scrub-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#mc-scrub-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
#mc-scrub-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}
/* Cinematic gradient overlays on canvas section */
#mc-scrub-sticky::before {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 35%;
  background: linear-gradient(to top, #060810 0%, transparent 100%);
  z-index: 3;
  pointer-events: none;
}
#mc-scrub-sticky::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 20%;
  background: linear-gradient(to bottom, #060810 0%, transparent 100%);
  z-index: 3;
  pointer-events: none;
}

/* Scroll storytelling text layers */
.scrub-text-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s cubic-bezier(0.16,1,0.3,1), transform 0.6s cubic-bezier(0.16,1,0.3,1);
}
.scrub-text-layer.visible {
  opacity: 1;
  transform: translateY(0);
}
.scrub-eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #6366f1;
  margin-bottom: 10px;
}
.scrub-headline {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 900;
  color: #fff;
  text-align: center;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 40px rgba(0,0,0,0.8);
  max-width: 700px;
  padding: 0 24px;
}
.scrub-sub {
  font-size: 1.05rem;
  color: rgba(255,255,255,0.65);
  margin-top: 14px;
  text-align: center;
  max-width: 500px;
  padding: 0 24px;
}

/* Scrub progress bar */
#scrub-progress {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
}
.scrub-progress-track {
  width: 120px;
  height: 2px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  overflow: hidden;
}
.scrub-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  border-radius: 2px;
  width: 0%;
  transition: width 0.05s linear;
}
.scrub-progress-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── 3. CINEMATIC SECTION REVEALS ── */
.cinematic-reveal {
  opacity: 0;
  transform: translateY(40px) scale(0.98);
  transition: opacity 0.9s cubic-bezier(0.16,1,0.3,1),
              transform 0.9s cubic-bezier(0.16,1,0.3,1);
}
.cinematic-reveal.in-view {
  opacity: 1;
  transform: none;
}

/* Staggered word reveals */
.word-reveal-wrap {
  overflow: hidden;
  display: inline-block;
}
.word-reveal {
  display: inline-block;
  transform: translateY(110%);
  opacity: 0;
  transition: transform 0.75s cubic-bezier(0.16,1,0.3,1),
              opacity 0.75s ease;
}
.word-reveal.in-view {
  transform: translateY(0);
  opacity: 1;
}

/* ── 4. PREMIUM GLOW SYSTEM ── */
.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  will-change: transform, opacity;
}
.glow-indigo { background: radial-gradient(circle, rgba(99,102,241,0.18) 0%, transparent 70%); }
.glow-purple { background: radial-gradient(circle, rgba(168,85,247,0.15) 0%, transparent 70%); }
.glow-green  { background: radial-gradient(circle, rgba(34,197,94,0.12) 0%, transparent 70%); }
.glow-cyan   { background: radial-gradient(circle, rgba(6,182,212,0.12) 0%, transparent 70%); }

/* Mouse-tracking glow */
#cursor-glow {
  position: fixed;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(99,102,241,0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 1;
  transform: translate(-50%, -50%);
  transition: opacity 0.4s ease;
  will-change: left, top;
}

/* ── 5. PREMIUM CARD INTERACTIONS ── */
.premium-card {
  position: relative;
  background: rgba(13,17,33,0.7);
  border: 1px solid rgba(55,65,81,0.4);
  border-radius: 20px;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.16,1,0.3,1),
              box-shadow 0.4s cubic-bezier(0.16,1,0.3,1),
              border-color 0.3s ease;
}
.premium-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(600px circle at var(--mouse-x,50%) var(--mouse-y,50%),
    rgba(99,102,241,0.08), transparent 40%);
  opacity: 0;
  transition: opacity 0.4s ease;
  border-radius: inherit;
  z-index: 0;
}
.premium-card:hover::before { opacity: 1; }
.premium-card:hover {
  transform: translateY(-4px) scale(1.005);
  border-color: rgba(99,102,241,0.35);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4), 0 0 0 1px rgba(99,102,241,0.15);
}
.premium-card > * { position: relative; z-index: 1; }

/* Featured card shimmer */
.plan-card.featured::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(99,102,241,0.06), transparent);
  animation: card-shimmer 3s ease-in-out infinite;
  z-index: 0;
  pointer-events: none;
}
@keyframes card-shimmer {
  0%   { left: -60%; }
  100% { left: 160%; }
}

/* ── 6. INFRASTRUCTURE NETWORK VISUALIZATION ── */
#infra-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
}
#infra-canvas {
  width: 100%;
  display: block;
}

/* Infra node labels */
.infra-node {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  transition: transform 0.3s ease;
}
.infra-node-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  border: 1px solid;
  backdrop-filter: blur(12px);
  position: relative;
}
.infra-node-icon::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 17px;
  border: 1px solid;
  opacity: 0.4;
  animation: node-pulse 2s ease-in-out infinite;
}
@keyframes node-pulse {
  0%,100% { transform: scale(1); opacity: 0.4; }
  50%      { transform: scale(1.12); opacity: 0; }
}
.infra-node-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.infra-node-status {
  font-size: 0.65rem;
  font-weight: 600;
  color: #22c55e;
  display: flex;
  align-items: center;
  gap: 4px;
}
.infra-status-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #22c55e;
  animation: status-blink 1.5s ease-in-out infinite;
}
@keyframes status-blink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.3; }
}

/* Latency badge */
.latency-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.25);
  color: #22c55e;
  animation: latency-update 2s ease-in-out infinite;
}
@keyframes latency-update {
  0%,85%,100% { opacity: 1; }
  90%          { opacity: 0.5; }
}

/* ── 7. STATS COUNTER ANIMATION ── */
.stat-counter {
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

/* ── 8. SCROLL PROGRESS BAR ── */
#scroll-progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: linear-gradient(90deg, #6366f1, #a855f7, #22c55e);
  z-index: 9999;
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.05s linear;
  pointer-events: none;
}

/* ── 9. ENHANCED LOADER ── */
#cc-loader {
  background: radial-gradient(ellipse at 40% 40%, #0d1030 0%, #060810 60%);
}
.loader-logo-wrap {
  position: relative;
  margin-bottom: 24px;
}
.loader-logo-ring {
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 1px solid rgba(99,102,241,0.2);
  animation: loader-ring-spin 3s linear infinite;
}
.loader-logo-ring::before {
  content: '';
  position: absolute;
  top: -1px; left: 30%;
  width: 20px; height: 2px;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  border-radius: 2px;
}
@keyframes loader-ring-spin { to { transform: rotate(360deg); } }
.loader-logo {
  width: 56px; height: 56px;
  animation: loader-logo-scale 0.6s cubic-bezier(0.34,1.56,0.64,1) forwards;
}
@keyframes loader-logo-scale {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── 10. GLASS MORPHISM PANELS ── */
.glass-panel {
  background: rgba(13,17,33,0.6);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.04);
}

/* ── 11. LINE ANIMATIONS FOR INFRA ── */
.animated-line {
  stroke-dasharray: 8 4;
  animation: dash-flow 1.2s linear infinite;
}
.animated-line-fast {
  stroke-dasharray: 6 3;
  animation: dash-flow 0.8s linear infinite;
}
@keyframes dash-flow { to { stroke-dashoffset: -24; } }

/* Packet dots traveling along path */
.packet-dot {
  r: 3;
  fill: #22c55e;
  filter: drop-shadow(0 0 4px rgba(34,197,94,0.8));
}

/* ── 12. TYPING EFFECT ── */
.typewriter {
  border-right: 2px solid #6366f1;
  animation: type-cursor 0.8s step-end infinite;
  white-space: nowrap;
  overflow: hidden;
}
@keyframes type-cursor { 50% { border-color: transparent; } }

/* ── 13. HOVER TILT CARDS ── */
.tilt-card {
  transform-style: preserve-3d;
  transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
  will-change: transform;
}

/* ── 14. GRADIENT TEXT ANIMATION ── */
.animated-gradient-text {
  background: linear-gradient(90deg, #818cf8 0%, #c084fc 33%, #22c55e 66%, #818cf8 100%);
  background-size: 300%;
  animation: text-gradient-flow 5s linear infinite;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
@keyframes text-gradient-flow { to { background-position: -300% 0; } }

/* ── 15. TERMINAL / CODE BLOCK ── */
.terminal-block {
  background: #0a0e1a;
  border: 1px solid rgba(99,102,241,0.15);
  border-radius: 14px;
  overflow: hidden;
}
.terminal-header {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 12px 16px;
  background: rgba(99,102,241,0.05);
  border-bottom: 1px solid rgba(99,102,241,0.08);
}
.terminal-dot {
  width: 11px; height: 11px; border-radius: 50%;
}
.terminal-dot-r { background: #ff5f57; }
.terminal-dot-y { background: #febc2e; }
.terminal-dot-g { background: #28c840; }
.terminal-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255,255,255,0.3);
  margin-left: auto;
  margin-right: auto;
  letter-spacing: 0.04em;
}
.terminal-body {
  padding: 20px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.82rem;
  line-height: 1.7;
  color: rgba(255,255,255,0.7);
}
.terminal-line { display: block; }
.terminal-prompt { color: #6366f1; }
.terminal-cmd    { color: #a5f3fc; }
.terminal-output { color: rgba(255,255,255,0.45); }
.terminal-success { color: #22c55e; }
.terminal-cursor {
  display: inline-block;
  width: 8px; height: 14px;
  background: #6366f1;
  vertical-align: middle;
  margin-left: 2px;
  animation: type-cursor 0.8s step-end infinite;
}

/* ── 16. SPEED / UPTIME METER ── */
.metric-ring-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}
.metric-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.metric-ring-bg {
  fill: none;
  stroke: rgba(99,102,241,0.1);
  stroke-width: 4;
}
.metric-ring-fill {
  fill: none;
  stroke: url(#ring-gradient);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 226; /* 2π×36 */
  stroke-dashoffset: 226;
  transition: stroke-dashoffset 1.5s cubic-bezier(0.16,1,0.3,1);
}
.metric-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
}
.metric-ring-val {
  font-size: 0.9rem;
  font-weight: 800;
  color: #fff;
  font-family: 'Plus Jakarta Sans', sans-serif;
}
.metric-ring-unit {
  font-size: 0.58rem;
  color: rgba(255,255,255,0.4);
  font-weight: 600;
}

/* ── 17. TRUST BADGES ── */
.trust-strip {
  display: flex;
  align-items: center;
  gap: 0;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent 0%, black 10%, black 90%, transparent 100%);
}
.trust-scroll {
  display: flex;
  gap: 36px;
  animation: trust-marquee 20s linear infinite;
  flex-shrink: 0;
}
@keyframes trust-marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}
.trust-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255,255,255,0.3);
  white-space: nowrap;
  flex-shrink: 0;
}
.trust-item svg { color: #6366f1; }

/* ── 18. BACKGROUND BEAM / SPOTLIGHT ── */
.bg-beam {
  position: absolute;
  pointer-events: none;
  overflow: hidden;
}
.beam-line {
  position: absolute;
  width: 1px;
  background: linear-gradient(180deg, transparent 0%, rgba(99,102,241,0.4) 50%, transparent 100%);
  animation: beam-fall linear infinite;
  opacity: 0;
}
@keyframes beam-fall {
  0%   { transform: translateY(-100%); opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(100vh); opacity: 0; }
}

/* ── 19. SECTION DIVIDER ── */
.section-beam-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(99,102,241,0.3) 30%, rgba(168,85,247,0.3) 70%, transparent 100%);
  position: relative;
}
.section-beam-divider::before {
  content: '';
  position: absolute;
  left: 50%; top: -2px;
  transform: translateX(-50%);
  width: 6px; height: 6px;
  background: #6366f1;
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(99,102,241,0.6);
}

/* ── 20. VPS / HOSTING WEB SPECIFIC ── */
.speed-bar-wrap { display: flex; flex-direction: column; gap: 10px; }
.speed-bar-item { display: flex; flex-direction: column; gap: 5px; }
.speed-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.55);
  font-weight: 500;
}
.speed-bar-track {
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
  overflow: hidden;
}
.speed-bar-fill {
  height: 100%;
  border-radius: 4px;
  width: 0%;
  transition: width 1.4s cubic-bezier(0.16,1,0.3,1);
}

/* ── 21. FLOATING TECH BADGES (Minecraft) ── */
.floating-badge {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: rgba(13,17,33,0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: 30px;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  white-space: nowrap;
  will-change: transform;
}
.floating-badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34,197,94,0.6);
  animation: status-blink 2s ease-in-out infinite;
}

/* ── 22. RESPONSIVE OVERRIDES ── */
@media (max-width: 767px) {
  .scrub-headline { font-size: clamp(1.6rem, 7vw, 2.2rem); }
  .floating-badge { display: none; }
  #infra-canvas-wrap { max-width: 100%; }
  .terminal-block { font-size: 0.75rem; }
}

/* ── 23. GPU ACCELERATION HINTS ── */
.gpu-layer {
  will-change: transform, opacity;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* ── 24. REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
  .trust-scroll { animation: none; }
  .beam-line { animation: none; }
  #cursor-glow { display: none; }
  .plan-card.featured::before { animation: none; }
  .loader-logo-ring { animation: none; }
  .animated-gradient-text { animation: none; background-position: 0 0; }
  .scrub-text-layer {
    opacity: 1 !important;
    transform: none !important;
  }
  .word-reveal { transform: none !important; opacity: 1 !important; }
  .cinematic-reveal { opacity: 1 !important; transform: none !important; }
}
