/* ========================================
   WORLD CHAT DESIGN ALIGNMENT v1.0
   ========================================
   
   Target: world.org/worldchat visual language
   Goal: Make Ourb look native to World App ecosystem
   
   Key World patterns extracted:
   - Dark theme primary (bg-gray-a10 = near-black)
   - High contrast white text on dark
   - Rounded-xl corners (1rem = 16px)
   - World Pro font family
   - Smooth transitions (duration-600)
   - Sticky section headers
   - Mobile-first responsive
   
   Usage: Add data-theme="world" to <html> or <body>
   Or add class="world-theme" to any container
   ======================================== */

/* ========================================
   1. WORLD DESIGN TOKENS
   ======================================== */

[data-theme="world"],
.world-theme {
  /* World gray scale (from world.org CSS) */
  --world-gray-a1: #FFFFFF;      /* Primary text on dark */
  --world-gray-a2: #F5F5F5;
  --world-gray-a3: #E5E5E5;
  --world-gray-a4: #D4D4D4;
  --world-gray-a5: #A3A3A3;
  --world-gray-a6: #737373;      /* Borders, dividers */
  --world-gray-a7: #525252;
  --world-gray-a8: #404040;      /* Card backgrounds */
  --world-gray-a9: #262626;      /* Elevated surfaces */
  --world-gray-a10: #171717;     /* Primary background */
  
  /* Alt grays (muted variants) */
  --world-alt-gray-e2: #A3A3A3;  /* Muted text */
  
  /* Semantic mapping to ourb-design tokens */
  --ourb-black: var(--world-gray-a1);
  --ourb-white: var(--world-gray-a10);
  --ourb-grey-900: var(--world-gray-a2);
  --ourb-grey-800: var(--world-gray-a3);
  --ourb-grey-700: var(--world-gray-a4);
  --ourb-grey-600: var(--world-gray-a5);
  --ourb-grey-500: var(--world-gray-a6);
  --ourb-grey-400: var(--world-gray-a6);
  --ourb-grey-300: var(--world-gray-a7);
  --ourb-grey-200: var(--world-gray-a8);
  --ourb-grey-100: var(--world-gray-a9);
  --ourb-grey-50: var(--world-gray-a10);
  --ourb-grey-25: #0F0F0F;
  
  /* World accent (subtle, not dominant) */
  --ourb-accent: var(--world-gray-a5);
  --ourb-accent-light: var(--world-gray-a4);
  --ourb-accent-dark: var(--world-gray-a6);
  
  /* Border color for dark mode */
  --ourb-border-color: var(--world-gray-a7);
  
  /* Typography */
  --world-font-display: "World Pro", "Inter", system-ui, -apple-system, sans-serif;
  --ourb-font-primary: var(--world-font-display);
  --ourb-font-display: var(--world-font-display);
  
  /* World-specific spacing */
  --world-radius-xl: 1rem;       /* 16px - their primary radius */
  --world-radius-4xl: 1.5rem;    /* 24px - large cards */
  
  /* Override ourb radius to be rounder */
  --ourb-radius-sm: 0.5rem;      /* 8px */
  --ourb-radius-md: 0.75rem;     /* 12px */
  --ourb-radius-lg: 1rem;        /* 16px */
  
  /* World transitions */
  --world-duration-50: 50ms;
  --world-duration-100: 100ms;
  --world-duration-600: 600ms;
  --world-ease-impulse: cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Color scheme for system UI */
  color-scheme: dark;
}

/* ========================================
   2. BASE STYLES
   ======================================== */

[data-theme="world"] body,
.world-theme {
  background: var(--world-gray-a10);
  color: var(--world-gray-a1);
}

/* ========================================
   3. TYPOGRAPHY (World style)
   ======================================== */

/* World uses clean, high-contrast text hierarchy */
[data-theme="world"] .world-h2,
.world-theme .world-h2 {
  font-family: var(--world-font-display);
  font-size: 2.5rem;   /* text-h2 equivalent */
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--world-gray-a1);
}

[data-theme="world"] .world-h4,
.world-theme .world-h4 {
  font-family: var(--world-font-display);
  font-size: 1.5rem;   /* text-h4 equivalent */
  font-weight: 400;
  line-height: 1.25;
  color: var(--world-gray-a1);
}

