/* ============================================
   Advanced Animations & New Sections
   ============================================ */

/* ── Split Text ── */
.split-text {
  overflow: hidden;
}

.split-word {
  display: inline-block;
  white-space: nowrap;
}

.split-char {
  display: inline-block;
  opacity: 0;
  transform: translateY(100%) rotateX(-80deg);
  transform-origin: center bottom;
  transition: none;
}

.split-text.animated .split-char {
  animation: char-reveal 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(var(--ci) * 0.03s);
}

@keyframes char-reveal {
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

/* ── Stagger Groups ── */
.stagger-group .stagger-item {
  opacity: 0;
  transform: translateY(50px) scale(0.94);
  filter: blur(6px);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              filter 0.7s ease;
}

.stagger-group.visible .stagger-item:nth-child(1) { transition-delay: 0.05s; }
.stagger-group.visible .stagger-item:nth-child(2) { transition-delay: 0.15s; }
.stagger-group.visible .stagger-item:nth-child(3) { transition-delay: 0.25s; }
.stagger-group.visible .stagger-item:nth-child(4) { transition-delay: 0.35s; }
.stagger-group.visible .stagger-item:nth-child(5) { transition-delay: 0.45s; }

.stagger-group.visible .stagger-item {
  opacity: 1;
  transform: translateY(0) scale(1);
  filter: blur(0);
}

/* ── Glow Cards (mouse spotlight) ── */
.glow-card {
  position: relative;
  overflow: hidden;
  --mx: 50%;
  --my: 50%;
}

.glow-card .bento-glow,
.glow-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    500px circle at var(--mx) var(--my),
    rgba(108, 92, 231, 0.12),
    transparent 40%
  );
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
  z-index: 0;
}

.glow-card:hover::before,
.glow-card:hover .bento-glow {
  opacity: 1;
}

.glow-card > *:not(.bento-glow) {
  position: relative;
  z-index: 1;
}

/* ── Section backgrounds ── */
.section-parallax-inner {
  position: absolute;
  inset: -20% 0;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}

.section-bg-mesh {
  background:
    radial-gradient(ellipse 50% 40% at 20% 30%, var(--hero-glow-1), transparent),
    radial-gradient(ellipse 40% 50% at 80% 70%, var(--hero-glow-2), transparent),
    radial-gradient(ellipse 45% 35% at 55% 15%, var(--hero-glow-3, transparent), transparent);
  opacity: 0.6;
}

.section-bg-dots {
  background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 50%, black, transparent);
  opacity: 0.5;
}

.section-in-view .section-parallax-inner {
  animation: mesh-pulse 8s ease-in-out infinite;
}

@keyframes mesh-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}

.section > .container {
  position: relative;
  z-index: 1;
}

/* ============================================
   About — Bento Grid
   ============================================ */

.about-bento {
  display: grid;
  grid-template-columns: minmax(220px, 260px) 1fr 1fr minmax(110px, 130px);
  grid-template-rows: auto auto auto;
  gap: 16px;
  margin-bottom: 24px;
}

.bento-photo {
  grid-column: 1;
  grid-row: 1 / 3;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bento-photo-wrap {
  position: relative;
  width: 100%;
  height: 280px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  transition: box-shadow 0.45s ease, transform 0.45s ease;
}

.bento-photo-inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  overflow: hidden;
  background: var(--bg-secondary);
}

.bento-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  transition:
    transform 0.65s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.65s cubic-bezier(0.22, 1, 0.36, 1);
  transform: translateZ(0);
}

.bento-photo-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
}

/* ── frame: градиентная рамка, естественные цвета ── */
.bento-photo[data-photo-style="frame"] .bento-photo-wrap,
.bento-photo:not([data-photo-style]) .bento-photo-wrap {
  padding: 3px;
  background: var(--accent-gradient);
  box-shadow: 0 14px 44px rgba(108, 92, 231, 0.22);
}

.bento-photo[data-photo-style="frame"] .bento-photo-inner,
.bento-photo:not([data-photo-style]) .bento-photo-inner {
  border-radius: calc(var(--radius-md) - 2px);
}

