﻿/* =========================================
   GALLERY PAGE STYLES [FINAL FIXED VERSION]
   ========================================= */

html, body {
  overflow-x: hidden;
  padding-top: 80px; 
}

/* ä¿®å¤å¯¼èˆªæ ä¸‹æ–¹çš„è“è‰²ç¼éš™ */
main {
  margin-top: -2px; 
  position: relative;
  z-index: 1;
}

/* =========================================
   LAYOUT (ä¾§è¾¹æ å¸ƒå±€ç³»ç»Ÿ)
   ========================================= */

.container.gallery-layout {
  max-width: 1400px; 
  width: 95%;        
}

.gallery-layout {
  display: grid;
  grid-template-columns: 280px 1fr; 
  gap: 30px;
  align-items: start;
  margin-top: 30px;
}

/* å¼ºåˆ¶å…è®¸æº¢å‡ºï¼Œç¡®ä¿ Sticky ç”Ÿæ•ˆ */
.section.stripe.s4 {
  overflow: visible !important;
}

.gallery-sidebar {
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  box-sizing: border-box;
  
  /* ä¾§è¾¹æ å¸é™„ */
  position: sticky;       
  top: 100px;             
  max-height: calc(100dvh - 120px);
  max-height: calc(100vh - 120px); 
  overflow-y: auto;       
  overflow-x: hidden;
  overscroll-behavior: auto;
  scrollbar-gutter: stable;
  z-index: 10;
}

/* When filter content is taller than the viewport, disable sticky mode to avoid clipping while page scrolls */
.gallery-sidebar.sidebar-static {
  position: static;
  top: auto;
  max-height: none;
  overflow: visible;
}

.gallery-sidebar::-webkit-scrollbar { width: 6px; }
.gallery-sidebar::-webkit-scrollbar-track { background: transparent; }
.gallery-sidebar::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }
.gallery-sidebar::-webkit-scrollbar-thumb:hover { background: var(--ink); }

/* =========================================
   MENU & BUTTONS
   ========================================= */
details.category-group { margin-bottom: 15px; }

summary.category-title {
  list-style: none;
  font-family: 'Baloo 2', cursive;
  font-size: 20px;
  font-weight: 800;
  cursor: pointer;
  padding: 10px;
  background: var(--c1);
  border: 3px solid var(--ink);
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: transform 0.1s;
  position: relative;
}
summary.category-title:hover { transform: translateY(-2px); }
summary.category-title:active { transform: translateY(1px) scale(0.98); }

summary.category-title::after { 
  content: '+'; 
  font-weight: 900; 
  font-size: 24px;
  line-height: 1;
  display: inline-block;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
details[open] summary.category-title::after { 
  transform: rotate(135deg); 
  color: #ff5e5e; 
}
summary.category-title::-webkit-details-marker { display: none; }

.submenu {
  padding: 10px 0 0 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 3px dashed #ccc;
  margin-left: 15px;
}
details[open] .submenu {
  animation: menuSlideDown 0.4s ease-out forwards;
}

@keyframes menuSlideDown {
  0% { opacity: 0; transform: translateY(-15px); }
  100% { opacity: 1; transform: translateY(0); }
}

.filter-btn {
  background: none;
  border: none;
  text-align: left;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 16px;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 8px;
  color: var(--ink);
  position: relative;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.filter-btn:hover { background: rgba(0,0,0,0.05); padding-left: 18px; }
.filter-btn:active { transform: scale(0.92); background: rgba(0,0,0,0.1); transition: transform 0.1s; }

.filter-btn.active {
  background: var(--c2);
  border: 2px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  color: var(--ink);
  animation: btnPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes btnPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.15); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1); }
}

.month-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.month-grid .filter-btn { text-align: center; padding-left: 0; }
.month-grid .filter-btn:hover { padding-left: 0; transform: scale(1.08); background: var(--c4); z-index: 1; }
.month-grid .filter-btn:active { transform: scale(0.9); }

/* =========================================
   DESKTOP: COMPACT CALENDAR-STYLE FILTERS
   (Year / Month only, mobile keeps old layout)
   ========================================= */
