/* ═══════════════════════════════════════════════════════════════
   Story Map — Constellation View Styles (v3)
   100% Cloto design tokens — zero hardcoded colors.
   ═══════════════════════════════════════════════════════════════ */

/* ── Overlay Container ── */

.smap-overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 50;
  background: var(--cloto-void);
  opacity: 0;
  transition: opacity 0.5s var(--ease-sheet, cubic-bezier(0.16,1,0.3,1));
  overflow: hidden;
}

.smap-overlay.is-visible {
  opacity: 1;
}

.smap-overlay.is-closing {
  opacity: 0;
  pointer-events: none;
}

/* ── View Container ── */

.smap-view--v3 {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  color: var(--cloto-text);
  font-family: var(--cloto-font-ui);
  overflow: hidden;
  background: var(--cloto-void);
}

.smap-view--v3.smap-view--reveal {
  position: relative;
  display: block;
}

.smap-empty {
  text-align: center;
  padding: var(--space-32) var(--space-12);
  color: var(--cloto-text);
  opacity: 0.5;
  font-style: italic;
}

/* ── Canvas Area ── */

.smap-canvas-area {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.smap-view--reveal .smap-canvas-area {
  position: absolute;
  inset: 0;
}

.smap-canvas-area--sidebar {
  position: relative;
}

/* ── Sidebar Header ── */

.smap-sidebar-header {
  text-align: center;
  padding-top: 12px;
  padding-bottom: var(--space-4);
  flex-shrink: 0;
}
.smap-sidebar-header__title {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-2xs);
  color: var(--cloto-teal);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.smap-sidebar-header__stats {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-xs);
  color: var(--cloto-text-40);
}

/* Sidebar legend: closer to bottom (no bottom section) */
.smap-canvas-area--sidebar .smap-reveal-legend {
  bottom: var(--space-12);
}

.smap-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  cursor: grab;
}
.smap-canvas:active { cursor: grabbing; }

/* ── Labels Layer ── */

.smap-labels-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* ── Node Labels ── */

.smap-node-label {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  text-align: center;
  white-space: nowrap;
}

.smap-node-label__short {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-xs);
  font-weight: 400;
  color: var(--cloto-text-70);
  letter-spacing: 0.02em;
  text-shadow: 0 1px 4px var(--cloto-void);
}

/* ── Link Pills ── */

.smap-link-pill {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  text-align: center;
}

.smap-link-pill__type {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-2xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cloto-text-70);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--cloto-glass-bg);
  backdrop-filter: var(--cloto-glass-blur);
  -webkit-backdrop-filter: var(--cloto-glass-blur);
  border: 1px solid var(--cloto-glass-border);
  display: inline-block;
}

/* ── Reveal Header (overlay on canvas) ── */

.smap-reveal-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  text-align: center;
  z-index: 10;
  padding: var(--space-16) var(--space-10) var(--space-20);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 1.2s ease, transform 1.2s ease;
  background: linear-gradient(to bottom, var(--cloto-void) 0%, transparent 100%);
  pointer-events: none;
}
.smap-reveal-header.visible { opacity: 1; transform: translateY(0); }

.smap-reveal-header__subtitle {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-xs);
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--cloto-teal);
  margin-bottom: var(--space-5);
}

.smap-reveal-header__title {
  font-family: var(--cloto-font-brand);
  font-size: var(--cloto-fs-3xl);
  font-weight: 400;
  color: var(--cloto-text-100);
  line-height: 1.2;
}
.smap-reveal-header__title em {
  color: var(--cloto-teal);
  font-style: normal;
}

.smap-reveal-header__stats {
  margin-top: var(--space-5);
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-sm);
  color: var(--cloto-text-40);
  transition: color 0.6s ease;
}

.smap-reveal-header__hint {
  margin-top: var(--space-2);
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-xs);
  color: var(--cloto-text-30);
  letter-spacing: 0.02em;
}

.smap-reveal-header__weaving {
  margin-top: var(--space-3);
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-xs);
  color: var(--cloto-teal);
  opacity: 0.5;
  animation: smap-weaving-pulse 2s ease-in-out infinite;
  transition: opacity 0.5s ease;
}
.smap-reveal-header__weaving.is-done {
  animation: none;
  opacity: 0;
  pointer-events: none;
}
@keyframes smap-weaving-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.6; }
}

/* ── Reveal Legend ── */

.smap-reveal-legend {
  position: absolute;
  bottom: 160px; left: var(--space-12);
  z-index: 8; opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
}
.smap-reveal-legend.visible { opacity: 1; }

.smap-reveal-legend__item {
  display: flex; align-items: center; gap: 5px; margin-bottom: 4px;
}
.smap-reveal-legend__dot {
  width: 6px; height: 6px; border-radius: var(--radius-full);
}
.smap-reveal-legend__text {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-2xs);
  color: var(--cloto-text-40);
}

/* ── Reveal Detail Panel ── */

