/* shelf.css — токены и набор лиц и плиток четырёх идей полки
   (docs/studio-features/22-shared-foundation.md §9.1, §9.2, §9.7; разметка — shelf_ui.js).

   Раскладки — одни на все идеи: телефон < 768 px, планшет 768–1099, компьютер ≥ 1100
   (в JS — shelfUi.BP). Касание — не меньше 44 × 44 везде; на странице без
   горизонтальной прокрутки, поля по бокам 16 px. Только свои классы (.shelf-*),
   свои переменные (--shelf-*) и слот шапки древа: до первой идеи ничего на экране не
   меняется (tests/test_studio_js_seams.py). */

:root {
    --shelf-tap: 44px;
    --shelf-gutter: 16px;
    --shelf-tile-grid: 160px;           /* компьютер: сетка */
    --shelf-tile-row: 148px;            /* компьютер: полки */
    --shelf-tile-tablet: 140px;
    --shelf-tile-min: 100px;            /* телефон: 3 колонки, не уже */
    --shelf-sheet-desktop: 420px;       /* общая карточка: правая панель */
    --shelf-sheet-tablet: 380px;
    --shelf-sheet-phone: 88vh;          /* нижний лист, не выше */
    --shelf-missing-opacity: 0.55;      /* недостающее — бледная обложка */
    --shelf-missing-saturate: 0.45;
}

/* Слот шапки древа (#tree-head-extras, tree_head.js): кнопки идей рядом с видом. */
.tree-head-extras:not([hidden]) { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ── Лица ─────────────────────────────────────────────────────────────── */
.shelf-face {
    display: inline-flex; align-items: center; gap: 8px; min-width: var(--shelf-tap); min-height: var(--shelf-tap);
    padding: 4px 8px 4px 4px; border: 0; border-radius: var(--radius-pill, 99px); background: transparent;
    color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.shelf-face:hover { background: var(--bg-card-hover, rgba(255, 255, 255, 0.04)); }
.shelf-face:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.shelf-face .shelf-av { flex: 0 0 auto; }
.shelf-av.shelf-av-28 { width: 28px; height: 28px; font-size: 12px; }
.shelf-av.shelf-av-36 { width: 36px; height: 36px; font-size: 14px; }
.shelf-av.shelf-av-40 { width: 40px; height: 40px; font-size: 15px; }
.shelf-av.shelf-av-48 { width: 48px; height: 48px; font-size: 18px; }
.shelf-av.shelf-av-96 { width: 96px; height: 96px; font-size: 34px; }
.shelf-av.shelf-av-160 { width: 160px; height: 160px; font-size: 56px; }
.shelf-face-96, .shelf-face-160 { flex-direction: column; text-align: center; padding: 8px; border-radius: var(--radius, 10px); }
.shelf-face-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.shelf-face-name { color: var(--text-strong, var(--text)); overflow-wrap: anywhere; }
.shelf-face-role, .shelf-face-count { color: var(--text-dim); font-size: 12px; }
.shelf-src-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--text-dim); }
.shelf-src-dot.shelf-src-discogs { background: var(--warning, #f0b95e); }
.shelf-faces { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.shelf-faces-more {
    min-height: var(--shelf-tap); padding: 0 12px; border: 1px solid var(--border); border-radius: var(--radius-pill, 99px);
    background: transparent; color: var(--text-mid, var(--text)); font: inherit; cursor: pointer;
}

/* ── Плитки ───────────────────────────────────────────────────────────── */
.shelf-tile { position: relative; width: var(--shelf-tile-grid); min-width: 0; }
.shelf-tile-btn {
    display: flex; flex-direction: column; gap: 4px; width: 100%; min-height: var(--shelf-tap); padding: 0; border: 0;
    background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.shelf-tile-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: var(--radius-sm, 7px); }
.shelf-tile-cover {
    position: relative; display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 1;
    overflow: hidden; border-radius: var(--radius-sm, 7px); background: var(--bg-input);
}
.shelf-tile-ini { color: var(--text-dim); font-size: 32px; font-weight: 700; }
.shelf-tile-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.shelf-tile.is-missing .shelf-tile-img { opacity: var(--shelf-missing-opacity); filter: saturate(var(--shelf-missing-saturate)); }
.shelf-tile-title {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    color: var(--text-strong, var(--text)); font-size: 14px; line-height: 1.3;
}
.shelf-tile-sub, .shelf-tile-mark { color: var(--text-mid, var(--text)); font-size: 12px; }
.shelf-tile-reason { display: flex; gap: 6px; align-items: flex-start; color: var(--text-mid, var(--text)); font-size: 12px; }
.shelf-tile-why { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.shelf-badge {
    position: absolute; top: 6px; left: 6px; max-width: calc(100% - 12px); padding: 2px 6px; border-radius: var(--radius-pill, 99px);
    background: rgba(0, 0, 0, 0.72); color: #fff; font-size: 11px; line-height: 1.4; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis;
}
.shelf-source {
    position: absolute; right: 6px; bottom: 6px; padding: 1px 5px; border-radius: 4px;
    background: rgba(0, 0, 0, 0.72); color: #fff; font-size: 10px;
}
.shelf-tile-check {
    position: absolute; top: 0; right: 0; display: flex; align-items: center; justify-content: center;
    width: var(--shelf-tap); height: var(--shelf-tap); cursor: pointer;
}
.shelf-tile-check input { width: 20px; height: 20px; margin: 0; }
.shelf-sr {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
    white-space: nowrap;
}
.shelf-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--shelf-tile-grid), 1fr)); gap: 16px;
}
.shelf-grid > .shelf-tile { width: auto; }
.shelf-row { display: flex; gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 4px; }
.shelf-row > .shelf-tile { flex: 0 0 var(--shelf-tile-row); width: var(--shelf-tile-row); scroll-snap-align: start; }

