/*main-header*/
.main-header {
  width: 100%;
  height: 420px;
  display: flex;
  justify-content: center;
  align-items: center;
  background-image: url(../img/header-bg.svg);
  background-position: center;
  background-size: cover;
}

.main-header--icon-text {
  font-family: TT-common-demi-bold;
  font-style: normal;
  font-weight: 500;
  font-size: 18px;
  line-height: 22px;
  letter-spacing: 8px;
  text-transform: uppercase;
  margin-left: 12px;
}

/*main-header*/

/*main-page*/

.main-page--wrapper {
  margin: -125px auto 0 auto;
  padding: 0 32px;
  max-width: 1002px;
}

.main-page--navigation {
  margin-bottom: 16px;
}

/*main-page*/

.posts {
  margin-bottom: 32px;
  gap: 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  flex-direction: row;
  justify-content: flex-start;
}

.post {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  box-sizing: border-box;
  height: 444px;
  width: 100%;
}

.post--info {
  display: flex;
  flex: 1 0 0;
  flex-direction: column;
  position: relative;
  padding: 32px;
  background-color: #fff;
  overflow: hidden;
}

.post--image {
  display: block;
  height: 190px;
  position: relative;
}

.post--image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
}

.post--cats {
  margin-bottom: 8px;
  display: flex;
  font-style: normal;
  font-weight: 600;
  font-size: 12px;
  line-height: 18px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #00a3ff;
  font-family: TT-common-demi-bold;
}

.post--title {
  width: 100%;
  margin-bottom: 8px;
  font-style: normal;
  font-weight: 500;
  font-size: 20px;
  line-height: 26px;
  color: #0c141d;
  font-family: TT-common-demi-bold;

  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: break-word;
}

.post--description {
  display: block;
  position: relative;
  margin-bottom: 12px;
  flex: 1 1 1px;
  font-style: normal;
  font-weight: normal;
  font-size: 16px;
  line-height: 20px;
  color: #5d6b7b;
  min-height: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post--description:not(.loaded)::after {
  content: '';
  display: block;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 16px;
  background: linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 1));
}

.post--author {
  display: flex;
  align-items: center;
  margin-top: auto;
  margin-bottom: 0;
}

.post--author--avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-right: 20px;
  background-size: contain;
  background-position: center;
}

.post--author--name {
  font-style: normal;
  font-weight: normal;
  font-size: 16px;
  line-height: 20px;
  color: #0c141d;
}

@media (min-width: 1100px) {
  .posts {
    display: grid;
    /* 
     * 6-column grid for precise control over post placement:
     * - Allows 3 regular posts per row (each spanning 2 columns)
     * - Allows 2 wider posts per row (each spanning 3 columns)
     * - Allows 1 full-width post (spanning all 6 columns)
     */
    grid-template-columns: repeat(6, 1fr);
    gap: 32px;
  }

  .post {
    width: 100%;
    height: 444px;
    /* 
     * Default post width - spans 2 of 6 columns:
     * - Used for posts 2-4, 8-10, etc. in each cycle
     * - Results in 3 posts per row (posts 2,3,4 and 8,9,10, etc.)
     */
    grid-column: span 2;
  }

  /* 
   * Featured post styling (1st post in each 6-post cycle):
   * - Spans all 6 columns (full width)
   * - Uses 45%/55% two-column internal layout
   * - Reduced height compared to standard posts
   */
  .post:nth-child(6n+1) {
    grid-column: span 6;
    display: grid;
    grid-template-columns: 45% 1fr;
    height: 280px;
  }

  /* 
   * Medium-width posts (5th and 6th in each 6-post cycle):
   * - Each spans 3 of 6 columns
   * - Results in 2 posts per row (posts 5,6 and 11,12, etc.)
   */
  .post:nth-child(6n+5),
  .post:nth-child(6n+6) {
    grid-column: span 3;
  }

  .post:nth-child(6n+1) .post--image {
    height: 280px;
  }

  .post:nth-child(6n+1) .post--description {
    font-size: 18px;
    line-height: 24px;
  }

  .post:nth-child(6n+1) .post--title {
    font-size: 32px;
    line-height: 38px;
    -webkit-line-clamp: 2;
  }
}

