/* 커스텀 폰트 */
@font-face {
    font-family: 'Newyear Coffee';
    src: url('./Newyear Coffee.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

html, body {
    margin: 0;
    padding: 0;
    overflow: auto;
    height: 100%;
    width: 100%;
    font-family: 'Newyear Coffee', sans-serif;
}

body{
    background-color: rgb(253, 242, 231);
    display: flex;
    justify-content: start;
    align-items: start;
}

.container{
    position: relative;
    width: 1280px;
    min-height: 832px;
    margin: 0;
    transform-origin: left top;
    left: 0;
    top: 0;
}

body {
    min-height: 100vh;
}

.background {
    display: block;
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
    position: absolute;
    top: 0;
    left: 0;
}

.character-btn {
    position: absolute;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 10;
    transition: transform 0.1s;
}

.character-btn:hover {
    transform: scale(1.1);
}

.character-btn[data-fixed="true"] {
    cursor: pointer;
}

.character-btn[data-fixed="true"]:hover {
    transform: scale(1.1);
}

.character-btn img {
    width: auto;
    height: auto;
    max-width: 210px;
    max-height: 210px;
    object-fit: contain;
    pointer-events: none;
}

.character-btn[data-asset="asset3.png"] img {
    max-width: 294px;
    max-height: 294px;
}

.character-btn[data-asset="asset8.png"] img {
    max-width: 294px;
    max-height: 294px;
}

.character-btn[data-asset="asset9.png"] img {
    max-width: 262.5px;
    max-height: 262.5px;
}

.foreground-fence {
    position: absolute;
    top: 272px;
    left: 262px;
    z-index: 20;
    pointer-events: none;
}

/* 팝업 스타일 */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(5px);
    background-color: var(--popup-bg-color, rgba(0, 0, 0, 0.5));
}

.popup-overlay.show {
    opacity: 1;
    visibility: visible;
}

.popup-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: popupFadeIn 0.3s ease;
}

