/**
 * Cards & Homepage Components
 *
 * Styles for feature cards, product cards, template cards, and CTAs.
 * Uses CSS variables from colors-variables.css for theming.
 */

/* ========================================
   Page Section
   ======================================== */

.section {
    padding: 80px 0;
}

.section--gray {
    background-color: var(--background-color, #f8f9fa);
}

.section--dark {
    background-color: var(--nav-background-color, #1a1a2e);
    color: #ffffff;
}

.section__header {
    text-align: center;
    margin-bottom: 50px;
}

.section__title {
    font-family: var(--font-family, "Poppins", sans-serif);
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0 0 15px;
    color: var(--text-title-color, #333333);
}

.section--dark .section__title {
    color: #ffffff;
}

.section__subtitle {
    font-size: 1.1rem;
    color: var(--text-color, #666666);
    margin: 0;
}

.section--dark .section__subtitle {
    color: rgba(255, 255, 255, 0.8);
}

/* ========================================
   Feature Cards
   ======================================== */

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
}

.feature-card {
    background: var(--background-white, #ffffff);
    padding: 30px;
    border: 1px solid var(--border-color-light, #e0e0e0);
    border-radius: 12px;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.feature-card__icon {
    font-size: 3rem;
    color: var(--primary-color, #3498db);
    margin-bottom: 20px;
    line-height: 1;
}

.feature-card__title {
    font-family: var(--font-family, "Poppins", sans-serif);
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 15px;
    color: var(--text-title-color, #333333);
}

.feature-card__text {
    font-size: 1rem;
    color: var(--text-color, #666666);
    line-height: 1.6;
    margin: 0;
}

/* ========================================
   Product Cards
   ======================================== */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    justify-content: center;
    width: 100%;
    max-width: 100%;
}

/* Featured products - use flexbox to center last row items */
.product-grid--2:not(.categories-horizontal-scroll),
.product-grid--3:not(.categories-horizontal-scroll),
.product-grid--4:not(.categories-horizontal-scroll),
.product-grid--5:not(.categories-horizontal-scroll) {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: stretch;
    gap: 30px;
}

/* Set flex-basis for consistent column widths + ensure equal heights */
.product-grid--2:not(.categories-horizontal-scroll) > *,
.product-grid--3:not(.categories-horizontal-scroll) > *,
.product-grid--4:not(.categories-horizontal-scroll) > *,
.product-grid--5:not(.categories-horizontal-scroll) > * {
    display: flex;
    flex-direction: column;
}

.product-grid--2:not(.categories-horizontal-scroll) > * {
    flex: 0 1 calc(50% - 15px);
    max-width: 450px;
}

.product-grid--3:not(.categories-horizontal-scroll) > * {
    flex: 0 1 calc(33.333% - 20px);
    max-width: 400px;
}

.product-grid--4:not(.categories-horizontal-scroll) > * {
    flex: 0 1 calc(25% - 22.5px);
    max-width: 350px;
}

.product-grid--5:not(.categories-horizontal-scroll) > * {
    flex: 0 1 calc(20% - 24px);
    max-width: 300px;
}

/* Categories - flexbox, shrink to fit, never wrap until 768px */
.categories-horizontal-scroll {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 30px;
}

.categories-horizontal-scroll > * {
    flex: 1 1 0;
    min-width: 0;
    max-width: 280px;
}

/* Aspect ratio modifiers */
.product-grid--aspect-4-3 .product-card__image {
    aspect-ratio: 4 / 3 !important;
}

.product-grid--aspect-1-1 .product-card__image {
    aspect-ratio: 1 / 1 !important;
}

/* Circle aspect - make entire chain transparent and non-clipping */
.product-grid--aspect-circle {
    overflow: visible;
}

.product-grid--aspect-circle .product-card-link {
    overflow: visible;
    padding: 5px 0 5px 0; /* Room for shadow and lift */
}

.product-grid--aspect-circle .product-card {
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0;
    overflow: visible !important;
}

.product-grid--aspect-circle .product-card:hover {
    background: transparent !important;
    box-shadow: none !important;
    transform: none !important;
}

.product-grid--aspect-circle .product-card__image {
    aspect-ratio: 1 / 1 !important;
    border-radius: 50%;
    overflow: hidden;
    background-color: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.product-grid--aspect-circle .product-card:hover .product-card__image {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}

/* Circle with hidden titles/descriptions - add gap to prevent overlap */
.product-grid--aspect-circle.hide-titles.hide-descriptions {
    gap: 40px;
}

/* Circle titles - tighter, balanced padding */
.product-grid--aspect-circle .product-card__body {
    padding: 12px 15px 8px 15px;
}

.product-grid--aspect-circle .product-card__title {
    margin-bottom: 5px;
}

/* Override min-height for circles/squares in image-only mode */
.product-grid--aspect-circle.hide-titles.hide-descriptions .product-card__image,
.product-grid--aspect-1-1.hide-titles.hide-descriptions .product-card__image {
    min-height: auto;
}

/* Hide titles when setting is off */
.hide-titles .product-card__title {
    display: none;
}

/* Hide descriptions when setting is off */
.hide-descriptions .product-card__text {
    display: none;
}

/* Hide prices when setting is off */
.hide-prices .product-card__price {
    display: none;
}

/* When both titles and descriptions are hidden, hide the entire body and let image fill card */
.hide-titles.hide-descriptions .product-card__body {
    display: none;
}

.hide-titles.hide-descriptions .product-card__image {
    aspect-ratio: auto;
    min-height: 200px;
}

.hide-titles.hide-descriptions .product-card {
    overflow: hidden;
}

.hide-titles.hide-descriptions .product-card__image img {
    border-radius: 12px;
}

.product-card-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}

.product-card-link:hover {
    text-decoration: none;
}

.product-card {
    background: var(--background-white, #ffffff);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.product-card__image {
    position: relative;
    aspect-ratio: 4 / 3;
    background-color: var(--background-white, #ffffff);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-card__placeholder {
    font-size: 4rem;
    color: var(--text-muted, #999999);
}

/* Homepage featured products - same aspect ratio with min-height for larger cards */
.product-card--featured .product-card__image {
    aspect-ratio: 4 / 3;
    min-height: 280px;
}

.product-card--featured .product-card__placeholder {
    font-size: 5rem;
}

.product-card--featured .product-card__body {
    padding: 30px;
}

.product-card--featured .product-card__title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 15px;
}

.product-card--featured .product-card__text {
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 25px;
}

.product-card--featured .product-card__footer {
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.product-card--featured .product-card__price {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.product-card__badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 6px 12px;
    background-color: var(--primary-color, #213a86);
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
}

.product-card__body {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-card__title {
    font-family: var(--font-family, "Poppins", sans-serif);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 10px;
    color: var(--text-title-color, #333333);
}

/* Homepage categories section */
.homepage-categories {
    padding: 40px 0 !important;
    background: #fff;
}

.homepage-categories__subtitle {
    font-size: 1.6rem;
    font-weight: 500;
    color: #333;
    margin-bottom: 30px;
}

/* Homepage category cards - larger, bolder titles */
.homepage-categories .product-card__title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #222;
}

/* ========================================
   Categories Scroll Wrapper & Arrows
   ======================================== */

.categories-scroll-wrapper {
    position: relative;
    width: 100%;
}

/* Scroll arrows - hidden by default, shown when scroll is active */
.scroll-arrow {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.2s ease;
    align-items: center;
    justify-content: center;
}

.scroll-arrow:hover {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(-50%) scale(1.05);
}

.scroll-arrow:active {
    transform: translateY(-50%) scale(0.95);
}

.scroll-arrow i {
    font-size: 1.25rem;
    color: var(--text-title-color, #333);
}

.scroll-arrow--left {
    left: -22px;
}

.scroll-arrow--right {
    right: -22px;
}

/* Hide arrow when at boundary */
.scroll-arrow.at-start,
.scroll-arrow.at-end {
    opacity: 0.3;
    pointer-events: none;
}

/* Show arrows when scroll wrapper has overflow */
.categories-scroll-wrapper.has-overflow .scroll-arrow {
    display: flex;
}

/* Categories grid centering - centered by default */
.categories-horizontal-scroll.mobile-scroll-enabled {
    justify-content: center;
}

/* When overflow, align to start */
.categories-scroll-wrapper.has-overflow .categories-horizontal-scroll.mobile-scroll-enabled {
    justify-content: flex-start;
}

/* Hide arrows on touch devices / small mobile */
@media (max-width: 576px) {
    .scroll-arrow {
        width: 36px;
        height: 36px;
    }

    .scroll-arrow--left {
        left: -10px;
    }

    .scroll-arrow--right {
        right: -10px;
    }

    .scroll-arrow i {
        font-size: 1rem;
    }
}

/* On very small screens, hide arrows (touch only) */
@media (max-width: 480px) and (hover: none) {
    .scroll-arrow {
        display: none !important;
    }
}

.product-card__text {
    font-size: 0.95rem;
    color: var(--text-color, #666666);
    line-height: 1.5;
    margin: 0 0 15px;
}

.product-card__price {
    font-family: var(--font-family, "Poppins", sans-serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color, #213a86);
    margin: 0 0 15px;
}

.product-card__price small {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-color, #666666);
}

.product-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: auto;
}

/* View Details link - subtle secondary styling */
.product-card__link {
    color: var(--secondary-color, #6c757d);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s ease;
}

.product-card__link:hover {
    color: var(--secondary-hover-color, #545b62);
    text-decoration: none;
}

.product-card__link i {
    font-size: 0.85rem;
    transition: transform 0.2s ease;
}

.product-card__link:hover i {
    transform: translateX(3px);
}

/* ========================================
   CTA Section
   ======================================== */

.cta {
    padding: 60px 20px;
    text-align: center;
    background: linear-gradient(135deg, var(--primary-color, #667eea) 0%, var(--primary-comliment-color, #764ba2) 100%);
    color: #ffffff;
}

.cta__title {
    font-family: var(--font-family, "Poppins", sans-serif);
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0 0 20px;
}

.cta__text {
    font-size: 1.1rem;
    margin: 0 0 30px;
    opacity: 0.9;
}

.cta__actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* ========================================
   Template Card (for templates page)
   ======================================== */

.template-card {
    background: var(--background-white, #ffffff);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.template-card__image {
    position: relative;
    aspect-ratio: 4/3;
    background-color: var(--background-white, #ffffff);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.template-card__image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 15px;
}

.template-card__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.template-card:hover .template-card__overlay {
    opacity: 1;
}

.template-card__body {
    padding: 16px;
    text-align: center;
}

.template-card__title {
    font-family: var(--font-family, "Poppins", sans-serif);
    font-size: 1rem;
    font-weight: 500;
    margin: 0;
    color: var(--text-title-color, #333333);
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 991px) {
    .section {
        padding: 60px 0;
    }

    .section__title {
        font-size: 2rem;
    }

    .cta__title {
        font-size: 2rem;
    }
}

@media (max-width: 576px) {
    .section {
        padding: 50px 0;
    }

    .section__title {
        font-size: 1.75rem;
    }

    .feature-card {
        padding: 25px;
    }

    .feature-card__icon {
        font-size: 2.5rem;
    }

    .feature-card__title {
        font-size: 1.25rem;
    }

    .cta {
        padding: 50px 15px;
    }

    .cta__title {
        font-size: 1.75rem;
    }

    .cta__actions {
        flex-direction: column;
    }

    .cta__actions .btn {
        width: 100%;
    }
}

/* Responsive - featured products use flexbox */
@media (max-width: 1200px) {
    /* Featured products - 5 col becomes 4 col */
    .product-grid--5:not(.categories-horizontal-scroll) > * {
        flex: 0 1 calc(25% - 22.5px);
    }
}

@media (max-width: 991px) {
    /* Featured products - switch to 2 columns */
    .product-grid--3:not(.categories-horizontal-scroll) > *,
    .product-grid--4:not(.categories-horizontal-scroll) > *,
    .product-grid--5:not(.categories-horizontal-scroll) > * {
        flex: 0 1 calc(50% - 15px);
        max-width: none;
    }

    /* Reduce min-height on featured cards at tablet to prevent overflow */
    .product-card--featured .product-card__image {
        min-height: auto;
    }
}

@media (max-width: 768px) {
    /* Featured products - 2 col stays 2 col */
    .product-grid--2:not(.categories-horizontal-scroll) > *,
    .product-grid--3:not(.categories-horizontal-scroll) > * {
        flex: 0 1 calc(50% - 15px);
        max-width: none;
    }

    /* Categories horizontal scroll on mobile - switch to flexbox */
    .categories-horizontal-scroll.mobile-scroll-enabled {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        justify-content: flex-start;
        align-items: flex-start;
        gap: 25px;
        padding-bottom: 5px;
    }

    .categories-horizontal-scroll.mobile-scroll-enabled > * {
        flex: 0 0 calc(36% - 12px);
        min-width: calc(36% - 12px);
        max-width: none;
        scroll-snap-align: start;
    }

    /* Reduce circle padding on mobile */
    .categories-horizontal-scroll.mobile-scroll-enabled.product-grid--aspect-circle .product-card-link {
        padding: 2px 0 8px 0;
    }

    /* Hide scrollbar but keep functionality */
    .categories-horizontal-scroll.mobile-scroll-enabled::-webkit-scrollbar {
        height: 0;
    }
}

@media (max-width: 576px) {
    /* Featured products - single column */
    .product-grid--2:not(.categories-horizontal-scroll) > *,
    .product-grid--3:not(.categories-horizontal-scroll) > *,
    .product-grid--4:not(.categories-horizontal-scroll) > *,
    .product-grid--5:not(.categories-horizontal-scroll) > * {
        flex: 0 1 100%;
        max-width: none;
    }

    /* Keep horizontal scroll for categories on phones */
    .categories-horizontal-scroll.mobile-scroll-enabled > * {
        flex: 0 0 calc(40% - 10px);
        min-width: calc(40% - 10px);
    }
}

/* ========================================
   Video Section
   ======================================== */

.video-section {
    overflow: hidden;
}

.video-section:has(.video-wrapper--full) {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.video-wrapper {
    max-width: 960px;
    margin: 0 auto;
}

.video-wrapper--full {
    max-width: 100%;
}

.video-responsive {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.video-wrapper--full .video-responsive {
    border-radius: 0;
}

.video-responsive iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* ========================================
   Info Blocks Section
   ======================================== */

.info-blocks-section {
    overflow: hidden;
}

.info-blocks-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: center;
}

.info-blocks-grid > * {
    flex: 1 1 300px;
    max-width: 100%;
}

/* Grid column variations */
.info-blocks-grid--2 > * {
    flex: 0 1 calc(50% - 15px);
    max-width: calc(50% - 15px);
}

.info-blocks-grid--3 > * {
    flex: 0 1 calc(33.333% - 20px);
    max-width: calc(33.333% - 20px);
}

.info-blocks-grid--4 > * {
    flex: 0 1 calc(25% - 22.5px);
    max-width: calc(25% - 22.5px);
}

.info-block-card {
    background: var(--background-white, #ffffff);
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.info-block-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.info-block-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color, #3498db) 0%, var(--primary-comliment-color, #2980b9) 100%);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.info-block-icon i {
    font-size: 1.75rem;
    color: #ffffff;
}

.info-block-title {
    font-family: var(--font-family, "Poppins", sans-serif);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-title-color, #333333);
    margin: 0 0 12px;
}

.info-block-description {
    font-size: 0.95rem;
    color: var(--text-color, #666666);
    line-height: 1.6;
    margin: 0;
}

/* Info Blocks Responsive */
@media (max-width: 991px) {
    .info-blocks-grid--4 > * {
        flex: 0 1 calc(50% - 15px);
        max-width: calc(50% - 15px);
    }
}

@media (max-width: 768px) {
    .info-blocks-grid--3 > * {
        flex: 0 1 calc(50% - 15px);
        max-width: calc(50% - 15px);
    }

    .info-block-card {
        padding: 25px;
    }

    .info-block-icon {
        width: 56px;
        height: 56px;
    }

    .info-block-icon i {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .info-blocks-grid--2 > *,
    .info-blocks-grid--3 > *,
    .info-blocks-grid--4 > * {
        flex: 0 1 100%;
        max-width: 100%;
    }

    .video-responsive {
        border-radius: 8px;
    }
}
