/* templates/css/product.css - стили карточки товара */

/* ===== CSS VARIABLES & RESET ===== */
:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --container: min(100% - 32px, 1200px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { 
    font-size: clamp(0.9rem, 0.85rem + 0.25vw, 1rem);
    -webkit-text-size-adjust: 100%; 
    scroll-behavior: smooth; 
    scroll-padding-top: 80px;
    text-rendering: optimizeLegibility;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100dvh;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}
img { display: block; max-width: 100%; height: auto; }
button, a, select { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ===== HEADER ===== */
.header {
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: clamp(10px, 1.5vw, 14px) 0;
    position: sticky; top: 0; z-index: 50;
}
.header__inner { width: var(--container); margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.header__logo { font-size: 1.25rem; font-weight: 800; color: var(--accent); text-decoration: none; letter-spacing: -0.5px; }
.header__breadcrumb { font-size: 0.8rem; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: auto; padding-left: 8px; }
.header__breadcrumb a { color: var(--text-secondary); text-decoration: none; transition: color var(--transition); }
.header__breadcrumb span { margin: 0 6px; color: var(--text-muted); }
@media (max-width: 480px) { .header__breadcrumb { display: none; } }

/* ===== MOBILE PRODUCT HEADER ===== */
.mobile-header { width: var(--container); margin: 0 auto; padding: 8px 0 4px; display: none; }
.mobile-header__title { font-size: clamp(1.1rem, 3vw + 0.2rem, 1.35rem); font-weight: 700; line-height: 1.3; color: var(--text); margin-bottom: 8px; }
.mobile-header__badges { display: flex; flex-wrap: wrap; gap: 6px; }
.mobile-header__badge { font-size: 0.7rem; font-weight: 600; padding: 4px 10px; border-radius: 99px; display: inline-flex; align-items: center; gap: 4px; }
.mobile-header__badge--hit { background: #fff7ed; color: #ea580c; }
.mobile-header__badge--safe { background: #f0fdf4; color: #16a34a; }
@media (max-width: 959px) { .mobile-header { display: block; } }

/* ===== MAIN LAYOUT ===== */
.product { width: var(--container); margin: clamp(16px, 3vw, 32px) auto; display: grid; grid-template-columns: 1fr; gap: clamp(16px, 2vw, 24px); align-items: start; }
@media (min-width: 960px) { .product { grid-template-columns: minmax(340px, 460px) 1fr; gap: clamp(24px, 3vw, 48px); } }

/* ===== GALLERY ===== */
.gallery { position: relative; display: flex; flex-direction: column-reverse; gap: 12px; }
@media (min-width: 960px) {
    .gallery { position: sticky; top: calc(72px + var(--safe-top)); flex-direction: row; align-items: flex-start; }
}

.gallery__thumbs {
    display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -ms-overflow-style: none;
}
.gallery__thumbs::-webkit-scrollbar { display: none; }

@media (min-width: 960px) {
    .gallery__thumbs {
        width: 72px; flex-direction: column; max-height: calc(90dvh - 120px);
        overflow-y: auto; overflow-x: hidden; padding: 0;
        scrollbar-width: none;
    }
    .gallery__thumbs::-webkit-scrollbar { display: none; }
}

.gallery__thumb {
    width: clamp(54px, 10vw, 68px); aspect-ratio: 3 / 4;
    border-radius: var(--radius-sm); overflow: hidden; cursor: pointer;
    border: 2px solid transparent; background: var(--surface);
    box-shadow: var(--shadow-sm); transition: all var(--transition); flex-shrink: 0;
}
.gallery__thumb img { width: 100%; height: 100%; object-fit: cover; }
.gallery__thumb--active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
@media (hover: hover) and (pointer: fine) { .gallery__thumb:hover { transform: scale(1.04); } }

@media (min-width: 960px) {
    .gallery__thumbs { scroll-snap-type: y mandatory; }
    .gallery__thumb { scroll-snap-align: start; width: 100%; }
}
@media (max-width: 959px) { .gallery__thumb { scroll-snap-align: center; } }

.gallery__main-wrapper {
    width: 100%; aspect-ratio: 3 / 4; height: auto;
    background: var(--surface); border-radius: var(--radius-lg);
    overflow: hidden; cursor: zoom-in; box-shadow: var(--shadow-md);
    position: relative; display: flex; align-items: center; justify-content: center;
    transition: box-shadow var(--transition);
}
.gallery__main-wrapper:hover { box-shadow: var(--shadow-lg); }
.gallery__main-img { width: 100%; height: 100%; object-fit: cover; transition: opacity 0.12s ease, transform 0.3s ease; }
.gallery__hint {
    position: absolute; bottom: clamp(8px, 2vw, 12px); right: clamp(8px, 2vw, 12px);
    background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(4px);
    color: #fff; padding: 5px 10px; border-radius: 99px;
    font-size: 0.7rem; font-weight: 500; pointer-events: none;
    display: flex; align-items: center; gap: 5px; opacity: 0.9;
}

/* ===== PRODUCT INFO ===== */
.info {
    background: var(--surface); border-radius: var(--radius-lg); 
    padding: clamp(16px, 2vw, 28px);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
    display: flex; flex-direction: column; gap: clamp(12px, 1.5vw, 18px);
}
@media (max-width: 959px) { .info { border-radius: var(--radius-lg) var(--radius-lg) 0 0; border-bottom: none; } }

.info__title { font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem); font-weight: 700; line-height: 1.2; }
.info__rating { display: flex; align-items: center; gap: 8px; }
.info__stars { display: flex; gap: 2px; }
.info__stars svg { width: clamp(14px, 1.5vw, 16px); height: clamp(14px, 1.5vw, 16px); }
.info__rating-text { font-size: 0.85rem; color: var(--text-secondary); font-weight: 500; }
.info__badges { display: flex; flex-wrap: wrap; gap: 6px; }
.info__badge { font-size: 0.72rem; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: #f1f5f9; color: #475569; display: inline-flex; align-items: center; gap: 4px; }
.info__badge--hit { background: #fff7ed; color: #ea580c; }
.info__badge--safe { background: #f0fdf4; color: #16a34a; }

.info__price-block { display: flex; align-items: baseline; gap: 10px; padding: 16px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.info__price { font-size: clamp(1.5rem, 1.3rem + 0.8vw, 2rem); font-weight: 800; color: var(--accent); }
.info__price-old { font-size: clamp(0.9rem, 0.8rem + 0.4vw, 1.05rem); color: var(--text-muted); text-decoration: line-through; }
.info__discount { background: var(--accent); color: #fff; font-size: 0.7rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; letter-spacing: 0.5px; }

.info__cta { display: flex; flex-direction: column; gap: 10px; padding: 8px 0; }
.info__btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: clamp(12px, 1.2vw, 14px) 18px; font-size: clamp(0.9rem, 0.85rem + 0.2vw, 1rem); font-weight: 600; border: none; border-radius: var(--radius-md); cursor: pointer; transition: all var(--transition); text-decoration: none; }
.info__btn:active { transform: scale(0.98); }
.info__btn--buy { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%); color: #fff; box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3); }
.info__btn--desc { background: var(--surface); color: var(--text-secondary); border: 1.5px solid var(--border); }
@media (hover: hover) and (pointer: fine) { .info__btn--buy:hover { box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4); transform: translateY(-1px); } .info__btn--desc:hover { background: #f8fafc; color: var(--text); border-color: var(--text-muted); } }

.info__size-section { display: flex; flex-direction: column; gap: 8px; }
.info__size-label { font-size: 0.85rem; color: var(--text-secondary); font-weight: 500; }
.info__size-select {
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    width: 100%; padding: 12px 40px 12px 14px;
    font-size: 0.95rem; font-weight: 500; color: var(--text);
    background: var(--surface); border: 1.5px solid var(--border);
    border-radius: var(--radius-md); cursor: pointer; transition: all var(--transition);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}
.info__size-select:hover { border-color: var(--text-muted); }
.info__size-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
@media (max-width: 480px) { .info__size-select { font-size: 1rem; padding: 14px 42px 14px 14px; } }

.info__color-section { display: flex; flex-direction: column; gap: 8px; }
.info__color-label { font-size: 0.85rem; color: var(--text-secondary); }
.info__color-label strong { color: var(--text); font-weight: 600; }
.info__color-options { display: flex; gap: 12px; flex-wrap: wrap; }
.info__color-swatch { 
    width: clamp(32px, 6vw, 38px); height: clamp(32px, 6vw, 38px); 
    border-radius: 50%; cursor: pointer; border: 2px solid var(--border); 
    background: var(--surface); position: relative; transition: all var(--transition); 
}
.info__color-swatch::after { 
    content: ''; position: absolute; inset: -4px; border-radius: 50%; 
    border: 2px solid transparent; transition: border-color var(--transition); 
}
.info__color-swatch--active::after { border-color: var(--accent); }

/* Цветовые классы для свотчей - можно расширять */
.info__color-swatch--gray { background: #94a3b8; }
.info__color-swatch--black { background: #0f172a; }
.info__color-swatch--blue { background: #3b82f6; }
.info__color-swatch--white { background: #f8fafc; border-color: #cbd5e1; }
.info__color-swatch--red { background: #ef4444; }
.info__color-swatch--green { background: #10b981; }
.info__color-swatch--pink { background: #ec4899; }
.info__color-swatch--yellow { background: #f59e0b; }
.info__color-swatch--purple { background: #8b5cf6; }
.info__color-swatch--brown { background: #78350f; }

.info__specs { display: flex; flex-direction: column; gap: 6px; }
.info__specs-title { font-size: 1rem; font-weight: 700; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.info__spec-row { display: flex; padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-size: 0.9rem; gap: 12px; }
.info__spec-label { flex: 0 0 40%; color: var(--text-secondary); }
.info__spec-value { flex: 1; color: var(--text); font-weight: 500; word-break: break-word; }

.info__delivery { display: flex; align-items: flex-start; gap: 12px; padding: 14px; background: #f8fafc; border-radius: var(--radius-md); font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }
.info__delivery svg { flex-shrink: 0; width: 20px; height: 20px; margin-top: 2px; color: #16a34a; }

/* ===== DESCRIPTION ===== */
#description { scroll-margin-top: 80px; }
.description { width: var(--container); margin: 0 auto clamp(32px, 5vw, 64px); }
.description__card { background: var(--surface); border-radius: var(--radius-lg); padding: clamp(16px, 2vw, 28px); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.description__title { font-size: clamp(1.15rem, 1rem + 0.5vw, 1.35rem); font-weight: 700; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 2px solid #f1f5f9; }
.description__text { font-size: clamp(0.92rem, 0.88rem + 0.2vw, 1rem); line-height: 1.7; color: #334155; }
.description__text p { margin-bottom: 14px; } .description__text p:last-child { margin-bottom: 0; }
.description__text strong { color: var(--text); }

/* ===== LIGHTBOX ===== */
.lightbox {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(15, 23, 42, 0.92); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transition: opacity 0.2s ease, visibility 0.2s ease;
    padding: calc(var(--safe-top, 0px) + 12px) calc(var(--safe-right, 0px) + 12px) calc(var(--safe-bottom, 0px) + 12px) calc(var(--safe-left, 0px) + 12px);
}
.lightbox--open { opacity: 1; visibility: visible; }
.lightbox__img {
    aspect-ratio: 3 / 4;
    max-width: min(90vw, 85dvh * 0.75);
    max-height: min(85dvh, 90vw * 1.33);
    width: auto; height: auto; object-fit: cover;
    border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
    transition: transform 0.25s ease;
}
.lightbox__close, .lightbox__nav {
    position: absolute; background: rgba(255,255,255,0.15); backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.2); color: #fff; border-radius: 50%;
    width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all var(--transition); z-index: 2;
}
.lightbox__close:hover, .lightbox__nav:hover { background: rgba(255,255,255,0.25); }
.lightbox__close { top: 16px; right: 16px; }
.lightbox__nav { top: 50%; transform: translateY(-50%); }
.lightbox__prev { left: 16px; }
.lightbox__next { right: 16px; }
.lightbox__nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.lightbox__counter {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
    color: #fff; padding: 6px 14px; border-radius: 99px; font-size: 0.8rem; font-weight: 500;
    border: 1px solid rgba(255,255,255,0.15);
}
@media (max-width: 480px) { .lightbox__nav { width: 36px; height: 36px; } .lightbox__prev { left: 8px; } .lightbox__next { right: 8px; } .lightbox__counter { bottom: 12px; font-size: 0.75rem; } }

/* ===== FOOTER ===== */
.footer { background: var(--surface); border-top: 1px solid var(--border); padding: clamp(16px, 2vw, 22px) 16px calc(16px + var(--safe-bottom)); text-align: center; font-size: 0.8rem; color: var(--text-muted); }

/* ===== ANIMATIONS ===== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.product, .description { animation: fadeUp 0.4s ease both; } .description { animation-delay: 0.08s; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; } }