/* ============================================================
   CSS Custom Properties & Theme — MASYA Portfolio v2
   ============================================================ */
:root {
  --accent: #FF0055;        /* Neon Ruby — главный акцент */
  --accent-rgb: 255, 0, 85;
  --accent-2: #FBBF24;      /* Golden Amber — второй акцент */
  --accent-2-rgb: 251, 191, 36;
  --bg-primary: #0D0C1D;    /* Obsidian — основной фон */
  --bg-secondary: #141A29;  /* Deep Navy — карточки */
  --text-primary: #F1F5F9;
  --text-muted: #64748B;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

/* ============================================================
   Base
   ============================================================ */
html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ============================================================
   Noise / Grain Texture Overlay
   ============================================================ */
.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 99998;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

/* ============================================================
   Glassmorphism Components
   ============================================================ */
.glass-nav {
  background: rgba(13, 12, 29, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.glass-nav.scrolled {
  background: rgba(13, 12, 29, 0.92);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
}

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              border-color 0.4s ease,
              box-shadow 0.4s ease;
  will-change: transform;
  position: relative;
  overflow: hidden;
}

/* Noise texture on cards */
.glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.025;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 128px 128px;
  pointer-events: none;
  z-index: 0;
}

.glass-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: rgba(var(--accent-rgb), 0.3);
  box-shadow: 0 12px 40px rgba(var(--accent-rgb), 0.15), var(--glass-shadow);
}

.glass-card > * {
  position: relative;
  z-index: 1;
}

.glass-btn {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.glass-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(var(--accent-rgb), 0.5);
  transform: translateY(-1px);
}

.glass-btn-accent {
  background: rgba(var(--accent-rgb), 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  color: var(--accent);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.glass-btn-accent:hover {
  background: rgba(var(--accent-rgb), 0.25);
  border-color: rgba(var(--accent-rgb), 0.6);
  box-shadow: 0 0 30px rgba(var(--accent-rgb), 0.2), 0 0 60px rgba(var(--accent-rgb), 0.1);
  transform: translateY(-2px) scale(1.02);
}

/* Glow pulse animation on accent buttons */
.glass-btn-accent::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: conic-gradient(
    from 0deg,
    transparent,
    rgba(var(--accent-rgb), 0.3),
    transparent,
    rgba(var(--accent-rgb), 0.3),
    transparent 60%,
    rgba(var(--accent-rgb), 0.2),
    transparent
  );
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
  z-index: -1;
}

.glass-btn-accent:hover::after {
  opacity: 1;
  animation: borderRotate 2s linear infinite;
}

/* ============================================================
   Active Click — микро-анимация нажатия
   ============================================================ */
.glass-btn:active,
.glass-btn-accent:active,
.decor-toggle:active,
.project-card a:active {
  transform: scale(0.95) !important;
  transition: transform 0.1s ease !important;
}

/* ============================================================
   Glow Circles (Background) — Neon Ruby + Golden Amber
   ============================================================ */
.glow-circle {
  filter: blur(120px);
  will-change: transform;
}

@media (max-width: 768px) {
  .glow-circle {
    animation: breathe 6s ease-in-out infinite;
  }
}

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.glow-ruby {
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.5), transparent 70%);
}

.glow-amber {
  background: radial-gradient(circle, rgba(var(--accent-2-rgb), 0.4), transparent 70%);
}

.glow-ruby-light {
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.2), transparent 70%);
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -30px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(20px, 30px) scale(1.02); }
}

/* ============================================================
   Reveal Animation (Intersection Observer)
   ============================================================ */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal.delay-100 { transition-delay: 0.1s; }
.reveal.delay-200 { transition-delay: 0.2s; }
.reveal.delay-300 { transition-delay: 0.3s; }
.reveal.delay-400 { transition-delay: 0.4s; }
.reveal.delay-500 { transition-delay: 0.5s; }
.reveal.delay-600 { transition-delay: 0.6s; }
.reveal.delay-700 { transition-delay: 0.7s; }

/* ============================================================
   Split Text Reveal — побуквенное появление
   ============================================================ */
.split-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(30px) rotateX(40deg);
  transition: opacity 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform, opacity;
}

.split-word.visible {
  opacity: 1;
  transform: translateY(0) rotateX(0deg);
}

