/* ==========================================================================
   DRUTPOL 3D Catalog - Frontend Styles
   Kolorystyka: czerwony (#c41e2a), ciemny (#1a1a1a), biały
   ========================================================================== */

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */
.tm-catalog-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 15px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        Ubuntu, Cantarell, "Helvetica Neue", Arial, sans-serif;
    color: #333;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.tm-catalog-wrapper *,
.tm-catalog-wrapper *::before,
.tm-catalog-wrapper *::after {
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Category filter bar
   -------------------------------------------------------------------------- */
.tm-catalog-filters {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 12px 0 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.tm-catalog-filters::-webkit-scrollbar {
    height: 4px;
}

.tm-catalog-filters::-webkit-scrollbar-thumb {
    background: #c41e2a;
    border-radius: 2px;
}

.tm-filter-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 8px 20px;
    border: 2px solid #d0d0d0;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    user-select: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tm-filter-btn:hover {
    background: #fef2f2;
    border-color: #c41e2a;
    color: #c41e2a;
}

.tm-filter-btn.active {
    background: #c41e2a;
    border-color: #c41e2a;
    color: #fff;
    box-shadow: 0 2px 8px rgba(196, 30, 42, 0.3);
}

/* --------------------------------------------------------------------------
   Flipbook container
   -------------------------------------------------------------------------- */
.tm-catalog-book {
    position: relative;
    margin: 0 auto;
    overflow: hidden;
    background: #fff;
    min-height: 400px;
}

/* Prevent grey bleed-through during page flip animations */
.tm-catalog-book .stf__wrapper {
    background: #fff;
}

.tm-catalog-book .stf__block {
    background: #fff;
}

/* Disable mouse/touch flipping — only nav buttons control pages */
.tm-catalog-book .stf__parent,
.tm-catalog-book .stf__wrapper,
.tm-catalog-book .stf__block,
.tm-catalog-book .stf__item {
    cursor: default !important;
    touch-action: pan-y !important;
}

/* --------------------------------------------------------------------------
   Page: base
   -------------------------------------------------------------------------- */
.tm-page {
    background: #fff;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    overflow: hidden;
    border: 1px solid #e8e8e8;
}

.tm-page-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tm-page-inner.tm-columns-1 {
    flex-direction: column;
}

.tm-page-inner.tm-columns-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 16px;
}

.tm-page-inner.tm-columns-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.tm-page-inner.tm-columns-4 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 14px;
}

.tm-page-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-style: italic;
    font-size: 16px;
    text-align: center;
    padding: 40px 20px;
}

/* Page number */
.tm-page-number {
    position: absolute;
    bottom: 8px;
    right: 14px;
    font-size: 11px;
    color: #bbb;
    font-weight: 600;
}

/* --------------------------------------------------------------------------
   Page: cover pages — DRUTPOL red/dark theme
   -------------------------------------------------------------------------- */
.tm-page-cover {
    background: linear-gradient(145deg, #1a1a1a 0%, #2d2d2d 40%, #1a1a1a 100%);
    padding: 40px 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
    border: none;
}

.tm-cover-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.tm-cover-logo {
    margin-bottom: 10px;
}

.tm-cover-icon {
    font-size: 48px;
    color: #c41e2a;
    text-shadow: 0 2px 8px rgba(196, 30, 42, 0.4);
}

.tm-cover-logo-img {
    max-width: 280px;
    height: auto;
    margin-bottom: 16px;
}

.tm-cover-title {
    font-size: 42px;
    font-weight: 900;
    letter-spacing: 4px;
    text-transform: uppercase;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.tm-title-drut {
    color: #fff;
}

.tm-title-pol {
    color: #c41e2a;
}

.tm-cover-since {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 3px;
    margin: 0;
    font-weight: 400;
}

.tm-cover-divider {
    width: 80px;
    height: 3px;
    background: #c41e2a;
    margin: 10px 0;
}

.tm-catalog-wrapper .tm-cover-subtitle,
.tm-catalog-wrapper h2.tm-cover-subtitle {
    font-size: 22px !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    letter-spacing: 3px !important;
    text-transform: uppercase !important;
    margin: 0 !important;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6) !important;
    background: none !important;
    -webkit-text-fill-color: #ffffff !important;
}

.tm-cover-year {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.4);
    margin: 4px 0 0;
}

.tm-cover-tagline {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    font-style: normal;
    margin: 0;
}

/* --------------------------------------------------------------------------
   Product card — DRUTPOL styling
   -------------------------------------------------------------------------- */
.tm-product-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.tm-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.tm-product-card.has-3d {
    border-color: #c41e2a;
    border-width: 2px;
}

.tm-product-card.has-3d:hover {
    box-shadow: 0 6px 20px rgba(196, 30, 42, 0.15);
}

/* --------------------------------------------------------------------------
   Product visual area
   -------------------------------------------------------------------------- */
.tm-product-visual {
    position: relative;
    width: 100%;
    height: 220px;
    background: #fafafa;
    overflow: hidden;
}

