/* The original mobile gallery and accordion stay unchanged. */
.space-floorplan-frame { display: none; }
@media (min-width: 1024px) {
  #khong-gian .space-layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    column-gap: clamp(32px, 4vw, 64px);
  }
  #khong-gian .space-visual {
    grid-column: 1;
    grid-row: 1;
  }
  #khong-gian .space-options {
    grid-column: 2;
    grid-row: 1;
  }
  #khong-gian .sticky-photo {
    top: 96px;
    display: grid;
    gap: 16px;
  }
  .space-floorplan-frame {
    display: block;
    width: 100%;
    aspect-ratio: 2020 / 1175;
    max-height: calc((100svh - 150px) * .58);
    background: #fafaf7;
    border: 0;
    border-radius: 0;
    padding: 0;
    overflow: hidden;
  }
  .space-floorplan { display: block; width: 100%; height: 100%; overflow: visible; }
  /* Cut room footprints out of the static architecture: no old floor below a raised room. */
  .floorplan-base { opacity: 1; }
  #fp-Floor-slab > path { stroke: none; fill: none; }
  .floorplan-base [stroke]:not([stroke="white"]) { stroke: #b4bfd0; }
  .floorplan-base [fill="white"] { fill: #f5f6f8; }
  /* White circulation, grey building mass and service rooms. */
  .space-floorplan-frame { background: #ffffff; }
  #fp-exterior-mass { fill: #d4d7dc; }
  #fp-Service-rooms [fill]:not([fill="none"]) { fill: #d4d7dc; }
  #fp-Service-rooms [stroke], #fp-Secondary-partitions [stroke],
  #fp-Staircase [stroke] { stroke: #78818d; }
  #khong-gian .floorplan-zone > g[id$="-walls"] [stroke] { stroke: #586472; stroke-width: 3; }
  /* Room colours follow the supplied plan; activity still follows service groups. */
  .floorplan-zone {
    --room-rest: #a5dff0; --room-active: #68c6e2;
    --room-ink: #397b91;
    --room-detail: #eaf8fc;
    --room-tone: var(--room-rest);
    transform: none;
    filter: none;
    transition: transform .7s cubic-bezier(.4,0,.2,1), filter .7s cubic-bezier(.4,0,.2,1), opacity .5s ease-in-out;
  }
  .floorplan-zone[data-room="Hub A"], .floorplan-zone[data-room="Hub B"] {
    --room-rest: #94d7d1; --room-active: #57bfb7;
    --room-ink: #326e70; --room-detail: #e6f6f3;
  }
  .floorplan-zone[data-room="Hub J"], .floorplan-zone[data-room="Hub L"] {
    --room-rest: #efb7bf; --room-active: #e88e9e;
    --room-ink: #9b5965; --room-detail: #fcebed;
  }
  .floorplan-zone[data-room="Studio C"], .floorplan-zone[data-room="Hub K"] {
    --room-rest: #c1d8b9; --room-active: #98bd8b;
    --room-ink: #5d7e61; --room-detail: #f0f5ec;
  }
  .floorplan-zone[data-room="Event Hub 1"],
  .floorplan-zone[data-room="Event Hub 2"], .floorplan-zone[data-room="Chill Hub"] {
    --room-rest: #f0e4ae; --room-active: #e5cf78;
    --room-ink: #938044; --room-detail: #fffbed;
  }
  .floorplan-zone [stroke]:not([stroke="white"]) { stroke: var(--room-ink); }
  .floorplan-zone [stroke="white"] { stroke: var(--room-tone); }
  .floorplan-zone .floorplan-room-floor { fill: var(--room-tone); stroke: var(--room-ink); stroke-width: 3; stroke-linejoin: round; }
  .floorplan-zone .floorplan-furniture [fill]:not([fill="none"]) { fill: var(--room-detail); }
  .floorplan-zone [fill], .floorplan-zone [stroke] {
    transition: fill .5s ease-in-out, stroke .5s ease-in-out;
  }

  /* Khu vực không thuộc danh mục được chọn sẽ chuyển sang màu xám */
  .floorplan-zone:not(.is-active) {
    --room-tone: #e6e9ee !important;
    --room-ink: #98a2b3 !important;
    --room-detail: #f3f5f8 !important;
    opacity: 0.75;
  }
  #khong-gian .floorplan-zone:not(.is-active) > g[id$="-walls"] [stroke] {
    stroke: #98a2b3;
    transition: stroke .5s ease-in-out;
  }

  /* Khu vực thuộc danh mục đang chọn: giữ nguyên hiệu ứng nổi bật và màu sắc */
  .floorplan-zone.is-active {
    --room-tone: var(--room-active);
    opacity: 1;
    transform: none;
    filter: none;
  }
  #khong-gian .floorplan-zone.is-active > g[id$="-walls"] [stroke] {
    stroke: #374151;
    stroke-width: 3;
    transition: stroke .5s ease-in-out;
  }

  .floorplan-zone .floorplan-inset-shadow { opacity: 1; transition: opacity .5s ease-in-out; }
  .floorplan-zone.is-active .floorplan-inset-shadow { opacity: 0; }
  #khong-gian .space-photo-stack {
    aspect-ratio: 16 / 9;
    max-height: calc((100svh - 150px) * .42);
    border-radius: 0;
  }
  #khong-gian .space-photo-item img { width: 100%; height: 100%; object-fit: cover; }

}
@media (prefers-reduced-motion: reduce) {
  .floorplan-zone, .floorplan-zone * { animation: none !important; transition: none !important; }
}

