/* One height for profile media, upload cropping, and the regular MyDancr TV feed.
 * Leave a small neighboring-card peek without resizing as browser bars collapse. */
:root {
  --dancr-scroll-card-height: clamp(560px, calc(100vh - 80px), 920px);
  --dancr-scroll-card-height: clamp(560px, calc(100svh - 80px), 920px);
}

.profile-media-card-feed {
  --profile-media-card-height: var(--dancr-scroll-card-height);
  --profile-media-card-gap: 16px;
  --profile-media-card-header: calc(72px + env(safe-area-inset-top, 0px));
}

/* Match the photo viewer layer so the video header is not covered by page chrome. */
.profile-tv-viewer.profile-media-card-feed {
  z-index: 1600;
}

/* Keep the demo notice visible without covering the public viewer's close control. */
.public-profile-shell .profile-media-viewer.profile-media-card-feed:not(:is(:fullscreen, :-webkit-full-screen)) {
  top: var(--mydancr-preview-banner-offset, 0px) !important;
  height: calc(100vh - var(--mydancr-preview-banner-offset, 0px)) !important;
  height: calc(100dvh - var(--mydancr-preview-banner-offset, 0px)) !important;
}

.profile-media-card-feed .profile-media-card-header {
  position: relative;
  box-sizing: border-box;
  height: var(--profile-media-card-header);
  display: flex;
  align-items: center;
  padding: env(safe-area-inset-top, 0px) 13px 0;
  background: #000;
}

