/* Additions for the MBDef page on top of the group template's index.css (which stays as in the template):
   the rotating map in the template's teaser slot, the numbers, the five steps, and the printed figures that open
   into their interactive versions (static/css/figs.css styles those). */

:root {
  --font-display: 'Newsreader', 'Iowan Old Style', Georgia, serif; /* the MBDef Explorer's display face */
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  /* the stage: the Explorer's dark ground, for the map and the interactive figures */
  --stage-bg: #0c1016;
  --stage-glow: #1a2433;
  --stage-ink: #e8ebee;
  --stage-muted: #9aa4b2;
}

html, body { overflow-x: hidden; }
[hidden] { display: none !important; } /* Bulma's reset gives <article> display: block, which would beat the attribute */

/* ---------------------------------------------------------------- the hero: the map, then the title */
.mbdef-hero { position: relative; padding: 8.5rem 1.5rem 3rem; }
.hero-inner { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 2.25rem; }
.map-stage { position: relative; }

.map3d {
  position: relative;
  display: block;
  height: min(62vh, 580px);
  min-height: 320px;
  overflow: hidden;
  border-radius: var(--border-radius-lg);
  background: radial-gradient(ellipse 65% 70% at 50% 48%, var(--stage-glow) 0%, #121a24 45%, var(--stage-bg) 100%);
  border: 1px solid #1f2733;
  box-shadow: var(--shadow-xl);
  color: var(--stage-ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  outline-offset: 4px;
}
.map3d canvas {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  cursor: grab;
  touch-action: pan-y; /* a vertical swipe still scrolls the page on phones; a sideways one turns the map */
  opacity: 0; transition: opacity 0.8s ease;
}
.map3d.is-ready canvas { opacity: 1; }
.map3d.is-dragging canvas { cursor: grabbing; }
.map3d-labels { position: absolute; inset: 0; pointer-events: none; }
.map3d-label {
  position: absolute; left: 0; top: 0;
  margin: -0.75em 0 0 -0.2em;
  padding: 0.12em 0.55em 0.14em 0.5em;
  font-size: 0.8rem; font-weight: 600; line-height: 1.3; white-space: nowrap;
  color: var(--stage-ink);
  background: rgba(16, 22, 30, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-left: 3px solid var(--dot);
  border-radius: 5px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  will-change: transform, opacity;
}
.map3d-note {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 2rem; text-align: center; color: var(--stage-ink);
}
.map3d-note[hidden] { display: none; }
.map3d-open { /* appears while the pointer is over the map: a click opens the Explorer */
  position: absolute; right: 1rem; top: 1rem; z-index: 300;
  padding: 0.35rem 0.8rem; border-radius: 999px;
  font-size: 0.82rem; font-weight: 600; color: #fff;
  background: rgba(82, 69, 234, 0.92);
  opacity: 0; transform: translateY(-4px); transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.map3d:hover .map3d-open, .map3d:focus-visible .map3d-open { opacity: 1; transform: none; }
.map3d.is-dragging .map3d-open { opacity: 0; }

.map-cap { display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; margin-top: 0.9rem; }
.map-legend { margin: 0; font-size: 0.92rem; line-height: 1.5; color: var(--secondary-color); max-width: 760px; }
.map-eyebrow {
  display: block; margin-bottom: 0.15rem;
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--primary-color);
}
.map-cap .explorer-btn { flex: none; }

.title-block { text-align: center; max-width: 980px; margin: 0 auto; }
.title-block .publication-title { margin-bottom: 1.25rem !important; }
.publication-authors sup { font-size: 0.65em; }
.publication-authors.affiliations { color: var(--text-secondary); font-weight: 400; margin-bottom: 0.5rem; }
.publication-authors.affiliations .author-block { margin-right: 0.9rem; }
.publication-authors.affiliations .eql-cntrb { display: block; margin-top: 0.25rem; }
.publication-status { font-size: 0.95rem; color: var(--secondary-color); margin-bottom: 1rem; }
.publication-status:empty { display: none; }

/* buttons: the Explorer button takes the template's accent gradient; a planned link is dashed, not a link */
.button.explorer-btn {
  background: var(--gradient-accent) !important;
  color: #fff !important; border: none !important;
  box-shadow: var(--shadow-md);
}
.button.explorer-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); filter: brightness(1.08); }
.button.is-soon {
  background: transparent !important; color: var(--secondary-color) !important;
  border: 2px dashed var(--border-color) !important; cursor: default; box-shadow: none;
}
.button.is-soon:hover { transform: none; }

/* ---------------------------------------------------------------- numbers */
.stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 0 0 1.75rem; }
.stat {
  background: var(--background-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem 0.75rem; text-align: center; box-shadow: var(--shadow-sm);
}
.stat b { display: block; font-size: 1.7rem; font-weight: 800; color: var(--text-primary); line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.9rem; color: var(--secondary-color); }
.highlights li { margin-bottom: 0.4rem; }

/* ---------------------------------------------------------------- how MBDef was built */
.section-lead { max-width: 720px; margin: -1rem auto 2rem; text-align: center; color: var(--text-secondary); }
.paper-figure { margin: 0 auto 2rem; }
.paper-figure img { display: block; width: 100%; height: auto; }
.paper-figure figcaption { margin-top: 0.5rem; text-align: center; font-size: 0.9rem; color: var(--secondary-color); }
.pipeline {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1.6rem;
}
.pipeline li {
  position: relative; display: flex; flex-direction: column;
  background: var(--background-primary); border: 1px solid var(--border-color);
  border-radius: var(--border-radius); padding: 1rem 0.9rem 1.1rem; box-shadow: var(--shadow-sm);
}
.pipeline li + li::before {
  content: '\2192'; position: absolute; left: -1.3rem; top: 50%; transform: translateY(-50%);
  font-size: 1.1rem; color: var(--secondary-color);
}
.pipeline .num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.8rem; height: 1.8rem; border-radius: 50%;
  background: var(--gradient-accent); color: #fff; font-weight: 700; font-size: 0.9rem; margin-bottom: 0.5rem;
}
.pipeline h3 { font-size: 1.02rem; font-weight: 700; margin: 0 0 0.35rem; color: var(--text-primary); }
.pipeline p { font-size: 0.9rem; line-height: 1.5; color: var(--text-secondary); margin: 0 0 0.7rem; flex: 1; }
.pipeline .chip {
  align-self: flex-start; font-size: 0.8rem; font-weight: 600;
  color: var(--primary-hover); background: var(--background-accent);
  border-radius: 999px; padding: 0.15rem 0.6rem;
}

