/* Motion Explorer component.
 *
 * Every rule is scoped to .motion-explorer and every class, id and custom
 * property is prefixed with "me-", so the component can sit inside another
 * site without clashing with its styles. The host page defines the --me-*
 * tokens (see the :root block in index.html for the complete list). Leave the
 * --me-f-* font tokens undefined to inherit the host page's fonts.
 *
 * Layout: a dark "monitor" (stage + transport bar) beside an instrument panel;
 * stacks into one column when the component is narrow.
 */

.motion-explorer {
  container-type: inline-size;
  color: var(--me-ink);
  font-family: var(--me-f-body); font-size: 15px; line-height: 1.5;
}
.motion-explorer *,
.motion-explorer *::before,
.motion-explorer *::after { box-sizing: border-box; }
.motion-explorer [hidden] { display: none !important; }

.me-layout {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: start;
}
@container (max-width: 860px) {
  .me-layout { grid-template-columns: minmax(0, 1fr); }
}

/* Monitor */
.motion-explorer .me-monitor {
  background: var(--me-stage);
  color: var(--me-stage-ink);
  border-radius: var(--me-radius);
  overflow: hidden;
  min-width: 0;
}
.motion-explorer .me-screen {
  position: relative;
  width: min(100%, calc(65svh * var(--me-frame-ratio, 1.777778)));
  max-width: 100%;
  margin-inline: auto;
  aspect-ratio: 16 / 9;
  background: var(--me-stage);
}
.motion-explorer .me-screen canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none; cursor: crosshair;
}
.motion-explorer .me-status {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 24px;
  text-align: center; color: var(--me-stage-muted); font-family: var(--me-f-data); font-size: 14px; line-height: 1.5;
}
.motion-explorer .me-status p { margin: 0; max-width: 52ch; }
.motion-explorer .me-transport {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 12px; border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.motion-explorer .me-transport input[type="range"] {
  flex: 1 1 200px; width: auto; min-width: 0; margin: 0; accent-color: var(--me-stage-ink);
}
.motion-explorer .me-tbtn {
  appearance: none; border: 1px solid rgba(255, 255, 255, 0.16); background: transparent;
  color: var(--me-stage-ink); border-radius: calc(var(--me-radius) * 0.8);
  height: 44px; min-width: 44px; padding: 0 10px; margin: 0;
  font-family: var(--me-f-body); font-size: 13px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.motion-explorer .me-tbtn:hover { background: rgba(255, 255, 255, 0.08); }
.motion-explorer .me-tbtn svg { width: 14px; height: 14px; fill: currentColor; }
.motion-explorer .me-clock {
  font-family: var(--me-f-data); font-size: 13px; color: var(--me-stage-muted);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.motion-explorer .me-clock b { color: var(--me-stage-ink); font-weight: 500; }
.motion-explorer .me-speed {
  font-family: var(--me-f-body); font-size: 13px; background: transparent; color: var(--me-stage-ink);
  border: 1px solid rgba(255, 255, 255, 0.16); border-radius: calc(var(--me-radius) * 0.8);
  height: 44px; padding: 0 10px; margin: 0;
}
.motion-explorer .me-speed option { color: #141722; background: #ffffff; }

/* Panel */
.motion-explorer .me-panel { display: grid; gap: 18px; min-width: 0; }
.motion-explorer .me-group { display: grid; gap: 10px; }
.motion-explorer .me-group + .me-group { border-top: 1px solid var(--me-line); padding-top: 18px; }
.motion-explorer .me-label {
  font-family: var(--me-f-body); font-size: 11px; font-weight: 600; line-height: 1.2; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--me-muted); display: flex; justify-content: space-between; gap: 8px; margin: 0;
}
.motion-explorer .me-label output {
  font-family: var(--me-f-data); font-size: 12px; font-weight: 500; letter-spacing: 0; text-transform: none;
  color: var(--me-ink); font-variant-numeric: tabular-nums;
}
.motion-explorer .me-seg {
  display: grid; grid-template-columns: 1fr 1fr; gap: 3px; padding: 3px;
  background: var(--me-surface); border: 1px solid var(--me-line); border-radius: var(--me-radius);
}
.motion-explorer .me-seg button {
  appearance: none; border: 0; border-radius: calc(var(--me-radius) * 0.7); margin: 0;
  background: transparent; color: var(--me-ink);
  font-family: var(--me-f-body); font-size: 14px; font-weight: 600; padding: 10px 8px; min-height: 44px; cursor: pointer;
}
.motion-explorer .me-seg button[aria-pressed="true"] { background: var(--me-accent); color: var(--me-accent-ink); }
.motion-explorer .me-note { margin: 0; color: var(--me-muted); font-size: 14px; }
.motion-explorer .me-hue {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, hsl(0 90% 58%), hsl(60 90% 52%), hsl(120 80% 48%),
    hsl(180 85% 48%), hsl(240 90% 64%), hsl(300 85% 60%), hsl(330 90% 60%));
}
.motion-explorer .me-hue-legend {
  display: flex; justify-content: space-between; font-family: var(--me-f-body); font-size: 12px; color: var(--me-muted);
}
.motion-explorer .me-panel input[type="range"] { width: 100%; margin: 0; accent-color: var(--me-accent); }
.motion-explorer .me-check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; margin: 0; }
.motion-explorer .me-check input { accent-color: var(--me-accent); width: 16px; height: 16px; margin: 0; }
.motion-explorer .me-btn {
  appearance: none; border: 1px solid var(--me-line); background: var(--me-surface); color: var(--me-ink);
  border-radius: calc(var(--me-radius) * 0.8); padding: 10px 14px; min-height: 44px; margin: 0;
  font-family: var(--me-f-body); font-size: 14px; font-weight: 500; cursor: pointer; justify-self: start;
}
.motion-explorer .me-btn:hover { border-color: var(--me-muted); }
.motion-explorer .me-btn[disabled] { opacity: 0.5; cursor: default; }
.motion-explorer .me-selinfo { margin: 0; font-size: 14px; }
.motion-explorer .me-selinfo strong { font-variant-numeric: tabular-nums; }
.motion-explorer .me-stats {
  margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px;
  font-family: var(--me-f-data); font-size: 12px; line-height: 1.5; color: var(--me-muted);
}
.motion-explorer .me-stats dt { color: var(--me-muted); margin: 0; }
.motion-explorer .me-stats dd { margin: 0; color: var(--me-ink); font-variant-numeric: tabular-nums; text-align: right; }
.motion-explorer .me-clip-select {
  font-family: var(--me-f-body); font-size: 16px; padding: 10px 12px; margin: 0; min-height: 44px; width: 100%; min-width: 0;
  border-radius: calc(var(--me-radius) * 0.8); border: 1px solid var(--me-line);
  background: var(--me-surface); color: var(--me-ink);
}
.motion-explorer .me-main { display: grid; gap: 14px; min-width: 0; }
.motion-explorer .me-credits {
  color: var(--me-muted); font-size: 13px; line-height: 1.5; max-width: 90ch;
  display: grid; gap: 4px;
}
.motion-explorer .me-credits p { margin: 0; }

.motion-explorer :focus-visible { outline: 2px solid var(--me-focus); outline-offset: 2px; }
.motion-explorer .me-monitor :focus-visible { outline-color: var(--me-stage-ink); }

/* ------------------------------------------------------------------------
 * pgorecki.pl: tokens mapped onto the site's own variables from style.css,
 * so the demo follows the site palette. Font tokens stay undefined, so the
 * component inherits the site fonts (except numbers, which use monospace).
 * --------------------------------------------------------------------- */
.motion-explorer {
  --me-ink: var(--ink, #e8eaf1);
  --me-muted: var(--ink-dim, #9097aa);
  --me-line: var(--border, rgba(255, 255, 255, 0.14));
  --me-surface: var(--bg-card, rgba(255, 255, 255, 0.04));
  --me-accent: var(--accent, #cfd6ff);
  --me-accent-ink: #000;
  --me-stage: #000;
  --me-stage-ink: var(--ink);
  --me-stage-muted: var(--ink-dim);
  --me-focus: var(--accent, #cfd6ff);
  --me-f-data: var(--font-display);
  --me-f-body: var(--font-body);
  --me-radius: 4px;
}

/* Page around the demo, modelled on the panels of /blackhole-simulations. */
.tr-container { max-width: 1240px; }
.tr-page { padding: 60px 0 80px; }
.tr-head { margin-bottom: 40px; max-width: 760px; }
.tr-head-meta { font-size: 13px; color: var(--ink-dim); margin: 0 0 8px; }
.tr-title {
  font-size: clamp(36px, 6vw, 64px); font-weight: 700; letter-spacing: -2px;
  margin: 0 0 12px; line-height: 1;
}
.tr-subtitle { color: var(--ink-dim); font-size: 18px; line-height: 1.6; margin: 0; }
.tr-about {
  margin-top: 56px; display: grid; gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
@media (max-width: 860px) { .tr-about { grid-template-columns: minmax(0, 1fr); } }
.tr-about-item { border: 1px solid var(--border); border-radius: 4px; padding: 20px 22px; }
.tr-about-label {
  display: block; font-size: 11px; color: var(--ink-dim);
  letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 8px;
}
.tr-about-item h2 { font-size: 18px; letter-spacing: -0.3px; margin: 0 0 8px; }
.tr-about-item p { font-size: 14px; line-height: 1.6; color: var(--ink-dim); margin: 0; }
.tr-links { margin-top: 32px; display: flex; justify-content: space-between; align-items: stretch; gap: 16px; }
.tr-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: 10px 18px; border: 1px solid var(--accent); border-radius: 3px;
  color: var(--accent); text-decoration: none; font-size: 13px; transition: background 0.2s, color 0.2s;
}
.tr-link-next { justify-content: flex-end; text-align: right; }
.tr-link:hover { background: var(--accent); color: #000; }
.tr-link.secondary { border-color: var(--border); color: var(--ink-dim); }
.tr-link.secondary:hover { background: transparent; color: var(--ink); border-color: var(--ink-dim); }

/* Comfortable controls and a full-width timeline on narrow screens. */
.motion-explorer .me-panel input[type="range"],
.motion-explorer .me-transport input[type="range"] { min-height: 36px; }
.motion-explorer .me-check { min-height: 44px; }
.motion-explorer .me-credits { overflow-wrap: anywhere; }
.motion-explorer .me-credits a { color: var(--accent); text-underline-offset: 3px; }
@container (max-width: 480px) {
  .motion-explorer .me-transport { gap: 10px; padding: 12px; }
  .motion-explorer .me-transport input[type="range"] { flex: 1 0 100%; order: 1; }
  .motion-explorer .me-clock { order: 2; flex: 1 0 100%; }
  .motion-explorer .me-speed { margin-left: auto; }
  .motion-explorer .me-panel { gap: 24px; }
  .motion-explorer .me-group + .me-group { padding-top: 24px; }
}
@media (max-width: 600px) {
  .tr-page { padding: 36px 0 56px; }
  .tr-head { margin-bottom: 28px; }
  .tr-title { line-height: 1.1; letter-spacing: -1px; }
  .tr-about { margin-top: 36px; }
  .tr-about-item { padding: 20px; }
  .tr-links { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tr-link { min-width: 0; padding: 10px 12px; line-height: 1.5; }
}

/* Keep the footage choice above the image on every screen size. */
.motion-explorer .me-clip-bar {
  display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  align-items: end; gap: 16px 24px; margin-bottom: 20px;
}
.motion-explorer .me-clip-bar .me-note { max-width: 68ch; padding-bottom: 10px; }
.motion-explorer .me-clip-select option { background: #171613; color: var(--me-ink); }
.motion-explorer .me-tbtn:disabled { opacity: 0.4; cursor: default; }
.motion-explorer .me-status { background: var(--me-stage); }
@container (max-width: 600px) {
  .motion-explorer .me-clip-bar { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .motion-explorer .me-clip-bar .me-note { padding-bottom: 0; }
}

.motion-explorer .me-seg button:disabled { opacity: .45; cursor: default; }
.motion-explorer .me-panel input:disabled { opacity: .45; cursor: default; }