@keyframes popupFadeIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.popup-image {
    max-width: 100%;
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* HTML에 직접 포함된 정적 팝업 오버레이 */
.popup-overlay-static {
    position: fixed;
    top: 40px;
    right: 40px;
    bottom: 40px;
    left: 40px;
    z-index: 10000;
    display: none; /* 기본적으로 숨김 */
    justify-content: end;
    align-items: end;
    background-color: rgb(244, 239, 226);
    border: 3px solid rgb(9, 9, 9);
    overflow: hidden; /* 팝업 오버레이 자체는 스크롤 불가 */
}

.popup-overlay-static.show {
    display: flex; /* show 클래스가 있을 때만 보임 */
}


.popup-text {
    position: absolute;
    top: 20px;
    right: 20px;
    
    font-size: 50px;
    font-weight: bold;
    color: #000;
    text-align: right;
    
    max-width: min(40vw, 520px);
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    
    /* 레이아웃에서 제외 - 폭 차지 안 함 */
    z-index: 10;
}

.popup-content {
    position: relative;
    max-width: 100vw;
    max-height: 100vh;
    width: 100%;
    height: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: end;
    gap: 10px;
    padding-bottom: 20px;
    overflow: hidden; /* 팝업 콘텐츠는 스크롤 불가 */
}

.popup-image-container {
    position: relative; /* .popup-text의 absolute 기준점 */
    display: flex;
    flex-direction: column;
    align-items: end;
    justify-content: flex-end;
    gap: 10px;
    padding-bottom: 20px;
    padding-top: 20px;
    margin-top: 10px;
    height: 100%;
    overflow: visible; /* absolute 텍스트가 잘리지 않도록 */
    flex-shrink: 0;
}

.popup-image-static {
    margin-top: 10px;
    max-width: 100vw;
    max-height: 100vh;
    width: auto;
    height: auto;
    min-width: 200px;
    object-fit: contain;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    flex-shrink: 0;
}

/* Masonry-like 레이아웃 - 스크롤 컨테이너 */
.popup-grid {
    flex: 1;
    min-width: 300px;
    width: 100%;
    height: 100%;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

/* 실제 columns 레이아웃을 담당하는 내부 래퍼 */
.popup-grid-inner {
    column-count: 3;
    column-gap: 10px;
    width: 100%;
}

/* asset1 / asset9: 그리드 콘텐츠를 더 크게 보이게 */
.popup-overlay-static.grid-large-asset1 .popup-grid-inner,
.popup-overlay-static.grid-large-asset9 .popup-grid-inner {
    column-count: 2;
}
.popup-grid::after {
    content: "";
    display: block;
    height: 20px;     /* 위 여백과 같은 값 */
  }
.popup-grid.popup-grid-empty {
    display: none;
    flex: 0;
    min-width: 0;
}

.grid-item {
    position: relative;
    width: 100%;
    margin-bottom: 10px;
    border-radius: 0px;
    overflow: hidden;
    /* columns 레이아웃에서 아이템이 잘리지 않도록 */
    break-inside: avoid;
    display: block;
}

/* 이미지/비디오: 가로 100%, 세로는 비율에 맞게 자동 */
.grid-item-media {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 0px;
    /* 잘림 방지: 전체 보이기 */
    object-fit: contain;
}

/* 비디오 컨테이너 (재생 버튼 오버레이용) */
.video-container {
    position: relative;
    width: 100%;
    display: block;
}

/* 비디오 기본 브라우저 컨트롤 숨김 (재생 전 상태) */
video.hide-controls::-webkit-media-controls {
    display: none !important;
    opacity: 0 !important;
}

video.hide-controls::-webkit-media-controls-enclosure {
    display: none !important;
    opacity: 0 !important;
}

video.hide-controls::-webkit-media-controls-panel {
    display: none !important;
    opacity: 0 !important;
}

video.hide-controls::-webkit-media-controls-play-button {
    display: none !important;
}

video.hide-controls::-webkit-media-controls-start-playback-button {
    display: none !important;
}

/* 타임라인/진행바 숨김 */
video.hide-controls::-webkit-media-controls-timeline {
    display: none !important;
}

video.hide-controls::-webkit-media-controls-current-time-display {
    display: none !important;
}

video.hide-controls::-webkit-media-controls-time-remaining-display {
    display: none !important;
}

/* 음량 컨트롤 숨김 */
video.hide-controls::-webkit-media-controls-volume-slider {
    display: none !important;
}

video.hide-controls::-webkit-media-controls-mute-button {
    display: none !important;
}

/* 전체화면 버튼 숨김 */
video.hide-controls::-webkit-media-controls-fullscreen-button {
    display: none !important;
}

/* 오버레이 재생 버튼 숨김 (Safari 등) */
video.hide-controls::-webkit-media-controls-overlay-play-button {
    display: none !important;
}

/* Firefox */
video.hide-controls::-moz-media-controls {
    display: none !important;
}

/* controls 속성이 있어도 hide-controls 클래스가 있으면 숨김 */
video.hide-controls {
    /* iOS Safari에서 기본 컨트롤 숨기기 */
    -webkit-appearance: none;
    appearance: none;
}

/* 긴 영상(50초 초과)용 재생 버튼 오버레이 */
.video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    cursor: pointer;
    z-index: 10;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* 재생 버튼은 기본적으로 숨김 */
.video-play-overlay .video-play-button {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, background-color 0.2s ease, transform 0.2s ease;
}

/* PC: hover 시에만 재생 버튼 표시 */
.video-container:hover .video-play-overlay:not(.hidden) .video-play-button {
    opacity: 1;
    visibility: visible;
}

/* 모바일: 터치 활성화 시 재생 버튼 표시 */
.video-play-overlay.touch-active .video-play-button {
    opacity: 1;
    visibility: visible;
}

.video-play-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.video-play-button {
    width: 80px;
    height: 80px;
    background-color: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    color: white;
    padding: 0;
    padding-left: 6px; /* 시각적으로 중앙 정렬을 위해 */
}

.video-play-button svg {
    width: 40px;
    height: 40px;
}

.video-play-overlay:hover .video-play-button {
    background-color: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* YouTube iframe은 16:9 비율 유지 */
.grid-item-youtube {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
}

.grid-item-youtube iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0px;
}

/* 화면 크기에 따른 열 개수 조절 */
@media (max-width: 1200px) {
    .popup-grid-inner {
        column-count: 2;
    }
}

@media (max-width: 800px) {
    .popup-content {
        flex-direction: column;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .popup-grid {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    
    .popup-grid-inner {
        column-count: 2;
    }
    
    .popup-image-static {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .popup-image-container {
        max-width: 100%;
        box-sizing: border-box;
    }
}
@media (max-width: 600px) {
    .popup-overlay-static {
      top: 12px;
      bottom: 12px;
      left: 12px;
      right: 12px;
    }
  
    .popup-content {
      max-width: 100%;
      padding: 12px;
      box-sizing: border-box;
    }
  
    .popup-grid {
      padding: 12px;
      box-sizing: border-box;
    }

    .popup-image-static {
      max-width: 100%;
      box-sizing: border-box;
    }

    .popup-image-container {
      max-width: 100%;
      box-sizing: border-box;
    }

    /* 모바일에서 텍스트가 세로로 삐져나오지 않도록 */
    /* position: fixed로 뷰포트 기준 고정 - overflow: hidden에 의해 잘리지 않음 */
    .popup-text {
      position: fixed;
      font-size: 24px;
      max-width: none;
      white-space: nowrap;
      top: 20px;
      right: 20px;
      z-index: 10001;
    }
  }
@media (max-width: 500px) {
    .popup-grid-inner {
        column-count: 1;
    }
}