.profile-media-card-feed .profile-media-card-heading {
  min-width: 0;
  overflow: hidden;
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  line-height: 22px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-media-card-feed :is(.profile-photo-viewer-image, .profile-tv-viewer-stage, .profile-media-viewer-stage) {
  position: relative !important;
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 730px !important;
  height: 100% !important;
  min-height: 0 !important;
  margin-inline: auto !important;
  display: block !important;
  padding: 0 5px 24px !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scroll-padding: 0 !important;
  overflow-anchor: none;
  scroll-snap-type: none !important;
  overscroll-behavior-y: contain;
  touch-action: pan-y !important;
  -webkit-overflow-scrolling: touch;
}

.profile-media-card-feed :is(.profile-photo-viewer-slide, .profile-tv-viewer-slide, .profile-media-viewer-slide) {
  position: relative;
  box-sizing: border-box !important;
  width: 100% !important;
  height: var(--profile-media-card-height) !important;
  min-height: var(--profile-media-card-height) !important;
  max-height: var(--profile-media-card-height) !important;
  margin: 0 0 var(--profile-media-card-gap) !important;
  overflow: hidden;
  border: 0;
  border-radius: 18px !important;
  background: #000;
  box-shadow: 0 14px 32px rgba(0, 0, 0, .38);
  scroll-snap-align: none !important;
  scroll-snap-stop: normal !important;
  isolation: isolate;
}

.profile-media-card-feed :is(.profile-photo-viewer-slide, .profile-tv-viewer-slide, .profile-media-viewer-slide):last-child {
  margin-bottom: 0 !important;
}

/* A quiet, easy-to-tap way back on every individual photo and video. */
body.dancr-button-system :is(#profilePhotoViewer, #profileTvViewer, .profile-media-viewer).profile-media-card-feed .profile-media-card-back {
  position: absolute !important;
  z-index: 5;
  top: calc(16px + env(safe-area-inset-top, 0px)) !important;
  left: max(12px, env(safe-area-inset-left, 0px)) !important;
  width: 44px !important;
  min-width: 44px !important;
  max-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  max-height: 44px !important;
  display: grid;
  place-items: center;
  padding: 0 !important;
  border: 1px solid rgba(255, 255, 255, .14) !important;
  border-radius: 50% !important;
  color: #fff !important;
  background: rgba(8, 8, 12, .3) !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: blur(8px) !important;
  backdrop-filter: blur(8px) !important;
  cursor: pointer;
}

body.dancr-button-system :is(#profilePhotoViewer, #profileTvViewer, .profile-media-viewer).profile-media-card-feed .profile-media-card-back:is(:hover, :focus-visible) {
  background: rgba(8, 8, 12, .55) !important;
  border-color: rgba(255, 255, 255, .4) !important;
}

.profile-media-card-feed .profile-media-card-back:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.profile-media-card-feed .profile-media-card-back svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Photos and videos fill their cards without added side bars. */
.profile-media-card-feed .profile-photo-viewer-slide-image {
  background-color: #000 !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}
.profile-media-card-feed :is(.profile-tv-viewer-slide, .profile-media-viewer-slide) > :is(img, video) {
  object-fit: cover !important;
  object-position: center !important;
  background: #000 !important;
}
/* Uploaded photos are framed for these cards before they enter moderation. */
.profile-media-card-feed [data-profile-photo-card] {
  display: block !important;
  width: 100% !important;
  height: var(--profile-media-card-height) !important;
  min-height: var(--profile-media-card-height) !important;
  max-height: var(--profile-media-card-height) !important;
  aspect-ratio: auto;
}
.profile-media-card-feed [data-profile-photo-card] > :is(img, .profile-photo-viewer-slide-image) {
  position: relative !important;
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: 100% !important;
  aspect-ratio: auto;
}
.profile-media-card-feed video::-webkit-media-controls-fullscreen-button {
  display: none !important;
}

/* Keep photo actions in their own cards; the original nodes are templates only. */
#profilePhotoViewer.profile-media-card-feed [data-profile-photo-control-template] {
  display: none !important;
}

/* A real image stays visible even when iOS does not paint a deferred video's
 * native poster. Only hide it after playback has presented a frame. */
.profile-media-card-feed .profile-media-video-poster {
  position: absolute !important;
  z-index: 2 !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  opacity: 1 !important;
  filter: none !important;
  transition: none !important;
  pointer-events: none;
}

.profile-media-card-feed video[data-frame-ready="true"] + .profile-media-video-poster {
  visibility: hidden;
}

.profile-media-card-feed .profile-media-video-poster:not([src]) {
  display: none !important;
}
.profile-media-card-feed .profile-media-viewer-sound {
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50% !important;
  color: #fff !important;
}
.profile-media-viewer-sound svg {
  display: block;
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Match the regular TV action material in every profile entry point. The
 * existing overlay/control IDs keep this layer above global utility styles. */
body.dancr-button-system :is(#profilePhotoViewer, #profileTvViewer, .profile-media-viewer).profile-media-card-feed :is(
  .profile-photo-viewer-previous,
  .profile-photo-viewer-next,
  .profile-photo-viewer-actions > button,
  .profile-tv-viewer-previous,
  .profile-tv-viewer-next,
  .profile-tv-viewer-actions > button,
  .profile-media-viewer-previous,
  .profile-media-viewer-next,
  .profile-media-viewer-actions > button
) {
  border: 1px solid rgba(255, 255, 255, 0.28) !important;
  border-radius: 50% !important;
  color: var(--dancr-color-text-primary) !important;
  background-color: rgba(18, 18, 28, 0.38) !important;
  background-image: linear-gradient(155deg, rgba(255, 255, 255, 0.17), rgba(255, 255, 255, 0.035)) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04),
    0 8px 22px rgba(0, 0, 0, 0.3) !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  -webkit-backdrop-filter: blur(16px) saturate(1.18) !important;
  backdrop-filter: blur(16px) saturate(1.18) !important;
}

body.dancr-button-system :is(#profilePhotoViewer, #profileTvViewer, .profile-media-viewer).profile-media-card-feed :is(
  .profile-photo-viewer-previous,
  .profile-photo-viewer-next,
  .profile-photo-viewer-actions > button,
  .profile-tv-viewer-previous,
  .profile-tv-viewer-next,
  .profile-tv-viewer-actions > button,
  .profile-media-viewer-previous,
  .profile-media-viewer-next,
  .profile-media-viewer-actions > button
):is(:hover, :focus-visible) {
  border-color: rgba(255, 255, 255, 0.42) !important;
  background-color: rgba(28, 28, 40, 0.48) !important;
  background-image: linear-gradient(155deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05)) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 0 0 2px rgba(126, 234, 255, 0.12),
    0 10px 24px rgba(0, 0, 0, 0.34) !important;
}