[data-theme="world"] .world-h8,
.world-theme .world-h8 {
  font-family: var(--world-font-display);
  font-size: 1.125rem; /* text-h8 equivalent */
  font-weight: 400;
  line-height: 1.4;
  color: var(--world-gray-a1);
}

[data-theme="world"] .world-b1,
.world-theme .world-b1 {
  font-family: var(--world-font-display);
  font-size: 1rem;     /* text-b1 - body */
  font-weight: 400;
  line-height: 1.5;
  color: var(--world-gray-a1);
}

[data-theme="world"] .world-b2,
.world-theme .world-b2 {
  font-family: var(--world-font-display);
  font-size: 0.875rem; /* text-b2 - small body */
  font-weight: 400;
  line-height: 1.5;
  color: var(--world-gray-a1);
}

[data-theme="world"] .world-b4,
.world-theme .world-b4 {
  font-family: var(--world-font-display);
  font-size: 0.75rem;  /* text-b4 - caption */
  font-weight: 400;
  line-height: 1.5;
  color: var(--world-alt-gray-e2);
}

/* Muted text */
[data-theme="world"] .world-muted,
.world-theme .world-muted {
  color: var(--world-alt-gray-e2);
}

/* ========================================
   4. LINKS (World underline animation)
   ======================================== */

[data-theme="world"] .world-link,
.world-theme .world-link {
  position: relative;
  display: inline;
  cursor: pointer;
  color: var(--world-gray-a1);
  text-decoration: none;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 220% 0.06em;
  background-repeat: no-repeat;
  background-position: 100% calc(100% - 0.06em);
  padding-bottom: 0.125rem;
  transition: background-position 600ms var(--world-ease-impulse);
}

[data-theme="world"] .world-link:hover,
.world-theme .world-link:hover {
  background-position: 0% calc(100% - 0.06em);
}

/* ========================================
   5. CARDS (World rounded style)
   ======================================== */

[data-theme="world"] .world-card,
.world-theme .world-card {
  background: var(--world-gray-a9);
  border: 1px solid var(--world-gray-a7);
  border-radius: var(--world-radius-xl);
  padding: 1.5rem;
}

[data-theme="world"] .world-card-elevated,
.world-theme .world-card-elevated {
  background: var(--world-gray-a8);
  border: 1px solid var(--world-gray-a6);
  border-radius: var(--world-radius-4xl);
  padding: 2rem;
}

/* ========================================
   6. BUTTONS (World style)
   ======================================== */

[data-theme="world"] .world-btn,
.world-theme .world-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  font-family: var(--world-font-display);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1;
  text-decoration: none;
  border: none;
  border-radius: 9999px;  /* Fully rounded pill */
  cursor: pointer;
  transition: all 100ms var(--world-ease-impulse);
}

/* Primary - White on dark */
[data-theme="world"] .world-btn-primary,
.world-theme .world-btn-primary {
  background: var(--world-gray-a1);
  color: var(--world-gray-a10);
}

[data-theme="world"] .world-btn-primary:hover,
.world-theme .world-btn-primary:hover {
  background: var(--world-gray-a3);
}

/* Ghost - Transparent */
[data-theme="world"] .world-btn-ghost,
.world-theme .world-btn-ghost {
  background: transparent;
  color: var(--world-gray-a1);
  border: 1px solid var(--world-gray-a6);
}

[data-theme="world"] .world-btn-ghost:hover,
.world-theme .world-btn-ghost:hover {
  background: var(--world-gray-a8);
}

/* ========================================
   7. INPUTS (World style)
   ======================================== */

[data-theme="world"] .world-input,
.world-theme .world-input {
  width: 100%;
  padding: 0.875rem 1.25rem;
  font-family: var(--world-font-display);
  font-size: 1rem;
  color: var(--world-gray-a1);
  background: var(--world-gray-a10);
  border: 1px solid transparent;
  border-radius: 9999px;
  outline: none;
  transition: all 100ms var(--world-ease-impulse);
}

[data-theme="world"] .world-input::placeholder,
.world-theme .world-input::placeholder {
  color: var(--world-alt-gray-e2);
}

