/* ══════════════════════════════════════════════════════════════
   STORYTELLING PAGE — cinematic journey map
   ══════════════════════════════════════════════════════════════ */

.st-page {
  min-height: 100vh;
  background: #070a14;
  color: #d4e4f8;
}

/* ── HERO ───────────────────────────────────────────────────── */
.st-hero {
  position: relative;
  padding: 80px 32px 60px;
  overflow: hidden;
  background: linear-gradient(145deg, #070a14 0%, #0b1d3a 55%, #07101e 100%);
  border-bottom: 1px solid rgba(74, 158, 255, 0.14);
}

.st-hero::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 70% at 8%  50%, rgba(74,158,255,0.11) 0%, transparent 68%),
    radial-gradient(ellipse 45% 60% at 92% 25%, rgba(231,76,60,0.07)  0%, transparent 68%),
    radial-gradient(ellipse 30% 40% at 50% 90%, rgba(46,204,113,0.05) 0%, transparent 68%);
  pointer-events: none;
}

.st-hero::after {
  content: '';
  position: absolute; inset: 0;
  background-image: radial-gradient(circle, rgba(74,158,255,0.14) 1px, transparent 1px);
  background-size: 42px 42px;
  pointer-events: none;
}

.st-hero-inner {
  position: relative; z-index: 1;
  max-width: 800px; margin: 0 auto; text-align: center;
}

.st-eyebrow {
  font-family: 'Courier New', monospace;
  font-size: var(--font-size-secondary); letter-spacing: 0;
  color: #4a9eff; text-transform: uppercase;
  margin-bottom: 1.2rem; opacity: 0;
  animation: stFadeUp 0.7s ease-out 0.05s forwards;
}

.st-title {
  font-size: var(--font-size-display);
  font-weight: 900; letter-spacing: 0;
  color: #fff; margin-bottom: 1rem; line-height: 1.06;
  text-shadow: 0 0 80px rgba(74,158,255,0.3);
  opacity: 0;
  animation: stFadeUp 0.75s ease-out 0.18s forwards;
}

.st-subtitle {
  font-size: var(--font-size-highlight); color: #7d94b2;
  max-width: 620px; margin: 0 auto;
  line-height: 1.75; opacity: 0;
  animation: stFadeUp 0.75s ease-out 0.32s forwards;
}

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

/* ── HINT BAR ────────────────────────────────────────────────── */
.st-hint {
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 9px 24px;
  background: rgba(74, 158, 255, 0.06);
  border-bottom: 1px solid rgba(74, 158, 255, 0.12);
}

.st-hint-text {
  font-size: var(--font-size-secondary);
  color: #5a80a8;
  letter-spacing: 0;
}

/* ══════════════════════════════════════════════════════════════
   GRAPH WRAPPER
   ══════════════════════════════════════════════════════════════ */
.st-net-wrap {
  position: relative;
  --story-pulse-x: 50%;
  --story-pulse-y: 50%;
  opacity: 0;
  width: min(1180px, calc(100% - 48px));
  aspect-ratio: 960 / 760;
  margin: 28px auto 0;
  animation: stFadeIn 0.9s ease-out 0.45s forwards;
  overflow: hidden;
  background: #050816;
  isolation: isolate;
  box-shadow:
    0 0 0 1px rgba(74,158,255,0.08),
    0 30px 70px -20px rgba(0,0,0,0.85);
}

.st-bg-map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.st-bg-map .leaflet-container {
  background: #07111d;
  filter: saturate(1.18) contrast(1.08) brightness(0.9);
}

.st-bg-map .leaflet-control-container {
  opacity: 0.78;
}

.st-bg-map .leaflet-control-attribution {
  font-size: var(--font-size-secondary);
  background: rgba(255, 255, 255, 0.72);
}

.st-bg-map .leaflet-control-scale-line {
  background: rgba(6, 9, 22, 0.64);
  border-color: rgba(221, 232, 255, 0.6);
  color: #e7f1ff;
}

.st-map-tint {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at var(--story-pulse-x) var(--story-pulse-y), rgba(74, 158, 255, 0.22) 0%, transparent 18%),
    linear-gradient(90deg, rgba(5,8,18,0.22), transparent 18%, transparent 82%, rgba(5,8,18,0.22)),
    linear-gradient(0deg, rgba(5,8,18,0.48), transparent 22%, transparent 82%, rgba(5,8,18,0.16));
  transition: background 620ms cubic-bezier(0.2, 0.78, 0.2, 1);
  pointer-events: none;
  z-index: 1;
}

.st-net-wrap.is-story-focused .st-bg-map .leaflet-container {
  filter: saturate(1.32) contrast(1.12) brightness(0.96);
}