.smap-reveal-detail {
  position: absolute;
  right: var(--space-12); top: 50%;
  transform: translateY(-50%) translateX(16px);
  width: 300px;
  background: var(--cloto-glass-bg);
  border: 1px solid var(--cloto-glass-border);
  border-radius: var(--radius-xl);
  backdrop-filter: var(--cloto-glass-blur);
  -webkit-backdrop-filter: var(--cloto-glass-blur);
  box-shadow: var(--shadow-lg);
  padding: var(--space-12);
  z-index: 20;
  color: var(--cloto-text-100);
  opacity: 0; pointer-events: none;
  transition: opacity var(--duration-slow) ease, transform var(--duration-slow) ease;
  max-height: 70vh;
  overflow-y: auto;
}
.smap-reveal-detail.visible {
  opacity: 1; pointer-events: all;
  transform: translateY(-50%) translateX(0);
}
.smap-reveal-detail::-webkit-scrollbar { width: 3px; }
.smap-reveal-detail::-webkit-scrollbar-thumb { background: var(--cloto-teal-a20); border-radius: 3px; }

.smap-reveal-detail__close {
  position: absolute; top: var(--space-5); right: var(--space-6);
  background: none; border: none;
  color: var(--cloto-text-40);
  font-size: 16px; cursor: pointer;
}
.smap-reveal-detail__source {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-2xs);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cloto-teal);
  opacity: 0.5;
  margin-bottom: var(--space-4);
}
.smap-reveal-detail__quote {
  font-family: var(--cloto-font-brand);
  font-size: var(--cloto-fs-lg);
  font-style: italic;
  color: var(--cloto-text-100);
  line-height: 1.4;
  margin-bottom: var(--space-7);
  padding-bottom: var(--space-7);
  border-bottom: 1px solid var(--cloto-glass-border);
}
.smap-reveal-detail__section-title {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-2xs);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cloto-text-25);
  margin-bottom: var(--space-4);
}
.smap-reveal-detail__conn {
  margin-bottom: var(--space-4);
  padding: 7px 9px;
  background: var(--cloto-teal-a6);
  border-radius: var(--radius-sm);
  border-left: 2px solid;
  cursor: pointer;
  transition: background var(--duration-fast);
}
.smap-reveal-detail__conn:hover { background: var(--cloto-teal-a8); }
.smap-reveal-detail__conn-type {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-2xs);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--cloto-text-100);
  margin-bottom: 2px;
}
.smap-reveal-detail__conn-label {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-sm);
  color: var(--cloto-text-70);
  line-height: 1.35;
}

/* ── Bottom Section (reveal) ── */

.smap-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  text-align: center;
  padding: var(--space-32) var(--space-10) var(--space-16);
  background: linear-gradient(to top, var(--cloto-void) 0%, transparent 100%);
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.smap-bottom.visible { opacity: 1; transform: translateY(0); }
.smap-bottom__cta { pointer-events: auto; }

.smap-bottom__claim {
  font-family: var(--cloto-font-brand);
  font-size: var(--cloto-fs-3xl);
  font-style: normal;
  font-weight: 400;
  color: var(--cloto-teal);
  margin-bottom: var(--space-4);
}

.smap-bottom__subcopy {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-sm);
  color: var(--cloto-text-40);
  margin-bottom: var(--space-10);
}

.smap-bottom__cta {
  display: inline-block;
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-base);
  font-weight: 500;
  color: var(--cloto-void);
  background: var(--cloto-teal);
  border: none;
  padding: var(--space-6) var(--space-16);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-glow-teal);
  cursor: pointer;
  transition: background var(--duration-normal) ease;
}
.smap-bottom__cta:hover { background: var(--cloto-teal-light); }
.smap-bottom__cta:disabled { opacity: var(--opacity-disabled); cursor: default; }
.smap-bottom__cta.smap-cta--disabled {
  opacity: var(--opacity-disabled);
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.smap-bottom__cta:not(.smap-cta--disabled) {
  transition: opacity 0.6s ease;
}

/* ── Sidebar Detail Panel (legacy) ── */

.smap-panel {
  width: 300px;
  flex-shrink: 0;
  height: 100%;
  background: var(--cloto-glass-bg);
  backdrop-filter: var(--cloto-glass-blur);
  -webkit-backdrop-filter: var(--cloto-glass-blur);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  border: 1px solid var(--cloto-glass-border);
  border-left: 1px solid var(--cloto-teal-a6);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: smapPanelIn var(--duration-slow) var(--ease-sheet) both;
}

@keyframes smapPanelIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes smapPanelOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(40px); opacity: 0; }
}

.smap-panel__header {
  padding: var(--space-10) var(--space-10) var(--space-7);
  border-bottom: 1px solid var(--cloto-teal-a6);
}

.smap-panel__header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.smap-panel__header-info { flex: 1; }

.smap-panel__label {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-2xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--cloto-text-25);
  margin-bottom: var(--space-3);
}