@media (min-width: 901px) {
  .gallery-sidebar .category-group--calendar {
    background: rgba(168, 244, 255, 0.22);
    border: 3px solid var(--ink);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 3px 4px 0 rgba(0,0,0,0.16);
  }

  .gallery-sidebar .category-group--calendar > summary.category-title {
    margin: 0;
    font-size: 18px;
    padding: 8px 10px;
    border-radius: 12px;
  }

  .gallery-sidebar .category-group--calendar > .submenu {
    margin: 8px 0 0;
    padding: 0;
    border-left: 0;
    gap: 8px;
  }

  .gallery-sidebar .category-group--calendar[open] .submenu {
    animation: none;
  }

  .gallery-sidebar .year-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .gallery-sidebar .category-group--month .month-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .gallery-sidebar .category-group--calendar .filter-btn {
    text-align: center;
    padding: 8px 6px;
    min-height: 40px;
    border: 2px solid var(--ink);
    border-radius: 10px;
    background: #fff;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
    font-size: 14px;
    line-height: 1.1;
  }

  .gallery-sidebar .category-group--calendar .filter-btn:hover {
    padding-left: 6px;
    transform: translateY(-2px) scale(1.03);
    background: var(--c4);
    z-index: 1;
  }

  .gallery-sidebar .category-group--calendar .filter-btn:active {
    transform: translateY(0) scale(0.97);
  }

  .gallery-sidebar .category-group--calendar .filter-btn.active {
    border-width: 3px;
    box-shadow: 3px 3px 0 var(--ink);
  }

  .gallery-sidebar .category-group--year .js-year-btn[data-year="all"],
  .gallery-sidebar .category-group--month .js-month-btn[data-month="all"] {
    grid-column: 1 / -1;
    min-height: 42px;
    background: linear-gradient(180deg, #fff 0%, rgba(255, 204, 255, 0.55) 100%);
    font-weight: 800;
  }
}

/* =========================================
   DESKTOP WIDE: MOVE CATEGORY TILES LEFT OF MONTH
   ========================================= */
@media (min-width: 1200px) {
  .gallery-layout {
    grid-template-columns: 520px 1fr;
    gap: 24px;
  }

  .gallery-sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-content: start;
  }

  .gallery-sidebar > h3,
  .gallery-sidebar > div:nth-of-type(1),
  .gallery-sidebar > .gallery-search,
  .gallery-sidebar > .category-group--year,
  .gallery-sidebar > .category-group--month {
    grid-column: 1 / -1;
  }

  .gallery-sidebar > .category-group--vrc {
    grid-column: 1;
    grid-row: auto;
    margin-bottom: 0;
  }

  .gallery-sidebar > .category-group--furmeet {
    grid-column: 2;
    grid-row: auto;
    margin-bottom: 0;
  }

  .gallery-sidebar > .sidebar-hd-panel {
    grid-column: 1 / -1;
    margin-top: 0 !important;
    padding-top: 0 !important;
    border-top: 0 !important;
  }

  .gallery-sidebar > .category-group--tile {
    background: rgba(255, 204, 255, 0.18);
    border: 3px solid var(--ink);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 3px 4px 0 rgba(0,0,0,0.16);
  }

  .gallery-sidebar > .category-group--tile > summary.category-title {
    min-height: 88px;
    padding: 12px 12px 14px;
    border-radius: 14px;
    justify-content: center;
    text-align: center;
    line-height: 1.15;
    font-size: 17px;
    background: var(--c1);
  }

  .gallery-sidebar > .category-group--tile > summary.category-title::after {
    position: absolute;
    right: 10px;
    top: 8px;
    font-size: 22px;
  }

  .gallery-sidebar > .category-group--tile > .submenu {
    margin: 8px 0 0;
    padding: 8px 0 0;
    border-left: 0;
    border-top: 2px dashed rgba(0,0,0,0.35);
    margin-left: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .gallery-sidebar > .category-group--tile > .submenu .filter-btn {
    text-align: center;
    padding: 8px 6px;
    border: 2px solid var(--ink);
    border-radius: 10px;
    background: #fff;
    box-shadow: 2px 2px 0 rgba(0,0,0,0.16);
    font-size: 13px;
    line-height: 1.1;
  }

  .gallery-sidebar > .category-group--tile > .submenu .filter-btn:hover {
    padding-left: 6px;
    transform: translateY(-2px) scale(1.02);
    background: var(--c4);
  }

  .gallery-sidebar > .sidebar-hd-panel .btn {
    width: 100%;
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    border-radius: 16px;
    padding: 12px 14px;
    line-height: 1.15;
    font-size: 15px;
    box-shadow: 0 4px 0 #2f3542;
    transform: none;
  }

  .gallery-sidebar > .sidebar-hd-panel .btn:hover {
    transform: none;
    box-shadow: 0 5px 0 #2f3542;
  }

  .gallery-sidebar > .sidebar-hd-panel .btn:active {
    transform: translateY(1px);
    box-shadow: 0 3px 0 #2f3542;
  }

  .gallery-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 12px;
  }
}

