:root {
  --fg: #111;
  --muted: #8a8a8a;
  --placeholder: #f3f3f3;
  --gap: 4px;
  --gutter: 16px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
html.locked { overflow: hidden; }

body {
  margin: 0;
  background: #fff;
  color: var(--fg);
  font-family: "Jost", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 300;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

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

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

.site {
  padding: 32px var(--gutter) 8px;
  text-align: center;
}

.brand {
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: 0.08em;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--gutter) 48px;
  min-height: 70vh;
}

.site-foot {
  padding: 24px var(--gutter) 40px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------- home: photo stacks ---------- */

.stacks {
  list-style: none;
  margin: 16px auto 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px 40px;
  max-width: 1200px;
}

@media (min-width: 700px) {
  .stacks { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-top: 40px; }
}

.stack {
  display: block;
  text-align: center;
  padding-bottom: 24px;
}

.pile {
  position: relative;
  aspect-ratio: 1;
  max-width: 400px;
  margin: 0 auto;
}

.pile img {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  background: var(--placeholder);
  border: 6px solid #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 0 8px 24px rgba(0, 0, 0, 0.1);
  transform: translate(-50%, -50%) translate(var(--x), var(--y)) rotate(var(--r));
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.pile img.land { width: 74%; height: auto; }
.pile img.port { height: 78%; width: auto; }

@media (hover: hover) {
  .stack:hover .pile img {
    transform: translate(-50%, -50%)
      translate(calc(var(--x) * 2.2), calc(var(--y) * 1.6))
      rotate(calc(var(--r) * 1.7));
  }
}

.stack .name {
  display: inline-block;
  margin-top: 4px;
  font-size: 1.2rem;
  font-weight: 400;
  letter-spacing: 0.08em;
}

.stack .count {
  margin-left: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---------- category ---------- */

.cat-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 calc(var(--gutter) * -1) 12px;
  padding: 12px var(--gutter);
  background: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.cat-head h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: 0.08em;
}

.cat-head .count {
  margin-left: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--muted);
  transition: color 0.2s;
}

.icon-btn:hover,
.icon-btn[aria-pressed="true"] { color: var(--fg); }

.icon-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
}

.back { margin-left: -12px; color: var(--fg); }

.toggle { margin-left: auto; margin-right: -12px; display: flex; }

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

@media (min-width: 700px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); --gap: 6px; }
}

.grid a {
  display: block;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--placeholder);
}

.grid img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s, transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (hover: hover) {
  .grid a:hover img { opacity: 0.88; transform: scale(1.02); }
}

/* list view */
.list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

@media (min-width: 700px) {
  .list { gap: 48px; }
}

.list a {
  display: block;
  max-width: 1200px;
  background: var(--placeholder);
}

.list img {
  display: block;
  width: 100%;
  height: 100%;
}

/* two photos in one row, left & right */
.photo-2-row-1 {
  display: flex;
  gap: 8px;
  max-width: 1200px;
}

.photo-2-row-1 a { min-width: 0; }

@media (min-width: 700px) {
  .photo-2-row-1 { gap: 16px; }
}

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

.viewer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  overscroll-behavior: contain;
  animation: fade 0.2s ease-out;
}

.viewer[hidden] { display: none; }

@keyframes fade { from { opacity: 0; } }

.v-img {
  display: block;
  background: var(--placeholder);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.v-btn {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  color: var(--fg);
  opacity: 0.6;
  transition: opacity 0.2s;
}

.v-btn:hover { opacity: 1; }

.v-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
}

.v-close { top: max(4px, env(safe-area-inset-top)); right: 4px; }

.v-prev,
.v-next { bottom: max(6px, env(safe-area-inset-bottom)); }
.v-prev { left: 4px; }
.v-next { right: 4px; }

.v-count {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(6px, env(safe-area-inset-bottom));
  line-height: 52px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
  pointer-events: none;
}

@media (min-width: 700px) {
  .v-close { top: 12px; right: 12px; }
  .v-prev,
  .v-next { top: 50%; bottom: auto; transform: translateY(-50%); width: 72px; height: 120px; }
  .v-prev { left: 8px; }
  .v-next { right: 8px; }
  .v-count { bottom: 8px; line-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
