/**
 * Machine Page Styles
 * Redesigned to match the original Nettuno Sistemi layout.
 *
 * @package Nettuno
 */

/* ==========================================================================
   1. HERO
   ========================================================================== */
.m-hero {
    padding-top: calc(var(--header-height) + var(--space-2xl));
    background: var(--color-secondary);
    text-align: center;
}

.m-hero__title {
    font-size: clamp(36px, 5vw, 50px);
    font-weight: var(--fw-semibold);
    font-family: var(--font-heading);
    color: var(--color-text);
    line-height: var(--lh-heading);
    margin-bottom: var(--space-2xl);
    text-align: center;
}

.m-hero__image-wrap {
    padding: 0 var(--container-padding);
    display: flex;
    justify-content: center;
}

.m-hero__image-container {
    width: 70vw;
    max-width: 1140px;
    background: linear-gradient(180deg, rgba(21, 143, 246, 0.1) 0%, rgba(2, 224, 129, 0.05) 100%);
    border-radius: 20px;
    overflow: hidden;
}

.m-hero__img {
    width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================================
   2. INTRO + CTA BUTTONS (all centered)
   ========================================================================== */
.m-intro {
    padding: var(--space-3xl) 0;
    background: var(--color-secondary);
    text-align: center;
}

.m-intro__heading {
    font-size: var(--fs-h2);
    font-weight: var(--fw-semibold);
    font-family: var(--font-heading);
    color: var(--color-text);
    margin-bottom: var(--space-xl);
    line-height: var(--lh-heading);
}

.m-intro__heading span {
    color: var(--color-primary);
}

.m-intro__text {
    max-width: 750px;
    margin: 0 auto var(--space-2xl);
    color: var(--color-text-muted);
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: var(--fw-medium);
    line-height: 1.5;
}

.m-intro__buttons {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
    justify-content: center;
}

/* Pill Buttons */
.m-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 32px;
    border-radius: 100px;
    font-size: var(--fs-small);
    font-weight: var(--fw-regular);
    font-family: var(--font-primary);
    line-height: 1;
    transition: var(--transition-normal);
    cursor: pointer;
    border: none;
    text-decoration: none;
}

.m-btn svg {
    width: 16px;
    height: 16px;
}

.m-btn--light {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-white);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.m-btn--light:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--color-white);
}

.m-btn--gray {
    background: #56565E;
    color: var(--color-white);
}

.m-btn--gray:hover {
    background: #6a6a72;
    color: var(--color-white);
}

.m-btn--green {
    background: #239E59;
    color: var(--color-white);
}

.m-btn--green:hover {
    background: #2bb968;
    color: var(--color-white);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(35, 158, 89, 0.3);
}

/* ==========================================================================
   SECTION TITLES
   ========================================================================== */
.m-section-title {
    font-size: var(--fs-h2);
    font-weight: var(--fw-semibold);
    font-family: var(--font-heading);
    color: var(--color-text);
    margin-bottom: var(--space-xl);
    line-height: var(--lh-heading);
}

.m-section-title--center {
    text-align: center;
}

/* ==========================================================================
   3. MATERIALS
   ========================================================================== */
.m-materials {
    padding: var(--space-2xl) 0 var(--space-3xl);
    background: var(--color-secondary);
}

.m-materials__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    max-width: 1000px;
    margin: 0 auto;
}

.m-materials__card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 8px 12px 28px;
    background: #fff;
    border-radius: 20px 65px 65px 20px;
    transition: var(--transition-normal);
    min-height: 80px;
}

.m-materials__card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.m-materials__name {
    font-family: var(--font-heading);
    font-size: var(--fs-body);
    font-weight: var(--fw-semibold);
    color: #171718;
    flex: 1;
}

.m-materials__img {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.m-materials__texture {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

.m-materials__detail {
    font-size: var(--fs-small);
    color: var(--color-text-muted);
}

/* ==========================================================================
   4. SHOWCASE VIDEO (autoplay loop)
   ========================================================================== */
.m-showcase {
    padding: var(--space-3xl) 0;
    background: var(--color-secondary);
}

.m-showcase__wrap {
    max-width: 900px;
    margin: 0 auto;
    border-radius: 20px;
    overflow: hidden;
    background: #000;
}

.m-showcase__video {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

/* ==========================================================================
   5. VIDEO (YouTube embeds — constrained width)
   ========================================================================== */
.m-video-section {
    padding: var(--space-3xl) 0;
    background: var(--color-secondary);
}

.m-video-container {
    width: 70%;
    margin: 0 auto;
}

.m-video-embed {
    position: relative;
    aspect-ratio: 16 / 9;
    padding-bottom: 56.25%;
    border-radius: 20px;
    overflow: hidden;
    background: var(--color-background-card);
}

@supports (aspect-ratio: 16 / 9) {
    .m-video-embed {
        padding-bottom: 0;
    }
}

.m-video-embed iframe,
.m-video-embed video {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ==========================================================================
   6. FEATURES
   ========================================================================== */
.m-features {
    padding: var(--space-3xl) 0;
    background: var(--color-secondary);
}

.m-features__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-xl);
    max-width: 1000px;
    margin: 0 auto;
}

.m-features__card {
    text-align: center;
    padding: var(--space-xl) var(--space-md);
}

.m-features__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-lg);
    color: var(--color-primary);
}

