/* Hero: главный экран и его визуальная композиция. */

/* Каркас и фон */
#hero {
    min-height: 100vh;
    min-height: 100svh;
    padding: clamp(7rem, 11vh, 9rem) 0 clamp(4rem, 8vh, 6rem);
    position: relative;
    isolation: isolate;
    overflow: hidden;
}

#hero::before {
    inset: 0;
    width: auto;
    height: auto;
    z-index: -2;
    opacity: 0.28;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 54px 54px;
    mask-image: linear-gradient(to bottom, transparent 4%, #000 34%, transparent 96%);
    mix-blend-mode: normal;
    filter: none;
}

[data-theme="light"] #hero::before {
    opacity: 0.34;
    background-image:
        linear-gradient(rgba(15, 23, 42, 0.06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.06) 1px, transparent 1px);
    filter: none;
    mix-blend-mode: normal;
}

/* Основная композиция */
#hero .hero-wrapper {
    width: 100%;
    max-width: 1460px;
    margin: 0 auto;
    padding-inline: clamp(1.5rem, 5vw, 4.5rem);
    display: flex;
    justify-content: center;
}

#hero .hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(500px, 0.92fr);
    gap: clamp(1rem, 3vw, 3.25rem);
    align-items: center;
    width: 100%;
}

/* Текст и действия */
#hero .hero-content {
    display: flex;
    flex-direction: column;
    max-width: 690px;
    padding: 0;
    animation: none;
}

#hero .hero-content h1 {
    max-width: 14ch;
    margin: 0 0 1.4rem;
    font-size: clamp(3rem, 4.15vw, 4.35rem);
    line-height: 1.03;
    font-weight: 700;
    letter-spacing: -0.052em;
    text-wrap: balance;
}

#hero .hero-content h1 span {
    background: var(--gradient-1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#hero .hero-description {
    max-width: 59ch;
    margin: 0 0 2rem;
    font-size: clamp(1.02rem, 1.25vw, 1.17rem);
    line-height: 1.68;
    text-wrap: pretty;
}

#hero .hero-buttons {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 2.25rem;
}

#hero .hero-buttons .btn {
    min-height: 3.35rem;
}

#hero .hero-buttons .btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
}

#hero .hero-buttons .btn:active {
    scale: 0.96;
}

/* Визуальная сцена */
#hero .hero-visual {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 640px;
    aspect-ratio: 640 / 380;
}

/* Фоновые слои */
#hero .ui-layer {
    position: absolute;
    border-radius: 16px;
    pointer-events: none;
    overflow: hidden;
    box-sizing: border-box;
    transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.7s ease, filter 0.4s ease;
}

#hero .layer-back-1 {
    width: 340px;
    height: 220px;
    background: color-mix(in srgb, var(--bg-card) 25%, transparent);
    border: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
    transform: translate(-90px, -55px) rotate(-5deg);
    z-index: -1;
    opacity: 0.35;
    padding: 16px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
}

#hero .layer-back-2 {
    width: 220px;
    height: 280px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--bg-card) 50%, transparent), transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 15%, transparent);
    transform: translate(140px, 45px) rotate(6deg);
    z-index: -2;
    opacity: 0.25;
    padding: 20px;
    display: flex;
    align-items: flex-end;
}

#hero .mock-code {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-family: monospace;
    font-size: 11px;
    color: var(--text-secondary);
    text-align: left;
    line-height: 1.4;
    opacity: 0.7;
}

#hero .mock-code span:nth-child(2) {
    padding-left: 12px;
    color: var(--accent);
}

#hero .mock-chart {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    width: 100%;
    height: 100px;
}

#hero .mock-chart .bar {
    flex: 1;
    background: linear-gradient(to top, color-mix(in srgb, var(--accent) 30%, transparent), var(--accent));
    border-radius: 4px;
    opacity: 0.5;
    transform-origin: bottom;
    transition: transform 0.3s ease;
}

#hero .mock-chart .bar:nth-child(1) { height: 40%; }
#hero .mock-chart .bar:nth-child(2) { height: 75%; }
#hero .mock-chart .bar:nth-child(3) { height: 55%; }
#hero .mock-chart .bar:nth-child(4) { height: 90%; }