/* ============================================================
   3D Tilt Hero Container
   ============================================================ */
.hero-3d {
  perspective: 1000px;
  transform-style: preserve-3d;
}

.hero-3d-inner {
  transition: transform 0.1s ease-out;
  transform-style: preserve-3d;
  will-change: transform;
}

/* ============================================================
   Tech Cards — Neon Ruby стиль
   ============================================================ */
.tech-card {
  cursor: pointer;
  position: relative;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Gradient border on hover */
.tech-card::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  padding: 1px;
  background: conic-gradient(
    from 0deg,
    transparent,
    rgba(var(--accent-rgb), 0),
    rgba(var(--accent-rgb), 0.6),
    rgba(var(--accent-rgb), 0),
    transparent 60%,
    rgba(var(--accent-2-rgb), 0.4),
    transparent
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

.tech-card:hover::before {
  opacity: 1;
  animation: borderRotate 2s linear infinite;
}

@keyframes borderRotate {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Spotlight effect on tech cards */
.tech-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(var(--accent-rgb), 0.1),
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.tech-card:hover::after {
  opacity: 1;
}

.tech-card:hover {
  transform: translateY(-6px) scale(1.03);
}

/* ============================================================
   Project Cards
   ============================================================ */
.project-card {
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              border-color 0.4s ease,
              box-shadow 0.4s ease;
  will-change: transform;
}

.project-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: rgba(var(--accent-rgb), 0.35);
  box-shadow: 0 12px 40px rgba(var(--accent-rgb), 0.12), var(--glass-shadow);
}

.project-card .project-glow {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.project-card:hover .project-glow {
  opacity: 1;
}

/* ============================================================
   Project Badge
   ============================================================ */
.project-badge {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
}

/* ============================================================
   Counter Animation
   ============================================================ */
.counter-number {
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Premium Scrollbar
   ============================================================ */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: rgba(var(--accent-rgb), 0.3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--accent-rgb), 0.5);
}

/* ============================================================
   Selection — Neon Ruby
   ============================================================ */
::selection {
  background: rgba(var(--accent-rgb), 0.3);
  color: white;
}

/* ============================================================
   Preloader
   ============================================================ */
#preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#preloader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#preloader.remove {
  display: none;
}

.preloader-content {
  text-align: center;
}

.preloader-logo {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, var(--accent), #fff, var(--accent));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 2s ease-in-out infinite;
  margin-bottom: 1.5rem;
}

@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.preloader-bar {
  width: 200px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin: 0 auto;
  overflow: hidden;
}

.preloader-bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 2px;
  animation: preloaderSlide 1.5s ease-in-out infinite;
  transform: translateX(-100%);
}

@keyframes preloaderSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ============================================================
   Decor Toggle
   ============================================================ */
.decor-toggle {
  position: relative;
  cursor: pointer;
}

.decor-toggle .decor-toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.decor-toggle:hover .decor-toggle-icon {
  transform: rotate(90deg);
}

.decor-toggle.active {
  border-color: rgba(var(--accent-rgb), 0.4) !important;
  background: rgba(var(--accent-rgb), 0.1) !important;
}

.decor-toggle.active .decor-toggle-icon {
  color: var(--accent);
}

/* ============================================================
   Binary Disintegration — эффект для кнопок Telegram
   ============================================================ */
[id$="TelegramBtn"],
#tg-contact-btn {
  position: relative;
  overflow: hidden;
  transition: filter 0.2s ease, text-shadow 0.2s ease;
}

[id$="TelegramBtn"] .binary-particles,
#tg-contact-btn .binary-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

/* ============================================================
   Section Divider — Golden Amber line
   ============================================================ */
.section-divider {
  width: 3rem;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 2px;
}

/* ============================================================
   Gradient text utility
   ============================================================ */
.gradient-text {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================================
   Mobile Responsive Fixes
   ============================================================ */
@media (max-width: 400px) {
  .glow-circle {
    display: none;
  }

  #heroTitle {
    font-size: 1.75rem !important;
  }

  #heroSubtitle {
    font-size: 0.9rem !important;
  }

  .glass-btn-accent {
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
  }

  .preloader-logo {
    font-size: 2rem !important;
  }
}

