/* ==========================================================================
   Normaxia.com — Design System
   Built with Emil Kowalski's Design Engineering Philosophy
   ==========================================================================*/

/* --------------------------------------------------------------------------
   1. CUSTOM PROPERTIES (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
  /* Brand palette */
  --nx-primary: #0b1220;
  --nx-primary-light: #1a2a44;
  --nx-accent: #b8860b;
  --nx-accent-soft: #d4a843;
  --nx-surface: #f4f1ea;
  --nx-surface-elevated: #fffef9;
  --nx-text-primary: #1e293b;
  --nx-text-secondary: #5c6370;
  --nx-text-on-dark: #e8e2d4;
  --nx-text-on-dark-muted: #a8a090;
  --nx-border: #d6cec0;
  --nx-border-light: #e8e2d4;

  /* Emil Kowalski animation tokens */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  /* Spacing scale */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Typography */
  --font-display: 'Cinzel', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

/* --------------------------------------------------------------------------
   2. RESET & BASE
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  color: var(--nx-text-primary);
  background: var(--nx-surface);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------------
   3. TYPOGRAPHY
   -------------------------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); }
h3 { font-size: 1.25rem; }

.section-label {
  font-family: var(--font-display);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--nx-accent);
  margin-bottom: var(--space-sm);
}

/* --------------------------------------------------------------------------
   4. NAVIGATION
   -------------------------------------------------------------------------- */
.site-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(184, 134, 11, 0.2);
  padding: 0 var(--space-2xl);

  /* Nav enters from top — interruptible transition */
  transform: translateY(-100%);
  opacity: 0;
  transition:
    transform 400ms var(--ease-out),
    opacity 300ms var(--ease-out);
}

.site-nav.visible {
  transform: translateY(0);
  opacity: 1;
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-family: var(--font-display);
  font-size: 1.125rem;
  color: var(--nx-text-on-dark);
  text-decoration: none;
}

.nav-brand img {
  height: 28px;
  width: auto;
}

.nav-links {
  display: flex;
  gap: var(--space-xl);
  list-style: none;
}

.nav-links a {
  color: var(--nx-text-on-dark-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
  transition:
    color 180ms var(--ease-out),
    border-color 180ms var(--ease-out);
}

.nav-links a:hover {
  color: var(--nx-accent-soft);
  border-bottom-color: var(--nx-accent);
}

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--nx-text-on-dark);
  font-size: 1.5rem;
  cursor: pointer;
  transition: transform 160ms var(--ease-out);
}

.nav-toggle:active {
  transform: scale(0.97);
}

/* --------------------------------------------------------------------------
   5. HERO SECTION
   -------------------------------------------------------------------------- */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 30%, rgba(184, 134, 11, 0.08) 0%, transparent 70%),
    linear-gradient(180deg, var(--nx-primary) 0%, var(--nx-primary-light) 50%, var(--nx-primary) 100%);
  padding: var(--space-4xl) var(--space-2xl);
  position: relative;
  overflow: hidden;
}

/* Subtle grid pattern overlay */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(184, 134, 11, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(184, 134, 11, 0.03) 1px, transparent 1px);
  background-size: 80px 80px;
  opacity: 0.5;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 800px;
}

/* Each hero child staggers enter */
.hero-content > * {
  opacity: 0;
  transform: translateY(8px);
}

.hero-content.entered > * {
  animation: heroFadeIn 350ms var(--ease-out) forwards;
}

.hero-content.entered > *:nth-child(1) { animation-delay: 0ms; }
.hero-content.entered > *:nth-child(2) { animation-delay: 60ms; }
.hero-content.entered > *:nth-child(3) { animation-delay: 120ms; }
.hero-content.entered > *:nth-child(4) { animation-delay: 180ms; }

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

.hero h1 {
  color: var(--nx-text-on-dark);
  margin-bottom: var(--space-md);
}

