/* =====================================================================================================
   ATELIER — каталог, картка товару (уточнення), швидкий перегляд, обране (2026-11-12)
   Підключається на сторінках з картками: головна/каталог (index.html), обране, товар.
   Спирається на токени й компоненти atelier.css (.at-btn, .at-grid, .at-card, .at-drawer, .at-acc …).
   Сітка 8px; анімації — лише transform / opacity; prefers-reduced-motion вимикає.
   ===================================================================================================== */

/* ── службові: показ лише на телефоні / лише від 768px ─────────────────────────────────────────── */
@media (max-width: 767.98px) { .at-fb-d, .at-fb-dflex { display: none !important; } }
@media (min-width: 768px) { .at-fb-m { display: none !important; } }

/* ── каталог: каркас ───────────────────────────────────────────────────────────────────────────── */
.at-listing { padding-bottom: 64px; }
.at-listing .at-crumbs { padding: 16px 0 8px; }
.at-listing .at-crumbs a { transition: color .2s; }
.at-listing__layout { display: block; }
@media (min-width: 1200px) {
  .at-listing__layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 40px; align-items: start; }
}
.at-listing__main { min-width: 0; }

/* дерево категорій (ПК) */
.at-tree { display: none; }
@media (min-width: 1200px) {
  .at-tree { display: block; position: sticky; top: calc(var(--at-sticky-top, 64px) + 16px); max-height: calc(100vh - var(--at-sticky-top, 64px) - 32px);
    overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 8px 8px 24px 0; transition: top .3s var(--at-ease); }
}
.at-tree__list, .at-tree__kids { list-style: none; margin: 0; padding: 0; }
.at-tree__item + .at-tree__item { margin-top: 2px; }
.at-tree__link { display: block; padding: 6px 0; font-size: 12px; font-weight: 500; line-height: 1.5; letter-spacing: .08em; text-transform: uppercase; color: #333; transition: color .2s, transform .25s var(--at-ease); }
.at-tree__link:hover { color: #000; transform: translateX(2px); }
.at-tree__item.is-active > .at-tree__link, .at-tree__item.is-open > .at-tree__link { font-weight: 700; color: #000; }
.at-tree__kids { display: none; padding: 4px 0 12px 16px; }
.at-tree__item.is-open > .at-tree__kids { display: block; }
.at-tree__kid { display: block; padding: 5px 0; font-size: 13px; color: var(--at-muted); transition: color .2s; }
/* один рядок: підміна шрифту під час завантаження не зсуває дерево (CLS = 0) */
.at-tree__link, .at-tree__kid { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.at-tree__kid:hover { color: #000; }
.at-tree__kid.is-active { color: #000; font-weight: 600; }

/* заголовок і кількість */
.at-listing__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; padding: 8px 0 16px; }
.at .at-listing__title { font-size: clamp(22px, 2.4vw, 28px); font-weight: 600; letter-spacing: -.01em; min-width: 0; overflow-wrap: anywhere; }
.at-listing__title > .at-listing__title-fallback:not(:only-child) { display: none; }
.at .at-listing__count { margin: 0; font-size: 13px; }
@media (min-width: 768px) { .at .at-listing__count { display: none; } }

/* чіпи підкатегорій / активних фільтрів */
.at-chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 0 0 16px; margin: 0 calc(var(--at-gutter) * -1); padding-left: var(--at-gutter); padding-right: var(--at-gutter);
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--at-gutter), #000 calc(100% - var(--at-gutter)), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 var(--at-gutter), #000 calc(100% - var(--at-gutter)), transparent 100%); }
.at-chips::-webkit-scrollbar { display: none; }
@media (min-width: 1200px) {
  /* на ПК поруч є дерево категорій — підкатегорії легким рядком посилань */
  /* один рядок (прокрутка вбік): підміна шрифту не переносить рядок і нічого не зсуває */
  .at-chips { margin: -4px 0 0; padding: 0 0 16px; gap: 4px 24px;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 48px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 48px), transparent); }
  .at-chips .at-chip { min-height: 32px; padding: 4px 0; border: 0; border-bottom: 1px solid transparent; background: none; color: var(--at-muted); }
  .at-chips .at-chip:hover { color: #000; border-bottom-color: currentColor; }
  .at-chips .at-chip.is-active { background: none; color: #000; font-weight: 600; border-bottom-color: #000; }
}
.at-chips--sub { padding-top: 0; }
.at-chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 16px; border: 1px solid var(--at-line); background: #fff; color: #222;
  font-size: 13px; font-weight: 500; white-space: nowrap; transition: border-color .2s, background-color .2s, color .2s, transform .25s var(--at-ease); }
.at-chip:hover { border-color: #222; }
.at-chip:active { transform: scale(.97); }
.at-chip.is-active { background: #000; border-color: #000; color: #fff; }
.at-chip--x { padding-right: 12px; }
.at-chip svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 1.8; fill: none; flex: 0 0 auto; }

/* ── липка смуга фільтрів ──────────────────────────────────────────────────────────────────────── */
.at-fbar { position: sticky; top: var(--at-sticky-top, 0px); z-index: 60; margin: 0 calc(var(--at-gutter) * -1) 16px; padding: 0 var(--at-gutter);
  background: color-mix(in srgb, var(--at-bg) 92%, transparent); -webkit-backdrop-filter: saturate(160%) blur(12px); backdrop-filter: saturate(160%) blur(12px);
  border-top: 1px solid var(--at-line); border-bottom: 1px solid var(--at-line); }
@media (min-width: 1200px) { .at-fbar { margin-left: 0; margin-right: 0; padding: 0; border-top: 0; } }
.at-fbar::after { content: ''; position: absolute; left: 0; right: 0; top: 100%; height: 12px; pointer-events: none; background: linear-gradient(rgba(0,0,0,.06), transparent); opacity: 0; transition: opacity .3s; }
.at-fbar.is-stuck::after { opacity: 1; }
.at-fbar__form { display: flex; align-items: center; gap: 8px; min-height: 48px; }
@media (min-width: 768px) { .at-fbar__form { gap: 16px; } }
@media (min-width: 1024px) { .at-fbar__form { gap: 24px; } }
@media (max-width: 1023.98px) { .at-fbar__val, .at-view__label { display: none; } }
.at-fbar__btn { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0; background: none; border: 0; cursor: pointer; list-style: none;
  font-family: var(--at-font-body); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #222; white-space: nowrap; user-select: none; }
.at-fbar__btn::-webkit-details-marker { display: none; }
.at-fbar__btn::marker { content: ''; }
.at-fbar__btn > svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.6; fill: none; flex: 0 0 auto; }
.at-fbar__btn--filters > svg { width: 18px; height: 18px; }
.at-fbar__chev { transition: transform .3s var(--at-ease); }
.at-dd[open] > .at-fbar__btn .at-fbar__chev { transform: rotate(180deg); }
.at-fbar__btn::after { content: ''; position: absolute; left: 0; right: 0; bottom: 10px; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .35s var(--at-ease); }
.at-fbar__btn:hover::after, .at-dd[open] > .at-fbar__btn::after { transform: scaleX(1); }
.at-fbar__num { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #000; color: #fff; font-size: 11px; letter-spacing: 0; }
.at-fbar__val { font-weight: 500; letter-spacing: .02em; text-transform: none; color: var(--at-muted); }
.at-fbar__dot { width: 6px; height: 6px; border-radius: 50%; background: #000; }
@media (min-width: 768px) { .at-fbar__btn--filters { order: 5; } }
.at-fbar__right { margin-left: auto; display: flex; align-items: center; gap: 16px; order: 6; }
.at-fbar__count { font-size: 12px; color: var(--at-muted); white-space: nowrap; }
@media (max-width: 767.98px) {
  .at-fbar__btn--filters { padding-right: 16px; border-right: 1px solid var(--at-line); }
  .at-fbar__btn::after { display: none; }
}

/* випадні панелі (details) */
.at-dd { position: relative; }
.at-dd__panel { position: absolute; z-index: 5; top: calc(100% + 1px); left: 0; min-width: 256px; padding: 16px; background: #fff; border: 1px solid var(--at-line); box-shadow: 0 24px 48px -24px rgba(0,0,0,.28);
  transform-origin: top left; animation: at-dd-in .28s var(--at-ease); }
@keyframes at-dd-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
.at-dd__panel--list { padding: 8px; }
.at-dd__panel--sizes { width: 344px; }
.at-dd__panel--price { width: 320px; }
@media (max-width: 767.98px) { .at-dd--sort .at-dd__panel { left: auto; right: auto; min-width: 232px; } }
.at-dd__actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.at-dd__actions .at-btn { flex: 1 1 0; padding-left: 16px; padding-right: 16px; }
.at-ready .at-dd__nojs { display: none; }
.at-dd__nojs { margin-top: 8px; }

/* варіант списку (радіо) */
.at-opt { position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px; cursor: pointer; font-size: 14px; color: #222; transition: background-color .2s; }
.at-opt:hover { background: var(--at-surface); }
.at-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.at-opt span { display: flex; align-items: center; gap: 12px; }
.at-opt span::before { content: ''; width: 16px; height: 16px; flex: 0 0 auto; border: 1px solid var(--at-line-strong); border-radius: 50%; transition: border-color .2s, box-shadow .2s; }
.at-opt input:checked + span { font-weight: 600; }
.at-opt input:checked + span::before { border-color: #000; box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 8px #000; }
.at-opt input:focus-visible + span { outline: 2px solid #222; outline-offset: 4px; }

/* квадратні кнопки розмірів (фільтр, товар, швидкий перегляд) */
.at-sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.at-size { position: relative; display: block; cursor: pointer; }
.at-size input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.at-size span { display: flex; align-items: center; justify-content: center; min-height: 40px; padding: 4px 8px; border: 1px solid var(--at-line); background: #fff;
  font-size: 13px; font-weight: 500; color: #222; text-align: center; transition: border-color .2s, background-color .2s, color .2s, transform .2s var(--at-ease); }
.at-size:hover span { border-color: #222; }
.at-size input:checked + span { background: #000; border-color: #000; color: #fff; font-weight: 600; }
.at-size input:focus-visible + span { outline: 2px solid #222; outline-offset: 2px; }
.at-size input:disabled + span { color: var(--at-line-strong); background: repeating-linear-gradient(135deg, #fff 0 6px, var(--at-surface) 6px 7px); cursor: not-allowed; }
.at-size:active span { transform: scale(.96); }

/* ціна від–до */
.at-price-range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.at-price-range .at-field { margin: 0; }
.at .at-price-range input { min-height: 44px; padding: 10px 12px; font-size: 14px; }

/* перемикач вигляду сітки */
.at-view { display: inline-flex; align-items: center; gap: 4px; }
.at-view__label { font-size: 12px; color: var(--at-muted); margin-right: 4px; }
.at-view__btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; font-size: 13px; font-weight: 600; color: var(--at-muted); border-bottom: 2px solid transparent; transition: color .2s, border-color .2s; }
.at-view__btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.at-view__btn:hover, .at-view__btn.is-active { color: #000; }
.at-view__btn.is-active { border-bottom-color: #000; }
@media (max-width: 767.98px) { .at-view__btn--lg { display: none; } .at-view__btn { width: 40px; height: 40px; border-bottom-width: 0; } .at-view__btn.is-active { background: var(--at-surface); } }
@media (min-width: 768px) { .at-view__btn--sm { display: none; } }

/* активні фільтри */
.at-active { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 8px; margin: -4px 0 24px; }
.at-active__reset { margin-left: 8px; font-size: 13px; }

/* сітка каталогу */
.at-listing__grid { transition: opacity .25s; }
.at-listing__grid.is-switching { opacity: 0; }
@media (min-width: 768px) and (max-width: 1023.98px) { .at-grid[data-view="4"] { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 768px) { .at-grid[data-view="2"] { gap: 40px 16px; } }

/* порожній стан */
.at-listing__empty { padding: 64px 16px 80px; border-top: 1px solid var(--at-line); }
.at-empty__art { width: 120px !important; height: 120px !important; margin: 0 auto 24px !important; stroke: #222 !important; stroke-width: 1.5 !important; fill: none; }
.at-empty__art .is-soft { stroke: var(--at-line-strong); }
.at .at-empty h2 { font-size: 22px; }
.at-empty p { max-width: 400px; margin: 0 auto 24px; }
.at-empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

/* панель «Всі фільтри» */
.at-filters__title { font-size: 16px !important; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.at-filters .at-drawer__body { padding-bottom: 8px; }
.at-filters__group { padding: 0 0 16px; }
.at-filters__group .at-opt { padding-left: 0; }
.at-filters__group .at-opt:hover { background: none; }
.at-filters__cat { display: block; padding: 8px 0; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #222; }
.at-filters__cat--kid { padding: 6px 0 6px 16px; font-size: 14px; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--at-muted); }
.at-filters__cat.is-active { color: #000; text-decoration: underline; text-underline-offset: 4px; }
.at-filters__foot { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.at-filters__foot .at-btn { padding-left: 16px; padding-right: 16px; }

/* ── картка: уточнення (ядро — atelier.css) ────────────────────────────────────────────────────── */
.at-card__media { background: linear-gradient(100deg, var(--at-surface) 30%, #fbfbfb 50%, var(--at-surface) 70%); background-size: 300% 100%; animation: at-shimmer 1.6s linear 3; }
.at-card__tilt { display: block; }
.at-card__ph { display: flex; align-items: center; justify-content: center; background: var(--at-surface); }
.at-card__ph svg { width: 48px; height: 48px; fill: none; stroke: var(--at-line-strong); stroke-width: 1.4; stroke-linejoin: round; }
.at-badge--soft { background: rgba(255,255,255,.94); color: #222; font-weight: 600; }
.at-card__badges { max-width: calc(100% - 64px); }
.at-card__badges .at-badge { white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 767.98px) { .at-card__badges .at-badge { font-size: 10px; padding: 3px 6px; letter-spacing: .02em; } }
.at-card.is-soldout .at-card__img { opacity: .62; }
.at-card.is-soldout:hover .at-card__img:not(.at-card__img--alt) { opacity: .62; }
.at-card__body { gap: 4px; padding-right: 2px; }
.at-card__body .at-price { margin-top: 2px; }
.at-card__cta { margin-top: 12px; width: 100%; }
.at-card__fav:focus-visible, .at-card__quick:focus-visible { outline: 2px solid #222; outline-offset: 2px; opacity: 1; transform: none; }
/* 3D-нахил: нахиляється вся «площина» фото разом з рамкою (тінь глибини видно), кнопки лишаються над нею (лише миша) */
@media (hover: hover) and (pointer: fine) {
  .at-card__media { overflow: visible; transform-style: flat; }
  .at-card__tilt { overflow: hidden; background: var(--at-surface); }
}
/* друге фото: м'яке «перегортання» (лише миша) */
@media (hover: hover) and (pointer: fine) {
  .at-card__img--alt { transform: perspective(900px) rotateY(-10deg) scale(1.04); transform-origin: 0 50%; }
  .at-card:hover .at-card__img--alt { transform: none; }
}
@media (hover: none) { .at-card__img--alt { display: none; } }

/* ── швидкий перегляд (вміст #atQuick) ─────────────────────────────────────────────────────────── */
.at-qv { container-type: inline-size; padding: 16px 0 8px; }
.at-qv__in, .at-qv__info { display: flex; flex-direction: column; gap: 16px; }
@container (min-width: 480px) {
  /* широка панель: фото стовпчиком зліва (гортаються разом з панеллю), інформація липне справа */
  .at-qv__in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .at .at-qv__gallery { display: flex; flex-direction: column; gap: 8px; overflow: visible; margin: 0; padding: 0; }
  .at-qv__info { position: sticky; top: 16px; }
}
.at-qv__gallery { display: grid; grid-auto-flow: column; grid-auto-columns: 72%; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin: 0 calc(var(--at-gutter) * -1); padding: 0 var(--at-gutter); overscroll-behavior-x: contain; }
.at-qv__gallery::-webkit-scrollbar { display: none; }
.at-qv__gallery.is-single { grid-auto-columns: 100%; }
.at-qv__slide { position: relative; aspect-ratio: 3 / 4; overflow: hidden; background: var(--at-surface); scroll-snap-align: start; }
.at-qv__slide > img, .at-qv__slide > picture > img, .at-qv__slide > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.at-qv__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.at .at-qv__name { font-size: 18px; font-weight: 600; line-height: 1.3; }
.at-qv__cat { display: block; margin-bottom: 4px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--at-muted); }
.at-qv__fav { flex: 0 0 auto; }
.at-qv .at-price { font-size: 16px; }
.at .at-qv__price { margin: 0; }
.at .at-qv__price .at-badge { align-self: center; }
.at .at-qv__desc { margin: 0; font-size: 13px; line-height: 1.6; color: var(--at-muted); }
.at-qv__actions { margin-top: 16px; }
.at-qv__label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #222; }
.at-qv__label b { font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--at-muted); }
.at-qv__note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--at-muted); margin: 0; }
.at-qv__note svg, .at-pd-lines svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: #222; stroke-width: 1.5; }
.at-qv__actions { display: grid; grid-template-columns: 1fr; gap: 8px; }
.at-qv__more { justify-self: center; font-size: 13px; }

/* квадратна кнопка-сердце (товар, швидкий перегляд) */
.at-heart-btn { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border: 1px solid #222; background: #fff; color: #222; cursor: pointer; transition: background-color .2s, transform .3s var(--at-ease-spring); }
.at-heart-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.5; transition: transform .3s var(--at-ease-spring), fill .2s; }
.at-heart-btn:hover { background: var(--at-surface); }
.at-heart-btn:hover svg { transform: scale(1.1); }
.at-heart-btn.is-active svg { fill: #000; }
.at-heart-btn.is-pop { animation: at-heart .6s var(--at-ease-spring); }
.at-heart-btn--float { position: absolute; z-index: 3; top: 12px; right: 12px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255,255,255,.88); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }

/* помилка «оберіть розмір» */
.at-size-error { display: none; margin: 8px 0 0; font-size: 12px; font-weight: 600; color: var(--at-sale); }
.is-size-missing .at-size-error { display: block; }
.is-size-missing .at-sizes { animation: at-shake .45s var(--at-ease); }
.is-size-missing .at-size span { border-color: var(--at-sale); }
@keyframes at-shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
.at-btn.is-loading { pointer-events: none; }
.at-btn.is-loading::before { content: ''; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: at-spin .7s linear infinite; }
@keyframes at-spin { to { transform: rotate(360deg); } }

/* ── обране ────────────────────────────────────────────────────────────────────────────────────── */
.at-favs { padding-top: 8px; padding-bottom: 72px; }
.at-favs__head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; padding: 8px 0 24px; border-bottom: 1px solid var(--at-line); margin-bottom: 24px; }
.at .at-favs__title { font-size: clamp(24px, 2.6vw, 32px); font-weight: 600; letter-spacing: -.01em; }
.at-favs__count { font-size: 13px; color: var(--at-muted); }
.at-favs .at-card { transition: opacity .35s var(--at-ease), transform .35s var(--at-ease); }
.at-favs .at-card.is-removing { opacity: 0; transform: scale(.94); }
.at-favs__empty { max-width: 480px; margin: 0 auto; padding: 48px 0 32px; text-align: center; }
.at-favs__art { width: 168px; height: 168px; margin: 0 auto 24px; display: block; }
.at-favs__art .ln { fill: none; stroke: #222; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.at-favs__art .soft { fill: var(--at-surface); }
.at-favs__art .heart { fill: var(--at-promo-bg); stroke: #222; stroke-width: 1.5; transform-origin: 84px 98px; animation: at-float 4s var(--at-ease) infinite; }
@keyframes at-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.at .at-favs__empty h2 { font-size: 22px; margin-bottom: 8px; }
.at-favs__empty p { color: var(--at-muted); margin: 0 auto 24px; }
.at-favs__empty .at-btn { min-width: 240px; }

@media (prefers-reduced-motion: reduce) {
  .at-card__media { animation: none; }
  .at-card__img--alt { transform: none !important; }
  .at-favs__art .heart { animation: none; }
  .at-dd__panel { animation: none; }
}
