/* CSS-ПЕРЕМЕННЫЕ */
:root {
    --white: #ffffff;
    --hover: #437257;
    --accent: #2a583f;
    --bg: #0c0c0c;
    --gray: #303030;
    --header-bg: rgba(12, 12, 12, 0.1);

    --radius-btn: 8px;
    --radius-card: 12px;

    --font: 'Alumni Sans', sans-serif;

    --fs-hero: clamp(48px, 7vw, 82px);
    --fs-h2: clamp(32px, 4vw, 48px);
    --fs-body: clamp(20px, 1.5vw, 30px);
    --fs-btn: clamp(24px, 1.5vw, 26px);

    --gap-para: 20px;

    /* =============================================
ЕТКА — настройки паттерна
Меняй --grid-size для изменения размера ячеек
Меняй --grid-color для изменения цвета линий
============================================= */
    --grid-size: 64px;
    --grid-color: rgba(255, 255, 255, 0.07);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    overflow-x: hidden;
    max-width: 100vw;
}

html,
.viewer-container {
    scroll-behavior: auto;
}

body {
    background-color: var(--bg);
    color: var(--white);
    font-family: var(--font);
    font-size: var(--fs-body);
    line-height: 1.4;
    overflow-x: hidden;
}

/* =============================================
СЕТКА — CSS-паттерн (без внешних файлов)
Рисуется через linear-gradient
Точно как на скриншотах: тёмный фон + тонкие светлые линии
============================================= */
.grid-bg {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: var(--grid-size) var(--grid-size);
    pointer-events: none;
    z-index: 0;
    /* Плавное исчезновение снизу:
         сверху сетка полностью видна, снизу растворяется в фон.
         Меняй 40% чтобы регулировать где начинается растворение */
    -webkit-mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 40%, transparent 100%);
}

.grid-bg canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* =============================================
ШАПКА
============================================= */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 14px 48px;
    max-width: 100vw;
    background: var(--header-bg);
    backdrop-filter: blur(32px);
    -webkit-backdrop-filter: blur(32px);
    border-bottom: 1px solid var(--gray);
    box-sizing: border-box;
}
header .wrapper,
footer .wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}
/* «Я иллюстратор ↗» — подчёркивание цвета hover при наведении */

.nav-link,
.nav-link p {
    font-size: var(--fs-btn);
    font-weight: 500;
    color: var(--white);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
    white-space: normal;
    flex-wrap: wrap;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 1px;
    background-color: transparent;
    transition: background-color 0.2s ease;
}

.nav-link:hover::after {
    background-color: var(--hover);
}

.nav-actions {
    display: flex;
    gap: 12px;
}

footer {
    padding: 24px 48px;
    max-width: 100vw;
    border-top: 1px solid var(--gray);
    box-sizing: border-box;
}

/* =============================================
WRAPPER — ограничение ширины контента
============================================= */
.wrapper {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* =============================================
КНОПКИ
============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px 12px 20px;
    border-radius: var(--radius-btn);
    font-family: var(--font);
    font-size: var(--fs-btn);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition:
        background 0.2s,
        border-color 0.2s,
        color 0.2s;
    border: 1px solid transparent;
    line-height: 1;
}

/* Заливка → ховер меняет цвет */
.btn-filled {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}

.btn-filled:hover {
    background: var(--hover);
    border-color: var(--hover);
}

/* Аутлайн → серый фон при ховере */
.btn-outline {
    background: transparent;
    color: var(--white);
    border-color: var(--white);
}

.btn-outline:hover {
    background: var(--gray);
}

.btn-icon {
    width: 1em;
    height: 1em;
    flex-shrink: 0;
}

.btn-language {
    padding: 12px 16px 12px 16px;
}

/* =============================================
HERO
============================================= */
.hero {
    position: relative;
    min-height: 100%;
    padding: 140px 48px 80px;
    display: flex;
    align-items: center;
    width: 100%;
}

