/* ===== ПЕРЕМЕННЫЕ ===== */

:root {
    --ink: #111111;
    --muted: #767676;            /* серый меню и ссылок */
    --gutter: 22px;              /* боковые поля на телефоне */
    --gutter-wide: 40px;         /* боковые поля на десктопе */
    --content-max: 1100px;
    --ease: 0.2s ease;
}


/* ===== ОСНОВА ===== */

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    min-height: 100%;
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    color: var(--ink);
    font-family: "Times New Roman", Times, serif;
    font-size: 16px;
    font-weight: 400;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 5px;
}

button {
    -webkit-tap-highlight-color: transparent;
}

img,
video {
    display: block;
    max-width: 100%;
    height: auto;
}

/* ===== ШАПКА ===== */

.site-header {
    position: relative;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    width: 100%;
    margin-bottom: 12px;
    background: #ffffff;
}

.logo {
    position: relative;
    z-index: 30;
    display: block;
    flex: 0 1 55%;
    width: 55%;
    min-width: 0;
    margin: 0 auto 0 0;
    line-height: 0;
}

.logo img {
    width: 100%;
    max-width: none;
}

.menu-button {
    position: relative;
    z-index: 30;
    display: block;
    flex-shrink: 0;
    margin: 12px 14px 0 auto;
    padding: 4px;
    background: none;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: 36px;
    line-height: 1;
    cursor: pointer;
}


/* ===== МЕНЮ: ТЕЛЕФОН (полноэкранное) ===== */

.site-menu {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 32px;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: 70px var(--gutter) 200px;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    background: #ffffff;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px);
    transition:
        opacity 0.3s ease,
        transform 0.3s ease,
        visibility 0.3s ease;
}

.site-menu.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.site-menu a {
    color: var(--muted);
    text-align: center;
    text-decoration: none;
    font-size: 25px;
    font-weight: 400;
    letter-spacing: 0.2px;
    touch-action: manipulation;
    transition: color var(--ease);
}

.site-menu a.active {
    color: var(--ink);
}

.menu-stamp {
    position: absolute;
    top: calc(50% + 60px);
    left: 50%;
    display: block;
    width: 150px;
    height: auto;
    margin: 0;
    transform: translateX(-50%);
}

/* Страница под открытым меню не прокручивается */
html.menu-open {
    overflow: hidden;
}

body.menu-open {
    position: fixed;
    left: 0;
    right: 0;
    width: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}


/* ===== ГЛАВНАЯ: ПРОЕКТЫ ===== */

.work-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    row-gap: 20px;
    margin-top: -50px;
    padding: 34px var(--gutter) 55px;
}

.project {
    min-width: 0;
    align-self: start;
}

.project-link {
    display: block;
    width: 100%;
    color: inherit;
    text-decoration: none;
}

.project-image {
    width: 100%;
    height: auto;
    transition: opacity 180ms ease;
}

.project-title {
    display: none;
}


/* ===== ПОДВАЛ ===== */

footer {
    margin-top: auto;
    padding: 30px var(--gutter) 24px;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}


/* ===== ВНУТРЕННИЕ СТРАНИЦЫ: about, contact, проекты ===== */

.content-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 24px var(--gutter) 60px;
}

.page-copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 24px;
    min-width: 0;
    max-width: 560px;
}

.page-copy p {
    margin: 0;
    font-size: 18px;
    line-height: 1.7;
}

.project-description {
    width: 100%;
    max-width: 560px;
    margin: 0 0 24px;
    color: var(--ink);
    font-size: 18px;
    font-weight: 400;
    line-height: 1.7;
}

.project-description p {
    margin: 0 0 16px;
}

.project-description p:last-child {
    margin-bottom: 0;
}

.page-visual {
    width: 100%;
    min-width: 0;
}

.page-visual img {
    width: 100%;
    height: auto;
}

.page-visual img + img {
    margin-top: 24px;
}

/* Ссылки внутри текста */
.text-link {
    color: var(--muted);
    text-decoration: none;
    transition: color var(--ease);
}


/* ===== CONTACT ===== */

.contact-layout .contact-icons {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 24px;
    padding: 10px 0;
}

.contact-layout .contact-icons a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-decoration: none;
}

.contact-layout .contact-icons img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    transition: opacity var(--ease);
}


/* ===== CLAIM ===== */

.claim-page {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 24px 0 40px;
}

.claim-page .page-copy {
    margin: 0 var(--gutter);
}

.claim-video,
.claim-photo,
.claim-logo-video {
    display: block;
    width: 100%;
    height: auto;
}

.claim-photo,
.claim-logo-video {
    padding: 0 var(--gutter);
}

.claim-video {
    aspect-ratio: 9 / 16;
    object-fit: cover;
}


/* ===== СТРАНИЦА ОШИБКИ (404) ===== */

.error-page {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 70vh;
    padding: 30px var(--gutter);
    text-align: center;
}

.error-page h1 {
    margin: 0 0 24px;
    font-size: clamp(64px, 15vw, 180px);
    font-weight: 400;
    line-height: 0.9;
}

.error-image {
    width: 100%;
    max-width: 600px;
    height: auto;
    margin: 0 0 24px;
}

.error-page a {
    color: inherit;
    text-decoration: none;
    font-size: 14px;
}


