/* ============================================================
   Embedded working pieces of a case (assets/js/case-embeds.js)
   ============================================================
   .cm-* is the 3D surroundings map, .cs-* a client site running live. Both are a
   .cp-media box the case grid sizes like any other tile. Until the visitor
   clicks, a transparent gate sits over the content: wheel and touch go to
   the page, not to the map or the site.
   ------------------------------------------------------------ */

.cp-embed {
  --e-ink: #1f1b19;
  --e-ink-2: #6f665f;
  --e-ink-3: #9a918a;
  --e-paper: #fbfaf8;
  --e-paper-2: #f2efeb;
  --e-line: rgba(31, 27, 25, 0.1);
  --e-brand: #cc092f;
  --e-brand-deep: #900f15;
  --e-ease: cubic-bezier(0.22, 0.8, 0.2, 1);
  position: relative;
  overflow: hidden;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  isolation: isolate;
}

.cp-embed button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.cp-embed svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the generic .cp-media img rules stretch every <img> over the box; these
   tiles place their own images */
.cp-embed img,
.cp-section-media-row .cp-embed img,
.cp-section-media-full .cp-embed img {
  position: static;
  inset: auto;
  width: auto;
  height: auto;
  object-fit: initial;
}

/* ---- the gate ------------------------------------------------------- */
.cm-gate {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  cursor: grab !important;
}

.cm-gate-pill {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 16px 0 14px;
  border-radius: 999px;
  background: rgba(251, 250, 248, 0.94);
  color: var(--e-ink);
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.45);
  transition: transform 0.35s var(--e-ease), background-color 0.35s var(--e-ease), color 0.35s var(--e-ease);
}

.cm-gate-pill b { font-weight: 500; }
.cm-gate-pill small { font-size: 12px; color: var(--e-ink-3); }

.cm-gate:hover .cm-gate-pill,
.cm-gate:focus-visible .cm-gate-pill {
  background: var(--e-ink);
  color: #fff;
  transform: translateY(-2px);
}

.cm-gate:hover .cm-gate-pill small,
.cm-gate:focus-visible .cm-gate-pill small { color: rgba(255, 255, 255, 0.6); }

.cm-gate:focus-visible { outline: none; }
.cm-gate:focus-visible .cm-gate-pill { outline: 2px solid #fff; outline-offset: 3px; }

.cp-embed.is-active .cm-gate { display: none; }

/* ---- shared chip -------------------------------------------------- */
.cm-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(251, 250, 248, 0.94) !important;
  color: var(--e-ink) !important;
  font-size: 12.5px !important;
  white-space: nowrap;
  box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.45);
  transition: background-color 0.25s var(--e-ease), color 0.25s var(--e-ease);
}

.cm-chip:hover { background: #fff !important; }
.cm-chip:focus-visible,
.cm-poi:focus-visible,
.cm-pin:focus-visible { outline: 2px solid var(--e-brand); outline-offset: 2px; }

.cm-exit {
  display: none;
  background: var(--e-ink) !important;
  color: #fff !important;
}

.cp-embed.is-active .cm-exit { display: inline-flex; }

/* ============================================================
   3D map
   ============================================================ */
.cp-embed--map {
  aspect-ratio: 16 / 9;
  container-type: inline-size;
  /* the presentation's sky, so the tile's own edge is the horizon */
  background: linear-gradient(180deg, #5d9bd6 0%, #9cc6ec 36%, #d6e8f5 70%, #edf3f8 100%) !important;
}

.cm-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 0.9s var(--e-ease);
  pointer-events: none;
}

.cp-embed--map.is-ready .cm-canvas { opacity: 1; }
.cp-embed--map.is-active .cm-canvas { pointer-events: auto; cursor: grab; }
.cp-embed--map.is-active .cm-canvas:active { cursor: grabbing; }

.cp-embed--map .cm-gate-pill { left: 16px; top: 16px; }

.cm-loader {
  position: absolute;
  left: 50%;
  top: 46%;
  translate: -50% -50%;
  display: grid;
  gap: 10px;
  justify-items: center;
  color: var(--e-ink-2);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  transition: opacity 0.5s;
  z-index: 3;
  pointer-events: none;
}

.cm-loader i {
  display: block;
  width: 120px;
  height: 2px;
  background: rgba(31, 27, 25, 0.12);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

.cm-loader i::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: var(--e-brand);
  animation: cm-load 1.1s ease-in-out infinite;
}

@keyframes cm-load { from { translate: -100% 0; } to { translate: 260% 0; } }

.cp-embed--map.is-ready .cm-loader,
.cp-embed--map.is-failed .cm-loader { opacity: 0; }

/* no WebGL, or the scene did not arrive: the presentation's own render */
.cp-embed--map.is-failed {
  background: var(--cm-fallback, none) center / cover no-repeat, #d6e8f5 !important;
}

.cp-embed--map.is-failed .cm-gate,
.cp-embed--map.is-failed .cm-ctrl,
.cp-embed--map.is-failed .cm-rail { display: none; }

/* ---- controls (top right) ---- */
.cm-ctrl {
  position: absolute;
  right: 16px;
  top: 16px;
  z-index: 3;
  display: flex;
  gap: 8px;
}

/* ---- pins ---- */
.cm-pins {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.cm-pin {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  will-change: transform;
}

.cm-pin.off { display: none; }

.cm-pin .dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--e-ink);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  border: 2px solid #fff;
  box-shadow: 0 6px 16px -6px rgba(0, 0, 0, 0.5);
  flex: none;
  transition: transform 0.25s var(--e-ease);
}

.cm-pin:hover .dot { transform: scale(1.12); }

.cm-pin .tag {
  display: none;
  white-space: nowrap;
  background: var(--e-paper);
  color: var(--e-ink);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.4);
}