@media (min-width: 651px) and (max-width: 1099px) {
  .posts {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
  }

  .post {
    width: 100%;
    /* 
     * Fluid post height scaling between breakpoints:
     * - 444px: Base height at min breakpoint (651px viewport)
     * - 484px: Target height at max breakpoint (1099px viewport)
     * - (484 - 444): Height difference to be distributed (40px)
     * - (100vw - 651px): Current viewport position above min breakpoint
     * - (1099 - 651): Total viewport range between breakpoints (448px)
     * 
     * Formula: minHeight + heightDifference * (currentViewport - minBreakpoint) / viewportRange
     */
    height: calc(444px + (484 - 444) * ((100vw - 651px) / (1099 - 651)));
  }

  .post--image {
    /* 
     * Fluid image height scaling between breakpoints:
     * - 166px: Base image height at min breakpoint (651px viewport)
     * - 230px: Target image height at max breakpoint (1099px viewport)
     * - (230 - 166): Image height difference to be distributed (64px)
     * - (100vw - 651px): Current viewport position above min breakpoint
     * - (1099 - 651): Total viewport range between breakpoints (448px)
     * 
     * Formula: minHeight + heightDifference * (currentViewport - minBreakpoint) / viewportRange
     */
    height: calc(166px + (230 - 166) * ((100vw - 651px) / (1099 - 651)));
  }

  /* nth-childs copy-pasted because not sass or anything */
  .post:nth-child(5n+1) {
    grid-column: span 2;
    display: grid;
    grid-template-columns: 45% 1fr;
    height: 280px;
  }

  .post:nth-child(5n+1) .post--image {
    height: 280px;
  }

  .post:nth-child(5n+1) .post--description {
    font-size: 18px;
    line-height: 24px;
  }

  .post:nth-child(5n+1) .post--title {
    font-size: 32px;
    line-height: 38px;
    -webkit-line-clamp: 2;
  }
}

@media (max-width: 650px) {
  .main-page {
    margin: 0;
  }

  .posts {
    display: grid;
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .post {
    width: 100%;
    /* 
     * Fluid post height scaling for mobile:
     * - 485px: Base height at max mobile breakpoint (650px viewport)
     * - 444px: Target height at min mobile breakpoint (400px viewport)
     * - (485 - 444): Height difference to be distributed (41px)
     * - 0.3: Damping factor to slow down the transition rate
     * - (650px - 100vw): How far current viewport is below max mobile breakpoint
     * - (650 - 400): Total viewport range for mobile scaling (250px)
     * 
     * Formula: maxHeight - heightDifference * dampingFactor * (maxBreakpoint - currentViewport) / viewportRange
     */
    height: calc(485px - (485 - 444) * 0.3 * ((650px - 100vw) / (650 - 400)));
  }

  /* Изменяем направление: от большого (265px) к маленькому (160px) */
  .post--image {
    /* 
     * Fluid image height scaling for mobile:
     * - 230px: Base image height at max mobile breakpoint (650px viewport)
     * - 166px: Target image height at min mobile breakpoint (400px viewport)
     * - (230 - 166): Image height difference to be distributed (64px)
     * - 0.3: Damping factor to slow down the transition rate
     * - (650px - 100vw): How far current viewport is below max mobile breakpoint
     * - (650 - 400): Total viewport range for mobile scaling (250px)
     * 
     * Formula: maxHeight - heightDifference * dampingFactor * (maxBreakpoint - currentViewport) / viewportRange
     */
    height: calc(230px - (230 - 166) * 0.3 * ((650px - 100vw) / (650 - 400)));
  }
}

@media (max-width: 600px) {
  .main-page--wrapper {
    padding: 0 20px;
  }

  .main-header {
    background-image: url(../img/header-bg-m.svg);
    background-position-y: 0;
  }
}

@media (max-width: 400px) {
  .post {
    height: 444px;
  }

  .post--image {
    height: 166px;
  }
}

/*posts*/