[data-theme="world"] .world-input:focus,
.world-theme .world-input:focus {
  outline: 1px solid var(--world-gray-a1);
}

[data-theme="world"] .world-input:hover,
.world-theme .world-input:hover {
  outline: 1px solid var(--world-alt-gray-e2);
}

/* ========================================
   8. DIVIDERS (World style)
   ======================================== */

[data-theme="world"] .world-divider,
.world-theme .world-divider {
  width: 100%;
  height: 1px;
  background: var(--world-gray-a6);
  border: none;
  margin: 1.5rem 0;
}

/* ========================================
   9. SECTION LAYOUT (World sticky sidebar)
   ======================================== */

[data-theme="world"] .world-section,
.world-theme .world-section {
  position: relative;
  display: grid;
  align-items: start;
  padding: 5rem 0;
  background: var(--world-gray-a10);
}

[data-theme="world"] .world-section-label,
.world-theme .world-section-label {
  position: sticky;
  top: calc(4rem + 1.5rem); /* header height + spacing */
  padding-bottom: 1.25rem;
  font-size: 1rem;
  color: var(--world-gray-a1);
}

@media (min-width: 1024px) {
  [data-theme="world"] .world-section,
  .world-theme .world-section {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
  }
}

/* ========================================
   10. CAROUSEL ITEMS (World app chips)
   ======================================== */

[data-theme="world"] .world-app-chip,
.world-theme .world-app-chip {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 4.5rem;
  padding: 0 1.5rem 0 0;
  background: var(--world-gray-a9);
  border-radius: var(--world-radius-xl);
}

[data-theme="world"] .world-app-chip img,
.world-theme .world-app-chip img {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: var(--world-radius-xl);
  object-fit: cover;
}

[data-theme="world"] .world-app-chip span,
.world-theme .world-app-chip span {
  font-size: 1rem;
  color: var(--world-gray-a1);
}

/* ========================================
   11. CHAT OVERRIDES (Ourb-specific)
   ======================================== */

/* Make Ourb chat look World-native */
[data-theme="world"] .chat-container.ourb-card,
.world-theme .chat-container.ourb-card {
  background: var(--world-gray-a9);
  border: 1px solid var(--world-gray-a7);
  border-radius: var(--world-radius-4xl);
}

[data-theme="world"] #log.chat-log,
.world-theme #log.chat-log {
  background: var(--world-gray-a10);
  border: 1px solid var(--world-gray-a8);
  border-radius: var(--world-radius-xl);
}

[data-theme="world"] .chat-message--assistant,
.world-theme .chat-message--assistant {
  background: var(--world-gray-a8);
  color: var(--world-gray-a1);
  border: 1px solid var(--world-gray-a7);
  border-radius: var(--world-radius-xl);
  border-bottom-left-radius: 0.25rem;
}

[data-theme="world"] .chat-message--user,
.world-theme .chat-message--user {
  background: var(--world-gray-a1);
  color: var(--world-gray-a10);
  border: none;
  border-radius: var(--world-radius-xl);
  border-bottom-right-radius: 0.25rem;
}

[data-theme="world"] .chat-composer .ourb-textarea,
.world-theme .chat-composer .ourb-textarea {
  background: var(--world-gray-a10);
  border: 1px solid transparent;
  color: var(--world-gray-a1);
  border-radius: 9999px;
}

[data-theme="world"] .chat-composer .ourb-textarea:focus,
.world-theme .chat-composer .ourb-textarea:focus {
  outline: 1px solid var(--world-gray-a1);
  border-color: transparent;
}

[data-theme="world"] .chat-composer .ourb-btn-primary,
.world-theme .chat-composer .ourb-btn-primary {
  background: var(--world-gray-a1);
  color: var(--world-gray-a10);
  border-radius: 9999px;
}

[data-theme="world"] .chat-composer .ourb-btn-primary:hover,
.world-theme .chat-composer .ourb-btn-primary:hover {
  background: var(--world-gray-a3);
}

/* ========================================
   12. NAV OVERRIDES
   ======================================== */

[data-theme="world"] .nav-sidebar,
.world-theme .nav-sidebar {
  background: var(--world-gray-a10);
  border-right: 1px solid var(--world-gray-a8);
}