.st-net-wrap.is-story-traveling .st-bg-map .leaflet-container {
  filter: saturate(1.5) contrast(1.16) brightness(1.02);
}

@keyframes stFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Plotly graph canvas */
.st-graph {
  display: block;
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  min-height: 0;
  background-color: transparent;
  transition: opacity 420ms cubic-bezier(0.2, 0.78, 0.2, 1);
}

.st-net-wrap.is-node-hovered .st-graph {
  opacity: 0.52;
}

.st-graph .js-plotly-plot,
.st-graph .plot-container,
.st-graph .svg-container {
  width: 100% !important;
  height: 100% !important;
}

/* Make Plotly nodes show pointer cursor */
.st-graph .nsewdrag,
.st-graph .drag {
  cursor: pointer !important;
}

.st-graph .hoverlayer {
  display: none;
}

.st-bg-map .st-story-outline {
  opacity: 0 !important;
  pointer-events: none;
  transition: opacity 420ms cubic-bezier(0.2, 0.78, 0.2, 1);
  vector-effect: non-scaling-stroke;
}

.st-net-wrap[data-story-focus="italia"] .st-story-region-outline,
.st-net-wrap[data-story-focus="fvg"] .st-story-region-outline,
.st-net-wrap[data-story-focus="uprov"] .st-story-region-outline {
  opacity: 0.82 !important;
}

.st-net-wrap[data-story-focus="fvg"] .st-story-province-outline,
.st-net-wrap[data-story-focus="uprov"] .st-story-province-outline,
.st-net-wrap[data-story-focus="sn"] .st-story-province-outline {
  opacity: 0.9 !important;
}

.st-net-wrap[data-story-focus="iudine"] .st-story-zone-outline,
.st-net-wrap[data-story-focus="izona"] .st-story-zone-outline,
.st-net-wrap[data-story-focus="arch"] .st-story-zone-outline,
.st-net-wrap[data-story-focus="s2"] .st-story-zone-outline {
  opacity: 0.92 !important;
}

.st-net-wrap[data-story-focus="mps04q"] .st-story-building-outline,
.st-net-wrap[data-story-focus="slama"] .st-story-building-outline,
.st-net-wrap[data-story-focus="evasim"] .st-story-building-outline,
.st-net-wrap[data-story-focus="s1"] .st-story-building-outline {
  opacity: 0.95 !important;
}

.st-hover-card {
  position: absolute;
  left: var(--story-card-left, 50%);
  top: var(--story-card-top, 50%);
  width: min(480px, calc(100% - 24px));
  padding: 18px 20px 17px;
  border: 1px solid rgba(132, 193, 255, 0.36);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(10, 15, 34, 0.98), rgba(16, 23, 43, 0.96)),
    rgba(10, 15, 34, 0.98);
  box-shadow:
    0 24px 58px rgba(0, 0, 0, 0.50),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset,
    0 0 42px rgba(74, 158, 255, 0.18);
  color: #e8f3ff;
  opacity: 0;
  transform: var(--story-card-transform, translate(18px, -50%)) scale(0.97);
  transition:
    opacity 150ms ease,
    transform 180ms cubic-bezier(0.2, 0.78, 0.2, 1),
    left 180ms cubic-bezier(0.2, 0.78, 0.2, 1),
    top 180ms cubic-bezier(0.2, 0.78, 0.2, 1);
  pointer-events: none;
  z-index: 5;
}

.st-hover-card.is-visible {
  opacity: 1;
  transform: var(--story-card-transform, translate(18px, -50%)) scale(1);
}

.st-hover-card-pointer {
  position: absolute;
  left: -9px;
  top: 50%;
  width: 18px;
  height: 18px;
  border-left: 1px solid rgba(132, 193, 255, 0.34);
  border-bottom: 1px solid rgba(132, 193, 255, 0.34);
  background: #0b1227;
  transform: translateY(-50%) rotate(45deg);
}

.st-hover-card.is-left .st-hover-card-pointer {
  left: auto;
  right: -9px;
  border-left: 0;
  border-bottom: 0;
  border-right: 1px solid rgba(132, 193, 255, 0.34);
  border-top: 1px solid rgba(132, 193, 255, 0.34);
}

.st-hover-card.is-above .st-hover-card-pointer {
  left: 28px;
  right: auto;
  top: auto;
  bottom: -9px;
  border-left: 0;
  border-bottom: 0;
  border-right: 1px solid rgba(132, 193, 255, 0.34);
  border-bottom: 1px solid rgba(132, 193, 255, 0.34);
  transform: rotate(45deg);
}

.st-hover-card.is-below .st-hover-card-pointer {
  left: 28px;
  top: -9px;
  border-left: 1px solid rgba(132, 193, 255, 0.34);
  border-bottom: 0;
  border-top: 1px solid rgba(132, 193, 255, 0.34);
  transform: rotate(45deg);
}