.hero .hero-accent {
  color: var(--nx-accent-soft);
}

.hero .hero-subtitle {
  color: var(--nx-text-on-dark-muted);
  font-size: 1.125rem;
  max-width: 600px;
  margin: 0 auto var(--space-2xl);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  gap: var(--space-lg);
  justify-content: center;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   6. BUTTONS — Emil Kowalski standard
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.75rem 1.75rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms var(--ease-out);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* SCALE-DOWN ON PRESS — Non-negotiable Emil standard */
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--nx-accent);
  color: var(--nx-primary);
  box-shadow: 0 2px 8px rgba(184, 134, 11, 0.25);
  transition:
    transform 160ms var(--ease-out),
    background 200ms var(--ease-out),
    box-shadow 200ms var(--ease-out);
}

.btn-primary:hover {
  background: var(--nx-accent-soft);
  box-shadow: 0 4px 16px rgba(184, 134, 11, 0.4);
}

.btn-outline {
  background: transparent;
  color: var(--nx-accent-soft);
  border: 1.5px solid var(--nx-accent);
  transition:
    transform 160ms var(--ease-out),
    background 200ms var(--ease-out),
    color 200ms var(--ease-out);
}

.btn-outline:hover {
  background: rgba(184, 134, 11, 0.08);
  color: var(--nx-accent-soft);
}

/* --------------------------------------------------------------------------
   7. SECTIONS — clip-path reveal on scroll
   -------------------------------------------------------------------------- */
.section {
  padding: var(--space-4xl) var(--space-2xl);
  max-width: 1280px;
  margin: 0 auto;
}

/* Clip-path reveal for sections entering viewport */
.section-reveal {
  clip-path: inset(0 0 100% 0);
  transition: clip-path 700ms var(--ease-in-out);
}

.section-reveal.revealed {
  clip-path: inset(0 0 0 0);
}

.section-header {
  text-align: center;
  margin-bottom: var(--space-3xl);
}

.section-header h2 {
  color: var(--nx-primary);
  margin-bottom: var(--space-sm);
}

.section-header p {
  color: var(--nx-text-secondary);
  max-width: 600px;
  margin: 0 auto;
}

/* --------------------------------------------------------------------------
   8. SERVICE CARDS
   -------------------------------------------------------------------------- */
.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-xl);
}

/* Cards stagger on scroll reveal */
.services-grid.revealed .service-card {
  opacity: 0;
  transform: translateY(12px);
  animation: cardFadeIn 400ms var(--ease-out) forwards;
}

.services-grid.revealed .service-card:nth-child(1) { animation-delay: 0ms; }
.services-grid.revealed .service-card:nth-child(2) { animation-delay: 80ms; }
.services-grid.revealed .service-card:nth-child(3) { animation-delay: 160ms; }

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

.service-card {
  background: var(--nx-surface-elevated);
  border: 1px solid var(--nx-border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  box-shadow: 0 1px 4px rgba(11, 18, 32, 0.04);
  transition:
    box-shadow 250ms var(--ease-out),
    transform 250ms var(--ease-out);
}

/* Hover ONLY on devices with fine pointer */
@media (hover: hover) and (pointer: fine) {
  .service-card:hover {
    box-shadow: 0 8px 32px rgba(11, 18, 32, 0.08);
    transform: translateY(-4px);
  }
}

.service-card .card-icon {
  font-size: 2rem;
  color: var(--nx-accent);
  margin-bottom: var(--space-md);
  /* origin-aware pop-in */
  transform: scale(0.92);
  opacity: 0;
  transition:
    transform 250ms var(--ease-out),
    opacity 250ms var(--ease-out);
}

.services-grid.revealed .service-card .card-icon {
  transform: scale(1);
  opacity: 1;
  transition-delay: calc(var(--card-index, 0) * 80ms);
}

.service-card h3 {
  color: var(--nx-primary);
  margin-bottom: var(--space-sm);
}

.service-card p {
  color: var(--nx-text-secondary);
  font-size: 0.9375rem;
  line-height: 1.7;
}

/* --------------------------------------------------------------------------
   9. TECHNOLOGY SECTION — origin-aware popovers
   -------------------------------------------------------------------------- */
.tech-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2xl);
  align-items: center;
}

