/* 一万张天空 — photo wall + slim century bar */

:root {
  --bg: #0b1014;
  --ink: #f2f2f2;
  --ink-dim: #b3b3b3;
  --ink-faint: #7a7a7a;
  --horizon: #7eb8d8;
  --track: rgba(255, 255, 255, 0.1);
  --gap: 3px;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: ui-sans-serif, system-ui, "PingFang SC", "Noto Sans SC", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sky: linear-gradient(
    90deg,
    #1d5f9c 0%,
    #4aa3d8 28%,
    #c9e6f5 55%,
    #e8d4dc 82%,
    #c4a8c8 100%
  );
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100svh;
  min-height: 100dvh;
}

button {
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  text-decoration-color: var(--ink-faint);
}

a:hover {
  text-decoration-color: var(--ink);
}

::selection {
  background: rgba(126, 184, 216, 0.28);
  color: var(--ink);
}

/* -------- sticky bar -------- */

.bar {
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--bg);
  padding-top: var(--safe-t);
}

.bar-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.4rem max(0.75rem, var(--safe-r)) 0.18rem max(0.75rem, var(--safe-l));
}

.bar-brand {
  min-width: 0;
  flex: 1 1 auto;
}

.bar-title {
  display: flex;
  align-items: flex-start;
  gap: 0.36rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink);
  cursor: pointer;
  min-width: 0;
  line-height: 1.28;
}

.bar-name {
  min-width: 0;
}

.bar-horizon {
  width: 22px;
  height: 8px;
  flex-shrink: 0;
  margin-top: 0.28em;
  color: var(--horizon);
}

.bar-start {
  display: block;
  margin-top: 0.06rem;
  padding-left: calc(22px + 0.36rem);
  font-size: 0.62rem;
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.bar-count {
  flex-shrink: 0;
  padding-top: 0.04rem;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  color: var(--ink-dim);
  white-space: nowrap;
}

.bar-count strong {
  color: var(--ink);
  font-weight: 650;
  font-size: 1.18em;
}

/* -------- slim current-hundred bar (inside sticky header) -------- */

.century {
  padding: 0 max(0.75rem, var(--safe-r)) 0.38rem max(0.75rem, var(--safe-l));
}

.century-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.16rem;
}

.century-range {
  font-size: 0.62rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  color: var(--horizon);
}

.century-frac {
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  color: var(--ink);
}

.century-track {
  height: 3px;
  width: 100%;
  background: var(--track);
  overflow: hidden;
}

.century-fill {
  height: 100%;
  width: 0;
  background: var(--sky);
  transform-origin: left center;
}

/* -------- empty samples -------- */

.samples-wrap {
  padding: 1.25rem max(0.75rem, var(--safe-r)) max(2rem, var(--safe-b))
    max(0.75rem, var(--safe-l));
}

.samples-note {
  text-align: center;
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin: 0 0 1rem;
}

.samples {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gap);
}

.sample {
  margin: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
}

.sample img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* -------- wall (ragged pack, real aspect) -------- */

.wall-wrap {
  padding: var(--gap) var(--gap) max(var(--gap), var(--safe-b));
}

.wall {
  position: relative;
  width: 100%;
}

.cell {
  display: block;
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  background: none;
  box-shadow: none;
  overflow: hidden;
  line-height: 0;
  font-size: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  color: inherit;
}

@keyframes cell-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

body.is-first .cell {
  animation: cell-in 0.42s var(--ease) both;
}

.cell:focus-visible {
  outline: 2px solid var(--horizon);
  outline-offset: 2px;
}

.cell img,
.cell .full {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: unset;
  object-position: top left;
  vertical-align: bottom;
}

.stamp {
  position: absolute;
  left: 3px;
  bottom: 3px;
  z-index: 1;
  pointer-events: none;
  font-size: 0.52rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  letter-spacing: 0.08em;
  line-height: 1.3;
  color: #f4f7fa;
  background: rgba(8, 12, 16, 0.52);
  padding: 0.12em 0.42em 0.1em;
}

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

.lb {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 16, 0.94);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s var(--ease);
  overscroll-behavior: none;
  touch-action: pan-y;
}

.lb.is-open {
  opacity: 1;
  pointer-events: auto;
}

body.is-lb .bar {
  visibility: hidden;
}

