/* BRAMA — «Наш простір»: фотогалерея приміщення + перегляд на весь екран */

.space-gallery {
  padding-bottom: 20px;
}

/* Вступ: заголовок ліворуч, текст і факти праворуч */
.sg-intro {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 56px;
  align-items: end;
  margin-bottom: 40px;
}

.sg-intro__title h2 {
  margin: 8px 0 0;
  font-size: clamp(1.9rem, 3.4vw, 2.8rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  max-width: 17ch;
}

.sg-intro__text p {
  margin: 0;
  color: var(--color-text);
  font-size: 1.05rem;
}

.sg-facts {
  list-style: none;
  padding: 0;
  margin: 22px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sg-facts li {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  padding: 7px 12px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-brown-dark);
  background: var(--color-card);
}

.sg-facts li:empty {
  display: none;
}

/* Мозаїка: велике фото бару, зала, три деталі */
.sg-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: 230px 230px 250px;
  grid-template-areas:
    "a a a a b b"
    "a a a a b b"
    "c c d d e e";
  gap: 14px;
}

.sg-tile {
  position: relative;
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--color-ink-soft);
  isolation: isolate;
}

.sg-tile--a { grid-area: a; }
.sg-tile--b { grid-area: b; }
.sg-tile--c { grid-area: c; }
.sg-tile--d { grid-area: d; }
.sg-tile--e { grid-area: e; }

/* Плиток стільки, скільки залів (js/space-gallery.js) */
.sg-tile[hidden] { display: none; }
.sg-grid { grid-auto-rows: 250px; }
.sg-tile--x { grid-column: span 2; }

.sg-grid[data-count="4"] {
  grid-template-areas:
    "a a a a b b"
    "a a a a b b"
    "c c c d d d";
}

.sg-grid[data-count="3"] {
  grid-template-rows: 240px 240px;
  grid-template-areas:
    "a a a a b b"
    "a a a a c c";
}

.sg-grid[data-count="2"] {
  grid-template-rows: 460px;
  grid-template-areas: "a a a b b b";
}

.sg-grid[data-count="1"] {
  grid-template-rows: 480px;
  grid-template-areas: "a a a a a a";
}

.sg-open {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
}

.sg-open:focus-visible {
  outline: 3px solid var(--color-brown);
  outline-offset: -3px;
}

.sg-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.9s var(--ease), filter 0.6s var(--ease);
}

/* Затемнення знизу — щоб підпис читався на будь-якому фото */
.sg-tile::after {
  content: "";
  position: absolute;
  inset: 45% 0 0;
  background: linear-gradient(to top, rgba(27, 22, 19, 0.72), rgba(27, 22, 19, 0));
  pointer-events: none;
  opacity: 0.85;
  transition: opacity 0.5s var(--ease);
}

.sg-tile figcaption {
  position: absolute;
  left: 18px;
  bottom: 14px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-on-dark);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1rem;
  pointer-events: none;
}

.sg-tile figcaption::before {
  content: "";
  width: 18px;
  height: 1px;
  background: currentColor;
  opacity: 0.7;
}

.sg-tile figcaption:empty {
  display: none;
}

@media (hover: hover) {
  .sg-tile:hover img {
    transform: scale(1.045);
  }

  .sg-tile:hover::after {
    opacity: 1;
  }
}

/* Підвал галереї: посилання на Instagram */
.sg-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--color-border);
}

.sg-foot p {
  margin: 0;
  color: var(--color-text-muted);
}

.sg-ig {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  border-radius: 999px;
  background: var(--color-ink);
  color: var(--color-on-dark);
  font-weight: 500;
  text-decoration: none;
  transition: background 0.3s var(--ease), transform 0.3s var(--ease);
}

.sg-ig:hover {
  background: var(--color-brown-dark);
  transform: translateY(-1px);
}

/* Планшет */
@media (max-width: 900px) {
  .sg-intro {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .sg-intro__title h2 {
    max-width: none;
  }

  .sg-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: 300px 220px 200px;
    grid-template-areas:
      "a a"
      "b c"
      "d e";
  }

  .sg-tile--x { grid-column: span 1; }
  .sg-grid { grid-auto-rows: 200px; }
  .sg-grid[data-count="4"] { grid-template-rows: 300px 220px; grid-template-areas: "a a" "b c" "d d"; grid-auto-rows: 200px; }
  .sg-grid[data-count="3"] { grid-template-rows: 300px 220px; grid-template-areas: "a a" "b c"; }
  .sg-grid[data-count="2"] { grid-template-rows: 300px; grid-template-areas: "a b"; }
  .sg-grid[data-count="1"] { grid-template-rows: 320px; grid-template-areas: "a a"; }
}

