/* =========================================================
 * 냠냠픽업 Gallery — grid + modal popup with floating UI
 * ========================================================= */

.gallery-body {
  display: block;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 100vh;
  background: var(--bg);
  padding-top: 100px;
  padding-bottom: 90px;
}

/* =========================================================
 * Floating top UI
 * ========================================================= */
.floating-header {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 10px 10px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 100px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.floating-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.floating-header .brand-dot {
  width: 32px;
  height: 32px;
  background: var(--yellow);
  border-radius: 8px;
}

.floating-header .brand h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.floating-header .brand p {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray-500);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.floating-mode {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 100px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.floating-mode .mode-btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 100px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  transition: all 0.2s;
  white-space: nowrap;
}

.floating-mode .mode-btn:hover {
  color: var(--white);
}

.floating-mode .mode-btn.active {
  background: var(--yellow);
  color: var(--black);
}

.floating-stats {
  position: fixed;
  top: 24px;
  right: 20px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 100px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 500;
}

.floating-stats strong {
  color: var(--black);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.floating-stats .stat-sep {
  color: var(--gray-300);
}

/* Edit toggle button inside stats pill */
.edit-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 10px;
  padding: 6px 12px;
  background: var(--black);
  color: var(--white);
  border: none;
  border-radius: 100px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}

.edit-toggle-btn:hover {
  background: var(--yellow);
  color: var(--black);
  transform: translateY(-1px);
}

.edit-mode .edit-toggle-btn {
  background: var(--yellow);
  color: var(--black);
}

/* =========================================================
 * Edit toolbar (shown in edit mode)
 * ========================================================= */
.floating-edit-toolbar {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 10px 10px 20px;
  background: rgba(17, 17, 17, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 100px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  color: var(--white);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: calc(100% - 40px);
}

.edit-mode .floating-edit-toolbar {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.edit-mode .floating-mode {
  display: none;
}

.edit-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.edit-dot {
  width: 8px;
  height: 8px;
  background: var(--yellow);
  border-radius: 50%;
  animation: editPulse 1.4s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes editPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.edit-dirty {
  color: var(--yellow);
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.2s;
}

.edit-mode.dirty .edit-dirty {
  opacity: 1;
}

.edit-actions {
  display: flex;
  gap: 6px;
}

.btn-edit {
  padding: 8px 14px;
  border-radius: 100px;
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-reset {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
}

.btn-reset:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-cancel {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
}

.btn-cancel:hover {
  background: rgba(255, 255, 255, 0.2);
}

.btn-save {
  background: var(--yellow);
  color: var(--black);
  font-weight: 700;
}

.btn-save:hover {
  background: #ffe95a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 222, 54, 0.4);
}

/* =========================================================
 * Edit mode card states
 * ========================================================= */
.edit-mode .screen-card {
  cursor: grab;
  position: relative;
  transition: transform 0.2s, opacity 0.2s;
}

.edit-mode .screen-card:active {
  cursor: grabbing;
}

/* Disable hover transform in edit mode to avoid clash with drag */
.edit-mode .screen-card:hover .screen-card-thumb {
  transform: none;
}

.edit-mode .screen-card:hover .expand-hint {
  opacity: 0;
}

/* Drag handle indicator on card */
.edit-mode .screen-card::before {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: rgba(0, 0, 0, 0.72)
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round'><circle cx='9' cy='5' r='1'/><circle cx='9' cy='12' r='1'/><circle cx='9' cy='19' r='1'/><circle cx='15' cy='5' r='1'/><circle cx='15' cy='12' r='1'/><circle cx='15' cy='19' r='1'/></svg>")
    center / 14px no-repeat;
  border-radius: 50%;
  z-index: 3;
  pointer-events: none;
}

.screen-card.dragging {
  opacity: 0.35;
  transform: scale(0.96);
}

.screen-card.drag-over-before {
  box-shadow: inset 4px 0 0 var(--yellow);
  border-radius: 20px;
}

.screen-card.drag-over-after {
  box-shadow: inset -4px 0 0 var(--yellow);
  border-radius: 20px;
}

/* Popup-style thumbnail — show popup centered on dimmed phone background */
.screen-card-thumb.is-popup {
  background:
    linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)),
    repeating-linear-gradient(45deg, #2a2a2a 0 6px, #1f1f1f 6px 12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.screen-card-thumb.is-popup img {
  width: auto;
  max-width: 85%;
  max-height: 85%;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* =========================================================
 * Floating bottom section filter
 * ========================================================= */
.floating-filter {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  max-width: calc(100% - 40px);
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 100px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
  overflow-x: auto;
  scrollbar-width: none;
}

.floating-filter::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 100px;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.filter-chip:hover {
  background: var(--gray-100);
  color: var(--black);
}

.filter-chip.active {
  background: var(--black);
  color: var(--white);
}

.filter-chip .chip-count {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  color: inherit;
}

.filter-chip.active .chip-count {
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
}

/* =========================================================
 * Gallery main grid
 * ========================================================= */
.gallery-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 32px;
}

.gallery-section {
  margin-bottom: 64px;
  scroll-margin-top: 100px;
}

.gallery-section:last-child {
  margin-bottom: 0;
}

.gallery-section.hidden {
  display: none;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--gray-150);
}

.section-head h3 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--black);
}

.section-head .section-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  background: var(--yellow-light);
  border-radius: 100px;
}