.tech-visual {
  background: var(--nx-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-2xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.tech-node {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--nx-primary-light);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--nx-accent);
  color: var(--nx-text-on-dark);
  font-size: 0.9375rem;
  font-weight: 500;
  position: relative;
}

.tech-node .node-badge {
  font-size: 0.75rem;
  color: var(--nx-accent-soft);
  background: rgba(184, 134, 11, 0.12);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

/* Popover trigger — origin-aware */
.tech-popover-trigger {
  position: relative;
  cursor: help;
  border-bottom: 1px dashed var(--nx-accent-soft);
  color: var(--nx-accent-soft);
  transition: color 180ms var(--ease-out);
}

.tech-popover-trigger:hover {
  color: var(--nx-accent);
}

.tech-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  background: var(--nx-surface-elevated);
  border: 1px solid var(--nx-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  width: 280px;
  font-size: 0.8125rem;
  color: var(--nx-text-primary);
  box-shadow: 0 8px 32px rgba(11, 18, 32, 0.12);
  pointer-events: none;

  /* ORIGIN-AWARE — scale from trigger, not center */
  transform-origin: bottom center;
  transform: scale(0.95);
  opacity: 0;
  transition:
    transform 200ms var(--ease-out),
    opacity 200ms var(--ease-out);
}

.tech-popover-trigger:hover .tech-popover {
  transform: scale(1);
  opacity: 1;
}

.tech-description {
  color: var(--nx-text-secondary);
  line-height: 1.8;
}

.tech-description h3 {
  color: var(--nx-primary);
  margin-bottom: var(--space-md);
}

/* --------------------------------------------------------------------------
   10. CHAT WIDGET SECTION
   -------------------------------------------------------------------------- */
.chat-section {
  background: var(--nx-primary);
  color: var(--nx-text-on-dark);
  padding: var(--space-4xl) var(--space-2xl);
}

.chat-section .section-header h2 {
  color: var(--nx-text-on-dark);
}

.chat-section .section-header p {
  color: var(--nx-text-on-dark-muted);
}

.chat-container {
  max-width: 720px;
  margin: 0 auto;
  background: var(--nx-primary-light);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(184, 134, 11, 0.15);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 480px;
}

/* Chat messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  scroll-behavior: smooth;
}

/* Chat bubbles — interruptible transitions */
.chat-bubble {
  display: flex;
  gap: var(--space-sm);
  max-width: 75%;

  /* Entry animation via @starting-style */
  opacity: 1;
  transform: translateY(0);
  transition:
    transform 250ms var(--ease-out),
    opacity 250ms var(--ease-out);

  @starting-style {
    opacity: 0;
    transform: translateY(8px);
  }
}

.chat-bubble.assistant { align-self: flex-start; }
.chat-bubble.user { align-self: flex-end; flex-direction: row-reverse; }

.chat-bubble .bubble-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
}

.chat-bubble.assistant .bubble-icon { color: var(--nx-accent-soft); }
.chat-bubble.user .bubble-icon { color: #94a3b8; }

.chat-bubble .bubble-content {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.6;
  word-wrap: break-word;
}

.chat-bubble.assistant .bubble-content {
  background: rgba(184, 134, 11, 0.06);
  color: var(--nx-text-on-dark);
  border-top-left-radius: 2px;
}

.chat-bubble.user .bubble-content {
  background: var(--nx-accent);
  color: var(--nx-primary);
  border-top-right-radius: 2px;
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 0.5rem 0;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--nx-accent-soft);
  border-radius: 50%;
  animation: typingBounce 1.4s var(--ease-out) infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Chat input */
.chat-input-area {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid rgba(184, 134, 11, 0.1);
  display: flex;
  gap: var(--space-sm);
}

.chat-input-area input {
  flex: 1;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(184, 134, 11, 0.15);
  border-radius: var(--radius-md);
  color: var(--nx-text-on-dark);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: border-color 200ms var(--ease-out);
}

.chat-input-area input::placeholder {
  color: var(--nx-text-on-dark-muted);
}

.chat-input-area input:focus {
  outline: none;
  border-color: var(--nx-accent);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.1);
}

