/* ============ BeadDay Gallery — 图纸分享站 ============ */
/* 复用 app.css 的 CSS 变量与设计风格，仅补充 gallery 专属布局 */

/* 确保 hidden 属性不被 display 覆盖 */
[hidden] { display: none !important; }

/* gallery 页面不需要隐藏 body overflow */
.gallery-body {
  overflow: auto;
  min-height: 100vh;
  background: var(--bg-soft);
}

/* ============ Header ============ */
.gallery-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.gallery-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}
.gallery-logo .logo-mark {
  width: 22px;
  height: 22px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  flex-shrink: 0;
}
.gallery-logo .logo-mark span {
  display: block;
  border-radius: 50%;
}
.gallery-logo-text {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.gallery-page-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-2);
  border-left: 1px solid var(--border);
  padding-left: 12px;
  margin-left: 4px;
}
.gallery-header-spacer {
  flex: 1;
}

/* ============ Main ============ */
.gallery-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

/* ============ Toolbar ============ */
.gallery-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.gallery-search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 480px;
}
.gallery-search-input {
  font: inherit;
  font-size: 14px;
  width: 100%;
  padding: 10px 36px 10px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.gallery-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 153, 255, 0.18);
}
.gallery-search-input::placeholder {
  color: var(--text-3);
}
.gallery-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border: none;
  background: var(--bg-panel);
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s;
}
.gallery-search-clear:hover {
  background: var(--glass-dark-hover);
  color: var(--text);
}
.gallery-sort-tabs {
  display: inline-flex;
  background: var(--bg-panel);
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 2px;
}
.gallery-sort-tab {
  padding: 6px 16px;
  border-radius: var(--r-pill);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-2);
  transition: background 0.12s, color 0.12s;
  border: none;
  background: transparent;
}
.gallery-sort-tab.active {
  background: #000;
  color: #fff;
}
.gallery-sort-tab:not(.active):hover {
  color: #000;
}

/* ============ Tag Bar ============ */
.gallery-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
  min-height: 0;
}
.gallery-tags:empty {
  margin-bottom: 0;
}
.gallery-tag-chip {
  font: inherit;
  font-size: 12px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: #fff;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
}
.gallery-tag-chip:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.gallery-tag-chip.active {
  background: #000;
  border-color: #000;
  color: #fff;
}

/* ============ Grid (masonry-like columns) ============ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}
@media (max-width: 1400px) {
  .gallery-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 1024px) {
  .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
}

/* ============ Card ============ */
.gallery-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s;
  display: flex;
  flex-direction: column;
}
.gallery-card:hover {
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
  border-color: var(--border-strong);
}
.gallery-card:active {
  transform: translateY(0);
}

/* Thumbnail: CSS grid pixel art */
.gallery-thumb {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-panel);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.gallery-thumb.thumb-fallback::after {
  content: '🖼️';
  font-size: 32px;
  color: var(--text-3, #aaa);
}
.gallery-thumb-grid {
  display: grid;
  width: 100%;
  height: 100%;
  gap: 0;
}
.gallery-thumb-cell {
  width: 100%;
  height: 100%;
}

/* Card body */
.gallery-card-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.gallery-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gallery-card-author {
  font-size: 12px;
  color: var(--text-2);
}
.gallery-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  color: var(--text-3);
}
.gallery-card-meta span {
  white-space: nowrap;
}
.gallery-card-meta .meta-dl {
  margin-left: auto;
}

/* ============ Status / Loading ============ */
.gallery-sentinel {
  height: 1px;
}
.gallery-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  gap: 12px;
  min-height: 80px;
}
.gallery-loading-spinner[hidden] { display: none; }
.gallery-loading-spinner {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 13px;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.gallery-end {
  font-size: 13px;
  color: var(--text-3);
  padding: 12px;
}
.gallery-error {
  text-align: center;
}
.gallery-error p {
  font-size: 14px;
  color: var(--text-2);
  margin: 0 0 8px;
}

/* Empty state */
.gallery-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 16px;
  text-align: center;
}
.gallery-empty-icon {
  margin-bottom: 8px;
  opacity: 0.5;
}
.gallery-empty-icon .logo-mark {
  width: 36px;
  height: 36px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}
.gallery-empty-icon .logo-mark span {
  display: block;
  border-radius: 4px;
}
.gallery-empty p {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin: 0;
}
.gallery-empty-hint {
  font-size: 13px !important;
  font-weight: 400 !important;
  color: var(--text-3) !important;
  margin-bottom: 8px !important;
}

/* ============ Detail View ============ */
.gallery-detail {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg-soft);
  overflow-y: auto;
  animation: detail-fade-in 0.18s ease-out;
}
.gallery-detail[hidden] {
  display: none;
}
@keyframes detail-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.gallery-detail-back {
  position: sticky;
  top: 0;
  z-index: 10;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 24px;
  border: none;
  background: #fff;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  color: var(--text);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.12s;
}
.gallery-detail-back:hover {
  background: var(--bg-soft);
}
.gallery-detail-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 32px;
  align-items: start;
}
@media (max-width: 760px) {
  .gallery-detail-content {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 20px 16px 48px;
  }
}

/* Detail: large preview */
.gallery-detail-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-1);
}
.gallery-detail-thumb {
  width: 100%;
  max-width: 480px;
  aspect-ratio: 1;
  display: grid;
  overflow: hidden;
  background: var(--bg-panel);
}
.gallery-detail-thumb-grid {
  display: grid;
  width: 100%;
  height: 100%;
}
.gallery-detail-image {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border-radius: 8px;
}
.gallery-detail-preview {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Detail: info panel */
.gallery-detail-info {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.gallery-detail-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.3;
}
.gallery-detail-author {
  font-size: 14px;
  color: var(--text-2);
}
.gallery-detail-desc {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.6;
  margin: 0;
}
.gallery-detail-desc.empty {
  color: var(--text-3);
  font-style: italic;
}
.gallery-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.gallery-detail-tag {
  font-size: 12px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg-soft);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.gallery-detail-tag:hover {
  background: var(--glass-dark-hover);
  color: var(--text);
}
.gallery-detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.gallery-detail-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.gallery-detail-stat-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.gallery-detail-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.gallery-detail-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gallery-detail-actions .btn {
  width: 100%;
  justify-content: center;
}
.gallery-detail-date {
  font-size: 12px;
  color: var(--text-3);
  text-align: center;
}

/* Detail loading */
.gallery-detail-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 80px 24px;
  color: var(--text-3);
  font-size: 14px;
}

/* ============ Responsive header ============ */
@media (max-width: 640px) {
  .gallery-header {
    padding: 0 12px;
    height: 50px;
    gap: 8px;
  }
  .gallery-page-title {
    font-size: 13px;
    padding-left: 8px;
    margin-left: 0;
  }
  .gallery-main {
    padding: 16px 12px 32px;
  }
  .gallery-toolbar {
    gap: 8px;
  }
  .gallery-search-wrap {
    max-width: none;
  }
}
