/* ============================================
   TikTok Video Transcriber - Liquid Glass Design System
   iOS-inspired translucent glass aesthetic with TikTok DNA
   ============================================ */

/* ─────────────── LIGHT MODE ─────────────── */
:root {
  /* Core palette — TikTok DNA */
  --tt-red: #fe2c55;
  --tt-red-hover: #e91e4a;
  --tt-red-soft: rgba(254, 44, 85, 0.12);
  --tt-red-glow: rgba(254, 44, 85, 0.35);
  --tt-cyan: #25f4ee;
  --tt-cyan-hover: #1ad8d3;
  --tt-cyan-soft: rgba(37, 244, 238, 0.12);
  --tt-cyan-glow: rgba(37, 244, 238, 0.35);

  /* Surfaces — light frosted glass */
  --tt-bg: #f2f2f7;
  --tt-bg-mesh-1: rgba(254, 44, 85, 0.04);
  --tt-bg-mesh-2: rgba(37, 244, 238, 0.03);
  --tt-bg-mesh-3: rgba(120, 80, 255, 0.03);
  --tt-surface: rgba(255, 255, 255, 0.6);
  --tt-surface-hover: rgba(255, 255, 255, 0.75);
  --tt-surface-solid: rgba(255, 255, 255, 0.85);
  --tt-surface-light: rgba(255, 255, 255, 0.45);
  --tt-surface-elevated: rgba(255, 255, 255, 0.72);

  /* Borders — liquid glass edges */
  --tt-border: rgba(0, 0, 0, 0.08);
  --tt-border-strong: rgba(0, 0, 0, 0.12);
  --tt-border-light: rgba(255, 255, 255, 0.5);
  --tt-border-glass: rgba(255, 255, 255, 0.35);

  /* Text — high contrast on glass */
  --tt-text: #1a1a1a;
  --tt-text-secondary: rgba(60, 60, 67, 0.78);
  --tt-text-muted: rgba(60, 60, 67, 0.44);

  /* Glass properties */
  --glass-blur: 40px;
  --glass-blur-heavy: 80px;
  --glass-blur-light: 20px;
  --glass-saturate: 1.8;
  --glass-brightness: 1.05;

  /* Glass shadows — soft multi-layered depth */
  --glass-shadow:
    0 0 0 0.5px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.04),
    0 8px 32px rgba(0, 0, 0, 0.06);
  --glass-shadow-hover:
    0 0 0 0.5px rgba(0, 0, 0, 0.08), 0 4px 16px rgba(0, 0, 0, 0.06),
    0 12px 48px rgba(0, 0, 0, 0.08);
  --glass-shadow-elevated:
    0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.08),
    0 24px 64px rgba(0, 0, 0, 0.12);

  /* Glows — TikTok brand energy */
  --glow-cyan: 0 0 24px rgba(37, 244, 238, 0.4);
  --glow-magenta: 0 0 24px rgba(254, 44, 85, 0.4);
  --glow-combined:
    0 0 20px rgba(254, 44, 85, 0.3), 0 0 40px rgba(37, 244, 238, 0.15);
  --glow-input-focus:
    0 0 0 3px rgba(37, 244, 238, 0.2), 0 0 20px rgba(37, 244, 238, 0.1);

  /* Radii — liquid roundness */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-full: 9999px;

  /* Timing — fluid motion */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-fluid: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-glass: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 450ms;
  --duration-glacial: 700ms;

  /* Safe area for notched devices */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
}