.m-features__icon svg {
    width: 36px;
    height: 36px;
}

.m-features__title {
    font-family: var(--font-heading);
    font-size: var(--fs-body);
    font-weight: var(--fw-semibold);
    color: var(--color-white);
    margin-bottom: var(--space-sm);
}

.m-features__desc {
    font-family: var(--font-heading);
    font-size: var(--fs-small);
    font-weight: var(--fw-medium);
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0;
}

/* ==========================================================================
   7. TECHNICAL SECTIONS
   ========================================================================== */
.m-tech {
    padding: var(--space-4xl) 0;
}

.m-tech:first-child {
    padding-top: var(--space-3xl);
}

.m-tech--gradient {
    background: linear-gradient(135deg, rgba(21, 143, 246, 0.06) 0%, rgba(2, 224, 129, 0.04) 100%);
}

/* Two-column grid */
.m-tech__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3xl);
    align-items: start;
}

.m-tech--image-left .m-tech__grid {
    direction: rtl;
}

.m-tech--image-left .m-tech__grid > * {
    direction: ltr;
}

.m-tech__text {
    text-align: left;
}

.m-tech__text .description-content {
    font-family: var(--font-heading);
    font-size: var(--fs-body);
    font-weight: var(--fw-medium);
    color: var(--color-text-muted);
    line-height: 1.5;
}

.m-tech__text .description-content strong {
    color: var(--color-text);
    font-weight: var(--fw-semibold);
}

.m-tech__image img {
    max-width: 100%;
    height: auto;
    max-height: 550px;
    border-radius: 20px;
    display: block;
    margin: 0 auto;
}

/* Full-width layout */
.m-tech__full {
    max-width: 900px;
}

.m-tech__full-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: var(--space-2xl);
}

.m-tech__full-card .description-content {
    font-family: var(--font-heading);
    font-size: var(--fs-body);
    font-weight: var(--fw-medium);
    color: var(--color-text-muted);
    line-height: 1.5;
    text-align: left;
}

.m-tech__full-card .description-content strong {
    color: var(--color-text);
    font-weight: var(--fw-semibold);
}

.m-tech__image--full {
    margin-top: var(--space-xl);
}

.m-tech__image--full img {
    border-radius: 20px;
    max-width: 70%;
}

/* Video in tech sections */
.m-tech__video video {
    width: 100%;
    height: auto;
    border-radius: 20px;
    display: block;
}

.m-tech__video--full {
    margin-top: var(--space-xl);
    max-width: 900px;
}

.m-tech__video--full video {
    border-radius: 20px;
}

/* ==========================================================================
   8. GALLERY (overrides for gallery within machine pages)
   ========================================================================== */
.single-maszyna .maszyna-gallery {
    padding: var(--space-3xl) 0;
    margin-bottom: 0;
}

.single-maszyna .maszyna-gallery h2 {
    display: block;
    font-size: var(--fs-h2);
    font-weight: var(--fw-bold);
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: var(--space-xl);
    text-align: center;
}

.single-maszyna .gallery-container {
    max-width: 800px;
    margin: 0 auto;
}

.single-maszyna .gallery-main {
    border-radius: 20px;
    overflow: hidden;
}

.single-maszyna .gallery-main-image {
    border-radius: 20px;
}

.single-maszyna .gallery-thumbs {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: var(--space-md);
}

.single-maszyna .gallery-thumb {
    border-radius: 12px;
    width: 80px;
    height: 80px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: var(--transition-fast);
    cursor: pointer;
    padding: 0;
    background: none;
}

.single-maszyna .gallery-thumb.active {
    border-color: var(--color-primary);
}

.single-maszyna .gallery-thumb:hover {
    border-color: rgba(110, 193, 228, 0.5);
}

.single-maszyna .gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.single-maszyna .gallery-fullscreen {
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 8px;
    padding: 8px;
    color: #fff;
    cursor: pointer;
    position: absolute;
    top: 12px;
    right: 12px;
    transition: var(--transition-fast);
}

.single-maszyna .gallery-fullscreen:hover {
    background: rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   9. APPLICATIONS
   ========================================================================== */
.m-applications {
    padding: var(--space-3xl) 0;
}

.m-applications__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
    max-width: 1000px;
    margin: 0 auto;
}

