/* static/css/project.css */

/* ========== СТРАНИЦА ПРОЕКТА ========== */

/* Главный контейнер изображения */
.main-media {
    width: 100%;
    transform-origin: center;
    transition: transform 0.4s ease;
}

.main-image-container {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    align-items: center;
    justify-content: center;
    position: relative;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow);
    aspect-ratio: 16/9;
    transition: border-color 0.4s ease, box-shadow 0.4s ease;
    cursor: pointer;
}

.main-image-container > picture,
.main-image-picture {
    display: block;
    width: 100%;
    height: 100%;
}

.main-photo,
.project-video {
    display: block;
    width: 100%;
    height: 100%;
}

.project-video {
    object-fit: contain;
    background: #000;
}

.main-media [hidden] {
    display: none !important;
}

.main-media.is-video:hover {
    transform: none;
}

.project-video-error {
    position: absolute;
    inset: auto 0 0;
    margin: 0;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    z-index: 7;
}

.project-video-error a { text-decoration: underline; }

.gallery-video-mark {
    position: absolute;
    inset: 6px 6px auto auto;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: rgba(12, 19, 24, 0.55);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: white;
    pointer-events: none;
}

.gallery-video-mark i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 16px;
    line-height: 1;
}
.gallery-video-mark i::before { display: block; vertical-align: 0; line-height: 1; }

.main-image-container,
.lightbox img {
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.main-image-container:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 3px;
}

.gallery-expand {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 6;
    opacity: 0;
    pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
    .main-image-container:hover .gallery-expand,
    .main-image-container:focus-visible .gallery-expand,
    .gallery-expand:focus-visible {
        opacity: 1;
        pointer-events: auto;
    }
}

@media (hover: none), (pointer: coarse) {
    .main-image-container .gallery-expand {
        display: none;
    }
}

.main-image-container:hover {
    border-color: var(--color-primary);
    box-shadow: 0 10px 30px rgba(13, 110, 253, 0.4);
}

@media (hover: hover) and (pointer: fine) {
    .main-media:hover {
        transform: scale(1.02);
    }
}

@media (prefers-reduced-motion: reduce) {
    .main-media {
        transition: none;
    }

    .main-media:hover {
        transform: none;
    }
}

.project-page .main-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    transition: transform 0.5s ease !important;
}

.main-image-container:hover .project-page .main-image,
.main-image-container:hover .main-image {
    transform: scale(1.05);
}

.main-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: opacity 0.3s ease, transform 0.5s ease;
    background: transparent;
}

.main-image.no-image {
    object-fit: contain;
    opacity: 0.7;
    padding: 2rem;
}

/* Индикатор загрузки */
.image-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 5;
}

.main-image-container.loading .image-loader {
    opacity: 1;
}

.main-image-container.loading .main-image {
    opacity: 0.3;
}

.main-image-container.loading:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow);
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Галерея превью */
.gallery-scroll {
    display: none;
}

.project-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.gallery-item {
    position: relative;
    display: block;
    aspect-ratio: 4/3;
    overflow: hidden;
    width: 100%;
    padding: 0;
    border-radius: 8px;
    color: inherit;
    font: inherit;
    cursor: pointer;
    transition: var(--transition-slow);
    border: 2px solid transparent;
    background: rgba(0, 0, 0, 0.3);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: var(--shadow-sm);
}

.gallery-item > picture,
.gallery-image-picture {
    display: block;
    width: 100%;
    height: 100%;
}

.gallery-item[data-media-type="video"] { background: #111820; }
.gallery-video-fallback {
    display: flex;
    position: absolute;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    background: #111820;
    color: #c3c8cd;
    font-size: .85rem;
    line-height: 1.2;
}
.gallery-video-fallback > i { font-size: 2rem; }
.gallery-item [hidden] { display: none !important; }

.gallery-item.active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.3);
}

.gallery-item:hover {
    transform: translateY(-3px);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-hover);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover img {
    transform: scale(1.08);
}

/* Атрибуция активной фотографии */
.photo-attribution {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.3rem;
    width: 100%;
    margin-top: 0.45rem;
    padding: 0.45rem 0.7rem;
    border-radius: 6px;
    background: rgba(8, 12, 18, 0.72);
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.88rem;
    line-height: 1.4;
}