/* ─────────────── DARK MODE ─────────────── */
.dark {
  /* Core palette — vibrant on dark */
  --tt-red: #fe2c55;
  --tt-red-hover: #ff4d73;
  --tt-red-soft: rgba(254, 44, 85, 0.15);
  --tt-red-glow: rgba(254, 44, 85, 0.5);
  --tt-cyan: #25f4ee;
  --tt-cyan-hover: #5dfff9;
  --tt-cyan-soft: rgba(37, 244, 238, 0.12);
  --tt-cyan-glow: rgba(37, 244, 238, 0.5);

  /* Surfaces — dark frosted glass */
  --tt-bg: #000000;
  --tt-bg-mesh-1: rgba(254, 44, 85, 0.06);
  --tt-bg-mesh-2: rgba(37, 244, 238, 0.04);
  --tt-bg-mesh-3: rgba(120, 80, 255, 0.05);
  --tt-surface: rgba(30, 30, 30, 0.6);
  --tt-surface-hover: rgba(45, 45, 45, 0.65);
  --tt-surface-solid: rgba(30, 30, 30, 0.85);
  --tt-surface-light: rgba(255, 255, 255, 0.06);
  --tt-surface-elevated: rgba(40, 40, 40, 0.7);

  /* Borders — dark glass shimmer */
  --tt-border: rgba(255, 255, 255, 0.1);
  --tt-border-strong: rgba(255, 255, 255, 0.16);
  --tt-border-light: rgba(255, 255, 255, 0.06);
  --tt-border-glass: rgba(255, 255, 255, 0.12);

  /* Text */
  --tt-text: #ffffff;
  --tt-text-secondary: #a1a1aa;
  --tt-text-muted: #71717a;

  /* Glass properties — darker, richer */
  --glass-blur: 40px;
  --glass-blur-heavy: 80px;
  --glass-blur-light: 20px;
  --glass-saturate: 1.6;
  --glass-brightness: 1.1;

  /* Glass shadows — dark depth */
  --glass-shadow:
    0 0 0 0.5px rgba(255, 255, 255, 0.06), 0 2px 8px rgba(0, 0, 0, 0.3),
    0 8px 32px rgba(0, 0, 0, 0.4);
  --glass-shadow-hover:
    0 0 0 0.5px rgba(255, 255, 255, 0.1), 0 4px 16px rgba(0, 0, 0, 0.4),
    0 12px 48px rgba(0, 0, 0, 0.5);
  --glass-shadow-elevated:
    0 0 0 0.5px rgba(255, 255, 255, 0.08), 0 8px 24px rgba(0, 0, 0, 0.5),
    0 24px 64px rgba(0, 0, 0, 0.6);

  /* Glows — more vivid in dark */
  --glow-cyan: 0 0 32px rgba(37, 244, 238, 0.5);
  --glow-magenta: 0 0 32px rgba(254, 44, 85, 0.5);
  --glow-combined:
    0 0 24px rgba(254, 44, 85, 0.35), 0 0 48px rgba(37, 244, 238, 0.2);
  --glow-input-focus:
    0 0 0 3px rgba(37, 244, 238, 0.25), 0 0 24px rgba(37, 244, 238, 0.15);

  --orb-cyan: #25f4ee;
  --orb-red: #fe2c55;
  --orb-purple: #7850ff;
}

/* ─────────────── AMBIENT ORBS (Dark Mode Only) ─────────────── */
.ambient-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

.dark .ambient-orb-1 {
  width: 400px;
  height: 400px;
  background: var(--orb-cyan);
  top: -100px;
  left: -100px;
}

.dark .ambient-orb-2 {
  width: 300px;
  height: 300px;
  background: var(--orb-red);
  bottom: -50px;
  right: -50px;
}

.dark .ambient-orb-3 {
  width: 250px;
  height: 250px;
  background: var(--orb-purple);
  top: 50%;
  right: 20%;
}

/* ─────────────── SEAMLESS HEADER ─────────────── */
.header-seamless {
  background: transparent;
  border-bottom: none;
}

/* ─────────────── GLASS UTILITY CLASSES ─────────────── */

/* Base glass panel */
.glass {
  background: var(--tt-surface);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate))
    brightness(var(--glass-brightness));
  -webkit-backdrop-filter: blur(var(--glass-blur))
    saturate(var(--glass-saturate)) brightness(var(--glass-brightness));
  border: 0.5px solid var(--tt-border-glass);
  box-shadow: var(--glass-shadow);
}

.glass:hover {
  background: var(--tt-surface-hover);
  box-shadow: var(--glass-shadow-hover);
}

/* Elevated glass — for cards, modals */
.glass-elevated {
  background: var(--tt-surface-elevated);
  backdrop-filter: blur(var(--glass-blur-heavy)) saturate(var(--glass-saturate))
    brightness(var(--glass-brightness));
  -webkit-backdrop-filter: blur(var(--glass-blur-heavy))
    saturate(var(--glass-saturate)) brightness(var(--glass-brightness));
  border: 0.5px solid var(--tt-border-glass);
  box-shadow: var(--glass-shadow-elevated);
}

/* Subtle glass — for inner elements */
.glass-subtle {
  background: var(--tt-surface-light);
  backdrop-filter: blur(var(--glass-blur-light)) saturate(1.2);
  -webkit-backdrop-filter: blur(var(--glass-blur-light)) saturate(1.2);
  border: 0.5px solid var(--tt-border-light);
}

/* Header glass — ultra-thin frosted bar */
.glass-header {
  background: var(--tt-surface-solid);
  backdrop-filter: blur(var(--glass-blur-heavy)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur-heavy))
    saturate(var(--glass-saturate));
  border-bottom: 0.5px solid var(--tt-border);
}

/* ─────────────── SELECTION ─────────────── */
::selection {
  background: var(--tt-red);
  color: white;
}