.cm-pin.sel .dot { background: var(--e-brand); animation: cm-pulse 1.6s var(--e-ease) 2; }
.cm-pin.sel .tag,
.cm-pin.hero .tag { display: block; }
.cm-pin.hero .dot { background: var(--e-brand); width: 16px; height: 16px; border-width: 3px; }
.cm-pin.hero .tag { background: var(--e-brand-deep); color: #fff; font-weight: 500; font-size: 13px; }
.cm-pin.hero .tag small { display: block; font-weight: 400; font-size: 11px; opacity: 0.85; margin-top: 1px; }

.cm-pin .card {
  display: none;
  position: absolute;
  left: 14px;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  width: 220px;
  background: var(--e-paper);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, 0.45);
  text-align: left;
}

.cm-pin.hero .card { left: 8px; }
.cp-embed .cm-pin .card img { display: block; width: 100%; height: 124px; object-fit: cover; background: var(--e-paper-2); }
.cm-pin .card b { display: block; padding: 9px 11px 0; font-size: 13px; font-weight: 500; color: var(--e-ink); }
.cm-pin .card span { display: block; padding: 2px 11px 10px; font-size: 12px; color: var(--e-ink-2); line-height: 1.4; }
.cm-pin.sel .card { display: block; }
.cm-pin.sel.has-card .tag { display: none; }
.cm-pin.edge .tag { display: block; background: var(--e-brand-deep); color: #fff; font-weight: 500; }
.cm-pin.edge.sel .tag { display: none; }
.cm-pin.edge .dot { background: var(--e-brand-deep); }

@keyframes cm-pulse { 50% { box-shadow: 0 0 0 10px rgba(204, 9, 47, 0.12); } }

/* ---- POI rail (bottom) ---- */
.cm-rail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 16px;
  z-index: 3;
  display: flex;
  gap: 8px;
  padding: 0 16px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scroll-padding: 0 16px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 48px), transparent);
}

.cm-rail::-webkit-scrollbar { display: none; }

.cm-poi {
  flex: none;
  scroll-snap-align: start;
  display: grid !important;
  grid-template-columns: 24px auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 14px 9px 10px !important;
  border-radius: 14px;
  background: rgba(251, 250, 248, 0.94) !important;
  color: var(--e-ink) !important;
  text-align: left;
  box-shadow: 0 8px 24px -14px rgba(0, 0, 0, 0.5);
  transition: background-color 0.25s var(--e-ease), transform 0.25s var(--e-ease);
}

.cm-poi:hover { background: #fff !important; transform: translateY(-2px); }

.cm-poi .n {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--e-ink);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  transition: background-color 0.25s var(--e-ease);
}

.cm-poi.sel .n { background: var(--e-brand); }
.cm-poi .t { font-size: 13px; line-height: 1.25; white-space: nowrap; }
.cm-poi .d { font-size: 13px; font-weight: 500; line-height: 1.25; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; padding-left: 6px; }
.cm-poi small { display: block; font-size: 11px; font-weight: 400; color: var(--e-ink-3); margin-top: 1px; }

@container (max-width: 620px) {
  .cm-ctrl .cm-chip:not(.cm-exit) span { display: none; }
  .cm-ctrl .cm-chip:not(.cm-exit) { width: 36px; padding: 0; justify-content: center; }
  .cp-embed--map .cm-gate-pill small { display: none; }
  .cp-embed--map .cm-gate-pill { left: 12px; top: 12px; }
  .cm-ctrl { right: 12px; top: 12px; }
  .cm-rail { bottom: 12px; padding: 0 12px; }
  .cm-poi .t small { display: none; }
}

@media (max-width: 640px) {
  .cp-embed--map { aspect-ratio: 4 / 5; }
}

/* ============================================================
   Live site
   ============================================================ */
.cp-embed--site,
.cp-section-media-row .cp-section-copy .cp-media.cp-embed--site {
  aspect-ratio: 16 / 11;
  display: flex;
  flex-direction: column;
  background: #141416 !important;
}

.cs-bar {
  flex: none;
  height: 40px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 14px;
  background: #1c1c1f;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.cs-dots { display: flex; gap: 6px; }
.cs-dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, 0.16); }

.cs-url {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 5px 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  letter-spacing: 0.01em;
}

.cs-open {
  justify-self: end;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  transition: color 0.2s;
}

.cs-open:hover { color: #fff; }

.cs-view {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  container-type: inline-size;
}

/* the whole page, captured top to bottom; case-embeds.js moves it */
.cp-embed .cs-view .cs-page {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: auto;
  display: block;
  will-change: transform;
}

.cp-embed .cs-view .cs-page--narrow { display: none; }

@container (max-width: 559px) {
  .cp-embed .cs-view .cs-page--wide { display: none; }
  .cp-embed .cs-view .cs-page--narrow { display: block; }
}

/* the live site, loaded only when the visitor asks for it */
.cs-frame {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  border: 0;
  background: #fff;
  transform-origin: 0 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s var(--e-ease);
}

.cp-embed--site.is-active.is-loaded .cs-frame {
  opacity: 1;
  pointer-events: auto;
}

.cs-gate { cursor: pointer !important; }
.cs-gate .cm-gate-pill { left: 50%; bottom: 20px; translate: -50% 0; }

.cs-gate { z-index: 2; }

.cs-exit {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 3;
}

@media (max-width: 640px) {
  .cp-embed--site,
  .cp-section-media-row .cp-section-copy .cp-media.cp-embed--site { aspect-ratio: 9 / 15; }
}

@media (prefers-reduced-motion: reduce) {
  .cp-embed *,
  .cp-embed *::after { transition: none !important; animation: none !important; }
}
