/* =============================================================================
   Module 2 — Layout
   -----------------------------------------------------------------------------
   Overrides for the split-screen mod2 layout:
     sidebar         — fixed overlay; top tracked by JS so it clears the header
     mod2-body       — full-width flex row (sidebar is overlay, not in flow)
     mod2-room-panel — sticky left half, holds the isometric room SVG
     mod2-text-panel — scrollable right half, holds section text
   ============================================================================= */
html:has(.mod2-page) {
  scroll-behavior: auto;
 scroll-padding-top: calc(40vh - 3px);  /* offsets anchor links by 40% of viewport */
}

/* --- Scroll mask — covers header + collapsed sidebar TOC ------------------- */
.mod2-page .scroll-mask-top {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  /* background-color: var(--background-default); */
  z-index: 5;
  pointer-events: none;
}

/* --- Fixed overlay sidebar ------------------------------------------------- */
/* .mod2-page .sidebar-panel {
  position: fixed;
  top: 0;          
  left: 0;
  margin-top: 0;
  max-height: 100vh; 
  z-index: 50;
  overflow: hidden;
} */

/* Allow sidebar content to scroll when expanded */
.mod2-page .sidebar-content {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* --- Two-column layout ----------------------------------------------------- */
/* Sidebar is a fixed overlay so mod2-body takes the full viewport width */
.mod2-body {
  display: flex;
  width: 100%;
  gap: var(--spacing-xl);
  align-items: flex-start;
}

/* --- Sticky room panel (left 50%) ------------------------------------------ */
.mod2-room-panel {
  position: sticky;
  top: var(--spacing-xxxl);
  width: 40%;
  height: 80vh;              /* was 100vh — shorter so it doesn't fill the full height */
  margin-top: var(--spacing-xxxl);   /* pushes it down from the top edge */
  margin-left: var(--spacing-xl);  /* left breathing room */
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.room-svg {
  width: 100%;
  height: 100%;
}

/* --- Scrollable text panel (right 50%) ------------------------------------- */
.mod2-text-panel {
  width: 55%;
  min-width: 0;
  padding: var(--spacing-xxxxl) var(--spacing-page-margins) var(--spacing-xxxl) var(--spacing-xl);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xxxxl);
}

/* Section-level spacing — mirrors .page-main > .module-section behaviour */
.mod2-text-panel .module-section {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xl);
}

/* Bottom nav — keep consistent with mod1/mod3 */
.mod2-text-panel .mod-nav {
  margin-top: var(--spacing-xl);
}

/* =============================================================================
   Room object interactions
   ============================================================================= */

/* Default: lightly dimmed so the active/hovered object stands out */
.room-object {
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.25s ease, filter 0.25s ease;
  pointer-events: all;   /* capture events even over fill:none areas */
}

.room-object:hover {
  opacity: 1;
}

/* Active object — fully visible + blue glow */
.room-object.is-active {
  opacity: 1;
  filter: drop-shadow(0 0 7px rgba(36, 79, 204, 0.5));
}

/* =============================================================================
   Room tooltip — speech bubble with downward tail
   Figma ref: node 323-2098 (260×130, 16px padding, 24px gap)
   ============================================================================= */

.room-tooltip {
  position: fixed;
  z-index: 200;
  pointer-events: none;        /* never intercept mouse events */
  display: none;
  flex-direction: column;
  align-items: center;
  width: 200px;
  /* anchor point = left/top set by JS; shift so tail-tip sits on the anchor */
  transform: translate(-50%, calc(-100% - 12px));
}

.room-tooltip.is-visible {
  display: flex;
}

.room-tooltip__bubble {
  position: relative;
  width: 100%;
  background: var(--colour-neutral-0);
  border: 1.5px solid var(--surface-callout-border);
  border-radius: var(--corner-m-radius);
  padding: var(--spacing-xs);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);       /* 24px — matches Figma */
  text-align: center;
  box-shadow: 0 4px 20px rgba(18, 18, 18, 0.1);
}

/* Tail — border triangle (drawn behind) */
.room-tooltip__bubble::before {
  content: '';
  position: absolute;
  top: calc(100% + 1px);       /* just outside the bottom border */
  left: 50%;
  transform: translateX(-50%);
  border: 9px solid transparent;
  border-top: 10px solid var(--surface-callout-border);
  border-bottom: none;
}

/* Tail — white fill triangle (drawn on top, covers the bottom border strip) */
.room-tooltip__bubble::after {
  content: '';
  position: absolute;
  top: calc(100% - 0.5px);     /* tiny overlap so no hairline shows */
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top: 9px solid var(--colour-neutral-0);
  border-bottom: none;
  z-index: 1;
}

.room-tooltip__title {
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 600;
  line-height: 24px;
  color: var(--text-default);
}

.room-tooltip__sub {
  font-family: var(--font-family);
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  color: var(--colour-primary-70);
}

