/* ================================
   ММ-Дизайн — Custom Styles
   ================================ */

/* --- Font Fallback Size-Adjust --- */
@font-face {
  font-family: 'Cormorant Garamond Fallback';
  src: local('Georgia');
  size-adjust: 105%;
  ascent-override: 95%;
  descent-override: 22%;
  line-gap-override: 0%;
}

@font-face {
  font-family: 'Inter Fallback';
  src: local('Arial');
  size-adjust: 107%;
  ascent-override: 90%;
  descent-override: 22%;
  line-gap-override: 0%;
}

/* --- Scroll Progress Bar --- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #C4A97D, #D4BC94, #C4A97D);
  transform: scaleX(0);
  transform-origin: left;
  z-index: 9999;
  pointer-events: none;
  transition: transform 0.1s linear;
}

/* --- Navigation --- */
.nav-link {
  position: relative;
  font-size: 0.9rem;
  font-weight: 400;
  color: #6B6560;
  transition: color 0.3s;
  padding: 0.25rem 0;
}

.nav-link:hover,
.nav-link.active {
  color: #C4A97D;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: #C4A97D;
}

.nav-link-mobile {
  font-size: 0.95rem;
  color: #6B6560;
  padding: 0.5rem 0;
  transition: color 0.3s;
}

.nav-link-mobile:hover,
.nav-link-mobile.active {
  color: #C4A97D;
}

/* --- Header scroll transform --- */
#header {
  transition: box-shadow 0.3s ease, background-color 0.3s ease;
}

#header .header-logo {
  transition: font-size 0.3s ease;
}

.header-scrolled {
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08) !important;
  background-color: rgba(255, 255, 255, 0.98) !important;
}

.header-scrolled .header-logo {
  font-size: 1.5rem !important;
}

/* --- Buttons --- */
.btn-primary {
  display: inline-block;
  padding: 0.875rem 2rem;
  background-color: #C4A97D;
  color: white;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
  transition: left 0.5s ease;
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:hover {
  background-color: #B09468;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(196, 169, 125, 0.35);
}

.btn-secondary {
  display: inline-block;
  padding: 0.875rem 2rem;
  border: 1.5px solid #C4A97D;
  color: #C4A97D;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  text-decoration: none;
}

.btn-secondary:hover {
  background-color: #C4A97D;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(196, 169, 125, 0.25);
}

/* --- Cards --- */
.advantage-card {
  background: white;
  border-radius: 1rem;
  padding: 2rem;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  border: 1px solid transparent;
  contain: layout style;
}

.advantage-card:hover {
  border-color: rgba(196, 169, 125, 0.2);
  box-shadow: 0 12px 40px rgba(107, 101, 96, 0.1);
  transform: translateY(-6px);
}

.advantage-card:hover .advantage-icon {
  transform: scale(1.1) rotate(5deg);
}

.advantage-icon {
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* --- Portfolio Cards with Overlay --- */
.portfolio-card {
  display: block;
  text-decoration: none;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  contain: layout style;
}

.portfolio-card:hover {
  transform: translateY(-6px);
}

.portfolio-card-image {
  position: relative;
  overflow: hidden;
}

.portfolio-card-image img {
  transition: transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94), filter 0.5s ease;
}

.portfolio-card:hover .portfolio-card-image img {
  transform: scale(1.08);
  filter: brightness(0.8);
}

.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0.1) 40%, transparent 100%);
  opacity: 0;
  transition: opacity 0.4s ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 1.5rem;
  border-radius: 0.75rem;
}

.portfolio-card:hover .card-overlay {
  opacity: 1;
}

.card-overlay-text {
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transform: translateY(10px);
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.portfolio-card:hover .card-overlay-text {
  transform: translateY(0);
}

/* Gold bottom border on hover */
.portfolio-card-image::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #C4A97D, #D4BC94);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  z-index: 2;
}

.portfolio-card:hover .portfolio-card-image::after {
  transform: scaleX(1);
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.8s ease-out both;
}

