/* AI Grand History — Scoped Design System
 * All rules are prefixed with #ai-grand-history-app so they
 * cannot leak into the WordPress theme around the shortcode.
 */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

/* ---------- Design tokens (scoped via custom-properties) ---------- */
#ai-grand-history-app {
  --aigh-bg-primary:    #0a0a0c;
  --aigh-bg-secondary:  #121216;
  --aigh-card-bg:       rgba(22, 22, 28, 0.7);
  --aigh-card-border:   rgba(255, 255, 255, 0.08);
  --aigh-card-hover-border: rgba(99, 102, 241, 0.4);
  --aigh-text-primary:  #f3f4f6;
  --aigh-text-secondary:#9ca3af;
  --aigh-accent-blue:   #3b82f6;
  --aigh-accent-purple: #8b5cf6;
  --aigh-accent-indigo: #6366f1;
  --aigh-gradient:      linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
  --aigh-glow:          0 0 20px rgba(99, 102, 241, 0.15);
  --aigh-milestone:     #10b981;
  --aigh-algorithm:     #3b82f6;
  --aigh-anecdote:      #f59e0b;

  box-sizing: border-box;
  background-color: var(--aigh-bg-primary);
  color: var(--aigh-text-primary);
  font-family: 'Outfit', 'Noto Sans SC', sans-serif;
  overflow-x: hidden;
  line-height: 1.6;
  border-radius: 8px;
}

#ai-grand-history-app *, #ai-grand-history-app *::before, #ai-grand-history-app *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---------- Header ---------- */
#ai-grand-history-app .aigh-header {
  position: relative;
  padding: 4rem 2rem;
  text-align: center;
  background: radial-gradient(circle at top, rgba(99, 102, 241, 0.15) 0%, transparent 60%);
  border-bottom: 1px solid var(--aigh-card-border);
}

#ai-grand-history-app .header-container {
  max-width: 1000px;
  margin: 0 auto;
}

#ai-grand-history-app .badge {
  display: inline-block;
  padding: 0.4rem 1rem;
  border-radius: 50px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  margin-bottom: 1.5rem;
}

#ai-grand-history-app .aigh-title {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: var(--aigh-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
  border: none;
  padding: 0;
}

#ai-grand-history-app .tagline {
  font-size: 1.1rem;
  color: var(--aigh-text-secondary);
  max-width: 600px;
  margin: 0 auto 2rem auto;
}

/* ---------- Language switcher ---------- */
#ai-grand-history-app .lang-switch-container {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  padding: 0.25rem;
  border-radius: 30px;
  border: 1px solid var(--aigh-card-border);
  width: fit-content;
  margin: 0 auto;
}

#ai-grand-history-app .lang-btn {
  background: transparent;
  border: none;
  color: var(--aigh-text-secondary);
  padding: 0.4rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s ease;
}

#ai-grand-history-app .lang-btn.active {
  background: var(--aigh-accent-indigo);
  color: var(--aigh-text-primary);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.4);
}

/* ---------- Filter controls ---------- */
#ai-grand-history-app .controls {
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
  flex-wrap: wrap;
  gap: 1.5rem;
}

#ai-grand-history-app .filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

#ai-grand-history-app .filter-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--aigh-card-border);
  color: var(--aigh-text-secondary);
  padding: 0.5rem 1.2rem;
  border-radius: 30px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.3s ease;
}

#ai-grand-history-app .filter-btn:hover,
#ai-grand-history-app .filter-btn.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--aigh-accent-indigo);
  color: var(--aigh-text-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.15);
}

/* ---------- Timeline track ---------- */
#ai-grand-history-app .timeline-section {
  position: relative;
  max-width: 900px;
  margin: 3rem auto;
  padding: 0 2rem;
}

#ai-grand-history-app .timeline-section::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: linear-gradient(to bottom, var(--aigh-accent-indigo) 0%, var(--aigh-accent-purple) 50%, transparent 100%);
  transform: translateX(-50%);
  opacity: 0.3;
}

