/* /photos — a quiet dark gallery with a camera-playback heads-up display. One typeface (DM Mono), the photos do the talking. */

@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('/assets/fonts/dm-mono-300.woff2') format('woff2');
}

@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/dm-mono-400.woff2') format('woff2');
}

:root {
  --bg: #0a0a0a;
  --fg: #ededed;
  --dim: #8a8a8a;
  --mute: #555;
  --line: #1c1c1c;
  --mono: 'DM Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --hud-h: 48px;
  --pad: 24px; /* inset of the top bar and footer text */
  --gap: 8px; /* gutter between photos, and from the window edge */
  --hero-max: 92vh; /* a featured portrait never grows taller than the screen */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  font: 400 12px/1.6 var(--mono);
  letter-spacing: 0.01em;
  color: var(--dim);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}

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

::selection {
  background: #2a2a2a;
  color: #fff;
}

:focus-visible {
  outline: 1px solid var(--fg);
  outline-offset: 3px;
}

button {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ---------- ambient backdrop (desktop hover) ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.backdrop-img {
  position: absolute;
  inset: -48px;
  background: center / cover no-repeat;
  opacity: 0;
  transition: opacity 0.9s ease;
  filter: blur(9px) brightness(0.3) saturate(0.9);
}

.backdrop-img.on {
  opacity: 1;
}

/* keeps the very edges and the type legible on top of the dimmed photo */
.backdrop::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(10, 10, 10, 0.5), rgba(10, 10, 10, 0.2) 30%, rgba(10, 10, 10, 0.2) 70%, rgba(10, 10, 10, 0.55));
}

main,
.foot {
  position: relative;
  z-index: 1;
}

/* ---------- heads-up display ---------- */

.hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: calc(var(--hud-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) var(--pad) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(10, 10, 10, 0.96) 0%, rgba(10, 10, 10, 0.8) 55%, rgba(10, 10, 10, 0) 100%);
}

.hud-name {
  color: var(--fg);
  white-space: nowrap;
  pointer-events: auto;
  padding: 10px 0;
  transition: color 0.2s;
}

.hud-name:hover {
  color: var(--dim);
}

/* tags: "photos" is everything, then one link per tag; the current one is bright */
.hud-tags {
  display: flex;
  align-items: baseline;
  gap: 14px;
  white-space: nowrap;
  pointer-events: auto;
}

.hud-title {
  margin: 0;
  font: inherit;
  letter-spacing: inherit;
}

.hud-tags a {
  color: var(--dim);
  padding: 10px 0;
  transition: color 0.2s;
}

.hud-tags a:hover,
.hud-tags a.is-active {
  color: var(--fg);
}

.hud-osd {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-left: auto;
  white-space: nowrap;
  color: #a3a3a3;
  font-variant-numeric: tabular-nums;
}

.hud-n {
  color: var(--fg);
}

.hud-loc {
  color: var(--fg);
  max-width: 44vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-loc:empty,
.hud-cam:empty,
.hud-exp:empty {
  display: none;
}

/* ---------- grid: the whole page, edge to edge ---------- */

main {
  padding-top: calc(var(--hud-h) + env(safe-area-inset-top, 0px) + var(--gap));
}

.grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  padding: 0 var(--gap);
}

/* A curated layout on every screen: featured photos take a full row, the rest go in pairs (a final triple if the
   count is odd). Each photo carries its row size (--n) and its share of the row (--f, proportional to its aspect
   ratio), so rows fill the width exactly, share one height, and the grid always ends flush. */
.ph {
  position: relative;
  margin: 0;
  min-width: 0;
  flex: var(--ar) 0 calc((100% - (var(--n) - 1) * var(--gap)) * var(--f));
  aspect-ratio: var(--asp);
  overflow: hidden;
  background: #151515;
}

/* on phones a stack is just its two photos side by side */
.stack {
  display: contents;
}

/* blurred placeholder while the real file loads */
.ph::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--ph) center / cover no-repeat;
  filter: blur(14px);
  transform: scale(1.12);
}

.ph-link {
  position: absolute;
  inset: 0;
  display: block;
}

.ph img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focus, 50% 50%);
}

.js .ph img {
  opacity: 0;
  transition: opacity 0.6s ease;
}

.js .ph.loaded img {
  opacity: 1;
}

.ph-link:focus-visible {
  outline-offset: -3px;
}

/* ---------- footer ---------- */

.foot {
  padding: 28px var(--pad) calc(24px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--mute);
  font-variant-numeric: tabular-nums;
}

/* ---------- visitor stats (only on /photos?stats) ---------- */

