/* =====================
   Global Styles & Reset
   ===================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-purple: #4a1a6b;
    --dark-purple: #2d1045;
    --light-purple: #6b2d9e;
    --accent-purple: #8b4abf;
    --white: #ffffff;
    --light-gray: #f5f5f5;
    --medium-gray: #e0e0e0;
    --text-gray: #333333;
    --shadow: rgba(74, 26, 107, 0.2);
    --shadow-dark: rgba(74, 26, 107, 0.4);
}

html,
body {
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, var(--dark-purple) 0%, var(--primary-purple) 100%);
    min-height: 100vh;
    color: var(--white);
    line-height: 1.6;
}

/* =====================
   Container
   ===================== */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* =====================
   Header
   ===================== */

.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px 0;
}

.site-title {
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--white);
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px var(--shadow-dark);
    letter-spacing: 1px;
}

.site-subtitle {
    font-size: 1.7rem;
    color: var(--light-gray);
    font-weight: 300;
}

/* =====================
   Search Bar
   ===================== */

.search-container {
    position: relative;
    max-width: 600px;
    margin: 0 auto 40px;
}

.search-input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    font-size: 1rem;
    border: 2px solid var(--white);
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-gray);
    outline: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--shadow);
}

.search-input:focus {
    background: var(--white);
    box-shadow: 0 6px 25px var(--shadow-dark);
    transform: translateY(-2px);
}

.search-input::placeholder {
    color: #999;
}

.search-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-purple);
    pointer-events: none;
}

/* =====================
   Loading & Messages
   ===================== */

.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-message,
.no-results {
    text-align: center;
    padding: 40px 20px;
    font-size: 1.1rem;
    color: var(--light-gray);
}

/* =====================
   Offers Grid
   ===================== */

.offers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    padding: 20px 0;
}

.offer-card {
    background: var(--white);
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 20px var(--shadow);
    transition: all 0.3s ease;
    cursor: pointer;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.offer-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px var(--shadow-dark);
}

.offer-image-container {
    position: relative;
    width: 100%;
    padding-top: 75%; /* 4:3 Aspect Ratio */
    overflow: hidden;
    background: #ffffff;
}

.offer-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.offer-card:hover .offer-image {
    transform: scale(1.05);
}

.offer-name {
    padding: 12px 15px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-purple);
    text-align: center;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    word-wrap: break-word;
    border-top: 3px solid var(--light-purple);
}

/* =====================
   Modal (Full Screen Image)
   ===================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 40px;
    color: var(--white);
    font-size: 50px;
    font-weight: 300;
    cursor: pointer;
    z-index: 1001;
    transition: color 0.3s ease;
    line-height: 1;
}

.close-modal:hover {
    color: var(--accent-purple);
}

.modal-content {
    text-align: center;
}

.modal-image-frame {
    position: relative;
    width: min(1100px, 92vw);
    height: min(72vh, 680px);
    display: flex;
    align-items: center;
    justify-content: center;
}

#modalImage {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(20, 20, 20, 0.55);
    color: var(--white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
    z-index: 1002;
}

.modal-nav:hover {
    background: rgba(20, 20, 20, 0.75);
    border-color: rgba(255, 255, 255, 0.35);
    transform: translateY(-50%) scale(1.04);
}

.modal-nav:active {
    transform: translateY(-50%) scale(0.98);
}

.modal-nav:focus-visible {
    outline: 2px solid rgba(139, 74, 191, 0.9);
    outline-offset: 3px;
}

.modal-nav:disabled {
    opacity: 0.35;
    cursor: default;
}

.modal-nav:disabled:hover {
    background: rgba(20, 20, 20, 0.55);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-50%);
}

.modal-nav-prev {
    left: 14px;
}

.modal-nav-next {
    right: 14px;
}

.modal-caption {
    color: var(--white);
    font-size: 1.1rem;
    font-weight: 500;
    margin-top: 16px;
    padding: 0;
    background: transparent;
    border-radius: 0;
    display: block;
    text-align: center;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
    letter-spacing: 0.2px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
}

/* =====================
   Responsive Design
   ===================== */

/* Tablets */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .site-title {
        font-size: 2.6rem;
    }

    .site-subtitle {
        font-size: 1.6rem;
    }

    .offers-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
    }

    .offer-name {
        font-size: 1rem;
        padding: 10px 12px;
        min-height: 48px;
    }

    .close-modal {
        font-size: 40px;
        right: 20px;
        top: 10px;
    }

    .modal-caption {
        font-size: 1rem;
    }

    .modal-image-frame {
        height: min(70vh, 620px);
    }
}

/* Mobile Phones */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .header {
        margin-bottom: 30px;
        padding: 10px 0;
    }

    .site-title {
        font-size: 2.6rem;
    }

    .site-subtitle {
        font-size: 1.3rem;
    }

    .search-container {
        margin-bottom: 24px;
        max-width: none;
        width: 100%;
        padding: 0 4px;
    }

    .search-input {
        padding: 12px 44px 12px 16px;
        font-size: 0.95rem;
        line-height: 1.2;
    }

    .search-icon {
        right: 20px;
    }

    .offers-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
    }

    .offer-card {
        border-radius: 12px;
    }

    .offer-name {
        font-size: 0.9rem;
        padding: 10px;
        min-height: 45px;
    }

    .close-modal {
        font-size: 35px;
        right: 15px;
        top: 10px;
    }

    .modal-caption {
        font-size: 0.95rem;
        margin-top: 12px;
    }

    .modal-nav {
        width: 42px;
        height: 42px;
    }

    .modal-image-frame {
        width: 94vw;
        height: min(68vh, 520px);
    }
}

/* Extra Small Devices */
@media (max-width: 320px) {
    .site-title {
        font-size: 1.8rem;
    }

    .offers-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .offer-name {
        font-size: 0.85rem;
    }
}

/* Landscape Mobile Orientation */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-image-frame {
        height: min(78vh, 420px);
    }

    .modal-caption {
        font-size: 0.9rem;
        margin-top: 10px;
    }
}
