/* ============================================================
   Settings -- shared with ruben dumka's personal site: pale blue
   paper, near-black ink, Futura. No radii, no shadows, no accent
   hue; underlines do the work buttons usually do, so nothing
   competes with the photographs.
   ============================================================ */
:root {
  /* Colors */
  --color-text: #111111;
  --color-text-dim: #4a4f59;
  --color-text-faint: #7d8494;
  --color-page: #ECF2FF;      /* main background, and the 3D stage */
  --color-sidebar: #E5EDFB;   /* results column and floating panels */
  --color-border: #D9DBDF;
  --color-photo: #DCE4F3;     /* behind a photo while it loads */

  /* Fonts */
  --font-display: "Futura-CondensedExtraBold", "Futura Condensed ExtraBold", "Futura", "Jost", system-ui, sans-serif;
  --font-body: "Futura-Medium", "Futura", "Jost", system-ui, sans-serif;

  /* Sizes */
  --title-size: 76px;
  --action-size: 24px;
  --body-size: 15px;
  --small-size: 13px;
  --tiny-size: 12px;

  /* Layout */
}

/* ============================================================
   Base
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  background: var(--color-page);
  color: var(--color-text);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--body-size);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ============================================================
   Controls -- text with underlines, not boxes
   ============================================================ */
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  text-align: left;
}

button:hover {
  text-decoration: underline;
}

button:disabled {
  color: var(--color-text-faint);
  cursor: default;
  text-decoration: none;
}

/* The selected item in a list: underlined, the way the site marks its email */
.chip.on,
.joint-grid button.on {
  text-decoration: underline 2px;
  text-underline-offset: 3px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  margin: 0;
  accent-color: var(--color-text);
}

.switch.tiny,
.numfield {
  font-size: var(--small-size);
}

.numfield {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

select {
  font: inherit;
  color: var(--color-text);
  background: var(--color-page);
  border: 1px solid var(--color-border);
  border-radius: 0;
  padding: 1px 4px;
}

/* ============================================================
   Title -- laid over the top-left corner of the 3D stage
   ============================================================ */
#viewport h1 {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  margin: 0;
  /* Pulls the letters flush into the top-left corner */
  margin-top: 10px;
  margin-left: 20px;   /* lines the title up with the menus below */
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: condensed;
  font-size: var(--title-size);
  line-height: 56px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  pointer-events: none;   /* drags on the title still orbit the camera */
  user-select: none;
}

/* ============================================================
   Layout: the stage fills the first screen; matches follow
   below it, full width, as the rest of the page.
   ============================================================ */
.stage {
  position: relative;
  height: 100vh;
  height: 100svh;      /* phones: the height without the browser chrome */
  min-height: 560px;
  display: flex;
  flex-direction: column;
  /* Menu panels open over the stage; keep them above the results. */
  z-index: 2;
}

#viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#viewport canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;   /* the canvas handles its own gestures */
}

/* ============================================================
   Dock under the figure: one line of menus, then the search
   ============================================================ */
.dock {
  flex: 0 0 auto;
  padding: 0 24px 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}

/* The one solid object on the page, so there is no doubt where to press. */
button.primary {
  padding: 12px 22px 11px;
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: condensed;
  font-size: var(--action-size);
  line-height: 26px;
  letter-spacing: 0.005em;
  color: var(--color-page);
  background: var(--color-text);
  text-decoration: none;
}

button.primary::after {
  content: "  \2192";
}

button.primary:hover {
  background: #2c2f36;
  text-decoration: none;
}

button.primary:disabled {
  color: var(--color-page);
  background: var(--color-text-faint);
}

.menubar {
  /* Panels are placed against the bar, not their own menu, so every one
     opens from the same left edge whichever word was clicked. */
  position: relative;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px 32px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}

.menu summary {
  display: block;
  cursor: pointer;
  list-style: none;
  user-select: none;
  color: var(--color-text-dim);
  white-space: nowrap;
}

.menu summary::-webkit-details-marker {
  display: none;
}

.menu summary::after {
  content: " +";
  color: var(--color-text-dim);
}

.menu[open] summary::after {
  content: " \2212";
}

.menu-value {
  margin-left: 4px;
  color: var(--color-text);
}

.menu summary:hover .menu-value,
.menu[open] .menu-value {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.menu-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 12px);
  z-index: 5;
  width: min(420px, calc(100vw - 32px));
  padding: 16px 18px;
  background: var(--color-sidebar);
  border: 1px solid var(--color-border);
}

.menu-note {
  margin: 0 0 8px;
  font-size: var(--tiny-size);
  color: var(--color-text-faint);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.chip {
  line-height: 22px;
}

.joint-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 12px;
  margin-bottom: 12px;
}

