/**
 * weave-modal-master-detail.css
 * Package: composer-weave-modal-layout-v4-master-detail-2026-08-11 (w-6)
 * Corrective: composer-weave-modal-priority-fix-v4.1-2026-08-11 (w-8)
 *
 * Priority:
 *   PRIMARY / HERO = selected Story Map node (or default SUMMARY when none selected)
 *   SECONDARY      = original SUMMARY demoted under the Story Map (lower-left)
 */

/* —— Desktop proportions: map narrow, hero wide —— */
@media (min-width: 769px) {
  .weave-modal__body {
    grid-template-columns: minmax(200px, 32%) minmax(0, 1fr) !important;
  }
  .weave-modal__hierarchy {
    position: sticky;
    top: 0;
    align-self: start;
    max-height: calc(90vh - 4.5rem);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  .weave-modal__summary,
  .weave-modal__hero {
    min-width: 0;
  }
}

/* Left column order (all breakpoints): title → Story Map → secondary SUMMARY → strands */
.weave-modal__hierarchy {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.weave-modal__hierarchy > .weave-modal__section-title {
  order: 0;
  flex-shrink: 0;
}
.weave-modal__hierarchy > #hierarchy-tree {
  order: 1;
}
.weave-modal__hierarchy > .modal-summary-secondary,
.weave-modal__hierarchy > #modal-summary-secondary-host {
  order: 2;
}
.weave-modal__hierarchy > .weave-components-panel {
  order: 3;
}

/* —— Hero pane (right / main) —— */
#modal-detail-pane {
  scroll-behavior: smooth;
  position: relative;
}

.modal-summary-default {
  animation: md-fade-in 0.2s ease;
}

/* Meta + visual rollup side by side */
.modal-summary-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.85rem 1rem;
  margin: 0 0 1.1rem;
}
.modal-summary-meta-row .weave-modal__meta {
  flex: 1 1 12rem;
  margin-bottom: 0 !important;
  min-width: 0;
}
.modal-summary-slivers {
  flex: 1 1 10rem;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.35rem;
  min-height: 7.5rem;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding: 0.15rem 0.1rem;
}
.modal-summary-slivers[hidden] {
  display: none !important;
}
.modal-summary-sliver {
  appearance: none;
  flex: 0 0 auto;
  width: 3.35rem;
  min-height: 7.5rem;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.35);
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.modal-summary-sliver:hover,
.modal-summary-sliver:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(0, 255, 255, 0.55);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  outline: none;
}
.modal-summary-sliver__img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 7.5rem;
  object-fit: cover;
  object-position: center 20%;
}
.modal-summary-sliver__badge {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.22rem 0.12rem 0.28rem;
  font-size: 0.48rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: center;
  color: #f4f0ff;
  background: linear-gradient(transparent, rgba(8, 6, 18, 0.92) 35%);
  line-height: 1.1;
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-summary-sliver--relic {
  border-color: rgba(232, 197, 106, 0.4);
}
.modal-summary-sliver--thread {
  border-color: rgba(157, 107, 255, 0.4);
}
.modal-summary-sliver--echo {
  border-color: rgba(100, 200, 255, 0.4);
}
/* Compact: hide rollup when SUMMARY is demoted under the map */
.modal-summary-secondary .modal-summary-slivers,
.modal-summary-secondary .modal-summary-meta-row {
  display: none !important;
}
@media (max-width: 640px) {
  .modal-summary-sliver {
    width: 2.9rem;
    min-height: 6.75rem;
  }
  .modal-summary-sliver__img {
    min-height: 6.75rem;
  }
  .modal-summary-sliver__badge {
    font-size: 0.44rem;
  }
  /* Extra-small phones: a touch more zoom-out (layout-safe) */
  .weave-modal__hierarchy #hierarchy-tree.hierarchy-tree--pyramid {
    zoom: 0.68;
    transform: none;
    width: 100%;
    margin: 0;
  }
}