/* Desktop album spans both columns beneath the plan and room information. */
#khong-gian .space-visual { min-width: 0; height: auto; }
#khong-gian .sticky-photo { position: static; }
.space-album-section { display: none; min-width: 0; position: relative; }
.space-album-track {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  /* Entrance transforms must not create a transient vertical scrollbar. */
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  cursor: grab;
  scrollbar-width: thin;
  scrollbar-color: var(--brand-indigo) transparent;
  padding-bottom: 8px;
}
.space-album-track::-webkit-scrollbar { height: 3px; }
.space-album-track::-webkit-scrollbar-thumb { background: var(--brand-indigo); border-radius: 3px; }
.space-album-track figure {
  position: relative;
  flex: 0 0 calc(31.6667% - 7.6px);
  min-width: 0;
  margin: 0;
  scroll-snap-align: start;
}
#khong-gian .space-album-track img {
  display: block;
  width: 100%;
  height: min(var(--space-album-height, 360px), calc((100svh - 150px) * .42));
  object-fit: cover;
  user-select: none;
}
.space-album-track figcaption {
  position: absolute;
  bottom: 0;
  inset-inline: 0;
  padding: 28px 12px 14px;
  background: linear-gradient(transparent, rgba(24,34,77,.85));
  color: white;
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
}
.space-album-track.is-dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; }
@supports selector(::-webkit-scrollbar) {
  .space-album-track { scrollbar-width: auto; scrollbar-color: auto; }
}
.space-album-controls {
  position: absolute;
  inset: 0 16px 11px;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  pointer-events: none;
}
.space-album-arrow {
  display: grid;
  place-items: center;
  width: 56px;
  height: 64px;
  padding: 6px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  box-shadow: none;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity .2s ease;
}
.space-album-arrow svg {
  width: 44px;
  height: 40px;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .75));
  transition: transform .2s ease;
}
#space-album-prev:hover:not(:disabled) svg { transform: translateX(-4px); }
#space-album-next:hover:not(:disabled) svg { transform: translateX(4px); }
.space-album-arrow:disabled { opacity: .3; cursor: default; }
.space-album-arrow:focus-visible { outline: 2px solid white; outline-offset: 2px; }

@media (min-width: 1024px) {
  #khong-gian .space-options {
    height: var(--space-panel-height, 480px);
    overflow-y: hidden;
    scrollbar-width: none;
    position: relative;
    scroll-behavior: smooth;
  }
  #khong-gian .space-options::-webkit-scrollbar { display: none; }
  #khong-gian .space-option { flex-shrink: 0; transform: none; }
  #khong-gian .space-option:last-child { min-height: 100%; }
  #khong-gian .space-option:not(.active) { opacity: .35; }
  #khong-gian .space-option.active { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #khong-gian .space-options { scroll-behavior: auto; }
}

@media (min-width: 1024px) {
  #khong-gian .space-layout { row-gap: 12px; }
  #khong-gian .space-album-section { display: block; grid-column: 1 / -1; grid-row: 2; }
}

/* Pointer selection uses the room fill; retain keyboard focus feedback. */
#khong-gian .floorplan-zone:focus:not(:focus-visible) { outline: none; }

@media (min-width: 1024px) {
  #khong-gian .space-option-head { cursor: default; }
}

/* Match the section reveal and the floorplan's gentle colour transitions. */
@media (min-width: 1024px) and (prefers-reduced-motion: no-preference) {
  .space-album-track figure {
    animation: spaceAlbumEnter .6s cubic-bezier(.2, .7, .2, 1) both;
    animation-delay: var(--album-enter-delay, 0ms);
  }
}
@keyframes spaceAlbumEnter {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Labels retain the names and coordinates of the original detailed plan. */
#khong-gian .floorplan-room-label {
  fill: #1f3b4d;
  stroke: none;
  font-family: var(--sans);
  pointer-events: none;
  user-select: none;
}