[data-theme="world"] .nav-link,
.world-theme .nav-link {
  color: var(--world-gray-a1);
  border-radius: var(--world-radius-xl);
}

[data-theme="world"] .nav-link:hover,
.world-theme .nav-link:hover {
  background: var(--world-gray-a8);
}

[data-theme="world"] .nav-link.active,
.world-theme .nav-link.active {
  background: var(--world-gray-a8);
  color: var(--world-gray-a1);
}

/* ========================================
   13. CONSOLE / DASHBOARD OVERRIDES
   ======================================== */

[data-theme="world"] .ourb-card,
.world-theme .ourb-card {
  background: var(--world-gray-a9);
  border: 1px solid var(--world-gray-a7);
  border-radius: var(--world-radius-xl);
}

[data-theme="world"] .ourb-card-header,
.world-theme .ourb-card-header {
  border-bottom: 1px solid var(--world-gray-a7);
}

[data-theme="world"] .ourb-card-title,
.world-theme .ourb-card-title {
  color: var(--world-gray-a1);
}

[data-theme="world"] .ourb-card-body,
.world-theme .ourb-card-body {
  color: var(--world-gray-a4);
}

/* ========================================
   14. BADGES (World style)
   ======================================== */

[data-theme="world"] .world-badge,
.world-theme .world-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 400;
  border-radius: 9999px;
  background: var(--world-gray-a8);
  color: var(--world-gray-a1);
}

[data-theme="world"] .world-badge-success,
.world-theme .world-badge-success {
  background: rgba(34, 197, 94, 0.15);
  color: #22c55e;
}

[data-theme="world"] .world-badge-warning,
.world-theme .world-badge-warning {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
}

[data-theme="world"] .world-badge-error,
.world-theme .world-badge-error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

/* ========================================
   15. TABLES (World style)
   ======================================== */

[data-theme="world"] table,
.world-theme table {
  width: 100%;
  border-collapse: collapse;
}

[data-theme="world"] th,
.world-theme th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--world-alt-gray-e2);
  border-bottom: 1px solid var(--world-gray-a7);
}

[data-theme="world"] td,
.world-theme td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--world-gray-a1);
  border-bottom: 1px solid var(--world-gray-a8);
}

[data-theme="world"] tr:hover td,
.world-theme tr:hover td {
  background: var(--world-gray-a9);
}

/* ========================================
   16. FOOTER (World style)
   ======================================== */

[data-theme="world"] footer,
.world-theme footer {
  background: var(--world-gray-a10);
  color: var(--world-gray-a1);
  padding: 1.5rem;
}

[data-theme="world"] footer a,
.world-theme footer a {
  color: var(--world-gray-a1);
  transition: color 50ms var(--world-ease-impulse);
}

[data-theme="world"] footer a:hover,
.world-theme footer a:hover {
  color: var(--world-alt-gray-e2);
}

/* ========================================
   17. MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 767px) {
  [data-theme="world"] .world-h2,
  .world-theme .world-h2 {
    font-size: 1.75rem;
  }
  
  [data-theme="world"] .world-h4,
  .world-theme .world-h4 {
    font-size: 1.25rem;
  }
  
  [data-theme="world"] .world-section,
  .world-theme .world-section {
    padding: 2.5rem 0;
  }
  
  [data-theme="world"] .world-card,
  .world-theme .world-card {
    padding: 1rem;
    border-radius: var(--world-radius-xl);
  }
}

/* ========================================
   18. UTILITY CLASSES
   ======================================== */

/* Background utilities */
.world-bg-a8 { background: var(--world-gray-a8); }
.world-bg-a9 { background: var(--world-gray-a9); }
.world-bg-a10 { background: var(--world-gray-a10); }

/* Text utilities */
.world-text-a1 { color: var(--world-gray-a1); }
.world-text-muted { color: var(--world-alt-gray-e2); }

/* Border utilities */
.world-border { border: 1px solid var(--world-gray-a7); }
.world-border-subtle { border: 1px solid var(--world-gray-a8); }

/* Radius utilities */
.world-rounded-xl { border-radius: var(--world-radius-xl); }
.world-rounded-4xl { border-radius: var(--world-radius-4xl); }
.world-rounded-full { border-radius: 9999px; }
