/* --- Змінні та Reset --- */

:root {
    /* Кольори */
    --bg-primary: #FFFAFA;
    --bg-secondary: #F5E6D3;
    --text-primary: #6B4E3D;
    --text-secondary: #8B7355;
    --accent: #6B4E3D;
    --white: #FFFFFF;

    /* Шрифт */
    --font-primary: 'Montserrat', sans-serif;

    /* Розміри */
    --container-width: 1200px;
    --section-padding: 80px 0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Fix 2.8: main займає вільний простір — footer завжди внизу */
.main {
    flex: 1;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
}

/* ---
   Container
   --- */

.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 20px;
}

/* ---
   Header
   --- */

.header {
    background-color: var(--bg-primary);
    padding: 20px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(107, 78, 61, 0.1);
}

.header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo__link {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.logo__link:hover {
    color: var(--text-secondary);
}

.nav__list {
    display: flex;
    gap: 40px;
}

.nav__link {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    transition: color 0.3s ease;
    position: relative;
}

.nav__link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--accent);
    transition: width 0.3s ease;
}

.nav__link:hover {
    color: var(--accent);
}

.nav__link:hover::after {
    width: 100%;
}

/* ---
   Buttons
   --- */

.btn {
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Вирівнювання іконок в кнопках */
.btn img {
    display: inline-block;
    margin: 0;
    padding: 0;
    vertical-align: middle;
    transform: translateY(2px);
}

.btn--cart {
    background-color: var(--accent);
    color: var(--white);
}

.btn--cart:hover {
    background-color: #5a3f31;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(107, 78, 61, 0.3);
}

.btn--primary {
    background-color: var(--accent);
    color: var(--white);
    padding: 16px 32px;
    font-size: 16px;
}

.btn--primary:hover {
    background-color: #5a3f31;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(107, 78, 61, 0.3);
}

.btn--small {
    background-color: var(--accent);
    color: var(--white);
    padding: 10px 20px;
}

.btn--small:hover {
    background-color: #5a3f31;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(107, 78, 61, 0.3);
}

.btn--secondary {
    background: #e0e0e0;
    color: var(--text-primary);
}

.btn--secondary:hover {
    background: #d0d0d0;
    transform: translateY(-2px);
}

/* Бургер-меню */
.burger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: transparent;
    padding: 5px;
}

.burger span {
    width: 25px;
    height: 3px;
    background-color: var(--accent);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.burger.active span:nth-child(1) {
    transform: rotate(45deg) translate(8px, 8px);
}

.burger.active span:nth-child(2) {
    opacity: 0;
}

.burger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

/* ---
   Hero Section
   --- */

.hero {
    padding: var(--section-padding);
    background-color: var(--bg-primary);
}

.hero__inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
}

.hero__content {
    max-width: 500px;
}

.hero__title {
    font-size: 48px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.hero__subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    line-height: 1.6;
}

.hero__image {
    position: relative;
}

.hero__image img {
    width: 100%;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(107, 78, 61, 0.15);
}

/* ---
   Features Section
   --- */

.features {
    padding: 60px 0;
    background-color: var(--bg-secondary);
}

.features__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
}

.feature {
    text-align: center;
    padding: 20px;
}

.feature__icon {
    width: 80px;
    height: 80px;
    background-color: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: var(--white);
    transition: transform 0.3s ease;
}

.feature:hover .feature__icon {
    transform: scale(1.1);
}

.feature__title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.feature__text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ---
   Bestsellers Section
   --- */

.bestsellers {
    padding: var(--section-padding);
    background-color: var(--bg-primary);
}

.section__title {
    font-size: 36px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 50px;
    color: var(--text-primary);
}

.products {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 30px;
}

.product {
    background-color: var(--white);
    border-radius: 15px;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.product:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 30px rgba(107, 78, 61, 0.2);
}