/* Tag-style when no images */
.m-applications__grid--tags {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.m-applications__card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    overflow: hidden;
    transition: var(--transition-normal);
}

.m-applications__card:hover {
    border-color: var(--color-primary);
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(110, 193, 228, 0.08);
}

.m-applications__img {
    aspect-ratio: 16 / 10;
    overflow: hidden;
}

.m-applications__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.m-applications__card:hover .m-applications__img img {
    transform: scale(1.05);
}

.m-applications__name {
    padding: var(--space-lg);
    font-size: var(--fs-body);
    font-weight: var(--fw-semibold);
    color: var(--color-white);
    text-align: center;
    margin: 0;
}

/* ==========================================================================
   10. EXTRA VIDEOS
   ========================================================================== */
.m-videos-extra {
    padding: var(--space-3xl) 0;
}

.m-videos__grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

/* ==========================================================================
   11. SPECS
   ========================================================================== */
.m-specs {
    padding: var(--space-3xl) 0;
}

.m-specs__wrapper {
    max-width: 900px;
    margin: 0 auto;
    border-radius: 20px;
    overflow: hidden;
    background: #fff;
}

.m-specs__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

/* Header row */
.m-specs__table thead th {
    background: #303033;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    padding: 14px 20px;
    text-align: left;
    border: none;
}

.m-specs__table thead th:first-child {
    border-radius: 20px 0 0 0;
}

.m-specs__table thead th:last-child {
    border-radius: 0 20px 0 0;
}

/* Body rows - alternating */
.m-specs__table tbody tr:nth-child(odd) {
    background: #fff;
}

.m-specs__table tbody tr:nth-child(even) {
    background: #eee;
}

.m-specs__table tbody tr:hover {
    background: #e0e0e0;
}

/* Cells */
.m-specs__name {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 500;
    color: #333;
    padding: 12px 20px;
    border-bottom: 1px solid #ddd;
    white-space: nowrap;
}

.m-specs__value {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 400;
    color: #555;
    padding: 12px 20px;
    border-bottom: 1px solid #ddd;
}

.m-specs__table tbody tr:last-child .m-specs__name,
.m-specs__table tbody tr:last-child .m-specs__value {
    border-bottom: none;
}

/* ==========================================================================
   12. DOCUMENTS
   ========================================================================== */
.m-documents {
    padding: var(--space-3xl) 0;
}

.m-documents__list {
    display: grid;
    gap: var(--space-md);
    max-width: 700px;
    margin: 0 auto;
}

.m-documents__item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-xl);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    color: var(--color-text);
    transition: var(--transition-fast);
    font-size: var(--fs-body);
}

.m-documents__item:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.m-documents__item svg {
    flex-shrink: 0;
}

/* ==========================================================================
   13. RELATED PRODUCTS
   ========================================================================== */
.m-related {
    padding: var(--space-3xl) 0;
    background: var(--color-background-light);
}

.m-related__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-lg);
}

.m-related__card {
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #f0f0f0 0%, #d0d0d0 40%, #888 100%);
    border-radius: 20px;
    overflow: hidden;
    transition: var(--transition-normal);
    text-decoration: none;
    color: #1a1a1a;
}

.m-related__card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
    color: #1a1a1a;
}

.m-related__img {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    min-height: 200px;
}

.m-related__img img {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    transition: transform var(--transition-slow);
}

.m-related__card:hover .m-related__img img {
    transform: scale(1.05);
}

.m-related__info {
    padding: var(--space-md) var(--space-lg) var(--space-lg);
}

.m-related__name {
    font-family: var(--font-heading);
    font-size: var(--fs-body);
    font-weight: var(--fw-semibold);
    margin-bottom: var(--space-sm);
    color: #1a1a1a;
}

.m-related__link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: var(--fs-small);
    font-weight: var(--fw-semibold);
    color: var(--color-primary);
}

.m-related__link svg {
    width: 16px;
    height: 16px;
    transition: transform var(--transition-fast);
}

.m-related__card:hover .m-related__link svg {
    transform: translateX(4px);
}

/* ==========================================================================
   14. CTA WAVE DIVIDER
   ========================================================================== */
.m-cta-wave {
    position: relative;
    height: 80px;
    background: var(--color-background);
    overflow: hidden;
}

.m-cta-wave__divider {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    line-height: 0;
}

.m-cta-wave__divider svg {
    width: 100%;
    height: 80px;
}

/* ==========================================================================
   15. VIDEO POPUP MODAL
   ========================================================================== */