/* ---------- Timeline cards ---------- */
#ai-grand-history-app .timeline-item {
  position: relative;
  width: 100%;
  margin-bottom: 4rem;
  display: flex;
  justify-content: flex-end;
}

#ai-grand-history-app .timeline-item:nth-child(even) {
  justify-content: flex-start;
}

#ai-grand-history-app .timeline-dot {
  position: absolute;
  top: 2rem;
  left: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--aigh-accent-indigo);
  border: 4px solid var(--aigh-bg-primary);
  transform: translateX(-50%);
  z-index: 10;
  box-shadow: 0 0 10px var(--aigh-accent-indigo);
  transition: all 0.3s ease;
}

#ai-grand-history-app .timeline-item:hover .timeline-dot {
  background: #fff;
  transform: translateX(-50%) scale(1.3);
  box-shadow: 0 0 15px #fff, 0 0 25px var(--aigh-accent-indigo);
}

#ai-grand-history-app .timeline-content {
  width: 45%;
  background: var(--aigh-card-bg);
  border: 1px solid var(--aigh-card-border);
  border-radius: 16px;
  padding: 2rem;
  position: relative;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

#ai-grand-history-app .timeline-content:hover {
  transform: translateY(-5px);
  border-color: var(--aigh-card-hover-border);
  box-shadow: 0 12px 40px rgba(99, 102, 241, 0.15), var(--aigh-glow);
}

/* Arrow connectors */
#ai-grand-history-app .timeline-content::before {
  content: '';
  position: absolute;
  top: 2rem;
  right: -8px;
  width: 16px;
  height: 16px;
  background: var(--aigh-card-bg);
  border-top: 1px solid var(--aigh-card-border);
  border-right: 1px solid var(--aigh-card-border);
  transform: translateY(-50%) rotate(45deg);
  z-index: 1;
}

#ai-grand-history-app .timeline-item:nth-child(even) .timeline-content::before {
  right: auto;
  left: -8px;
  border-top: none;
  border-right: none;
  border-bottom: 1px solid var(--aigh-card-border);
  border-left: 1px solid var(--aigh-card-border);
  transform: translateY(-50%) rotate(45deg);
}

/* ---------- Card content ---------- */
#ai-grand-history-app .event-year {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--aigh-accent-indigo);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#ai-grand-history-app .category-tag {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-weight: 600;
}

#ai-grand-history-app .tag-milestone {
  background: rgba(16, 185, 129, 0.1);
  color: var(--aigh-milestone);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

#ai-grand-history-app .tag-algorithm {
  background: rgba(59, 130, 246, 0.1);
  color: var(--aigh-algorithm);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

#ai-grand-history-app .tag-anecdote {
  background: rgba(245, 158, 11, 0.1);
  color: var(--aigh-anecdote);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

#ai-grand-history-app .event-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
  color: var(--aigh-text-primary);
  border: none;
  padding: 0;
}

#ai-grand-history-app .event-summary {
  font-size: 0.95rem;
  color: var(--aigh-text-secondary);
  margin-bottom: 1.2rem;
}

/* ---------- Expandable story ---------- */
#ai-grand-history-app .event-story {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease-out;
  font-size: 0.9rem;
  color: #d1d5db;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 0;
}

#ai-grand-history-app .event-story.expanded {
  max-height: 350px;
  padding-top: 1rem;
  margin-top: 0.5rem;
}

#ai-grand-history-app .figure-info {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--aigh-accent-purple);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#ai-grand-history-app .figure-info::before {
  content: '👤';
}

#ai-grand-history-app .expand-btn {
  background: transparent;
  border: none;
  color: var(--aigh-accent-indigo);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.5rem;
  transition: color 0.2s ease;
}

#ai-grand-history-app .expand-btn:hover {
  color: var(--aigh-accent-purple);
}

