/* ============================================
   ATMAN Design System
   Платформа глубинного развития человека
   ============================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500&family=Inter:wght@300;400;500;600;700&family=Caveat:wght@400;500;600;700&display=swap');

/* --- CSS Variables --- */
:root {
  /* Primary Colors — Terracotta */
  --color-primary: #D97757;
  --color-primary-light: #E69A7B;
  --color-primary-dark: #C5563A;
  --color-primary-bg: rgba(217, 119, 87, 0.08);

  /* Secondary — Warm Brown */
  --color-secondary: #8B7355;
  --color-secondary-light: #A68968;
  --color-secondary-dark: #6B5744;

  /* Accent Colors */
  --color-gold: #D4AF37;
  --color-gold-light: #E8CC6E;
  --color-sage: #9CAF88;
  --color-sage-light: #B8C9A8;
  --color-lavender: #B8A9C9;
  --color-lavender-light: #D1C6DE;

  /* Backgrounds */
  --color-bg: #FFF9F5;
  --color-bg-secondary: #F5EDE5;
  --color-bg-tertiary: #EBE0D5;
  --color-bg-dark: #2D2420;

  /* Text */
  --color-text: #2D2420;
  --color-text-secondary: #6B5744;
  --color-text-tertiary: #9C8977;
  --color-text-inverse: #FFF9F5;

  /* Semantic */
  --color-success: #7FA883;
  --color-success-light: #E8F5E9;
  --color-warning: #E8A547;
  --color-warning-light: #FFF3E0;
  --color-error: #D17A6F;
  --color-error-light: #FDECEA;
  --color-info: #7B9DAD;
  --color-info-light: #E3F2FD;

  /* Fonts */
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-accent: 'Caveat', cursive;

  /* Font Sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;
  --text-6xl: 3.75rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Borders */
  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(45, 36, 32, 0.06);
  --shadow-md: 0 4px 12px rgba(45, 36, 32, 0.08);
  --shadow-lg: 0 8px 24px rgba(45, 36, 32, 0.12);
  --shadow-xl: 0 16px 48px rgba(45, 36, 32, 0.16);

  /* Animations */
  --ease-smooth: cubic-bezier(0.4, 0.0, 0.2, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --ease-enter: cubic-bezier(0.0, 0.0, 0.2, 1);
  --duration-fast: 150ms;
  --duration-base: 300ms;
  --duration-slow: 500ms;
  --duration-slower: 800ms;

  /* Layout */
  --container-max: 1200px;
  --container-narrow: 800px;
  --header-height: 72px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-smooth);
}

a:hover {
  color: var(--color-primary-dark);
}

ul, ol {
  list-style: none;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.2;
  color: var(--color-text);
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }
h5 { font-size: var(--text-xl); }
h6 { font-size: var(--text-lg); }

p {
  margin-bottom: var(--space-4);
  color: var(--color-text-secondary);
}

.text-accent {
  font-family: var(--font-accent);
}

.text-gradient {
  background: linear-gradient(135deg, var(--color-primary), var(--color-gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

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

.container--narrow {
  max-width: var(--container-narrow);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-8);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--duration-base) var(--ease-smooth);
  text-decoration: none;
  line-height: 1.4;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 4px 16px rgba(217, 119, 87, 0.3);
}

.btn--primary:hover {
  background: var(--color-primary-dark);
  box-shadow: 0 6px 20px rgba(217, 119, 87, 0.4);
  transform: translateY(-1px);
  color: white;
}

.btn--secondary {
  background: transparent;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn--secondary:hover {
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
}

.btn--ghost {
  background: transparent;
  color: var(--color-text-secondary);
}

.btn--ghost:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text);
}

.btn--lg {
  padding: var(--space-4) var(--space-10);
  font-size: var(--text-lg);
}

.btn--sm {
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
}

.btn--full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* --- Cards --- */
.card {
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-base) var(--ease-smooth);
  border: 1px solid rgba(45, 36, 32, 0.06);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card--flat {
  box-shadow: none;
  background: var(--color-bg-secondary);
}

.card--bordered {
  box-shadow: none;
  border: 1px solid var(--color-bg-tertiary);
}

