/* ─── Theme variables ─────────────────────────────────── */
:root {
  --accent-rgb:      124, 58, 237;
  --c-accent:        #7c3aed;
  --c-accent-light:  #8b5cf6;
  --c-accent-dim:    #6d28d9;
  --c-accent-muted:  #a78bfa;
  --c-accent-faint:  #c4b5fd;
  --c-grad-from:     #8b5cf6;
  --c-grad-to:       #06b6d4;
}

html[data-theme="red"] {
  --accent-rgb:      220, 38, 38;
  --c-accent:        #dc2626;
  --c-accent-light:  #ef4444;
  --c-accent-dim:    #b91c1c;
  --c-accent-muted:  #fca5a5;
  --c-accent-faint:  #fecaca;
  --c-grad-from:     #ef4444;
  --c-grad-to:       #f97316;
}

/* ─── Base resets ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

::selection {
  background: rgba(var(--accent-rgb), 0.35);
  color: #fff;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0d0d0d; }
::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

/* ─── Hero animations (CSS-only, no JS dependency) ───── */
@keyframes heroFadeUp {
  from { opacity: 0; transform: translateY(28px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes cardFadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

[data-motion="hero-title"] {
  animation: heroFadeUp 0.7s cubic-bezier(.22,.68,0,1.2) 0.05s forwards;
}
[data-motion="hero-sub"] {
  animation: heroFadeUp 0.65s ease-out 0.15s forwards;
}
[data-motion="hero-ctas"] {
  animation: heroFadeUp 0.6s ease-out 0.35s forwards;
}

/* ─── Reveal on scroll ────────────────────────────────── */
@keyframes revealFallback {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  animation: revealFallback 0.6s ease 2.5s both;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
  animation: none;
}
.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }

/* ─── Card stagger ────────────────────────────────────── */
[data-motion="card"] {
  animation: cardFadeUp 0.5s ease-out calc(var(--card-delay, 0) * 1ms) both;
}

/* ─── pulseGlow override (uses CSS var) ───────────────── */
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
  50%       { box-shadow: 0 0 20px 4px rgba(var(--accent-rgb), 0.3); }
}

/* ─── Ticker ──────────────────────────────────────────── */
#ticker-track { will-change: transform; }
#ticker-track:hover { animation-play-state: paused; }

/* ─── Card hover ──────────────────────────────────────── */
.card-hover {
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.card-hover:hover {
  transform: translateY(-3px);
  border-color: rgba(var(--accent-rgb), 0.4);
  box-shadow: 0 8px 32px rgba(var(--accent-rgb), 0.12);
}

/* ─── Gradient text ───────────────────────────────────── */
.gradient-text {
  background: linear-gradient(135deg, var(--c-grad-from), var(--c-grad-to));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Accent line ─────────────────────────────────────── */
.accent-line {
  position: relative;
  padding-bottom: 0.75rem;
}
.accent-line::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 40px; height: 2px;
  background: var(--c-accent);
  border-radius: 1px;
}

/* ─── Prose (blog content) ────────────────────────────── */
.prose-dark { color: #d1d5db; }
.prose-dark h1,.prose-dark h2,.prose-dark h3 { color: #f9fafb; margin-top: 1.75em; margin-bottom: 0.75em; }
.prose-dark h2 { font-size: 1.5rem; font-weight: 600; }
.prose-dark h3 { font-size: 1.2rem; font-weight: 600; }
.prose-dark p  { line-height: 1.8; margin-bottom: 1.25em; }
.prose-dark a  { color: var(--c-accent-light); text-decoration: underline; text-decoration-color: rgba(var(--accent-rgb), 0.4); }
.prose-dark a:hover { color: var(--c-accent-muted); }
.prose-dark code { background: #1c1c1c; border: 1px solid #2a2a2a; padding: 0.15em 0.4em; border-radius: 4px; font-size: 0.875em; color: var(--c-accent-faint); font-family: 'JetBrains Mono', monospace; }
.prose-dark pre { background: #141414; border: 1px solid #2a2a2a; padding: 1.25em; border-radius: 8px; overflow-x: auto; margin: 1.5em 0; }
.prose-dark pre code { background: none; border: none; padding: 0; color: #e2e8f0; }
.prose-dark blockquote { border-left: 3px solid var(--c-accent); padding-left: 1.25em; margin: 1.5em 0; color: #9ca3af; font-style: italic; }
.prose-dark ul,.prose-dark ol { padding-left: 1.5em; margin-bottom: 1.25em; }
.prose-dark li { margin-bottom: 0.4em; line-height: 1.7; }
.prose-dark img { border-radius: 8px; width: 100%; margin: 1.5em 0; }
.prose-dark hr { border-color: #2a2a2a; margin: 2em 0; }

/* ─── Tag badge ───────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 9999px;
  font-size: 0.7rem; font-weight: 500;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--c-accent-faint);
}

/* ─── Glow button ─────────────────────────────────────── */
.btn-accent {
  background: var(--c-accent);
  color: white;
  font-weight: 500;
  transition: background 0.2s, box-shadow 0.2s, transform 0.15s;
}
.btn-accent:hover {
  background: var(--c-accent-dim);
  box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.4);
  transform: translateY(-1px);
}
.btn-accent:active { transform: translateY(0); }

/* ─── Admin sidebar ───────────────────────────────────── */
.admin-sidebar a.active {
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--c-accent-muted);
  border-left-color: var(--c-accent);
}

/* ─── Status badges ───────────────────────────────────── */
.badge-draft     { background: rgba(107,114,128,0.2); color: #9ca3af; border: 1px solid rgba(107,114,128,0.3); }
.badge-published { background: rgba(16,185,129,0.15); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.3); }

/* ─── Currency bar ────────────────────────────────────── */
.currency-item { display: flex; align-items: center; gap: 3px; }
.currency-up   { color: #10b981; }
.currency-down { color: #ef4444; }

/* ─── Hero glow ───────────────────────────────────────── */
.hero-glow {
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.12) 0%, transparent 70%);
  pointer-events: none;
  top: -100px; right: -100px;
  border-radius: 50%;
}

/* ─── Hero grid background ────────────────────────────── */
.hero-grid {
  background-image:
    linear-gradient(rgba(var(--accent-rgb), 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
}

/* ─── Input focus accent ──────────────────────────────── */
input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(var(--accent-rgb), 0.5) !important;
  outline-offset: 0;
}

/* ─── Code block header ───────────────────────────────── */
.prose-dark pre { position: relative; overflow: visible; }
.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4em 1em;
  background: #0a0a0a;
  border-bottom: 1px solid #2a2a2a;
  border-radius: 8px 8px 0 0;
  margin: -1.25em -1.25em 1.25em;
}
.code-lang {
  font-size: 0.62rem;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #4b5563;
}
.code-copy-btn {
  font-size: 0.62rem;
  font-family: 'JetBrains Mono', monospace;
  color: #6b7280;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  padding: 2px 9px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  line-height: 1.7;
}
.code-copy-btn:hover {
  color: var(--c-accent-faint);
  border-color: rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.08);
}

/* ─── Video embed ─────────────────────────────────────── */
.prose-dark .video-embed, .video-embed {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  border-radius: 10px;
  margin: 1.75em 0;
  background: #0f0f0f;
  border: 1px solid #2a2a2a;
}
.prose-dark .video-embed iframe, .video-embed iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: none;
}

/* ─── Download button ─────────────────────────────────── */
.prose-dark .download-btn, .download-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  color: var(--c-accent-faint) !important;
  text-decoration: none !important;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  margin: 1em 0;
  width: fit-content;
}
.download-btn:hover {
  background: rgba(var(--accent-rgb), 0.18) !important;
  border-color: rgba(var(--accent-rgb), 0.5) !important;
  color: var(--c-accent-muted) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(var(--accent-rgb), 0.15);
}
.download-btn svg { width: 1rem; height: 1rem; flex-shrink: 0; }

/* ─── Image gallery ───────────────────────────────────── */
.prose-dark .gallery, .gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.625rem;
  margin: 1.75em 0;
}
.prose-dark .gallery img, .gallery img {
  width: 100% !important;
  height: 180px !important;
  object-fit: cover;
  border-radius: 8px;
  margin: 0 !important;
  cursor: zoom-in;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.gallery img:hover {
  transform: scale(1.03);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}

/* ─── Lightbox ────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.93);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  cursor: zoom-out;
  backdrop-filter: blur(8px);
  animation: lb-in 0.18s ease;
}
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
.lightbox-inner { position: relative; }
.lightbox-inner img {
  display: block;
  max-width: 90vw !important;
  max-height: 90vh !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
  border-radius: 10px;
  margin: 0 !important;
  box-shadow: 0 32px 80px rgba(0,0,0,0.7);
}
.lightbox-close {
  position: absolute;
  top: -14px; right: -14px;
  width: 30px; height: 30px;
  background: #252525;
  border: 1px solid #404040;
  border-radius: 50%;
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s;
}
.lightbox-close:hover { background: #3a3a3a; }