/* Controls stay attached to their cards, not the viewport. */
.profile-media-card-feed :is(.profile-photo-viewer-slide, .profile-tv-viewer-slide, .profile-media-viewer-slide) {
  position: relative;
}

.profile-media-card-feed :is(.profile-photo-viewer-footer, .profile-tv-viewer-footer, .profile-media-viewer-footer) {
  position: absolute !important;
  z-index: 3;
  inset: 0 !important;
  display: block !important;
  min-height: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  pointer-events: none;
}

.profile-media-card-feed :is(.profile-photo-viewer-actions, .profile-tv-viewer-actions, .profile-media-viewer-actions) {
  position: absolute !important;
  right: 9px !important;
  bottom: 18px !important;
  width: 46px !important;
  min-width: 46px !important;
  max-width: 46px !important;
  display: grid !important;
  grid-template-columns: 46px !important;
  gap: 6px !important;
  pointer-events: auto;
}

/* Keep identity and position readable without covering the photo or video. */
.profile-media-card-feed :is(.profile-photo-viewer-copy, .profile-tv-viewer-copy, .profile-media-viewer-copy) {
  position: absolute;
  right: 70px;
  bottom: max(22px, calc(env(safe-area-inset-bottom, 0px) + 14px));
  left: max(16px, env(safe-area-inset-left, 0px));
  min-width: 0;
  display: grid;
  gap: 3px;
  color: #fff;
  text-shadow: 0 1px 3px #000, 0 2px 8px rgba(0, 0, 0, .92);
}

.profile-media-card-feed :is(.profile-photo-viewer-copy, .profile-tv-viewer-copy, .profile-media-viewer-copy) strong {
  overflow: hidden;
  color: #fff;
  font-size: 16px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-media-card-feed .profile-media-viewer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 3px 10px;
  font-size: 12px;
  line-height: 1.4;
}

.profile-media-card-feed .profile-media-viewer-meta .profile-media-position {
  color: rgba(255, 255, 255, .85);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.profile-media-card-feed :is(.profile-photo-viewer-status, #profileTvViewerStatus, .profile-media-viewer-share-status) {
  position: absolute !important;
  right: 56px !important;
  bottom: 4px !important;
  width: max-content !important;
  max-width: min(200px, calc(100vw - 100px));
  pointer-events: none;
}

.profile-media-card-feed :is(.profile-photo-viewer-actions, .profile-tv-viewer-actions, .profile-media-viewer-actions) > button {
  box-sizing: border-box !important;
  width: 46px !important;
  min-width: 46px !important;
  max-width: 46px !important;
  height: 46px !important;
  min-height: 46px !important;
  max-height: 46px !important;
}

.profile-media-card-feed :is(.profile-photo-viewer-previous, .profile-photo-viewer-next, .profile-tv-viewer-previous, .profile-tv-viewer-next, .profile-media-viewer-previous, .profile-media-viewer-next) {
  position: absolute !important;
  z-index: 4;
  left: auto !important;
  right: 9px !important;
}

.profile-media-card-feed :is(.profile-photo-viewer-previous, .profile-tv-viewer-previous, .profile-media-viewer-previous) {
  top: 16px !important;
}

.profile-media-card-feed :is(.profile-photo-viewer-next, .profile-tv-viewer-next, .profile-media-viewer-next) {
  top: 70px !important;
}

.profile-media-card-feed :is(.profile-photo-viewer-previous, .profile-photo-viewer-next, .profile-tv-viewer-previous, .profile-tv-viewer-next, .profile-media-viewer-previous, .profile-media-viewer-next) {
  width: 46px !important;
  height: 46px !important;
  transform: none !important;
}

@media (max-width: 720px) {
  :root {
    --dancr-scroll-card-height: clamp(520px, calc(100vh - 64px), 1040px);
    --dancr-scroll-card-height: clamp(520px, calc(100svh - 64px), 1040px);
  }

  .profile-media-card-feed {
    --profile-media-card-gap: 12px;
  }
}
