/* =============================================================
   УМНАЯ ФЕРМА — ПОЛНЫЙ АДАПТИВНЫЙ style.css
   ЗАМЕНИТЬ СТАРЫЙ css/style.css ЦЕЛИКОМ.

   HTML: .home > .topbar + .hero-screen
         .hero-screen > .hero-copy + .hero-visual + .footer
         .hero-copy > .title-image + .subtitle + .description
                      + .hint + .start-button
         .hero-visual > .farm-bg + .hero-image

   Изображения:
     ../assets/logo.svg
     ../assets/title.png
     ../assets/hero.png
     ../assets/farm-bg.png
     ../assets/farm-bg-desktop.png

   Экраны:
     1) вертикальный телефон
     2) горизонтальный телефон
     3) вертикальный планшет
     4) горизонтальный планшет / небольшое окно ПК
     5) большой ПК

   Все настройки — В ОДНОМ ФАЙЛЕ. Не подключать отдельный
   umnaya_ferma_tablet.css поверх этого файла.
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800;900&display=swap');

:root {
    --aqua: #66c3d0;
    --ink: #14394b;
    --muted: #567e8b;
    --footer-bottom: 10px;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 0; min-height: 100%; margin: 0; }
body { background: #e9f7fa; color: var(--ink); font-family: 'Nunito', Arial, sans-serif; }
button { font-family: inherit; }

/* ОДИН ЭКРАН: фон всегда на всю доступную область. */
.home {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    margin: 0;
    overflow: hidden;
    background: #eaf8ff;
}

.home::before,
.home::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.home::before {
    z-index: -2;
    background: url('../assets/farm-bg.png') center center / cover no-repeat;
}
.home::after {
    z-index: -1;
    background: linear-gradient(to bottom,
        rgba(255,255,255,.12), rgba(255,255,255,.03) 40%, transparent 65%);
}

/* Логотип */
.topbar {
    position: relative;
    z-index: 5;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    padding: 10px 16px 0;
}
.brand-logo { display: block; width: 150px; max-width: 75%; height: auto; }
.menu-button { display: none; }

/* =============================================================
   БАЗОВЫЙ ЭКРАН: ТЕЛЕФОН ВЕРТИКАЛЬНО
   Порядок: название → тексты → персонажи → кнопка.
   Родитель .hero-copy имеет display: contents, поэтому order
   работает непосредственно для всех его элементов.
   ============================================================= */
.hero-screen {
    position: relative;
    z-index: 1;
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 0;
    padding: 0 14px 35px; /* место для копирайта */
    text-align: center;
}
.hero-copy { display: contents; }
.title-image {
    order: 1;
    display: block;
    flex: 0 0 auto;
    width: min(100%, 345px);
    height: auto;
    margin: 0 auto;
}
.subtitle {
    order: 2;
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    width: fit-content;
    max-width: 100%;
    margin: -28px auto 0;
    padding: 7px 20px;
    border-radius: 999px;
    background: rgba(215,246,248,.94);
    color: #239cab;
    font-size: 17px;
    font-weight: 800;
    line-height: 1.2;
}
.description {
    order: 3;
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    width: 100%;
    max-width: 390px;
    margin: 9px auto 0;
    color: #173b4d;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.3;
    letter-spacing: -.2px;
    text-align: center;
}
.description::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: -10px;
    bottom: -24px;
    left: 50%;
    width: calc(100% + 26px);
    max-width: 480px;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at center,
        rgba(255,255,255,.86), rgba(255,255,255,.4) 55%, transparent 80%);
    pointer-events: none;
}
.hint {
    order: 4;
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    width: 100%;
    max-width: 390px;
    margin: 5px auto 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
    text-align: center;
    text-shadow: 0 1px 5px rgba(255,255,255,.94);
}

/* Персонажи целиком внутри картинки: никаких агрессивных scale(). */
.hero-visual {
    order: 5;
    position: relative;
    display: flex;
    flex: 0 0 auto;
    align-items: flex-end;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 0;
    margin-top: 12px;
    overflow: visible;
}
.farm-bg { display: none; }
.hero-image {
    display: block;
    flex: 0 1 auto;
    width: min(92vw, 355px);
    max-width: 100%;
    max-height: min(37dvh, 320px);
    height: auto;
    object-fit: contain;
    object-position: center bottom;
    transform: none;
    filter: none;
}
.hero-visual::after { display: none; }