.bento-photo[data-photo-style="frame"] .bento-photo-img,
.bento-photo:not([data-photo-style]) .bento-photo-img {
  filter: contrast(1.07) saturate(0.94) brightness(1.03);
}

.bento-photo[data-photo-style="frame"] .bento-photo-overlay,
.bento-photo:not([data-photo-style]) .bento-photo-overlay {
  opacity: 1;
  background: linear-gradient(to top, rgba(8, 8, 18, 0.5) 0%, transparent 42%);
}

/* ── mono: ч/б, строго и по-редакторски ── */
.bento-photo[data-photo-style="mono"] .bento-photo-wrap {
  padding: 0;
  border: 1px solid var(--border-color);
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
}

.bento-photo[data-photo-style="mono"] .bento-photo-img {
  filter: grayscale(1) contrast(1.22) brightness(1.06);
}

.bento-photo[data-photo-style="mono"] .bento-photo-overlay {
  opacity: 1;
  background:
    linear-gradient(135deg, rgba(108, 92, 231, 0.18) 0%, transparent 55%),
    linear-gradient(to top, rgba(0, 0, 0, 0.35) 0%, transparent 38%);
  mix-blend-mode: soft-light;
}

/* ── noir: тёмный кинематограф + акцентное свечение (default) ── */
.bento-photo[data-photo-style="noir"] .bento-photo-wrap {
  padding: 0;
  box-shadow:
    0 0 0 1px rgba(108, 92, 231, 0.35),
    0 0 28px rgba(108, 92, 231, 0.2),
    0 18px 48px rgba(0, 0, 0, 0.45);
}

.bento-photo[data-photo-style="noir"] .bento-photo-img {
  filter: contrast(1.14) saturate(0.82) brightness(0.8);
}

.bento-photo[data-photo-style="noir"] .bento-photo-overlay {
  opacity: 1;
  background:
    radial-gradient(ellipse 90% 70% at 85% 8%, rgba(108, 92, 231, 0.42) 0%, transparent 52%),
    radial-gradient(ellipse 100% 90% at 50% 110%, rgba(0, 0, 0, 0.55) 0%, transparent 48%),
    linear-gradient(to top, rgba(6, 6, 14, 0.65) 0%, transparent 45%);
}

/* clip-path на высокой ячейке с фото даёт сбой на десктопе */
.bento-photo.bento-cell {
  clip-path: none;
}

.bento-photo.bento-cell:not(.visible) {
  opacity: 0;
  transform: translateY(24px) scale(0.98);
}

.bento-photo:hover .bento-photo-img {
  transform: scale(1.04);
}

.bento-photo[data-photo-style="frame"]:hover .bento-photo-wrap,
.bento-photo:not([data-photo-style]):hover .bento-photo-wrap {
  box-shadow: 0 18px 52px rgba(108, 92, 231, 0.32);
}

.bento-photo[data-photo-style="mono"]:hover .bento-photo-img {
  filter: grayscale(1) contrast(1.28) brightness(1.08);
}

.bento-photo[data-photo-style="noir"]:hover .bento-photo-wrap {
  box-shadow:
    0 0 0 1px rgba(108, 92, 231, 0.5),
    0 0 36px rgba(108, 92, 231, 0.3),
    0 22px 56px rgba(0, 0, 0, 0.5);
}

.bento-photo[data-photo-style="noir"]:hover .bento-photo-img {
  filter: contrast(1.18) saturate(0.88) brightness(0.85);
}

[data-theme="light"] .bento-photo[data-photo-style="frame"] .bento-photo-wrap,
[data-theme="light"] .bento-photo:not([data-photo-style]) .bento-photo-wrap {
  box-shadow: 0 14px 40px rgba(91, 76, 219, 0.16);
}

[data-theme="light"] .bento-photo[data-photo-style="mono"] .bento-photo-wrap {
  box-shadow: 0 14px 36px rgba(91, 76, 219, 0.12);
}

[data-theme="light"] .bento-photo[data-photo-style="mono"] .bento-photo-img {
  filter: grayscale(1) contrast(1.16) brightness(1.02);
}

