/* ============================================
   KDTL — Kingdom Data Technology Limited
   Custom Styles & Animations
   ============================================ */

/* Base */
:root {
    --gold: #c9a063;
    --gold-light: #e8c473;
    --gold-dark: #8c6b34;
    --deep: #0a0a0a;
    --night: #101014;
    --charcoal: #16161c;
    --graphite: #1f1f28;
    --electric: #00ffaa;
    --cyan: #5ce1ff;
    --line: #2a2a36;
    --muted: #888892;
}

* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--deep);
    color: #f5f5f5;
    overflow-x: hidden;
}

::selection {
    background: var(--gold);
    color: var(--deep);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--deep);
}
::-webkit-scrollbar-thumb {
    background: var(--graphite);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--gold);
}

/* ============================================
   BACKGROUND EFFECTS
   ============================================ */

/* Grid background pattern */
.bg-grid {
    background-image:
        linear-gradient(rgba(201, 160, 99, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(201, 160, 99, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
}

.grid-bg {
    background-image:
        radial-gradient(circle at 1px 1px, rgba(201,160,99,0.15) 1px, transparent 0);
    background-size: 40px 40px;
}

/* Radial gradient utility */
.bg-gradient-radial {
    background-image: radial-gradient(var(--tw-gradient-stops));
}

/* Grain overlay */
.grain-overlay::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.04;
    pointer-events: none;
    z-index: 9997;
    mix-blend-mode: overlay;
}

/* Scan line effect */
.scan-overlay {
    background: linear-gradient(
        to bottom,
        transparent,
        rgba(201, 160, 99, 0.02) 50%,
        transparent
    );
    background-size: 100% 4px;
    animation: scanLine 8s linear infinite;
}

@keyframes scanLine {
    0% { background-position: 0 0; }
    100% { background-position: 0 -100vh; }
}

/* ============================================
   LOADER
   ============================================ */
.loader-logo img {
    filter: drop-shadow(0 0 20px rgba(201,160,99,0.5));
}

.loader-bar {
    position: relative;
    overflow: hidden;
}

.loader-bar::before {
    content: '';
    position: absolute;
    top: 0;
    left: -50%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    animation: loaderSlide 1.5s ease-in-out infinite;
}

@keyframes loaderSlide {
    0% { left: -50%; }
    100% { left: 100%; }
}

/* ============================================
   NAV
   ============================================ */
#navbar {
    backdrop-filter: blur(0px);
}

#navbar.scrolled {
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(42, 42, 54, 0.5);
}

.nav-link {
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 1px;
    background: var(--gold);
    transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 60%;
}

/* Active scroll section indicator */
.nav-link.active {
    color: var(--gold);
}

/* ============================================
   HERO ANIMATIONS
   ============================================ */
.hero-fade {
    opacity: 0;
    animation: heroFadeIn 1s ease-out forwards;
}

.hero-fade:nth-child(1) { animation-delay: 0.1s; }
.hero-fade:nth-child(2) { animation-delay: 0.3s; }
.hero-fade:nth-child(3) { animation-delay: 0.5s; }
.hero-fade:nth-child(4) { animation-delay: 0.7s; }
.hero-fade:nth-child(5) { animation-delay: 0.9s; }
.hero-fade:nth-child(6) { animation-delay: 1.1s; }

@keyframes heroFadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
        filter: blur(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

/* Logo glow */
.logo-glow {
    position: relative;
    filter: drop-shadow(0 0 40px rgba(201, 160, 99, 0.4));
}

.logo-glow::before {
    content: '';
    position: absolute;
    inset: -10%;
    background: radial-gradient(circle, rgba(201,160,99,0.3) 0%, transparent 70%);
    border-radius: 50%;
    z-index: -1;
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.2); opacity: 1; }
}

/* Marquee */
.marquee-container {
    display: flex;
    width: max-content;
}

/* ============================================
   REVEAL ANIMATIONS (scroll-triggered)
   ============================================ */