/* ===== ПОЯВЛЕНИЕ КАРТИНОК И ВИДЕО (см. script.js) ===== */

img.media-pending,
video.media-pending {
    opacity: 0;
}

/* backwards, а не both: после анимации не «замораживаем» opacity,
   иначе hover-эффекты на картинках не работают */
img.media-loaded,
video.media-loaded {
    animation: mediaFadeIn 0.8s ease backwards;
}

@keyframes mediaFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* ===== НАВЕДЕНИЕ: только там, где есть мышь ===== */

@media (hover: hover) {
    .site-menu a:hover {
        color: var(--ink);
    }

    .project-link:hover .project-image {
        opacity: 0.84;
    }

    .text-link:hover {
        color: var(--ink);
    }

    .contact-layout .contact-icons a:hover img {
        opacity: 0.65;
    }
}


/* ===== ТЕЛЕФОН: подгонка карточек на главной ===== */

@media (max-width: 699.98px) {
    /* Третья карточка шире и выходит за левое поле */
    .work-grid .project:nth-child(3) {
        width: calc(100% + 57px);
        margin-left: -35px;
    }

    /* Четвёртая ближе к третьей */
    .work-grid .project:nth-child(4) {
        margin-top: -15px;
    }
}


/* ===== ДЕСКТОП ===== */

@media (min-width: 700px) {

    /* Шапка и меню */

    .site-header {
        z-index: auto;
    }

    .logo {
        flex: 0 1 max(180px, 19.84vw);   /* 300px на эталонных 1512px */
        width: max(180px, 19.84vw);
    }

    .menu-button,
    .menu-stamp {
        display: none;
    }

    .site-menu {
        position: relative;
        inset: auto;
        z-index: 10;
        flex-direction: row;
        justify-content: flex-end;
        gap: 28px;
        width: auto;
        height: auto;
        margin-left: auto;
        padding: 30px var(--gutter-wide) 0 0;
        overflow: visible;
        touch-action: auto;
        background: transparent;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
        transition: none;
    }

    .site-menu a {
        font-size: 20px;
    }

    /* Главная: асимметричная сетка */

    /* Все размеры в vw: композиция выглядит одинаково на любой ширине.
       Эталон 1512px (MacBook 14"): значение в vw = пиксели / 1512 * 100.
       Чтобы подвинуть карточку, меняй vw: 1vw примерно 15px на эталонном экране. */

    .work-grid {
        grid-template-columns: repeat(12, minmax(0, 1fr));
        column-gap: 1.59vw;
        row-gap: 1.98vw;
        align-items: start;
        margin-top: 0;
        padding: 0 2.65vw 4.63vw;
    }

    .work-grid .project:nth-child(1) {
        grid-column: 1 / span 5;
        grid-row: 1;
        margin-top: -1.32vw;
        margin-left: -1.32vw;
        transform: translateY(-1.65vw);
    }

    .work-grid .project:nth-child(2) {
        grid-column: 7 / span 5;
        grid-row: 1;
        margin-top: -3.31vw;
        margin-right: -4.63vw;
        transform: translateY(-1.65vw);
    }

    .work-grid .project:nth-child(3) {
        grid-column: 4 / span 6;
        grid-row: 2;
        margin-top: -7.28vw;
        margin-right: -7.94vw;
    }

    .work-grid .project:nth-child(4) {
        grid-column: 1 / span 5;
        grid-row: 3;
        margin-top: -1.98vw;
        margin-left: -1.32vw;
    }

    .work-grid .project:nth-child(5) {
        grid-column: 7 / span 6;
        grid-row: 3;
        margin-top: 1.98vw;
    }

    /* Внутренние страницы: текст слева, изображения справа */

    .content-layout,
    .claim-page {
        padding-left: var(--gutter-wide);
        padding-right: var(--gutter-wide);
    }

    .content-layout {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        column-gap: 60px;
        row-gap: 28px;
        padding-top: 44px;
        padding-bottom: 80px;
    }

    .page-copy p,
    .project-description {
        font-size: 19px;
    }

    /* Текст остаётся на экране, пока листаются картинки */
    .content-layout .page-copy,
    .claim-page > .page-copy {
        position: sticky;
        top: 70px;
        align-self: start;
    }

    /* Contact */

    .contact-layout {
        min-height: 55vh;
    }

    .contact-layout .contact-icons {
        grid-column: 2;
        grid-row: 1;
        align-self: stretch;
        gap: 38px;
    }

    .contact-layout .contact-icons img {
        width: 88px;
        height: 88px;
    }

    /* Claim: текст слева, четыре медиа-блока справа */

    .claim-page {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: start;
        column-gap: 60px;
        row-gap: 40px;
        padding-top: 44px;
        padding-bottom: 80px;
    }

    .claim-page > .page-copy {
        grid-column: 1;
        grid-row: 1 / span 4;   /* 4 = число медиа-блоков справа; текст липнет на всю высоту */
        margin: 0;
    }

    .claim-page > :not(.page-copy) {
        grid-column: 2;
    }

    .claim-photo,
    .claim-logo-video {
        padding: 0;
    }
}


/* ===== УМЕНЬШЕНИЕ АНИМАЦИИ ===== */

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }

    img.media-pending,
    video.media-pending {
        opacity: 1;
    }
}