.stats {
  margin: 48px 0 0;
  padding: 0 var(--pad);
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.stats h2 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 400;
  color: var(--fg);
}

.stats-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.stats-row b {
  font-weight: 400;
  color: var(--fg);
}

.stats table {
  border-collapse: collapse;
  margin: 0 0 24px;
}

.stats td {
  padding: 2px 24px 2px 0;
  vertical-align: baseline;
  white-space: nowrap;
}

.stats td:last-child {
  color: var(--fg);
}

.stats .bar {
  display: inline-block;
  height: 8px;
  background: #333;
  vertical-align: middle;
  margin-right: 8px;
}

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

.lb {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  background: #050505;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.lb[hidden] {
  display: none;
}

.lb:focus,
.lb:focus-visible {
  outline: none; /* focus lands here when the viewer opens; the ring belongs on the buttons when tabbing */
}

.lb-bar {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 20px;
  min-height: var(--hud-h);
  padding: 0 var(--pad);
}

.lb-top {
  padding-top: env(safe-area-inset-top, 0px);
}

.lb-n {
  color: var(--fg);
}

.lb-btn {
  color: var(--fg);
  padding: 12px;
  margin-left: -12px; /* keeps the label on the page's text inset while the hit area and focus ring stay centred */
}

.lb-btn:hover {
  color: var(--dim);
}

.lb-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--pad);
}

.lb-stage img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transition: opacity 0.25s ease;
}

.lb.loading .lb-stage img {
  opacity: 0.35;
}

.lb-bot {
  justify-content: flex-start;
  flex-wrap: wrap;
  padding-top: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.lb-title,
.lb-where {
  color: var(--fg);
}

.lb-where:empty {
  display: none;
}

.lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  padding: 24px 20px;
  color: var(--dim);
  font-size: 16px;
  z-index: 2;
}

.lb-nav:hover {
  color: var(--fg);
}

.lb-prev {
  left: 4px;
}

.lb-next {
  right: 4px;
}

body.lb-open {
  position: fixed;
  left: 0;
  right: 0;
  overflow: hidden;
}

/* ---------- responsive ---------- */

@media (min-width: 641px) {
  /* a featured portrait shares its row with the pair next to it: the pair stacked on the left, the portrait shown
     whole and tall on the right; the stack stretches to the portrait's height, each photo taking its natural share.
     --od is the desktop order (same as the phone order except the stacked pair moves in front of its portrait) */
  .grid > * {
    order: var(--od, 0);
  }

  .ph {
    flex-basis: calc((100% - (var(--nd, var(--n)) - 1) * var(--gap)) * var(--fd, var(--f)));
  }

  .stack {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    min-width: 0;
    flex: var(--ar) 0 calc((100% - (var(--n) - 1) * var(--gap)) * var(--f));
  }

  .stack > .ph {
    flex: calc(1 / var(--ar)) 1 0;
    min-height: 0;
    aspect-ratio: auto;
  }

  /* only if a portrait has nothing to stack beside it: a wide frame, cropped to its "focus" */
  .ph.hero.crop {
    aspect-ratio: 16 / 9;
    max-height: var(--hero-max);
  }
}

@media (hover: none) {
  .lb-nav {
    display: none;
  }
}

@media (max-width: 640px) {
  :root {
    --pad: 16px;
    --gap: 4px;
    --hud-h: 44px;
  }

  body {
    font-size: 13px;
  }

  /* on a phone the tags get their own line under the name and counter (41px + 29px + 2px = 72px) */
  .hud {
    flex-wrap: wrap;
    row-gap: 0;
    height: auto;
    min-height: calc(var(--hud-h) + env(safe-area-inset-top, 0px));
    padding-bottom: 2px;
    background: linear-gradient(to bottom, rgba(10, 10, 10, 0.96) 0%, rgba(10, 10, 10, 0.86) 70%, rgba(10, 10, 10, 0) 100%);
  }

  .hud-tags {
    order: 3;
    flex-basis: 100%;
    gap: 12px;
  }

  .hud-tags a {
    padding: 0 0 8px;
  }

  main {
    padding-top: calc(72px + env(safe-area-inset-top, 0px) + var(--gap));
  }

  .hud-exp {
    display: none;
  }

  /* on a phone there is room for the counter and one more thing: the place if there is one, else the camera */
  .hud-loc:not(:empty) ~ .hud-cam {
    display: none;
  }

  .backdrop {
    display: none;
  }

  .lb-stage {
    padding: 0;
  }

  .foot {
    padding-top: 20px;
  }
}

@media (max-width: 359px) {
  .hud-cam {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .js .ph img,
  .lb-stage img {
    transition: none;
  }
}