.product__badge {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 8px 16px;
    background-color: #E63946;
    color: white;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.product__badge.badge--hit {
    background-color: #E63946;
}

.product__badge.badge--vegan {
    background-color: #52B788;
}

.product__badge.badge--new {
    background-color: #457B9D;
}

.product__link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.product__image {
    width: 100%;
    height: 250px;
    overflow: hidden;
    background-color: #f0f0f0;
}

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

.product:hover .product__image img {
    transform: scale(1.1);
}

.product__title {
    font-size: 18px;
    font-weight: 600;
    padding: 20px 20px 10px;
    color: var(--text-primary);
}

.product__price {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    padding: 0 20px 20px;
}

.product .btn {
    margin: 0 20px 20px;
    width: calc(100% - 40px);
    justify-content: center;
}

/* ---
   Footer
   --- */

.footer {
    background-color: #4A3428;
    color: var(--white);
    padding: 60px 0 30px;
}

.footer__inner {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 40px;
    margin-bottom: 30px;
}

.footer__logo {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
}

.footer__text {
    font-size: 14px;
    line-height: 1.6;
    opacity: 0.8;
}

.footer__title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.footer__list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer__link {
    font-size: 14px;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.footer__link:hover {
    opacity: 1;
}

/* ---
   Cart Badge (Лічильник кошика)
   --- */

.cart-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: #E63946;
    color: var(--white);
    font-size: 12px;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.btn--cart {
    position: relative;
}

/* Анімація пульсації */
@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

.cart-badge.pulse {
    animation: pulse 0.4s ease-in-out;
}

/* ---
   Modal Window (Модальне вікно)
   --- */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7);
    background-color: var(--white);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-width: 400px;
    width: 90%;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal__content {
    /* Flexbox centering for strict alignment */
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    text-align: center;
}

.modal__title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    /* Ensure title takes full width to center properly */
}

.cart-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
}

/* Specific fix for cart button alignment */
.btn--cart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.btn--cart .cart-icon {
    /* Moving icon UP to align with text center */
    transform: translateY(-2px);
}

.modal__text {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.6;
    width: 100%;
    text-align: center;
}

.modal .btn {
    width: 100%;
}

/* Модальне вікно кошика (більший розмір) */
.modal--cart {
    max-width: 500px;
}

/* Список товарів у кошику */
.cart-items {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 24px;
    text-align: left;
    width: 100%;
    /* List stays left-aligned for readability but container is full width */
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: var(--bg-secondary);
    border-radius: 10px;
    margin-bottom: 10px;
}

.cart-item__info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cart-item__name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.cart-item__controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-item__qty-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cart-item__qty-btn:hover {
    background: #5a3f31;
    transform: scale(1.1);
}

.cart-item__quantity {
    min-width: 30px;
    text-align: center;
    font-weight: 600;
    color: var(--text-primary);
}

