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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #0a0a0a;
  color: #e0e0e0;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== Auth Screen ===== */
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
}

.auth-container {
  text-align: center;
  padding: 2rem;
  max-width: 360px;
  width: 100%;
}

.auth-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.auth-container h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  color: #888;
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

.pin-input-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.pin-input {
  width: 56px;
  height: 64px;
  background: #1a1a1a;
  border: 2px solid #333;
  border-radius: 12px;
  color: #fff;
  font-size: 1.5rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  -webkit-text-security: disc;
}

.pin-input:focus {
  border-color: #fff;
}

.pin-input.error {
  border-color: #ff4444;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.auth-error {
  color: #ff4444;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.auth-hint {
  color: #555;
  font-size: 0.8rem;
  margin-top: 1rem;
}

/* ===== App Container ===== */
.app {
  opacity: 0;
  transition: opacity 0.5s ease;
}

.app.visible {
  opacity: 1;
}

/* ===== Header ===== */
.header {
  text-align: center;
  padding: 3rem 1.5rem 2rem;
}

.header-title {
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.header-subtitle {
  color: #666;
  font-size: 0.95rem;
  font-weight: 300;
}

/* ===== Trip List (Home) ===== */
.trip-list {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.trip-card {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 16 / 10;
  background: #1a1a1a;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.trip-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.trip-card:active {
  transform: scale(0.98);
}

.trip-card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.trip-card:hover .trip-card-image {
  transform: scale(1.05);
}

.trip-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.85) 0%,
    rgba(0, 0, 0, 0.2) 50%,
    transparent 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.5rem;
}

.trip-card-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.25rem;
}

.trip-card-date {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 0.25rem;
}

.trip-card-desc {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.5);
}

/* ===== Gallery View ===== */
.gallery-view {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 0.75rem 3rem;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: #888;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 1rem 0.75rem;
  transition: color 0.2s;
  font-family: inherit;
}

.back-btn:hover {
  color: #fff;
}

.gallery-header {
  text-align: center;
  padding: 0.5rem 1rem 2rem;
}

.gallery-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.25rem;
}

.gallery-date {
  color: #888;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.gallery-desc {
  color: #666;
  font-size: 0.9rem;
}

/* ===== Section Accordion ===== */
.gallery-section {
  margin-bottom: 0.5rem;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 1.25rem 0.5rem;
  border: none;
  border-bottom: 1px solid #222;
  background: none;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.section-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.gallery-section:first-child .section-header {
  padding-top: 0.5rem;
}

.section-arrow {
  flex-shrink: 0;
  color: #666;
  transition: transform 0.3s ease;
}

.gallery-section:not(.collapsed) .section-arrow {
  transform: rotate(90deg);
}

.section-name {
  font-size: 1.1rem;
  font-weight: 600;
  color: #ccc;
  letter-spacing: 0.02em;
}

.section-count {
  font-size: 0.8rem;
  color: #555;
  background: #1a1a1a;
  padding: 2px 8px;
  border-radius: 10px;
}

.section-content {
  overflow: hidden;
  transition: max-height 0.4s ease, opacity 0.3s ease;
  max-height: 20000px;
  opacity: 1;
}

.gallery-section.collapsed .section-content {
  max-height: 0;
  opacity: 0;
}

.section-grid {
  columns: 4;
  column-gap: 6px;
  padding: 0.5rem 2px 0;
}

/* ===== Gallery Loading ===== */
.gallery-loading {
  column-span: all;
  text-align: center;
  padding: 4rem 1rem;
  color: #666;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #222;
  border-top-color: #888;
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Masonry Grid ===== */
.masonry-grid {
  padding: 0 2px;
}

.masonry-item {
  break-inside: avoid;
  margin-bottom: 6px;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: #1a1a1a;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.4s ease forwards;
}

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

.masonry-item img,
.masonry-item video {
  display: block;
  width: 100%;
  height: auto;
  transition: transform 0.3s ease;
}

.masonry-item:hover img,
.masonry-item:hover video {
  transform: scale(1.03);
}

/* Video thumbnail wrapper — 16:9 고정 비율 */
.video-thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #111;
}

.video-thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Video overlay */
.video-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}

.video-indicator svg {
  fill: #fff;
  margin-left: 4px;
}

.masonry-item:hover .video-indicator {
  transform: translate(-50%, -50%) scale(1.1);
  background: rgba(0, 0, 0, 0.8);
}

/* Loading placeholder */
.media-placeholder {
  width: 100%;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  font-size: 2rem;
  min-height: 200px;
}

/* ===== Lightbox ===== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox.visible {
  opacity: 1;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  z-index: 10;
  padding: 8px;
  transition: color 0.2s;
}

.lightbox-close:hover {
  color: #fff;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  z-index: 10;
  padding: 16px;
  transition: color 0.2s;
}

.lightbox-nav:hover {
  color: #fff;
}

.lightbox-prev {
  left: 0.5rem;
}

.lightbox-next {
  right: 0.5rem;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-content img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-content video {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 4px;
  outline: none;
}

.lightbox-counter {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: #666;
  font-size: 0.85rem;
}

/* ===== Responsive ===== */

/* Tablet */
@media (max-width: 1024px) {
  .section-grid {
    columns: 3;
  }

  .trip-list {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

/* Mobile */
@media (max-width: 768px) {
  .section-grid {
    columns: 2;
    column-gap: 4px;
  }

  .masonry-item {
    margin-bottom: 4px;
    border-radius: 6px;
  }

  .header {
    padding: 2rem 1rem 1.5rem;
  }

  .header-title {
    font-size: 1.5rem;
  }

  .trip-list {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0 0.75rem 2rem;
  }

  .trip-card {
    border-radius: 12px;
  }

  .gallery-header {
    padding: 0.5rem 0.75rem 1.5rem;
  }

  .gallery-title {
    font-size: 1.35rem;
  }

  .lightbox-nav {
    padding: 12px;
  }

  .lightbox-prev {
    left: 0;
  }

  .lightbox-next {
    right: 0;
  }

  .video-indicator {
    width: 44px;
    height: 44px;
  }

  .pin-input {
    width: 48px;
    height: 56px;
    font-size: 1.25rem;
  }
}

/* Small Mobile */
@media (max-width: 400px) {
  .pin-input {
    width: 44px;
    height: 52px;
    gap: 8px;
  }

  .pin-input-group {
    gap: 8px;
  }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* ===== Utility ===== */
[hidden] {
  display: none !important;
}