.hero .wrapper {
    flex-direction: row;
    align-items: center;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 650px;
    display: flex;
    flex-direction: column;
    gap: 48px;
}

.hero-identity {
    display: flex;
    align-items: center;
    gap: 40px;
}

/* Логотип — замени src на путь к своему файлу */
.hero-logo {
    width: 64px;
    height: auto;
    flex-shrink: 0;
}

/* Имя — правь текст прямо в HTML */
.hero-name {
    font-size: var(--fs-hero);
    font-weight: 700;
    line-height: 1;
    letter-spacing: 4%;
}

/* Блок образования */
.hero-edu {
    display: flex;
    flex-direction: column;
    gap: var(--gap-para);
}

.edu-hero {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

p {
    font-size: var(--fs-body);
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 4%;
}

.hero-actions {
    display: flex;
    flex-direction: column;
    width: 330px;
    gap: 24px;
}

.hero-actions .main-btns {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.hero-actions .secondary-btns {
    width: 100%;
    display: flex;
    flex-direction: row;
    gap: 16px;
}

.hero-actions .btn {
    width: 100%;
    justify-content: center;
}

/* 3D-изображение справа */
.hero-3d {
    position: absolute;
    align-items: center;
    right: 25%; /* Вместо 550px */
    width: 55%;
    top: 64%;
    transform: translateY(-50%);
    max-width: 650px;
    pointer-events: none;
}

.hero-3d img {
    width: 160%;
    height: auto;
    display: block;
}

/* =============================================
ПОРТФОЛИО
============================================= */

.portfolio .hero-name {
    margin-bottom: 32px;
}

.portfolio,
.about {
    padding: 80px 48px;
    width: 100%;
}

.section-title {
    font-size: var(--fs-hero);
    font-weight: 700;
}

.section-subtitle {
    margin-bottom: 64px;
}

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

/* =============================================
КАРТОЧКА ПОРТФОЛИО
Фон — сетка (та же CSS-сетка)
Ховер: масштаб + свечение + выезд панели
============================================= */
.card {
    position: relative;
    border-radius: var(--radius-card);
    overflow: hidden;
    aspect-ratio: 4 / 4;
    cursor: pointer;
    border: 1px solid var(--gray);
    transition:
        transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.35s ease;
}

.card:hover {
    transform: scale(1.035);
    box-shadow: 0 0 40px 8px rgba(67, 114, 87, 0.45);
}

/* Фоновая сетка карточки */
.card-grid-bg {
    position: absolute;
    inset: 0;
    background-color: #111;
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: var(--grid-size) var(--grid-size);
    z-index: 0;
}

/* Изображение карточки */
.card-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
}

/* Бейдж года */
.card-year {
    position: absolute;
    bottom: 5%;
    right: 0px;
    z-index: 3;
    background: var(--accent);
    color: var(--white);
    font-family: var(--font);
    font-size: var(--fs-btn);
    font-weight: 600;
    padding: 4px 24px;
    border-radius: 6px 0 0 6px;
}

/* =========================
VIEWER (ИСПРАВЛЕННЫЙ)
========================= */
.viewer {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 999;
}
.viewer.active {
    display: flex;
    justify-content: center;
    align-items: center;
}
.viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 15, 15, 0.7);
    backdrop-filter: blur(20px);
}
.viewer-container {
    position: relative;
    width: 100%;
    height: 100%;
    padding: 40px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    z-index: 1;

    overflow-y: auto;
    overflow-x: hidden;
}

.viewer-navigation {
    position: fixed;
    width: calc(100% - 120px);
    height: calc(100% - 100px);
    max-width: 940px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    display: flex;
    padding-top: 16px;
    z-index: 2;
    /* игнорирование прокрутки */
    pointer-events: none;
}

.viewer-close-area {
    position: fixed;
    width: calc(100% - 0px);
    height: calc(100% - 0px);
    margin-top: 0px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 0;
    /* игнорирование прокрутки */
    cursor: pointer;
}

