/* ==========================================================================
   OSTOV — layout of the plugin blocks (assets/css/blocks.css).

   This file carries the grid only: containers, columns, gaps and the
   catalogue rhythm. The visual layer (colour, type, hairlines, states) lives
   in assets/ostov-core.css, and the approved Stage 1.5 stylesheet already
   styles every prototype twin (.shell, .rail, .plates, .plate, .gallery,
   .toolbar, .buy, .spec, .buybar, .drawing).

   The vocabulary is the prototype one: the same class names mean the same
   grid in both stylesheets, so the two never argue.

   The catalogue grid
     A 12-column grid inside one container: max width 1560px, page padding
     72px (28px under 1080px), column gap 28px. The plate rhythm is assigned
     by index — 7 columns, then 5 and tall, then triples, then a full-bleed
     12 — so the page has a cadence instead of a scatter. Below 1080px the
     facet rail leaves the flow (the filters move into the bottom sheet),
     below 620px every plate spans the full width.
   ========================================================================== */

/* ---- container ----------------------------------------------------------- */

.ostov-shell {
  max-width:var(--max-width, 1560px);
  margin:0 auto;
  padding:0 var(--page-pad, 72px);
  display:grid;
  grid-template-columns:260px minmax(0,1fr);
  gap:56px;
  align-items:start;
}

.ostov-shell--wide {
  grid-template-columns:minmax(0,1fr);
}

.ostov-shell__rail {
  position:sticky;
  top:88px;
  min-width:0;
}

.ostov-shell__main {
  min-width:0;
}

.ostov-page {
  max-width:var(--max-width, 1560px);
  margin:0 auto;
  padding:0 var(--page-pad, 72px);
}

/* ---- catalogue grid ------------------------------------------------------ */

.ostov-plates {
  display:grid;
  grid-template-columns:repeat(12, minmax(0,1fr));
  gap:56px var(--gap, 28px);
  padding:44px 0 20px;
}

.ostov-plates > .ostov-plate {
  grid-column:span 4;
  min-width:0;
}

/* The rhythm is read from the order of the plates, never from randomness. */
.ostov-plates > .ostov-plate:nth-child(9n+1) {
  grid-column:span 7;
}

.ostov-plates > .ostov-plate:nth-child(9n+2) {
  grid-column:span 5;
}

.ostov-plates > .ostov-plate:nth-child(9n+9) {
  grid-column:span 12;
}

.ostov-plates > .ostov-plate--wide {
  grid-column:span 7;
}

.ostov-plates > .ostov-plate--tall {
  grid-column:span 5;
}

.ostov-plates > .ostov-plate--half {
  grid-column:span 6;
}

.ostov-plates > .ostov-plate--full {
  grid-column:span 12;
}

/* ---- plate internals ----------------------------------------------------- */

.ostov-plate__row {
  display:flex;
  align-items:center;
  gap:12px;
  margin-top:9px;
}

.ostov-plate__row .ostov-plate__dims {
  margin-left:auto;
}

/* ---- facet rail ---------------------------------------------------------- */

.ostov-filters__group {
  border-top:1px solid var(--rule);
}

.ostov-filters__group:last-of-type {
  border-bottom:1px solid var(--rule);
}

.ostov-filters__group-title {
  font-size:13px;
  font-weight:600;
  margin-bottom:12px;
}

.ostov-filters__head {
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  font-size:13px;
  font-weight:600;
  margin-bottom:12px;
}

.ostov-filters__opt {
  display:flex;
  align-items:center;
  gap:10px;
  padding:6px 0;
  font-size:14px;
}

.ostov-filters__count {
  margin-left:auto;
}

