/* ============================================================
   moiseev_portfolio — общие стили (тема, дизайнерские фишки)
   Подключается на всех страницах после inline <style>.
   ============================================================ */

/* ---- Light theme override ----
   Переопределяет переменные из inline-стилей страниц.
   Активируется через [data-theme="light"] на <html>. */
html[data-theme="light"] {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f0f2f8;
  --dark: #e8ebf2;
  --text: #161a26;
  --muted: #4a5266;
  --line: rgba(127, 90, 240, 0.18);
  --shadow: 0 10px 40px rgba(60, 70, 100, 0.08);
  --shadow-lg: 0 20px 60px rgba(127, 90, 240, 0.12);
  --shadow-xl: 0 30px 80px rgba(127, 90, 240, 0.18);
  --glow: 0 0 40px rgba(127, 90, 240, 0.18);
  color-scheme: light;
}
html[data-theme="light"] body {
  background: radial-gradient(ellipse at 20% 10%, rgba(127,90,240,0.18) 0%, transparent 55%),
              radial-gradient(ellipse at 80% 25%, rgba(0,183,255,0.14) 0%, transparent 55%),
              radial-gradient(ellipse at 50% 90%, rgba(44,182,125,0.12) 0%, transparent 55%),
              var(--bg) !important;
  color: var(--text) !important;
}
/* Шапка в светлой теме — лёгкий градиент в тонах body (фиолетовый/голубой/зелёный).
   На главной за прозрачной шапкой просвечивает hero-glow, на проектных страницах
   такого свечения нет и через transparent шапку виден чистый белый. Свой градиент
   даёт согласованный вид на любой странице, без «толстой белой полосы». */
