/* ============================================
   阿甜的 NewLife — 手帐展示网站
   移动端优先 · 温暖可爱风
   ============================================ */

/* --- CSS Variables --- */
:root {
  --bg: #FFF8F0;
  --pink: #E8A0BF;
  --pink-light: #F5D5E5;
  --pink-dark: #D4789E;
  --mint: #A8D8B9;
  --yellow: #FFE4A0;
  --orange: #FFB385;
  --text: #4A3728;
  --text-light: #7A6558;
  --card-bg: #FFFFFF;
  --card-shadow: 0 4px 20px rgba(74, 55, 40, 0.08);
  --card-shadow-hover: 0 8px 32px rgba(74, 55, 40, 0.15);
  --radius: 16px;
  --radius-lg: 24px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* --- Header --- */
.header {
  text-align: center;
  padding: 48px 20px 32px;
  position: relative;
}

.header__decoration {
  font-size: 32px;
  margin-bottom: 12px;
  letter-spacing: 8px;
}

.header__title {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.header__subtitle {
  font-size: 14px;
  color: var(--text-light);
  font-weight: 400;
  letter-spacing: 1px;
}

.header__line {
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, var(--pink), var(--mint));
  margin: 16px auto 0;
  border-radius: 2px;
}

/* --- Stats Bar --- */
.stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 16px 20px 24px;
  flex-wrap: wrap;
}

.stats__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--card-bg);
  padding: 12px 20px;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  min-width: 90px;
}

.stats__number {
  font-size: 22px;
  font-weight: 700;
  color: var(--pink-dark);
}

.stats__label {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

/* --- Category Tabs --- */
.categories {
  display: flex;
  gap: 10px;
  padding: 0 16px 20px;
  max-width: 1200px;
  margin: 0 auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.categories::-webkit-scrollbar {
  display: none;
}

.categories__tab {
  flex-shrink: 0;
  padding: 8px 18px;
  border: 2px solid var(--pink-light);
  border-radius: 24px;
  background: var(--card-bg);
  color: var(--text-light);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.categories__tab:hover {
  border-color: var(--pink);
  color: var(--text);
}

.categories__tab.active {
  background: var(--pink);
  border-color: var(--pink);
  color: white;
  box-shadow: 0 2px 8px rgba(232, 160, 191, 0.4);
}

/* --- Gallery Grid --- */
.gallery {
  padding: 0 16px 32px;
  max-width: 1200px;
  margin: 0 auto;
}

.gallery__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* --- Card --- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  -webkit-tap-highlight-color: transparent;
}

.card:hover,
.card:active {
  transform: translateY(-4px);
  box-shadow: var(--card-shadow-hover);
}

.card__image-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: var(--pink-light);
}

.card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.card:hover .card__image {
  transform: scale(1.03);
}

.card__image-count {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(74, 55, 40, 0.6);
  color: white;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
}

.card__body {
  padding: 14px 16px 16px;
}

.card__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-light);
}

.card__date {
  font-weight: 400;
}

.card__stats {
  display: flex;
  gap: 10px;
}

.card__stat {
  display: flex;
  align-items: center;
  gap: 3px;
}

.card__stat-icon {
  font-size: 13px;
}

/* --- Loading indicator --- */
.loading {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-light);
  font-size: 14px;
}

.loading__dots {
  display: inline-flex;
  gap: 4px;
}

.loading__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pink);
  animation: bounce 1.2s ease-in-out infinite;
}

.loading__dot:nth-child(2) { animation-delay: 0.2s; }
.loading__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* --- Modal Overlay --- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.92);
  z-index: 1000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

/* Top bar with download + close buttons */
.modal__top-bar {
  position: absolute;
  top: 12px;
  right: 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 1010;
}

.modal__close {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  font-size: 28px;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.modal__close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.modal__download {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.modal__download:hover {
  background: var(--pink);
}

.modal__download-all {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  font-size: 13px;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 20px;
  transition: background 0.2s;
  white-space: nowrap;
}

.modal__download-all:hover {
  background: var(--pink);
}

/* Card download button */
.card__download {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(255, 255, 255, 0.85);
  border: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  z-index: 5;
  backdrop-filter: blur(4px);
}

.card:hover .card__download,
.card:active .card__download {
  opacity: 1;
}

.card__download:hover {
  background: var(--pink);
  color: white;
}

.modal__title {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 180px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
  font-weight: 500;
  z-index: 1010;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal__counter {
  position: absolute;
  top: 56px;
  left: 16px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  z-index: 1010;
}

.modal__image-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 80px 16px 100px;
  position: relative;
  overflow: hidden;
  touch-action: pan-y;
}

.modal__image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  -webkit-user-drag: none;
  transition: opacity 0.2s ease;
  -webkit-touch-callout: default;
}

/* Navigation arrows */
.modal__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1010;
  transition: background 0.2s;
}

.modal__arrow:hover {
  background: rgba(255, 255, 255, 0.3);
}

.modal__arrow--left {
  left: 12px;
}

.modal__arrow--right {
  right: 12px;
}

/* Hide arrows on mobile (touch swipe instead) */
@media (max-width: 768px) {
  .modal__arrow {
    display: none;
  }
}

/* --- Thumbnails --- */
.modal__thumbnails {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 8px;
  padding: 12px 16px 16px;
  overflow-x: auto;
  justify-content: center;
  background: linear-gradient(transparent, rgba(0,0,0,0.6));
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.modal__thumbnails::-webkit-scrollbar {
  display: none;
}

.modal__thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.2s, transform 0.2s;
  flex-shrink: 0;
  border: 2px solid transparent;
}

.modal__thumb.active {
  opacity: 1;
  border-color: var(--pink);
  transform: scale(1.1);
}

.modal__thumb:hover {
  opacity: 0.8;
}

/* --- Footer --- */
.footer {
  text-align: center;
  padding: 32px 20px 24px;
  color: var(--text-light);
  font-size: 13px;
  border-top: 1px solid rgba(232, 160, 191, 0.2);
}

.footer__brand {
  font-weight: 600;
  color: var(--pink-dark);
}

.footer__links {
  margin-top: 8px;
}

.footer__links a {
  color: var(--pink);
  text-decoration: none;
  transition: color 0.2s;
}

.footer__links a:hover {
  color: var(--pink-dark);
}

/* --- Back to top --- */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--pink);
  color: white;
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(232, 160, 191, 0.4);
  z-index: 100;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--pink-dark);
}

/* --- Responsive --- */

/* Tablet: 2 columns */
@media (min-width: 600px) {
  .gallery__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
  }

  .header__title {
    font-size: 34px;
  }

  .gallery {
    padding: 0 24px 40px;
  }
}

/* Desktop: 3 columns */
@media (min-width: 1024px) {
  .gallery__grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
  }

  .header {
    padding: 64px 20px 40px;
  }

  .header__title {
    font-size: 40px;
  }

  .gallery {
    padding: 0 32px 48px;
  }

  .stats {
    gap: 32px;
  }

  .stats__item {
    padding: 16px 28px;
  }
}

/* --- Utility --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