.section-head .section-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
}

/* Grid */
.screen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
}

/* =========================================================
 * Screen card
 * ========================================================= */
.screen-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  text-align: left;
  font-family: inherit;
  animation: fadeInUp 0.4s ease both;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen-card-thumb {
  position: relative;
  aspect-ratio: 390 / 844;
  background: var(--white);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--gray-150);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
}

.screen-card:hover .screen-card-thumb {
  transform: translateY(-6px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.14);
  border-color: var(--yellow);
}

.screen-card-thumb img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.screen-card-thumb::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(0, 0, 0, 0.4) 100%);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.screen-card:hover .screen-card-thumb::after {
  opacity: 1;
}

.expand-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  padding: 7px 16px;
  background: var(--yellow);
  color: var(--black);
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.2, 0, 0, 1);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.screen-card:hover .expand-hint {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.screen-card-info {
  padding: 0 4px;
}

.screen-card-number {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-400);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.screen-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--black);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* =========================================================
 * Modal — full-screen with floating UI
 * ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  padding: 40px 100px;
}

.modal-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.show .modal {
  animation: modalEnter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Close button (top-right) */
.modal-close {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1010;
}

.modal-close:hover {
  background: var(--yellow);
  color: var(--black);
  border-color: var(--yellow);
  transform: rotate(90deg);
}

/* Modal meta (top-left) */
.modal-meta-float {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 1010;
  max-width: 340px;
  padding: 12px 18px 12px 18px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
}

.modal-section {
  display: inline-block;
  padding: 2px 10px;
  background: var(--yellow);
  color: var(--black);
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.modal-meta-float h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 300px;
}

/* Counter (top center-right) */
.modal-counter-float {
  position: fixed;
  top: 32px;
  right: 84px;
  z-index: 1010;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
}

/* Modal arrows */
.modal-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 1010;
}

.modal-arrow-prev {
  left: 24px;
}

.modal-arrow-next {
  right: 24px;
}

.modal-arrow:hover:not(:disabled) {
  background: var(--yellow);
  color: var(--black);
  border-color: var(--yellow);
  transform: translateY(-50%) scale(1.08);
}

.modal-arrow:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* Modal phone */
.modal-phone-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-phone {
  margin: 0;
}

.modal-phone .phone-frame {
  max-height: calc(100vh - 100px);
}

/* Modal hints (bottom-center) */
.modal-hints-float {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1010;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
}

.modal-hints-float .hint-sep {
  color: rgba(255, 255, 255, 0.3);
}

.modal-hints-float kbd {
  display: inline-block;
  padding: 1px 6px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  color: var(--white);
  min-width: 18px;
  text-align: center;
}

/* Prevent body scroll when modal open */
body.modal-open {
  overflow: hidden;
}

/* =========================================================
 * Responsive
 * ========================================================= */
@media (max-width: 900px) {
  .gallery-body {
    padding-top: 80px;
    padding-bottom: 80px;
  }

  .floating-header {
    top: 12px;
    left: 12px;
    padding: 8px 14px 8px 8px;
  }

  .floating-header .brand h1 {
    font-size: 13px;
  }

  .floating-header .brand p {
    display: none;
  }

  .floating-header .brand-dot {
    width: 28px;
    height: 28px;
  }

  .floating-mode {
    top: 14px;
    padding: 3px;
  }

  .floating-mode .mode-btn {
    padding: 7px 12px;
    font-size: 11px;
  }

  .floating-stats {
    top: 14px;
    right: 12px;
    padding: 10px 14px;
    font-size: 11px;
  }

  .floating-stats .stat:nth-child(3),
  .floating-stats .stat-sep {
    display: none;
  }

  .floating-filter {
    bottom: 12px;
    max-width: calc(100% - 24px);
  }

  .filter-chip {
    padding: 7px 12px;
    font-size: 11px;
  }

  .gallery-main {
    padding: 0 16px;
  }

  .gallery-section {
    margin-bottom: 40px;
  }

  .section-head h3 {
    font-size: 19px;
  }

  .screen-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
  }

  .screen-card-thumb {
    border-radius: 14px;
  }

  /* Modal */
  .modal-backdrop {
    padding: 16px;
  }

  .modal-arrow {
    width: 44px;
    height: 44px;
  }

  .modal-arrow-prev {
    left: 12px;
  }

  .modal-arrow-next {
    right: 12px;
  }

  .modal-close {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
  }

  .modal-meta-float {
    top: 12px;
    left: 12px;
    right: 64px;
    max-width: none;
    padding: 8px 14px;
  }

  .modal-meta-float h2 {
    font-size: 13px;
    max-width: 100%;
  }

  .modal-section {
    font-size: 9px;
  }

  .modal-counter-float {
    display: none;
  }

  .modal-phone .phone-frame {
    width: 300px;
    height: 650px;
    border-radius: 32px;
    max-height: calc(100vh - 150px);
  }

  .modal-phone .phone-screen img {
    width: 300px;
  }

  .modal-hints-float {
    display: none;
  }
}

@media (max-width: 520px) {
  .screen-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .modal-phone .phone-frame {
    width: 260px;
    height: 565px;
  }

  .modal-phone .phone-screen img {
    width: 260px;
  }
}
