/* Personal photo archive — /photos */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body.ph-photos {
  font-family: 'Work Sans', sans-serif;
  color: rgba(255, 255, 255, 0.92);
  background-color: #090A0D;
  min-height: 100vh;
  overflow-x: hidden;
}

body.ph-photos::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(90, 110, 130, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 100% 80%, rgba(40, 55, 70, 0.25), transparent 50%),
    linear-gradient(180deg, #0c1016 0%, #090A0D 40%, #07080b 100%);
  pointer-events: none;
}

a:link, a:visited { color: inherit; text-decoration: none; }

.ph-photos-wrap {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 3vh, 40px) clamp(16px, 3vw, 32px) 64px;
}

.ph-photos-top {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: clamp(28px, 4vh, 48px);
}

.brand { display: block; }

.brand img {
  height: 28px;
  width: auto;
  display: block;
}

.ph-photos-brand {
  font-family: 'Fahkwang', sans-serif;
  font-weight: 500;
  font-size: clamp(1.75rem, 3.5vw, 2.35rem);
  letter-spacing: 0.06em;
  color: #fff;
}

.ph-photos-brand span {
  display: block;
  margin-top: 4px;
  font-family: 'Work Sans', sans-serif;
  font-size: 0.42em;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(185, 200, 200, 0.55);
}

.ph-photos-meta {
  font-size: 0.92rem;
  color: rgba(200, 210, 220, 0.55);
  text-align: right;
}

.ph-photos-year {
  margin: 40px 0 16px;
  font-family: 'Fahkwang', sans-serif;
  font-weight: 400;
  font-size: 1.15rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(220, 230, 235, 0.45);
}

.ph-photos-year:first-of-type { margin-top: 0; }

.ph-photos-year span {
  margin-left: 12px;
  font-family: 'Work Sans', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: rgba(200, 210, 220, 0.3);
  font-variant-numeric: tabular-nums;
}

.ph-photos-wrap:has(.ph-photos-grid) { width: min(1640px, 100%); }

/* Same grid as /wallpapers: fixed columns, rows lined up, landscape fills the
   column and tall frames are capped and centred. */
.ph-photos-grid {
  --cols: 5;
  --gap: 18px;
  --tall-max-h: min(52vw, 380px);
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
  container-type: inline-size;
}

/* Resolved in .ph-photos-thumb, so cqw measures the grid: one column width,
   i.e. 1.5x the height of a 3:2 thumb. */
@supports (width: 1cqw) {
  .ph-photos-grid {
    --tall-max-h: calc((100cqw - (var(--cols) - 1) * var(--gap)) / var(--cols));
  }
}

@supports (grid-template-rows: masonry) {
  .ph-photos-grid {
    grid-template-rows: masonry;
    align-tracks: start;
  }
}

@media (max-width: 1350px) {
  .ph-photos-grid { --cols: 4; }
}

@media (max-width: 900px) {
  .ph-photos-grid { --cols: 3; }
}

@media (max-width: 800px) {
  .ph-photos-grid { --gap: 14px; }
}

@media (max-width: 550px) {
  .ph-photos-grid { --cols: 2; --gap: 10px; }
}

.ph-photos-card {
  position: relative;
  display: block;
  border-radius: 6px;
  overflow: hidden;
  color: inherit;
  transition: transform 0.15s ease;
}

.ph-photos-card:hover { transform: scale(1.02); }

.ph-photos-card:focus-visible {
  outline: 2px solid rgba(150, 175, 205, 0.8);
  outline-offset: 2px;
}

.ph-photos-thumb {
  position: relative;
  display: block;
  aspect-ratio: var(--ar);
  width: min(100%, calc(var(--tall-max-h) * var(--ar)));
  margin-inline: auto;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
}

.ph-photos-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.22s ease;
}

.ph-photos-card img.is-loaded { opacity: 1; }
.ph-photos-card:hover img.is-loaded { opacity: 0.85; }

/* A fade per thumb is a compositing layer per thumb, dozens at once mid-scroll. */
@media (hover: none) {
  .ph-photos-card,
  .ph-photos-card:hover { transition: none; transform: none; }
  .ph-photos-card img { opacity: 1; transition: none; }
}

/* Lightbox (gallery.js): the photo on the left, details on the right. */

body.ph-lb-open { overflow: hidden; }

.ph-lb {
  --side: 380px;
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--side);
  background: #000;
  overflow: hidden;
}

.ph-lb[hidden] { display: none; }
.ph-lb:focus { outline: none; }

.ph-lb-media {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 0;
  padding: 64px 76px;
}