/* Firefox: no zoom — keep compact pills without transform overlap */
@supports not (zoom: 1) {
  @media (max-width: 768px) {
    .weave-modal__hierarchy #hierarchy-tree.hierarchy-tree--pyramid {
      transform: none;
      zoom: normal;
    }
    .hierarchy-tree--pyramid .pyramid-node {
      min-width: 4.1rem !important;
      max-width: 5.1rem !important;
      padding: 0.22rem 0.24rem !important;
    }
    .hierarchy-tree--pyramid .pyramid-node__label {
      font-size: 0.54rem;
    }
  }
}

/* Selected: hero = node panel only (SUMMARY is relocated, not left dominating) */
.weave-modal.is-node-selected #modal-detail-pane > #modal-summary-default {
  /* Safety: if relocation missed, never show full SUMMARY as hero */
  display: none !important;
}

.weave-modal.is-node-selected #node-preview-panel,
.weave-modal.is-node-selected #node-preview-panel.hidden {
  /* Win over generic .hidden { display:none !important } */
  display: block !important;
}

/* —— Secondary SUMMARY (lower-left under Story Map) —— */
.modal-summary-secondary {
  margin-top: 0.35rem;
  padding: 0.65rem 0.7rem 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.28);
  max-height: min(38vh, 280px);
  overflow: auto;
  flex-shrink: 0;
}
.modal-summary-secondary.hidden {
  display: none !important;
}
.modal-summary-secondary .modal-summary-default {
  display: block !important; /* override selected-state hide when nested here */
  animation: none;
}
.modal-summary-secondary .weave-modal__section-title {
  font-size: 0.65rem;
  margin-bottom: 0.4rem;
  color: #8a82a8;
}
.modal-summary-secondary .weave-modal__section-title::before {
  content: none;
}
/* Compact secondary copy */
.modal-summary-secondary .weave-modal__desc {
  font-size: 0.78rem !important;
  line-height: 1.4 !important;
  color: #9a92b0 !important;
  margin-bottom: 0.55rem !important;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.modal-summary-secondary .weave-modal__edu {
  margin-top: 0.35rem;
  padding-top: 0.35rem;
}
.modal-summary-secondary .weave-modal__edu h4 {
  font-size: 0.75rem !important;
  color: #8a9aaa !important;
}
.modal-summary-secondary .weave-modal__edu p,
.modal-summary-secondary .weave-modal__linked {
  font-size: 0.72rem !important;
  color: #7a7290 !important;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.modal-summary-secondary .weave-modal__meta {
  gap: 0.3rem !important;
  margin-bottom: 0.45rem !important;
}
.modal-summary-secondary .weave-modal__meta div {
  grid-template-columns: 72px 1fr !important;
  font-size: 0.72rem !important;
}
.modal-summary-secondary .weave-modal__vote,
.modal-summary-secondary .weave-modal__realm-link {
  display: none !important; /* demoted: no vote/CTA clutter under map */
}
.modal-summary-secondary__label {
  display: block;
  margin: 0 0 0.4rem;
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6a6288;
}

/* —— HERO node panel (selected result) —— */
.node-preview-panel,
.node-preview-panel--hero {
  margin-top: 0;
  padding: 0.25rem 0 0.5rem;
  border: none;
  background: transparent;
  animation: md-hero-in 0.24s ease;
  min-height: 12rem;
}
.node-preview-panel.hidden {
  display: none !important;
}
.weave-modal.is-node-selected .node-preview-panel--hero {
  padding: 0.35rem 0.15rem 0.75rem;
  border-radius: 14px;
  background: linear-gradient(
    165deg,
    rgba(0, 255, 255, 0.06),
    rgba(20, 12, 40, 0.15) 40%,
    transparent 100%
  );
  box-shadow: inset 0 0 0 1px rgba(0, 255, 255, 0.12);
}

.node-preview-panel__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(0, 255, 255, 0.18);
}
.node-preview-panel__viewing {
  margin: 0;
  flex: 1 1 12rem;
  font-size: 1.15rem;
  font-weight: 750;
  line-height: 1.35;
  color: #f8f4ff;
  letter-spacing: 0.01em;
}
body.weave-simple-mode .node-preview-panel__viewing {
  font-size: 1.22rem;
}
.node-preview-panel__back {
  appearance: none;
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(0, 255, 255, 0.45);
  background: rgba(0, 40, 48, 0.55);
  color: #9ef0ff;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.node-preview-panel__back:hover,
.node-preview-panel__back:focus-visible {
  background: rgba(0, 80, 90, 0.6);
  outline: 2px solid rgba(0, 255, 255, 0.5);
  outline-offset: 2px;
}
.node-preview-panel__relation {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  color: #a898d0;
  font-style: italic;
}
.node-preview-panel__relation:empty {
  display: none;
}
.node-preview-panel__media {
  margin: 0 0 1rem;
  border-radius: 14px;
  overflow: hidden;
  max-height: 280px;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}
.node-preview-panel__img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
}
.node-preview-panel__title {
  margin: 0 0 0.55rem;
  font-size: 1.45rem;
  color: #fff;
  line-height: 1.25;
  font-weight: 750;
}
body.weave-simple-mode .node-preview-panel__title {
  font-size: 1.55rem;
}
.node-preview-panel__body {
  margin: 0 0 1.15rem;
  font-size: 1.02rem;
  line-height: 1.6;
  color: #ddd6f0;
  max-width: 42rem;
}
.node-preview-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 1rem;
}
.node-preview-panel__link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.55rem 1.15rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 255, 255, 0.5);
  background: rgba(0, 200, 220, 0.22);
  color: #e8ffff;
  font-weight: 750;
  font-size: 0.9rem;
  text-decoration: none;
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.12);
}
.node-preview-panel__link:hover,
.node-preview-panel__link:focus-visible {
  filter: brightness(1.1);
  text-decoration: none;
}