.smap-panel__title {
  font-family: var(--cloto-font-brand);
  font-size: 17px;
  font-style: italic;
  font-weight: 400;
  color: var(--cloto-text);
  line-height: 1.3;
}

.smap-panel__close {
  background: none; border: none;
  color: var(--cloto-text-40);
  cursor: pointer; font-size: 16px;
  padding: 0 0 0 var(--space-4); line-height: 1;
}
.smap-panel__close:hover { opacity: 0.8; }

.smap-panel__chips {
  margin-top: var(--space-5);
  display: flex; flex-wrap: wrap; gap: 5px;
}

.smap-panel__chip {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-2xs);
  padding: 2px var(--space-4);
  border-radius: var(--radius-full);
  cursor: pointer;
  border: 1px solid;
  transition: opacity var(--duration-normal);
}
.smap-panel__chip:hover { opacity: 0.8; }

.smap-panel__body {
  flex: 1; overflow-y: auto;
  padding: var(--space-6) var(--space-8) var(--space-8);
}

.smap-panel__branch-label {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-2xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--cloto-text-25);
  margin-bottom: var(--space-5);
}

.smap-panel__branch {
  padding: var(--space-4) var(--space-6);
  margin-bottom: 5px;
  border-radius: var(--radius-md);
  background: var(--cloto-surface-a50);
  border: 1px solid transparent;
  display: flex; align-items: center; gap: var(--space-4);
  opacity: 0;
  animation: smapBranchFade 0.3s ease forwards;
}

@keyframes smapBranchFade {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

.smap-panel__branch-dot {
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  opacity: 0.7; flex-shrink: 0;
}

.smap-panel__branch-type {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-2xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.5; flex-shrink: 0;
}

.smap-panel__branch-text {
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-sm);
  line-height: 1.35;
}

/* Branch color variants — all via tokens */
.smap-panel__branch[data-color="gold"] { border-color: var(--cloto-gold-a15); }
.smap-panel__branch[data-color="gold"] .smap-panel__branch-dot { background: var(--cloto-gold); }
.smap-panel__branch[data-color="gold"] .smap-panel__branch-text { color: var(--cloto-gold); }

.smap-panel__branch[data-color="teal"] { border-color: var(--cloto-teal-a12); }
.smap-panel__branch[data-color="teal"] .smap-panel__branch-dot { background: var(--cloto-teal); }
.smap-panel__branch[data-color="teal"] .smap-panel__branch-text { color: var(--cloto-teal); }

.smap-panel__branch[data-color="tealLight"] { border-color: var(--cloto-teal-a12); }
.smap-panel__branch[data-color="tealLight"] .smap-panel__branch-dot { background: var(--cloto-teal-light); }
.smap-panel__branch[data-color="tealLight"] .smap-panel__branch-text { color: var(--cloto-teal-light); }

.smap-panel__branch[data-color="cyan"] { border-color: var(--cloto-info-a12); }
.smap-panel__branch[data-color="cyan"] .smap-panel__branch-dot { background: var(--cloto-info); }
.smap-panel__branch[data-color="cyan"] .smap-panel__branch-text { color: var(--cloto-info); }

.smap-panel__branch[data-color="rose"] { border-color: var(--cloto-danger-a12); }
.smap-panel__branch[data-color="rose"] .smap-panel__branch-dot { background: var(--cloto-danger); }
.smap-panel__branch[data-color="rose"] .smap-panel__branch-text { color: var(--cloto-danger); }

.smap-panel__branch[data-color="purple"] { border-color: var(--cloto-purple-a12); }
.smap-panel__branch[data-color="purple"] .smap-panel__branch-dot { background: var(--cloto-purple); }
.smap-panel__branch[data-color="purple"] .smap-panel__branch-text { color: var(--cloto-purple); }

.smap-panel__footer {
  padding: var(--space-5) var(--space-8);
  border-top: 1px solid var(--cloto-teal-a6);
  text-align: center;
  font-family: var(--cloto-font-ui);
  font-size: var(--cloto-fs-2xs);
  color: var(--cloto-text-25);
}

/* ── Mobile Responsive ── */

@media (max-width: 768px) {
  .smap-reveal-header__title {
    font-size: var(--cloto-fs-2xl);
  }

  .smap-reveal-legend {
    display: none;
  }

  .smap-reveal-detail {
    right: var(--space-6); left: var(--space-6);
    width: auto;
  }

  .smap-bottom__cta {
    padding: var(--space-5) var(--space-12);
  }

  .smap-bottom__claim {
    font-size: var(--cloto-fs-2xl);
  }

  .smap-canvas-area--sidebar {
    flex-direction: column;
  }

  .smap-panel {
    width: 100%;
    height: auto;
    max-height: 280px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    animation: smapPanelInMobile var(--duration-slow) var(--ease-sheet) both;
  }

  @keyframes smapPanelInMobile {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
}
