:root {
  --c-spot: #f2f2f2;
  --c-text1: #050505;
  --c-text2: #474747;
}

body, html {
  margin: 0; 
  padding: 0;
  background-color: var(--c-spot);
  color: var(--c-text1);
  font-family: 'Alegreya', serif;
}

/* Типографика */
h1 { 
  font-family: 'Source Sans Pro', sans-serif; 
  font-size: 20px; 
  line-height: 28px; 
  letter-spacing: 0.02em; 
  font-weight: 400; 
  color: var(--c-text1); 
  margin-top: 0; 
  margin-bottom: 24px; 
}

h2 { 
  font-size: 21px; 
  line-height: 28px; 
  letter-spacing: 0; 
  font-weight: 400; 
  margin-top: 0; 
  margin-bottom: 24px; 
}

h3 { 
  font-size: 18px; 
  line-height: 24px; 
  letter-spacing: 0; 
  font-weight: 500; 
  font-style: italic; 
  color: var(--c-text2); 
  margin-bottom: 10px; 
}

em, i {
  font-style: italic;
  font-weight: 400;
}

p, .description { 
  font-size: 16px; 
  line-height: 22px; 
  letter-spacing: 0; 
  font-weight: 400; 
}

.description {
  max-width: 672px; 
}

.description p:first-child {
  margin-top: 0;
}

.description a {
  color: var(--c-text1);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.2s ease;
}

.description a:hover {
  color: var(--c-text2);
}

.description a[href^="http"]::after {
  content: '\2192'; 
  display: inline-block;
  margin-left: 4px;
  font-size: 0.9em;
}

.description img {
  display: block;
  min-width: 320px; 
  max-width: 100%; 
  height: auto;
  margin: 24px 0; 
}

.caption-1 { 
  font-family: 'Source Sans Pro', sans-serif; 
  font-size: 13px; 
  line-height: 16px; 
  letter-spacing: 0.02em; 
  color: var(--c-text2); 
}

a { 
  text-decoration: none; 
  color: inherit; 
}

/* Архитектура */
.layout { 
  display: flex; 
  min-height: 100vh; 
  align-items: flex-start; 
}

.sidebar { 
  box-sizing: border-box;
  width: 240px; 
  flex-shrink: 0; 
  padding: 40px 20px; 
  background: var(--c-spot); 
  position: sticky; 
  top: 0;
  height: 100vh; 
  overflow-y: auto; 
}

.workspace { 
  box-sizing: border-box;
  flex-grow: 1; 
  padding: 40px; 
}

.mobile-header { 
  display: none; 
  padding: 10px 20px; 
  background: var(--c-spot); 
  border-bottom: 1px solid #ddd; 
  align-items: center;
  justify-content: space-between; 
}

.mobile-logo {
  font-family: 'Source Sans Pro', sans-serif; 
  font-size: 20px; 
  line-height: 28px;
  letter-spacing: 0.02em;
  font-weight: 400; 
  color: var(--c-text1); 
  text-decoration: none;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; 
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.close-btn {
  display: none; 
  position: absolute;
  top: 10px;
  right: 10px;
}

.drawer-overlay {
  display: none; 
}

/* Меню */
.menu ul { 
  list-style: none; 
  padding: 0; 
  margin: 0 0 0 20px; 
}

.menu li { 
  margin-bottom: 0px; /* Уменьшено с 8px для группировки проектов */
}

.category h3 {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 13px; 
  line-height: 16px; 
  letter-spacing: 0.02em;
  color: var(--c-text2);
  font-weight: 400;
  font-style: normal; 
  text-transform: none; 
  margin-top: 24px; /* Увеличено с 16px для отделения новых категорий */
  margin-bottom: 4px; /* Для отделения заголовка от списка */
}

.menu a {
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 13px; 
  line-height: 16px; 
  letter-spacing: 0.02em;
  color: var(--c-text1); 
  font-weight: 400;
  text-decoration: none;
}

.menu a.active { 
  text-decoration: underline; 
}

.about-link {
  display: block;
  font-family: 'Source Sans Pro', sans-serif;
  font-size: 13px;
  line-height: 16px;
  letter-spacing: 0.02em;
  color: var(--c-text2); 
}

/* Главная страница */
.home-wrapper {
  width: 100%;
  height: calc(100vh - 80px);
  display: flex;
  justify-content: center;
  align-items: center;
}

.home-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain; 
}

.mobile-home-menu {
  display: none; 
}

/* Галерея (Сетка) */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(max(320px, calc((100% - 60px) / 4)), 1fr)); 
  gap: 20px;
  margin-top: 40px;
}

.preview-block { 
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex; 
  flex-direction: column; 
}

.gallery-item { 
  display: block;
  width: 100%; 
  aspect-ratio: 1/1; 
  overflow: hidden;
}

.thumb-img { 
  width: 100%; 
  height: 100%; 
  object-fit: contain; 
  display: block;
}

.preview-block .caption-1 {
  margin-top: 8px;
  text-align: left; 
}

.pswp__bg { 
  background-color: #252525 !important; 
  opacity: 1 !important; 
}

.pswp__custom-caption {
  position: absolute; 
  bottom: 12px;
  left: 50%; 
  transform: translateX(-50%);
  color: #d7d7d7; 
  font-family: 'Source Sans Pro', sans-serif; 
  font-size: 13px; 
  line-height: 16px;
  letter-spacing: 0.02em;
  text-align: center;
}

/* Логика для ОДНОКОЛОНОЧНОЙ галереи */
@media (max-width: 979px) {
  .gallery { 
    grid-template-columns: 1fr; 
    gap: 40px;
  }
  .gallery-item {
    aspect-ratio: auto; 
    display: flex;
    justify-content: center; 
  }
  .thumb-img {
    width: auto;
    height: auto;
    max-width: 100%; 
    max-height: min(calc(100vw - 320px), 480px); 
  }
}

/* Адаптивность: Смартфоны */
@media (max-width: 799px) {
  .mobile-header { display: flex; }
  .close-btn { display: flex; }
  .desktop-logo { display: none; } 
  
  .workspace {
    padding: 40px 20px; 
  }

  .sidebar { 
    width: 320px; 
    position: fixed; 
    right: -320px; 
    left: auto;
    top: 0; 
    height: 100vh; 
    z-index: 100;
    transition: right 0.3s ease; 
    box-shadow: -2px 0 5px rgba(0,0,0,0.1); 
  }
  
  .sidebar.is-open { 
    right: 0; 
  }

  .drawer-overlay {
    display: block;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.3); 
    z-index: 90; 
    opacity: 0;
    pointer-events: none; 
    transition: opacity 0.3s ease;
  }
  
  .drawer-overlay.is-visible {
    opacity: 1;
    pointer-events: auto; 
  }

  .home-wrapper {
    height: auto;
    min-height: calc(100vh - 60px);
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
  }
  
  .home-img {
    margin-bottom: 40px;
    object-position: top center; 
  }
  
  .mobile-home-menu {
    display: block;
    width: 100%;
  }

  .thumb-img {
    max-height: min(calc(100vw - 40px), 480px); 
  }
}