/* Glitch canvas */
#hero .cardGlitchCanvas {
    display: block !important;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#hero .hero-visual::before {
    content: '';
    position: absolute;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, color-mix(in srgb, var(--accent) 25%, transparent), transparent 65%);
    filter: blur(60px);
    -webkit-filter: blur(60px);
    z-index: -3;
    pointer-events: none;
}

#hero .hero-visual:hover .layer-back-1 {
    transform: translate(-50px, -25px) rotate(-2deg);
    opacity: 0.65;
}

#hero .hero-visual:hover .layer-back-2 {
    transform: translate(95px, 15px) rotate(4deg);
    opacity: 0.5;
}

#hero .hero-visual:hover .mock-chart .bar {
    transform: scaleY(1.15);
}

/* Плавающие карточки */
#hero .floating-card {
    width: 100% !important;
    height: 100% !important;
    max-width: 640px !important;
    min-height: 380px !important;
    position: relative;
    display: flex !important;
}

/* Анимации сцены */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

@keyframes floatMain {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes codeakVisualEnter {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes codeakHeroEnter {
    from {
        opacity: 0;
        transform: translateY(20px);
        filter: blur(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

/* Появление контента */
@media (prefers-reduced-motion: no-preference) {
    #hero .hero-content > * {
        opacity: 0;
        animation: codeakHeroEnter 0.72s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    }

    #hero .hero-content > :nth-child(2) { animation-delay: 0.08s; }
    #hero .hero-content > :nth-child(3) { animation-delay: 0.16s; }
}

/* Адаптивная композиция */
@media (max-width: 1300px) {
    section#hero {
        padding-top: clamp(6.5rem, 10vh, 8rem);
    }

    #hero .hero-grid {
        grid-template-columns: minmax(0, 1.12fr) minmax(440px, 0.88fr);
        gap: 0.75rem;
        text-align: left;
    }

    #hero .hero-content {
        align-items: flex-start;
        max-width: 640px;
        margin: 0;
        padding: 0;
        text-align: left;
    }

    #hero .hero-content h1,
    #hero .hero-description {
        margin-left: 0;
        margin-right: 0;
        text-align: left;
    }

    #hero .hero-content h1 {
        font-size: clamp(2.8rem, 4.2vw, 3.45rem);
    }

    #hero .hero-description {
        max-width: 55ch;
        font-size: 1.02rem;
    }

    #hero .hero-buttons {
        justify-content: flex-start;
        width: 100%;
    }

    #hero .hero-visual {
        height: 520px;
    }

  #hero .floating-card {
    width: 100% !important;
    max-width: 460px !important;
    min-height: auto !important;
    aspect-ratio: 640 / 380;
  }
      #hero .layer-back-1 {
    width: 260px;
    height: 170px;
    transform: translate(-50px, -40px) rotate(-4deg);
    padding: 12px;
  }
  #hero .mock-code {
    font-size: 9px;
    gap: 4px;
  }

  #hero .layer-back-2 {
    width: 170px;
    height: 210px;
    transform: translate(90px, 30px) rotate(4deg);
    padding: 14px;
  }
  #hero .mock-chart {
    height: 70px;
    gap: 8px;
  }

  #hero .hero-visual:hover .layer-back-1 {
    transform: translate(-30px, -20px) rotate(-2deg);
  }
  #hero .hero-visual:hover .layer-back-2 {
    transform: translate(65px, 15px) rotate(2deg);
  }
}

@media (max-width: 1080px) {
      #hero .floating-card {
        max-width: 540px !important;
        margin: 0 auto;
    }

    #hero .hero-grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    #hero .hero-content {
        align-items: center;
        max-width: 760px;
        margin-inline: auto;
        text-align: center;
    }

    #hero .hero-content h1,
    #hero .hero-description {
        margin-left: auto;
        margin-right: auto;
        text-align: center;
    }

    #hero .hero-content h1 {
        max-width: 16ch;
        font-size: clamp(2.65rem, 6vw, 3.6rem);
    }

    #hero .hero-description {
        max-width: 62ch;
    }

    #hero .hero-buttons {
        justify-content: center;
    }

    #hero .hero-visual {
        width: min(100%, 720px);
        height: 390px;
        margin-inline: auto;
    }

}

