/*
 * Compact face comparison (morph canvas + slider) for the result and profile
 * pages. Loaded after redesign.css, so equal-specificity rules here win, and
 * scoped to .unified-comparison--compact so the compare page is untouched.
 * The card's first .side-photo is the left end of the slider, its last the right.
 */

/* Slider track ------------------------------------------------------------ */
/* redesign.css clears the range background, which hides the track entirely. */

.unified-comparison--compact .morph-slider {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 4px 0;
}

.unified-comparison--compact .morph-slider::-webkit-slider-runnable-track {
  box-sizing: border-box;
  height: 12px;
  border: 2px solid var(--fk-ink);
  border-radius: 999px;
  background: var(--fk-bg-2);
}

.unified-comparison--compact .morph-slider::-moz-range-track {
  box-sizing: border-box;
  height: 12px;
  border: 2px solid var(--fk-ink);
  border-radius: 999px;
  background: var(--fk-bg-2);
}

.unified-comparison--compact .morph-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 26px;
  height: 26px;
  margin-top: -9px;
  border: 2px solid var(--fk-ink);
  border-radius: 50%;
  background: var(--fk-hot);
  box-shadow: 2px 2px 0 var(--fk-ink);
}

.unified-comparison--compact .morph-slider::-moz-range-thumb {
  box-sizing: border-box;
  width: 26px;
  height: 26px;
  border: 2px solid var(--fk-ink);
  border-radius: 50%;
  background: var(--fk-hot);
  box-shadow: 2px 2px 0 var(--fk-ink);
}

/* Tablet: keep the three columns instead of stacking full-width photos. ---- */

@media (min-width: 781px) and (max-width: 1020px) {
  .unified-comparison.unified-comparison--compact {
    grid-template-columns: minmax(0, 0.7fr) minmax(260px, 1.3fr) minmax(0, 0.7fr);
    gap: 16px;
    padding: 18px;
  }
}

/* Phone: one compact card ---------------------------------------------------
 *   [        morph canvas  (score) ]
 *   [me] ━━━━━━━ slider ━━━━━━━ [star]
 *   [ compare-with select ][Transform]
 *   [ video / premium actions        ]
 */

@media (max-width: 780px) {
  .unified-comparison.unified-comparison--compact {
    --morph-size: clamp(200px, 62vw, 248px);
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto 48px !important;
    grid-template-areas:
      "canvas canvas canvas canvas"
      "me slider slider star"
      "select select play play";
    align-items: center;
    gap: 8px;
    margin: 10px auto 24px;
    padding: 12px;
  }

  /* Flatten the wrappers so their children sit on the card grid. */
  .unified-comparison--compact .morph-center,
  .unified-comparison--compact .morph-controls {
    display: contents;
  }

  .unified-comparison--compact .morph-container {
    grid-area: canvas;
    justify-self: center;
    margin: 0;
    border: 0;
    box-shadow: none;
  }

  .unified-comparison--compact .morph-container,
  .unified-comparison--compact .morph-container canvas {
    width: var(--morph-size) !important;
  }

  .unified-comparison--compact .morph-arrows {
    display: none;
  }

  /* Score chip rides on the canvas' top-right corner. */
  .unified-comparison--compact .match-info-badge {
    grid-area: canvas;
    align-self: start;
    justify-self: end;
    z-index: 3;
    margin: 8px calc((100% - var(--morph-size)) / 2 + 8px) 0 0;
    padding: 4px 10px;
    gap: 4px;
    box-shadow: 2px 2px 0 var(--fk-ink);
    pointer-events: none;
  }

  .unified-comparison--compact .match-info-badge .percentage {
    font-size: 15px;
  }

  .unified-comparison--compact .match-info-badge .label {
    font-size: 10px;
  }

  /* Both photos shrink to avatars at the slider ends. */
  .unified-comparison--compact .side-photo:first-child {
    grid-area: me;
  }

  .unified-comparison--compact .side-photo:last-child {
    grid-area: star;
  }

  .unified-comparison--compact .side-photo {
    display: flex;
    align-self: center;
    align-items: center;
    justify-content: center;
    gap: 0;
  }

  .unified-comparison--compact .side-photo-label,
  .unified-comparison--compact .side-photo-name,
  .unified-comparison--compact .side-photo-group,
  .unified-comparison--compact .side-photo > a:nth-of-type(2) {
    display: none !important;
  }

  .unified-comparison--compact .side-photo > a {
    min-height: 0;
    width: auto;
  }

  .unified-comparison--compact .side-photo-img {
    width: 48px !important;
    height: 48px !important;
    border-radius: 50% !important;
    box-shadow: 2px 2px 0 var(--fk-ink) !important;
  }

  .unified-comparison--compact .side-photo-img:hover {
    transform: none;
  }

  .unified-comparison--compact .morph-slider-container {
    grid-area: slider;
    width: 100%;
    max-width: none;
  }

  /* The avatars already say who is on which end. */
  .unified-comparison--compact .morph-slider-labels {
    display: none;
  }

  .unified-comparison--compact .morph-slider {
    margin: 0;
  }

  .unified-comparison--compact .celebrity-selector-container {
    grid-area: select;
    width: auto;
    max-width: none;
    min-width: 0;
    margin: 0;
  }

  .unified-comparison--compact .selector-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .unified-comparison--compact .celebrity-selector {
    min-height: 44px;
    padding: 8px 32px 8px 12px;
    background-position: right 10px center;
    /* 16px keeps iOS Safari from zooming in when the select gets focus. */
    font-size: 16px;
    text-overflow: ellipsis;
  }

  .unified-comparison--compact .play-btn {
    grid-area: play;
    gap: 4px;
    min-height: 44px;
    margin: 0;
    padding: 0 12px !important;
    font-size: 15px !important;
    white-space: nowrap;
  }

  .unified-comparison--compact .video-action-stack,
  .unified-comparison--compact .premium-export-card {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 4px;
  }

  .unified-comparison--compact .video-action-stack {
    gap: 8px;
    padding: 0;
  }

  .unified-comparison--compact .beamcue-video-note {
    font-size: 12px;
    line-height: 1.4;
  }
}