.animate-fade-in-up {
  animation: fadeInUp 0.8s ease-out both;
}

/* Scroll animations — progressive enhancement */
.scroll-animate {
  opacity: 1;
  transform: translateY(0);
}

.js-scroll-ready .scroll-animate {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s ease-out, transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transition-delay: var(--delay, 0s);
}

.js-scroll-ready .scroll-animate.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Text Reveal --- */
.text-reveal {
  overflow: hidden;
  display: inline-block;
}

.text-reveal-word {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
}

.text-reveal-inner {
  display: inline-block;
  transform: translateY(110%);
  transition: transform 0.6s cubic-bezier(0.77, 0, 0.175, 1);
  transition-delay: var(--word-delay, 0s);
}

.text-reveal.revealed .text-reveal-inner {
  transform: translateY(0);
}

/* Clip Reveal for labels */
.clip-reveal {
  clip-path: inset(0 100% 0 0);
  transition: clip-path 0.8s cubic-bezier(0.77, 0, 0.175, 1);
  transition-delay: var(--reveal-delay, 0s);
}

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

/* --- Image Reveal (curtain wipe) --- */
.image-reveal {
  position: relative;
  overflow: hidden;
}

.image-reveal::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #C4A97D, #D4BC94);
  z-index: 2;
  transform: scaleX(1);
  transform-origin: right;
  transition: transform 0.8s cubic-bezier(0.77, 0, 0.175, 1);
  transition-delay: 0.1s;
}

.image-reveal.revealed::before {
  transform: scaleX(0);
}

/* --- Section Dividers --- */
.section-divider {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  line-height: 0;
  overflow: hidden;
}

.section-divider svg {
  display: block;
  width: 100%;
  height: auto;
}

.section-divider-top {
  position: absolute;
  top: -1px;
  left: 0;
  width: 100%;
  line-height: 0;
  overflow: hidden;
}

.section-divider-top svg {
  display: block;
  width: 100%;
  height: auto;
}

/* --- Hero Section --- */
.hero-section {
  position: relative;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center;
  will-change: transform;
}

.hero-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    180deg,
    rgba(245, 240, 235, 0.92) 0%,
    rgba(245, 240, 235, 0.85) 30%,
    rgba(245, 240, 235, 0.70) 60%,
    rgba(196, 169, 125, 0.15) 100%
  );
}

.hero-content {
  position: relative;
  z-index: 2;
}

/* Floating circles */
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-20px) rotate(3deg); }
}

@keyframes float-reverse {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(15px) rotate(-2deg); }
}

@keyframes float-slow {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-12px) scale(1.02); }
}

.floating-circle {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(196, 169, 125, 0.15);
  pointer-events: none;
  contain: layout style paint;
}

.floating-circle:nth-child(1) {
  animation: float 7s ease-in-out infinite;
}
.floating-circle:nth-child(2) {
  animation: float-reverse 8s ease-in-out infinite;
}
.floating-circle:nth-child(3) {
  animation: float-slow 6s ease-in-out infinite;
}
.floating-circle:nth-child(4) {
  animation: float 9s ease-in-out infinite;
}
.floating-circle:nth-child(5) {
  animation: float-reverse 7.5s ease-in-out infinite;
}

/* --- Counters --- */
.counter-block {
  position: relative;
}

.counter-number {
  font-family: 'Cormorant Garamond', serif;
  font-size: 3rem;
  font-weight: 600;
  color: #C4A97D;
  line-height: 1;
}

/* --- Skeleton Shimmer --- */
.skeleton {
  background: linear-gradient(90deg, #F5F0EB 25%, #ede6de 50%, #F5F0EB 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.5rem;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-image {
  position: relative;
}

.skeleton-image img {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.skeleton-image.loaded img {
  opacity: 1;
}

.skeleton-image.loaded::before {
  display: none;
}

/* --- Project Gallery Layout --- */

/* Gallery: main image with nav arrows */
.gallery-main-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #faf8f5;
  border-radius: 16px;
  overflow: hidden;
  height: min(450px, 50vh);
  margin-bottom: 0.75rem;
}

.gallery-main-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  cursor: pointer;
  transition: opacity 0.15s;
}