/* ---------- Co-creation form ---------- */
#ai-grand-history-app .co-creation-section {
  max-width: 800px;
  margin: 5rem auto;
  padding: 3rem 2rem;
  background: radial-gradient(circle at bottom right, rgba(139, 92, 246, 0.08) 0%, transparent 50%), var(--aigh-bg-secondary);
  border: 1px solid var(--aigh-card-border);
  border-radius: 24px;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

#ai-grand-history-app .co-creation-title {
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.5rem;
  background: linear-gradient(to right, #fff, var(--aigh-text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  border: none;
  padding: 0;
}

#ai-grand-history-app .co-creation-subtitle {
  font-size: 1rem;
  color: var(--aigh-text-secondary);
  text-align: center;
  margin-bottom: 2.5rem;
}

#ai-grand-history-app .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

#ai-grand-history-app .form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#ai-grand-history-app .form-group.full-width {
  grid-column: span 2;
}

#ai-grand-history-app label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--aigh-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#ai-grand-history-app input,
#ai-grand-history-app select,
#ai-grand-history-app textarea {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--aigh-card-border);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  color: var(--aigh-text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

#ai-grand-history-app input:focus,
#ai-grand-history-app select:focus,
#ai-grand-history-app textarea:focus {
  outline: none;
  border-color: var(--aigh-accent-indigo);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
  background: rgba(255, 255, 255, 0.06);
}

#ai-grand-history-app select option {
  background: var(--aigh-bg-secondary);
  color: var(--aigh-text-primary);
}

#ai-grand-history-app .submit-btn {
  grid-column: span 2;
  background: var(--aigh-gradient);
  border: none;
  padding: 1rem;
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 1rem;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

#ai-grand-history-app .submit-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

#ai-grand-history-app .submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ---------- Toast ---------- */
#ai-grand-history-app .toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--aigh-bg-secondary);
  border: 1px solid var(--aigh-milestone);
  color: var(--aigh-text-primary);
  padding: 1rem 1.5rem;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5), 0 0 15px rgba(16, 185, 129, 0.2);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  z-index: 99999;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  pointer-events: none;
}

#ai-grand-history-app .toast.show {
  opacity: 1;
  transform: translateY(0);
}

#ai-grand-history-app .toast-icon {
  color: var(--aigh-milestone);
  font-size: 1.2rem;
}

/* ---------- Footer ---------- */
#ai-grand-history-app .aigh-footer {
  text-align: center;
  padding: 3rem;
  border-top: 1px solid var(--aigh-card-border);
  color: rgba(255, 255, 255, 0.3);
  font-size: 0.85rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  #ai-grand-history-app .aigh-title {
    font-size: 2.2rem;
  }

  #ai-grand-history-app .controls {
    flex-direction: column;
    align-items: stretch;
  }

  #ai-grand-history-app .timeline-section::before {
    left: 2rem;
  }

  #ai-grand-history-app .timeline-item,
  #ai-grand-history-app .timeline-item:nth-child(even) {
    justify-content: flex-end;
  }

  #ai-grand-history-app .timeline-dot {
    left: 2rem;
  }

  #ai-grand-history-app .timeline-content {
    width: calc(100% - 3.5rem);
  }

  #ai-grand-history-app .timeline-content::before,
  #ai-grand-history-app .timeline-item:nth-child(even) .timeline-content::before {
    right: auto;
    left: -8px;
    border-top: none;
    border-right: none;
    border-bottom: 1px solid var(--aigh-card-border);
    border-left: 1px solid var(--aigh-card-border);
    transform: translateY(-50%) rotate(45deg);
  }

  #ai-grand-history-app .form-grid {
    grid-template-columns: 1fr;
  }

  #ai-grand-history-app .form-group.full-width {
    grid-column: span 1;
  }

  #ai-grand-history-app .submit-btn {
    grid-column: span 1;
  }
}
