/* ===================================================
   S8 Cloud — Custom Styles
   Layered on top of Tailwind CSS
   =================================================== */

/* ---------- Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;600;700;900&display=swap');

:root {
  --accent: #6366f1;
  --accent-light: #818cf8;
  --cyan: #22d3ee;
  --purple: #a855f7;
  --green: #34d399;
  --rose: #fb7185;
  --amber: #fbbf24;
}

/* ---------- Base ---------- */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #050507;
  color: #f0f0f5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Hide scrollbar during preloader */
body.loading {
  overflow: hidden;
}

/* ---------- Preloader ---------- */
#preloader {
  will-change: opacity, clip-path;
}

#preloader .boot-line {
  opacity: 0;
  transform: translateX(-8px);
}

#preloader .boot-line.ok  { color: #34d399; }
#preloader .boot-line.warn { color: #fbbf24; }
#preloader .boot-line.info { color: #818cf8; }
#preloader .boot-line.sys  { color: #6b7280; }
#preloader .boot-line .hl  { color: #22d3ee; }

::selection {
  background: rgba(99,102,241,0.3);
  color: #fff;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ---------- Gradient Text ---------- */
.gradient-text {
  background: linear-gradient(135deg, var(--accent-light) 0%, var(--cyan) 50%, var(--purple) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gradient-text-warm {
  background: linear-gradient(135deg, var(--amber) 0%, var(--rose) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ---------- Glass ---------- */
.glass {
  background: rgba(5,5,7,0.8);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.glass-card {
  background: rgba(15,15,23,0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ---------- Hero Grid ---------- */
.hero-grid {
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 30%, transparent 100%);
  animation: grid-drift 20s linear infinite;
}

@keyframes grid-drift {
  0%   { background-position: 0 0; }
  100% { background-position: 60px 60px; }
}

/* ---------- Glow Orbs ---------- */
.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  will-change: transform;
}

.glow-orb-1 {
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(99,102,241,0.15), transparent 70%);
  top: -10%; left: 30%;
  animation: float-1 12s ease-in-out infinite;
}

.glow-orb-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(34,211,238,0.1), transparent 70%);
  top: 5%; right: 10%;
  animation: float-2 15s ease-in-out infinite;
}

.glow-orb-3 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(168,85,247,0.08), transparent 70%);
  bottom: 10%; left: 50%;
  animation: float-3 18s ease-in-out infinite;
}

@keyframes float-1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -20px) scale(1.05); }
  66% { transform: translate(-20px, 15px) scale(0.95); }
}

@keyframes float-2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(-25px, 20px) scale(1.03); }
  66% { transform: translate(15px, -25px) scale(0.97); }
}

@keyframes float-3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -30px) scale(1.08); }
}

/* ---------- Pulse Dot ---------- */
.pulse-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* ---------- Feature Cards ---------- */
.feature-card {
  position: relative;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.4s;
}

.feature-card:hover {
  transform: translateY(-6px);
  border-color: rgba(255,255,255,0.12);
  background: rgba(20,20,31,0.8);
}

.feature-card:hover::before { opacity: 1; }

.feature-card:hover .feature-icon-glow {
  opacity: 1;
}

.feature-icon-glow {
  position: absolute;
  width: 80px; height: 80px;
  border-radius: 50%;
  filter: blur(30px);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}

/* ---------- Architecture Flow ---------- */
.arch-line {
  position: absolute;
  top: 50%;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    var(--accent) 0%,
    var(--cyan) 33%,
    var(--purple) 66%,
    var(--green) 100%
  );
  opacity: 0.2;
  z-index: 0;
  overflow: visible;
}

/* Travelling pulse dots on architecture line */
.arch-pulse-dot {
  position: absolute;
  top: 50%;
  left: -4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan), 0 0 30px var(--cyan);
  transform: translateY(-50%);
  animation: arch-travel 4s ease-in-out infinite;
}

@keyframes arch-travel {
  0%   { left: 0%;   opacity: 0; }
  5%   { opacity: 1; }
  95%  { opacity: 1; }
  100% { left: 100%; opacity: 0; }
}

.arch-step {
  position: relative;
  z-index: 1;
}

.arch-step-num {
  transition: all 0.3s;
}

.arch-step:hover .arch-step-num {
  transform: scale(1.1);
  box-shadow: 0 0 30px rgba(99,102,241,0.3);
}

/* ---------- Code Window ---------- */
.code-window {
  position: relative;
  overflow: hidden;
}

.code-window::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: linear-gradient(transparent, rgba(15,15,23,1));
  pointer-events: none;
}