.reveal {
    opacity: 0;
    transform: translateY(40px);
    transition: all 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger children */
.reveal-stagger > * {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.reveal-stagger.visible > *:nth-child(1) { transition-delay: 0.05s; opacity: 1; transform: translateY(0); }
.reveal-stagger.visible > *:nth-child(2) { transition-delay: 0.15s; opacity: 1; transform: translateY(0); }
.reveal-stagger.visible > *:nth-child(3) { transition-delay: 0.25s; opacity: 1; transform: translateY(0); }
.reveal-stagger.visible > *:nth-child(4) { transition-delay: 0.35s; opacity: 1; transform: translateY(0); }
.reveal-stagger.visible > *:nth-child(5) { transition-delay: 0.45s; opacity: 1; transform: translateY(0); }
.reveal-stagger.visible > *:nth-child(6) { transition-delay: 0.55s; opacity: 1; transform: translateY(0); }

/* ============================================
   PILLAR CARDS
   ============================================ */
.pillar-card {
    position: relative;
}

.pillar-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 1.5rem;
    padding: 1px;
    background: linear-gradient(135deg, transparent, transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    transition: all 0.5s ease;
}

.pillar-card:hover::before {
    background: linear-gradient(135deg, var(--gold), transparent 50%, var(--electric));
}

/* ============================================
   TECH CARDS
   ============================================ */
.tech-card {
    transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.tech-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.tech-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--gold), var(--electric));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.4s ease;
}

.tech-card:hover::after {
    transform: scaleX(1);
}

/* ============================================
   TX STREAM
   ============================================ */
#txStream {
    font-family: 'JetBrains Mono', monospace;
    color: var(--muted);
}

.tx-line {
    padding: 4px 0;
    border-bottom: 1px solid rgba(42, 42, 54, 0.3);
    animation: txAppear 0.4s ease-out;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tx-line .tx-hash {
    color: var(--gold);
}

.tx-line .tx-amount {
    color: var(--electric);
}

.tx-line .tx-status {
    color: var(--cyan);
}

@keyframes txAppear {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   FLOW DOT (DC4S → DC4G)
   ============================================ */
@keyframes flowDot {
    0% { left: 16%; background: var(--gold); }
    33% { left: 48%; background: var(--electric); }
    66% { left: 50%; background: var(--electric); }
    100% { left: 84%; background: var(--cyan); }
}

/* ============================================
   TIMELINE ACTIVE STATE
   ============================================ */
.timeline-item {
    position: relative;
}

.timeline-dot {
    transition: all 0.3s ease;
}

.timeline-item:hover .timeline-dot {
    transform: translate(-50%, 0) scale(1.5);
    box-shadow: 0 0 30px currentColor;
}

/* ============================================
   CURSOR
   ============================================ */
@media (hover: hover) and (pointer: fine) {
    body.has-cursor .cursor-dot,
    body.has-cursor .cursor-ring {
        display: block;
    }
}

.cursor-dot {
    transform: translate(-50%, -50%);
}

.cursor-ring {
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

a:hover ~ .cursor-ring,
button:hover ~ .cursor-ring {
    width: 50px;
    height: 50px;
    border-color: var(--electric);
}

/* ============================================
   COUNTER ANIMATIONS
   ============================================ */
.counter, .counter-large, .tx-counter {
    font-variant-numeric: tabular-nums;
}

/* ============================================
   UTILITY ANIMATIONS
   ============================================ */

/* Floating animation */
@keyframes subtleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Glow text effect */
.glow-text {
    text-shadow:
        0 0 10px rgba(201,160,99,0.6),
        0 0 20px rgba(201,160,99,0.3);
}

/* Gradient border */
.gradient-border {
    position: relative;
    background: var(--charcoal);
    border-radius: 1rem;
}

.gradient-border::before {
    content: '';
    position: absolute;
    inset: 0;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--gold), transparent, var(--electric));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

/* ============================================
   CHINESE LANGUAGE STYLING
   ============================================ */
html[data-lang="zh"] body {
    font-family: 'Manrope', 'Noto Sans TC', sans-serif;
}

html[data-lang="zh"] .font-display {
    font-family: 'Noto Sans TC', 'Syne', sans-serif;
    font-weight: 700;
}

/* When in Chinese, headings get a touch more spacing */
html[data-lang="zh"] h1,
html[data-lang="zh"] h2,
html[data-lang="zh"] h3 {
    letter-spacing: 0.02em;
}

/* Language switch active */
.lang-active {
    color: var(--gold) !important;
    font-weight: 700;
}

/* ============================================
   FORM STYLES
   ============================================ */
input, textarea {
    background: rgba(10, 10, 10, 0.6) !important;
    color: #f5f5f5 !important;
}

input:focus, textarea:focus {
    box-shadow: 0 0 0 3px rgba(201,160,99,0.15);
}

input::placeholder, textarea::placeholder {
    color: var(--muted) !important;
}

/* ============================================
   RESPONSIVE TWEAKS
   ============================================ */
@media (max-width: 768px) {
    .hero-title-responsive {
        font-size: clamp(2.5rem, 12vw, 4rem);
    }
}

@media (max-width: 640px) {
    #networkCanvas {
        opacity: 0.5;
    }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   SHIMMER EFFECT (for buttons / hovers)
   ============================================ */
.shimmer {
    position: relative;
    overflow: hidden;
}

.shimmer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    animation: shimmerSlide 3s infinite;
}

@keyframes shimmerSlide {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ============================================
   SECTION DIVIDERS
   ============================================ */
.divider-glow {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: 0.4;
}

.divider-cyan {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--cyan), transparent);
    opacity: 0.4;
}

