/* 图库 (cloud_storage/templates/tuku_home.html): pictures first. A plain head,
   one row of category chips, then rows of equal height whose widths follow each
   picture's shape, with no cropping - and a dark viewer over the page when one
   is opened. */

.tuku {
  --tk-ink: #342e27;
  --tk-muted: #6a6155;
  --tk-red: #7a2a1f;
  --tk-line: #e7dcc8;
  --tk-paper: #fffdf8;
  --tk-wash: #f6efe2;
  color: var(--tk-ink);
  margin: 0 auto;
  max-width: 1600px;
  padding: 24px 16px 64px;
}

.tuku :is(a, button):focus-visible,
.tuku-view :is(a, button):focus-visible {
  outline: 3px solid #33758b;
  outline-offset: 3px;
}

.tuku-head {
  margin-bottom: 14px;
}

.tuku-title {
  color: var(--tk-red);
  font-family: "Songti SC", "Noto Serif CJK SC", serif;
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 600;
  letter-spacing: 0.1em;
  line-height: 1.3;
  margin: 0;
}

.tuku-lead {
  color: var(--tk-muted);
  font-size: 15px;
  margin: 6px 0 0;
}

/* -- tiers: two tabs over the filters, 精美大图 and 更多图片 -- */
.tuku-tiers {
  border-bottom: 1px solid var(--tk-line);
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
}

.tuku-tier {
  align-items: center;
  border-bottom: 2px solid transparent;
  color: var(--tk-muted);
  display: inline-flex;
  font-size: 16px;
  gap: 6px;
  margin-bottom: -1px;
  min-height: 44px;
  padding: 0 12px;
  text-decoration: none;
  transition:
    color 0.15s,
    border-color 0.15s;
}

.tuku-tier:hover {
  color: var(--tk-ink);
  text-decoration: none;
}

.tuku-tier.is-on {
  border-bottom-color: var(--tk-red);
  color: var(--tk-red);
  font-weight: 600;
}