/* Телефон: гортання стрічкою */
@media (max-width: 620px) {
  .space-gallery {
    padding-bottom: 12px;
  }

  .sg-grid {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin: 0 -20px;
    padding: 0 20px 6px;
    scrollbar-width: none;
  }

  .sg-grid::-webkit-scrollbar {
    display: none;
  }

  .sg-tile {
    flex: 0 0 82%;
    height: 340px;
    scroll-snap-align: center;
  }

  .sg-foot {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Перегляд на весь екран ------------------------------------------------ */

.sg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-rows: 1fr auto;
  padding: 56px 72px 24px;
  background: rgba(18, 14, 12, 0.94);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.sg-lightbox.is-open {
  opacity: 1;
}

.sg-lightbox__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.sg-lightbox__stage img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 10px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  object-fit: contain;
  user-select: none;
}

.sg-lightbox__bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding-top: 18px;
  color: var(--color-on-dark);
  font-family: var(--font-display);
}

.sg-lightbox__count {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-on-dark-muted);
}

.sg-lightbox__count:empty {
  display: none;
}

/* «Забронювати цей зал» під фото */
.sg-lightbox__book {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: #f6efe4;
  color: #2a1d17;
  font: 600 0.9rem/1.2 var(--font-body, inherit);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.sg-lightbox__book:hover {
  background: #fff;
}

.sg-lightbox__book:hover svg {
  transform: translateX(2px);
}

.sg-lightbox__book svg {
  transition: transform 0.2s;
}

.sg-lightbox__book:focus-visible {
  outline: 2px solid #f6efe4;
  outline-offset: 3px;
}

.sg-lightbox__book[hidden] {
  display: none;
}

/* Фото залу в розкладі відкривається на весь екран */
.bkg-room__media.is-zoomable {
  cursor: zoom-in;
}

.sg-lb-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(246, 239, 228, 0.22);
  border-radius: 50%;
  background: rgba(246, 239, 228, 0.06);
  color: var(--color-on-dark);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s;
}

.sg-lb-btn:hover {
  background: rgba(246, 239, 228, 0.16);
}

.sg-lb-close { top: 16px; right: 16px; }
.sg-lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.sg-lb-next { right: 14px; top: 50%; transform: translateY(-50%); }

@media (max-width: 620px) {
  .sg-lightbox {
    padding: 64px 12px 20px;
  }

  .sg-lightbox__bar {
    flex-wrap: wrap;
    gap: 8px 12px;
    padding-bottom: 60px;
  }

  .sg-lightbox__book {
    margin-left: 0;
  }

  .sg-lb-prev,
  .sg-lb-next {
    top: auto;
    bottom: 12px;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sg-tile img,
  .sg-lightbox {
    transition: none;
  }
}

/* Ціни та абонементи ------------------------------------------------------ */

.space-prices {
  padding: 60px 0 10px;
}

.sp-head {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: end;
  margin-bottom: 28px;
}

.sp-head h2 {
  margin: 8px 0 0;
  font-size: clamp(1.9rem, 3.4vw, 2.6rem);
  letter-spacing: -0.02em;
}

.sp-head__note {
  margin: 0;
  color: var(--color-text-muted);
}

.sp-grid {
  display: grid;
  grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
  gap: 16px;
}

.sp-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 22px 22px 20px;
  border: 1px solid var(--color-border);
  border-radius: calc(var(--radius) + 2px);
  background: linear-gradient(180deg, #fffdf9, var(--color-card));
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.sp-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 24px 50px -30px rgba(71, 48, 38, 0.45);
}

.sp-card__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.sp-card__idx {
  padding: 1px 7px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--color-text-muted);
}

.sp-card__badge {
  padding: 3px 10px;
  border-radius: 999px;
  background: #7fb572;
  color: #13210f;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sp-card h3 {
  margin: 0;
  font-size: 1.15rem;
}

.sp-card__price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  margin: 14px 0 6px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--color-border);
}

.sp-card__price strong {
  font-family: var(--font-display);
  font-size: 2.3rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--color-brown-dark);
}

.sp-card__price.is-text strong {
  font-size: 1.3rem;
}

.sp-card__from,
.sp-card__unit {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.sp-card__note {
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--color-text);
}

.sp-card ul {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

.sp-card li {
  position: relative;
  padding-left: 20px;
}

.sp-card li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.55em;
  width: 8px;
  height: 5px;
  border-left: 1.5px solid #6f9a64;
  border-bottom: 1.5px solid #6f9a64;
  transform: rotate(-45deg);
}

.sp-card__cta {
  margin-top: auto;
  padding-top: 20px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-brown);
  text-decoration: none;
}