.viewer-navigation button,
.viewer-navigation a {
    pointer-events: auto;
}

.viewer-contact {
    display: flex;
    width: 100%;
    justify-content: right;
    max-width: 768px;
}

.viewer-close-container {
    display: flex;
    width: 100%;
    justify-content: right;
}

.viewer-content {
    position: relative;
    width: 100%;
    height: auto;
    background: #111;
    border-radius: 16px;
    max-width: 800px;
    transform: scale(0.96);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    /* Чтобы padding не съедал ширину */
    box-sizing: border-box;

    /* Скрываем скроллбар для Firefox */
    scrollbar-width: none;

    /* Скрываем скроллбар для IE и Edge */
    -ms-overflow-style: none;
}

/* Скрываем скроллбар для Chrome, Safari и Opera */
.viewer-content::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.viewer.active .viewer-content {
    transform: scale(1);
    opacity: 1;
}

/* Кнопка закрытия (крестик) */
.viewer-close {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        background 0.2s,
        transform 0.2s;
    z-index: 10;
    /* Убираем стандартные стили кнопки */
    padding: 0;
    line-height: 1;
}
.viewer-close:hover {
    background: var(--accent);
    transform: scale(1.1);
}
.viewer-close svg {
    width: 24px;
    height: 24px;
    pointer-events: none;
}

/* Стрелки навигации */

.arrows {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
}

.viewer-prev,
.viewer-next {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition:
        background 0.2s,
        transform 0.2s;
    z-index: 10;
    padding: 0;
    line-height: 1;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) and (pointer: fine) {
    .viewer-prev:hover,
    .viewer-next:hover {
        background: var(--accent);
        transform: scale(1.1);
    }
}
.viewer-prev:active,
.viewer-next:active {
    background: var(--accent);
    transform: scale(1.05);
}
.viewer-prev svg,
.viewer-next svg {
    width: 24px;
    height: 24px;
    pointer-events: none;
}
/* Разворачиваем правую стрелку, чтобы смотрела вправо */
.viewer-next svg {
    transform: rotate(180deg);
}

/* Блокировка скролла body при открытом viewer */
body.no-scroll {
    overflow: hidden;
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
}

/* =========================
ABOUT ME
========================= */

.about .wrapper {
    display: flex;
    flex-direction: column;
    gap: 48px;
    margin-bottom: 148px;
}

.about > .hero-name {
    margin-bottom: 32px;
    font-size: clamp(42px, 6vw, 64px);
}

.wrapper-about {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 64px;
    align-items: flex-start;
}