.photo-attribution[hidden],
.photo-attribution [hidden] {
    display: none;
}

.photo-attribution a {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
    padding: 0.12rem 0;
    border-bottom: 1px dotted rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.92);
    transition: border-color 0.2s ease, color 0.2s ease;
}

.photo-attribution a:hover,
.photo-attribution a:focus-visible {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.photo-attribution a:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.photo-attribution i {
    flex: 0 0 auto;
    font-size: 0.82rem;
}

/* Характеристики проекта */
.project-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 2rem 0;
    padding: 2rem;
    /*
     * Match the former combined opacity of the panel (.6) and cards (.4).
     * A single layer prevents bright horizontal bands between card rows.
     */
    background: rgba(0, 0, 0, 0.76) !important;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-sm);
}

.spec-item {
    flex: 1 1 calc((100% - 3rem) / 3);
    min-width: 0;
    text-align: center;
    padding: 1.5rem;
    background: transparent;
    border-radius: 12px;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.spec-item:hover {
    transform: translateY(-5px);
    background: rgba(0, 0, 0, 0.333);
    border-color: var(--color-primary);
    box-shadow: var(--shadow-hover);
}

.spec-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem auto;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    font-size: 2rem;
    color: var(--color-primary);
    transition: all 0.3s ease;
}

.spec-item:hover .spec-icon {
    background: var(--color-primary);
    color: white;
    transform: scale(1.1);
}

.spec-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: white;
    margin: 0.5rem 0;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

.spec-label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Описание проекта */
.project-description {
    --project-copy-gap: 1.1rem;
    --project-compact-gap: 0.55rem;
    margin: 2rem 0;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.3);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-sm);
}

.project-description h3 {
    color: white;
    font-size: 2rem;
    margin-bottom: 1.5rem;
    position: relative;
    padding-bottom: 0.5rem;
}

.project-description h3::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 80px;
    height: 3px;
    background: var(--color-primary);
}

.project-description > h3 {
    margin-bottom: 0.5em;
    text-box-trim: trim-start;
    text-box-edge: cap alphabetic;
}

.project-description h4 {
    color: white;
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.project-description p {
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.8;
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.project-description .markdown-content p,
.project-description .markdown-content ul,
.project-description .markdown-content ol {
    margin-bottom: var(--project-copy-gap);
}

.project-description .markdown-content :is(p, h1, h2, h3, h4, h5, h6):has(+ :is(ul, ol)) {
    margin-bottom: var(--project-compact-gap);
}

.project-description .markdown-content > :last-child {
    margin-bottom: 0;
}

/* Keep real list markers; paragraphs inside loose Markdown lists add no gaps. */
.project-description .markdown-content :is(ul, ol) {
    margin-inline-start: 0;
    padding-inline-start: 1.2em;
    list-style-position: outside;
}
.project-description .markdown-content ul { list-style-type: disc; }
.project-description .markdown-content ol { list-style-type: decimal; padding-inline-start: 1.5em; }
.project-description .markdown-content li {
    margin: 0;
    padding-inline-start: .1em;
    font-size: 1.1rem;
    line-height: 1.65;
}
.project-description .markdown-content li + li { margin-top: .25em; }
.project-description .markdown-content li > p { margin: 0; font-size: inherit; line-height: inherit; }
.project-description .markdown-content li > p + p { margin-top: .25em; }
.project-description .markdown-content li > :is(ul, ol) { margin-block: .25em 0; }

/* Бейдж типа проекта */
.project-type-badge {
    display: inline-block;
    padding: 0.5rem 1.5rem;
    background: var(--color-primary);
    color: white;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 2px 10px rgba(13, 110, 253, 0.3);
    margin: 1rem 0;
}

.project-type-badge--work {
    position: relative;
    display: inline-grid;
    max-width: 100%;
    overflow: hidden;
    padding: 0;
    vertical-align: middle;
}

.project-type-badge--work .project-card-type-label {
    padding: 0.5rem 1.5rem;
}

@media (prefers-reduced-motion: reduce) {
    .project-type-badge--work {
        display: inline-flex;
        padding: 0.5rem 1.5rem;
    }

    .project-type-badge--work .project-card-type-label {
        padding: 0;
    }
}

/* Значение стоимости */
.project-cost {
    margin-top: var(--project-copy-gap);
    padding-top: var(--project-copy-gap);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.project-cost h4 {
    margin-bottom: var(--project-compact-gap);
}

.project-cost .cost-value {
    margin-top: var(--project-compact-gap) !important;
}

.project-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: var(--project-copy-gap);
}

.cost-value {
    font-size: 1.6rem !important;
    color: var(--color-primary) !important;
    font-weight: 800 !important;
    text-align: left !important;
    line-height: 1.2 !important;
    margin: 1rem 0 !important;
    letter-spacing: 1px !important;
    display: block !important;
    width: 100% !important;
}

/* Лайтбокс */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(5px);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--color-primary);
}

