/* ==========================================================
   Public storefront design system - shop-engine
   ========================================================== */

:root {
    --color-primary: #1a1a1a;
    --color-accent: #c9a227;
    --color-bg: #ffffff;

    --text-muted: #6b7280;
    --text-faint: #9ca3af;
    --border: #e8e6e1;
    --border-soft: #f0eee9;
    --surface: #faf9f6;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow-card: 0 1px 2px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.04);
    --shadow-hover: 0 8px 24px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-primary);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

h1, h2, h3 { letter-spacing: -0.01em; margin: 0; }

/* ================= HEADER ================= */

.site-header {
    border-bottom: 1px solid var(--border);
    padding: 0;
    position: sticky;
    top: 0;
    background: var(--color-header-bg);
    backdrop-filter: blur(6px);
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    height: 68px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 21px;
    color: var(--color-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}
.logo__image { height: 36px; width: auto; display: block; }
.logo__text { white-space: nowrap; }

.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.main-nav > a {
    padding: 8px 14px;
    color: var(--color-header-link);
    text-decoration: none;
    font-size: 14.5px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background .12s, color .12s;
}
.main-nav > a:hover { background: var(--surface); color: var(--color-accent); }

/* Dropdown */
.nav-dropdown { position: relative; }

.nav-dropdown__trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    color: var(--color-header-link);
    text-decoration: none;
    font-size: 14.5px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background .12s, color .12s;
}
.nav-dropdown:hover .nav-dropdown__trigger { background: var(--surface); color: var(--color-accent); }
.nav-dropdown__caret { transition: transform .15s; opacity: 0.6; }
.nav-dropdown:hover .nav-dropdown__caret { transform: rotate(180deg); }

.nav-dropdown__panel {
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    padding: 10px;
    min-width: 260px;
    max-height: 70vh;
    overflow-y: auto;
    display: grid;
    gap: 1px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity .15s, transform .15s, visibility .15s;
    z-index: 50;
}
.nav-dropdown:hover .nav-dropdown__panel,
.nav-dropdown:focus-within .nav-dropdown__panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(8px);
}

.nav-dropdown__panel a {
    padding: 9px 12px;
    color: var(--color-header-link);
    text-decoration: none;
    font-size: 13.5px;
    border-radius: var(--radius-sm);
}
.nav-dropdown__panel a:hover { background: var(--surface); color: var(--color-accent); }

.header-actions { display: flex; align-items: center; gap: 20px; flex-shrink: 0; }

.lang-switch a {
    margin: 0 3px;
    text-decoration: none;
    color: var(--text-faint);
    font-size: 12.5px;
    font-weight: 600;
}
.lang-switch a.active { color: var(--color-accent); }

.cart-link {
    display: flex;
    align-items: center;
    gap: 7px;
    text-decoration: none;
    color: var(--color-header-link);
    font-weight: 600;
    font-size: 14px;
}
.cart-link:hover { color: var(--color-accent); }

/* ================= INTRO / TEXT BLOCK ================= */

.intro-block { padding: 48px 24px 8px; }
.intro-block h1 { font-size: 28px; margin-bottom: 16px; }
.intro-block__content {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.7;
    max-width: 760px;
}
.intro-block__content h2 { font-size: 19px; color: var(--color-primary); margin: 1em 0 0.4em; }
.intro-block__content p { margin: 0 0 0.9em; }
.intro-block__content ul { padding-left: 1.3em; }

/* ================= HOME SECTIONS ================= */

.home-section { padding: 40px 24px; }

.home-section--categories { padding-top: 32px; padding-bottom: 8px; }

.categories-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 14px;
    justify-items: stretch;
}

.category-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--color-primary);
    justify-self: center;
    width: 96px;
}

.category-tile__image {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .15s, transform .15s;
}
.category-tile:hover .category-tile__image { border-color: var(--color-accent); transform: translateY(-2px); }
.category-tile__image img { width: 100%; height: 100%; object-fit: cover; }

.category-tile__name {
    font-size: 12.5px;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Категорія без фото - підписаний блок, однакова ширина по всій сітці, компактний */
.category-tile--text {
    justify-self: stretch;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px 8px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.3;
    transition: border-color .15s, transform .15s;
}
.category-tile--text:hover { border-color: var(--color-accent); transform: translateY(-2px); }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}
.section-head h2 { font-size: 22px; font-weight: 700; }
.section-head__link { color: var(--color-accent); text-decoration: none; font-size: 14px; font-weight: 600; white-space: nowrap; }
.section-head__link:hover { text-decoration: underline; }
.section-head__count { color: var(--text-faint); font-size: 13.5px; }