/* ---------------------------------------------------------------- printed figures that open into interactive ones */
/* each printed figure is a button; a small pill under it says it opens (never over the figure's own content).
   On hover the figure lifts towards the reader, glows faintly in the accent, and a light sweeps across it once. */
.fig-shot {
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  width: 100%; padding: 0; margin: 0;
  border: 0; background: none; cursor: zoom-in; border-radius: var(--border-radius);
}
.fig-shot-pic {
  position: relative; display: block; width: 100%; overflow: hidden; border-radius: 10px;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.fig-shot-pic img { display: block; width: 100%; height: auto; }
.fig-shot-pic::after { /* the sweep of light */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0) 35%, rgba(165, 156, 255, 0.22) 48%, rgba(255, 255, 255, 0.5) 50%, rgba(165, 156, 255, 0.22) 52%, rgba(255, 255, 255, 0) 65%);
  transform: translateX(-110%);
}
.fig-shot:hover .fig-shot-pic, .fig-shot:focus-visible .fig-shot-pic {
  transform: translateY(-3px) scale(1.012);
  box-shadow: 0 0 0 1px rgba(82, 69, 234, 0.22), 0 18px 40px -18px rgba(82, 69, 234, 0.55);
}
.fig-shot:hover .fig-shot-pic::after, .fig-shot:focus-visible .fig-shot-pic::after { transform: translateX(110%); transition: transform 1.1s cubic-bezier(0.22, 1, 0.36, 1); }
.fig-shot:active .fig-shot-pic { transform: translateY(-1px) scale(1.004); }
.fig-shot:focus-visible { outline: none; }
.fig-shot:focus-visible .fig-shot-pic { outline: 2px solid var(--primary-color); outline-offset: 3px; }
.fig-badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0.65rem; border-radius: 999px;
  font: 600 0.75rem/1.2 Inter, system-ui, sans-serif; color: var(--primary-color);
  background: var(--background-accent); border: 1px solid rgba(82, 69, 234, 0.25);
  transition: color 0.3s, background 0.3s, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1); pointer-events: none;
}
.fig-shot:hover .fig-badge, .fig-shot:focus-visible .fig-badge { color: #fff; background: var(--primary-color); transform: translateY(-2px); }

/* the stage: a full-screen <dialog> holding a veil over the page and the card; index.js moves both with the Web
   Animations API (the card opens out of the printed figure). The page keeps its scrollbar space, so nothing shifts. */
html { scrollbar-gutter: stable; }
html.has-stage { overflow: hidden; }
.fig-stage {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 16px; border: 0; background: transparent; color: var(--stage-ink); overflow: hidden;
}
.fig-stage[open] { display: grid; place-items: center; }
.fig-stage:focus { outline: none; }
.fig-stage::backdrop { background: transparent; }
.fig-veil { position: fixed; inset: 0; background: rgba(8, 10, 16, 0.74); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.fig-stage-inner {
  position: relative; display: flex; flex-direction: column;
  width: min(1240px, 100%); max-height: calc(100vh - 32px);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 18px;
  background: var(--stage-bg); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); overflow: hidden;
  transform-origin: 0 0; /* the morph lays the card over the printed figure from its top left */
}
.fig-stage-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 1.25rem 0.9rem 1.5rem; border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: radial-gradient(ellipse 60% 120% at 0% 0%, rgba(82, 69, 234, 0.18), rgba(82, 69, 234, 0) 70%);
}
.fig-stage-text { min-width: 0; }
.fig-stage-k { margin: 0 0 0.2rem; font: 500 0.72rem/1.3 var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: #a59cff; }
.fig-stage-title { margin: 0; font: 600 1.55rem/1.2 var(--font-display); color: #fff; text-wrap: balance; }
.fig-stage-nav { display: flex; gap: 0.4rem; flex: none; }
.fig-stage-btn {
  appearance: none; cursor: pointer; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--stage-ink); background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.14);
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.fig-stage-btn:hover { background: rgba(165, 156, 255, 0.25); border-color: #a59cff; transform: translateY(-1px); }
.fig-stage-btn:focus-visible { outline: 2px solid #a59cff; outline-offset: 2px; }
.fig-stage-body { position: relative; flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; overflow-anchor: none; padding: 0.75rem 1.5rem 1.5rem; } /* no anchoring: a figure opens at its top */
/* the printed figure on its way between the page and the stage (index.js) */
.fig-ghost {
  position: fixed; z-index: 10; margin: 0; transform-origin: 0 0; border-radius: 10px;
  background: #fff; will-change: transform, filter, opacity; pointer-events: none;
}

/* the carousel: the figures differ in height, so keep the slides even; the template's dots vanish on white */
.results-carousel .item img { background: #fff; max-height: 430px; object-fit: contain; }
.slider-pagination .slider-page { background: var(--border-color); box-shadow: none; }
.slider-pagination .slider-page.is-active { background: var(--primary-color); }

/* ---------------------------------------------------------------- the explorer section */
.explorer-figure { margin: 0 0 1.5rem; }
.explorer-figure img {
  display: block; width: 100%; height: auto;
  border-radius: var(--border-radius-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--border-color);
}
.explorer-figure figcaption { margin-top: 0.75rem; font-size: 0.95rem; color: var(--secondary-color); text-align: center; }
.bibtex-note { color: var(--secondary-color); font-size: 0.95rem; }

/* ---------------------------------------------------------------- small screens */
@media screen and (max-width: 1023px) {
  .pipeline { grid-template-columns: 1fr; gap: 1.4rem; max-width: 520px; margin: 0 auto; }
  .pipeline li + li::before { content: '\2193'; left: 50%; top: -1.35rem; transform: translateX(-50%); }
}

@media screen and (max-width: 768px) {
  .mbdef-hero { padding: 7.25rem 1rem 2rem; }
  .map3d { height: 52vh; max-height: 380px; min-height: 280px; }
  .map3d-label { font-size: 0.72rem; }
  .map-cap { flex-direction: column; align-items: stretch; }
  .map-cap .explorer-btn { width: 100%; }
  .map-drag { display: none; }
  .stat-row { gap: 0.5rem; }
  .stat { padding: 0.8rem 0.3rem; }
  .fig-stage { padding: 0; }
  .fig-stage-inner { width: 100%; height: 100%; max-height: 100vh; border-radius: 0; border: none; }
  .fig-stage-head { padding: 0.8rem 0.75rem 0.7rem 1rem; }
  .fig-stage-title { font-size: 1.2rem; }
  .fig-stage-btn { width: 2rem; height: 2rem; }
  .fig-stage-body { padding: 0.5rem 1rem 1.5rem; flex: 1; }
}

@media screen and (max-width: 480px) {
  .stat b { font-size: 1.3rem; }
  .publication-title { font-size: 1.85rem !important; }
}

@media (prefers-reduced-motion: reduce) {
  .map3d canvas, .map3d-open { transition: none; }
  .hero, .section { animation: none; }
}
