:root {
  --paper: #efeae2;
  --rail: #e7e1d6;
  --ink: #221e1a;
  --muted: #6e675f;
  --line: #d4cbc0;
  --card: #f7f4ee;
  --mat: #e6dfd4;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --sans: "Helvetica Neue", Helvetica, "Liberation Sans", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

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

body {
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}

.deck {
  margin: 0;
  color: var(--muted);
}

.deck a {
  color: inherit;
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100%;
  min-height: 0;
}

#rail {
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding: 28px 28px 40px;
  border-right: 1px solid var(--line);
  background: var(--rail);
}

.search-label,
.facet h2 {
  margin: 22px 0 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.search-label { margin-top: 0; }

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 0 0 22px;
}

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

.brand span {
  font-family: var(--serif);
  font-size: 1.35rem;
  line-height: 1.1;
}

.hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.search {
  width: 100%;
  border: none;
  border-bottom: 1px solid #cfc6ba;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 8px 0;
}

.years { display: flex; flex-direction: column; gap: 2px; }

.years button,
.stacks button,
.clear {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.years button {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid transparent;
  font-size: 0.92rem;
}

.stacks { display: flex; flex-wrap: wrap; gap: 6px; }

.stacks button {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45em;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid #cfc6ba;
  font-size: 0.75rem;
}

.years button .n,
.stacks button .n { color: #8a8178; }

.years button[aria-pressed="true"],
.stacks button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--card);
  border-color: var(--ink);
}

.years button[aria-pressed="true"] .n { color: #d9d0c6; }

.clear {
  margin-top: 22px;
  padding: 0;
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  font-size: 0.8rem;
}

main {
  min-width: 0;
  height: 100%;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.count {
  margin: 0;
  padding: 22px 40px 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.wall {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 36px 28px;
  padding: 18px 40px 28px;
}

.colophon {
  padding: 8px 40px 56px;
}

.card {
  display: block;
  color: inherit;
  content-visibility: auto;
  contain-intrinsic-size: auto 340px;
}

.open {
  display: block;
  color: inherit;
  text-decoration: none;
}

.frame {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  aspect-ratio: 5 / 4;
  background: var(--mat);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(34, 30, 26, 0.06);
}

.thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.monogram {
  font-family: var(--serif);
  font-size: 4rem;
  line-height: 1;
  color: rgba(34, 30, 26, 0.38);
}

.frame.tone-light .monogram { color: rgba(255, 252, 247, 0.78); }

.open-mark {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(34, 30, 26, 0.42);
  color: #f7f4ee;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.open-mark svg {
  width: 2rem;
  height: 2rem;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.28));
  transform: translateY(6px) scale(0.92);
  transition: transform 180ms ease;
}

.open:hover .frame,
.open:focus-visible .frame {
  transform: translateY(-2px);
  box-shadow: 0 16px 30px rgba(34, 30, 26, 0.1);
}

.open:hover .open-mark,
.open:focus-visible .open-mark {
  opacity: 1;
}

.open:hover .open-mark svg,
.open:focus-visible .open-mark svg {
  transform: none;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.download {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  line-height: 0;
  text-decoration: none;
  transition: transform 160ms ease;
}

.download img {
  width: 18px;
  height: 18px;
  display: block;
}

.download:hover,
.download:focus-visible {
  transform: translateY(-1px);
}

.download:active {
  transform: translateY(1px) scale(0.92);
}

.label {
  display: block;
  padding: 12px 4px 0;
  text-align: center;
}

.name {
  flex: 0 1 auto;
  color: inherit;
  font-family: var(--serif);
  font-size: 1.08rem;
  line-height: 1.25;
  text-decoration: none;
}

.meta,
.tags {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.tags { margin-top: 6px; }

.empty {
  grid-column: 1 / -1;
  margin: 24px 0;
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

button:focus-visible,
input:focus-visible,
.open:focus-visible,
.download:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .open-mark,
  .open-mark svg,
  .download { transition: none; }
  .open:hover .frame,
  .open:focus-visible .frame,
  .open:hover .open-mark svg,
  .open:focus-visible .open-mark svg,
  .download:active { transform: none; }
}

@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }
  #rail {
    height: auto;
    max-height: calc(100dvh - 9rem);
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .count { padding: 18px 16px 0; }
  .wall {
    grid-template-columns: 1fr 1fr;
    gap: 28px 16px;
    padding: 16px 16px 20px;
  }
  .colophon { padding: 8px 16px 40px; }
}

@media (max-width: 520px) {
  .wall { grid-template-columns: 1fr; }
}