/* =========================================
   IMAGE GRID
   ========================================= */
.gallery-grid { 
  display: grid; 
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); 
  gap: 15px; 
}


.gallery-item {
  position: relative;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 16px;
  padding: 8px; 
  padding-bottom: 35px;
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0; 
  animation-fill-mode: forwards;
  transition: transform 0.2s;
}
.gallery-item:hover { transform: translateY(-5px) rotate(-1deg); z-index: 2; }

.gallery-img { 
  width: 100%; 
  height: 180px; 
  object-fit: cover; 
  border: 2px solid var(--ink); 
  border-radius: 8px; 
  background: #eee; 
}

.gallery-caption { 
  position: absolute; 
  bottom: 6px; 
  left: 5px; 
  right: 5px; 
  text-align: center; 
  font-family: 'Baloo 2', cursive; 
  font-size: 14px; 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
}

.section__lead.sticker-style {
  display: inline-block;
  background-color: #fff;
  color: var(--ink);
  padding: 8px 24px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.2);
  font-weight: 800;
  margin-top: 10px;
  margin-bottom: 20px;
  position: relative;
  z-index: 5;
}

/* =========================================
   MOBILE ADAPTATION
   ========================================= */
.mobile-filter-toggle { display: none; }

@media (max-width: 900px) {
  .gallery-layout { display: block; }
  
  .gallery-sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto;
    max-height: 70dvh;
    max-height: 70vh; 
    z-index: 2100; 
    border-radius: 20px 20px 0 0;
    transform: translateY(110%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-bottom: 0;
    overflow-y: auto; 
    overflow-x: hidden;
    overscroll-behavior: contain;
  }
  .gallery-sidebar.is-open { transform: translateY(0); }

  .mobile-filter-toggle {
    display: flex; align-items: center; gap: 8px;
    position: fixed; bottom: 30px; right: 30px; 
    z-index: 2200; 
    background: var(--c4); color: var(--ink);
    border: 4px solid var(--ink); border-radius: 50px;
    padding: 12px 24px;
    font-family: 'Baloo 2', cursive; font-size: 18px; font-weight: 800;
    box-shadow: 4px 6px 0 rgba(0,0,0,0.3);
    cursor: pointer;
    animation: bounceIn 0.5s;
    transition: transform 0.1s;
  }
  .mobile-filter-toggle:active { transform: scale(0.95); }
  
  .sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1950; display: none; }
  .sidebar-overlay.active { display: block; }
}

/* =========================================
   ANIMATIONS
   ========================================= */
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes bounceIn { 0% { transform: scale(0); } 80% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes popInStagger {
  0% { opacity: 0; transform: scale(0.6) translateY(40px); }
  60% { opacity: 1; transform: scale(1.05) translateY(-10px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.8) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.05); } 100% { transform: scale(1); } }

/* =========================================
   COMPONENTS
   ========================================= */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.9); z-index: 9999; display: none; align-items: center; justify-content: center; padding: 20px; }
