/* Photography section of jichu.art. Self-contained: shares only the fonts
   and the favicon with the main site. Layout notes are in README.md. */

@font-face {
  font-family: "Playfair Display";
  src: url("../../assets/fonts/playfair-display-latin-700-normal.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("../../assets/fonts/open-sans-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Open Sans";
  src: url("../../assets/fonts/open-sans-latin-600-normal.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}

:root {
  --text: #ffffff;
  --body: #c4c4c4;
  --muted: #8f8f8f;
  --accent: #db4f3d;
  --serif: "Playfair Display", "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", Georgia, serif;
  --sans: "Open Sans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --gap: 6px;
  --edge: clamp(20px, 3.4vw, 48px);
  --top: 76px;
  --vh: 100vh;
}
@supports (height: 100svh) { :root { --vh: 100svh; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: #000; }
body {
  margin: 0; background: #000; color: var(--body);
  font: 400 15px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img { display: block; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.skip { position: absolute; left: -999px; top: 0; z-index: 30; padding: 10px 16px; background: #fff; color: #000; }
.skip:focus { left: 0; }
.hide { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Top bar ---------------------------------------------------------------- */

.top {
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
  height: var(--top); padding: 0 var(--edge);
}
.top.over { position: absolute; top: 0; left: 0; right: 0; z-index: 5; }
.name { font: 700 22px/1 var(--serif); letter-spacing: .02em; color: var(--text); text-decoration: none; white-space: nowrap; }
.top nav { display: flex; gap: clamp(16px, 2.4vw, 32px); }
.top nav a {
  color: var(--text); text-decoration: none;
  font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  padding: 4px 0; border-bottom: 1px solid transparent; white-space: nowrap;
}
.top nav a:hover, .top nav a[aria-current="page"] { border-bottom-color: var(--accent); }
.top nav .lang { padding-left: clamp(14px, 2vw, 26px); border-left: 1px solid rgba(255, 255, 255, .28); letter-spacing: .06em; }

/* Chinese edition (photography/zh/). The Latin faces have no Chinese glyphs, so the system's own are used;
   Chinese needs no letter-spacing and a little more line height. */
:lang(zh) body { line-height: 1.85; }
:lang(zh) .top nav a, :lang(zh) .more h2 { letter-spacing: .08em; font-size: 14px; }
:lang(zh) .top nav .lang { letter-spacing: .06em; font-size: 13px; }
:lang(zh) .hero h1, :lang(zh) .panel h1, :lang(zh) .head h1, :lang(zh) .tile-title, :lang(zh) .subjects a, :lang(zh) .about h2 { letter-spacing: .04em; }

/* Rows: every photograph keeps its own aspect ratio. A row is as wide as the
   screen unless that would make it taller than the screen; then it is as tall
   as the screen and centred. --sum is the sum of the aspect ratios in the row. */

.rows { display: flex; flex-direction: column; align-items: center; gap: var(--gap); }
.row {
  display: flex; align-items: flex-start; gap: var(--gap);
  width: min(100%, calc((var(--vh) - 24px) * var(--sum) + (var(--n) - 1) * var(--gap)));
}
.ph {
  position: relative; display: block; overflow: hidden;
  flex: var(--ar) 1 0; min-width: 0; aspect-ratio: var(--ar);
  background: var(--c, #111);
}
.ph img { width: 100%; height: 100%; object-fit: cover; object-position: var(--pos, 50% 50%); }
a.ph { cursor: zoom-in; }

/* Home: opening slideshow ------------------------------------------------ */

.hero { position: relative; height: var(--vh); min-height: 520px; overflow: hidden; background: #111; }
.slide {
  position: absolute; inset: 0; display: block; color: var(--text); text-decoration: none;
  opacity: 0; pointer-events: none; transition: opacity 1.4s ease;
}
.slide.on { opacity: 1; pointer-events: auto; z-index: 1; }
.slide picture, .slide picture img { position: absolute; inset: 0; width: 100%; height: 100%; }
.slide picture img { object-fit: cover; object-position: 50% 55%; }
.slide::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.5) 0%, rgba(0,0,0,0) 24%, rgba(0,0,0,0) 46%, rgba(0,0,0,.84) 100%);
}
.slide-cap { position: absolute; z-index: 1; right: var(--edge); bottom: clamp(60px, 9vh, 92px); text-align: right; line-height: 1.5; }
.slide-cap b { display: block; font: 700 22px/1.3 var(--serif); border-bottom: 1px solid var(--accent); padding-bottom: 4px; margin-bottom: 6px; }
.slide-cap span { color: rgba(255,255,255,.84); font-size: 14px; }
.slide:hover .slide-cap b, .slide:focus-visible .slide-cap b { color: var(--accent); }
.hero-text { position: absolute; z-index: 2; left: var(--edge); bottom: clamp(60px, 9vh, 92px); pointer-events: none; }
.hero h1 { font: 700 clamp(52px, 8.4vw, 132px)/1 var(--serif); color: var(--text); margin: 0 0 16px; }
.hero-text p { margin: 0; color: rgba(255,255,255,.84); }
.hero-ctl { position: absolute; z-index: 3; left: var(--edge); bottom: 16px; display: flex; align-items: center; gap: 8px; }
.dot { position: relative; flex: 0 0 40px; height: 28px; padding: 0; border: 0; background: none; cursor: pointer; }
.dot::before { content: ""; position: absolute; left: 0; right: 0; top: 13px; height: 2px; background: rgba(255,255,255,.4); }
.dot[aria-current]::before { background: #fff; }
.dot:hover::before { background: var(--accent); }
.hero-pause { display: grid; place-items: center; width: 28px; height: 28px; margin-right: 4px; padding: 0; border: 0; background: none; color: #fff; cursor: pointer; }
.hero-pause svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hero-pause .i-play { display: none; fill: currentColor; stroke: none; }
.hero-pause[aria-pressed="true"] .i-pause { display: none; }
.hero-pause[aria-pressed="true"] .i-play { display: block; }
.hero-pause:hover { color: var(--accent); }
@media (prefers-reduced-motion: reduce) { .slide { transition: none; } }

/* Subjects: a line of links on the index page and at the top of each subject page. */

.subjects { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px clamp(18px, 2.4vw, 36px); padding: clamp(26px, 4.4vh, 46px) var(--edge); }
.subjects-label { font-size: 13px; color: var(--muted); }
.subjects a { font: 700 clamp(24px, 2.7vw, 40px)/1.3 var(--serif); color: var(--text); text-decoration: none; white-space: nowrap; }
.subjects sup { font: 400 12px/1 var(--sans); color: var(--muted); margin-left: 5px; }
.subjects a:hover, .subjects a[aria-current] { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 6px; }
.head { padding: 14px var(--edge) 6px; }
.head h1 { font: 700 clamp(40px, 4.4vw, 72px)/1.04 var(--serif); color: var(--text); margin: 0 0 10px; }
.head .count { color: var(--muted); font-size: 13px; margin: 0; }
.head + .subjects { padding-top: 14px; padding-bottom: 26px; }
.head + .subjects a { font-size: clamp(17px, 1.5vw, 22px); }
.head + .subjects sup { font-size: 12px; }

/* Home: series tiles ----------------------------------------------------- */

.tile { text-decoration: none; color: var(--text); }
.tile::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,0) 46%, rgba(0,0,0,.78) 100%);
}
.tile img { filter: brightness(.9); transition: filter .25s ease; }
.tile:hover img, .tile:focus-visible img { filter: none; }
.tile-text { position: absolute; z-index: 1; left: clamp(16px, 2vw, 28px); right: 16px; bottom: clamp(14px, 1.8vw, 24px); }
.tile-title { display: block; font: 700 clamp(26px, 2.9vw, 44px)/1.1 var(--serif); }
.tile-meta { display: block; margin-top: 8px; font-size: 13px; color: rgba(255,255,255,.84); }
.tile:hover .tile-title, .tile:focus-visible .tile-title { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 6px; }

/* Home: about ------------------------------------------------------------ */

.about {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 24px 48px;
  padding: clamp(72px, 11vh, 132px) var(--edge) clamp(40px, 6vh, 72px);
}
.about h2 { font: 700 clamp(34px, 3.6vw, 56px)/1.05 var(--serif); color: var(--text); margin: 0; }
.about div { max-width: 640px; font-size: 17px; }
.about p { margin: 0 0 16px; }
.about a { color: var(--text); text-decoration-color: var(--accent); text-underline-offset: 4px; }
.about a:hover { color: var(--accent); }

.foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px; padding: 28px var(--edge) 40px; font-size: 13px; color: var(--muted); }
.foot p { margin: 0; }
.foot a { color: var(--body); text-underline-offset: 3px; }
.foot a:hover { color: var(--text); }

/* Series page ------------------------------------------------------------ */

.lead { display: flex; align-items: flex-end; gap: var(--gap); margin-bottom: var(--gap); }
.panel { flex: 1 0 300px; padding: 0 28px 4px var(--edge); }
.panel h1 { font: 700 clamp(40px, 4.4vw, 72px)/1.04 var(--serif); color: var(--text); margin: 0 0 18px; }
.panel p { margin: 0 0 10px; }
.panel .where { color: var(--text); }
.panel .count { color: var(--muted); font-size: 13px; }
.panel .how a { color: var(--text); text-decoration-color: var(--accent); text-underline-offset: 4px; }
.panel .how a:hover { color: var(--accent); }
.lead .row {
  flex: 0 1 calc((var(--vh) - var(--top) - 12px) * var(--sum) + (var(--n) - 1) * var(--gap));
  width: auto;
}

.more { padding-top: clamp(64px, 10vh, 120px); }
.more h2 { font: 600 13px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 16px; padding: 0 var(--edge); }
.more .row { width: 100%; }
.more .tile { aspect-ratio: auto; flex: 1 1 0; height: clamp(220px, 36vh, 380px); }

/* Upright screens (tablets, phones): the title block sits above the first row
   instead of beside it, so the row can use the full width. */
@media (orientation: portrait), (max-width: 900px) {
  .lead { display: block; }
  .lead .row { width: min(100%, calc((var(--vh) - 24px) * var(--sum) + (var(--n) - 1) * var(--gap))); margin: 0 auto; }
  .panel { padding: 20px var(--edge) 28px; }
}

/* The narrowest phones: the Subjects link gives way; the subjects are listed right under the opening picture. */
@media (max-width: 374px) { html:not(:lang(zh)) .top nav .opt2 { display: none; } }

/* Phones held upright: one photograph per line, full width. */
@media (max-width: 760px) and (orientation: portrait) {
  :root { --top: 64px; }
  .name { font-size: 19px; }
  .top nav a { font-size: 11px; }
  .row, .lead .row { flex-direction: column; width: 100%; }
  .row .ph { flex: none; width: 100%; }
  .slide-cap { left: var(--edge); right: auto; text-align: left; bottom: 58px; }
  .slide-cap b { font-size: 19px; }
  .hero-text { bottom: 168px; }
  .top { gap: 12px; }
  .top nav { gap: 10px; }
  .top nav a { letter-spacing: .08em; }
  .top nav .lang { padding-left: 10px; }
  :lang(zh) .top nav { gap: 12px; }
  :lang(zh) .top nav a { font-size: 13px; }
  .top nav .wide, .top nav .opt { display: none; }
  .top nav a { padding: 10px 0; }
  /* Subject pages: a three-column grid of square crops to browse; the viewer shows each photograph whole. */
  .rows.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
  .rows.grid .row { display: contents; }
  .rows.grid .ph { aspect-ratio: 1; }
  .about { grid-template-columns: minmax(0, 1fr); }
  .more .tile { height: 46vw; flex: none; }
}

/* Viewer ----------------------------------------------------------------- */

.viewer {
  position: fixed; inset: 0; z-index: 50; background: #000;
  display: grid; grid-template-rows: minmax(0, 1fr) auto; touch-action: pan-y;
}
.viewer[hidden] { display: none; }
.v-stage { position: relative; display: grid; place-items: center; overflow: hidden; cursor: zoom-out; }
.v-img { background-size: cover; background-position: center; cursor: default; user-select: none; -webkit-user-drag: none; }
.v-cap {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 2px 24px;
  padding: 10px var(--edge) 14px; font-size: 13px; color: var(--body); min-height: 46px;
}
.v-cap b { color: var(--text); font-weight: 600; }
.v-place { margin-left: 14px; }
.v-btn {
  position: absolute; z-index: 2; display: grid; place-items: center;
  width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(0,0,0,.45); color: #fff; cursor: pointer;
}
.v-btn:hover { background: var(--accent); }
.v-btn[disabled] { opacity: .25; cursor: default; background: rgba(0,0,0,.45); }
.v-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.v-close { top: 14px; right: 14px; }
.v-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.v-next { right: 14px; top: 50%; transform: translateY(-50%); }
html.viewing { overflow: hidden; }
@media (hover: none) { .v-prev, .v-next { display: none; } }