/* Stronger selected map node */
.pyramid-node--active {
  border-color: rgba(0, 255, 255, 0.7) !important;
  box-shadow: 0 0 0 2px rgba(0, 255, 255, 0.3), 0 0 20px rgba(0, 255, 255, 0.2);
  background: rgba(0, 255, 255, 0.12) !important;
}

/* Story root pill — sits above Artifact / Chapters */
.pyramid-tier--story-root {
  width: 100%;
  justify-content: center;
}
.pyramid-node--story {
  min-width: 140px;
  max-width: 220px;
  border-color: rgba(232, 197, 106, 0.4);
}
.pyramid-node--story .pyramid-node__icon {
  color: #f0d98a;
}
.pyramid-node--story.pyramid-node--active {
  border-color: rgba(232, 197, 106, 0.75) !important;
  box-shadow: 0 0 0 2px rgba(232, 197, 106, 0.35), 0 0 18px rgba(232, 197, 106, 0.15);
  background: rgba(232, 197, 106, 0.12) !important;
}
.pyramid-apex {
  margin-bottom: 0.15rem;
}
.pyramid-apex__map-label {
  margin-bottom: 0;
}

/* Simple Mode targets */
body.weave-simple-mode .pyramid-node {
  min-height: 44px;
  min-width: 44px;
}
body.weave-simple-mode .node-preview-panel__back,
body.weave-simple-mode .node-preview-panel__link {
  min-height: 44px;
}

@keyframes md-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes md-hero-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/*
 * Mobile research layout (≤768px):
 *   [ Story Map — compact, fixed band ]
 *   [ Content — Summary or selected node — scrolls here ]
 * Hides Strands panel + secondary SUMMARY (they pushed content off-screen).
 */