.ostov-filters__price {
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.ostov-filters__note {
  max-width:66ch;
}

/* ---- toolbar ------------------------------------------------------------- */

.ostov-toolbar {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  flex-wrap:wrap;
  padding:22px 0;
  border-bottom:1px solid var(--ink);
}

.ostov-toolbar__form {
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}

/* ---- conditions strip ---------------------------------------------------- */

.ostov-conditions {
  display:flex;
  flex-wrap:wrap;
  gap:6px 28px;
  align-items:baseline;
  margin:26px 0 0;
  padding:14px 0;
  border-top:1px solid var(--rule);
  border-bottom:1px solid var(--rule);
  color:var(--ink-2);
  font-size:13px;
  line-height:1.45;
}

.ostov-conditions__item { margin:0; }
.ostov-conditions__item b { color:var(--ink); font-weight:600; }

.ostov-wishlist-toggle {
  display:inline-flex;
  align-items:center;
  min-height:40px;
  padding:6px 0;
  border:0;
  border-radius:var(--radius);
  color:var(--ink-2);
  font-size:13px;
  text-decoration:underline;
  text-decoration-color:var(--rule);
  text-underline-offset:3px;
  cursor:pointer;
}

.ostov-wishlist-toggle:hover,
.ostov-wishlist-toggle[aria-pressed="true"] { color:var(--clay); text-decoration-color:currentColor; }

.ostov-wishlist-toggle:focus-visible {
  outline:2px solid var(--ink);
  outline-offset:3px;
}

.ostov-wishlist-toggle[aria-disabled="true"] { opacity:.65; cursor:wait; }

.ostov-buy-panel__wishlist-toggle { margin-top:8px; }

.ostov-plate__wishlist-toggle { min-height:34px; margin-top:2px; }

@media (max-width:620px) {
  .ostov-conditions { display:grid; gap:7px; margin-top:20px; padding:13px 0; }
  .ostov-wishlist-toggle { min-height:44px; }
}

/* ---- buy panel ----------------------------------------------------------- */

.ostov-buy-panel__rows {
  margin:20px 0 0;
}

.ostov-buy-panel__row {
  display:flex;
  justify-content:space-between;
  gap:16px;
  align-items:baseline;
  padding:9px 0;
  border-bottom:1px solid var(--rule-2);
  font-size:14px;
}

.ostov-buy-panel__option {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  margin:0 0 10px;
}

.ostov-buy-panel__qty {
  display:flex;
  align-items:center;
  gap:14px;
}

.ostov-buy-panel__spec {
  margin:0;
}

/* ---- configurator -------------------------------------------------------- */

.ostov-configurator {
  min-width:0;
}

.ostov-configurator__form {
  display:grid;
  gap:16px;
  justify-items:start;
}

/* Two columns only when there is a choice to make on the left. */
.ostov-configurator__form:has(.ostov-configurator__options) {
  grid-template-columns:minmax(0,320px) minmax(0,1fr);
  column-gap:var(--gap, 28px);
  align-items:start;
}

.ostov-configurator__form:has(.ostov-configurator__options) > .ostov-configurator__options {
  grid-column:1;
  grid-row:1;
}

.ostov-configurator__form:has(.ostov-configurator__options) > .ostov-configurator__summary {
  grid-column:2;
  grid-row:1 / span 3;
}

.ostov-configurator__form:has(.ostov-configurator__options) > .ostov-configurator__quantity {
  grid-column:1;
  grid-row:2;
}

.ostov-configurator__form:has(.ostov-configurator__options) > .ostov-configurator__add {
  grid-column:1;
  grid-row:3;
}

.ostov-configurator__option {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  margin:0 0 10px;
}

.ostov-configurator__summary {
  min-width:0;
}

.ostov-configurator__drawing {
  margin-top:16px;
}

/* ---- wishlist ------------------------------------------------------------ */

.ostov-wishlist__list {
  margin:0;
  padding:0;
  list-style:none;
}

.ostov-wishlist__item {
  display:grid;
  grid-template-columns:96px minmax(0,1fr) auto;
  gap:18px;
  align-items:center;
  padding:16px 0;
  border-bottom:1px solid var(--rule-2);
}

.ostov-wishlist__frame {
  display:block;
  aspect-ratio:1/1;
  overflow:hidden;
  border-radius:var(--radius);
  background:var(--sheet-2);
}

.ostov-wishlist__frame img {
  width:100%;
  height:100%;
  object-fit:cover;
}

.ostov-wishlist__body {
  min-width:0;
}

.ostov-wishlist__dims,
.ostov-wishlist__price,
.ostov-wishlist__lead {
  margin:2px 0 0;
}

/* ---- catalogue ----------------------------------------------------------- */
/* The block prints the approved grid (.plates) and the rhythm classes of the
   prototype; what is left for this file is the frame of the block itself. */

.ostov-catalogue {
  min-width:0;
}

.ostov-catalogue__empty {
  padding:56px 0;
  border-top:1px solid var(--ink);
}

.ostov-catalogue__empty h2 {
  margin:0 0 10px;
  font-size:clamp(24px, 2.7vw, 42px);
  font-weight:500;
  letter-spacing:-.022em;
}

.ostov-catalogue__empty p {
  max-width:66ch;
  color:var(--ink-2);
}

.ostov-catalogue__pagination {
  margin-top:44px;
}

.pagination__item {
  display:inline-block;
  margin:0 6px 6px 0;
}

.pagination__item .page-numbers {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:40px;
  height:40px;
  padding:0 12px;
  border:1px solid var(--rule);
  border-radius:var(--radius);
  background:var(--paper);
  color:var(--ink);
  font-size:14px;
  font-variant-numeric:tabular-nums;
}

.pagination__item .page-numbers:hover {
  border-color:var(--ink-3);
}

.pagination__item .page-numbers.current {
  border-color:var(--ink);
  background:var(--ink);
  color:var(--sheet);
}

/* ---- gallery ------------------------------------------------------------- */

.ostov-gallery {
  display:grid;
  grid-template-columns:84px minmax(0,1fr);
  gap:16px;
}

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

.ostov-gallery__thumb {
  padding:0;
  border:1px solid var(--rule);
  border-radius:var(--radius);
  overflow:hidden;
  background:var(--sheet-2);
  cursor:pointer;
  aspect-ratio:1/1;
}

.ostov-gallery__thumb[aria-current="true"] {
  border-color:var(--ink);
}

.ostov-gallery__thumb img {
  width:100%;
  height:100%;
  object-fit:cover;
}

.ostov-gallery__stage {
  position:relative;
  overflow:hidden;
  background:var(--sheet-2);
  aspect-ratio:4/5;
}

.ostov-gallery__stage img {
  width:100%;
  height:100%;
  object-fit:cover;
}

.ostov-gallery__caption {
  margin-top:10px;
  font-size:12.5px;
  color:var(--ink-2);
  max-width:66ch;
}

/* ---- mobile filter sheet ------------------------------------------------ */
/* The sheet is a native dialog: the browser gives the backdrop and Escape. */

.ostov-filter-sheet {
  border:0;
  padding:0;
  max-width:none;
  max-height:88svh;
  width:100%;
  background:var(--sheet);
  color:var(--ink);
}

.ostov-filter-sheet::backdrop {
  background:rgba(25,23,18,.45);
}

.ostov-filter-sheet__head {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  padding:18px 20px;
  border-bottom:1px solid var(--rule);
}

.ostov-filter-sheet__body {
  padding:0 20px 18px;
  overflow-y:auto;
  max-height:62svh;
}

.ostov-filter-sheet__foot {
  padding:14px 20px calc(14px + env(safe-area-inset-bottom));
  border-top:1px solid var(--ink);
  display:flex;
  gap:12px;
  align-items:center;
}

.ostov-filter-sheet__foot .btn {
  flex:1;
}

.ostov-filter-sheet__close {
  font-family:inherit;
  font-size:13px;
  font-weight:600;
  letter-spacing:.1em;
  text-transform:uppercase;
  color:var(--ink-2);
  background:none;
  border:0;
  padding:0;
  cursor:pointer;
}

.ostov-filter-sheet__close:hover {
  color:var(--ink);
}

.ostov-filters-open {
  display:none;
}

/* ---- applied filter chips ------------------------------------------------ */
/* A chip is a label, so it is the one place where a pill is correct. The
   cross of the remove control is drawn with two hairlines, not with a
   symbol. */

.ostov-chips {
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
  padding:14px 0 0;
}

.ostov-chips__item {
  display:inline-flex;
  align-items:center;
  gap:8px;
  font-size:13px;
  padding:5px 8px 5px 11px;
  border:1px solid var(--rule);
  border-radius:999px;
  background:var(--paper);
}

.ostov-chips__remove {
  position:relative;
  width:14px;
  height:14px;
  padding:0;
  border:0;
  background:none;
  cursor:pointer;
}

.ostov-chips__remove::before,
.ostov-chips__remove::after {
  content:'';
  position:absolute;
  left:2px;
  top:6px;
  width:10px;
  height:1px;
  background:var(--ink-2);
}

.ostov-chips__remove::before {
  transform:rotate(45deg);
}

.ostov-chips__remove::after {
  transform:rotate(-45deg);
}

.ostov-chips__remove:hover::before,
.ostov-chips__remove:hover::after {
  background:var(--clay);
}

.ostov-chips__reset {
  font-family:inherit;
  font-size:11px;
  font-weight:600;
  letter-spacing:.1em;
  text-transform:uppercase;
  color:var(--ink-2);
  background:none;
  border:0;
  padding:0;
  cursor:pointer;
}

.ostov-chips__reset:hover {
  color:var(--ink);
}

/* The sheet enters once, and only when the visitor allows motion. */
.ostov-filter-sheet[data-ostov-motion="full"] {
  animation:ostov-sheet-in .24s ease both;
}

@keyframes ostov-sheet-in {
  from { opacity:.4; transform:translateY(16px); }
  to   { opacity:1;  transform:none; }
}

@media (prefers-reduced-motion: reduce){
  .ostov-filter-sheet[data-ostov-motion="full"] {
    animation:none;
  }
}

/* ---- responsive ---------------------------------------------------------- */

@media (max-width: 1080px){
  .ostov-shell,
  .ostov-page {
    padding-left:var(--page-pad-compact, 28px);
    padding-right:var(--page-pad-compact, 28px);
  }

  .ostov-shell {
    grid-template-columns:minmax(0,1fr);
    gap:0;
  }

  /* The rail leaves the flow only when the sheet can take it over. */
  .ostov-shell:has(.ostov-filter-sheet) .ostov-shell__rail {
    display:none;
  }

  .ostov-plates {
    gap:34px 16px;
  }

  .ostov-plates > .ostov-plate,
  .ostov-plates > .ostov-plate:nth-child(9n+1),
  .ostov-plates > .ostov-plate:nth-child(9n+2),
  .ostov-plates > .ostov-plate:nth-child(9n+9),
  .ostov-plates > .ostov-plate--wide,
  .ostov-plates > .ostov-plate--tall,
  .ostov-plates > .ostov-plate--half {
    grid-column:span 6;
  }

  .ostov-filters-open {
    display:inline-flex;
    align-items:center;
    gap:8px;
    font-family:inherit;
    font-size:14px;
    font-weight:600;
    padding:10px 16px;
    border:1px solid var(--ink);
    border-radius:var(--radius);
    background:var(--sheet);
    cursor:pointer;
  }
}

@media (max-width: 760px){
  .ostov-configurator__form:has(.ostov-configurator__options) {
    grid-template-columns:minmax(0,1fr);
  }

  .ostov-configurator__form:has(.ostov-configurator__options) > .ostov-configurator__summary {
    grid-column:1;
    grid-row:auto;
  }

  .ostov-configurator__form:has(.ostov-configurator__options) > .ostov-configurator__quantity,
  .ostov-configurator__form:has(.ostov-configurator__options) > .ostov-configurator__add {
    grid-column:1;
    grid-row:auto;
  }

  .ostov-gallery {
    grid-template-columns:minmax(0,1fr);
  }

  .ostov-gallery__thumbs {
    order:2;
    flex-direction:row;
    overflow-x:auto;
  }

  .ostov-gallery__thumb {
    width:68px;
    flex:0 0 auto;
  }

  .ostov-wishlist__item {
    grid-template-columns:72px minmax(0,1fr);
    row-gap:10px;
  }

  .ostov-wishlist__remove {
    grid-column:2;
    justify-self:start;
  }
}

@media (max-width: 620px){
  .ostov-plates > .ostov-plate,
  .ostov-plates > .ostov-plate:nth-child(9n+1),
  .ostov-plates > .ostov-plate:nth-child(9n+2),
  .ostov-plates > .ostov-plate:nth-child(9n+9),
  .ostov-plates > .ostov-plate--wide,
  .ostov-plates > .ostov-plate--tall,
  .ostov-plates > .ostov-plate--half,
  .ostov-plates > .ostov-plate--full {
    grid-column:span 12;
  }
}