.tm-product-visual model-viewer {
    width: 100%;
    height: 220px;
    background: #fafafa;
    --poster-color: transparent;
}

/* Model-viewer in catalog: NO interaction, only auto-rotate.
   Prevent touch events from being captured by model-viewer so
   flipbook swipe gestures work correctly on mobile. */
.tm-mv-preview {
    pointer-events: none !important;
    touch-action: none !important;
    -webkit-user-select: none;
    user-select: none;
}

/* Prevent page content from interfering with flipbook swipe on mobile */
.tm-page {
    -webkit-user-select: none;
    user-select: none;
    touch-action: pan-y;
}

.tm-page img {
    -webkit-user-drag: none;
    user-drag: none;
    -webkit-touch-callout: none;
}

/* 3D Badge — red DRUTPOL */
.tm-badge-3d {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #c41e2a;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
    letter-spacing: 1px;
    z-index: 2;
    box-shadow: 0 2px 6px rgba(196, 30, 42, 0.4);
    text-transform: uppercase;
}

/* Image fallback */
.tm-product-image {
    width: 100%;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
}

.tm-product-image img {
    width: 100%;
    height: 220px;
    object-fit: contain;
    background: #fff;
}

.tm-no-image {
    width: 100%;
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9f9f9;
    color: #ccc;
    font-size: 13px;
}

/* --------------------------------------------------------------------------
   Product info
   -------------------------------------------------------------------------- */
.tm-product-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.tm-product-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    color: #1a1a1a;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.tm-product-sku {
    font-size: 12px;
    color: #888;
    margin: 0;
}

.tm-detail-btn {
    display: block;
    width: 100%;
    margin-top: auto;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background: #c41e2a;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.25s ease;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tm-detail-btn:hover {
    background: #a11722;
}

.tm-detail-btn:active {
    background: #8a1320;
}

/* --------------------------------------------------------------------------
   Navigation — DRUTPOL red
   -------------------------------------------------------------------------- */
.tm-catalog-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 20px 0 10px;
}

.tm-nav-prev,
.tm-nav-next {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    border: 2px solid #c41e2a;
    border-radius: 4px;
    background: #c41e2a;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    user-select: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tm-nav-prev:hover,
.tm-nav-next:hover {
    background: #a11722;
    border-color: #a11722;
}

.tm-nav-prev:active,
.tm-nav-next:active {
    background: #8a1320;
    border-color: #8a1320;
}

.tm-page-indicator {
    font-size: 14px;
    font-weight: 700;
    color: #1a1a1a;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Product detail modal
   -------------------------------------------------------------------------- */
.tm-product-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.tm-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.tm-modal-content {
    position: relative;
    background: #fff;
    max-width: 1100px;
    width: 100%;
    border-radius: 8px;
    padding: 32px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 92vh;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    z-index: 1;
    animation: tmModalFadeIn 0.3s ease;
    border-top: 4px solid #c41e2a;
    box-sizing: border-box;
}

@keyframes tmModalFadeIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.tm-product-modal .tm-modal-close,
.tm-product-modal .tm-modal-close:focus,
.tm-product-modal .tm-modal-close:active {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 2px solid #fff !important;
    border-radius: 50% !important;
    background: #1a1a1a !important;
    color: #fff !important;
    font-size: 22px !important;
    font-weight: 400 !important;
    line-height: 1 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.2s ease, transform 0.2s ease !important;
    z-index: 10 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
    text-shadow: none !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    box-sizing: border-box !important;
}

.tm-product-modal .tm-modal-close:hover {
    background: #c41e2a !important;
    transform: rotate(90deg) !important;
}

/* Detail layout inside modal */
.tm-detail-wrapper {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tm-detail-visual {
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
}

.tm-detail-visual model-viewer {
    display: block;
}

/* 3D wrapper with fullscreen button */
.tm-detail-3d-wrap {
    position: relative;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background: #f5f5f5;
}

.tm-detail-mv {
    width: 100% !important;
    height: 60vh !important;
    min-height: 450px !important;
    background: #f5f5f5;
    display: block;
}

.tm-detail-3d-wrap:fullscreen,
.tm-detail-3d-wrap:-webkit-full-screen {
    background: #1a1a1a;
}

.tm-detail-3d-wrap:fullscreen .tm-detail-mv,
.tm-detail-3d-wrap:-webkit-full-screen .tm-detail-mv {
    height: 100vh !important;
    width: 100vw !important;
}

.tm-mv-fullscreen {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 6px;
    background: rgba(26, 26, 26, 0.85);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: background 0.2s ease;
}

.tm-mv-fullscreen:hover {
    background: #c41e2a;
}

/* Image with zoom hint */
.tm-detail-image {
    position: relative;
    cursor: zoom-in;
}

.tm-zoomable-img {
    cursor: zoom-in;
    transition: opacity 0.2s ease;
}

.tm-zoomable-img:hover {
    opacity: 0.9;
}

.tm-zoom-hint {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(26, 26, 26, 0.8);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    pointer-events: none;
}

/* Lightbox */
.tm-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    cursor: zoom-out;
    animation: tmModalFadeIn 0.2s ease;
}

.tm-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    cursor: default;
}

.tm-lightbox-close {
    position: absolute !important;
    top: 20px !important;
    right: 20px !important;
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    border: 2px solid #fff !important;
    border-radius: 50% !important;
    background: rgba(0, 0, 0, 0.6) !important;
    color: #fff !important;
    font-size: 28px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    padding: 0 !important;
    z-index: 1 !important;
    transition: background 0.2s ease, transform 0.2s ease !important;
}

.tm-lightbox-close:hover {
    background: #c41e2a !important;
    transform: rotate(90deg) !important;
}

.tm-detail-image {
    width: 100%;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
}

.tm-detail-image img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
}