.ph-lb-stage {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ph-lb-img {
  display: block;
  max-width: none;
  border-radius: 2px;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.ph-lb-img.is-zoomed {
  transform: scale(2.5);
  cursor: zoom-out;
}

.ph-lb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: 1px solid rgb(27, 35, 47);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(94, 120, 162, 0.12) 0%, rgba(94, 120, 162, 0) 55%), rgba(15, 21, 30, 0.8);
  color: rgba(255, 255, 255, 0.82);
  font: 500 0.82rem 'Work Sans', sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.ph-lb-btn:link,
.ph-lb-btn:visited { color: rgba(255, 255, 255, 0.82); }

.ph-lb-btn:hover {
  border-color: rgb(36, 50, 70);
  background: linear-gradient(180deg, rgba(97, 123, 165, 0.17) 0%, rgba(97, 123, 165, 0) 55%), rgba(16, 22, 34, 0.86);
  color: rgba(255, 255, 255, 0.95);
}

.ph-lb-btn[hidden] { display: none; }

.ph-lb-close,
.ph-lb-nav {
  position: absolute;
  z-index: 2;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
}

.ph-lb-close { top: 14px; left: 16px; }

.ph-lb-count {
  position: absolute;
  top: 26px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.8rem;
  color: rgba(185, 200, 210, 0.5);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.ph-lb-nav {
  top: 50%;
  transform: translateY(-50%);
}

.ph-lb-prev { left: 16px; }
.ph-lb-next { right: 16px; }

.ph-lb-side {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 22px 32px;
  border-left: 1px solid rgb(27, 35, 47);
  background: rgb(12, 16, 22);
}

.ph-lb-title {
  margin: 0 0 6px;
  font-family: 'Fahkwang', sans-serif;
  font-weight: 500;
  font-size: 1.35rem;
  letter-spacing: 0.03em;
  line-height: 1.25;
  color: #fff;
  overflow-wrap: anywhere;
}

.ph-lb-date {
  margin: 0 0 16px;
  font-size: 0.88rem;
  color: rgba(185, 200, 210, 0.55);
}

.ph-lb-date[hidden],
.ph-lb-exif[hidden],
.ph-lb-tags[hidden] { display: none; }

.ph-lb-exif {
  margin: 0;
  padding: 0;
  border-top: 1px solid rgba(50, 64, 82, 0.55);
  list-style: none;
}

.ph-lb-exif li {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(40, 52, 68, 0.45);
  font-size: 0.85rem;
}

.ph-lb-exif .k { color: rgba(170, 185, 200, 0.45); }

.ph-lb-exif .v {
  color: rgba(235, 240, 245, 0.88);
  word-break: break-word;
}

.ph-lb-tags {
  margin: 14px 0 0;
  font-size: 0.8rem;
  line-height: 1.6;
  color: rgba(170, 185, 200, 0.5);
}

.ph-lb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.ph-lb-delete {
  border-color: rgba(190, 70, 70, 0.6);
  color: rgb(240, 150, 150);
}

.ph-lb-delete:hover {
  border-color: rgba(190, 70, 70, 0.6);
  background: rgba(190, 40, 40, 0.25);
  color: #fff;
}

/* Phones and narrow windows: the photo on top, details under it, all one scroll. */
@media (max-width: 900px) {
  .ph-lb {
    display: block;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .ph-lb-media {
    height: 78svh;
    padding: 60px 10px 14px;
  }
  .ph-lb-close { top: 10px; left: 10px; width: 40px; height: 40px; }
  .ph-lb-count { top: 22px; }
  .ph-lb-nav { width: 38px; height: 38px; opacity: 0.8; }
  .ph-lb-prev { left: 8px; }
  .ph-lb-next { right: 8px; }
  .ph-lb-side {
    overflow: visible;
    min-height: 22svh;
    padding: 20px 16px calc(28px + env(safe-area-inset-bottom, 0px));
    border-left: 0;
    border-top: 1px solid rgb(27, 35, 47);
  }
}

/* Local curation (edit.js, dev server only) */

.ph-photos-meta a { text-decoration: underline; text-underline-offset: 3px; }

.ph-photos-card-delete {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font: 600 1rem/26px 'Work Sans', sans-serif;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.ph-photos-card:hover .ph-photos-card-delete { opacity: 1; }
.ph-photos-card-delete:hover { background: rgb(190, 40, 40); }

.ph-photos-card.is-busy { opacity: 0.5; pointer-events: none; }

.ph-photos-card.is-deleted { cursor: default; }
.ph-photos-card.is-deleted img.is-loaded { opacity: 0.15; filter: grayscale(1); }
.ph-photos-card.is-deleted .ph-photos-card-delete { display: none; }

.ph-photos-card-undo {
  position: absolute;
  inset: 0;
  margin: auto;
  width: fit-content;
  height: fit-content;
  padding: 6px 14px;
  border: 1px solid rgba(140, 165, 190, 0.7);
  border-radius: 6px;
  background: rgba(12, 16, 22, 0.9);
  color: #fff;
  font: 500 0.85rem 'Work Sans', sans-serif;
  cursor: pointer;
}

.ph-photos-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 1100;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px 10px 16px;
  border: 1px solid rgb(27, 35, 47);
  border-radius: 10px;
  background: rgba(12, 16, 22, 0.96);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
}

.ph-photos-toast button,
.ph-photos-removed button {
  padding: 4px 12px;
  border: 1px solid rgba(140, 165, 190, 0.7);
  border-radius: 6px;
  background: transparent;
  color: #fff;
  font: 500 0.85rem 'Work Sans', sans-serif;
  cursor: pointer;
}

.ph-photos-removed {
  margin: 0;
  padding: 0;
  max-width: 44rem;
  list-style: none;
}

.ph-photos-removed li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(40, 52, 68, 0.45);
  font-size: 0.92rem;
}

.ph-photos-removed .r { font-size: 0.8rem; color: rgba(170, 185, 200, 0.55); }