/* -- filters: categories on one line that scrolls sideways on a phone -- */
.tuku-filters {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.tuku-chips,
.tuku-shapes {
  display: flex;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.tuku-chips {
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  padding: 2px 0 4px;
  scrollbar-width: none;
}

.tuku-chips::-webkit-scrollbar {
  display: none;
}

.tuku-chip,
.tuku-shape {
  align-items: center;
  border: 1px solid var(--tk-line);
  border-radius: 999px;
  color: var(--tk-ink);
  display: inline-flex;
  font-size: 15px;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  text-decoration: none;
  transition:
    background-color 0.15s,
    border-color 0.15s;
  white-space: nowrap;
}

.tuku-chip:hover,
.tuku-shape:hover {
  background: var(--tk-wash);
  color: var(--tk-ink);
  text-decoration: none;
}

.tuku-chip.is-on,
.tuku-shape.is-on {
  background: var(--tk-red);
  border-color: var(--tk-red);
  color: #fff;
}

.tuku-chip__n {
  font-size: 13px;
  opacity: 0.7;
}

.tuku-shape {
  font-size: 14px;
  min-height: 36px;
  padding: 0 12px;
}

/* -- topics: folded under 按主题; open, the chips wrap rather than scroll -- */
.tuku-topics {
  flex: 1 1 100%;
}

.tuku-topics__toggle {
  align-items: center;
  border-radius: 999px;
  color: var(--tk-muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  gap: 6px;
  list-style: none;
  min-height: 36px;
  padding: 0 4px;
  user-select: none;
}

.tuku-topics__toggle::-webkit-details-marker {
  display: none;
}

.tuku-topics__toggle::after {
  border-bottom: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  content: "";
  height: 6px;
  margin: -3px 0 0 2px;
  transform: rotate(45deg);
  transition: transform 0.15s;
  width: 6px;
}

.tuku-topics[open] > .tuku-topics__toggle::after {
  margin-top: 3px;
  transform: rotate(-135deg);
}

.tuku-topics__toggle:hover,
.tuku-topics__toggle b {
  color: var(--tk-ink);
}

.tuku-topics__toggle:focus-visible {
  outline: 2px solid var(--tk-red);
  outline-offset: 2px;
}

.tuku-topic-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 6px 0 4px;
  padding: 0;
}

.tuku-chip--topic {
  font-size: 14px;
  min-height: 34px;
  padding: 0 12px;
}

.tuku-count {
  color: var(--tk-muted);
  font-size: 14px;
  margin: 6px 0 10px;
}

/* -- the grid: justified rows in plain CSS. Each picture's flex-basis is its
   width at the row height and it grows in proportion to that, so a row widened
   to the edge keeps one height across it; the last row's spare width goes to
   ::after instead of stretching it. -- */
.tuku-grid {
  --h: 120px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
}

.tuku-grid::after {
  content: "";
  flex-grow: 1000;
}

.tuku-item {
  background: var(--c);
  border-radius: 3px;
  flex: var(--r) 1 calc(var(--r) * var(--h));
  overflow: hidden;
}

.tuku-link {
  display: block;
}

.tuku-link img {
  aspect-ratio: var(--r);
  display: block;
  height: auto;
  object-fit: cover;
  transition: opacity 0.2s;
  width: 100%;
}

.tuku-link:hover img {
  opacity: 0.88;
}

@media (min-width: 600px) {
  .tuku-grid {
    --h: 180px;
    gap: 6px;
  }
}

@media (min-width: 1100px) {
  .tuku-grid {
    --h: 230px;
    gap: 8px;
  }
}

.tuku-count a {
  color: var(--tk-red);
}

/* 接着看：tuku.js 滚近了自己去取，这条链接多半一闪而过；没有脚本时它就是下一页。 */
.tuku-more {
  margin: 0 0 24px;
  text-align: center;
}

.tuku-next {
  border: 1px solid var(--tk-line);
  border-radius: 999px;
  color: var(--tk-red);
  display: inline-block;
  font-size: 15px;
  padding: 10px 22px;
  text-decoration: none;
}

.tuku-next:hover {
  background: var(--tk-wash);
}

.tuku-next[aria-busy="true"] {
  color: var(--tk-muted);
}

.tuku-empty {
  color: var(--tk-muted);
  padding: 48px 0;
  text-align: center;
}

/* -- the viewer -- */
.tuku-view {
  background: #111;
  border: 0;
  color: #eee;
  height: 100%;
  margin: 0;
  max-height: none;
  max-width: none;
  padding: 0;
  width: 100%;
}

.tuku-view::backdrop {
  background: #111;
}

.tuku-view[open] {
  display: flex;
  flex-direction: column;
}

.tuku-view__stage {
  align-items: center;
  display: flex;
  flex: 1 1 auto;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  position: relative;
  touch-action: pan-y pinch-zoom;
}

.tuku-view__img {
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  cursor: zoom-in;
  display: block;
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  user-select: none;
}

/* 放大：原尺寸，可以拖着看（手机上用手指滚）。 */
.tuku-view.is-zoomed .tuku-view__stage {
  align-items: flex-start;
  justify-content: flex-start;
  overflow: auto;
  touch-action: auto;
}

.tuku-view.is-zoomed .tuku-view__img {
  cursor: zoom-out;
  margin: auto;
  max-height: none;
  max-width: none;
}

.tuku-view__nav,
.tuku-view__close {
  align-items: center;
  background: rgba(0, 0, 0, 0.45);
  border: 0;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex;
  height: 48px;
  justify-content: center;
  position: absolute;
  width: 48px;
}

.tuku-view__nav:hover,
.tuku-view__close:hover {
  background: rgba(0, 0, 0, 0.7);
}

.tuku-view__nav[disabled] {
  opacity: 0.25;
  pointer-events: none;
}

.tuku-view__nav {
  top: calc(50% - 60px);
}

.tuku-view__nav--prev {
  left: 12px;
}

.tuku-view__nav--next {
  right: 12px;
}

.tuku-view__close {
  right: 12px;
  top: 12px;
}

/* 手机上靠滑动翻页，两边的按钮让给图。 */
@media (hover: none) and (max-width: 700px) {
  .tuku-view__nav {
    display: none;
  }
}

.tuku-view.is-zoomed .tuku-view__nav {
  display: none;
}

.tuku-view__bar {
  align-items: center;
  background: #1b1b1b;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: space-between;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}

.tuku-view__info {
  font-size: 14px;
  margin: 0;
  min-width: 0;
}

.tuku-view__meta {
  color: #aaa;
  font-size: 13px;
  margin-left: 10px;
}

.tuku-view__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tuku-btn {
  align-items: center;
  background: #f4efe6;
  border-radius: 999px;
  color: #222;
  display: inline-flex;
  font-size: 14px;
  gap: 6px;
  min-height: 40px;
  padding: 0 16px;
  text-decoration: none;
}

.tuku-btn:hover {
  background: #fff;
  color: #222;
  text-decoration: none;
}

.tuku-btn--quiet {
  background: transparent;
  border: 1px solid #555;
  color: #eee;
}

.tuku-btn--quiet:hover {
  background: #2a2a2a;
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .tuku-link img,
  .tuku-chip,
  .tuku-shape,
  .tuku-tier {
    transition: none;
  }
}
