/* ==================== ФУНКЦИИ СЕКЦИЯ ==================== */
.functions-section {
  background-color: var(--color-black);
  color: var(--color-white);
  padding: var(--spacing-6xl) 0;
}

.section-badge {
  display: inline-block;
  padding: 8px 16px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-2xl);
  font-size: var(--font-text-m-size);
  font-weight: 500;
  margin: 0 auto var(--spacing-xl);
  text-align: center;
  width: -moz-fit-content;
  width: fit-content;
  display: block;
}

.mb-5xl {
  margin-bottom: var(--spacing-6xl);
}

.function-item {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-5xl);
  align-items: center;
  margin-top: var(--spacing-5xl);
}

.function-image {
  position: relative;
}

.function-image img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-2xl);
}

.function-content {
  padding-left: var(--spacing-3xl);
}

.function-number {
  font-size: var(--font-display-2xl-size);
  font-weight: 600;
  color: var(--color-white);
  opacity: 0.1;
  margin-bottom: var(--spacing-l);
  line-height: 1;
}

/* ==================== FUNCTION SCROLL ANIMATION ==================== */
.function-scroll-section {
  min-height: 4800px; /* Статическая высота для скролл-анимации (6 блоков × 800px) */
  position: relative;
  background-color: var(--color-black);
}

/* Бейдж вынесен за sticky контейнер - уходит при скролле */
.function-badge-wrapper {
  display: flex;
  justify-content: center;
  padding-top: 40px;
  padding-bottom: 20px;
}

.function-badge-wrapper .section-badge {
  margin: 0;
  background-color: transparent;
  border: 1px solid #282828;
  padding: 4px 16px;
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  letter-spacing: -0.32px;
  color: #DDDDDD;
}

/* .function-header - заголовок уходит при скролле */
.function-header {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin: 0 auto 60px;
  padding: 0 20px;
}


.function-scroll-content {
  position: sticky;
  top: 120px;
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  gap: 150px;
  height: 671px;
  width: 100%;
  max-width: 1216px;
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box;
}

/* Левая часть: телефон */
.function-scroll-left {
  order: 2;
  display: flex;
  gap: 109px;
  align-items: center;
  flex: 0 0 auto;
}

/* Правая часть теперь слева: телефон */
.function-scroll-right {
  order: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex: 0 0 auto;
}

/* Свечение под телефоном */
.phone-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 800px;
  height: 800px;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.12) 0%,
    rgba(255, 255, 255, 0.06) 25%,
    rgba(255, 255, 255, 0.02) 50%,
    transparent 70%
  );
  filter: blur(40px);
}

.phone-glow img {
  display: none;
}

/* Прогресс индикатор */
.function-progress-indicator {
  position: relative;
  width: 22px;
  height: 671px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}

.progress-dot {
  position: absolute;
  bottom: calc(100% - 22px);
  width: 22px;
  height: 22px;
  background-color: #282828;
  border: 0.2px solid white;
  border-radius: 11px;
  transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  box-sizing: border-box;
}

.progress-dot::before {
  content: '';
  position: absolute;
  inset: -0.2px;
  border-radius: 11px;
  box-shadow: inset 0px 0px 13px 3px rgba(255, 255, 255, 0.5);
  pointer-events: none;
}

.progress-dot::after {
  content: '';
  width: 14px;
  height: 14px;
  background-color: white;
  border-radius: 50%;
  position: relative;
  z-index: 1;
  box-shadow: 0px 0px 8px 2px rgba(255, 255, 255, 0.8),
              0px 0px 16px 4px rgba(255, 255, 255, 0.4);
}