[data-theme="light"] .bento-photo[data-photo-style="noir"] .bento-photo-wrap {
  box-shadow:
    0 0 0 1px rgba(91, 76, 219, 0.28),
    0 0 24px rgba(91, 76, 219, 0.14),
    0 16px 40px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .bento-photo[data-photo-style="noir"] .bento-photo-img {
  filter: contrast(1.1) saturate(0.88) brightness(0.9);
}

[data-theme="light"] .bento-photo[data-photo-style="noir"] .bento-photo-overlay {
  background:
    radial-gradient(ellipse 90% 70% at 85% 8%, rgba(91, 76, 219, 0.28) 0%, transparent 52%),
    radial-gradient(ellipse 100% 90% at 50% 110%, rgba(0, 0, 0, 0.2) 0%, transparent 48%),
    linear-gradient(to top, rgba(20, 20, 40, 0.4) 0%, transparent 45%);
}

.bento-photo-meta {
  text-align: center;
}

.bento-photo-meta strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 2px;
}

.bento-photo-meta span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.bento-main {
  grid-column: 2 / 4;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 280px;
}

.bento-sign {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.about-bento .bento-stat:nth-of-type(3) {
  grid-column: 4;
  grid-row: 1;
}

.about-bento .bento-stat:nth-of-type(4) {
  grid-column: 4;
  grid-row: 2;
}

.bento-code {
  grid-column: 1;
  grid-row: 3;
}

.bento-focus {
  grid-column: 2;
  grid-row: 3;
}

.bento-location {
  grid-column: 3 / 5;
  grid-row: 3;
}

.bento-cell {
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  opacity: 0;
  transform: translateY(30px) scale(0.96);
  clip-path: inset(0 0 100% 0);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              clip-path 0.8s cubic-bezier(0.22, 1, 0.36, 1),
              border-color var(--transition-base),
              box-shadow var(--transition-base);
}

.bento-cell.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  clip-path: inset(0 0 0 0);
}

.bento-cell:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-4px) scale(1);
}

.bento-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-primary);
  margin-bottom: 12px;
  display: block;
}

.bento-quote {
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 1.6;
  color: var(--text-primary);
  margin: 0 0 24px;
  font-style: normal;
}

.bento-stat {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-height: 120px;
}

.bento-stat-value {
  font-size: 2.5rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
}

.bento-stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.bento-code-snippet {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.8;
  color: var(--text-secondary);
  margin: 0;
}

.bento-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bento-list li {
  position: relative;
  padding-left: 18px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.bento-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
}

.bento-location {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.bento-location-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-gradient);
  border-radius: 50%;
  margin-bottom: 10px;
  color: #fff;
}

.bento-location-icon svg {
  width: 22px;
  height: 22px;
}

.bento-location strong {
  font-size: 1.1rem;
  display: block;
  margin: 4px 0;
}

.bento-location p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

.about-principles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.principle-card {
  padding: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: transform var(--transition-base), border-color var(--transition-base);
}

.principle-card:hover {
  transform: translateY(-6px);
  border-color: var(--accent-primary);
}

.principle-num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-primary);
  margin-bottom: 12px;
  display: block;
}

.principle-card h4 {
  font-size: 1.05rem;
  margin-bottom: 8px;
}

.principle-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin: 0;
}

/* ============================================
   Process Timeline
   ============================================ */

.process {
  position: relative;
  overflow: hidden;
}

.process-timeline {
  position: relative;
  max-width: 700px;
  margin: 0 auto;
  padding-left: 40px;
}

.process-line {
  position: absolute;
  left: 11px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}

.process-line-fill {
  width: 100%;
  height: 0%;
  background: var(--accent-gradient);
  border-radius: 2px;
  transition: height 0.1s linear;
  box-shadow: 0 0 12px var(--accent-glow);
}

