:root {
  color-scheme: light dark;
  --canvas: light-dark(#f6f4ef, #131211);
  --surface: light-dark(#fdfcf9, #1c1a18);
  --sunken: light-dark(#ece9e1, #0d0c0b);
  --ink: light-dark(#191714, #efece6);
  --soft: light-dark(#4d4942, #bdb8ae);
  --muted: light-dark(#6a655c, #97917f);
  --line: light-dark(#d9d4c8, #2f2c28);
  --line-strong: light-dark(#191714, #efece6);
  --a: light-dark(var(--a-light, #191714), var(--a-dark, #efece6));
  --on-a: light-dark(#fdfcf9, #131211);
  --display: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Noto Serif CJK JP', 'Source Han Serif', 'Songti SC', 'Hiragino Mincho ProN', serif;
  --text: system-ui, -apple-system, 'Segoe UI', 'Noto Sans CJK JP', sans-serif;
  --gutter: clamp(1rem, 3vw, 2rem);
}

:root[data-theme='light'] { color-scheme: light; }
:root[data-theme='dark'] { color-scheme: dark; }

/* A section and its tile take the colour of the script's own site. */
.tile, .chapter { --a: light-dark(var(--a-light), var(--a-dark)); }

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

html { scroll-padding-top: 3.5rem; -webkit-text-size-adjust: 100%; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--text);
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
ul { padding: 0; list-style: none; }
svg, img { display: block; }
:focus-visible { outline: 2px solid var(--a); outline-offset: 2px; }
::selection { background: var(--a); color: var(--on-a); }

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 3rem;
  padding-inline: var(--gutter);
  background: var(--canvas);
  border-bottom: 1px solid var(--line);
}

.wordmark { font-family: var(--display); font-size: 1.0625rem; letter-spacing: 0.02em; white-space: nowrap; }
.tools { display: flex; align-items: center; gap: 0.5rem; }
.langs { display: flex; }

.langs a {
  display: grid;
  place-items: center;
  min-width: 2rem;
  height: 2rem;
  color: var(--muted);
  font-size: 0.8125rem;
}

.langs a:hover { color: var(--ink); }
.langs a[aria-current] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--ink); }

.theme {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--soft);
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
}

.theme:hover { color: var(--ink); }

main { max-width: 90rem; margin-inline: auto; padding-inline: var(--gutter); }

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 24rem);
  align-items: end;
  gap: 1rem 3rem;
  padding-block: clamp(2rem, 6vw, 4.5rem) clamp(1.25rem, 3vw, 2rem);
}

h1 {
  font-family: var(--display);
  font-size: clamp(3rem, 9vw, 7.5rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.lede { padding-bottom: 0.5em; color: var(--soft); font-size: 1.0625rem; }

.wall {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line);
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: clamp(1rem, 2.5vw, 2rem) clamp(1rem, 2.5vw, 2rem) clamp(0.75rem, 1.5vw, 1rem);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--a);
  transition: background-color 160ms ease, color 160ms ease;
}

.tile-glyph { display: block; width: min(100%, 13rem); margin-inline: auto; aspect-ratio: 1; }
.tile-glyph svg, .glyph svg { width: 100%; height: 100%; }

.tile-label {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--ink);
  font-size: 0.875rem;
  line-height: 1.35;
  transition: color 160ms ease;
}

.tile-count { color: var(--muted); font-variant-numeric: tabular-nums; transition: color 160ms ease; }

@media (hover: hover) {
  .tile:hover { background: var(--a); color: var(--on-a); }
  .tile:hover .tile-label, .tile:hover .tile-count { color: var(--on-a); }
}

.chapter {
  display: grid;
  grid-template-columns: minmax(12rem, 18rem) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  padding-block: clamp(2.5rem, 6vw, 5rem);
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 3rem;
}

.rail-inner { position: sticky; top: 5rem; }
.glyph { width: 100%; max-width: 15rem; aspect-ratio: 1; margin-bottom: 1.5rem; color: var(--a); }
h2 { font-family: var(--display); font-weight: 400; }
.chapter-name { font-size: 1.875rem; line-height: 1.2; }
.note { margin-top: 0.5rem; color: var(--soft); font-size: 0.875rem; }
.note a { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 0.2em; }
.note a:hover { color: var(--a); text-decoration-color: currentColor; }
.meta { margin-top: 0.375rem; color: var(--muted); font-size: 0.75rem; }

.works { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1rem, 2vw, 1.5rem); }

/* An odd count opens on one wide card, so that no row ends on a gap. */
.work:first-child:nth-last-child(odd) { grid-column: 1 / -1; }

.work {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color 160ms ease;
}

a.work:hover { border-color: var(--a); }

.plate {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--sunken);
  border-bottom: 1px solid var(--line);
}

.plate img { width: 100%; height: 100%; object-fit: cover; object-position: top; }

/* Sites with a dark theme have a night screenshot, which follows this page's theme. */
.night { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .night { display: block; }
  :root:not([data-theme='light']) .day { display: none; }
}

:root[data-theme='dark'] .night { display: block; }
:root[data-theme='dark'] .day { display: none; }

.drawn {
  position: absolute;
  inset: 12% 0;
  background: var(--a);
  mask: url('/shots/han-compose.svg') center / contain no-repeat;
  -webkit-mask: url('/shots/han-compose.svg') center / contain no-repeat;
}

.drawn-ids { position: absolute; left: 1rem; bottom: 0.75rem; color: var(--soft); font-size: 0.875rem; }

.caption { display: flex; flex: 1; flex-direction: column; padding: 1rem 1.25rem 1.125rem; }
.work-name { font-family: var(--display); font-size: 1.3125rem; font-weight: 400; line-height: 1.3; }
.desc { flex: 1; margin-top: 0.375rem; color: var(--soft); font-size: 0.9375rem; }
.address { margin-top: 0.75rem; color: var(--a); font-size: 0.8125rem; }
.address.pending { color: var(--muted); }

.works + .rows { margin-top: clamp(1rem, 2vw, 1.5rem); }

.row {
  display: grid;
  grid-template-columns: minmax(0, 13rem) minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 0.25rem 1.25rem;
  padding: 0.875rem 0;
  border-top: 1px solid var(--line);
}

li:last-child .row { border-bottom: 1px solid var(--line); }
.row-name { font-family: var(--display); font-size: 1.0625rem; overflow-wrap: anywhere; }
.row:hover .row-name { color: var(--a); }
.row-desc { color: var(--soft); font-size: 0.875rem; }
.sample { display: block; margin-top: 0.25rem; color: var(--ink); }
.row .address { margin-top: 0; white-space: nowrap; }

.related { padding-block: clamp(2.5rem, 6vw, 4.5rem); border-bottom: 1px solid var(--line); }
.related h2 { margin-bottom: 1rem; font-size: 1.875rem; line-height: 1.2; }

.colophon { padding-block: 2.5rem 3.5rem; color: var(--muted); font-size: 0.8125rem; }
.colophon h2 { margin-bottom: 0.5rem; color: var(--ink); font-size: 1.125rem; }
.links { margin-top: 1rem; }
.links a { color: var(--soft); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 0.2em; }
.links a:hover { color: var(--ink); }

@media (max-width: 60rem) {
  .chapter { grid-template-columns: minmax(0, 1fr); }
  .rail-inner { position: static; display: flex; align-items: center; gap: 1.25rem; }
  .glyph { flex: none; width: 6.5rem; margin-bottom: 0; }
}

@media (max-width: 40rem) {
  .masthead { grid-template-columns: minmax(0, 1fr); }
  .wall { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .works { grid-template-columns: minmax(0, 1fr); }
  .row { grid-template-columns: minmax(0, 1fr); }
  .tile-glyph { width: min(100%, 9rem); }
}
