/* ============================================================
   SPEECHIO — CYBER-BRUTALIST PREMIUM EFFECTS
   Glitch, Scanlines, Noise, CRT, Decorators
   ============================================================ */

/* --- SCANLINE OVERLAY --- */
.scanline-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.06) 2px,
    rgba(0, 0, 0, 0.06) 4px
  );
  mix-blend-mode: multiply;
}

/* --- CRT FLICKER ON LOAD --- */
@keyframes crtFlicker {
  0%   { opacity: 0.03; }
  5%   { opacity: 0.08; }
  10%  { opacity: 0.02; }
  15%  { opacity: 0.06; }
  20%  { opacity: 0.01; }
  100% { opacity: 0; }
}

.crt-flicker {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9996;
  background: white;
  animation: crtFlicker 1.5s ease-out forwards;
}

/* --- GLITCH TEXT EFFECT --- */
.glitch-text {
  position: relative;
  display: inline-block;
}

.glitch-text::before,
.glitch-text::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.glitch-text::before {
  color: rgba(255,255,255,0.5);
  z-index: -1;
}

.glitch-text::after {
  color: var(--lime);
  z-index: -1;
}

.glitch-text:hover::before {
  animation: glitchBefore 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  opacity: 0.8;
}

.glitch-text:hover::after {
  animation: glitchAfter 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  opacity: 0.8;
}

@keyframes glitchBefore {
  0%   { clip-path: inset(40% 0 0 0); transform: translate(-3px, -2px); }
  20%  { clip-path: inset(10% 0 70% 0); transform: translate(3px, 1px); }
  40%  { clip-path: inset(60% 0 10% 0); transform: translate(-2px, 3px); }
  60%  { clip-path: inset(20% 0 40% 0); transform: translate(2px, -1px); }
  80%  { clip-path: inset(50% 0 20% 0); transform: translate(-1px, 2px); }
  100% { clip-path: inset(0 0 0 0); transform: translate(0); opacity: 0; }
}

@keyframes glitchAfter {
  0%   { clip-path: inset(0 0 60% 0); transform: translate(3px, 2px); }
  20%  { clip-path: inset(70% 0 10% 0); transform: translate(-3px, -1px); }
  40%  { clip-path: inset(10% 0 60% 0); transform: translate(2px, -3px); }
  60%  { clip-path: inset(40% 0 20% 0); transform: translate(-2px, 1px); }
  80%  { clip-path: inset(20% 0 50% 0); transform: translate(1px, -2px); }
  100% { clip-path: inset(0 0 0 0); transform: translate(0); opacity: 0; }
}

/* Stronger glitch for hero */
.hero-title .glitch-text:hover::before {
  animation-duration: 0.6s;
}

.hero-title .glitch-text:hover::after {
  animation-duration: 0.6s;
  animation-delay: 0.05s;
}

/* --- SCROLL REVEAL ANIMATION STATES --- */
/* Hidden state only applied after JS is ready to avoid FOUC */
.js-ready .reveal-up {
  opacity: 0;
  transition: opacity 0.7s cubic-bezier(0.23, 1, 0.32, 1);
}

.reveal-up.is-visible {
  opacity: 1 !important;
}

.js-ready .reveal-left {
  opacity: 0;
  transition: opacity 0.7s cubic-bezier(0.23, 1, 0.32, 1);
}

.reveal-left.is-visible {
  opacity: 1 !important;
}

.js-ready .reveal-scale {
  opacity: 0;
  transition: opacity 0.7s cubic-bezier(0.23, 1, 0.32, 1);
}

.reveal-scale.is-visible {
  opacity: 1 !important;
}