.chat-input-area .btn {
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   11. CONTACT & TRUST SECTION
   -------------------------------------------------------------------------- */
.contact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-xl);
}

.contact-card {
  text-align: center;
  padding: var(--space-2xl);
  background: var(--nx-surface-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid var(--nx-border-light);
  transition: box-shadow 250ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .contact-card:hover {
    box-shadow: 0 4px 20px rgba(11, 18, 32, 0.06);
  }
}

.contact-card .contact-icon {
  font-size: 1.75rem;
  color: var(--nx-accent);
  margin-bottom: var(--space-md);
}

.contact-card h4 {
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--nx-primary);
  margin-bottom: var(--space-xs);
}

.contact-card p,
.contact-card a {
  font-size: 0.875rem;
  color: var(--nx-text-secondary);
  text-decoration: none;
}

.contact-card a:hover {
  color: var(--nx-accent);
}

/* --------------------------------------------------------------------------
   12. FOOTER
   -------------------------------------------------------------------------- */
.site-footer {
  background: var(--nx-primary);
  color: var(--nx-text-on-dark-muted);
  padding: var(--space-3xl) var(--space-2xl);
  text-align: center;
  border-top: 1px solid rgba(184, 134, 11, 0.2);
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  align-items: center;
}

.footer-brand {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--nx-text-on-dark);
}

.footer-links {
  display: flex;
  gap: var(--space-xl);
  list-style: none;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  color: var(--nx-text-on-dark-muted);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 180ms var(--ease-out);
}

.footer-links a:hover {
  color: var(--nx-accent-soft);
}

.footer-copy {
  font-size: 0.8125rem;
  color: var(--nx-text-on-dark-muted);
}

/* --------------------------------------------------------------------------
   13. RESPONSIVE
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .site-nav {
    padding: 0 var(--space-md);
  }

  .nav-links {
    display: none;
  }

  .nav-toggle {
    display: block;
  }

  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: rgba(11, 18, 32, 0.98);
    backdrop-filter: blur(12px);
    padding: var(--space-lg) var(--space-md);
    gap: var(--space-md);
    border-bottom: 1px solid rgba(184, 134, 11, 0.2);
  }

  .hero {
    padding: var(--space-3xl) var(--space-md);
    min-height: 90vh;
  }

  .hero h1 {
    font-size: clamp(1.75rem, 6vw, 2.5rem);
  }

  .hero-actions {
    flex-direction: column;
    align-items: center;
  }

  .section {
    padding: var(--space-2xl) var(--space-md);
  }

  .tech-grid {
    grid-template-columns: 1fr;
  }

  .chat-container {
    height: 400px;
  }

  .chat-bubble {
    max-width: 90%;
  }
}

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

  /* Allow opacity/color transitions for comprehension */
  .btn,
  .nav-links a,
  .service-card,
  .contact-card,
  .footer-links a {
    transition:
      color 200ms ease,
      background 200ms ease,
      box-shadow 200ms ease;
  }

  .hero-content > * {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .slide-in { transform: translateX(0); opacity: 1; }
}

/* --------------------------------------------------------------------------
   15. UTILITY CLASSES
   -------------------------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
}

.text-accent { color: var(--nx-accent); }
.text-accent-soft { color: var(--nx-accent-soft); }