/* Lumafield Foundation Model — iPhone embeddings interactive module */

@font-face {
  font-family: "Monument Grotesk";
  src: url("fonts/MonumentGrotesk-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Monument Grotesk";
  src: url("fonts/MonumentGrotesk-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Monument Grotesk Semi-Mono";
  src: url("fonts/MonumentGroteskSemiMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

#lf-phone-module {
  position: relative;
  width: 100%;
  max-width: 1350px;
  height: 500px;
  background: #000;
  overflow: hidden;
  font-family: "Monument Grotesk", -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}

#lf-phone-module canvas {
  position: absolute;
  inset: 0;
  display: block;
  cursor: grab;
}
#lf-phone-module canvas.lf-dragging { cursor: grabbing; }
#lf-phone-module canvas.lf-hovering { cursor: pointer; }

/* ---- Story text overlay: left column on desktop ---- */
.lf-story {
  position: absolute;
  left: 40px;
  top: 50%;
  transform: translateY(-50%);
  width: 340px;
  font-size: 21px;
  line-height: 1.35;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transition: opacity 0.45s ease;
  pointer-events: none;
  z-index: 3;
}
.lf-story.lf-visible { opacity: 1; }
.lf-story-text { display: block; }

/* "Block text" beats: the caption renders large and centered in the module */
.lf-story.lf-block {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: auto;
  max-width: 72%;
  font-size: 32px;
  line-height: 1.25;
  letter-spacing: 0.02em;
  text-align: center;
  z-index: 4;
}

/* Prominent replay button, shown under the caption on the story's last beat */
.lf-replay {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 22px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: #000;
  background: #ffe25a;
  border: none;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.45s ease, transform 0.45s ease, visibility 0s linear 0.45s, background 0.15s;
  pointer-events: auto;
}
.lf-replay.lf-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.45s ease, transform 0.45s ease, visibility 0s, background 0.15s;
}
.lf-replay:hover { background: #fff; }
.lf-replay svg { display: block; }

/* ---- Scan flipbook: full-frame CT slice cycling (story beat 1) ---- */
.lf-flipbook {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 400px; /* clear of the narration column */
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0s linear 0.6s;
  pointer-events: none;
  z-index: 2;
}
.lf-flipbook.lf-visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.6s ease, visibility 0s;
}
.lf-flipbook img {
  max-height: 92%;
  max-width: 92%;
  object-fit: contain;
}

/* ---- Figure: full-phone slice with a drawn-on highlight box ---- */
.lf-figure {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 400px; /* clear of the narration column */
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0s linear 0.6s;
  pointer-events: none;
  z-index: 2;
}
.lf-figure.lf-visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.6s ease, visibility 0s;
}
.lf-figure img {
  max-height: 92%;
  max-width: 92%;
  object-fit: contain;
}
.lf-figure-box {
  position: absolute;
  border: 2px solid #ff3b30;
  border-radius: 3px;
  box-shadow: 0 0 14px rgba(255, 59, 48, 0.55), inset 0 0 10px rgba(255, 59, 48, 0.25);
  opacity: 0;
  pointer-events: none;
}

/* ---- Spotlight: ring + tethered image frame walking a cluster ---- */
.lf-spotlight {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 3;
}
.lf-spotlight.lf-visible { opacity: 1; }
.lf-spot-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.lf-spot-svg line {
  stroke: rgba(255, 255, 255, 0.75);
  stroke-width: 1;
}
.lf-spot-ring {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 1.5px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.7);
}
.lf-spot-frame {
  position: absolute;
  width: 92px;
  padding: 5px 5px 4px;
  background: rgba(8, 8, 8, 0.92);
  border: 1px solid #fff;
  transform: translate(-50%, -50%);
}
.lf-spot-frame img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
}
.lf-spot-id {
  margin-top: 3px;
  font-family: "Monument Grotesk Semi-Mono", ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 10px;
  text-align: center;
  color: #c9c9c9;
}

/* ---- Floating cluster labels (track the 3D clusters) ---- */
.lf-labels {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}
.lf-cluster-label {
  position: absolute;
  left: -9999px;
  top: -9999px;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.7s ease;
}
.lf-cluster-label.lf-visible { opacity: 1; }

