/* Capylumei — album */

@font-face {
  /* DM Serif Text Italic, subset to the Latin used on the page (SIL OFL, see fonts/wordmark-OFL.txt) */
  font-family: "Capylumei Wordmark";
  src: url("fonts/wordmark.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  /* Noto Serif SC SemiBold, subset to the Chinese used on the page (SIL OFL, see fonts/album-serif-OFL.txt) */
  font-family: "Album Serif";
  src: url("fonts/album-serif.woff2") format("woff2");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

:root {
  --paper: #faf6ee;
  --ink: #2a231d;
  --muted: #85786b;
  --rule: #e7ddcc;
  --accent: #ec8a2c;
  --accent-ink: #b45a17;
  --focus: #d9711f;
  --viewer-bg: #18140f;
  --viewer-ink: #f4ede2;

  --gutter: 16px;
  --gap: 12px;
  --row-gap: 26px;
  --radius: 6px;

  --font-sans: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-serif: "Album Serif", "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-mark: "Capylumei Wordmark", "Georgia", serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #16130f;
    --ink: #f1e9dd;
    --muted: #a69888;
    --rule: #332b22;
    --accent: #f0943f;
    --accent-ink: #f2a35a;
    --focus: #f0943f;
    color-scheme: dark;
  }
}

@media (min-width: 720px) {
  :root {
    --gutter: 32px;
    --gap: 22px;
    --row-gap: 40px;
  }
}

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

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

html:has(.viewer[open]) {
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

.masthead,
main,
.colophon {
  width: min(1120px, 100% - 2 * var(--gutter));
  margin-inline: auto;
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0 14px;
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1.25rem;
  line-height: 1;
  letter-spacing: 0.08em;
  color: var(--ink);
  text-decoration: none;
}

.wordmark::before {
  content: "";
  width: 0.45em;
  height: 0.45em;
  border-radius: 50%;
  background: var(--accent);
}

.masthead__meta {
  font-size: 0.8125rem;
  letter-spacing: 0.18em;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- intro ---------- */

.intro {
  padding: clamp(44px, 9vw, 104px) 0 clamp(30px, 5vw, 60px);
}

.intro h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(2.375rem, 1.5rem + 4.2vw, 4.5rem);
  line-height: 1.12;
  letter-spacing: 0.06em;
  text-wrap: balance;
}

.lede {
  margin: 0.9rem 0 0;
  max-width: 32em;
  font-size: clamp(1rem, 0.95rem + 0.3vw, 1.125rem);
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* ---------- gallery ---------- */

.gallery {
  display: grid;
  gap: var(--row-gap);
}

/* Each row: widths proportional to the photos' aspect ratios, so every photo in a row
   has the same height and none is cropped. */
.row {
  display: flex;
  align-items: flex-start;
  gap: var(--gap);
}

.tile {
  flex: var(--a, 1) 1 0;
  min-width: 0;
  margin: 0;
}

.tile a {
  display: block;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--c, var(--rule));
  cursor: zoom-in;
}

.tile picture {
  display: block;
}

.tile img {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (hover: hover) {
  .tile a:hover img {
    transform: scale(1.025);
  }
}

.tile figcaption {
  display: flex;
  align-items: baseline;
  gap: 0.7em;
  margin-top: 0.75rem;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 0.9375rem;
  line-height: 1.45;
  letter-spacing: 0.04em;
}

.num {
  flex: none;
  font-family: var(--font-mark);
  font-weight: 400;
  font-size: 0.9375rem;
  letter-spacing: 0.02em;
  color: var(--accent-ink);
}

/* Phones: one wide photo, then pairs of squares, then one wide photo. */
@media (max-width: 719.98px) {
  .gallery {
    grid-template-columns: 1fr 1fr;
    gap: 22px var(--gap);
  }

  .row {
    display: contents;
  }

  .tile img {
    aspect-ratio: 1;
    object-fit: cover;
  }

  .tile--wide {
    grid-column: 1 / -1;
  }

  .tile--wide img {
    aspect-ratio: auto;
  }

  .tile figcaption {
    gap: 0.55em;
    margin-top: 0.55rem;
    font-size: 0.875rem;
  }

  .num {
    font-size: 0.875rem;
  }
}

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

.colophon {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: clamp(64px, 10vw, 120px);
  padding: 18px 0 40px;
  border-top: 1px solid var(--rule);
  font-family: var(--font-mark);
  color: var(--muted);
}

.wordmark--small {
  font-size: 1rem;
  color: var(--muted);
}

.wordmark--small::before {
  background: var(--muted);
}

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

.viewer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--viewer-bg);
  color: var(--viewer-ink);
  overflow: hidden;
}

.viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  animation: viewer-in 0.22s ease-out;
}

.viewer::backdrop {
  background: rgba(10, 8, 6, 0.5);
}

@keyframes viewer-in {
  from {
    opacity: 0;
  }
}

.viewer__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 12px 6px 18px;
}

.viewer__count {
  font-family: var(--font-mark);
  font-size: 1.0625rem;
  letter-spacing: 0.06em;
  opacity: 0.8;
}

.viewer__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.viewer__btn,
.viewer__nav {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.viewer__orig {
  min-height: 34px;
  padding: 0 15px;
  border: 1px solid rgba(244, 237, 226, 0.32);
  font-size: 0.8125rem;
  letter-spacing: 0.12em;
  text-decoration: none;
}

.viewer__btn:hover,
.viewer__nav:hover {
  background: rgba(244, 237, 226, 0.1);
}

.viewer__stage {
  position: relative;
  min-height: 0;
  touch-action: pan-y pinch-zoom;
}

/* Absolutely positioned so the percentages resolve against the stage: the photo is
   centred and scaled down to fit, never up beyond its own size. */
.viewer__img {
  position: absolute;
  inset: 4px 16px;
  margin: auto;
  display: block;
  width: auto;
  height: auto;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 8px);
  border-radius: 4px;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 0.25s ease;
}

.viewer__img.is-loading {
  opacity: 0;
}

.viewer__foot {
  display: grid;
  grid-template-columns: 52px 1fr 52px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px max(14px, env(safe-area-inset-bottom));
}

.viewer__caption {
  margin: 0;
  text-align: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.06em;
}

.viewer :focus-visible {
  outline-color: rgba(244, 237, 226, 0.7);
  outline-offset: 1px;
}

@media (prefers-reduced-motion: reduce) {
  .tile img,
  .viewer__img {
    transition: none;
  }

  .tile a:hover img {
    transform: none;
  }

  .viewer[open] {
    animation: none;
  }
}