.st-hover-card-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 13px;
  border-bottom: 1px solid rgba(132, 193, 255, 0.18);
}

.st-hover-card-icon {
  flex: 0 0 54px;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background:
    radial-gradient(circle at 35% 30%, rgba(96, 165, 250, 0.38), transparent 52%),
    rgba(74, 158, 255, 0.13);
  border: 1px solid rgba(125, 187, 255, 0.34);
  box-shadow: 0 0 24px rgba(74, 158, 255, 0.16) inset;
  font-size: var(--font-size-icon);
  line-height: 1;
}

.st-hover-card-heading {
  min-width: 0;
}

.st-hover-card-kicker {
  margin-bottom: 5px;
  color: #7dbbff;
  font-size: var(--font-size-secondary);
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.st-hover-card-title {
  color: #ffffff;
  font-size: var(--font-size-title);
  font-weight: 900;
  line-height: 1.12;
}

.st-hover-card-subtitle {
  margin-top: 6px;
  color: #93b6dc;
  font-size: var(--font-size-primary);
  font-weight: 700;
}

.st-hover-card-text {
  margin-top: 13px;
  color: #d0e1f6;
  font-size: var(--font-size-primary);
  line-height: 1.55;
}

.st-hover-card-details {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  padding: 11px 12px;
  border: 1px solid rgba(132, 193, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.st-hover-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 22px;
  font-size: var(--font-size-secondary);
}

.st-hover-card-row-label {
  color: #8ea3bb;
  font-weight: 700;
}

.st-hover-card-row strong {
  color: #f7fbff;
  font-size: var(--font-size-primary);
  text-align: right;
}

.st-hover-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.st-hover-card-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border: 1px solid rgba(125, 187, 255, 0.24);
  border-radius: 999px;
  background: rgba(74, 158, 255, 0.10);
  color: #b9d8fa;
  font-size: var(--font-size-secondary);
  font-weight: 800;
}

.st-hover-card-action {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(132, 193, 255, 0.16);
  color: #9fffd0;
  font-size: var(--font-size-primary);
  font-weight: 900;
}

/* ══════════════════════════════════════════════════════════════
   LEGEND
   ══════════════════════════════════════════════════════════════ */
.st-legend {
  display: flex; align-items: center; justify-content: center;
  gap: 28px; flex-wrap: wrap;
  padding: 20px 24px 36px;
  border-top: 1px solid rgba(74,158,255,0.10);
}

.st-leg-item {
  display: flex; align-items: center; gap: 9px;
}

.st-leg-label {
  font-size: var(--font-size-secondary); font-weight: 500; color: #6a82a0;
}

/* ══════════════════════════════════════════════════════════════
   LIGHT THEME OVERRIDES
   ══════════════════════════════════════════════════════════════ */
body[data-theme="light"] .st-page      { background: #edf2fa; }

body[data-theme="light"] .st-hero {
  background: linear-gradient(145deg, #e0ecf8 0%, #c8dcf6 55%, #d5eaf4 100%);
  border-bottom-color: rgba(74,158,255,0.25);
}
body[data-theme="light"] .st-title    { color: #0b1528; text-shadow: none; }
body[data-theme="light"] .st-subtitle { color: #3d5570; }
body[data-theme="light"] .st-eyebrow  { color: #1a62d6; }

body[data-theme="light"] .st-hint {
  background: rgba(74,158,255,0.06);
  border-color: rgba(74,158,255,0.2);
}
body[data-theme="light"] .st-hint-text { color: #3d5570; }
body[data-theme="light"] .st-leg-label { color: #3d5570; }
body[data-theme="light"] .st-legend    { border-top-color: rgba(74,158,255,0.18); }

body[data-theme="light"] .st-net-wrap {
  background: #dfe9f5;
  box-shadow:
    0 0 0 1px rgba(26,98,214,0.16),
    0 24px 54px -24px rgba(26,52,80,0.35);
}

body[data-theme="light"] .st-bg-map .leaflet-container {
  filter: saturate(1.04) contrast(1.02) brightness(1);
}

body[data-theme="light"] .st-map-tint {
  background:
    radial-gradient(circle at var(--story-pulse-x) var(--story-pulse-y), rgba(26, 98, 214, 0.16) 0%, transparent 18%),
    linear-gradient(90deg, rgba(223,233,245,0.18), transparent 18%, transparent 82%, rgba(223,233,245,0.18)),
    linear-gradient(0deg, rgba(223,233,245,0.42), transparent 22%, transparent 82%, rgba(223,233,245,0.12));
}

body[data-theme="light"] .st-graph {
  background-color: transparent;
}
