/* Self-hosted so the pages do not wait on fonts.googleapis.com, which does not
   answer from mainland China. Latin only: the Chinese runs on the system's own
   face (PingFang, Microsoft YaHei, Noto Sans CJK), which is what a Chinese
   reader expects and what costs nothing to download. */

@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/fonts/source-serif-4-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: "Libre Franklin";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("/fonts/libre-franklin-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ------------------------------------------------------------------ gate */

.gate { max-width: 560px; }
.gate .field:first-child { margin-top: 0; }
.gate .field label { font-size: var(--t-body); font-weight: 500; color: var(--ink); }
.gate .field :is(input) { height: 48px; font-size: var(--t-body); }
.gate .btn-row { margin-top: var(--s-2); }
.gate .btn { height: 48px; }
.gate .form__status { min-height: 1.6em; }

@media (min-width: 640px) {
  .gate { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ archive */

/* the lift of a plate: a hairline that darkens, and the photograph inside its
   mask — the kit's own hover, no tilt, no growth of the box */
.plate {
  display: block;
  position: relative;
  border: 0;
  padding: 0;
  background: var(--surface);
  border-radius: var(--r-md);
  overflow: clip;
  aspect-ratio: var(--plate-ratio, 4 / 3);
  cursor: zoom-in;
  text-align: left;
  color: inherit;
  width: 100%;
}
.plate > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 600ms var(--ease), filter 300ms var(--ease);
  background: var(--surface);
}
@media (hover: hover) and (pointer: fine) {
  .plate:hover > img { transform: scale(1.03); }
}
.plate:focus-visible { outline: 2px solid var(--action); outline-offset: 3px; }

/* the chosen state: a ring in the accent, and the tick in its corner */
.plate[data-picked] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent); }
.plate__tick {
  position: absolute;
  top: var(--s-3);
  left: var(--s-3);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in oklab, var(--bg) 82%, transparent);
  border: 1px solid color-mix(in oklab, var(--ink) 26%, transparent);
  color: transparent;
  transition: background 180ms var(--ease), border-color 180ms var(--ease), color 180ms var(--ease);
}
.plate[data-picked] .plate__tick {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.plate__tick svg { width: 14px; height: 14px; }

/* a video's own badge: the length in the corner, and a play mark in the middle */
.plate__play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.plate__play svg {
  width: 44px;
  height: 44px;
  color: var(--p-bg);
  filter: drop-shadow(0 1px 6px rgb(0 0 0 / .45));
}
.plate__len {
  position: absolute;
  right: var(--s-3);
  bottom: var(--s-3);
  font: 500 var(--t-label)/1 var(--font-text);
  font-variant-numeric: tabular-nums;
  color: var(--p-bg);
  background: color-mix(in oklab, #29251e 70%, transparent);
  padding: 6px 8px;
  border-radius: var(--r-sm);
}

/* the wall: from line to line, gap 2px, one ratio, no captions */
.wall {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 2px;
}
.wall .plate { border-radius: 0; }
.wall .plate__tick { top: var(--s-2); left: var(--s-2); width: 22px; height: 22px; }
@media (max-width: 1023px) { .wall { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 639px) { .wall { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* the bar that carries the count and the two actions */
.pickbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3) var(--s-5);
  padding: var(--s-3) 0;
}
.pickbar__count { font-variant-numeric: tabular-nums; font-weight: 500; }
.pickbar__spacer { flex: 1 1 auto; }

/* fixed at the phone's foot only: on a desktop the panel is always in view */
.pickbar-fixed { display: none; }
@media (max-width: 1023px) {
  .pickbar-fixed {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 45;
    background: var(--bg);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -1px 0 color-mix(in oklab, var(--ink) 6%, transparent);
  }
  .pickbar-fixed[hidden] { display: none; }
  :root:has(.pickbar-fixed:not([hidden])) { --bar: 68px; }
}

/* ------------------------------------------------------------------ the viewer */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  grid-template-rows: auto 1fr auto;
  background: color-mix(in oklab, #1c1913 92%, transparent);
  color: var(--p-inv-ink);
  backdrop-filter: blur(6px);
}
.viewer[data-open] { display: grid; }
.viewer__bar {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  min-height: 56px;
}
.viewer__name {
  font-size: var(--t-small);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: color-mix(in oklab, var(--p-inv-ink) 78%, transparent);
}
.viewer__spacer { flex: 1 1 auto; }
.viewer__stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0 var(--s-5);
}
.viewer__stage > img,
.viewer__stage > video {
  max-width: 100%;
  max-height: 100%;
  display: block;
  border-radius: var(--r-sm);
  background: #000;
}
.viewer__nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5) var(--s-5);
}
.iconbtn {
  appearance: none;
  border: 1px solid color-mix(in oklab, currentColor 34%, transparent);
  background: transparent;
  color: inherit;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 180ms var(--ease), border-color 180ms var(--ease);
}
.iconbtn:hover { background: color-mix(in oklab, currentColor 12%, transparent); border-color: color-mix(in oklab, currentColor 58%, transparent); }
.iconbtn:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn[disabled] { opacity: .35; cursor: default; }

/* ------------------------------------------------------------------ the download panel */

.panel-dl {
  background: var(--surface);
  padding: var(--s-6);
  border-radius: var(--r-md);
}
@media (min-width: 640px) { .panel-dl { padding: var(--s-7); } }
.panel-dl__rows { display: grid; gap: var(--s-3); font-variant-numeric: tabular-nums; }
.panel-dl__row { display: flex; justify-content: space-between; gap: var(--s-4); font-size: var(--t-small); }
.panel-dl__row strong { font-weight: 500; }
.meter { height: 6px; border-radius: 999px; background: color-mix(in oklab, var(--ink) 12%, transparent); overflow: clip; }
.meter > i { display: block; height: 100%; width: 0; background: var(--action); border-radius: inherit; transition: width 200ms linear; }

/* ------------------------------------------------------------------ misc */

.t-num { font-variant-numeric: tabular-nums; }
.sticky-note {
  font-size: var(--t-small);
  color: var(--muted);
  max-width: 56ch;
}

@media (prefers-reduced-motion: reduce) {
  .plate > img { transition: none; }
  .viewer { backdrop-filter: none; }
}
/* a photograph in a frame: the frame sets the ratio with --ratio, the picture fills it */
.mrc-frame { overflow: clip; border-radius: var(--r-lg); background: var(--surface); }
.mrc-frame > img { position: absolute; inset: 0; width: 100%; height: 100%; max-width: none; object-fit: cover; display: block; }
