/* ========================================
   album-detail.css

   Breakpoints:
   - Mobile:  360px - 741px (기본)
   - Tablet:  742px - 1199px
   - Desktop: 1200px+
   ======================================== */

/* ========================================
   1. Reset & Base
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #000;
    color: #fff;
    overflow-x: hidden;
}

/* Body scroll lock - 모달 열릴 때 JS로 추가 */
body.scroll-lock {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* ========================================
   2. Layout
   ======================================== */
.container {
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh; /* iOS Safari 대응 */
    padding: 0;
}

/* ========================================
   3. Header
   ======================================== */
.header-frame {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.8), rgba(0,0,0,0));
    z-index: 100;
}

.logo {
    height: 24px;
    width: auto;
}

.back-button,
.more-button {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 24px;
}

/* ========================================
   4. Hero Section
   ======================================== */
.header-spacer {
  height: 60px;
}

.album-hero {
  position: relative;
}

.album-hero .cover {
  width: 100%;
  height: 240px; /* hero 크기 */
  object-fit: cover;
  display: block;
}

.hero-overlay {
  position: absolute;
  inset: 0; /* top right bottom left = 0 */
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
  /* 상단 + 하단 그라데이션으로 커버 느낌 */
  background:
    linear-gradient(to bottom, rgba(0,0,0,0.4) 0%, transparent 30%),
    linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 50%, transparent 100%);
}

.grid-toggle-icon-wrapper {
  position: absolute;
  right: 12px;
  bottom: 12px;
}

.grid-toggle-icon {
    align-items: end;
    height: 24px;
    width: 24px;
}

/* ========================================
   6. Photo Grid
   ======================================== */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 0;
    margin-bottom: 40px;
}

.photo-grid.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* 개선: padding-bottom hack → aspect-ratio */
.photo-card {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    cursor: pointer;
    background-color: #1a1a1a;
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.photo-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    transition: opacity 0.2s;
}

.photo-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photo-date {
    font-size: 10px;
    color: #999;
    margin-top: 2px;
}

/* ========================================
   7. Empty State
   ======================================== */
.empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-text {
    font-size: 16px;
    color: #666;
}

/* ========================================
   8. Loading & Error
   ======================================== */
.loading,
.error {
    text-align: center;
    padding: 40px 20px;
    font-size: 14px;
    color: #999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid #333;
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.error {
    color: #ff4444;
}

/* ========================================
   8.5. Like Button (Photo Card)
   ======================================== */
.like-btn {
    position: absolute;
    bottom: 8px;
    left: 8px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 12px;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    gap: 4px;
}

.like-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Heart Icon (SVG) */
.heart-icon {
    width: 20px;
    height: 20px;
    vertical-align: middle;
}

.heart-icon.heart-lg {
    width: 32px;
    height: 32px;
}

/* ========================================
   9. Menu (Bottom Sheet)
   개선: 100dvh로 iOS Safari 대응
   ======================================== */
.menu-overlay {
    position: fixed;
    inset: 0; /* top/right/bottom/left: 0 */
    height: 100vh;
    height: 100dvh; /* iOS Safari 대응 */
    background: rgba(0,0,0,0.7);
    z-index: 200;
}

.menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a1a1a;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom)); /* 노치 대응 */
    z-index: 201;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

.menu-item {
    width: 100%;
    padding: 16px;
    background: none;
    border: none;
    color: #fff;
    font-size: 16px;
    text-align: left;
    cursor: pointer;
}

.menu-item-delete {
    color: #ff4444;
}

.menu-divider {
    height: 1px;
    background: #333;
    margin: 8px 0;
}

/* Dropdown Menu */
.dropdown-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1a1a1a;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    z-index: 201;
    animation: slideUp 0.3s ease-out;
}

.dropdown-menu button {
    width: 100%;
    padding: 16px;
    background: none;
    border: none;
    color: #fff;
    font-size: 16px;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
}

.dropdown-menu button:hover {
    background: #333;
}

.dropdown-menu button.danger {
    color: #ff4444;
}

/* ========================================
   10. Image Viewer Modal
   개선: 100dvh로 iOS Safari 대응
   ======================================== */
.image-viewer {
    position: fixed;
    inset: 0;
    height: 100vh;
    height: 100dvh; /* iOS Safari 대응 */
    background: #000;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
}

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

.viewer-content img {
    max-width: 90%;
    max-height: 80%;
    object-fit: contain;
}

.viewer-close {
    position: absolute;
    top: 20px;
    top: calc(20px + env(safe-area-inset-top)); /* 노치 대응 */
    right: 20px;
    width: 44px;
    height: 44px;
    background: rgba(0,0,0,0.5);
    border: none;
    border-radius: 22px;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    z-index: 10;
}

.viewer-image {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.viewer-actions {
    position: absolute;
    bottom: 40px;
    bottom: calc(40px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
}

.viewer-like-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: rgba(0,0,0,0.7);
    border: none;
    border-radius: 24px;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

.viewer-like-btn:hover {
    background: rgba(0,0,0,0.9);
}

.viewer-like {
    position: absolute;
    bottom: 40px;
    bottom: calc(40px + env(safe-area-inset-bottom)); /* 노치 대응 */
    right: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(0,0,0,0.7);
    border: none;
    border-radius: 24px;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
}

.viewer-like-count {
    font-size: 16px;
    font-weight: 600;
}

.viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(0,0,0,0.5);
    border: none;
    border-radius: 25px;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-prev,
.viewer-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(0,0,0,0.5);
    border: none;
    border-radius: 25px;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-prev {
    left: 20px;
}

.viewer-next {
    right: 20px;
}

/* ========================================
   11. Hover - 데스크톱 전용
   개선: @media (hover: hover)로 hover 지원 기기만
   ======================================== */

/* 모바일: photo-info 항상 표시 */
.photo-info {
    opacity: 1;
}

/* hover 지원 기기에서만 hover 효과 */
@media (hover: hover) {
    .back-button:hover,
    .more-button:hover,
    .grid-toggle-button:hover {
        opacity: 0.7;
    }

    .photo-card img {
        transition: transform 0.2s;
    }

    .photo-card:hover img {
        transform: scale(1.05);
    }

    /* hover 지원시 photo-info 숨김 → hover로 표시 */
    .photo-info {
        opacity: 0;
    }

    .photo-card:hover .photo-info {
        opacity: 1;
    }

    .menu-item:hover {
        background: #333;
    }

    .viewer-like:hover {
        background: rgba(0,0,0,0.9);
    }

    .viewer-prev:hover,
    .viewer-next:hover {
        background: rgba(0,0,0,0.8);
    }
}

/* ========================================
   12. Responsive - Tablet (742px - 1199px)
   ======================================== */
@media (min-width: 742px) {
    /* Header */
    .logo {
        height: 28px;
    }

    /* Content */
    .album-title {
        font-size: 32px;
    }

    /* Photo Grid */
    .photo-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .photo-grid.grid-4 {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ========================================
   13. Responsive - Desktop (1200px+)
   ======================================== */
@media (min-width: 1200px) {
    /* Layout */
    .container {
        max-width: 1200px;
        margin: 0 auto;
    }

    /* Header */
    .header-frame {
        max-width: 1200px;
        margin: 0 auto;
    }

    .logo {
        height: 32px;
    }

    /* Content */
    .album-title {
        font-size: 36px;
    }

    /* Photo Grid */
    .photo-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .photo-grid.grid-4 {
        grid-template-columns: repeat(6, 1fr);
    }
}