.space-album-track figcaption {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 32px 18px 16px;
}
#khong-gian .space-album-track .space-album-logo {
  width: 66px;
  height: auto;
  flex: 0 0 66px;
  object-fit: contain;
  opacity: .95;
}

.space-starting-price { display: none; }
@media (min-width: 1024px) {
  #khong-gian .space-option-head { align-items: center; gap: 18px; }
  .space-option-title { min-width: 0; }
  .space-starting-price {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
    align-items: flex-end;
    margin-left: auto;
    color: var(--brand-indigo);
    line-height: 1.35;
    white-space: nowrap;
    font-size: 12px;
  }
  .space-starting-price strong { font-size: clamp(18px, 1.4vw, 22px); font-weight: 500; }
  .space-starting-price small { font-size: 11px; color: #626b83; }
  .space-price-contact { white-space: normal; max-width: 110px; text-align: right; }
}

.space-categories, .space-info-rule { display: none; }
@media (min-width: 1024px) {
  .space-info-rule {
    display: block;
    grid-column: 2;
    grid-row: 1;
    align-self: end;
    border-bottom: 1px solid var(--line);
  }
  .space-categories {
    display: flex;
    position: relative;
    flex-wrap: wrap;
    gap: 8px 28px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--line);
  }
  .space-categories::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -1px;
    width: var(--category-indicator-width, 0px);
    height: 2px;
    background: var(--brand-cyan);
    transform: translateX(var(--category-indicator-x, 0px));
    transition: transform .45s cubic-bezier(.25, 1, .5, 1), width .45s cubic-bezier(.25, 1, .5, 1);
    pointer-events: none;
  }
  .space-categories button {
    padding: 12px 0;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: #626b83;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: color .3s ease;
  }
  .space-categories button:hover { color: var(--brand-indigo); }
  .space-categories button[aria-pressed="true"] {
    color: var(--brand-indigo);
  }
}

@media (min-width: 1024px) {
  #khong-gian .space-option.active { border-top-color: transparent; }
}

/* Align each desktop room card with the full height of the plan. */
@media (min-width: 1024px) {
  #khong-gian .space-option {
    min-height: var(--space-panel-height, 480px);
    padding: 0 0 4px;
    border-top: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }
  #khong-gian .space-detail-wrapper { flex: 1; display: flex; }
  #khong-gian .space-detail-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  #khong-gian .space-detail-inner > .underlink {
    align-self: flex-start;
    margin-top: auto;
    margin-bottom: 12px;
  }
}
@media (min-width: 1024px) {
  .space-floorplan-frame { min-height: 400px; }
}
@media (min-width: 1024px) and (max-width: 1279px) {
  .space-floorplan-frame { min-height: 460px; }
}

/* Room photography belongs to the information column. */
@media (min-width: 1024px) {
  #khong-gian .space-layout {
    row-gap: 24px;
    align-items: start;
    /* Keep reserved scroll height below the content, not inside grid rows. */
    align-content: start;
  }
  #khong-gian .space-visual { grid-row: 1 / 4; align-self: stretch; }
  #khong-gian .sticky-photo {
    position: sticky;
    top: calc(var(--space-header-height, 80px) + 4px);
    gap: 24px;
  }
  #khong-gian .space-categories {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    margin-bottom: 0;
    gap: 8px 16px;
    position: relative;
    top: auto;
    z-index: 10;
    background: #fff;
  }
  #khong-gian .space-floorplan-frame { min-height: 0; max-height: none; }
  #khong-gian .space-info-rule { height: var(--space-category-height, 48px); box-sizing: border-box; }
  #khong-gian .space-options { grid-row: 2; height: auto; overflow: hidden; }
  #khong-gian .space-option { display: none; min-height: 0; padding: 0; }
  #khong-gian .space-option.active { display: flex; }
  #khong-gian .space-detail-inner > .underlink { margin-top: 4px; margin-bottom: 0; }
  #khong-gian .space-album-section { grid-column: 2; grid-row: 3; }
  .space-album-track {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    overflow: hidden;
    scroll-snap-type: none;
    cursor: default;
    padding-bottom: 0;
  }
  .space-album-track figure:first-child { grid-column: 1 / -1; }
  #khong-gian .space-album-track figure > img { height: auto; aspect-ratio: 4 / 3; object-fit: cover; }
  #khong-gian .space-album-track figure:first-child > img { aspect-ratio: 16 / 9; }
  .space-album-track figcaption { padding: 28px 12px 12px; }
  #khong-gian .space-album-track .space-album-logo { width: 48px; flex-basis: 48px; }
  .space-album-track figure:last-child:nth-child(even) { grid-column: 1 / -1; }
  #khong-gian .space-album-track figure:last-child:nth-child(even) > img { aspect-ratio: 16 / 9; }
}