/* Кнопка */
.start-button {
    order: 6;
    position: relative;
    z-index: 3;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: 100%;
    max-width: 350px;
    min-height: 54px;
    margin: 10px auto 0;
    padding: 8px 18px;
    border: 3px solid rgba(255,255,255,.96);
    border-radius: 999px;
    background: linear-gradient(180deg,#7ad9e5 0%,#43c7d6 45%,#19b7c8 100%);
    box-shadow: 0 10px 24px rgba(25,183,200,.28),
                inset 0 2px 0 rgba(255,255,255,.45),
                inset 0 -3px 0 rgba(0,0,0,.08);
    color: white;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: .2px;
    cursor: pointer;
    overflow: hidden;
    transition: transform .2s ease, box-shadow .2s ease;
}
.start-button::before {
    content: "";
    position: absolute;
    inset: 6px 10px auto;
    height: 42%;
    border-radius: 999px;
    background: linear-gradient(to bottom,rgba(255,255,255,.36),rgba(255,255,255,.04));
    pointer-events: none;
}
.start-button > span { position: relative; z-index: 1; }
.start-button:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(25,183,200,.32), inset 0 2px 0 rgba(255,255,255,.45); }
.start-button:active { transform: translateY(1px) scale(.985); }
.start-button:focus-visible { outline: 3px solid #087f90; outline-offset: 3px; }
.arrow { font-size: 25px; line-height: 1; }

/* Копирайт ВСЕГДА внизу и по центру, также на планшете. */
.footer {
    order: 7;
    position: absolute;
    z-index: 6;
    right: 0;
    bottom: max(var(--footer-bottom), env(safe-area-inset-bottom, 0px));
    left: 0;
    width: 100%;
    margin: 0;
    padding: 0 8px;
    color: #516d78;
    font-size: 10px;
    line-height: 1.3;
    text-align: center;
    text-shadow: 0 1px 5px #fff;
    pointer-events: none;
}

/* Пользовательская настройка: весь текст над героями немного выше,
   сами герои и кнопка не смещаются. */
@media (orientation: portrait) and (max-width: 600px) {
    .title-image, .subtitle, .description, .hint {
        position: relative;
        top: -20px;
    }
}

/* =============================================================
   ТЕЛЕФОНЫ ВЕРТИКАЛЬНО — короткая высота
   ============================================================= */
@media (orientation: portrait) and (max-width: 600px) and (max-height: 750px) {
    .topbar { padding-top: 6px; }
    .brand-logo { width: 140px; }
    .hero-screen { padding-bottom: 28px; }
    .hero-screen { justify-content: flex-start; padding-top: 18px; }
    .title-image { width: min(100%, 275px); }
    .subtitle { margin-top: -23px; padding: 6px 17px; font-size: 15px; }
    .description { margin-top: 6px; font-size: 14px; line-height: 1.27; }
    .hint { margin-top: 4px; font-size: 12px; }
    .hero-visual { margin-top: 9px; }
    .hero-image { width: min(86vw, 310px); max-height: min(33dvh, 245px); }
    .start-button { min-height: 48px; margin-top: 7px; font-size: 18px; }
    .footer { font-size: 9px; }
}
@media (orientation: portrait) and (max-width: 600px) and (max-height: 630px) {
    .brand-logo { width: 125px; }
    .title-image { width: min(100%, 232px); }
    .subtitle { margin-top: -19px; font-size: 14px; }
    .description { font-size: 13px; }
    .hint { font-size: 11px; }
    .hero-visual { margin-top: 6px; }
    .hero-image { width: min(80vw, 260px); max-height: 30dvh; }
    .start-button { min-height: 43px; margin-top: 5px; font-size: 16px; }
}
/* На среднем по высоте телефоне освобождаем место под кнопку и копирайт. */
@media (orientation: portrait) and (max-width: 400px) and (min-height: 751px) {
    .title-image { width: min(100%, 315px); }
    .subtitle { margin-top: -26px; }
    .hero-image { max-height: min(34dvh, 295px); }
}
@media (orientation: portrait) and (max-width: 360px) {
    .hero-screen { padding-right: 10px; padding-left: 10px; }
    .description { font-size: 14px; }
    .hint { font-size: 12px; }
}

/* =============================================================
   ПЛАНШЕТ ВЕРТИКАЛЬНО
   601–1199px по ширине: 768×1024, 820×1180, 834×1194,
   1032×1376, Android 800×1280.
   Текст сверху, персонажи, кнопка; высоты не растягиваются.
   ============================================================= */
@media (orientation: portrait) and (min-width: 601px) and (max-width: 1199px) {
    .home { max-width: none; }
    .topbar { padding: 15px 22px 0; }
    .brand-logo { width: clamp(175px, 20vw, 205px); max-width: none; }
    .hero-screen {
        justify-content: center;
        padding: 0 24px 39px;
    }
    .title-image { width: min(62vw, 460px); margin: 0 auto; }
    .subtitle {
        margin: -34px auto 0;
        padding: 9px 27px;
        font-size: clamp(18px, 2vw, 21px);
    }
    .description {
        max-width: 570px;
        margin: 14px auto 0;
        font-size: clamp(18px, 2.1vw, 22px);
        line-height: 1.32;
    }
    .hint { max-width: 560px; margin-top: 8px; font-size: clamp(15px, 1.75vw, 18px); }
    .hero-visual { margin-top: clamp(8px, 1.1dvh, 16px); }
    .hero-image {
        width: min(72vw, 555px);
        max-width: 100%;
        max-height: min(37dvh, 480px);
        height: auto;
    }
    .start-button {
        width: min(75vw, 380px);
        max-width: 380px;
        min-height: 60px;
        margin-top: 13px;
        font-size: 22px;
    }
    .footer { font-size: 11px; }
}
/* 768×1024: специально освобождаем нижнюю область под кнопку. */
@media (orientation: portrait) and (min-width: 601px) and (max-width: 1199px) and (max-height: 1100px) {
    .title-image { width: min(58vw, 410px); }
    .subtitle { margin-top: -29px; }
    .hero-image { width: min(66vw, 465px); max-height: 33dvh; }
    .start-button { margin-top: 10px; }
}
/* Низкий вертикальный планшет: всё обязано оставаться внутри экрана. */
@media (orientation: portrait) and (min-width: 601px) and (max-height: 960px) {
    .title-image { width: min(57vw, 390px); }
    .subtitle { margin-top: -27px; font-size: 17px; padding: 7px 22px; }
    .description { margin-top: 8px; font-size: 17px; }
    .hint { margin-top: 5px; font-size: 14px; }
    .hero-visual { margin-top: 6px; }
    .hero-image { width: min(64vw, 455px); max-height: 35dvh; }
    .start-button { min-height: 52px; margin-top: 7px; font-size: 19px; }
}

/* =============================================================
   ВЫСОКИЕ ВЕРТИКАЛЬНЫЕ ПЛАНШЕТЫ — 820×1180, 834×1194,
   800×1280.
   Фон выше относительно героев, чтобы нарисованные тени были
   ближе к копытам. Текстовая группа начинается выше,
   изображение и кнопка сохраняют удобное положение.
   ============================================================= */
@media (orientation: portrait) and (min-width: 790px) and (max-width: 949px) and (min-height: 1101px) {
    .home::before { background-position: center 82%; }
    .hero-screen {
        justify-content: flex-start;
        padding-top: clamp(4px, 1.3dvh, 20px);
        padding-bottom: 39px;
    }
    .title-image { width: min(64vw, 475px); }
    .description { max-width: 600px; font-size: 20px; line-height: 1.35; }
    .hint { font-size: 17px; }
    .hero-visual { margin-top: clamp(32px, 3.1dvh, 40px); }
    .hero-image {
        width: min(70vw, 555px);
        max-height: min(37dvh, 480px);
    }
    .start-button { margin-top: 16px; }
}

/* =============================================================
   ОБЩИЙ ГОРИЗОНТАЛЬНЫЙ МАКЕТ
   Левый блок целиком; персонажи справа.
   ============================================================= */
@media (orientation: landscape) and (min-width: 601px) {
    .home::before {
        background-image: url('../assets/farm-bg-desktop.png');
        background-position: center center;
    }
    .home::after {
        background: linear-gradient(90deg,
            rgba(255,255,255,.35), rgba(255,255,255,.13) 46%, transparent 75%);
    }
    .hero-screen {
        display: grid;
        grid-template-columns: minmax(0, 48fr) minmax(0, 52fr);
        grid-template-rows: minmax(0, 1fr);
        align-items: stretch;
        justify-content: stretch;
        column-gap: 14px;
        padding: 0 4% 38px;
    }
    .hero-copy {
        display: flex;
        grid-column: 1;
        grid-row: 1;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        align-self: stretch;
        width: 100%;
        min-width: 0;
        min-height: 0;
        margin: 0;
        text-align: center;
        transform: none;
    }
    .hero-copy .title-image { width: min(100%, 410px); margin: 0 auto; }
    .hero-copy .subtitle { margin: -31px auto 0; font-size: 18px; padding: 8px 25px; }
    .hero-copy .description { max-width: 475px; margin: 15px auto 0; font-size: 19px; }
    .hero-copy .hint { max-width: 470px; margin: 8px auto 0; font-size: 16px; }
    .hero-copy .start-button {
        width: min(100%, 335px);
        max-width: 335px;
        min-height: 59px;
        margin: 25px auto 0;
        font-size: 21px;
    }
    .hero-visual {
        display: flex;
        grid-column: 2;
        grid-row: 1;
        align-self: stretch;
        align-items: flex-end;
        justify-content: center;
        width: 100%;
        height: 100%;
        min-width: 0;
        min-height: 0;
        margin: 0;
        overflow: visible;
        transform: translateY(-15px);
    }
    .hero-image {
        display: block;
        width: min(100%, 530px);
        max-width: 100%;
        max-height: min(75dvh, 570px);
        height: auto;
        object-fit: contain;
        object-position: center bottom;
        transform: none;
    }
}

/* =============================================================
   ПЛАНШЕТ ГОРИЗОНТАЛЬНО, включая 1180×820 и 1366×1024.
   Нет (pointer:coarse)! В Responsive DevTools работает так же,
   как на реальном планшете. Не перехватываем большой ПК.
   ============================================================= */
@media (orientation: landscape) and (min-width: 768px) and (max-width: 1399px) and (min-height: 601px) {
    .topbar { padding: 12px 18px 0; }
    .brand-logo { width: clamp(165px, 17vw, 195px); max-width: none; }
    .hero-screen {
        grid-template-columns: minmax(0, 48fr) minmax(0, 52fr);
        column-gap: 14px;
        padding: 0 clamp(20px, 4vw, 55px) 35px;
    }
    .hero-copy { transform: translateY(-4px); }
    .hero-copy .title-image { width: min(100%, 405px); }
    .hero-copy .subtitle { margin-top: -30px; font-size: 17px; padding: 8px 24px; }
    .hero-copy .description { max-width: 465px; margin-top: 12px; font-size: 18px; }
    .hero-copy .hint { margin-top: 8px; font-size: 16px; }
    .hero-copy .start-button { width: min(100%, 330px); min-height: 58px; margin-top: 24px; font-size: 20px; }
    .hero-visual { transform: translate(-5px, -23px); }
    .hero-image { width: min(100%, 515px); max-height: min(72dvh, 530px); }
    .footer { font-size: 10px; }
}
/* Небольшой планшет 1024×768: делаем композицию компактнее. */
@media (orientation: landscape) and (min-width: 768px) and (max-width: 1100px) and (min-height: 601px) {
    .brand-logo { width: 175px; }
    .hero-copy .title-image { width: min(100%, 355px); }
    .hero-copy .subtitle { margin-top: -26px; font-size: 16px; }
    .hero-copy .description { font-size: 17px; margin-top: 10px; }
    .hero-copy .hint { font-size: 14px; margin-top: 6px; }
    .hero-copy .start-button { max-width: 300px; min-height: 54px; margin-top: 18px; font-size: 19px; }
    .hero-visual { transform: translate(-4px, -20px); }
    .hero-image { width: min(100%, 450px); max-height: 70dvh; }
}

/* =============================================================
   ТЕЛЕФОН ГОРИЗОНТАЛЬНО: почти нет высоты.
   ============================================================= */
@media (orientation: landscape) and (max-height: 600px) and (max-width: 1000px) {
    .home::before { background-image: url('../assets/farm-bg-desktop.png'); }
    .topbar { padding: 4px 12px 0; }
    .brand-logo { width: 110px; max-width: none; }
    .hero-screen {
        display: grid;
        grid-template-columns: minmax(0, 45fr) minmax(0, 55fr);
        grid-template-rows: minmax(0, 1fr);
        column-gap: 8px;
        padding: 0 16px 20px;
    }
    .hero-copy { display: flex; grid-column: 1; grid-row: 1; flex-direction: column; align-items: center; justify-content: center; min-width: 0; transform: none; }
    .hero-copy .title-image { width: min(100%, 190px); }
    .hero-copy .subtitle { margin-top: -12px; padding: 4px 12px; font-size: 11px; }
    .hero-copy .description { margin-top: 5px; font-size: 11px; line-height: 1.25; }
    .hero-copy .hint { margin-top: 3px; font-size: 10px; line-height: 1.25; }
    .hero-copy .start-button { width: min(100%, 230px); min-height: 36px; margin-top: 9px; padding: 4px 10px; gap: 8px; font-size: 13px; }
    .arrow { font-size: 16px; }
    .hero-visual { grid-column: 2; grid-row: 1; height: 100%; margin: 0; transform: translateY(-3px); }
    .hero-image { width: min(100%, 300px); max-height: 86%; }
    .footer { font-size: 8px; --footer-bottom: 5px; }
}
@media (orientation: landscape) and (max-height: 340px) and (max-width: 1000px) {
    .hero-copy .title-image { width: min(100%, 145px); }
    .hero-copy .subtitle { margin-top: -8px; }
    .hero-copy .description { font-size: 10px; margin-top: 3px; }
    .hero-copy .hint { font-size: 9px; }
    .hero-copy .start-button { min-height: 32px; margin-top: 5px; }
    .hero-image { max-height: 83%; }
}

/* =============================================================
   БОЛЬШОЙ ПК ОТ 1400px
   Выразительный крупный заголовок + крупные герои; размер
   картинки ограничен колонкой — хвост не обрезается.
   ============================================================= */
@media (min-width: 1400px) {
    .home::before { background-image: url('../assets/farm-bg-desktop.png'); }
    .topbar { padding: 12px 18px 0; }
    .brand-logo { width: 230px; max-width: none; }
    .hero-screen {
        display: grid;
        grid-template-columns: minmax(0, 48fr) minmax(0, 52fr);
        grid-template-rows: minmax(0, 1fr);
        column-gap: 12px;
        padding: 0 clamp(25px, 3.4vw, 58px) 30px;
    }
    .hero-copy { display: flex; grid-column: 1; grid-row: 1; transform: translate(0, -35px); }
    .hero-copy .title-image { width: min(100%, 625px); }
    .hero-copy .subtitle { margin-top: -45px; padding: 11px 32px; font-size: 22px; }
    .hero-copy .description { max-width: 610px; margin-top: 20px; font-size: 23px; line-height: 1.35; }
    .hero-copy .hint { max-width: 580px; margin-top: 12px; font-size: 19px; }
    .hero-copy .start-button {
        width: min(100%, 395px);
        max-width: 395px;
        min-height: 68px;
        margin-top: 35px;
        font-size: 24px;
    }
    .hero-visual { grid-column: 2; grid-row: 1; transform: translate(0, -55px); }
    .hero-image {
        width: min(100%, 760px);
        max-width: 100%;
        max-height: min(84dvh, 760px);
        transform: none;
    }
    .footer { font-size: 11px; }
}
/* ПК небольшой высоты: не позволяем нижней части уходить за экран. */
@media (min-width: 1400px) and (max-height: 800px) {
    .brand-logo { width: 195px; }
    .hero-copy { transform: translateY(-8px); }
    .hero-copy .title-image { width: min(100%, 430px); }
    .hero-copy .subtitle { margin-top: -33px; font-size: 18px; }
    .hero-copy .description { margin-top: 11px; font-size: 18px; }
    .hero-copy .hint { margin-top: 8px; font-size: 16px; }
    .hero-copy .start-button { min-height: 56px; margin-top: 20px; font-size: 20px; }
    .hero-visual { transform: translateY(-23px); }
    .hero-image { max-height: 80dvh; }
}

@media (prefers-reduced-motion: reduce) {
    .start-button { transition: none; }
}
/* Плавный уход с главной страницы */
body {
    transition: opacity 0.4s ease;
}

body.page-leaving {
    opacity: 0;
}