/* ============================================
   PARALLAX UTILITIES
   ============================================ */
[data-parallax] {
    transition: transform 0.05s linear;
}

/* ============================================
   ICON BUTTON RIPPLE
   ============================================ */
button, a.btn-ripple {
    position: relative;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    transform: scale(0);
    animation: rippleEffect 0.6s linear;
    pointer-events: none;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ============================================
   LIGHT MODE
   ============================================ */

/* Smooth theme transition */
body,
.bg-kd-deep, .bg-kd-night, .bg-kd-charcoal, .bg-kd-graphite,
.text-white, .text-kd-muted, .text-kd-gold, .text-kd-electric, .text-kd-cyan,
.border-kd-line, .border-kd-gold,
#navbar, .scroll-progress {
    transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease, background 0.35s ease;
}

/* Light-mode variable overrides */
:root[data-theme="light"] {
    --gold: #8c6b34;
    --gold-light: #b88956;
    --gold-dark: #5e481f;
    --deep: #f5f0e8;
    --night: #fdfaf2;
    --charcoal: #ffffff;
    --graphite: #fbf6ea;
    --line: #e5dac3;
    --muted: #6a6256;
    --electric: #1f8a6b;
    --cyan: #2596be;
}

/* Color swap for Tailwind utilities in light mode */
:root[data-theme="light"] body {
    background: #f5f0e8;
    color: #1a1612;
}