/* Gallery prev/next arrows */
.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.9);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.25s, background 0.2s;
  color: #6B6560;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  z-index: 2;
}

.gallery-main-wrap:hover .gallery-nav { opacity: 1; }
.gallery-nav:hover { background: white; color: #C4A97D; }
.gallery-nav-prev { left: 12px; }
.gallery-nav-next { right: 12px; }

/* Gallery counter */
.gallery-counter {
  position: absolute;
  bottom: 10px;
  right: 14px;
  font-size: 0.75rem;
  color: rgba(107,101,96,0.45);
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.1em;
  z-index: 2;
}

/* Thumbnail strip (always horizontal, below image) */
.gallery-thumbstrip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: #C4A97D transparent;
}

.gallery-thumbstrip::-webkit-scrollbar { height: 3px; }
.gallery-thumbstrip::-webkit-scrollbar-thumb { background: #C4A97D; border-radius: 2px; }

.gallery-thumb {
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
  opacity: 0.6;
}

.gallery-thumb:hover { opacity: 0.9; }
.gallery-thumb.active { opacity: 1; }

/* Shared thumb styles */
.project-thumb {
  cursor: pointer;
}

.project-thumb img {
  display: block;
  transition: transform 0.3s ease;
}

.project-thumb:hover img {
  transform: scale(1.05);
}

.project-thumbs-wrap {
  position: relative;
}

.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: #C4A97D transparent;
}

.scrollbar-thin::-webkit-scrollbar { height: 4px; }
.scrollbar-thin::-webkit-scrollbar-track { background: transparent; }
.scrollbar-thin::-webkit-scrollbar-thumb { background: #C4A97D; border-radius: 2px; }

/* --- Lightbox Enhanced --- */
#lightbox {
  backdrop-filter: blur(12px);
  background: rgba(0, 0, 0, 0.9) !important;
}

#lightbox img {
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.lightbox-enter {
  opacity: 0 !important;
  transform: scale(0.95);
}

.lightbox-active {
  opacity: 1 !important;
  transform: scale(1);
}

.lightbox-counter {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.8rem;
  font-family: 'Inter', sans-serif;
  letter-spacing: 0.15em;
  z-index: 10;
}

/* --- Form focus enhanced --- */
input:focus,
textarea:focus {
  border-color: #C4A97D !important;
  box-shadow: 0 0 0 3px rgba(196, 169, 125, 0.1);
}

/* --- Smooth scroll --- */
html {
  scroll-behavior: smooth;
}

/* --- Selection color --- */
::selection {
  background-color: rgba(196, 169, 125, 0.2);
  color: #6B6560;
}

/* --- Film Grain Texture (CSS only) --- */
@media (prefers-reduced-motion: no-preference) {
  body::after {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 9998;
    pointer-events: none;
    opacity: 0.03;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
  }
}

/* --- Magnetic button transform --- */
.magnetic-btn {
  transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  will-change: transform;
}

/* --- Skip to content link --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 10000;
  padding: 0.75rem 1.5rem;
  background: #C4A97D;
  color: white;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
}

/* --- Focus visible --- */
:focus-visible {
  outline: 2px solid #C4A97D;
  outline-offset: 2px;
}

/* === Accessibility: prefers-reduced-motion === */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .scroll-progress {
    transition: none;
  }

  .js-scroll-ready .scroll-animate {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .floating-circle {
    animation: none !important;
  }

  .text-reveal-inner {
    transform: none;
    transition: none;
  }

  .clip-reveal {
    clip-path: none;
    transition: none;
  }

  .image-reveal::before {
    display: none;
  }

  .card-overlay {
    opacity: 1;
  }

  .card-overlay-text {
    transform: none;
  }

  body::after {
    display: none;
  }
}