.lb-inner {
  width: min(1400px, 100%);
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lb-photo {
  max-width: 100%;
  max-height: 78svh;
  width: auto;
  height: auto;
  object-fit: contain;
}

.lb-cap {
  margin-top: 0.9rem;
  text-align: center;
  color: var(--ink);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.lb-cap:empty,
.lb-meta:empty {
  display: none;
}

.lb-cap .dot {
  color: var(--ink-faint);
  padding: 0 0.45em;
}

.lb-cap .num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  letter-spacing: 0.08em;
  font-weight: 650;
}

.lb-meta {
  margin-top: 0.2rem;
  color: var(--ink-dim);
  font-size: 0.78rem;
}

.lb-close,
.lb-nav {
  position: absolute;
  background: none;
  border: 0;
  color: var(--ink-dim);
  cursor: pointer;
  padding: 0.6rem 0.8rem;
  min-height: 44px;
  min-width: 44px;
}

.lb-close {
  top: 0.8rem;
  right: 0.8rem;
  font-size: 0.8rem;
}

.lb-nav {
  top: 50%;
  transform: translateY(-50%);
  font-size: 2rem;
  line-height: 1;
}

.lb-nav:active,
.lb-close:active {
  color: var(--ink);
}

@media (hover: hover) and (pointer: fine) {
  .lb-nav:hover,
  .lb-close:hover {
    color: var(--ink);
  }
}

.lb-prev {
  left: 0.2rem;
}

.lb-next {
  right: 0.2rem;
}

.lb-close:focus-visible,
.lb-nav:focus-visible {
  outline: 1px solid var(--horizon);
}

.noscript {
  text-align: center;
  padding: 2rem;
  color: var(--ink-faint);
}

/* -------- 404 -------- */

.lost {
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: max(2rem, var(--safe-t)) max(2rem, var(--safe-r))
    max(2rem, var(--safe-b)) max(2rem, var(--safe-l));
}

.lost h1 {
  font-weight: 500;
  font-size: 1.5rem;
  margin: 0 0 0.6rem;
}

.lost p {
  color: var(--ink-dim);
  margin: 0 0 1.5rem;
}

@media (max-width: 639px) {
  .bar-row {
    padding: 0.32rem max(0.6rem, var(--safe-r)) 0.12rem max(0.6rem, var(--safe-l));
    gap: 0.5rem;
  }

  .bar-title {
    font-size: 0.64rem;
    letter-spacing: 0.02em;
    gap: 0.3rem;
  }

  .bar-horizon {
    width: 16px;
    height: 6px;
    margin-top: 0.3em;
  }

  .bar-start {
    padding-left: calc(16px + 0.3rem);
    font-size: 0.56rem;
  }

  .bar-count {
    font-size: 0.78rem;
  }

  .century {
    padding: 0 max(0.6rem, var(--safe-r)) 0.3rem max(0.6rem, var(--safe-l));
  }

  .stamp {
    font-size: 0.46rem;
    left: 2px;
    bottom: 2px;
    padding: 0.1em 0.32em 0.08em;
  }

  .lb-inner {
    width: 100%;
    max-height: 100svh;
    max-height: 100dvh;
    padding: calc(3.4rem + var(--safe-t)) 0.7rem calc(4.6rem + var(--safe-b));
  }

  .lb-photo {
    max-width: 100%;
    max-height: 62svh;
    max-height: 62dvh;
    object-fit: contain;
  }

  .lb-cap {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    padding: 0 0.4rem;
    line-height: 1.55;
  }

  .lb-close {
    top: max(0.35rem, var(--safe-t));
    right: max(0.2rem, var(--safe-r));
    min-height: 44px;
    min-width: 44px;
    padding: 0.85rem 1rem;
  }

  .lb-nav {
    top: auto;
    bottom: max(0.2rem, var(--safe-b));
    transform: none;
    font-size: 1.65rem;
    min-height: 48px;
    min-width: 48px;
    padding: 0.7rem 1.15rem;
  }

  .lb-prev {
    left: max(0.1rem, var(--safe-l));
  }

  .lb-next {
    right: max(0.1rem, var(--safe-r));
  }
}

@media (prefers-reduced-motion: reduce) {
  .lb {
    transition: none;
  }

  body.is-first .cell {
    animation: none;
  }
}
