/* MV_SideBySide — two people at the same age, on one screen (#523).

   The two frames stay side by side at every width, phone included. Stacking
   them would be the usual responsive answer and it would destroy the feature:
   the whole point is holding two faces next to each other. At 375px each
   column lands around 150px — small, and still a face. */

/* ---- the panel's entry point -------------------------------------------- */

/* Fourth of the panel heading's quiet italic links, under "Print a memory
   page" — same voice, same stacked medallion treatment (timeline.css). */
.panel__side-by-side-link {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: var(--space-xxs);
  margin-top: var(--space-xxs);
  padding: 2px var(--space-xs);
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--font-size-sm);
  color: var(--color-highlight-deep);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.panel__side-by-side-link:hover,
.panel__side-by-side-link:focus-visible {
  color: var(--color-highlight-deep);
  background-color: var(--color-highlight-soft);
}

@media (hover: none) and (pointer: coarse) {
  .panel__side-by-side-link {
    touch-action: manipulation;
    min-height: var(--touch-target-min);
  }
}

/* ---- the view ----------------------------------------------------------- */

.side-by-side__intro {
  margin: 0 0 var(--space-md);
  color: var(--color-text-muted);
  line-height: 1.55;
}

.side-by-side__controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-sm) var(--space-md);
  align-items: end;
}

.side-by-side__picker {
  min-width: 0;
}

/* The age control spans the pickers above it — it governs both sides. */
.side-by-side__age-control {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-top: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-alt);
}

/* "At 25" — the number is the question being asked, so it reads as heritage
   serif, and tabular so 24 → 25 doesn't shuffle the slider beside it. */
.side-by-side__age-value {
  flex: 0 0 auto;
  min-width: 5.5em;
  font-family: var(--font-serif);
  font-size: var(--font-size-lg);
  color: var(--color-text);
  font-variant-numeric: tabular-nums;
}

/* The same scrub control as the tree's time machine — one slider language. */
.side-by-side__slider {
  flex: 1 1 8rem;
  min-width: 6rem;
  height: var(--touch-target-min);
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

.side-by-side__slider:disabled {
  cursor: default;
  opacity: 0.5;
}

.side-by-side__slider:focus {
  outline: none;
}

.side-by-side__slider::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: var(--color-border-strong);
}

.side-by-side__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 3px solid var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-border-strong), var(--shadow-sm);
}

.side-by-side__slider:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-accent);
}

.side-by-side__slider::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: var(--color-border-strong);
}

.side-by-side__slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 3px solid var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-border-strong), var(--shadow-sm);
}

.side-by-side__slider:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-accent);
}

/* ---- the pair ---------------------------------------------------------- */

/* Five shared rows — frame, name, age, note, swap — so the two captions line
   up whatever happens inside them. Without this a name that wraps on one side
   drops that side's age half a line below the other's, and the two numbers the
   view exists to compare stop reading as a pair. */
.side-by-side__stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto auto auto auto;
  column-gap: var(--space-md);
  row-gap: 0;
  margin-top: var(--space-lg);
}

/* Capped so the pair *and* their captions land on one screen — a portrait
   plate that fills a wide dialog pushes the ages below the fold, and the age
   is the answer the view exists to give. */
.side-by-side__side {
  display: grid;
  grid-template-rows: subgrid;
  grid-row: span 5;
  margin: 0 auto;
  width: 100%;
  max-width: 260px;
  min-width: 0;
  text-align: center;
}

/* The caption's parts take the shared rows themselves. */
.side-by-side__caption {
  display: contents;
}

/* Both frames are one shape and one size — that identity is what makes the
   comparison read as a comparison rather than as two pictures. */
.side-by-side__frame {
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-lg);
  background-color: var(--color-surface-alt);
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 0 0 1px var(--color-border), var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* No photo to show: the initials plate, in the deep-disc voice the avatars
   use — cream serif on a deep warm ground, never a pale watermark. */
.side-by-side__frame--empty {
  background-color: color-mix(in srgb, var(--color-node-fill-personal) 40%, var(--color-accent-deep));
  color: var(--color-surface-elevated);
  font-family: var(--font-serif);
  font-size: var(--font-size-xxl);
  letter-spacing: var(--letter-spacing-wide);
}

/* Nobody picked yet — an invitation, not a hole. */
.side-by-side__side--blank .side-by-side__frame {
  background-color: transparent;
  color: var(--color-text-faint);
  font-family: var(--font-sans);
  font-size: var(--font-size-sm);
  letter-spacing: normal;
  box-shadow: none;
  border: 2px dashed var(--color-border-strong);
}

.side-by-side__name {
  margin: var(--space-sm) 0 0;
  font-family: var(--font-serif);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  overflow-wrap: anywhere;
}

/* The age itself — the answer the view exists to give. */
.side-by-side__age {
  margin: 2px 0 0;
  font-family: var(--font-serif);
  font-size: var(--font-size-lg);
  color: var(--color-accent);
}

.side-by-side__note {
  margin: var(--space-xxs) 0 0;
  font-size: var(--font-size-xs);
  font-style: italic;
  color: var(--color-text-muted);
  line-height: 1.4;
}

/* An empty age or note keeps its (zero-height) row rather than collapsing —
   that is what holds the two sides level when only one of them has a line. */

.side-by-side__swap {
  justify-self: center;
  margin-top: var(--space-xs);
  padding: var(--space-xs) var(--space-xxs);
  border: none;
  background: none;
  color: var(--color-accent);
  font-size: var(--font-size-sm);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  border-radius: var(--radius-sm);
}

.side-by-side__swap:hover {
  color: var(--color-accent-hover);
}

.side-by-side__swap:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ---- the chooser ------------------------------------------------------- */

.side-by-side__strip {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

.side-by-side__strip-title {
  margin: 0 0 var(--space-xs);
  font-family: var(--font-serif);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
}

.side-by-side__thumbs {
  display: flex;
  gap: var(--space-sm);
  overflow-x: auto;
  padding-bottom: var(--space-xs);
  scrollbar-width: thin;
}

.side-by-side__thumb {
  flex: 0 0 auto;
  width: 84px;
  padding: var(--space-xxs);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: none;
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.side-by-side__thumb:hover {
  transform: translateY(-2px);
}

.side-by-side__thumb:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.side-by-side__thumb--current {
  border-color: var(--color-accent);
}

.side-by-side__thumb-image {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-sm);
  background-color: var(--color-surface-alt);
  background-size: cover;
  background-position: center;
  box-shadow: inset 0 0 0 1px var(--color-border);
}

.side-by-side__thumb-age {
  display: block;
  margin-top: var(--space-xxs);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.side-by-side__thumb--current .side-by-side__thumb-age {
  color: var(--color-accent);
  font-weight: var(--font-weight-bold);
}

@media (max-width: 560px) {
  /* The pickers stack; the pair never does. */
  .side-by-side__controls {
    grid-template-columns: 1fr;
  }

  .side-by-side__age-control {
    padding: var(--space-xs) var(--space-sm);
    gap: var(--space-sm);
  }

  .side-by-side__age-value {
    min-width: 4.5em;
    font-size: var(--font-size-base);
  }

  .side-by-side__stage {
    gap: var(--space-sm);
  }

  .side-by-side__frame--empty {
    font-size: var(--font-size-lg);
  }
}

@media (hover: none) and (pointer: coarse) {
  .side-by-side__swap {
    min-height: var(--touch-target-min);
  }

  .side-by-side__thumb {
    width: 96px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .side-by-side__thumb {
    transition: none;
  }

  .side-by-side__thumb:hover {
    transform: none;
  }
}