.process-step {
  position: relative;
  margin-bottom: 40px;
  opacity: 0.4;
  transform: translateX(20px);
  transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.process-step:last-child {
  margin-bottom: 0;
}

.process-step.active {
  opacity: 1;
  transform: translateX(0);
}

.process-dot {
  position: absolute;
  left: -40px;
  top: 24px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  transition: border-color 0.4s, box-shadow 0.4s, transform 0.4s;
  z-index: 1;
}

.process-step.active .process-dot {
  border-color: var(--accent-primary);
  box-shadow: 0 0 20px var(--accent-glow);
  transform: scale(1.15);
}

.process-step.active .process-dot::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--accent-gradient);
  animation: dot-pulse 2s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.85); }
}

.process-card {
  padding: 28px 32px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.process-step.active .process-card {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.process-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-primary);
  margin-bottom: 8px;
  display: block;
}

.process-card h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
}

.process-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0;
}

/* ============================================
   FAQ
   ============================================ */

.faq {
  position: relative;
  overflow: hidden;
}

.faq-list {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.faq-item.open {
  border-color: var(--accent-primary);
  box-shadow: 0 0 24px var(--accent-glow);
}

.faq-question {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
  cursor: none;
  transition: color var(--transition-fast);
}

.faq-question:hover {
  color: var(--accent-primary);
}

.faq-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), color var(--transition-fast);
}

.faq-item.open .faq-icon {
  transform: rotate(180deg);
  color: var(--accent-primary);
}

.faq-answer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.faq-item.open .faq-answer {
  max-height: 320px;
}

.faq-answer p {
  padding: 0 24px 20px;
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ── Enhanced section headers on scroll ── */
.section-in-view .section-tag {
  animation: tag-glow 2s ease-in-out infinite;
}

@keyframes tag-glow {
  0%, 100% { box-shadow: 0 0 0 transparent; }
  50% { box-shadow: 0 0 20px var(--accent-glow); }
}

/* ── Stack cards enhanced ── */
.stack-card.glow-card::before {
  border-radius: var(--radius-lg);
}

.stagger-group.visible .stack-card {
  animation: card-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

/* ── Service cards entrance ── */
.services-grid .service-card {
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow var(--transition-base),
              border-color var(--transition-base);
}

.service-card.visible {
  animation: card-slide-up 0.8s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

@keyframes card-slide-up {
  from {
    opacity: 0;
    transform: translateY(60px) rotateX(8deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

@keyframes card-pop {
  from { transform: scale(0.9); }
  to { transform: scale(1); }
}

/* ── Project cards 3D lift ── */
.project-card {
  transform-style: preserve-3d;
  perspective: 1000px;
}

.project-card.visible {
  animation: project-enter 0.9s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

@keyframes project-enter {
  from {
    opacity: 0;
    transform: translateY(80px) rotateX(12deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

/* ── Contact cards wave ── */
.contact-card {
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              border-color var(--transition-base);
}

.contact-card.visible {
  animation: contact-wave 0.7s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}

@keyframes contact-wave {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .about-bento {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto;
  }

  .bento-photo {
    grid-column: 1;
    grid-row: auto;
  }

  .bento-photo-wrap {
    height: 320px;
  }

  .bento-main {
    grid-column: 2;
    grid-row: auto;
    min-height: auto;
  }

  .about-bento .bento-stat:nth-of-type(3),
  .about-bento .bento-stat:nth-of-type(4) {
    grid-column: auto;
    grid-row: auto;
  }

  .bento-code,
  .bento-focus,
  .bento-location {
    grid-column: auto;
    grid-row: auto;
  }

  .bento-location {
    grid-column: 1 / -1;
  }

  .about-principles {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .about-bento {
    grid-template-columns: 1fr;
  }

  .bento-photo-wrap {
    height: 280px;
  }

  .bento-main {
    grid-column: 1;
  }

  .bento-quote {
    font-size: 1.05rem;
  }

  .process-timeline {
    padding-left: 32px;
  }

  .process-dot {
    left: -32px;
    width: 20px;
    height: 20px;
  }

  .split-text.animated .split-char {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .stagger-group .stagger-item {
    opacity: 1;
    transform: none;
    filter: none;
  }

  .bento-cell {
    opacity: 1;
    transform: none;
    clip-path: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .split-char,
  .stagger-item,
  .bento-cell,
  .process-step {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    clip-path: none !important;
    animation: none !important;
  }
}