.cart-item__price-block {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cart-item__price {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
}

.cart-item__remove {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #E63946;
    color: white;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}

.cart-item__remove img {
    width: 14px;
    height: 14px;
    filter: brightness(0) invert(1);
    /* Робить іконку білою */
}

.cart-item__remove:hover {
    background: #c5303a;
    transform: scale(1.1);
}

.cart-total {
    margin-top: 20px;
    padding: 16px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-total__label {
    font-size: 18px;
    font-weight: 600;
    color: white;
}

.cart-total__value {
    font-size: 24px;
    font-weight: 700;
    color: white;
}

.cart-empty {
    text-align: center;
    font-size: 16px;
    color: var(--text-secondary);
    padding: 40px 20px;
}

.modal__actions {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-top: 16px;
    gap: 12px;
}

.modal__actions .btn {
    width: 100%;
}

/* ---
   Order Page (Сторінка оформлення)
   --- */

.order-section {
    padding: 80px 0;
    background: var(--bg-primary);
}

.order-title {
    font-size: 42px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 50px;
    color: var(--text-primary);
}

.order-content {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 60px;
    max-width: 1200px;
    margin: 0 auto;
}

.order-subtitle {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
}

/* Список товарів */
.order-items {
    background: var(--white);
    padding: 32px;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(107, 78, 61, 0.1);
    height: fit-content;
}

.order-list {
    margin-bottom: 24px;
}

.order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 12px;
}

.order-item__info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.order-item__name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.order-item__quantity {
    font-size: 14px;
    color: var(--text-secondary);
}

.order-item__price {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

.order-total-block {
    padding: 20px;
    background: var(--accent);
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-total-label {
    font-size: 20px;
    font-weight: 600;
    color: white;
}

.order-total-value {
    font-size: 28px;
    font-weight: 700;
    color: white;
}

.order-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.order-empty a {
    color: var(--accent);
    text-decoration: underline;
}

/* Форма */
.order-form-wrapper {
    background: var(--white);
    padding: 32px;
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(107, 78, 61, 0.1);
}

.order-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-input,
.form-textarea {
    padding: 14px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-family: var(--font-primary);
    font-size: 16px;
    color: var(--text-primary);
    transition: all 0.3s ease;
    background: var(--bg-primary);
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: white;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: #aaa;
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* --- Вибір умов доставки/оплати --- */

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-primary);
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.radio-label:hover {
    border-color: var(--accent);
    background: white;
}

.radio-label input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--accent);
}

.radio-text {
    font-size: 16px;
    color: var(--text-primary);
}

.btn--full {
    width: 100%;
    margin-top: 12px;
}

.btn--full:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Модалка успішного замовлення */

.modal--success {
    max-width: 500px;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: #52B788;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: white;
    margin: 0 auto 24px;
}

.modal__text--small {
    font-size: 14px;
    color: #999;
    margin-top: 24px;
}

/* ---
   Responsive Design
   --- */


/* Планшети */

@media (max-width: 992px) {
    .hero__inner {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .hero__title {
        font-size: 40px;
    }

    .features__grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

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

    .footer__inner {
        grid-template-columns: 1fr 1fr;
        gap: 30px;
    }

    .order-content {
        grid-template-columns: 1fr;
        gap: 40px;
    }
}

/* Мобільні */

@media (max-width: 768px) {
    .burger {
        display: flex;
    }

    .nav {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 100%;
        background-color: var(--bg-primary);
        padding: 20px;
        transition: left 0.3s ease;
        box-shadow: 0 4px 10px rgba(107, 78, 61, 0.1);
    }

    .nav.active {
        left: 0;
    }

    .nav__list {
        flex-direction: column;
        gap: 20px;
    }

    .hero__title {
        font-size: 32px;
    }

    .hero__subtitle {
        font-size: 16px;
    }

    .products {
        grid-template-columns: 1fr;
    }

    .footer__inner {
        grid-template-columns: 1fr;
    }

    .section__title {
        font-size: 28px;
    }

    .order-title {
        font-size: 32px;
    }

    .order-subtitle {
        font-size: 24px;
    }

    .order-items,
    .order-form-wrapper {
        padding: 24px;
    }
}

@media (max-width: 480px) {
    .hero__title {
        font-size: 28px;
    }

    .btn--cart {
        font-size: 0;
        padding: 12px;
    }

    .btn--cart svg {
        margin: 0;
    }
}

/* ===========================
   Scroll-анімації (fix 4.10)
   =========================== */

.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger ефект для дітей в гріді */
.animate-on-scroll:nth-child(2) {
    transition-delay: 0.1s;
}

.animate-on-scroll:nth-child(3) {
    transition-delay: 0.2s;
}

.animate-on-scroll:nth-child(4) {
    transition-delay: 0.3s;
}

/* ===========================
   Сторінка 404 (fix 4.5)
   =========================== */

.error-page {
    padding: 120px 0;
    text-align: center;
    background: var(--bg-secondary);
}

.error-page__content {
    max-width: 600px;
    margin: 0 auto;
}

.error-page__code {
    font-size: 120px;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 16px;
    opacity: 0.3;
}

.error-page__title {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.error-page__text {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.error-page__actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}