/* System colours rather than a hand-picked palette: the gallery inherits the
   viewer's light/dark preference and the photos stay the only saturated thing
   on the page. */
:root {
  color-scheme: light dark;
  --line: color-mix(in srgb, CanvasText 15%, transparent);
  --sunk: color-mix(in srgb, CanvasText 8%, transparent);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 system-ui, -apple-system, sans-serif;
  background: Canvas;
  color: CanvasText;
}

h1 { font-size: 18px; margin: 0; }
.muted { opacity: .62; }
.error { color: #d33; margin: 0; }
[hidden] { display: none !important; }

/* ---------- sign in ---------- */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  width: min(360px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.card p { margin: -6px 0 4px; }

label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  opacity: .8;
}

input {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: Canvas;
  color: CanvasText;
}

button, .ghost {
  font: inherit;
  cursor: pointer;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--sunk);
  color: CanvasText;
  text-decoration: none;
  text-align: center;
}

button:hover, .ghost:hover { background: color-mix(in srgb, CanvasText 14%, transparent); }
button[disabled] { opacity: .5; cursor: default; }

/* ---------- library ---------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: color-mix(in srgb, Canvas 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.bar-title { flex: 0 0 auto; }

.search {
  flex: 1 1 auto;
  display: flex;
  gap: 8px;
  max-width: 520px;
  margin: 0 auto;
}

.search input {
  flex: 1 1 auto;
  min-width: 0;
  border-radius: 999px;
  padding: 9px 16px;
}

.search button { border-radius: 999px; white-space: nowrap; }

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px 0;
  font-size: 13px;
}

.grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  padding: 20px 24px;
}

/* Search results carry a score; the timeline does not. */
.score {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  backdrop-filter: blur(4px);
}

figure { margin: 0; position: relative; }

figure img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  border-radius: 10px;
  background: var(--sunk);
  cursor: zoom-in;
}

/* Anything not `ready` has no thumbnail to show, so the tile carries the
   status word instead of rendering as a broken image. */
.placeholder {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--sunk);
  display: grid;
  place-items: center;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  opacity: .55;
}

figcaption {
  font-size: 11px;
  opacity: .6;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sentinel { height: 1px; }

.end, .empty {
  text-align: center;
  padding: 24px;
  margin: 0;
}

/* ---------- lightbox ---------- */

.lightbox {
  border: none;
  padding: 0;
  max-width: 100vw;
  max-height: 100dvh;
  width: 100%;
  height: 100%;
  background: #000;
  color: #fff;
  overflow: hidden;
}

.lightbox::backdrop { background: rgba(0, 0, 0, .85); }

#lightbox-image {
  width: 100%;
  height: calc(100dvh - 92px);
  object-fit: contain;
  display: block;
  background: #000;
}

.lightbox-meta {
  height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 10px 18px;
  position: relative;
}

.lightbox .ghost {
  border-color: rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .1);
  color: #fff;
}

.lightbox .ghost:hover { background: rgba(255, 255, 255, .2); }

#download {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
}

.close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 2;
  font-size: 20px;
  line-height: 1;
  padding: 4px 12px;
}

.nav {
  position: absolute;
  top: calc(50dvh - 46px);
  z-index: 2;
  font-size: 28px;
  line-height: 1;
  padding: 6px 16px;
}

.prev { left: 16px; }
.next { right: 16px; }

@media (max-width: 600px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; padding: 12px; }
  #download { position: static; transform: none; margin-top: 6px; align-self: flex-start; }
  .lightbox-meta { height: 120px; }
  #lightbox-image { height: calc(100dvh - 120px); }
}

/* ---------- people ---------- */

.people-grid { padding: 8px 24px 32px; }

.grid-of-people {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.group-heading {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .07em;
  opacity: .55;
  margin: 22px 0 12px;
}

.person { text-align: center; }

/* The face is shown by positioning the photo behind a window, rather than by
   cropping server-side: the box and the thumbnail are both already known, so a
   face crop costs no extra request and no stored derivative. */
.face {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  background-color: var(--sunk);
  background-repeat: no-repeat;
  cursor: pointer;
  border: 2px solid transparent;
}

.person:hover .face { border-color: color-mix(in srgb, CanvasText 30%, transparent); }
.person.merging .face { border-color: #d33; }

.person-name {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: text;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-name.unnamed { font-weight: 400; opacity: .55; font-style: italic; }
.person-count { font-size: 11px; opacity: .55; }

.person-merge {
  margin-top: 6px;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
}

.name-input {
  width: 100%;
  margin-top: 8px;
  font-size: 13px;
  padding: 5px 8px;
  text-align: center;
}

/* Pets sit in the same grid as people — same naming, same merging, so one
   interaction to learn — but a dog is not a face and should not pretend to be.
   Rounded rather than circular, because the crop is a whole animal. */
.person { position: relative; }
.person.pet .face { border-radius: 14px; }

.kind-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 1;
  font-size: 12px;
  line-height: 1;
  padding: 3px 5px;
  border-radius: 999px;
  background: color-mix(in srgb, Canvas 75%, transparent);
  backdrop-filter: blur(4px);
}