/* ─────────────── SCROLLBAR ─────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.25);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(128, 128, 128, 0.45);
}

/* Line clamp utility */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─────────────── ANIMATIONS ─────────────── */

/* Fade in — glass emergence */
@keyframes fadeIn {
  from {
    opacity: 0;
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
  }
  to {
    opacity: 1;
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
  }
}

/* Fade in up — glass card slide */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0px);
  }
}

/* Shimmer — glass loading state */
@keyframes shimmer {
  0% {
    background-position: -200% center;
  }
  100% {
    background-position: 200% center;
  }
}

/* Pulse glow — TikTok energy */
@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: var(--glow-magenta);
  }
  50% {
    box-shadow:
      0 0 40px rgba(254, 44, 85, 0.5),
      0 0 80px rgba(254, 44, 85, 0.2);
  }
}

/* Aurora gradient float — background mesh motion */
@keyframes aurora-drift {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  25% {
    transform: translate(30px, -20px) rotate(3deg) scale(1.05);
  }
  50% {
    transform: translate(-10px, 20px) rotate(-2deg) scale(0.98);
  }
  75% {
    transform: translate(-30px, -10px) rotate(1deg) scale(1.02);
  }
}

@keyframes aurora-drift-reverse {
  0%,
  100% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  25% {
    transform: translate(-20px, 30px) rotate(-3deg) scale(1.03);
  }
  50% {
    transform: translate(20px, -10px) rotate(2deg) scale(1.06);
  }
  75% {
    transform: translate(10px, 20px) rotate(-1deg) scale(0.97);
  }
}

/* Spin with fluid easing */
@keyframes fluid-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Progress bar wave */
@keyframes progress-wave {
  0% {
    background-position: 0 50%;
  }
  100% {
    background-position: 200% 50%;
  }
}

/* Gentle float for idle elements */
@keyframes gentle-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

/* Glass border shimmer */
@keyframes border-shimmer {
  0% {
    border-color: var(--tt-border-glass);
  }
  50% {
    border-color: var(--tt-border-strong);
  }
  100% {
    border-color: var(--tt-border-glass);
  }
}

.animate-fade-in {
  animation: fadeIn 0.5s var(--ease-fluid) both;
}

.animate-fade-in-up {
  animation: fadeInUp 0.55s var(--ease-fluid) both;
}

.animate-shimmer {
  background: linear-gradient(
    90deg,
    transparent 0%,
    var(--tt-surface-light) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s var(--ease-glass) infinite;
}

.animate-gentle-float {
  animation: gentle-float 4s var(--ease-glass) infinite;
}

.animate-fluid-spin {
  animation: fluid-spin 1s linear infinite;
}

/* ─────────────── RANGE SLIDER ─────────────── */
input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--tt-surface-light);
  border-radius: var(--radius-full);
  outline: none;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--tt-text);
  border-radius: 50%;
  cursor: pointer;
  transition:
    transform var(--duration-fast) var(--ease-spring),
    box-shadow var(--duration-fast) var(--ease-glass);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

input[type='range']::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ─────────────── FOCUS ─────────────── */
*:focus-visible {
  outline: 2px solid var(--tt-cyan);
  outline-offset: 1px;
}

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

  .aurora-orb-1,
  .aurora-orb-2,
  .aurora-orb-3 {
    animation: none !important;
  }
}

/* ─────────────── TOUCH DEVICES ─────────────── */
@media (hover: none) and (pointer: coarse) {
  * {
    -webkit-tap-highlight-color: transparent;
  }
}

/* ─────────────── SCROLLBAR HIDE ─────────────── */
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* ─────────────── GLASS HELPERS ─────────────── */

/* Animated gradient border (used on focus states) */
.glass-glow-border {
  position: relative;
}

.glass-glow-border::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    135deg,
    var(--tt-cyan) 0%,
    transparent 40%,
    transparent 60%,
    var(--tt-red) 100%
  );
  -webkit-mask-image: linear-gradient(#fff 0 0), linear-gradient(#fff 0 0);
  -webkit-mask-clip: content-box, padding-box;
  -webkit-mask-composite: xor;
  mask-image: linear-gradient(#fff 0 0), linear-gradient(#fff 0 0);
  mask-clip: content-box, padding-box;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-glass);
  pointer-events: none;
}

.glass-glow-border:hover::before,
.glass-glow-border:focus-within::before {
  opacity: 1;
}

/* Inner light reflection — top edge highlight */
.glass-inner-light {
  position: relative;
}

.glass-inner-light::after {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  pointer-events: none;
}

.dark .glass-inner-light::after {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.15),
    transparent
  );
}
