/**
 * Clip Flow Feature Gallery - Modern, Clean, Polished
 * Aesthetic: Light, airy, sophisticated with smooth micro-interactions
 */

/* CSS Variables - Sophisticated Color Palette */
:root {
  /* Core Colors */
  --bg-primary: #fafafa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f4f4f5;
  
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-tertiary: #a1a1aa;
  
  /* Accent Colors - Soft Blue */
  --accent: #3b82f6;
  --accent-light: #dbeafe;
  --accent-soft: rgba(59, 130, 246, 0.08);
  
  /* UI Colors */
  --border: #e4e4e7;
  --border-light: #f4f4f5;
  
  /* Shadows - Subtle & Sophisticated */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.02);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
  --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.15);
  
  /* Radius - Modern & Soft */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  
  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
  
  /* Spacing */
  --container-width: 1200px;
  --section-gap: 3rem;
}

/* Dark Mode - Elegant & Refined */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #09090b;
    --bg-secondary: #18181b;
    --bg-tertiary: #27272a;
    
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-tertiary: #71717a;
    
    --border: #27272a;
    --border-light: #3f3f46;
    
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  }
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Ambient Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse at 20% 30%, rgba(59, 130, 246, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(147, 51, 234, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* Container */
.container {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

@media (min-width: 768px) {
  .container {
    padding: 0 2rem;
  }
}

@media (min-width: 1024px) {
  .container {
    padding: 0 3rem;
  }
}

/* Header - Clean & Modern */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(250, 250, 250, 0.85);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border);
  transition: all var(--transition-base);
}

@media (prefers-color-scheme: dark) {
  .site-header {
    background: rgba(9, 9, 11, 0.85);
  }
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-spring);
}

.brand-mark:hover {
  transform: scale(1.05);
}

.brand-mark svg {
  width: 100%;
  height: 100%;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* GitHub Button */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  text-decoration: none;
  transition: all var(--transition-base);
  box-shadow: var(--shadow-xs);
}

.btn:hover {
  color: var(--text-primary);
  border-color: var(--text-tertiary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn svg {
  width: 18px;
  height: 18px;
}

/* Main Content */
main.container {
  padding-top: 100px;
  padding-bottom: 4rem;
}

/* Feature Groups */
.feature-groups {
  display: flex;
  flex-direction: column;
  gap: var(--section-gap);
}

.feature-group {
  opacity: 1;
  transform: translateY(0);
  transition: all var(--transition-slow);
}

/* Initial hidden state for animation - will be overridden by JS */
.feature-group:not(.visible) {
  opacity: 0;
  transform: translateY(20px);
}

.feature-group.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Group Header */
.group-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.group-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--accent);
  transition: all var(--transition-base);
}

.group-icon:hover {
  background: var(--accent-soft);
  border-color: var(--accent-light);
  transform: scale(1.05);
}

.group-icon svg {
  width: 22px;
  height: 22px;
}

.group-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.group-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.group-count {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-tertiary);
}

/* Features Grid */
.features-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 1.25rem;
  align-items: stretch;
}

@media (min-width: 640px) {
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .features-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Feature Card - Beautiful & Interactive */
.feature-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-spring);
  box-shadow: var(--shadow-sm);
  opacity: 1;
  transform: translateY(0);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.feature-card.animate-in {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeUp 0.6s ease forwards;
}

.feature-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.feature-card:hover {
  transform: translateY(-8px) scale(1.01);
  box-shadow: var(--shadow-xl);
  border-color: var(--accent-light);
}

@keyframes fadeUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-media {
  position: relative;
  background: #ffffff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  padding: 16px;
}

.card-media img {
  max-width: 100%;
  max-height: 220px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  transition: transform var(--transition-slow);
}

.feature-card:hover .card-media img {
  transform: scale(1.02);
}

.card-content {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.3;
  height: 24px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-summary {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 42px;
  flex-shrink: 0;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  height: 28px;
  align-items: flex-start;
  overflow: hidden;
  flex-shrink: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
}

.tag:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

/* Media Placeholder */
.media-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.media-placeholder.large {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
}

/* Modal - Refined & Elegant */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.modal-backdrop:not([hidden]) {
  opacity: 1;
}

dialog.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-xl);
  width: min(900px, calc(100% - 2rem));
  max-height: calc(100% - 4rem);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0, 0, 0, 0.05);
  z-index: 201;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: all var(--transition-spring);
}

dialog.modal[open] {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

dialog.modal:not([open]) {
  display: none;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.modal-kicker {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: 0;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-tertiary);
  color: var(--text-primary);
  transform: rotate(90deg);
}

.modal-body {
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-media-section {
  padding: 2rem 2rem 1rem;
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

@media (max-width: 768px) {
  .modal-media-section {
    padding: 1.25rem 1.25rem 0.75rem;
    flex-direction: column;
    gap: 1rem;
  }
}

.modal-content-section {
  padding: 0 2rem 2rem;
}

@media (max-width: 768px) {
  .modal-content-section {
    padding: 0 1.25rem 1.25rem;
  }
}

/* Media Gallery in Modal */
#modalMedia {
  flex: 1;
  border-radius: var(--radius-lg);
  background: var(--bg-primary);
  overflow: hidden;
  min-height: 0;
}

.media-item {
  width: 100%;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.media-item img {
  width: 100%;
  max-height: 500px;
  height: auto;
  display: block;
  border-radius: var(--radius-md);
  object-fit: contain;
  background: var(--bg-tertiary);
}

/* Gallery Dots - Vertical on the right side */
.gallery-dots {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
  padding-top: 0.5rem;
}

@media (max-width: 768px) {
  .gallery-dots {
    flex-direction: row;
    justify-content: center;
    padding-top: 0;
  }
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
}

.dot:hover {
  background: var(--text-tertiary);
  transform: scale(1.2);
}

.dot.active {
  background: var(--accent);
  transform: scale(1.2);
  box-shadow: var(--shadow-glow);
}

/* Modal Content */
.modal-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0 0 1.5rem 0;
}

#modalMeta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#modalMeta .tag {
  font-size: 0.8125rem;
  padding: 0.375rem 0.875rem;
}

/* Footer */
.site-footer {
  padding: 3rem 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--text-tertiary);
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.footer-link:hover {
  color: var(--accent);
}

/* Error Message */
.error-message {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-secondary);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .header-inner {
    padding: 0.875rem 0;
  }
  
  .brand-title {
    font-size: 1.125rem;
  }
  
  main.container {
    padding-top: 80px;
  }
  
  .group-header {
    margin-bottom: 1.5rem;
  }
  
  .group-title {
    font-size: 1.25rem;
  }
  
  .modal-header {
    padding: 1.25rem;
  }
  
  .modal-title {
    font-size: 1.25rem;
  }
  
  .modal-body {
    padding: 1.25rem;
    grid-template-columns: 1fr;
  }
}

/* Loading Animation */
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.loading {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 25%,
    var(--border) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

/* Hover Preview */
.hover-preview {
  position: fixed;
  width: 800px;
  max-width: calc(100vw - 40px);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl), 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  z-index: 150;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.98);
  transition: all var(--transition-base);
  pointer-events: none;
  overflow: hidden;
}

.hover-preview.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.hover-preview img {
  width: 100%;
  height: 500px;
  object-fit: contain;
  background: var(--bg-tertiary);
  display: block;
}

.hover-preview .preview-info {
  padding: 1.25rem;
  border-top: 1px solid var(--border);
}

.hover-preview .preview-info h4 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.hover-preview .preview-info p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