.tm-detail-no-image {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9f9f9;
    color: #ccc;
    font-size: 14px;
    border-radius: 8px;
}

.tm-detail-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tm-detail-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    color: #1a1a1a;
}

.tm-detail-sku,
.tm-detail-dimensions,
.tm-detail-material {
    font-size: 15px;
    color: #555;
    margin: 0;
}

.tm-detail-sku strong,
.tm-detail-dimensions strong,
.tm-detail-material strong {
    color: #c41e2a;
}

.tm-detail-description {
    margin-top: 12px;
    border-top: 2px solid #c41e2a;
    padding-top: 16px;
}

.tm-detail-description h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px;
    color: #1a1a1a;
}

.tm-detail-description-text {
    font-size: 14px;
    color: #666;
    line-height: 1.7;
}

.tm-detail-description-text p {
    margin: 0 0 10px;
}

/* --------------------------------------------------------------------------
   Responsive: mobile
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .tm-catalog-wrapper {
        padding: 10px 8px;
    }

    .tm-catalog-filters {
        padding: 8px 0 14px;
    }

    .tm-filter-btn {
        padding: 6px 14px;
        font-size: 12px;
    }

    .tm-page {
        padding: 14px;
        gap: 12px;
    }

    .tm-page-inner.tm-columns-2,
    .tm-page-inner.tm-columns-3,
    .tm-page-inner.tm-columns-4 {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .tm-product-visual,
    .tm-product-visual model-viewer,
    .tm-product-image,
    .tm-product-image img,
    .tm-no-image {
        height: 180px;
    }

    .tm-cover-title {
        font-size: 28px;
        letter-spacing: 3px;
    }

    .tm-cover-subtitle {
        font-size: 14px;
    }

    .tm-cover-icon {
        font-size: 36px;
    }

    .tm-catalog-nav {
        gap: 10px;
        padding: 14px 0 8px;
    }

    .tm-nav-prev,
    .tm-nav-next {
        padding: 12px 18px;
        font-size: 13px;
        min-height: 44px;
        min-width: 44px;
    }

    .tm-page-indicator {
        font-size: 12px;
    }

    .tm-product-modal {
        padding: 10px;
        /* Fix iOS fullscreen modal scroll */
        -webkit-overflow-scrolling: touch;
    }

    .tm-modal-content {
        max-width: 100%;
        padding: 20px 16px;
        border-radius: 8px;
        max-height: 85vh;
        -webkit-overflow-scrolling: touch;
    }

    /* Larger tap target for close button on mobile */
    .tm-product-modal .tm-modal-close {
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        font-size: 26px !important;
        top: 8px !important;
        right: 8px !important;
    }

    .tm-detail-title {
        font-size: 20px;
    }

    .tm-detail-visual model-viewer,
    .tm-detail-mv {
        height: 50vh !important;
        min-height: 320px !important;
    }

    .tm-lightbox {
        padding: 20px;
    }

    .tm-lightbox-close {
        top: 10px !important;
        right: 10px !important;
        width: 44px !important;
        height: 44px !important;
        font-size: 24px !important;
    }

    .tm-detail-image {
        min-height: 200px;
    }

    .tm-detail-image img {
        max-height: 280px;
    }
}

/* --------------------------------------------------------------------------
   Responsive: small mobile
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    .tm-product-visual,
    .tm-product-visual model-viewer,
    .tm-product-image,
    .tm-product-image img,
    .tm-no-image {
        height: 150px;
    }

    .tm-product-title {
        font-size: 13px;
    }

    .tm-detail-btn {
        font-size: 12px;
        padding: 6px 12px;
    }

    .tm-cover-title {
        font-size: 22px;
    }

    .tm-cover-icon {
        font-size: 28px;
    }

    .tm-detail-visual model-viewer {
        height: 220px !important;
    }
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */
@media print {
    .tm-catalog-filters,
    .tm-catalog-nav,
    .tm-product-modal,
    .tm-detail-btn,
    .tm-badge-3d {
        display: none !important;
    }

    .tm-product-card {
        break-inside: avoid;
    }
}