/* Staggered children */
.js-ready .stagger-children > * {
  opacity: 0;
  transition: opacity 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.stagger-children.is-visible > * {
  opacity: 1;
}
.stagger-children.is-visible > *:nth-child(1)  { transition-delay: 0.00s; }
.stagger-children.is-visible > *:nth-child(2)  { transition-delay: 0.07s; }
.stagger-children.is-visible > *:nth-child(3)  { transition-delay: 0.14s; }
.stagger-children.is-visible > *:nth-child(4)  { transition-delay: 0.21s; }
.stagger-children.is-visible > *:nth-child(5)  { transition-delay: 0.28s; }
.stagger-children.is-visible > *:nth-child(6)  { transition-delay: 0.35s; }
.stagger-children.is-visible > *:nth-child(7)  { transition-delay: 0.42s; }
.stagger-children.is-visible > *:nth-child(8)  { transition-delay: 0.49s; }
.stagger-children.is-visible > *:nth-child(9)  { transition-delay: 0.56s; }
.stagger-children.is-visible > *:nth-child(10) { transition-delay: 0.63s; }
.stagger-children.is-visible > *:nth-child(11) { transition-delay: 0.70s; }
.stagger-children.is-visible > *:nth-child(12) { transition-delay: 0.77s; }

/* --- GLASS ACCENT BAND --- */
.glass-band {
  display: inline-block;
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 6px 16px;
  font-family: var(--font-mono);
  font-size: clamp(11px, 1.2vw, 16px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.glass-band-full {
  display: block;
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border-top: 1px solid var(--glass-border);
  border-bottom: 1px solid var(--glass-border);
  color: var(--text);
  padding: 12px var(--gutter);
  font-family: var(--font-mono);
  font-size: clamp(13px, 1.5vw, 20px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

/* --- WIREFRAME SEPARATOR --- */
.wire-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  color: var(--border-strong);
}

.wire-separator::before,
.wire-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.wire-separator span {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}

/* --- CODE DECORATOR --- */
.code-deco {
  font-family: var(--font-mono);
  font-size: 0.7em;
  color: var(--text-muted);
  opacity: 0.6;
}

/* --- TEXT SCRAMBLE CURSOR --- */
.scramble-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: rgba(255,255,255,0.7);
  margin-left: 2px;
  animation: blink 0.6s step-start infinite;
  vertical-align: middle;
}

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

/* --- HOVER GLOW LINE --- */
.glow-line {
  position: relative;
  overflow: hidden;
}

.glow-line::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: -100%;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
  transition: left 0.5s ease;
}

.glow-line:hover::after {
  left: 100%;
}

/* --- GRID PRODUCT GLITCH HOVER --- */
.grid-product:hover .grid-product-name {
  animation: productGlitch 0.3s step-end;
}

@keyframes productGlitch {
  0%   { text-shadow: -2px 0 rgba(255,255,255,0.4), 2px 0 rgba(255,255,255,0.15); }
  25%  { text-shadow: 2px 0 rgba(255,255,255,0.3), -2px 0 rgba(255,255,255,0.2); }
  50%  { text-shadow: -1px 0 rgba(255,255,255,0.2), 1px 0 rgba(255,255,255,0.35); }
  75%  { text-shadow: 1px 0 rgba(255,255,255,0.25), -1px 0 rgba(255,255,255,0.3); }
  100% { text-shadow: none; }
}

/* --- SECTION NUMBER COUNTER --- */
.section-counter {
  position: absolute;
  top: var(--gutter);
  right: var(--gutter);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  opacity: 0.5;
}

/* --- DASHED CONNECTOR LINES (for steps) --- */
.step-connector {
  width: 1px;
  height: 24px;
  border-left: 1px dashed var(--border-strong);
  margin: 0 auto;
}

/* --- NOISE STATIC EFFECT --- */
@keyframes noiseShift {
  0%   { background-position: 0 0; }
  25%  { background-position: 50% 50%; }
  50%  { background-position: 100% 0; }
  75%  { background-position: 0 100%; }
  100% { background-position: 50% 25%; }
}

.noise-bg {
  position: relative;
}

.noise-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
  animation: noiseShift 4s steps(5) infinite;
}

/* --- SECTION BAND INDICATOR (Left border) --- */
.band-indicator {
  position: relative;
}

.band-indicator::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,0.4), rgba(255,255,255,0.05));
}

/* --- MARQUEE GLASS ACCENT --- */
.marquee-section .glass-band-full {
  margin: 0;
  font-size: clamp(10px, 1vw, 14px);
  padding: 8px var(--gutter);
  letter-spacing: 0.15em;
}

/* --- PAGE LOAD ANIMATION SEQUENCE --- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-section .hero-meta {
  animation: fadeInUp 0.8s ease-out 0.3s both;
}

.hero-section .hero-title .line:nth-child(1) {
  animation: fadeInUp 0.8s ease-out 0.5s both;
}

.hero-section .hero-title .line:nth-child(2) {
  animation: fadeInUp 0.8s ease-out 0.65s both;
}

.hero-section .hero-title .line:nth-child(3) {
  animation: fadeInUp 0.8s ease-out 0.8s both;
}

.hero-section .hero-glass-band {
  animation: fadeInUp 0.6s ease-out 0.95s both;
}

.hero-section .hero-subtitle {
  animation: fadeInUp 0.6s ease-out 1.1s both;
}

.hero-section .hero-cta {
  animation: fadeInUp 0.6s ease-out 1.25s both;
}

/* --- CUSTOM SCROLLBAR --- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg);
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.4);
}

/* Firefox */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) var(--bg);
}

/* --- MISC PREMIUM POLISH --- */

/* Horizontal rule with brackets */
.bracket-hr {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--border-strong);
  letter-spacing: 0.2em;
  padding: 24px 0;
}

.bracket-hr::before {
  content: '{';
}

.bracket-hr::after {
  content: '}';
}

.bracket-hr span {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Typing dots animation */
@keyframes typingDots {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

.typing-dots span {
  animation: typingDots 1.4s infinite;
  font-family: var(--font-mono);
  font-size: 20px;
  color: rgba(255,255,255,0.7);
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@media (prefers-reduced-motion: reduce) {
  .crt-flicker,
  .scanline-overlay {
    display: none;
  }

  .glitch-text::before,
  .glitch-text::after {
    display: none;
  }

  .js-ready .stagger-children > * {
    transition: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .js-ready .reveal-up,
  .js-ready .reveal-left,
  .js-ready .reveal-scale {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}
