/* === Modern Portfolio Design === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0a0e1a;
  --surface: #141824;
  --surface-light: #1a1f2e;
  --text: #e8eaed;
  --text-muted: #9ca3af;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.3);
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  --radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  background-image: 
    radial-gradient(circle at 20% 10%, rgba(59, 130, 246, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.15) 0%, transparent 50%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* === Header === */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
  gap: 24px;
}

.brand-title {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 0;
  font-weight: 500;
}

.contact-wrapper {
  display: flex;
  align-items: center;
  gap: 16px;
}

.contact-master {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.contacts {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.contact-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  position: relative;
  overflow: hidden;
}

.contact-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
  opacity: 0;
  transition: var(--transition);
}

.contact-btn:hover::before {
  opacity: 1;
}

.contact-btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
  border-color: transparent;
  color: white;
  box-shadow: 0 4px 20px var(--accent-glow);
}

.contact-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px var(--accent-glow);
}

/* === Main === */
.main {
  min-height: calc(100vh - 200px);
  padding: 40px 0 60px;
}

.search-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 32px;
}

.search-input {
  flex: 1;
  max-width: 500px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 15px;
  color: var(--text);
  transition: var(--transition);
}

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

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  background: var(--surface-light);
}

.results-count {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

/* === Gallery === */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 28px;
}

@media (max-width: 768px) {
  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
  }
}

@media (max-width: 480px) {
  .gallery {
    grid-template-columns: 1fr;
  }
}

/* === Work Card === */
.work-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
}

.work-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  padding: 1px;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: var(--transition);
  pointer-events: none;
}

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

.work-card:hover::before {
  opacity: 1;
}

.work-card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, #1a1f2e 0%, #0f1419 100%);
  overflow: hidden;
}

.work-card-media img,
.work-card-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: var(--transition);
}

.work-card:hover .work-card-media img {
  transform: scale(1.05);
}

.media-badge {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.work-card-content {
  padding: 20px;
}

.work-card-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.work-card-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.work-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface-light);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.like-btn:hover {
  background: var(--surface);
  border-color: rgba(255, 255, 255, 0.15);
  transform: scale(1.05);
}

.like-icon {
  font-size: 18px;
  filter: drop-shadow(0 2px 4px rgba(239, 68, 68, 0.3));
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
  font-size: 16px;
}

/* === Footer === */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 28px 0;
  margin-top: 60px;
}

.footer-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
}

.footer-content a {
  color: var(--accent);
  text-decoration: none;
  transition: var(--transition);
}

.footer-content a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* === LIGHTBOX === */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.97);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox.hidden {
  display: none;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  cursor: pointer;
}

.lightbox-container {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  z-index: 1;
  overflow: hidden;
  touch-action: none;
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 10;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(90deg);
}

.lightbox-viewer {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 80px 20px 20px;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
}

.viewer-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.viewer-stage img,
.viewer-stage video {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.6);
  touch-action: pan-y pinch-zoom;
  user-select: none;
  -webkit-user-drag: none;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 5;
}

.viewer-nav:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-50%) scale(1.1);
}

.viewer-nav-prev {
  left: 20px;
}

.viewer-nav-next {
  right: 20px;
}

.viewer-counter {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  color: white;
  padding: 8px 16px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.lightbox-thumbs {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  overflow-x: auto;
  overflow-y: hidden;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.3) transparent;
}

.lightbox-thumbs::-webkit-scrollbar {
  height: 6px;
}

.lightbox-thumbs::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.lightbox-thumbs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.thumb-item {
  flex: 0 0 auto;
  width: 90px;
  height: 68px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  position: relative;
  background: rgba(255, 255, 255, 0.05);
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
  transform: scale(1.05);
}

.thumb-item:hover:not(.active) {
  border-color: rgba(255, 255, 255, 0.3);
}

.thumb-video-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  color: white;
  font-size: 24px;
  pointer-events: none;
}

.lightbox-info {
  background: linear-gradient(to top, rgba(0,0,0,0.95), rgba(0,0,0,0.85));
  backdrop-filter: blur(20px);
  padding: 24px;
  max-height: 35vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.info-title {
  font-size: 28px;
  font-weight: 800;
  margin: 0 0 12px;
  color: white;
  letter-spacing: -0.02em;
}

.info-desc {
  font-size: 16px;
  color: var(--text-muted);
  margin: 0 0 20px;
  white-space: pre-wrap;
  line-height: 1.6;
}

.info-actions {
  display: flex;
  gap: 12px;
}

.info-actions .like-btn {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.info-actions .like-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* === Mobile Optimizations === */
@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }

  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 14px 0;
  }

  .brand-title {
    font-size: 20px;
  }

  .contact-wrapper {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .contacts {
    width: 100%;
  }

  .contact-btn {
    flex: 1;
    justify-content: center;
    padding: 12px 16px;
    font-size: 13px;
  }

  .search-bar {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 24px;
  }

  .search-input {
    max-width: none;
  }

  .gallery {
    gap: 16px;
  }

  .work-card-content {
    padding: 16px;
  }

  .work-card-title {
    font-size: 18px;
  }

  .work-card-footer {
    padding: 12px 16px;
  }

  /* Lightbox mobile */
  .lightbox-viewer {
    padding: 50px 8px 8px;
    min-height: 0;
    overflow: hidden;
  }

  .viewer-stage {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .viewer-stage img,
  .viewer-stage video {
    max-width: 100vw;
    max-height: calc(100vh - 200px);
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
  }

  .viewer-stage img {
    width: 100%;
    height: auto;
    max-height: calc(100vh - 200px);
  }

  .viewer-nav {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
  }

  .viewer-nav:active {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%) scale(0.95);
  }

  .viewer-nav-prev {
    left: 8px;
  }

  .viewer-nav-next {
    right: 8px;
  }

  .viewer-counter {
    top: 8px;
    left: 8px;
    font-size: 12px;
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.8);
  }

  .lightbox-close {
    top: 8px;
    right: 8px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
  }

  .lightbox-close:active {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(0.95);
  }

  .lightbox-info {
    max-height: 40vh;
    padding: 16px;
  }

  .info-title {
    font-size: 20px;
  }

  .info-desc {
    font-size: 14px;
    line-height: 1.5;
  }

  .lightbox-thumbs {
    padding: 10px;
    flex-shrink: 0;
  }

  .thumb-item {
    width: 70px;
    height: 52px;
  }

  .lightbox-container {
    max-height: 100vh;
    overflow: hidden;
  }

  .footer-content {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

/* iOS safe areas */
@supports (padding: env(safe-area-inset-top)) {
  .lightbox-close {
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
  }

  .viewer-counter {
    top: max(12px, env(safe-area-inset-top));
  }

  .lightbox-info {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  @media (max-width: 768px) {
    .lightbox-viewer {
      padding-top: max(60px, calc(60px + env(safe-area-inset-top)));
    }
  }
}

/* === Utilities === */
.hidden {
  display: none !important;
}

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