/* --- Form Elements --- */
.input {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: white;
  border: 2px solid var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-smooth);
  outline: none;
}

.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-bg);
}

.input::placeholder {
  color: var(--color-text-tertiary);
}

.label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

/* --- Tags / Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge--free {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge--premium {
  background: linear-gradient(135deg, #D4AF37, #E8CC6E);
  color: white;
}

.badge--popular {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.badge--recommended {
  background: var(--color-info-light);
  color: var(--color-info);
}

/* --- Chip (Filter) --- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  background: var(--color-bg-secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-smooth);
}

.chip:hover {
  background: var(--color-bg-tertiary);
}

.chip.active {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* --- Header (Internal pages) --- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(255, 249, 245, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(45, 36, 32, 0.06);
  z-index: 100;
  transition: box-shadow var(--duration-base) var(--ease-smooth);
}

.header.scrolled {
  box-shadow: var(--shadow-sm);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.header__logo {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header__logo span {
  color: var(--color-primary);
}

.header__nav {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.header__nav a {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color var(--duration-fast);
  position: relative;
}

.header__nav a:hover,
.header__nav a.active {
  color: var(--color-primary);
}

.header__nav a.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--color-primary);
  border-radius: 1px;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Mobile menu toggle */
.header__menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
}

.header__menu-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-text);
  margin: 6px 0;
  transition: all var(--duration-base);
}

/* --- Footer --- */
.footer {
  background: var(--color-bg-dark);
  color: var(--color-text-inverse);
  padding: var(--space-16) 0 var(--space-8);
}

.footer__grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--space-12);
  margin-bottom: var(--space-12);
}

.footer__brand {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-4);
}

.footer__brand span {
  color: var(--color-primary-light);
}

.footer__desc {
  color: rgba(255, 249, 245, 0.6);
  font-size: var(--text-sm);
  line-height: 1.6;
}

.footer__title {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 249, 245, 0.4);
  margin-bottom: var(--space-4);
}

.footer__links a {
  display: block;
  color: rgba(255, 249, 245, 0.7);
  font-size: var(--text-sm);
  padding: var(--space-1) 0;
  transition: color var(--duration-fast);
}

.footer__links a:hover {
  color: var(--color-primary-light);
}

.footer__bottom {
  border-top: 1px solid rgba(255, 249, 245, 0.1);
  padding-top: var(--space-8);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-sm);
  color: rgba(255, 249, 245, 0.4);
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 36, 32, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-base) var(--ease-smooth);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-10);
  max-width: 480px;
  width: 90%;
  transform: translateY(20px) scale(0.95);
  transition: transform var(--duration-base) var(--ease-smooth);
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  background: none;
  border: none;
  font-size: var(--text-2xl);
  cursor: pointer;
  color: var(--color-text-tertiary);
  padding: var(--space-2);
}

/* --- Progress Bar --- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-gold));
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-smooth);
}

/* --- Sections --- */
.section {
  padding: var(--space-20) 0;
}

.section--alt {
  background: var(--color-bg-secondary);
}

.section__header {
  text-align: center;
  max-width: 600px;
  margin: 0 auto var(--space-12);
}

.section__subtitle {
  font-family: var(--font-accent);
  font-size: var(--text-xl);
  color: var(--color-primary);
  margin-bottom: var(--space-2);
}

.section__title {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-4);
}

.section__desc {
  font-size: var(--text-lg);
  color: var(--color-text-tertiary);
}

/* --- Rating Stars --- */
.rating {
  display: flex;
  gap: 2px;
  color: var(--color-gold);
}

.rating svg {
  width: 16px;
  height: 16px;
}

/* --- Avatar --- */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  object-fit: cover;
  background: var(--color-bg-tertiary);
}

.avatar--sm { width: 32px; height: 32px; }
.avatar--lg { width: 64px; height: 64px; }
.avatar--xl { width: 96px; height: 96px; }

/* --- Animations --- */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--duration-slow) var(--ease-enter),
              transform var(--duration-slow) var(--ease-enter);
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

.fade-in-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: opacity var(--duration-slow) var(--ease-enter),
              transform var(--duration-slow) var(--ease-enter);
}