.joint-grid button {
  font-size: var(--small-size);
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.joint-grid button.body {
  grid-column: 1 / -1;
}

.viewpoint {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.vp-readout {
  display: flex;
  gap: 24px;
}

.vp-readout div {
  display: flex;
  flex-direction: column;
}

.vp-readout b {
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: condensed;
  font-size: 30px;
  line-height: 30px;
  font-variant-numeric: tabular-nums;
}

.vp-readout span {
  font-size: var(--tiny-size);
  color: var(--color-text-dim);
}

.slider {
  display: block;
  font-size: var(--small-size);
}

.slider b {
  font-weight: 500;
}

.slider input {
  width: 100%;
  margin-top: 4px;
  accent-color: var(--color-text);
}

.slider[hidden] {
  display: none;
}

/* ============================================================
   Results -- styled as the site's sidebar, laid out below
   ============================================================ */
.results {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-sidebar);
  border-top: 1px solid var(--color-border);
}

.results-head {
  padding: 24px 24px 6px;
}

.results-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: condensed;
  font-size: 40px;
  line-height: 36px;
  letter-spacing: -0.005em;
}

.results-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 8px 24px 16px;
  border-bottom: 1px solid var(--color-border);
}

.result-grid {
  padding: 20px 24px;
  display: grid;
  gap: 18px 14px;
  /* Auto-fill rather than a fixed two columns: cards are as tall as their
     pose is, so the column has to stay narrow however wide the pane gets. */
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  align-content: start;
  /* Cards keep their own height rather than stretching to the tallest in
     the row -- their height is the point. */
  align-items: start;
  /* `overflow: hidden` on the cards makes them scroll containers, whose
     automatic minimum size collapses `auto` rows; size rows explicitly. */
  grid-auto-rows: max-content;
}

/* ============================================================
   Result cards
   ============================================================ */
.card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--color-page);
  border: 1px solid var(--color-border);
  /* `--ar` is the pose's frame shape, set per card. Capping the width caps
     the height without distorting that shape. */
  width: min(100%, calc(var(--ar, 1) * 420px));
  margin-inline: auto;
}

/* The card takes the shape of the pose it is showing; `aspect-ratio` is
   set per card from the matched person's own proportions. */
.card .thumb {
  position: relative;
  flex: 0 0 auto;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--color-photo);
}

.card .shot {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.card .shot.mirrored {
  transform: scaleX(-1);
}

.card .shot img {
  position: absolute;
  display: block;
  max-width: none;
  max-height: none;
  background: var(--color-photo);
}

/* Photos arrive one or two at a time; until then the card is a quiet block. */
.card .shot img:not(.loaded) {
  visibility: hidden;
}

/* Wikimedia kept refusing this one; say so rather than leave a blank. */
.card .thumb.failed::after {
  content: "Photo unavailable";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--tiny-size);
  color: var(--color-text-faint);
}

/* Records written before the person's box was stored: show the whole frame. */
.card .thumb.nocrop .shot img {
  position: static;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card .stick {
  position: absolute;
  right: 5px;
  bottom: 5px;
  padding: 2px;
  background: rgba(236, 242, 255, 0.86);
}

.card .stick.mirrored {
  transform: scaleX(-1);
}

.card .badges {
  position: absolute;
  left: 5px;
  top: 5px;
  display: flex;
  gap: 4px;
}

.badge {
  padding: 1px 6px;
  font-size: var(--tiny-size);
  line-height: 18px;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
  background: rgba(236, 242, 255, 0.9);
}

.badge.view,
.badge.mir {
  color: var(--color-text-dim);
}

.card .body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px 10px;
}

.card .title {
  font-size: var(--small-size);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .credit {
  font-size: var(--tiny-size);
  line-height: 1.4;
  color: var(--color-text-faint);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .credit a {
  color: var(--color-text-dim);
}

.card .row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 4px;
  font-size: var(--small-size);
}

.card .row button,
.card .row a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.card .row button:hover,
.card .row a:hover {
  text-decoration-thickness: 2px;
}

.colophon {
  margin-top: auto;
  padding: 18px 24px 26px;
  border-top: 1px solid var(--color-border);
  font-size: var(--tiny-size);
  line-height: 1.55;
  color: var(--color-text-dim);
}

.colophon h3 {
  margin: 0 0 6px;
  font-size: var(--small-size);
  font-weight: 500;
  color: var(--color-text);
}

.colophon p {
  margin: 0 0 8px;
}

.colophon p[hidden] {
  display: none;
}

.colophon a {
  color: var(--color-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.empty {
  grid-column: 1 / -1;
  padding: 28px 8px;
  text-align: center;
  font-size: var(--small-size);
  line-height: 1.7;
  color: var(--color-text-dim);
}

.empty code {
  padding: 2px 6px;
  font-size: var(--tiny-size);
  background: var(--color-page);
  border: 1px solid var(--color-border);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  translate: -50% 0;
  z-index: 50;
  padding: 8px 16px;
  font-size: var(--small-size);
  color: var(--color-page);
  background: var(--color-text);
}

.toast[hidden] {
  display: none;
}

/* ============================================================
   Phones & small screens
   ============================================================ */
@media (max-width: 760px) {
  :root {
    --title-size: 46px;
    --action-size: 20px;
  }

  #viewport h1 {
    margin-top: 6px;
    margin-left: 13px;
    line-height: 36px;
  }

  button.primary {
    width: 100%;
    line-height: 22px;
  }

  .dock {
    padding: 0 16px 18px;
  }

  .menubar {
    gap: 6px 20px;
  }

  .results-head,
  .results-controls,
  .result-grid,
  .colophon {
    padding-left: 16px;
    padding-right: 16px;
  }

  .result-grid {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
  }
}