.about .edu,
.about .expirience {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.about .subtitle {
    font-weight: 900;
}

@media (max-width: 920px) {
    .wrapper-about {
        grid-template-columns: 1fr;
    }
}

/* =========================
PROJECT CONTENT
========================= */

.project {
    max-width: 100%;
    margin: 0 auto;
    padding: 0px;
    border-radius: 16px;
    overflow: hidden;
}

.project img {
    width: 100%;
    margin-top: 0px;
    margin-bottom: 0px;
    display: block;
}

/* =============================================
   EDUCATION
============================================= */

/* =============================================
   АДАПТИВ (ИСПРАВЛЕННЫЙ)
============================================= */

/* Планшеты (1024px и меньше) */
@media (max-width: 1024px) {
    :root {
        --grid-size: 48px;
    }

    .hero-3d {
        width: 45%;
        right: 10%;
    }

    .hero-content {
        max-width: 55%;
    }
}

/* Малые планшеты / Большие телефоны (800px и меньше) */
@media (max-width: 800px) {
    header {
        width: 100%;
        padding: 12px 20px;
    }

    .hero,
    .portfolio {
        padding: 100px 20px 40px;
        min-height: auto;
        flex-direction: row;
    }

    .hero .wrapper {
        flex-direction: row;
        width: 100%;
        gap: 0px;
    }

    .hero-content {
        max-width: 52%;
        width: 100%;
        align-items: flex-start;
        gap: 32px;
    }

    .hero-identity {
        flex-direction: row;
        gap: 20px;
    }

    .hero-logo {
        width: 48px;
    }

    .hero-3d {
        position: relative;
        right: 10%;
        top: auto;
        transform: none;
        width: 90%;
        max-width: 500px;
        margin: 0 auto;
        order: 2; /* Картинка под текстом */
    }

    .hero-3d img {
        width: 200%;
    }

    /* Убираем фиксированную ширину кнопок, пусть тянутся */
    .hero-actions {
        width: 100%;
        max-width: 400px;
    }

    /* Перенос кнопок в hero, если экран мал */
    .hero-actions .secondary-btns {
        flex-wrap: wrap;
    }

    .hero-actions .secondary-btns .btn {
        flex: 1 1 40%;
    }

    .portfolio {
        padding: 80px 20px 60px;
    }

    .portfolio .section-subtitle {
        margin-bottom: 42px;
    }

    .portfolio-grid {
        gap: 20px;
    }

    .about {
        padding: 30px 20px 24px;
    }

    .about .wrapper {
        gap: 32px;
        margin-bottom: 32px;
    }

    .about .hero-name,
    .about .section-title {
        margin-bottom: 16px;
    }

    .about .section-subtitle {
        margin-bottom: 28px;
    }

    footer {
        padding: 32px 20px;
    }

    footer .wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .card-year {
        padding: 4px 20px;
    }
}

/* Мобильные (600px и меньше) */
@media (max-width: 600px) {
    header {
        width: 100%;
    }

    .nav-link svg {
        width: 18px;
        height: 18px;
    }

    /* Делаем кнопки в шапке только иконками */
    .nav-actions .btn {
        padding: 12px;
    }
    .nav-actions .btn span, /* если бы был спан */
    .nav-actions .btn {
        font-size: 0; /* Скрываем текст */
        gap: 0;
    }
    .nav-actions .btn svg {
        margin: 0;
        width: 24px;
        height: 24px;
    }

    footer {
        padding: 24px 16px;
    }

    footer .wrapper {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    footer p,
    footer .nav-link,
    footer .nav-link p {
        font-size: 0.95rem;
    }

    .hero .wrapper {
        flex-direction: column;
        width: 100%;
        gap: 0px;
    }

    .hero-content {
        max-width: 100%;
        width: 100%;
        align-items: flex-start;
        gap: 32px;
    }

    .hero-3d {
        position: relative;
        right: 3%;
        top: auto;
        transform: none;
        width: 100%;
        height: 360px;
        order: -1; /* Картинка под текстом */

        display: flex;
        justify-content: center;
        align-items: center;
    }

    .hero-3d img {
        width: 140%;
    }

    .hero-actions {
        gap: 16px;
    }

    /* Портфолио: карточки в 1 колонку */
    .portfolio-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .card:hover {
        transform: scale(1.01);
        box-shadow: 0 0 20px 4px rgba(67, 114, 87, 0.3);
    }

    .card-year {
        padding: 2px 12px;
    }

    .viewer-container {
        padding: 16px;
    }
    .viewer-navigation {
        width: calc(100% - 48px);
        height: calc(100% - 48px);
    }
    .viewer-navigation button svg {
        width: 18px;
        height: 18px;
    }

    .viewer-contact {
        justify-content: center;
    }

    .viewer-content {
        padding: 0px;
    }

    .arrows {
        position: absolute;
        bottom: 0px;
    }

    .edu-hero {
        gap: 4px;
        margin-bottom: 24px;
    }
}

/* Очень маленькие экраны (400px) */
@media (max-width: 400px) {
    header {
        padding: 8px 16px;
    }

    .btn {
        padding: 10px 16px;
    }
}

/* Плавный скролл — только если пользователь не настроил "уменьшить движение" */
@media (prefers-reduced-motion: no-preference) {
    html,
    .viewer-container {
        scroll-behavior: smooth;
    }
}

/* Уважаем настройки доступности: отключаем анимации */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