.sp-card__cta:hover {
  color: var(--color-brown-dark);
}

/* Виділений тариф (абонемент) — темна картка з цеглою */
.sp-card.is-featured {
  border-color: var(--color-border-dark);
  background:
    var(--grid-line) 0 0 / var(--grid-size),
    radial-gradient(120% 120% at 100% 0%, rgba(104, 72, 62, 0.55), transparent 60%),
    var(--color-ink);
  color: var(--color-on-dark);
  box-shadow: 0 30px 60px -35px rgba(27, 22, 19, 0.8);
}

.sp-card.is-featured h3,
.sp-card.is-featured .sp-card__price strong {
  color: var(--color-on-dark);
}

.sp-card.is-featured .sp-card__idx {
  border-color: rgba(246, 239, 228, 0.25);
  color: var(--color-on-dark-muted);
}

.sp-card.is-featured .sp-card__price {
  border-color: rgba(246, 239, 228, 0.18);
}

.sp-card.is-featured .sp-card__from,
.sp-card.is-featured .sp-card__unit,
.sp-card.is-featured ul {
  color: var(--color-on-dark-muted);
}

.sp-card.is-featured .sp-card__note {
  color: rgba(246, 239, 228, 0.9);
}

.sp-card.is-featured li::before {
  border-color: #a6d49a;
}

.sp-card.is-featured .sp-card__cta {
  color: var(--color-on-dark);
}

/* Ціни по залах */
.sp-rooms {
  margin-top: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-card);
  overflow: hidden;
}

.sp-rooms__head,
.sp-rooms li {
  display: grid;
  grid-template-columns: 1fr 120px 120px;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
}

.sp-rooms__head {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: var(--color-cream);
}

.sp-rooms__cols {
  display: contents;
}

.sp-rooms ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sp-rooms li {
  border-top: 1px solid var(--color-border);
  font-size: 0.92rem;
}

.sp-rooms li span:not(.sp-rooms__name) {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-brown-dark);
}

@media (max-width: 900px) {
  .sp-head {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .sp-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .sp-rooms__head,
  .sp-rooms li {
    grid-template-columns: 1fr 80px 80px;
    padding: 12px 14px;
  }
}

/* Відео залу ---------------------------------------------------------- */
.sg-open { position: relative; }
.sg-play {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px 7px 9px;
  border-radius: 999px;
  background: rgba(18, 14, 12, 0.72);
  color: #f6efe4;
  font: 600 0.8rem/1 var(--font-body);
  backdrop-filter: blur(4px);
  transition: background 0.2s, transform 0.2s;
}
.sg-tile:hover .sg-play { background: #f6efe4; color: #2a1d17; transform: scale(1.04); }

.sg-lightbox__stage { position: relative; }
.sg-lightbox__stage img[hidden] { display: none; }
.sg-lightbox__video {
  width: min(100%, calc((100vh - 170px) * 16 / 9));
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.sg-lightbox__video.is-vertical {
  width: min(100%, calc((100vh - 170px) * 9 / 16));
  aspect-ratio: 9 / 16;
}

/* Розмір відео — від реального місця в перегляді (container query):
   ціле відео завжди вміщається, нічого не обрізається на будь-якому екрані */
.sg-lightbox__stage {
  container-type: size;
}

@supports (width: 1cqw) {
  .sg-lightbox__video {
    width: min(100cqw, 100cqh * 16 / 9);
  }

  .sg-lightbox__video.is-vertical {
    width: min(100cqw, 100cqh * 9 / 16);
  }
}

/* Повний екран (кнопка ⤢) */
.sg-lightbox__video:fullscreen {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
}

.sg-lightbox__video:-webkit-full-screen {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.sg-lb-full { top: 16px; left: 16px; }
.sg-lb-btn[hidden] { display: none; }
.sg-lightbox__video iframe { display: block; width: 100%; height: 100%; border: 0; }

/* Розклад: фото/обкладинка залу з відео */
.bkg-room__media.has-video { position: relative; }
.bkg-room__play {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  border-radius: 50%;
  background: rgba(18, 14, 12, 0.7);
  color: #f6efe4;
  font-size: 0.9rem;
  pointer-events: none;
}

/* Низький екран (телефон горизонтально) — менше відступів, більше відео */
@media (max-height: 520px) {
  .sg-lightbox {
    padding: 10px 72px 8px;
  }

  .sg-lightbox__bar {
    padding-top: 8px;
    padding-bottom: 0;
    flex-wrap: nowrap;
  }

  .sg-lb-prev,
  .sg-lb-next {
    top: 50%;
    bottom: auto;
    transform: translateY(-50%);
  }
}