@media (max-width: 600px) {
    section#hero {
        min-height: 100svh;
        padding: 5.7rem 0 2.75rem;
    }

    #hero .hero-wrapper {
        padding-inline: 1rem;
    }

    #hero .hero-grid {
        gap: 0.7rem;
    }

    #hero .hero-content {
        padding: 0;
    }

    #hero .hero-content h1 {
        max-width: 100%;
        margin-bottom: 1rem;
        font-size: clamp(1.75rem, 8.25vw, 2.35rem);
        line-height: 1.08;
        letter-spacing: -0.042em;
    }

    #hero .hero-description {
        max-width: 38ch;
        margin-bottom: 1.35rem;
        font-size: 0.96rem;
        line-height: 1.55;
    }

    #hero .hero-buttons {
        flex-direction: column;
        gap: 0.7rem;
        margin-bottom: 0;
    }

    #hero .hero-buttons .btn {
        width: min(100%, 22rem);
        min-height: 3rem;
        padding: 0.78rem 1rem;
        font-size: 0.92rem;
    }

    #hero .hero-visual {
        width: 100%;
        height: 285px;
    }

    #hero .hero-visual::before {
        width: 88%;
    }

  #hero .floating-card {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    aspect-ratio: 640 / 380;
  }
}

/* Уменьшенное движение */
@media (prefers-reduced-motion: reduce) {
    #hero .hero-content > *,
    #hero .hero-visual,
    #hero .floating-card {
        opacity: 1;
        animation: none;
        filter: none;
        transform: none;
        transition-duration: 0.01ms;
    }
}

/* Каскадные корректировки desktop-композиции */
@media (max-width: 1400px) {
  #hero .hero-grid {
    grid-template-columns: minmax(0, 1.15fr) minmax(420px, 0.85fr);
    gap: 1.5rem;
    align-items: center;
  }
  #hero .hero-content {
    align-items: flex-start;
    max-width: 100%;
    text-align: left;
  }
  #hero .hero-content h1,
  #hero .hero-description {
    margin-left: 0;
    margin-right: 0;
    text-align: left;
  }
  #hero .hero-description {
    max-width: 100%;
    font-size: 1rem;
  }
  #hero .hero-buttons {
    justify-content: flex-start;
  }
  #hero .hero-visual {
    width: 100%;
    max-width: 520px;
    height: auto;
    aspect-ratio: 640 / 380;
  }
  #hero .floating-card {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    min-height: auto !important;
  }
  #hero .layer-back-1 {
    width: 240px;
    height: 160px;
    transform: translate(-45px, -35px) rotate(-4deg);
    padding: 12px;
  }
  #hero .mock-code {
    font-size: 9px;
    gap: 4px;
  }
  #hero .layer-back-2 {
    width: 160px;
    height: 200px;
    transform: translate(65px, 25px) rotate(4deg);
    padding: 12px;
  }
  #hero .mock-chart {
    height: 60px;
    gap: 6px;
  }
  #hero .hero-visual:hover .layer-back-1 {
    transform: translate(-25px, -15px) rotate(-2deg);
  }
  #hero .hero-visual:hover .layer-back-2 {
    transform: translate(45px, 15px) rotate(2deg);
  }
}

/* Переход к компактному hero */
@media (max-width: 980px) {
  section#hero {
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(5.75rem, 10svh, 7rem) 0 clamp(2.5rem, 6svh, 4rem);
  }

  #hero .hero-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
    text-align: center;
  }
  #hero .hero-content {
    align-items: center;
    max-width: 760px;
    margin-inline: auto;
    text-align: center;
  }
  #hero .hero-content h1,
  #hero .hero-description {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
  }
  #hero .hero-description {
    max-width: 58ch;
  }
  #hero .hero-buttons {
    justify-content: center;
    margin-bottom: 0;
  }
  #hero .hero-visual {
    display: none;
  }
}