/* Планшет 768–1099. */
@media (max-width: 1099px) {
    .shelf-tile { width: var(--shelf-tile-tablet); }
    .shelf-grid { grid-template-columns: repeat(auto-fill, minmax(var(--shelf-tile-tablet), 1fr)); }
    .shelf-row > .shelf-tile { flex-basis: var(--shelf-tile-tablet); width: var(--shelf-tile-tablet); }
}

/* Телефон < 768: 3 колонки по полям 16 px, лица — одной прокручиваемой строкой. */
@media (max-width: 767px) {
    .shelf-grid { grid-template-columns: repeat(3, minmax(var(--shelf-tile-min), 1fr)); gap: 8px; }
    .shelf-row > .shelf-tile {
        flex-basis: max(var(--shelf-tile-min), calc((100vw - 2 * var(--shelf-gutter) - 16px) / 3));
        width: max(var(--shelf-tile-min), calc((100vw - 2 * var(--shelf-gutter) - 16px) / 3));
    }
    .shelf-faces { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; }
    .shelf-faces > * { flex: 0 0 auto; scroll-snap-align: start; }
}

/* Библиотека: «Опознано в MusicBrainz» и список неопознанных (22 §9.6, shelf_lib.js). */
.shelf-lib-slot { margin: 4px 0 12px; }
.shelf-lib-line {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: var(--shelf-tap);
    color: var(--text-mid, var(--text-dim)); font-size: 14px;
}
.shelf-lib-more, .shelf-lib-link {
    min-height: var(--shelf-tap); padding: 0 4px; border: 0; background: transparent; color: var(--accent-text, var(--accent));
    font: inherit; text-align: left; cursor: pointer; overflow-wrap: anywhere;
}
.shelf-lib-more:hover, .shelf-lib-link:hover { text-decoration: underline; }
.shelf-lib-more:focus-visible, .shelf-lib-link:focus-visible, .shelf-lib-filter:focus-visible,
.shelf-lib-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm, 6px); }
.shelf-lib-sep { color: var(--text-faint, var(--text-dim)); }
.shelf-lib-list {
    margin-top: 8px; padding: 12px; border: 1px solid var(--border-soft, var(--border)); border-radius: var(--radius, 10px);
    background: var(--bg-card);
}
.shelf-lib-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.shelf-lib-title { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-strong, var(--text)); }
.shelf-lib-close {
    width: var(--shelf-tap); height: var(--shelf-tap); border: 0; background: transparent; color: var(--text-dim);
    font-size: 22px; line-height: 1; cursor: pointer;
}
.shelf-lib-filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.shelf-lib-filter {
    min-height: var(--shelf-tap); padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius-pill, 99px);
    background: transparent; color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.shelf-lib-filter.active { border-color: var(--accent); color: var(--accent-text, var(--accent)); background: var(--accent-wash, transparent); }
.shelf-lib-rows { list-style: none; margin: 0; padding: 0; }
.shelf-lib-row {
    display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 6px 0;
    border-top: 1px solid var(--border-soft, var(--border));
}
.shelf-lib-row:first-child { border-top: 0; }
.shelf-lib-cover { flex: 0 0 44px; width: 44px; height: 44px; border-radius: var(--radius-sm, 6px); object-fit: cover; background: var(--bg-elev); }
.shelf-lib-body { flex: 1 1 auto; min-width: 0; }
.shelf-lib-name { color: var(--text-strong, var(--text)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shelf-lib-why { color: var(--text-dim); font-size: 13px; line-height: 1.35; }
.shelf-lib-steps { color: var(--text-faint, var(--text-dim)); }
.shelf-lib-retry { flex: 0 0 auto; min-height: var(--shelf-tap); min-width: var(--shelf-tap); }
.shelf-lib-retry-ico { display: none; font-size: 18px; line-height: 1; }
.shelf-lib-empty { margin: 8px 0; color: var(--text-dim); }
.shelf-lib-next { margin-top: 8px; min-height: var(--shelf-tap); }
.shelf-lib-sk { height: 56px; background: var(--bg-elev); border-radius: var(--radius-sm, 6px); margin: 4px 0; }
.shelf-lib-album { margin-top: 8px; font-size: 14px; }
.shelf-lib-muted { color: var(--text-dim); font-size: 13px; padding: 4px; }
@media (max-width: 767px) {
    .shelf-lib-list { padding: 8px; }
    .shelf-lib-row { gap: 8px; }
    .shelf-lib-why {
        font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    }
    .shelf-lib-steps, .shelf-lib-sep, .shelf-lib-retry-txt { display: none; }
    .shelf-lib-retry-ico { display: inline; }
    .shelf-lib-retry { padding: 0; }
}
