/**
 * The shared preview: tiles, the modal, and the parallax stage.
 *
 * Loaded by every surface that shows media, so it leans on the design tokens
 * (--panel, --text, --accent, ...) where they exist and falls back to literal
 * values where a public page — the community gallery — has its own palette and
 * does not load them.
 */

/* --- tiles ---------------------------------------------------------------- */

.wgp-openable { cursor: pointer; }
.wgp-openable:focus-visible {
  outline: 2px solid var(--accent, #6ea8fe);
  outline-offset: 2px;
}

.wgp-media { display: block; width: 100%; height: auto; }

/* A 3D tile is a picture that happens to turn: the click belongs to the tile,
   not to the camera. Steering lives in the modal. */
.wgp-model-tile { pointer-events: none; }

.wgp-thumb-video { display: block; }

.wgp-audio-tile, .wgp-code-tile, .wgp-game-tile, .wgp-doc-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; min-height: 160px; padding: 18px; text-align: center;
  border-radius: 12px; background: var(--panel-2, rgba(255, 255, 255, .05));
  color: var(--muted, rgba(255, 255, 255, .68)); font-size: 12px;
}
.wgp-audio-tile svg {
  width: 42px; height: 42px; fill: none; stroke: currentColor;
  stroke-width: 1.6; stroke-linecap: round;
}
.wgp-audio-name, .wgp-code-name { word-break: break-word; }
.wgp-code-tile { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* --- the modal ------------------------------------------------------------ */

/* The page behind a preview must not scroll under it. */
html.wgp-open, html.wgp-open body { overflow: hidden; }

.wgp-scrim {
  position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center;
  padding: 24px; overflow-y: auto;
  background: rgba(6, 8, 12, .78); backdrop-filter: blur(10px);
}

.wgp-sheet {
  position: relative; width: min(1100px, 100%); max-height: calc(100vh - 48px);
  overflow-y: auto; padding: 18px; border-radius: 18px;
  border: 1px solid var(--border, rgba(255, 255, 255, .12));
  background: var(--panel, #0e1016); color: var(--text, #f2f4f8);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
}

.wgp-close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 10px; cursor: pointer;
  background: rgba(8, 10, 15, .6); color: #fff;
}
.wgp-close svg {
  width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round;
}

.wgp-stage {
  display: grid; place-items: center; overflow: hidden;
  border-radius: 12px; background: #05060a;
}
.wgp-stage > * { max-width: 100%; max-height: min(70vh, 720px); }
.wgp-model, .wgp-game, .wgp-doc {
  width: 100%; height: min(70vh, 640px); border: 0; background: #05060a;
}

.wgp-head { margin-top: 14px; }
.wgp-title { margin: 0; font-size: 16px; font-weight: 600; }
.wgp-meta {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px;
  font-size: 11.5px; color: var(--muted, rgba(255, 255, 255, .62));
}
.wgp-kind {
  padding: 1px 8px; border-radius: 999px;
  background: var(--panel-2, rgba(255, 255, 255, .07));
}
.wgp-prompt {
  margin: 8px 0 0; font-size: 12.5px; line-height: 1.5;
  color: var(--muted, rgba(255, 255, 255, .72));
}

/* --- actions -------------------------------------------------------------- */

.wgp-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.wgp-action {
  display: inline-flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 12px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--border, rgba(255, 255, 255, .14));
  background: var(--panel-2, rgba(255, 255, 255, .05));
  color: var(--text, #f2f4f8); font: inherit; font-size: 12px;
}
.wgp-action:hover:not(:disabled) { border-color: var(--accent, #6ea8fe); }
.wgp-action:disabled { opacity: .62; cursor: default; }
.wgp-action.is-done { color: var(--accent, #6ea8fe); border-color: currentColor; }
.wgp-action svg {
  width: 15px; height: 15px; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round;
}
.wgp-note {
  margin-top: 8px; font-size: 12px;
  color: var(--bad, #ff8a8a);
}

/* --- comments ------------------------------------------------------------- */

.wgp-comments {
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--border, rgba(255, 255, 255, .1));
}
.wgp-comments-head { margin: 0 0 10px; font-size: 13px; font-weight: 600; }
.wgp-comment-list { display: flex; flex-direction: column; gap: 10px; }
.wgp-comment {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px;
  font-size: 12.5px; line-height: 1.5;
}
.wgp-comment b { grid-column: 1; font-size: 12px; }
.wgp-comment p { grid-column: 1; margin: 0; overflow-wrap: anywhere; }
.wgp-comment-remove {
  grid-column: 2; grid-row: 1 / span 2; align-self: start;
  border: 0; background: none; cursor: pointer; font: inherit; font-size: 11.5px;
  color: var(--muted, rgba(255, 255, 255, .6));
}
.wgp-comment-remove:hover:not(:disabled) { color: var(--bad, #ff8a8a); }
.wgp-empty { margin: 0; font-size: 12px; color: var(--muted, rgba(255, 255, 255, .6)); }

.wgp-comment-form { display: flex; gap: 8px; margin-top: 12px; }
.wgp-comment-input {
  flex: 1; height: 32px; padding: 0 10px; border-radius: 9px;
  border: 1px solid var(--border, rgba(255, 255, 255, .14));
  background: var(--panel-2, rgba(255, 255, 255, .05));
  color: inherit; font: inherit; font-size: 12.5px;
}
.wgp-comment-input:focus { outline: none; border-color: var(--accent, #6ea8fe); }

/* --- the parallax stage --------------------------------------------------- */
/* Carried over from Creator unchanged: the layer bleed the renderer seats is
   computed against these transforms, so the two move together or an edge
   enters frame. */

.wgp-parallax {
  position: relative; overflow: hidden; width: 100%; height: 100%;
  background: #05060a; isolation: isolate; touch-action: pan-y;
}
.wgp-parallax-layer {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
  object-fit: cover; transform-origin: 50% 50%; will-change: transform;
  transform: translate3d(0, 0, 0); pointer-events: none; user-select: none;
  transition: transform .42s cubic-bezier(.22, .61, .36, 1);
}
.wgp-parallax.is-active .wgp-parallax-layer { transition: transform .12s linear; }
.wgp-parallax-hint {
  position: absolute; left: 10px; bottom: 10px; z-index: 40;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 999px; pointer-events: none;
  background: rgba(8, 10, 15, .62); color: rgba(255, 255, 255, .82);
  font-size: 10.5px; letter-spacing: .01em; backdrop-filter: blur(8px);
  opacity: 1; transition: opacity .3s ease;
}
.wgp-parallax.is-active .wgp-parallax-hint { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .wgp-parallax-layer { transition: none; transform: none !important; }
}

@media (max-width: 640px) {
  .wgp-scrim { padding: 12px; }
  .wgp-sheet { padding: 14px; border-radius: 14px; }
}
