/* Melanin Chat - Optimized */

:root {
  /* Light theme - Apple glass beige */
  --bg: #FAF7F2;
  --glass: rgba(250, 247, 242, 0.7);
  --border: rgba(232, 221, 212, 0.3);
  --text: #8B4513;
  --text-muted: #CD853F;
  --accent: #8B4513;
  --error: #CD5C5C;
  
  /* Subtitle colors */
  --subtitle-color: #E74C3C;
  --subtitle-glow: rgba(231, 76, 60, 0.4);
  --subtitle-glow-intense: rgba(231, 76, 60, 0.7);
  
  /* Shadows */
  --shadow: 0 8px 32px 0 rgba(139, 69, 19, 0.15);
  --shadow-lg: 0 16px 64px 0 rgba(139, 69, 19, 0.2);
  
  /* Font */
  --font: 'Inter', system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #2F1B1B;
  --glass: rgba(47, 27, 27, 0.7);
  --border: rgba(74, 46, 46, 0.3);
  --text: #F5DEB3;
  --text-muted: #BC9A6A;
  --accent: #DAA520;
  --shadow: 0 8px 32px 0 rgba(218, 165, 32, 0.15);
  --shadow-lg: 0 16px 64px 0 rgba(218, 165, 32, 0.2);
  
  /* Subtitle colors for dark theme */
  --subtitle-color: #FFD700;
  --subtitle-glow: rgba(255, 215, 0, 0.4);
  --subtitle-glow-intense: rgba(255, 215, 0, 0.7);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: all 300ms ease;
  background-image: 
    radial-gradient(circle at 25% 25%, rgba(139, 69, 19, 0.02) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(218, 165, 32, 0.02) 0%, transparent 50%);
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  padding: 1.25rem 0;
  background: var(--glass);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: center;
  position: relative;
}

.logo img {
  height: 30px;
  transition: transform 300ms ease;
  filter: drop-shadow(0 2px 8px rgba(139, 69, 19, 0.1));
}

.logo:hover img { transform: scale(1.05); }

.theme-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  background: var(--glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  cursor: pointer;
  transition: all 150ms ease;
  font: 500 0.8rem var(--font);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow);
}

.theme-toggle:hover {
  background: var(--accent);
  color: var(--bg);
  transform: translateY(-50%) scale(1.05);
  box-shadow: var(--shadow-lg);
}

/* Main */
.main {
  flex: 1;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
  padding: 2rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.hero {
  text-align: center;
  padding: 1.5rem 1rem;
}

.title {
  font-size: clamp(1.875rem, 4.5vw, 3rem);
  font-weight: 700;
  margin-bottom: 0.75rem;
  line-height: 1.25;
  letter-spacing: -0.025em;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
  text-shadow: 0 1px 2px rgba(139, 69, 19, 0.1);
}

.subtitle {
  font-size: clamp(0.875rem, 2vw, 1rem);
  color: var(--subtitle-color);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  margin-top: 1.25rem;
  min-height: 1.5rem;
  text-shadow: 0 0 10px var(--subtitle-glow);
  animation: glow-pulse 3s ease-in-out infinite alternate;
}

#typing-text::after {
  content: '|';
  animation: blink 1s infinite;
  color: var(--subtitle-color);
}

@keyframes glow-pulse {
  0% {
    text-shadow: 0 0 10px var(--subtitle-glow), 0 0 20px var(--subtitle-glow);
  }
  100% {
    text-shadow: 0 0 20px var(--subtitle-glow-intense), 0 0 40px var(--subtitle-glow);
  }
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Chat */
.chat {
  flex: 1;
}

.chat-embed {
  background: var(--glass);
  backdrop-filter: blur(30px);
  border: 1px solid var(--border);
  border-radius: 2rem;
  overflow: hidden;
  height: 70vh;
  min-height: 600px;
  position: relative;
  box-shadow: var(--shadow-lg);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
}

.loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--glass);
  backdrop-filter: blur(20px);
  z-index: 10;
  transition: opacity 500ms ease;
  border-radius: 2rem;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1.25rem;
  filter: drop-shadow(0 2px 8px rgba(218, 165, 32, 0.3));
}

.loading p {
  color: var(--text);
  font-weight: 600;
  margin: 0;
}

.loading small {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* Footer */
.footer {
  background: var(--glass);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 4rem;
  text-align: center;
}

.social {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.social-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--glass);
  backdrop-filter: blur(10px);
  color: var(--text);
  text-decoration: none;
  border-radius: 1rem;
  border: 1px solid var(--border);
  font-weight: 500;
  font-size: 0.875rem;
  transition: all 150ms ease;
  box-shadow: var(--shadow);
}

.social-link:hover {
  background: var(--accent);
  color: var(--bg);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.copyright {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.copyright strong {
  color: var(--accent);
  font-weight: 700;
}

.copyright small {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}


/* Responsive */
@media (max-width: 768px) {
  .header { padding: 1rem 0; }
  .container { padding: 0 1rem; }
  .main { padding: 1.5rem 1rem 2rem; gap: 2rem; }
  .hero { padding: 1rem 0.5rem; }
  .title { margin-bottom: 1.25rem; }
  .logo img { height: 28px; }
  .theme-toggle { font-size: 0.75rem; padding: 0.5rem; }
  .chat-embed { height: 60vh; min-height: 500px; border-radius: 1.5rem; }
  .social { flex-direction: column; align-items: center; gap: 0.75rem; }
}

@media (max-width: 480px) {
  .main { padding: 1rem 0.75rem 1.5rem; }
  .chat-embed { height: 55vh; min-height: 450px; margin: 0 0.5rem; }
  .logo img { height: 26px; }
  .hero { padding: 0.75rem 0.25rem; }
}

.theme-toggle:focus,
.social-link:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}