/* ---- Legend ---- */
.lf-legend {
  position: absolute;
  left: 40px;
  bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  max-width: 700px;
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
  z-index: 3;
}
.lf-legend.lf-visible { opacity: 1; }
.lf-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #c9c9c9;
}
.lf-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

/* ---- Inspector sidebar ---- */
.lf-sidebar {
  position: absolute;
  right: 16px;
  top: 16px;
  bottom: 16px;
  width: 280px;
  background: rgba(12, 12, 12, 0.88);
  border: 1px solid #2a2a2a;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 14px;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 4;
  backdrop-filter: blur(4px);
}
.lf-sidebar.lf-visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.lf-sidebar-img-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #060606;
  border: 1px solid #222;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: none;
}
.lf-sidebar-img-wrap img {
  /* Explicit box + object-fit so host-page img rules (e.g. width:100%)
     can never distort the slice, however the module is embedded. */
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: auto;
}
.lf-sidebar-text {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.lf-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 500;
}
.lf-sidebar-brand .lf-legend-dot { width: 11px; height: 11px; }
.lf-sidebar-meta {
  font-family: "Monument Grotesk Semi-Mono", ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 13px;
  color: #9d9d9d;
  line-height: 1.7;
}
.lf-sidebar-meta strong { color: #fff; font-weight: 400; }
.lf-sidebar-caption {
  margin-top: auto;
  font-size: 11px;
  color: #6f6f6f;
  line-height: 1.5;
}

/* ---- Storyboard transport (back / play-pause / forward) ---- */
.lf-transport {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 6px;
  z-index: 5;
}
.lf-transport .lf-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lf-transport svg { display: block; }

/* ---- Controls ---- */
.lf-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  gap: 8px;
  z-index: 5;
}
.lf-btn {
  font-family: inherit;
  font-size: 12px;
  color: #c9c9c9;
  background: rgba(20, 20, 20, 0.85);
  border: 1px solid #333;
  padding: 6px 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.lf-btn:hover { color: #fff; border-color: #666; }
.lf-btn.lf-hidden { display: none; }

/* When the sidebar is open, keep controls clear of it */
.lf-sidebar.lf-visible ~ .lf-controls { right: 312px; }

/* ---- Hover hint ---- */
.lf-hint {
  position: absolute;
  right: 16px;
  top: 16px;
  font-size: 12px;
  color: #7a7a7a;
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
  z-index: 2;
}
.lf-hint.lf-visible { opacity: 1; }

/* ---- Loading / error ---- */
.lf-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #7a7a7a;
  text-align: center;
  padding: 0 60px;
  z-index: 6;
  background: #000;
}
.lf-status.lf-hidden { display: none; }

/* ---- Narrow screens: narration on top, cloud below ---- */
@media (max-width: 760px) {
  .lf-transport { top: 12px; left: 12px; }
  .lf-flipbook { left: 0; top: 150px; } /* below the narration */
  .lf-figure { left: 0; top: 150px; }
  .lf-story {
    left: 16px;
    right: 16px;
    top: 56px;
    transform: none;
    width: auto;
    font-size: 16px;
    line-height: 1.4;
  }
  .lf-story.lf-block { left: 50%; right: auto; top: 50%; transform: translate(-50%, -50%); font-size: 21px; }
  .lf-legend { left: 16px; bottom: 12px; max-width: none; right: 116px; gap: 4px 12px; }
  .lf-legend-item { font-size: 11px; }
  .lf-hint { display: none; }

  /* Inspector becomes a bottom sheet */
  .lf-sidebar {
    top: auto;
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    height: 152px;
    flex-direction: row;
    padding: 12px;
    gap: 12px;
    transform: translateY(12px);
  }
  .lf-sidebar.lf-visible { transform: translateY(0); }
  .lf-sidebar-img-wrap { width: 126px; height: 126px; aspect-ratio: auto; }
  .lf-sidebar-brand { font-size: 15px; }
  .lf-sidebar-meta { font-size: 12px; }
  .lf-sidebar-caption { font-size: 10px; }
  .lf-sidebar.lf-visible ~ .lf-controls { right: 16px; bottom: 176px; }
}