/* Wraps both the images and the SVG overlay inside .mod2-room-panel */
    .room-image-container {
      position: relative;
      width: 100%;
      height: 100%;
      background-color: var(--colour-neutral-10); /* visible while images load */
    }

    /* Each image fills the container; only .is-active is opaque */
    .room-image {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      object-fit: contain;
      object-position: center;
      opacity: 0;
      transition: opacity 0.25s ease 0s;
      pointer-events: none; /* images never block SVG mouse events */
      background-color: var(--background-default); /* fallback while images load */
    }

    .room-image.is-active {
      opacity: 1;
      transition-delay: 0s;
    }

    .room-image:not(.is-active) {
      transition-delay: 0.25s;
    }

    /* SVG overlay sits above images, below tooltip (z-index 200) */
    .room-overlay {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      z-index: 5;
    }

    /* Dev helper: add class="show-hotspots" to #room-overlay to see hit areas.
       Remove for production. */
.room-overlay.show-hotspots .room-object:hover * {
  fill:   rgba(36, 79, 204, 0.15) !important;
  stroke: rgba(36, 79, 204, 0.50) !important;
  stroke-width: 1.5px !important;
}

    /* ── learn more/ modals ────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(18, 18, 18, 0.5);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay.is-visible {
  opacity: 1;
  pointer-events: all;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 400;
  width: min(700px, calc(100vw - var(--spacing-xl) * 2));
  max-height: calc(100vh - var(--spacing-xl) * 2);
  overflow-y: auto;
  background-color: var(--colour-neutral-0);
  border-radius: var(--corner-l-radius);
  box-shadow: 0 8px 40px rgba(18, 18, 18, 0.2);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.modal.is-visible {
  opacity: 1;
  pointer-events: all;
  transform: translate(-50%, -50%);
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--spacing-m);
  padding: var(--spacing-xl) var(--spacing-xl) 0;
  position: sticky;
  top: 0;
  background-color: var(--colour-neutral-0);
  z-index: 1;
}

.modal__title {
  font-family: var(--font-family);
  font-size: var(--type-h3-size);
  font-weight: var(--type-h3-weight);
  line-height: var(--type-h3-line-height);
  color: var(--text-default);
}

.modal__body {
  padding: var(--spacing-l) var(--spacing-xl) var(--spacing-xl);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-l);
  font-family: var(--font-family);
  font-size: var(--type-body-size);
  line-height: var(--type-body-line-height);
  color: var(--text-default);
}

.modal__body ul,
.modal__body ol {
  padding-left: var(--spacing-l);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-s);
}
.modal__body ul { list-style: disc; }
.modal__body ol { list-style: decimal; }

.modal__figure {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-s);
  max-width: 80%;
  height: auto;
}

.modal__figure-row {
  display: flex;
  gap: var(--spacing-m);
}

.modal__figure-row img {
  flex: 1;
  width: 0;          /* flex handles sizing, not intrinsic width */
  height: auto;
  border-radius: var(--corner-s-radius);
}

.modal__caption {
  font-family: var(--font-family);
  font-size: var(--type-labels-size);
  font-style: var(--type-labels-style);
  line-height: var(--type-labels-line-height);
  color: var(--text-labels-default);
}

.modal__flip-btn {
  align-self: flex-start;
}

.modal__figure img.is-flipped,
.modal__figure-placeholder.is-flipped {
  transform: scaleX(-1);
}

/* disabling hotspots on zooms */

.room-overlay.hotspots-disabled .room-object {
    pointer-events: none;
    opacity: 0;
}


/* image zoomin ani */
/* zoom images default to transparent bg */

.room-image.is-zoom.is-active {
  animation: zoom-in-scale 0.3s ease   forwards,
             zoom-in-bg    0.3s linear forwards;
}

@keyframes zoom-in-scale {
  from { transform: scale(0.4); }
  to   { transform: scale(1); }
}

@keyframes zoom-in-bg {
  0%   { background-color: transparent; }
  85%  { background-color: transparent; }
  100% { background-color: var(--background-default); }
}

.room-image.is-zoom-out {
  animation: zoom-out-scale   0.3s ease   forwards,
             zoom-out-bg      0.3s linear forwards,
             zoom-out-opacity 0.3s linear forwards;
  transition: none;
  pointer-events: none;
  z-index: 2;
}

@keyframes zoom-out-scale {
  from { transform: scale(1); }
  to   { transform: scale(0.4); }
}

@keyframes zoom-out-bg {
  0%   { background-color: var(--background-default); }
  15%  { background-color: var(--background-default); }
  100% { background-color: transparent; }
}

@keyframes zoom-out-opacity {
  0%   { opacity: 1; }
  15%  { opacity: 1; }
  100% { opacity: 0; }
}

.mod2-text-panel .module-section,
.mod2-text-panel [id][data-section] {
  opacity: 0.35;
  transition: opacity 0.3s ease;
}

.mod2-text-panel .module-section.is-active,
.mod2-text-panel [id][data-section].is-active {
  opacity: 1;
}