/* external-preview.css -- styles for external-link previews inside .popup.
 * Uses only the site's theme tokens (assets/css/critical/15-colors.css):
 * --bg, --bg1, --fg, --fg2, --primary. Light/dark follow :root[data-theme]. */

.xp {
  box-sizing: border-box;
  padding: 0.75rem 0.9rem;
  color: var(--fg);
  background: var(--bg);
  font-size: 0.9rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.xp-title {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--fg);
}

.xp-sub {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--fg2);
}

.xp-body,
.xp-body p {
  margin: 0 0 0.5rem;
}

.xp-path {
  margin: 0 0 0.5rem;
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--fg2);
  word-break: break-all;
}

.xp-thumb {
  float: right;
  max-width: 40%;
  max-height: 160px;
  margin: 0 0 0.5rem 0.75rem;
  border: 1px solid var(--bg1);
  border-radius: 3px;
  background: var(--bg1);
}

/* "Source" link at the bottom of every card */
.xp-source {
  display: block;
  clear: both;
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--bg1);
  font-size: 0.8rem;
  color: var(--primary);
  text-decoration: none;
}
.xp-source:hover {
  text-decoration: underline;
}

/* Generic fallback card */
.xp-card-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

/* Buttons (Open PDF here) */
.xp-btn {
  font: inherit;
  font-size: 0.85rem;
  margin: 0.25rem 0 0.5rem;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--primary);
  border-radius: 3px;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
}
.xp-btn:hover {
  background: var(--primary);
  color: var(--bg);
}

/* YouTube poster with click-to-play (mirrors the embed-iframe interaction gate) */
.xp-poster {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 0 0 0.5rem;
  border: 0;
  border-radius: 3px;
  background: var(--bg1) center / cover no-repeat;
  cursor: pointer;
}
.xp-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 2.5rem;
  color: #fff;
  text-shadow: 0 0 12px rgba(0, 0, 0, 0.8);
}
.xp-video-frame {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 0 0 0.5rem;
  border: 0;
  background: #000;
}

/* Full-height iframe previews (allowlisted sites, PDFs) */
.xp-frame {
  display: flex;
  flex: 1 1 auto;
  min-height: 300px;
  height: 100%;
  padding: 0;
}
.xp-frame iframe,
.xp-pdf-frame {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 300px;
  border: 0;
  background: var(--bg);
}
.xp-pdf iframe {
  background: #525659;
} /* PDF viewer chrome is dark in every browser */

/* Keep drag/resize smooth: iframes swallow mouse events */
.popup.resizing .xp iframe,
.popup.dragging .xp iframe {
  pointer-events: none;
}

@media (max-width: 480px) {
  .xp {
    padding: 0.6rem 0.7rem;
  }
  .xp-thumb {
    float: none;
    display: block;
    max-width: 100%;
    max-height: 120px;
    margin: 0 0 0.5rem;
  }
  .xp-frame,
  .xp-frame iframe {
    min-height: 220px;
  }
}