:root[data-theme="light"] .bg-kd-deep { background-color: #f5f0e8 !important; }
:root[data-theme="light"] .bg-kd-night { background-color: #fdfaf2 !important; }
:root[data-theme="light"] .bg-kd-charcoal { background-color: #ffffff !important; }
:root[data-theme="light"] .bg-kd-graphite { background-color: #fbf6ea !important; }

:root[data-theme="light"] .text-white { color: #1a1612 !important; }
:root[data-theme="light"] .text-kd-muted { color: #6a6256 !important; }
:root[data-theme="light"] .text-kd-gold { color: #8c6b34 !important; }
:root[data-theme="light"] .text-kd-gold-light { color: #b88956 !important; }
:root[data-theme="light"] .text-kd-electric { color: #1f8a6b !important; }
:root[data-theme="light"] .text-kd-cyan { color: #2596be !important; }

:root[data-theme="light"] .border-kd-line { border-color: #e5dac3 !important; }
:root[data-theme="light"] .border-kd-gold\/30 { border-color: rgba(140, 107, 52, 0.3) !important; }
:root[data-theme="light"] .border-kd-electric\/30 { border-color: rgba(31, 138, 107, 0.3) !important; }
:root[data-theme="light"] .border-kd-cyan\/30 { border-color: rgba(37, 150, 190, 0.3) !important; }
:root[data-theme="light"] .border-kd-gold-light\/30 { border-color: rgba(184, 137, 86, 0.3) !important; }

/* Subtle shadows for cards in light mode for depth */
:root[data-theme="light"] .pillar-card,
:root[data-theme="light"] .tech-card,
:root[data-theme="light"] .box-card {
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
}

:root[data-theme="light"] .pillar-card:hover,
:root[data-theme="light"] .tech-card:hover,
:root[data-theme="light"] .box-card:hover {
    box-shadow: 0 10px 40px rgba(140, 107, 52, 0.15);
}

/* Grid background - lighter pattern for light mode */
:root[data-theme="light"] .bg-grid {
    background-image:
        linear-gradient(rgba(140, 107, 52, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(140, 107, 52, 0.08) 1px, transparent 1px);
    background-size: 50px 50px;
}

:root[data-theme="light"] .grid-bg {
    background-image: radial-gradient(circle at 1px 1px, rgba(140,107,52,0.18) 1px, transparent 0);
}

/* Particle network - more subtle in light mode */
:root[data-theme="light"] #networkCanvas { opacity: 0.5; }

/* Scrollbar light theme */
:root[data-theme="light"] ::-webkit-scrollbar-track { background: #f5f0e8; }
:root[data-theme="light"] ::-webkit-scrollbar-thumb { background: #d0c4a8; }
:root[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #8c6b34; }

/* Form inputs - light backgrounds with dark text */
:root[data-theme="light"] input,
:root[data-theme="light"] textarea {
    background: #ffffff !important;
    color: #1a1612 !important;
    border-color: #e5dac3 !important;
}
:root[data-theme="light"] input:focus,
:root[data-theme="light"] textarea:focus {
    box-shadow: 0 0 0 3px rgba(140, 107, 52, 0.18);
}

/* Tagline pill backgrounds - slightly different in light mode */
:root[data-theme="light"] .bg-kd-gold\/5 { background-color: rgba(140, 107, 52, 0.08) !important; }
:root[data-theme="light"] .bg-kd-electric\/5 { background-color: rgba(31, 138, 107, 0.06) !important; }
:root[data-theme="light"] .bg-kd-cyan\/5 { background-color: rgba(37, 150, 190, 0.06) !important; }

/* Loader background */
:root[data-theme="light"] #loader { background: #f5f0e8; }
:root[data-theme="light"] #loader .text-kd-muted { color: #8c7e64 !important; }

/* Gradient backgrounds (radial) - softer in light */
:root[data-theme="light"] [class*="from-kd-gold\/"] { opacity: 0.7; }
:root[data-theme="light"] [class*="from-kd-electric\/"] { opacity: 0.5; }

/* Improve text contrast on light cards */
:root[data-theme="light"] .tech-card,
:root[data-theme="light"] .pillar-card,
:root[data-theme="light"] .box-card {
    background: #ffffff !important;
}

/* Fix headings that use opacity on white */
:root[data-theme="light"] .text-white\/90 { color: rgba(26, 22, 18, 0.85) !important; }
:root[data-theme="light"] .text-white\/80 { color: rgba(26, 22, 18, 0.75) !important; }

/* Marquee bar */
:root[data-theme="light"] .bg-kd-night[style*="marquee"],
:root[data-theme="light"] section + div.bg-kd-night {
    background-color: #fbf6ea !important;
}

/* Tech line status indicators darken in light mode */
:root[data-theme="light"] .tx-line {
    color: #6a6256;
    border-bottom-color: rgba(140, 107, 52, 0.1);
}

/* Image-containing case cards become light with subtle backgrounds */
:root[data-theme="light"] .bg-gradient-to-br.from-orange-900\/30,
:root[data-theme="light"] .bg-gradient-to-br.from-emerald-900\/30,
:root[data-theme="light"] .bg-gradient-to-br.from-cyan-900\/30 {
    opacity: 0.6;
}

/* Theme toggle button states */
.theme-icon-sun, .theme-icon-moon {
    transition: opacity 0.3s ease, transform 0.4s ease;
}

/* Scrollbar for navbar in light mode */
:root[data-theme="light"] #navbar.scrolled {
    background: rgba(245, 240, 232, 0.9);
    border-bottom-color: rgba(140, 107, 52, 0.15);
}

/* Keep gradient text vibrant in both themes */
:root[data-theme="light"] .from-kd-gold.to-kd-gold-light,
:root[data-theme="light"] .from-kd-electric.to-kd-cyan {
    /* No opacity change - keep gradients vibrant */
}

/* Mobile menu backdrop */
:root[data-theme="light"] #mobileMenu {
    background: rgba(253, 250, 242, 0.97);
}