.code-body .kw  { color: var(--purple); }
.code-body .fn  { color: #60a5fa; }
.code-body .str { color: var(--green); }
.code-body .cm  { color: #55556a; font-style: italic; }
.code-body .num { color: var(--amber); }
.code-body .op  { color: #888; }

/* ---------- Typing cursor ---------- */
.typing-cursor::after {
  content: '|';
  animation: blink 1s step-end infinite;
  color: var(--accent-light);
  font-weight: 300;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ---------- CTA Glow ---------- */
.cta-glow {
  position: absolute;
  width: 600px; height: 400px;
  background: radial-gradient(circle, rgba(99,102,241,0.12), transparent 70%);
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
  bottom: -100px; left: 50%;
  transform: translateX(-50%);
}

/* ---------- Magnetic button ---------- */
.magnetic-btn {
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.magnetic-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 40px rgba(99,102,241,0.35);
}

.magnetic-btn:active {
  transform: translateY(-1px);
}

/* ---------- Lang Toggle ---------- */
.lang-toggle {
  position: relative;
  width: 56px;
  height: 28px;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  transition: all 0.3s;
  overflow: hidden;
}

.lang-toggle:hover {
  border-color: rgba(255,255,255,0.2);
}

.lang-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lang-toggle-thumb span {
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0;
}

.lang-toggle.zh .lang-toggle-thumb {
  transform: translateX(28px);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .nav-links-desktop { display: none !important; }
  .mobile-menu-btn { display: flex !important; }
}

@media (min-width: 769px) {
  .mobile-menu-btn { display: none !important; }
  .mobile-menu { display: none !important; }
}

/* ---------- Reveal animations (GSAP targets) ---------- */
/* These are set by GSAP; ensure content is visible if GSAP fails */
.reveal { opacity: 0; }
.reveal-up { opacity: 0; transform: translateY(40px); }
.reveal-left { opacity: 0; transform: translateX(-40px); }
.reveal-right { opacity: 0; transform: translateX(40px); }
.reveal-scale { opacity: 0; transform: scale(0.9); }

/* Fallback: if GSAP hasn't initialized after 3s, show everything */
@keyframes fallback-show {
  to { opacity: 1; transform: none; }
}
.reveal, .reveal-up, .reveal-left, .reveal-right, .reveal-scale {
  animation: fallback-show 0s 3s forwards;
}

/* ---------- Particle canvas ---------- */
#particles-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* ---------- Encryption Demo ---------- */
.encrypt-demo-box {
  position: relative;
  background: rgba(10,10,16,0.8);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 16px;
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.encrypt-demo-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0.5;
}

.encrypt-progress-track {
  height: 2px;
  background: rgba(255,255,255,0.04);
  border-radius: 1px;
  overflow: hidden;
}

.encrypt-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  width: 0%;
  transition: width 0.05s linear;
  border-radius: 1px;
  box-shadow: 0 0 8px var(--cyan);
}

/* Glowing border animation on hover */
.encrypt-demo-box:hover {
  border-color: rgba(34,211,238,0.15);
  box-shadow: 0 0 40px rgba(34,211,238,0.05);
}

/* ---------- Hero title decrypt flash ---------- */
.hero-title-line {
  display: inline-block;
  cursor: pointer;
  transition: transform 0.35s cubic-bezier(.19,1,.22,1),
              text-shadow 0.35s ease,
              filter 0.35s ease;
  position: relative;
}

.hero-title-line:hover {
  transform: scale(1.04) translateY(-2px);
  text-shadow: 0 0 30px rgba(99, 102, 241, 0.5),
               0 0 60px rgba(99, 102, 241, 0.2),
               0 0 100px rgba(99, 102, 241, 0.08);
}

/* Gradient line gets a different glow color */
.hero-title-line.gradient-text:hover {
  text-shadow: none;
  filter: brightness(1.25) drop-shadow(0 0 20px rgba(129, 140, 248, 0.4));
}

/* Cycling indicator — subtle underline pulse on the rotating word */
.hero-title-line.is-cycling::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 40%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-light), transparent);
  border-radius: 2px;
  animation: cycleUnderline 3s ease-in-out infinite;
}

@keyframes cycleUnderline {
  0%, 100% { opacity: 0.2; width: 30%; }
  50% { opacity: 0.6; width: 50%; }
}

/* ---------- Scanline overlay for hero (subtle) ---------- */
.scanline-overlay {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.03) 2px,
    rgba(0,0,0,0.03) 4px
  );
  pointer-events: none;
  z-index: 1;
}

/* ---------- CJK Typography ---------- */
/* When language is Chinese, adjust line-height, spacing and font weight */
html[lang="zh-CN"] body {
  font-family: 'Noto Sans SC', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: 0.02em;
}

html[lang="zh-CN"] p,
html[lang="zh-CN"] .section-desc,
html[lang="zh-CN"] .hero-sub {
  line-height: 1.9;
  word-break: keep-all;
}

html[lang="zh-CN"] h1,
html[lang="zh-CN"] h2,
html[lang="zh-CN"] h3 {
  letter-spacing: 0.04em;
  font-weight: 800;
}

/* Hero title gets extra breathing room in Chinese */
html[lang="zh-CN"] .hero-title-line {
  letter-spacing: 0.08em;
}

html[lang="zh-CN"] .feature-card p,
html[lang="zh-CN"] .arch-step p {
  line-height: 1.85;
  letter-spacing: 0.02em;
}

html[lang="zh-CN"] .text-xs {
  letter-spacing: 0.06em;
}

/* Smooth transition on all i18n elements for lang switch */
[data-i18n] {
  will-change: opacity, transform;
}