@media (max-width: 768px) {
  .weave-modal {
    padding: 0 !important;
    align-items: stretch !important;
  }
  .weave-modal__panel {
    width: 100% !important;
    max-height: 100vh !important;
    max-height: 100dvh !important;
    height: 100vh !important;
    height: 100dvh !important;
    border-radius: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .weave-modal__header {
    flex-shrink: 0;
  }
  /* Stack map then content; content owns remaining scroll */
  .weave-modal__body {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  /* —— Map band (top) —— */
  .weave-modal__hierarchy {
    order: 1;
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    max-height: min(34vh, 240px);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-right: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(8, 6, 18, 0.98);
    padding: 0.4rem 0.45rem 0.5rem !important;
    gap: 0.35rem;
  }
  .weave-modal.is-node-selected .weave-modal__hierarchy {
    max-height: min(30vh, 210px);
  }

  /* Hide bulky companions that pushed content out of the scrollport */
  .weave-modal__hierarchy > .weave-components-panel,
  .weave-modal__hierarchy > #modal-summary-secondary-host,
  .weave-modal__hierarchy > .modal-summary-secondary,
  .pyramid-echoes-banner {
    display: none !important;
  }

  .weave-modal__hierarchy > .weave-modal__section-title {
    order: 0;
    margin: 0 0 0.25rem !important;
    font-size: 0.65rem;
  }
  .weave-modal__hierarchy > #hierarchy-tree {
    order: 1;
    flex-shrink: 0;
  }

  /* Zoom-out map (layout-safe) */
  .weave-modal__hierarchy #hierarchy-tree.hierarchy-tree--pyramid {
    gap: 0.1rem;
    padding: 0.05rem 0 0.2rem;
    width: 100%;
    margin: 0;
    transform: none;
    zoom: 0.72;
  }
  .hierarchy-tree--pyramid .pyramid-tier {
    display: flex;
    flex-wrap: wrap !important;
    justify-content: center;
    overflow: visible;
    gap: 0.26rem;
    padding-bottom: 0.05rem;
    width: 100%;
  }
  .hierarchy-tree--pyramid .pyramid-node {
    flex: 0 1 auto;
    min-width: 4.3rem !important;
    max-width: 5.4rem !important;
    min-height: 0 !important;
    padding: 0.26rem 0.28rem !important;
    border-radius: 8px;
    gap: 0.05rem;
  }
  .hierarchy-tree--pyramid .pyramid-node__icon {
    font-size: 0.8rem;
  }
  .hierarchy-tree--pyramid .pyramid-node__type {
    font-size: 0.46rem;
    letter-spacing: 0.03em;
  }
  .hierarchy-tree--pyramid .pyramid-node__label {
    font-size: 0.56rem;
    line-height: 1.15;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .pyramid-tier--story-root .pyramid-node--story {
    min-width: 5rem !important;
    max-width: 7rem !important;
  }
  .pyramid-connector {
    height: 6px;
  }
  .pyramid-connector--between {
    height: 4px;
  }
  .pyramid-apex__map-label {
    font-size: 0.55rem;
  }
  body.weave-simple-mode .pyramid-node {
    min-height: 0 !important;
    min-width: 4.3rem !important;
  }

  /* —— Content band (directly under map) — owns remaining height + scroll —— */
  .weave-modal__summary,
  .weave-modal__hero,
  #modal-detail-pane {
    order: 2 !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0.7rem 0.85rem 1.5rem !important;
    border-top: none;
  }

  .node-preview-panel__header {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(13, 8, 32, 0.97);
    padding-top: 0.15rem;
  }
  /* Story Map pill is enough to return — free vertical space on phones */
  .node-preview-panel__back,
  #modal-back-to-story,
  .pyramid-apex__back {
    display: none !important;
  }
  .node-preview-panel__viewing {
    font-size: 1rem;
    flex: 1 1 auto;
  }
  .node-preview-panel__title {
    font-size: 1.15rem;
  }
  .node-preview-panel__media {
    max-height: 180px;
  }
  .node-preview-panel__img {
    max-height: 180px;
  }
}