.fade-in-left.visible {
  opacity: 1;
  transform: translateX(0);
}

.fade-in-right {
  opacity: 0;
  transform: translateX(30px);
  transition: opacity var(--duration-slow) var(--ease-enter),
              transform var(--duration-slow) var(--ease-enter);
}

.fade-in-right.visible {
  opacity: 1;
  transform: translateX(0);
}

.scale-in {
  opacity: 0;
  transform: scale(0.9);
  transition: opacity var(--duration-slow) var(--ease-enter),
              transform var(--duration-slow) var(--ease-bounce);
}

.scale-in.visible {
  opacity: 1;
  transform: scale(1);
}

/* Stagger children */
.stagger > * { transition-delay: 0ms; }
.stagger > *:nth-child(1) { transition-delay: 100ms; }
.stagger > *:nth-child(2) { transition-delay: 200ms; }
.stagger > *:nth-child(3) { transition-delay: 300ms; }
.stagger > *:nth-child(4) { transition-delay: 400ms; }
.stagger > *:nth-child(5) { transition-delay: 500ms; }
.stagger > *:nth-child(6) { transition-delay: 600ms; }

/* --- AI Assistant Widget --- */
.ai-widget {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 500;
}

.ai-widget__trigger {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(217, 119, 87, 0.4);
  transition: all var(--duration-base) var(--ease-smooth);
  color: white;
  font-size: 24px;
}

.ai-widget__trigger:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(217, 119, 87, 0.5);
}

.ai-widget__panel {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 380px;
  height: 500px;
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.95);
  transition: all var(--duration-base) var(--ease-smooth);
}

.ai-widget__panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.ai-widget__header {
  padding: var(--space-4) var(--space-5);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: white;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.ai-widget__messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.ai-widget__message {
  max-width: 85%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.ai-widget__message--bot {
  background: var(--color-bg-secondary);
  color: var(--color-text);
  align-self: flex-start;
  border-bottom-left-radius: var(--radius-sm);
}

.ai-widget__message--user {
  background: var(--color-primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: var(--radius-sm);
}

.ai-widget__input {
  display: flex;
  padding: var(--space-3);
  gap: var(--space-2);
  border-top: 1px solid var(--color-bg-tertiary);
}

.ai-widget__input input {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-bg-tertiary);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  outline: none;
}

.ai-widget__input input:focus {
  border-color: var(--color-primary);
}

.ai-widget__input button {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- Utility Classes --- */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.text-primary { color: var(--color-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.font-heading { font-family: var(--font-heading); }
.font-accent { font-family: var(--font-accent); }
.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.pt-header { padding-top: var(--header-height); }

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  h1 { font-size: var(--text-4xl); }
  h2 { font-size: var(--text-3xl); }
  .section__title { font-size: var(--text-3xl); }
  .footer__grid { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root {
    --header-height: 64px;
  }

  h1 { font-size: var(--text-3xl); }
  h2 { font-size: var(--text-2xl); }
  .section { padding: var(--space-12) 0; }
  .section__title { font-size: var(--text-2xl); }
  .container { padding: 0 var(--space-4); }

  .header__nav { display: none; }
  .header__menu-toggle { display: block; }

  .footer__grid {
    grid-template-columns: 1fr;
    gap: var(--space-8);
  }

  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }

  .ai-widget__panel {
    width: calc(100vw - var(--space-8));
    right: calc(-1 * var(--space-2));
    height: 60vh;
  }

  /* Mobile navigation overlay */
  .header__nav.mobile-open {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: var(--header-height) 0 0 0;
    background: var(--color-bg);
    padding: var(--space-8);
    gap: var(--space-6);
    z-index: 99;
  }

  .header__nav.mobile-open a {
    font-size: var(--text-lg);
  }
}

@media (max-width: 480px) {
  h1 { font-size: var(--text-2xl); }
  .btn--lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
  }
}

/* --- Page transition --- */
body {
  animation: pageEnter var(--duration-slow) var(--ease-enter);
}

@keyframes pageEnter {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

body.page-exit {
  animation: pageExit var(--duration-base) var(--ease-smooth) forwards;
}

@keyframes pageExit {
  to {
    opacity: 0;
  }
}