.m-popup {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.m-popup[hidden] {
    display: none;
}

.m-popup__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.m-popup__dialog {
    position: relative;
    width: 100%;
    max-width: 900px;
    background: var(--color-secondary);
    border-radius: 20px;
    overflow: hidden;
    animation: m-popup-in 0.4s ease;
}

@keyframes m-popup-in {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.m-popup__close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-white);
    cursor: pointer;
    transition: var(--transition-fast);
}

.m-popup__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.m-popup__close svg {
    width: 20px;
    height: 20px;
}

.m-popup__header {
    padding: 40px 40px 20px;
}

.m-popup__label {
    display: inline-block;
    font-size: 14px;
    font-weight: var(--fw-semibold);
    color: var(--color-primary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.m-popup__title {
    font-family: var(--font-heading);
    font-size: clamp(24px, 3vw, 36px);
    font-weight: var(--fw-semibold);
    color: var(--color-text);
    margin: 0;
    line-height: var(--lh-heading);
}

.m-popup__body {
    padding: 0 40px 40px;
}

.m-popup__body .m-video-embed {
    border-radius: 20px;
}

/* ==========================================================================
   LIGHTBOX improvements
   ========================================================================== */
.single-maszyna .lightbox {
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(4px);
}

.single-maszyna .lightbox-content img {
    border-radius: 12px;
    max-width: 85%;
    max-height: 85vh;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* Tablet landscape */
@media (max-width: 1024px) {
    .m-hero__image-container {
        width: 85vw;
    }

    .m-features__grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .m-tech__grid {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }

    .m-tech--image-left .m-tech__grid {
        direction: ltr;
    }

    .m-applications__grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .m-related__grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .m-video-container {
        max-width: 85%;
    }

    .m-showcase__wrap {
        max-width: 100%;
    }

    .single-maszyna .gallery-container {
        max-width: 100%;
    }
}

/* Tablet portrait */
@media (max-width: 800px) {
    .m-hero__title {
        font-size: clamp(28px, 6vw, 42px);
    }

    .m-hero__image-container {
        width: 93vw;
    }

    .m-intro__buttons {
        flex-direction: column;
        align-items: center;
    }

    .m-intro__buttons .m-btn {
        justify-content: center;
        width: 100%;
        max-width: 300px;
    }

    .m-materials__grid {
        grid-template-columns: 1fr;
        max-width: 500px;
    }

    .m-features__grid {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-lg);
    }

    .m-applications__grid {
        grid-template-columns: 1fr 1fr;
    }

    .m-related__grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .m-tech {
        padding: var(--space-3xl) 0;
    }

    .m-specs__wrapper {
        border-radius: 14px;
        margin: 0 var(--space-md);
    }

    .m-specs__name {
        white-space: normal;
        font-size: 13px;
        padding: 10px 14px;
    }

    .m-specs__value {
        font-size: 13px;
        padding: 10px 14px;
    }

    .m-specs__table thead th {
        font-size: 13px;
        padding: 12px 14px;
    }

    .m-video-container {
        max-width: 95%;
    }

    .m-popup {
        padding: 20px;
    }

    .m-popup__header {
        padding: 30px 24px 16px;
    }

    .m-popup__body {
        padding: 0 24px 24px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .m-hero {
        padding-top: calc(var(--header-height) + var(--space-xl));
    }

    .m-hero__image-container {
        width: 100%;
        border-radius: 0;
    }

    .m-features__grid {
        grid-template-columns: 1fr;
    }

    .m-materials__card {
        padding: 10px 6px 10px 20px;
        min-height: 64px;
    }

    .m-materials__img {
        width: 56px;
        height: 56px;
    }

    .m-applications__grid {
        grid-template-columns: 1fr;
    }

    .m-related__grid {
        grid-template-columns: 1fr;
    }

    .m-specs__wrapper {
        border-radius: 12px;
        margin: 0;
        overflow-x: auto;
    }

    .m-specs__name {
        font-size: 12px;
        padding: 8px 12px;
        min-width: 120px;
    }

    .m-specs__value {
        font-size: 12px;
        padding: 8px 12px;
    }

    .m-specs__table thead th {
        font-size: 12px;
        padding: 10px 12px;
    }

    .m-tech__full-card {
        padding: var(--space-lg);
    }

    .m-tech__image--full img {
        max-width: 100%;
    }

    .m-video-container {
        max-width: 100%;
    }

    .m-showcase__wrap {
        border-radius: 12px;
    }

    .single-maszyna .gallery-thumb {
        width: 60px;
        height: 60px;
    }

    .m-popup {
        padding: 10px;
    }

    .m-popup__dialog {
        border-radius: 16px;
    }

    .m-popup__header {
        padding: 24px 20px 12px;
    }

    .m-popup__body {
        padding: 0 20px 20px;
    }

    .m-popup__body .m-video-embed {
        border-radius: 12px;
    }
}
