/* Copilot Podcast Mobile Styles */
/* MAI Copilot Design System */

/* ============================================
   Theme Variables
   ============================================ */

/* MAI Copilot Light Theme */
:root {
  --foreground-100: #faf9f7;
  --foreground-200: #f0eeeb;
  --foreground-250: #e6e4e0;
  --foreground-300: #d9d6d1;
  --foreground-450: #a8a29e;
  --foreground-550: #78716c;
  --foreground-600: #57534e;
  --foreground-700: #44403c;
  --foreground-800: #292524;
  --foreground-900: #1c1917;

  --background-100: #ffffff;
  --background-150: #faf9f7;
  --background-200: #f5f3f0;
  --background-250: #efede9;
  --background-300: #e7e4df;

  --accent-200: #fef3e2;
  --accent-250: #fde9cc;
  --accent-300: #fcd9a8;
  --accent-400: #f9b54c;
  --accent-500: #f59e0b;
  --accent-550: #d97706;
  --accent-600: #b45309;

  --muted-200: #f5f0eb;
  --muted-300: #ebe5dd;

  --stroke-300: #e5ddd3;
  --stroke-450: #c7bfb3;
}

/* Dark Theme */
.dark {
  --foreground-100: #1c1917;
  --foreground-200: #292524;
  --foreground-250: #44403c;
  --foreground-300: #57534e;
  --foreground-450: #78716c;
  --foreground-550: #a8a29e;
  --foreground-600: #d6d3d1;
  --foreground-700: #e7e5e4;
  --foreground-800: #f5f5f4;
  --foreground-900: #fafaf9;

  --background-100: #0c0a09;
  --background-150: #1c1917;
  --background-200: #292524;
  --background-250: #3a3634;
  --background-300: #44403c;

  --accent-200: #451a03;
  --accent-250: #78350f;
  --accent-300: #92400e;
  --accent-400: #b45309;
  --accent-500: #d97706;
  --accent-550: #f59e0b;
  --accent-600: #fbbf24;

  --muted-200: #292524;
  --muted-300: #3a3634;

  --stroke-300: #44403c;
  --stroke-450: #57534e;
}

/* ============================================
   Typography - MAI Copilot Style
   ============================================ */

.text-2xs { font-size: 10px; line-height: 14px; }
.text-xs { font-size: 12px; line-height: 16px; }
.text-sm { font-size: 14px; line-height: 20px; }
.text-base { font-size: 16px; line-height: 26px; }
.text-base-dense { font-size: 16px; line-height: 22px; }
.text-md { font-size: 18px; line-height: 26px; }
.text-lg { font-size: 20px; line-height: 26px; }
.text-xl { font-size: 24px; line-height: 32px; }

.text-2xs-medium, .text-xs-medium, .text-sm-medium, .text-base-medium,
.text-md-medium, .text-lg-medium, .text-xl-medium { font-weight: 500; }
.text-2xs-strong, .text-xs-strong, .text-sm-strong, .text-base-strong,
.text-md-strong, .text-lg-strong, .text-xl-strong { font-weight: 600; }

/* ============================================
   Base Styles
   ============================================ */

html, body {
  overscroll-behavior: none;
}

body.no-scroll {
  overflow: hidden;
}

body {
  font-family: 'Ginto Copilot Variable', 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  height: 100%;
}

/* Animated gradient background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: 
    radial-gradient(ellipse 80% 60% at 20% 30%, rgba(253, 233, 204, 0.3) 0%, transparent 50%),
    radial-gradient(ellipse 70% 50% at 80% 70%, rgba(252, 217, 168, 0.2) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 50% 50%, rgba(254, 243, 226, 0.1) 0%, transparent 50%),
    var(--background-150);
  background-size: 200% 200%, 200% 200%, 200% 200%, 100% 100%;
  animation: gradientFlow 20s ease-in-out infinite;
}

@keyframes gradientFlow {
  0%, 100% {
    background-position: 0% 0%, 100% 100%, 50% 50%, 0% 0%;
  }
  25% {
    background-position: 100% 0%, 0% 100%, 25% 75%, 0% 0%;
  }
  50% {
    background-position: 100% 100%, 0% 0%, 75% 25%, 0% 0%;
  }
  75% {
    background-position: 0% 100%, 100% 0%, 50% 50%, 0% 0%;
  }
}

/* Sound wave indicator animation */
.sound-wave-indicator .wave-bar {
  animation: soundWave 1s ease-in-out infinite;
}
.sound-wave-indicator .wave-bar:nth-child(1) {
  height: 40%;
  animation-delay: 0s;
}
.sound-wave-indicator .wave-bar:nth-child(2) {
  height: 80%;
  animation-delay: 0.15s;
}
.sound-wave-indicator .wave-bar:nth-child(3) {
  height: 60%;
  animation-delay: 0.3s;
}

@keyframes soundWave {
  0%, 100% {
    height: 30%;
  }
  50% {
    height: 100%;
  }
}

/* Smooth transitions */
* {
  transition-property: background-color, border-color, color, fill, stroke, opacity, box-shadow, transform;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

/* ============================================
   Utilities
   ============================================ */

/* Hide scrollbar but keep functionality */
.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Safe area for mobile */
.safe-bottom {
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.safe-top {
  padding-top: max(12px, env(safe-area-inset-top));
}

/* Line clamp utilities */
.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   Audio Player
   ============================================ */

.audio-progress {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--foreground-800) 0%, var(--foreground-800) var(--progress, 35%), var(--foreground-250) var(--progress, 35%), var(--foreground-250) 100%);
  cursor: pointer;
  width: 100%;
}
.audio-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--foreground-800);
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Player transition */
.player-content {
  transition: opacity 0.2s ease;
}