.lightbox-close,
.gallery-expand {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(12, 18, 28, 0.8);
    color: var(--color-primary);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    -webkit-tap-highlight-color: transparent;
    transition: background-color 120ms ease, border-color 120ms ease;
}

.lightbox-close {
    position: absolute;
    top: max(16px, env(safe-area-inset-top));
    right: max(16px, env(safe-area-inset-right));
    z-index: 10000;
}

.lightbox-close:hover,
.gallery-expand:hover {
    background: rgba(13, 110, 253, 0.15);
    border-color: var(--color-primary);
}

.lightbox-close:focus-visible,
.gallery-expand:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 3px;
}

/* Заголовок проекта */
.major h1 {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

/* Кнопки */
.button.primary,
.button.alt {
    min-width: 200px;
    padding: 0.8rem 2rem;
    font-size: 1rem;
}

/* Адаптация для мобильных */
@media (max-width: 736px) {
    .project-specs {
        padding: 1rem;
        gap: 1rem;
    }
    
    .spec-item {
        flex-basis: 100%;
        padding: 1rem;
    }
    
    .spec-value {
        font-size: 1.5rem;
    }
    
    .spec-icon {
        width: 50px;
        height: 50px;
        font-size: 1.5rem;
    }
    
    .project-gallery-controls {
        margin: 1rem 0;
    }

    .project-gallery {
        display: flex;
        flex-wrap: nowrap;
        min-width: 0;
        max-width: 100%;
        margin: 0;
        padding: 4px;
        gap: 0.5rem;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-padding-inline: 4px;
        scroll-snap-type: x proximity;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .project-gallery::-webkit-scrollbar {
        display: none;
    }

    .project-gallery .gallery-item {
        flex: 0 0 clamp(92px, 26vw, 160px);
        width: clamp(92px, 26vw, 160px);
        scroll-snap-align: start;
    }

    .photo-attribution {
        font-size: 0.8rem;
    }
    
    .cost-value {
        font-size: 1.5rem !important;
    }
    
    .project-description h3 {
        font-size: 1.5rem;
    }

    .project-description {
        --project-copy-gap: 1rem;
        --project-compact-gap: 0.5rem;
    }
    
    .project-description p {
        font-size: 1rem;
    }

    .major h1 {
        font-size: 1.8rem;
    }
    
    .button.primary,
    .button.alt {
        min-width: 100%;
    }
}

@media (max-width: 736px) and (hover: hover) and (pointer: fine) {
    .project-gallery-controls.has-overflow {
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .project-gallery-controls.has-overflow .project-gallery {
        flex: 1 1 0;
    }

    .project-gallery-controls.has-overflow .gallery-scroll {
        display: flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 44px;
        width: 44px;
        height: 44px;
        padding: 0;
        border: 1px solid rgba(255, 255, 255, 0.22);
        border-radius: 6px;
        background: rgba(12, 18, 28, 0.85);
        color: white;
        font-size: 1rem;
        cursor: pointer;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    .gallery-scroll:not(:disabled):hover {
        background: rgba(12, 18, 28, 0.95);
        border-color: var(--color-primary);
    }

    .gallery-scroll:focus-visible {
        outline: 2px solid var(--color-primary);
        outline-offset: 2px;
    }

    .gallery-scroll:disabled {
        opacity: 0.35;
        cursor: default;
    }
}