@media (min-width: 401px) and (max-width: 640px) {
  #heroTitle {
    font-size: 2rem !important;
  }

  #heroSubtitle {
    font-size: 1rem !important;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  #hero {
    min-height: 120vh !important;
    padding-top: 4rem !important;
  }

  .tech-card {
    padding: 0.75rem !important;
  }

  .tech-card .text-4xl {
    font-size: 1.5rem !important;
    margin-bottom: 0.5rem !important;
  }
}

@media (max-width: 640px) {
  #techModalCard {
    padding: 1.5rem !important;
    margin: 0 0.5rem !important;
  }

  #techModalCard .text-5xl {
    font-size: 2.5rem !important;
  }

  #techModalCard h3 {
    font-size: 1.25rem !important;
  }

  footer #contacts > div {
    flex-direction: column !important;
    gap: 0.5rem !important;
  }

  footer .text-xs {
    font-size: 0.65rem !important;
  }

  .project-card .p-6 {
    padding: 1rem !important;
  }

  .project-card h3 {
    font-size: 1rem !important;
  }

  .project-card .text-sm {
    font-size: 0.8rem !important;
  }
}

/* ============================================================ */
/* Ticket System — FAB + Modal
/* ============================================================ */

/* --- FAB Button --- */
.ticket-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #cc0044);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.ticket-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(var(--accent-rgb), 0.6);
}

.ticket-fab:active {
  transform: scale(0.95);
}

.ticket-fab.active {
  background: #ef4444;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}

.ticket-fab.active:hover {
  box-shadow: 0 6px 30px rgba(239, 68, 68, 0.5);
}

/* --- Modal Backdrop --- */
.ticket-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-out;
}

.ticket-modal-backdrop.active {
  opacity: 1;
  pointer-events: all;
}

/* --- Modal Card --- */
.ticket-modal {
  width: 100%;
  max-width: 420px;
  background: rgba(13, 12, 29, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.ticket-modal.active {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* --- Modal Header --- */
.ticket-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.ticket-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.ticket-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #9ca3af;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  outline: none;
}

.ticket-modal-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* --- Modal Body --- */
.ticket-modal-body {
  padding: 16px 24px 24px;
}

.ticket-modal-description {
  font-size: 0.875rem;
  color: #9ca3af;
  margin: 0 0 20px;
  line-height: 1.5;
}

/* --- Form --- */
.ticket-form-group {
  margin-bottom: 16px;
}

.ticket-form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: #d1d5db;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ticket-form-input,
.ticket-form-textarea {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #fff;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
  box-sizing: border-box;
}

.ticket-form-input:focus,
.ticket-form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1);
  background: rgba(255, 255, 255, 0.08);
}

.ticket-form-input::placeholder,
.ticket-form-textarea::placeholder {
  color: rgba(255, 255, 255, 0.25);
}

.ticket-form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

.ticket-form-counter {
  text-align: right;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.3);
  margin-top: 4px;
}

/* --- Error / Success --- */
.ticket-form-error,
.ticket-form-success {
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  margin-bottom: 16px;
  line-height: 1.4;
  white-space: pre-line;
}

.ticket-form-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.ticket-form-success {
  background: rgba(34, 197, 94, 0.1);
  border: 1px solid rgba(34, 197, 94, 0.2);
  color: #86efac;
}

/* --- Submit Button --- */
.ticket-form-submit {
  width: 100%;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--accent), #cc0044);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  outline: none;
}

.ticket-form-submit:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.3);
}

.ticket-form-submit:active {
  transform: translateY(0);
}

.ticket-form-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* --- Spinner --- */
.ticket-spinner {
  animation: ticket-spin 1s linear infinite;
}

@keyframes ticket-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* --- Mobile adjustments --- */
@media (max-width: 480px) {
  .ticket-fab {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }

  .ticket-modal-backdrop {
    padding: 12px;
    align-items: flex-end;
  }

  .ticket-modal {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    transform: translateY(40px) scale(1);
  }

  .ticket-modal.active {
    transform: translateY(0) scale(1);
  }

  .ticket-modal-header {
    padding: 16px 20px 0;
  }

  .ticket-modal-body {
    padding: 12px 20px 20px;
  }
}

/* Убираем горизонтальный скролл */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}