.player-content.switching {
  opacity: 0.5;
}

/* Main App Header */
#mainApp > header {
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(24px);
  background: rgba(255, 255, 255, 0.7) !important;
}

/* Fixed Bottom Control Bar */
.control-bar {
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.4s ease, transform 0.4s ease;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(24px);
  background: rgba(255, 255, 255, 0.7) !important;
}

.control-bar.visible {
  opacity: 1;
  transform: translateY(0);
}

.control-bar .audio-progress {
  height: 3px;
}

.control-bar .audio-progress::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
}

/* ============================================
   Swipe to Delete
   ============================================ */

.swipe-container {
  position: relative;
  overflow: hidden;
  border-radius: 1rem;
}

.swipe-delete-bg {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  height: 44px;
  padding: 0 16px;
  background: #ef4444;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 22px;
  opacity: 1;
  transition: opacity 0.2s ease-out;
}

.swipe-delete-bg.hiding {
  opacity: 0;
}

.swipe-delete-bg svg {
  width: 16px;
  height: 16px;
  color: white;
}

/* Not interested hint */
.swipe-hint {
  display: flex;
  align-items: center;
  gap: 6px;
  color: white;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.swipe-hint span {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.swipe-delete-bg.active .swipe-hint span {
  opacity: 1;
}

.swipe-content {
  position: relative;
  background: var(--background-100);
  transform: translateX(0) translateZ(0);
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
  z-index: 1;
  backface-visibility: hidden;
}

.swipe-content.swiping {
  transition: none;
}

.swipe-content.removing {
  transition: transform 0.2s ease-out, opacity 0.2s ease-out;
  transform: translateX(-100%) translateZ(0) !important;
  opacity: 0;
}

/* ============================================
   Feed Items
   ============================================ */

.feed-item {
  max-height: 200px;
  overflow: visible;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Loading animation for dynamically added items */
.feed-item.loading-in {
  opacity: 0;
  transform: translateY(15px) translateZ(0);
}

.feed-item.loaded {
  opacity: 1;
  transform: translateY(0) translateZ(0);
  transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}

/* Remove loading transition after animation completes */
.feed-item.loaded .swipe-content {
  transform: translateX(0) translateZ(0);
}

.feed-item.collapsed {
  transition: max-height 0.2s ease-out, margin 0.2s ease-out, padding 0.2s ease-out;
  max-height: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding: 0 !important;
  overflow: hidden;
}

/* ============================================
   Clickable Items
   ============================================ */

.feed-item .swipe-content {
  cursor: pointer;
}

.feed-item .swipe-content:hover {
  background: var(--background-150);
}

.feed-item .swipe-content:active {
  transform: scale(0.98);
}

.completed-item {
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.completed-item:hover {
  background: var(--background-150) !important;
}

.completed-item:active {
  transform: scale(0.98);
}

/* Replay indicator on completed items */
.completed-item .replay-hint {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.completed-item:hover .replay-hint {
  opacity: 1;
}

.completed-item:hover .completed-badge {
  opacity: 0;
}

/* ============================================
   Completed Episodes
   ============================================ */

.completed-section {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.4s ease, opacity 0.3s ease, margin 0.3s ease;
}

.completed-section.has-items {
  max-height: none;
  opacity: 1;
  overflow: visible;
}

/* Collapsed state - show only last 3 items */
.completed-collapsed .completed-item:nth-last-child(n+4) {
  display: none;
}

.completed-item {
  transition: opacity 0.25s ease;
}

#toggleCompletedBtn {
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

#toggleCompletedBtn:hover {
  background-color: var(--muted-200);
}

.completed-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--muted-200);
  color: var(--foreground-550);
}

/* New item animation - fade in only */
.completed-item.new-item {
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ============================================
   Welcome Page
   ============================================ */

.welcome-page {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: transparent;
  display: flex;
  flex-direction: column;
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

.welcome-page.fading {
  opacity: 0;
}

.welcome-page.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.main-app {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-app.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered animation for feed items */
.main-app.visible .feed-item {
  animation: slideInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  opacity: 0;
}

.main-app.visible .feed-item:nth-child(1) { animation-delay: 0.1s; }
.main-app.visible .feed-item:nth-child(2) { animation-delay: 0.2s; }
.main-app.visible .feed-item:nth-child(3) { animation-delay: 0.3s; }
.main-app.visible .feed-item:nth-child(4) { animation-delay: 0.4s; }
.main-app.visible .feed-item:nth-child(5) { animation-delay: 0.5s; }

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Topic tags animation */
.topic-tag {
  animation: fadeInUp 0.5s ease forwards;
  opacity: 0;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Copilot Branding
   ============================================ */

.copilot-gradient {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.copilot-icon-gradient {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
}

/* ============================================
   Article Detail Page
   ============================================ */

.article-page {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: var(--background-100);
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.article-page.visible {
  transform: translateX(0);
}

.article-container {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.article-header {
  border-bottom: 1px solid var(--foreground-200);
}

.article-body {
  font-size: 16px;
  line-height: 1.75;
  color: var(--foreground-700);
}

.article-body p {
  margin-bottom: 1.25rem;
}

.article-body p:first-child::first-letter {
  font-size: 3.5rem;
  font-weight: 600;
  float: left;
  line-height: 1;
  margin-right: 0.5rem;
  margin-top: 0.1rem;
  color: var(--foreground-800);
}

.article-body blockquote {
  border-left: 3px solid var(--accent-400);
  padding-left: 1rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--foreground-600);
}

.article-body h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--foreground-800);
  margin-top: 2rem;
  margin-bottom: 1rem;
}

/* Source item clickable style */
.source-item {
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.source-item:hover {
  background: var(--background-200) !important;
}

.source-item:active {
  transform: scale(0.98);
}