/* ================= PRODUCT CARDS ================= */

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 20px;
}

.product-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--color-primary);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow .2s, transform .2s, border-color .2s;
}
.product-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    border-color: var(--border);
}

.product-card__image {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--surface);
    overflow: hidden;
}
.product-card__image img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform .3s;
}
.product-card:hover .product-card__image img { transform: scale(1.04); }

.product-card__no-image {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-faint); font-size: 13px;
}

.product-card__badge {
    position: absolute;
    top: 10px; left: 10px;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 9px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.product-card__badge--new { background: #16a34a; color: #fff; }
.product-card__badge--out { background: #fff; color: #b42318; box-shadow: 0 0 0 1px #f3c6c2 inset; }

.product-card__body { padding: 14px 14px 16px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.product-card__name {
    font-size: 14px;
    line-height: 1.4;
    font-weight: 500;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.8em;
}
.product-card__footer { display: flex; align-items: baseline; gap: 8px; margin-top: auto; }
.product-card__price { font-weight: 700; font-size: 16.5px; color: var(--color-primary); }
.product-card__old-price { font-size: 13px; color: var(--text-faint); text-decoration: line-through; }

/* ================= PAGINATION ================= */

.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 36px; flex-wrap: wrap; }
.pagination__page, .pagination__arrow {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px; padding: 0 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--color-primary);
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid var(--border);
}
.pagination__page:hover, .pagination__arrow:hover { background: var(--surface); }
.pagination__page.is-active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination__dots { color: var(--text-faint); padding: 0 4px; }

/* ================= CATALOG / CATEGORY ================= */

.catalog-category { padding: 40px 24px 60px; }
.category-header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.category-header h1 { font-size: 26px; }
.category-header__count { color: var(--text-faint); font-size: 13.5px; white-space: nowrap; }

.category-description {
    color: var(--text-muted);
    font-size: 14.5px;
    line-height: 1.7;
    max-width: 760px;
    margin-bottom: 32px;
}
.category-description h2 { font-size: 18px; color: var(--color-primary); margin: 1em 0 0.4em; }
.category-description p { margin: 0 0 0.8em; }

/* ---- Каталог: без сайдбару, блок категорій + товари ---- */

.catalog-main-full { padding: 8px 24px 60px; }
.catalog-main-full .category-header { margin-bottom: 24px; }

/* ================= PRODUCT PAGE ================= */

.product-page {
    padding: 40px 24px 60px;
    display: grid;
    grid-template-columns: 420px 1fr;
    grid-template-areas:
        "gallery title"
        "gallery price"
        "gallery buy"
        "gallery description";
    column-gap: 48px;
    row-gap: 0;
}

.product-area-gallery { grid-area: gallery; }
.product-area-title { grid-area: title; font-size: 24px; margin: 0 0 12px; align-self: start; }
.product-area-price { grid-area: price; }
.product-area-buy { grid-area: buy; }
.product-area-description { grid-area: description; }

.product-main-image {
    width: 100%;
    max-height: 460px;
    object-fit: contain;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.product-thumbs { display: flex; gap: 8px; margin-top: 10px; }
.product-thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: pointer; }

/* Ціна - виділена акцентним кольором, з "чіпом" фону */
.product-price {
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
    margin: 8px 0 20px;
}
.product-price__value {
    font-size: 30px;
    font-weight: 800;
    color: var(--color-accent);
    letter-spacing: -0.01em;
}
.product-price__currency { font-size: 20px; font-weight: 700; }
.product-price__old { font-size: 15px; color: var(--text-faint); text-decoration: line-through; }

.out-of-stock { color: #b42318; font-weight: 600; margin-bottom: 16px; }

.product-area-buy button {
    background: var(--color-buy-btn);
    color: #fff;
    border: none;
    padding: 13px 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: background .15s;
}
.product-area-buy button:hover { background: var(--color-accent); }

.product-description { margin-top: 28px; color: var(--text-muted); font-size: 14.5px; line-height: 1.7; }
.product-description p { margin: 0 0 0.9em; }

/* Таблиця характеристик (Параметр: Значення), згенерована з <ul> через spec-table.js */
.spec-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0 0 20px;
    font-size: 14px;
    table-layout: auto;
}
.spec-table tr:nth-child(odd) { background: var(--surface); }
.spec-table tr:nth-child(even) { background: #fff; }
.spec-table td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: top;
    max-width: 50%;
    overflow-wrap: break-word;
    word-break: break-word;
}
.spec-table__label {
    text-align: left;
    font-weight: 600;
    color: var(--color-primary);
    white-space: nowrap;
    width: 1%;
}
.spec-table__value {
    text-align: right;
    color: var(--text-muted);
}
@media (max-width: 560px) {
    .spec-table { font-size: 13px; }

    /* На вузьких екранах перемикаємо з table-layout на flex-рядки:
       уникає пастки width:1%+white-space:normal (перенос по буквах) */
    .spec-table, .spec-table tbody { display: block; width: 100%; }
    .spec-table tr {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 10px;
        padding: 7px 10px;
        border-bottom: 1px solid var(--border-soft);
    }
    .spec-table td {
        display: inline;
        padding: 0;
        border-bottom: none;
        max-width: none;
    }
    .spec-table__label {
        white-space: nowrap;
        flex-shrink: 0;
    }
    .spec-table__value {
        flex: 1;
        min-width: 0;
        text-align: right;
        word-break: break-word;
    }
}

/* ================= CART ================= */

.cart-page { padding: 40px 24px 60px; }
.cart-page h1 { margin-bottom: 24px; }
.cart-empty { color: var(--text-muted); }
.cart-empty a { color: var(--color-accent); }

.cart-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.cart-table td { padding: 14px 12px; border-bottom: 1px solid var(--border-soft); font-size: 14.5px; vertical-align: middle; }
.cart-table__image img { width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.cart-table__name a { color: var(--color-primary); text-decoration: none; font-weight: 500; }
.cart-table__name a:hover { color: var(--color-accent); }
.cart-table__qty { color: var(--text-muted); white-space: nowrap; }
.cart-table__sum { font-weight: 700; white-space: nowrap; }
.cart-table__remove button {
    background: none; border: none; cursor: pointer;
    color: var(--text-faint); font-size: 15px; padding: 6px;
    transition: color .12s;
}
.cart-table__remove button:hover { color: #b42318; }

.cart-summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.cart-total { font-size: 18px; font-weight: 700; }
.cart-total span { color: var(--color-accent); }

.cart-page .btn, .order-success-page .btn, .checkout-page .btn {
    display: inline-block; background: var(--color-buy-btn); color: #fff;
    padding: 13px 26px; border-radius: var(--radius-sm); text-decoration: none; font-weight: 600;
    border: none; cursor: pointer; font-size: 15px;
}
.cart-page .btn:hover, .order-success-page .btn:hover, .checkout-page .btn:hover { background: var(--color-accent); }

/* ---- Checkout ---- */

.checkout-page { padding: 40px 24px 60px; }
.checkout-page h1 { margin-bottom: 28px; }

.checkout-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 40px; align-items: start; }

.checkout-form {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 28px; box-shadow: var(--shadow-card);
}
.checkout-form h3 { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.checkout-form label { display: block; margin-top: 14px; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.checkout-form label:first-of-type { margin-top: 10px; }
.checkout-form input[type=text], .checkout-form input[type=tel], .checkout-form input[type=email], .checkout-form textarea {
    width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14.5px; font-family: inherit;
}
.checkout-form input:focus, .checkout-form textarea:focus { outline: none; border-color: var(--color-accent); }
.checkout-form textarea { min-height: 80px; resize: vertical; }

.payment-options { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.payment-option { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; color: var(--color-primary); cursor: pointer; }
.payment-option input { width: auto; margin: 0; }
.payment-option--disabled { color: var(--text-faint); cursor: not-allowed; }

.checkout-submit { width: 100%; margin-top: 24px; padding: 14px; font-size: 15.5px; }

.checkout-summary {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px;
}
.checkout-summary h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.checkout-summary__row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.checkout-summary__name { color: var(--text-muted); }
.checkout-summary__sum { font-weight: 600; white-space: nowrap; }
.checkout-summary__total { display: flex; justify-content: space-between; font-size: 17px; font-weight: 700; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---- Order success ---- */

.order-success-page { padding: 60px 24px; max-width: 640px; text-align: center; }
.order-success__icon {
    width: 64px; height: 64px; border-radius: 50%;
    background: #e7f6ef; color: #16794f;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px; margin: 0 auto 20px;
}
.order-success-page h1 { font-size: 26px; margin-bottom: 12px; }
.order-success__sub { color: var(--text-muted); font-size: 14.5px; margin: 4px 0; }
.order-success-page .cart-table { text-align: left; margin-top: 24px; }
.order-success-page .cart-total { text-align: right; }

/* ================= STATIC PAGES / CONTACTS / BLOG ================= */

.static-page, .contacts-page, .not-found { padding: 40px 24px 60px; max-width: 760px; }
.static-page h1, .contacts-page h1 { font-size: 26px; margin-bottom: 20px; }
.page-content { color: var(--text-muted); font-size: 15px; line-height: 1.75; }
.page-content h2 { color: var(--color-primary); font-size: 19px; margin: 1em 0 0.4em; }
.page-content p { margin: 0 0 0.9em; }

.not-found { text-align: center; padding: 100px 24px; }
.not-found h1 { font-size: 48px; }

/* ================= FOOTER ================= */

.site-footer {
    margin-top: 60px;
    background: var(--color-footer-bg);
    color: var(--color-footer-text);
    padding-top: 48px;
}

.footer-inner {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1.2fr 1fr;
    gap: 32px;
    padding-bottom: 40px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.footer-brand { display: block; text-decoration: none; color: inherit; }
.footer-brand[href]:hover .footer-col__title { color: var(--color-accent); }
.footer-logo { height: 32px; width: auto; display: block; margin-bottom: 12px; }

.footer-col__title {
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 16px;
}

.footer-about, .footer-requisites, .footer-contacts {
    display: block;
    color: var(--color-footer-text);
    text-decoration: none;
    font-size: 13.5px;
    line-height: 1.9;
}
.footer-link {
    display: block;
    color: var(--color-footer-link);
    text-decoration: none;
    font-size: 13.5px;
    line-height: 1.9;
}
.footer-link:hover { color: #fff; }
.footer-requisites, .footer-about { line-height: 1.7; }

.footer-bottom {
    padding: 20px 0;
    color: #7a7a7a;
    font-size: 12.5px;
}

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

@media (max-width: 900px) {
    .product-page {
        grid-template-columns: 1fr;
        grid-template-areas:
            "gallery"
            "title"
            "price"
            "buy"
            "description";
    }
    .checkout-grid { grid-template-columns: 1fr; }
    .footer-inner { grid-template-columns: 1fr 1fr; }

    /* Хедер на мобільних - стовпчиком: лого (центр) / меню (зліва) / кошик (справа) */
    .header-inner {
        height: auto;
        flex-direction: column;
        align-items: stretch;
        padding: 10px 0;
    }
    .logo { align-self: center; }

    .main-nav {
        display: flex;
        flex: none;
        align-self: stretch;
        justify-content: space-between;
        flex-wrap: wrap;
        padding: 0 10px;
        margin: 20px 0;
    }

    .header-actions { align-self: flex-end; margin-right: 20px; }
}

@media (max-width: 560px) {
    .footer-inner { grid-template-columns: 1fr; }
    .products-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

    /* Лого+назва в футері по центру на мобільних */
    .footer-col--brand { text-align: center; }
    .footer-logo { margin: 0 auto 12px; }

    /* Категорії на головній - по 2 в ряд на мобільних */
    .categories-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }

    /* Компактніший хедер на мобільних - звільняє місце під товар */
    .header-inner { padding: 8px 0; gap: 6px; }
    .logo { font-size: 17px; }
    .logo__image { height: 26px; }
    .main-nav > a, .nav-dropdown__trigger { padding: 5px 10px; font-size: 13.5px; }

    /* Товар: назва -> фото -> ціна -> кнопка (за проханням) */
    .product-page {
        padding: 10px 16px 40px;
        row-gap: 10px;
        grid-template-areas:
            "title"
            "gallery"
            "price"
            "buy"
            "description";
    }
    .product-area-title {
        font-size: 16px;
        line-height: 1.25;
        margin: 0;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .product-main-image {
        max-height: min(260px, 36vh);
        width: 100%;
        object-fit: contain;
        background: var(--surface);
    }
    .product-thumbs { display: none; }

    .product-price { margin: 0; }
    .product-price__value { font-size: 24px; }
    .product-price__currency { font-size: 16px; }
    .out-of-stock { margin-bottom: 8px; font-size: 13.5px; }
    .product-area-buy button {
        width: 100%;
        padding: 12px;
        font-size: 14.5px;
    }
    .product-description { margin-top: 16px; font-size: 14px; }
}