html[data-theme="light"] header {
  background: linear-gradient(135deg,
    rgba(127, 90, 240, 0.10) 0%,
    rgba(0, 183, 255, 0.06) 50%,
    rgba(44, 182, 125, 0.08) 100%) !important;
  backdrop-filter: blur(20px) saturate(180%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
  box-shadow: 0 1px 0 rgba(127, 90, 240, 0.10) !important;
}

/* Inline body { overflow-x: hidden } на всех страницах ломает position: sticky
   на iOS Safari — шапка прокручивается вверх вместе с контентом. overflow-x: clip
   решает то же самое (обрезает горизонтальный overflow), но не создаёт scrolling
   ancestor и sticky продолжает работать. */
@supports (overflow-x: clip) {
  body { overflow-x: clip !important; }
  html { overflow-x: clip !important; }
}
html[data-theme="light"] footer { background: rgba(240, 242, 248, 0.95) !important; }
html[data-theme="light"] .particle { opacity: 0.18 !important; }
html[data-theme="light"] .hero h1,
html[data-theme="light"] .case-title,
html[data-theme="light"] .page-hero h1,
html[data-theme="light"] .brand strong {
  background: linear-gradient(135deg, #161a26 0%, var(--primary) 50%, var(--accent) 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
}
html[data-theme="light"] section h2 {
  background: linear-gradient(135deg, #161a26, var(--primary)) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}
html[data-theme="light"] .stat-card,
html[data-theme="light"] .skill-category,
html[data-theme="light"] .case-card,
html[data-theme="light"] .project-card,
html[data-theme="light"] .offer-card,
html[data-theme="light"] .feature-card,
html[data-theme="light"] .section-card,
html[data-theme="light"] .who-item,
html[data-theme="light"] .process-step,
html[data-theme="light"] .tech-item,
html[data-theme="light"] .showcase-stat,
html[data-theme="light"] .about-content,
html[data-theme="light"] .gallery-item,
html[data-theme="light"] .gallery-caption,
html[data-theme="light"] .filter-btn,
html[data-theme="light"] .quick-route,
html[data-theme="light"] .social-link {
  background: linear-gradient(145deg, #ffffff, #f5f6fa) !important;
  border-color: var(--line) !important;
}
html[data-theme="light"] .nav-links a,
html[data-theme="light"] .about-text p,
html[data-theme="light"] .offer-card p,
html[data-theme="light"] .who-item p,
html[data-theme="light"] .process-step p,
html[data-theme="light"] .feature-card p,
html[data-theme="light"] .psr-box p,
html[data-theme="light"] .case-subtitle,
html[data-theme="light"] .card-subtitle,
html[data-theme="light"] .hero-subtitle,
html[data-theme="light"] .case-card-content .case-desc {
  color: var(--muted) !important;
}
html[data-theme="light"] .skill-category ul li,
html[data-theme="light"] .offer-card .offer-features li,
html[data-theme="light"] .stat-label,
html[data-theme="light"] .nav-links a {
  color: #4a5266 !important;
}
html[data-theme="light"] .lang-select { background: #ffffff !important; color: var(--text) !important; }
/* старое правило теневой плашки заменено на полупрозрачную шапку выше */
/* Hero glow в светлой теме — усилить, чтобы фон не был «пустым» */
html[data-theme="light"] .hero::before {
  background: radial-gradient(circle, rgba(127,90,240,0.35) 0%, rgba(0,183,255,0.18) 40%, transparent 75%) !important;
  filter: blur(80px) !important;
}
/* Page-hero на projects.html — добавим лёгкий акцент */
html[data-theme="light"] .page-hero { position: relative; }
html[data-theme="light"] .page-hero::before {
  content: ''; position: absolute; top: -10%; left: 50%; transform: translateX(-50%);
  width: 700px; height: 360px;
  background: radial-gradient(ellipse, rgba(127,90,240,0.25) 0%, rgba(44,182,125,0.12) 50%, transparent 80%);
  filter: blur(70px); z-index: -1; pointer-events: none;
}

/* Контакты: в светлой теме нужен тёмный текст на светлом фоне; на ховере (бренд-цвета) — белый. */
html[data-theme="light"] .social-link { color: var(--text) !important; }
html[data-theme="light"] .social-link span { color: inherit !important; }
html[data-theme="light"] .social-link:hover { color: #fff !important; }
html[data-theme="light"] .social-link.telegram:hover,
html[data-theme="light"] .social-link.vk:hover { color: #fff !important; }

/* Дополнительные правки контраста в светлой теме */
html[data-theme="light"] .tech-name { color: var(--text) !important; }
html[data-theme="light"] .case-card-content h3,
html[data-theme="light"] .card-content h3,
html[data-theme="light"] .feature-card h4,
html[data-theme="light"] .process-step h4,
html[data-theme="light"] .offer-card h3,
html[data-theme="light"] .skill-category h3,
html[data-theme="light"] .who-item p,
html[data-theme="light"] .contact h2,
html[data-theme="light"] .case-title,
html[data-theme="light"] .section-card h2,
html[data-theme="light"] .stat-card { color: var(--text) !important; }
html[data-theme="light"] .stat-card .stat-label { color: #4a5266 !important; }
/* Тёмный фон под градиент-текстами в hero — он перекрывает основной текст в светлой теме */
html[data-theme="light"] .hero h1 { filter: drop-shadow(0 0 20px rgba(127, 90, 240, 0.18)) !important; }
/* Кнопки .btn (с фиолетовым/зелёным градиентом) — текст белый и в тёмной, и в светлой — оставляем. */
/* .btn-secondary прозрачная — в светлой теме нужен тёмный текст. */
html[data-theme="light"] .btn-secondary { color: var(--text) !important; border-color: rgba(127, 90, 240, 0.45) !important; }
html[data-theme="light"] .btn-secondary:hover { background: rgba(127, 90, 240, 0.08) !important; }

/* ---- Theme toggle button ---- */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface, transparent);
  color: var(--muted, #a0aec0);
  border: 1px solid var(--line, rgba(127,90,240,.2));
  cursor: pointer; font-size: 1.1rem; line-height: 1;
  transition: transform .3s ease, border-color .3s ease, color .3s ease;
  font-family: inherit;
}
.theme-toggle:hover { border-color: var(--primary, #7f5af0); color: var(--primary, #7f5af0); transform: rotate(20deg); }
.theme-toggle:active { transform: scale(0.92) rotate(20deg); }

/* ---- Иконки в заголовках секций — обёртка-бейдж ----
   Эмодзи-fallback на разных ОС в светлой теме теряют цвет, поэтому в резюме
   используем inline SVG, наследующий currentColor. Бейдж работает и для эмодзи. */
.section-card h2 .icon,
.psr-icon,
.tech-icon {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', 'EmojiOne Color', sans-serif;
  background: linear-gradient(135deg, rgba(127, 90, 240, 0.20), rgba(44, 182, 125, 0.14)) !important;
  border: 1px solid rgba(127, 90, 240, 0.45) !important;
  border-radius: 12px !important;
  line-height: 1;
  color: var(--primary, #7f5af0) !important;
  filter: none !important;
}
.section-card h2 .icon { width: 46px; height: 46px; font-size: 1.5rem !important; flex-shrink: 0; }
.section-card h2 .icon svg { width: 24px; height: 24px; display: block; }
.tech-icon { width: 56px; height: 56px; font-size: 1.8rem !important; margin: 0 auto 10px; }
.tech-icon svg { width: 30px; height: 30px; display: block; }
.psr-icon { width: 40px; height: 40px; font-size: 1.3rem !important; margin-right: 8px; }
html[data-theme="light"] .section-card h2 .icon,
html[data-theme="light"] .psr-icon,
html[data-theme="light"] .tech-icon {
  background: linear-gradient(135deg, #ece4ff, #d6f0e2) !important;
  border-color: rgba(127, 90, 240, 0.45) !important;
  color: #5a37d8 !important;
}

/* ---- Magnetic / haptic feedback for buttons ---- */
.btn, .filter-btn, .social-link, .offer-cta, .quick-route { will-change: transform; }
.btn:active, .filter-btn:active, .social-link:active,
.offer-cta:active, .quick-route:active, .theme-toggle:active {
  transform: scale(0.96) !important;
  transition: transform 80ms ease !important;
}

/* ---- AI terminal в hero ---- */
.ai-terminal {
  max-width: 560px; margin: 0 auto 36px;
  background: rgba(10, 14, 26, 0.7);
  border: 1px solid var(--line, rgba(127,90,240,.2));
  border-radius: 14px; box-shadow: var(--shadow, 0 10px 40px rgba(0,0,0,0.3));
  backdrop-filter: blur(12px);
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  text-align: left; overflow: hidden;
}
html[data-theme="light"] .ai-terminal { background: rgba(20, 24, 40, 0.92); }
.ai-terminal-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line, rgba(127,90,240,.2));
  background: rgba(0,0,0,0.25);
}
.ai-terminal-bar .dot { width: 10px; height: 10px; border-radius: 50%; background: #4a5266; }
.ai-terminal-bar .dot.r { background: #ff5f57; }
.ai-terminal-bar .dot.y { background: #febc2e; }
.ai-terminal-bar .dot.g { background: #28c940; }
.ai-terminal-bar .label { margin-left: 10px; color: #8a93a6; font-size: 0.78rem; letter-spacing: 0.04em; }
.ai-terminal-body {
  padding: 18px 20px; min-height: 152px;
  font-size: 0.92rem; line-height: 1.85; color: #cdd6f4;
}
.ai-terminal-line { display: block; opacity: 0; transform: translateY(4px); }
.ai-terminal-line.is-visible { opacity: 1; transform: none; transition: opacity .25s ease, transform .25s ease; }
.ai-terminal-line .prompt { color: #7f5af0; margin-right: 8px; font-weight: 700; }
.ai-terminal-line .ok { color: #2cb67d; font-weight: 700; }
.ai-terminal-line .accent { color: #00b7ff; }
.ai-terminal-line .typing::after {
  content: '_'; display: inline-block; margin-left: 2px;
  animation: ai-blink 1s steps(2, start) infinite;
  color: #7f5af0;
}
@keyframes ai-blink { to { visibility: hidden; } }

/* ---- View Transitions API ----
   Плавный morph hero-картинок между index ↔ project pages. */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) {
  animation-duration: 0.28s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
}

/* ---- Mobile: меньше hero terminal ---- */
@media (max-width: 600px) {
  .ai-terminal { max-width: 100%; margin-left: 12px; margin-right: 12px; }
  .ai-terminal-body { padding: 14px 16px; min-height: 130px; font-size: 0.85rem; }
}

/* ============================================================
   Mascot: AI-стикмен, плавно догоняет курсор + сидящие маскоты на углах
   ============================================================ */
.moi-mascot {
  position: fixed; top: 0; left: 0;
  width: 40px; height: 54px;
  pointer-events: none; z-index: 1500;
  will-change: transform;
  transform: translate(-200px, -200px);
  transform-origin: 50% 50%;
  filter: drop-shadow(0 3px 6px rgba(127, 90, 240, 0.32));
}
.moi-mascot svg { width: 100%; height: 100%; overflow: visible; display: block; }

/* Сидящий маскот на углу карточки — поменьше, появляется/исчезает плавно */
.moi-corner-mascot {
  position: fixed; top: 0; left: 0;
  width: 30px; height: 40px;
  pointer-events: none; z-index: 1400;
  will-change: transform, opacity;
  opacity: 0;
  transform: translate(-200px, -200px) scale(0.6);
  transform-origin: 50% 50%;
  filter: drop-shadow(0 2px 4px rgba(127, 90, 240, 0.32));
  transition: opacity 0.32s ease, scale 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.moi-corner-mascot.is-visible { opacity: 1; }
.moi-corner-mascot.is-visible .mascot-character { animation: moi-corner-enter 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
.moi-corner-mascot svg { width: 100%; height: 100%; overflow: visible; display: block; }

@keyframes moi-corner-enter {
  0%   { transform-origin: 50% 100%; transform: scale(0.4); opacity: 0; }
  100% { transform-origin: 50% 100%; transform: scale(1); opacity: 1; }
}

/* Курсорный маскот не нужен на тач-устройствах. Угловой — нужен и там. */
@media (hover: none), (pointer: coarse) {
  .moi-mascot { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .moi-mascot, .moi-corner-mascot { display: none !important; }
}

/* Halo управляется из JS через SVG transform/opacity-атрибуты.
   CSS animation не используется: transform-box: fill-box ненадёжен
   в мобильных Safari, и halo там просто не показывался. */

/* Светлая тема — приглушённая тень */
html[data-theme="light"] .moi-mascot,
html[data-theme="light"] .moi-corner-mascot { filter: drop-shadow(0 3px 6px rgba(60, 70, 100, 0.2)); }

/* Старый keyframes оставлен на случай — но он давал резкий «пульс». */
@keyframes moi-halo {
  0%   { transform: scale(1);   opacity: 0.55; }
  70%  { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}
/* Мягкое дыхание: edge-to-edge плавное расширение и сжатие, всегда видимое */
@keyframes moi-halo-breathe {
  0%, 100% { transform: scale(1.35); opacity: 0.40; }
  50%      { transform: scale(1.60); opacity: 0.65; }
}

/* ============================================================
   Мобильная навигация: узкая плашка + выезжающая панель
   ============================================================ */
/* Клон CTA «Связаться» в .nav-links нужен только в мобильном меню,
   на десктопе он не должен показываться — иначе получаются 7 пунктов и wrap. */
.nav-cta-mobile-li { display: none !important; }

.nav-burger {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: transparent;
  color: var(--muted, #a0aec0);
  border: 1px solid var(--line, rgba(127, 90, 240, .2));
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
  padding: 0;
  font-family: inherit;
  align-items: center;
  justify-content: center;
}
.nav-burger:hover { color: var(--primary, #7f5af0); border-color: var(--primary, #7f5af0); }
.nav-burger span {
  position: absolute;
  left: 9px; right: 9px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transition: top .25s ease, transform .25s ease, opacity .15s ease;
}
.nav-burger span:nth-child(1) { top: 12px; }
.nav-burger span:nth-child(2) { top: 18px; }
.nav-burger span:nth-child(3) { top: 24px; }
header nav.is-open .nav-burger span:nth-child(1) { top: 18px; transform: rotate(45deg); }
header nav.is-open .nav-burger span:nth-child(2) { opacity: 0; }
header nav.is-open .nav-burger span:nth-child(3) { top: 18px; transform: rotate(-45deg); }

@media (max-width: 768px) {
  /* Узкая плашка-шапка вместо столбца */
  header nav {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    padding: 6px 14px !important;
    min-height: 52px !important;
  }
  header .brand {
    flex: 1 1 auto;
    min-width: 0;
    width: auto !important;
    align-items: flex-start !important;
    gap: 0;
    overflow: hidden;
  }
  header .brand strong { font-size: .92rem !important; line-height: 1.15 !important; }
  header .brand span { font-size: .68rem !important; line-height: 1.15 !important; }

  /* Большая CTA в шапке прячется — клон есть в выезжающем меню */
  header nav > a.btn { display: none !important; }

  /* Компактные toggle/dropdown */
  .theme-toggle { width: 32px !important; height: 32px !important; font-size: 1rem !important; }
  .lang-select { padding: 3px 6px !important; font-size: .78rem !important; }

  /* Бургер */
  .nav-burger { display: inline-flex !important; }

  /* Выезжающая панель. В закрытом виде:
       - max-height: 0 + overflow: hidden — содержимое схлопнуто
       - visibility: hidden — на iOS Safari это страхует от случаев,
         когда max-height:0 не убирает фон box-shadow или border
       - padding/shadow/border занулены, чтобы не оставались полоски
     В открытом — наоборот. */
  html body header .nav-links {
    position: fixed !important;
    top: var(--moi-header-h, 52px) !important;
    left: 0 !important;
    right: 0 !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
    margin: 0 !important;
    padding: 0 24px !important;
    background: rgba(10, 14, 26, 0.97);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid transparent !important;
    box-shadow: none !important;
    list-style: none !important;
    width: auto !important;
    max-height: 0 !important;
    overflow: hidden !important;
    visibility: hidden;
    transition: max-height .35s cubic-bezier(.4, 0, .2, 1),
                padding .35s ease,
                box-shadow .25s ease,
                border-bottom-color .25s ease,
                visibility 0s linear .35s !important;
    z-index: 998;
    pointer-events: none;
    transform: none !important;
  }
  html[data-theme="light"] header .nav-links {
    background: rgba(255, 255, 255, 0.97);
  }
  html body header nav.is-open .nav-links {
    max-height: calc(100vh - var(--moi-header-h, 52px)) !important;
    padding: 14px 24px 22px !important;
    border-bottom: 1px solid var(--line) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .5) !important;
    overflow-y: auto !important;
    visibility: visible;
    pointer-events: auto;
    transition: max-height .35s cubic-bezier(.4, 0, .2, 1),
                padding .35s ease,
                box-shadow .25s ease,
                border-bottom-color .25s ease,
                visibility 0s !important;
  }
  html[data-theme="light"] header nav.is-open .nav-links {
    border-bottom-color: rgba(127, 90, 240, .2) !important;
  }
  header .nav-links li {
    width: 100%;
    list-style: none;
  }
  /* В мобильном меню клон CTA показываем */
  .nav-cta-mobile-li { display: list-item !important; width: 100% !important; }
  header .nav-links a {
    display: block;
    padding: 10px 4px;
    font-size: 1.05rem;
    width: 100%;
  }

  /* CTA-кнопка внутри меню */
  header .nav-links .nav-cta-mobile {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 12px 22px !important;
    border-radius: 999px !important;
    background: linear-gradient(135deg, var(--accent), var(--primary)) !important;
    color: #fff !important;
    text-decoration: none;
    font-weight: 800;
    font-size: .95rem;
    width: auto !important;
    box-shadow: 0 8px 24px rgba(127, 90, 240, .35);
  }
  header .nav-links .nav-cta-mobile::after { content: none; }

  body.nav-open { overflow: hidden; }
}

@media (max-width: 380px) {
  header .brand strong { font-size: .85rem !important; }
  header .brand span { display: none !important; }
}

/* Прогресс-бар оставляем на самом верху страницы (исходное поведение).
   Белая «полоса» под ним убирается через прозрачную шапку выше. */
