/* ====================================
   THEME FIX
==================================== */

:root {
  color-scheme: light;
}

html {
  background: #ffffff !important;
}

/* подстраховка */
@media (prefers-color-scheme: dark) {
  html,
  body,
  .page,
  .intro {
    background: #ffffff !important;
    color: #111111 !important;
  }
}

/* ====================================
   GLOBAL RESET
==================================== */

html,
body {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

/* ====================================
   BASE
==================================== */

body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #ffffff;
  color: #111111;
  overflow-x: hidden;
}

.accent {
  color: #2344ff;
}

/* ====================================
   PRELOADER
==================================== */

.preloader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  z-index: 1000;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.preloader.preloader--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-dot {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #000000;
  animation: preloader-pulse 1.1s ease-in-out infinite;
}

@keyframes preloader-pulse {
  0% {
    transform: scale(0.7);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(0.7);
    opacity: 0.5;
  }
}

/* ====================================
   INTRO
==================================== */

.intro {
  min-height: 80vh;          /* было height: 90vh */
  padding: 0 32px;
  display: flex;
  align-items: flex-end;
  background: #ffffff;
  position: relative;
  z-index: 1;
}

.intro-inner {
  width: 100%;
}

.intro-inner p {
  margin: 0;
  font-size: 40px;
  line-height: 1.2;
  font-weight: 600;
  color: #d0d0d0;
  padding-bottom: 0;
}

/* ====================================
   LAYOUT
==================================== */

.page {
  width: 100%;
  margin: 0;
  padding: 32px 0 80px;
  background: #ffffff;
}

.case {
  padding: 80px 32px;
  margin-bottom: 0;
}

.case--black {
  background: #272727;
}

/* ====================================
   MASONRY GRID (desktop / tablet)
==================================== */

.case-grid {
  position: relative;
  width: 100%;
}

.case-grid-item {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0;
}

.case-grid-item img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0;
  transition: transform 0.25s ease, filter 0.25s ease, opacity 0.35s ease-out;
  opacity: 0; /* появление после загрузки */
}

.case-grid-item:hover img {
  transform: scale(1.04);
}

/* ====================================
   TEXT BLOCKS
==================================== */

.case-grid-item--text {
  padding: 4px 2px 6px;
}

.case-grid-item--text p {
  margin: 0;
  font-size: 20px;
  line-height: 26px;
  color: #b6b0b1;
  font-weight: 400;
}

.case-grid-item--text .accent {
  color: #2344ff;
  text-decoration: none;
  font-weight: 500;
}

/* ====================================
   LIGHTBOX
==================================== */

.lightbox {
  position: fixed;
  inset: 0;
  background: #ffffff;
  display: none;
  justify-content: center;
  align-items: stretch;
  z-index: 999;
}

.lightbox.visible {
  display: flex;
}

.lightbox-inner {
  position: relative;
  width: 100%;
  height: 100%;
}

.lightbox-text {
  position: fixed;
  top: 48px;
  left: 48px;
  max-width: 420px;
  color: #b6b0b1;
  font-size: 16px;
  line-height: 1.4;
}

.lightbox-main {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-height: calc(100vh - 96px);
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox-img {
  max-height: calc(100vh - 96px);
  max-width: calc(100vw - 320px);
  height: auto;
  width: auto;
  object-fit: contain;
  cursor: pointer;
}

/* ====================================
   THUMBS (DESKTOP)
==================================== */

.lightbox-thumbs-wrapper {
  position: fixed;
  top: 50%;
  right: 48px;
  transform: translateY(-50%);
  max-height: calc(100vh - 96px);
  padding-right: 4px;
}

.lightbox-thumbs {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  overflow-x: visible;
  padding-left: 24px;
  scrollbar-width: none;
}

.lightbox-thumbs::-webkit-scrollbar {
  width: 0;
}

.lightbox-thumb {
  position: relative;
  width: 48px;
  flex: 0 0 auto;
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.lightbox-thumb img {
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.lightbox-thumb.is-active {
  opacity: 1;
}

.lightbox-thumb.is-active::before {
  content: "";
  position: absolute;
  left: -20px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  background: #ff3b30;
  border-radius: 50%;
  z-index: 2;
}

/* ====================================
   PLACEHOLDER FOR IMAGES
==================================== */

.case-grid-item::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.05);
  transition: opacity 0.2s ease-out;
}

.case--black .case-grid-item::before {
  background: rgba(255, 255, 255, 0.05);
}

.case-grid-item.is-loading::before {
  opacity: 1;
}

.case-grid-item.is-loaded::before {
  opacity: 0;
}

.case-grid-item.is-loaded img {
  opacity: 1;
}

/* ====================================
   MOBILE
==================================== */

@media (max-width: 768px) {
  .intro {
    height: auto;
    min-height: 100vh;       /* было 70vh */
    padding: 24px 16px 0;
    display: flex;
    align-items: flex-end;
  }

  .intro-inner p {
    font-size: 24px;
    line-height: 1.3;
    padding-bottom: 32px;
  }

  .case {
    padding: 48px 16px 64px;
  }

  .case-grid {
    position: static;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
    row-gap: 24px;
  }

  .case-grid-item {
    position: static;
    margin: 0;
    width: 100% !important;
    transform: none !important;
  }

  .case-grid-item:hover img {
    transform: none;
  }

  .case-grid-item--w2,
  .case-grid-item--w3,
  .case-grid-item--text {
    grid-column: 1 / -1;
  }

  .case-grid-item--text {
    padding: 0 0 16px;
  }

  .case-grid-item--text p {
    font-size: 18px;
    line-height: 1.36;
  }

  .case-grid-item--text .accent {
    font-size: 18px;
  }

  /* отключаем тёмный плейсхолдер под интро на мобиле */
  .case-grid-item::before {
    display: none;
  }

  .lightbox-text {
    top: 24px;
    left: 24px;
    max-width: 260px;
    font-size: 14px;
  }

  .lightbox-main {
    max-height: calc(100vh - 120px);
  }

  #lightbox-img {
    max-height: calc(100vh - 120px);
    max-width: calc(100vw - 48px);
  }

  .lightbox-thumbs-wrapper {
    position: fixed;
    bottom: 16px;
    left: 0;
    right: 0;
    top: auto;
    transform: none;
    max-height: none;
    display: flex;
    justify-content: center;
    pointer-events: none;
  }

  .lightbox-thumbs {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: 80px;
    padding-inline: 24px;
    pointer-events: auto;
    scrollbar-width: none;
  }

  .lightbox-thumbs::-webkit-scrollbar {
    height: 0;
  }

  .lightbox-thumb {
    width: 48px;
  }

  .lightbox-thumb.is-active::before {
    left: 50%;
    top: 100%;
    transform: translate(-50%, 4px);
  }
}