.progress-line {
  width: 4px;
  height: calc(100% - 22px);
  background: linear-gradient(180deg, #DDDDDD 0%, rgba(221, 221, 221, 0.2) 100%);
  border-radius: 2px;
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
}

/* Текстовые блоки */
.function-text-blocks {
  position: relative;
  width: 384px;
  min-height: 671px;
  display: flex;
  align-items: center;
}

.function-text-block {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.function-text-block.active {
  opacity: 1;
  visibility: visible;
}

.function-text-block .function-number {
  font-family: 'Onest', sans-serif;
  font-size: 72px;
  font-weight: 600;
  line-height: 90px;
  letter-spacing: -1.44px;
  color: white;
  opacity: 0.1;
  margin: 0;
}

.function-text-block .display-m {
  font-family: 'Onest', sans-serif;
  font-size: 36px;
  font-weight: 400;
  line-height: 44px;
  letter-spacing: -0.72px;
  color: white;
  margin: 0;
}

.function-text-block .text-xl {
  font-family: 'Onest', sans-serif;
  font-size: 20px;
  font-weight: 400;
  line-height: 30px;
  letter-spacing: -0.4px;
  color: #bfbfbf;
  margin: 0;
}

.function-text-block .btn {
  align-self: flex-start;
  margin-top: 40px;
  background-color: var(--color-white);
  color: var(--color-black);
  border-radius: 1000px;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  font-family: 'Onest', sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
  letter-spacing: -0.32px;
  transition: all 0.3s ease;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}

.function-text-block .btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(255, 255, 255, 0.2);
}

.function-text-block .btn img {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.function-phone-frame {
  position: relative;
  width: 267px;
  height: 550px;
  flex-shrink: 0;
}

.phone-frame-border {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}

.phone-scrollable-content {
  position: absolute;
  top: 9px;
  left: 10.5px;
  width: 246px;
  height: 532px;
  overflow: hidden;
  border-radius: 36.36px;
  z-index: 1;
  background-color: #f2f2f2;
}

.phone-scrollable-content picture {
  display: contents;
}

#showroomScreenshot {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: auto;
  min-height: 100%;
  object-fit: cover;
  object-position: top;
  will-change: transform;
  transition: transform 0.1s linear;
}

/* ==================== PAGESPEED КОМПОНЕНТ ==================== */
.pagespeed-container {
  backdrop-filter: blur(12.5px);
  background-color: rgba(26, 26, 26, 1);
  border-radius: 32px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 80px;
  max-width: 864px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

.pagespeed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.pagespeed-title-container {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 24px;
  background-color: #282828;
  border-radius: 1000px;
}

.pagespeed-icon {
  width: 14.554px;
  height: 20.002px;
  flex-shrink: 0;
}

.pagespeed-title {
  font-family: 'Onest', sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
  letter-spacing: -0.32px;
  color: #FFFFFF;
  margin: 0;
}

.pagespeed-link {
  font-family: 'Onest', sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: -0.28px;
  color: #7E7E7E;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.pagespeed-link:hover {
  opacity: 0.7;
}

.pagespeed-divider-horizontal {
  width: 100%;
  height: 1px;
  background-color: #DDDDDD;
  opacity: 0.2;
}

.pagespeed-divider-img {
  display: none;
}

.pagespeed-content {
  display: flex;
  align-items: center;
  gap: 24px;
  width: 100%;
}

.pagespeed-logo-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-shrink: 0;
}

.google-logo {
  width: 72.904px;
  height: 24px;
  flex-shrink: 0;
}

.pagespeed-logo-text {
  font-family: 'Onest', sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  letter-spacing: -0.32px;
  color: #FFFFFF;
  text-align: center;
  margin: 0;
}

.pagespeed-divider-vertical-container {
  width: 1px;
  height: 92px;
  background-color: #DDDDDD;
  opacity: 0.2;
  flex-shrink: 0;
}

.pagespeed-divider-vertical {
  display: none;
}

.pagespeed-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.pagespeed-metric-value {
  width: 68px;
  height: 68px;
  border: 3px solid #32D35D;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
}

.metric-number {
  font-family: 'Onest', sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 18px;
  letter-spacing: -0.32px;
  color: #32D35D;
  margin: 0;
}

.metric-unit {
  font-family: 'Onest', sans-serif;
  font-size: 14px;
  font-weight: 500;
  line-height: 14px;
  letter-spacing: -0.28px;
  color: #32D35D;
  margin: 0;
}

.pagespeed-metric-value-simple {
  width: 68px;
  height: 68px;
  border: 3px solid #32D35D;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-sizing: border-box;
}

.metric-percentage {
  font-family: 'Onest', sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
  letter-spacing: -0.32px;
  color: #32D35D;
  text-align: center;
  margin: 0;
}

.pagespeed-metric-label {
  font-family: 'Onest', sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  letter-spacing: -0.32px;
  color: #FFFFFF;
  text-align: center;
  margin: 0;
}

/* Desktop: метрики в ряд */
.pagespeed-metrics-grid {
  display: contents;
}

/* Mobile link - hidden on desktop */
.pagespeed-link-mobile {
  display: none;
}

/* PageSpeed Circle Animation */
.pagespeed-circle-container {
  position: relative;
  width: 68px;
  height: 68px;
  flex-shrink: 0;
}

.pagespeed-circle {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.pagespeed-circle-bg {
  fill: none;
  stroke: rgba(50, 211, 93, 0.15);
  stroke-width: 3;
}

.pagespeed-circle-progress {
  fill: none;
  stroke: #32D35D;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 194.78; /* 2 * PI * 31 */
  stroke-dashoffset: 194.78;
  transition: stroke-dashoffset 1.5s ease-out;
}

.pagespeed-circle-container.animated .pagespeed-circle-progress {
  stroke-dashoffset: 0;
}

.pagespeed-circle-value {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: 'Onest', sans-serif;
  font-size: 16px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.32px;
  color: #32D35D;
  text-align: center;
}

/* ==================== RESPONSIVE: TABLET (768px - 1024px) ==================== */
@media (min-width: 768px) and (max-width: 1024px) {
  .function-scroll-section {
    min-height: 3000px;
  }

  .function-scroll-content {
    gap: 40px;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    height: 600px;
    max-width: 100%;
  }

  .function-scroll-right {
    order: 1;
    height: auto;
    flex-shrink: 0;
  }

  .function-scroll-left {
    order: 2;
    gap: 24px;
    width: auto;
    flex: 1;
    flex-direction: column;
    align-items: flex-start;
  }

  .function-progress-indicator {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 22px;
    align-items: center;
  }

  .progress-dot {
    position: relative;
    bottom: auto;
    left: 0;
    flex-shrink: 0;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .progress-line {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    width: calc(100% - 22px);
    height: 4px;
    background: linear-gradient(90deg, #DDDDDD 0%, rgba(221, 221, 221, 0.2) 100%);
    border-radius: 2px;
  }

  .function-text-blocks {
    width: 100%;
    min-height: auto;
    padding: 0;
  }

  .function-text-block {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    transform: none;
    text-align: left;
  }

  .function-text-block.active {
    position: relative;
  }

  .function-text-block:not(.active) {
    display: none;
  }

  .function-text-block .function-number {
    display: block;
    font-size: 56px;
    line-height: 70px;
    opacity: 0.1;
  }

  .function-text-block .display-m {
    font-size: 24px;
    line-height: 32px;
    text-align: left;
  }

  .function-text-block .text-xl {
    font-size: 14px;
    line-height: 20px;
    text-align: left;
  }

  .function-text-block .btn {
    width: auto;
    align-self: flex-start;
    justify-content: center;
  }

  .function-phone-frame {
    width: 220px;
    height: 453px;
  }

  .phone-scrollable-content {
    top: 7px;
    left: 9px;
    width: 202px;
    height: 437px;
    border-radius: 30px;
  }

  .phone-glow {
    display: none;
  }

  .function-header h2 {
    font-size: 32px;
    line-height: 40px;
  }

  .function-header p {
    font-size: 16px;
    line-height: 24px;
  }

  /* PageSpeed */
  .pagespeed-container {
    max-width: 100%;
    padding: 24px;
		margin: 12px;
  }

  .pagespeed-content {
    gap: 12px;
  }

  .pagespeed-logo-container {
    gap: 8px;
  }

  .pagespeed-logo-text {
    font-size: 12px;
    line-height: 16px;
  }

  .google-logo {
    width: 60px;
    height: 20px;
  }

  .pagespeed-divider-vertical-container {
    height: 72px;
  }

  .pagespeed-metrics-grid {
    display: flex;
    gap: 8px;
    flex: 1;
  }

  .pagespeed-metric {
    flex: 1;
    min-width: 0;
    gap: 8px;
  }

  .pagespeed-metric-value,
  .pagespeed-circle-container {
    width: 56px;
    height: 56px;
  }

  .pagespeed-circle {
    width: 100%;
    height: 100%;
  }

  .pagespeed-metric-label {
    font-size: 12px;
    line-height: 16px;
  }
}

/* ==================== RESPONSIVE: 1400px ==================== */
@media (min-width: 1201px) and (max-width: 1400px) {
  .function-scroll-content {
    gap: 100px;
    max-width: 1100px;
  }

  .function-text-blocks {
    width: 350px;
  }

  .function-scroll-left {
    gap: 80px;
  }

  .pagespeed-content {
    gap: 20px;
  }

  .pagespeed-metrics-grid {
    display: flex;
    flex: 1;
    gap: 16px;
    min-width: 0;
  }

  .pagespeed-metric {
    flex: 1;
    min-width: 0;
  }
}

/* ==================== RESPONSIVE: 1200px ==================== */
@media (min-width: 1025px) and (max-width: 1200px) {
  .pagespeed-content {
    gap: 16px;
  }

  .pagespeed-logo-container {
    flex-shrink: 0;
  }

  .pagespeed-divider-vertical-container {
    height: 80px;
  }

  .pagespeed-metrics-grid {
    display: flex;
    flex: 1;
    gap: 12px;
    min-width: 0;
  }

  .pagespeed-metric {
    flex: 1;
    min-width: 0;
  }

  .pagespeed-metric-value,
  .pagespeed-circle-container {
    width: 60px;
    height: 60px;
  }

  .pagespeed-metric-label {
    font-size: 14px;
    line-height: 20px;
  }

  /* Function scroll */
  .function-scroll-content {
    gap: 80px;
    max-width: 960px;
    flex-direction: row;
    justify-content: flex-start;
  }

  .function-scroll-left {
    gap: 60px;
    width: 100%;
    flex: 1;
  }

  .function-text-blocks {
    width: 100%;
    padding: 60px 24px;
  }

  .function-text-block {
    top: 50%;
    left: 24px;
    right: 24px;
    transform: translateY(-50%);
  }

  .function-text-block .btn {
    width: 100%;
    align-self: stretch;
    justify-content: center;
  }

  .function-progress-indicator {
    height: 600px;
  }
}

/* ==================== RESPONSIVE: MOBILE (<768px) ==================== */
@media (max-width: 768px) {
  .function-item {
    grid-template-columns: 1fr;
    gap: var(--spacing-2xl);
  }

  .function-content {
    padding-left: 0;
  }

  .function-number {
    font-size: var(--font-display-l-size);
  }

  /* PageSpeed */
  .pagespeed-container {
    padding: 24px;
    margin-top: 48px;
    max-width: calc(100% - 32px);
  }

  .pagespeed-header {
    flex-direction: column;
    align-items: center;
    gap: 0;
  }

  .pagespeed-title-container {
    padding: 6px 16px;
  }

  .pagespeed-title {
    font-size: 14px;
    line-height: 20px;
  }

  .pagespeed-link {
    display: none;
  }

  .pagespeed-divider-horizontal {
    display: none;
  }

  .pagespeed-content {
    flex-direction: column;
    align-items: center;
    gap: 24px;
  }

  .pagespeed-logo-container {
    gap: 8px;
  }

  .pagespeed-divider-vertical-container {
    display: none;
  }

  /* 4 метрики в сетке 2x2 */
  .pagespeed-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    width: 100%;
  }

  .pagespeed-metric {
    width: auto;
    flex: none;
  }

  .pagespeed-link-mobile {
    display: block;
    font-family: 'Onest', sans-serif;
    font-size: 14px;
    font-weight: 500;
    line-height: 20px;
    letter-spacing: -0.28px;
    color: #7E7E7E;
    text-decoration: none;
    text-align: center;
  }

  /* Function scroll - Mobile */
  .function-scroll-section {
    min-height: 4800px;
    padding: 0;
  }

  .function-badge-wrapper {
    padding-top: 24px;
    padding-bottom: 16px;
  }

  .function-badge-wrapper .section-badge {
    font-size: 12px;
    line-height: 18px;
    letter-spacing: -0.24px;
    padding: 4px 16px;
  }

  .function-header {
    margin-bottom: 20px;
    padding: 0 16px;
  }

  .function-scroll-content {
    position: sticky;
    top: 80px;
    display: flex !important;
    flex-direction: column !important;
    height: auto;
    min-height: 500px;
    gap: 50px;
    justify-content: flex-start;
    align-items: center;
    padding: 16px;
    max-width: 100%;
  }

  .function-scroll-right {
    order: 1 !important;
    flex-shrink: 0;
    width: 100%;
    height: 300px;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    margin-bottom: 24px;
  }

  .function-scroll-left {
    order: 2 !important;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    align-items: stretch;
  }

  .function-progress-indicator {
    display: flex !important;
    width: 100% !important;
    height: 22px;
    flex-direction: row;
    align-items: center;
    order: 1;
    margin-bottom: 16px;
  }

  .progress-dot {
    position: relative;
    bottom: auto;
    left: 0;
    flex-shrink: 0;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .progress-line {
    position: relative;
    bottom: auto;
    top: auto;
    left: auto;
    transform: none;
    width: calc(100% - 22px);
    height: 4px;
    margin-top: 0;
    background: linear-gradient(90deg, #DDDDDD 0%, rgba(221, 221, 221, 0.2) 100%);
    border-radius: 2px;
  }

  .function-text-blocks {
    width: 100%;
    max-width: 100%;
    min-height: 500px;
    padding: 0;
    order: 2 !important;
  }

  .function-text-block {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    gap: 20px;
    align-items: stretch;
  }

  .function-text-block.active {
    position: relative;
    display: flex;
    flex-direction: column;
    opacity: 1;
    visibility: visible;
    width: 100%;
  }

  .function-text-block:not(.active) {
    display: none;
  }

  .function-text-block .function-number {
    display: none;
  }

  .function-header h2 {
    font-size: 24px;
    line-height: 32px;
    font-weight: 500;
    letter-spacing: -0.48px;
  }

  .function-header p {
    font-size: 14px;
    line-height: 20px;
    letter-spacing: -0.28px;
  }

  .function-text-block .display-m {
    font-size: 20px;
    line-height: 30px;
    letter-spacing: -0.4px;
    text-align: center;
    background: linear-gradient(180deg, #FFFFFF 0%, rgba(255, 255, 255, 0.8) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent; /* Firefox fix */
  }

  .function-text-block .text-xl {
    font-size: 14px;
    line-height: 20px;
    letter-spacing: -0.28px;
    text-align: center;
  }

  .function-text-block .btn {
    width: 100%;
    align-self: stretch;
    justify-content: center;
    font-size: 14px;
    line-height: 20px;
    margin-top: 20px;
  }

  .function-phone-frame {
    width: 200px;
    height: 412px;
  }

  .phone-scrollable-content {
    top: 7px;
    left: 8px;
    width: 184px;
    height: 398px;
    border-radius: 27px;
  }

  .phone-glow {
    display: none;
  }
}