.lightbox.active { display: flex; animation: fadeIn 0.2s; }
.lightbox-img { max-width: 95%; max-height: 85vh; border: 4px solid #fff; border-radius: 8px; }

/* ä¿®å¤ï¼šå…³é—­æŒ‰é’®å±‚çº§æœ€é«˜ï¼Œé˜²æ­¢è¢«åˆ‡æ¢æŒ‰é’®é®æŒ¡ */
.lightbox-close { 
  position: absolute; 
  top: 20px; 
  right: 20px; 
  color: #fff; 
  font-size: 40px; 
  cursor: pointer; 
  z-index: 10005; /* ç¡®ä¿åœ¨é¡¶å±‚ */
  text-shadow: 0 2px 5px rgba(0,0,0,0.5);
  transition: transform 0.2s;
}
.lightbox-close:hover { transform: scale(1.2) rotate(90deg); color: #ff4757; }

#no-result {
  display: none;
  margin: 60px auto;
  padding: 50px 20px;
  max-width: 500px;
  text-align: center;
  background-color: #fff; 
  border: 4px solid var(--ink);
  border-radius: 24px;
  box-shadow: var(--shadow);
  font-family: 'Baloo 2', cursive;
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
  animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* =========================================
   LIGHTBOX CONTROLS
   ========================================= */
.lb-nav {
  background: rgba(255, 255, 255, 0.1); 
  border: none;
  color: white;
  font-size: 3rem;
  padding: 0 20px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 100%;
  z-index: 10001; 
}
.lb-nav:hover { background: rgba(255, 255, 255, 0.3); color: #FCFF7D; }
.lb-prev { left: 0; }
.lb-next { right: 0; }

@media (max-width: 768px) {
  .lb-nav { font-size: 2rem; padding: 0 15px; background: transparent; }
}

/* =========================================`r`n   LIGHTBOX DOWNLOAD BUTTON (æ–°æ ·å¼)
   ========================================= */
.lb-download-btn {
  position: absolute;
  bottom: 30px;
  right: 30px;
  
  background-color: #fff;
  color: var(--ink, #000); 
  font-family: 'Baloo 2', cursive;
  font-weight: 800;
  font-size: 18px;
  text-decoration: none;
  
  padding: 10px 24px;
  border: 4px solid var(--ink, #000);
  border-radius: 50px; 
  box-shadow: 4px 6px 0 rgba(0,0,0,0.4); 
  
  z-index: 10010; 
  transition: transform 0.2s, background-color 0.2s;
  
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer; /* ç¡®ä¿é¼ æ ‡å˜æˆæ‰‹åž‹ */
}

.lb-download-btn:hover {
  background-color: #7bed9f; 
  transform: scale(1.1) rotate(-2deg); 
  box-shadow: 6px 8px 0 rgba(0,0,0,0.5);
}

.lb-download-btn:active {
  transform: scale(0.95);
  box-shadow: 2px 3px 0 rgba(0,0,0,0.5);
}

@media (max-width: 768px) {
  .lb-download-btn {
    bottom: 20px;
    right: 20px;
    padding: 8px 16px;
    font-size: 14px;
    border-width: 3px;
  }
}


/* =========================================
   NEW: GALLERY ENHANCEMENTS (Search / Sort / Infinite Scroll / Lightbox)
   ========================================= */

/* Fix: caption positioning anchor */
.gallery-item{
  position: relative;
  content-visibility: auto;
  contain-intrinsic-size: 220px 240px;
}

/* Screen-reader only */
.sr-only{
  position:absolute !important;
  width:1px; height:1px;
  padding:0; margin:-1px;
  overflow:hidden; clip:rect(0,0,0,0);
  white-space:nowrap; border:0;
}

/* Search box */
.gallery-search{
  position: relative;
  margin: 12px 0 18px 0;
}

.search-input{
  width: 100%;
  padding: 12px 44px 12px 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  box-shadow: 4px 6px 0 rgba(0,0,0,0.25);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  outline: none;
}

.search-input:focus{
  transform: translateY(-1px);
}

.search-clear{
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  background: var(--c4);
  font-family: 'Baloo 2', cursive;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  box-shadow: 3px 4px 0 rgba(0,0,0,0.25);
}

.search-clear:hover{ transform: translateY(-50%) scale(1.06); }
.search-clear:active{ transform: translateY(-50%) scale(0.95); }

/* Sort buttons layout */
.sort-grid{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

/* Infinite scroll sentinel */
.scroll-sentinel{
  height: 1px;
  width: 100%;
  margin-top: 24px;
}

/* Lightbox: loading state + copy link button */
.lightbox.is-loading #lightbox-img{
  filter: blur(2px);
  transform: scale(0.995);
}

.lightbox.is-loading::after{
  content: "Loadingâ€¦";
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  padding: 10px 16px;
  border: 4px solid var(--ink, #000);
  border-radius: 999px;
  background: #fff;
  font-family: 'Baloo 2', cursive;
  font-weight: 800;
  box-shadow: 4px 6px 0 rgba(0,0,0,0.4);
  z-index: 10020;
}

@media (max-width: 520px){
  .sort-grid{ grid-template-columns: 1fr; }
  .lb-download-btn{ right: 18px; bottom: 30px; }
}

