@import url('https://fonts.googleapis.com/css2?family=Jua&family=Noto+Sans+KR:wght@400;700&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    background-color: #f0f0f0;
    font-family: sans-serif;
    padding: 0; 
    transition: background-color 0.3s;
    overflow: hidden; 
    height: 100vh;
    display: flex;
    flex-direction: column;
    /* 배경 설정 */
    background-image: url('https://imgur.com/LW5rYRE.png');
    background-size: cover; 
    background-repeat: no-repeat; 
    background-position: center top; 
    background-attachment: fixed; 
}

.main-title {
    position: absolute; 
    top: 70px;          
    left: -15px;         
    z-index: 100;       
    text-align: left;
    color: #001fff;
    pointer-events: none; /* 제목 드래그 방지 */
    user-select: none;    /* 제목 텍스트 선택 방지 */
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 700;
}

.title-image {
    height: 400px;   
    width: auto;   
    display: block;
    margin-bottom: 8px; 
}

.main-title p {
    margin: 0;
    margin-left: 220px;
    margin-top: -390px;
    font-size: 14px;
    opacity: 0.9;
    text-shadow: none; 
}

/* ---------------------- Flex 레이아웃 (가로 스크롤 설정) ---------------------- */

.main-container {
    display: flex; 
    flex-direction: row; 
    flex-wrap: nowrap; 
    
    overflow-x: auto; 
    overflow-y: hidden; 
    
    gap: 40px; 
    
    padding: 0 0 0 250px;
    
    width: 100%;
    height: 100vh; 
    
    align-items: center; 
    justify-content: flex-start; 
    
    scroll-behavior: smooth;
    
    -ms-overflow-style: none;   
    scrollbar-width: none;   
}

/* 스크롤 끝부분 잘림 방지용 가상 요소 */
.main-container::after {
    content: '';
    display: block;
    flex: 0 0 40px; /* 오른쪽 여백 확보 */
    height: 1px;
}

.main-container::-webkit-scrollbar {
    display: none;
}

/* ---------------------- 기본 (세로형) 스타일 ---------------------- */

.archive-item {
    position: relative;
    flex: 0 0 auto; 
    
    width: 250px; 
    height: 450px; 
    background-color: #d3d3d3; 
    overflow: hidden;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease-out;

    user-select: none;
    -webkit-user-select: none;
    z-index: 200;
}

.archive-item:hover {
    transform: translateY(-10px);
}

/* 횡단보도 줄무늬 위치 */
.archive-item::before {
    content: '';
    position: absolute;
    top: 50%; 
    left: 0;
    width: 100%;
    height: 76%; 
    transform: translateY(-50%);
    
    background: repeating-linear-gradient(
        to bottom, 
        #000 0px,
        #000 30px, 
        #fff 30px,
        #fff 60px
    );
    background-size: 100% 60px;
    background-position: center top; 
    z-index: 1; 
}

/* 스크롤 영역 (통로) */
.scroll-area {
    position: absolute;
    right: 15px; 
    top: 50%;
    transform: translateY(-50%);
    width: 30px; 
    height: 90%;
    background-color: rgba(128, 128, 128, 0.3);
    border-radius: 20px;
    
    /* ✅ [수정됨] 이미지가 좁은 통로보다 커도 잘리지 않게 visible로 변경 */
    overflow: visible; 
    
    z-index: 2; 
}

/* 노란 막대 (드래그 대상) */
.crosswalk-strip.yellow-strip {
    position: relative; /* ✅ [수정됨] 자식 요소 위치 기준점 */
    left: 0;
    width: 100%;
    height: 80px; 
    background-color: #ffd700; 
    border-radius: 20px;
    cursor: grab;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    transition: top 0.1s ease-out;
    z-index: 10; /* 이미지보다 뒤에 있지만, 다른 요소보단 위에 */
}

/* 사람 PNG (아이콘) */
.walking-person {
    position: absolute;
    
    /* ✅ [수정됨] 무조건 정중앙 배치 */
    left: 80%;
    top: 50%;
    transform: translate(-50%, -50%);
    
    /* 크기 조절 (필요시 숫자 변경) */
    height: 60px; 
    width: auto; 
    
    pointer-events: none; 
    z-index: 20; /* 노란 막대보다 위에 표시 */
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.5));
}


/* ---------------------- 가로형 스타일 전환 (.horizontal) ---------------------- */

.archive-item.horizontal {
    width: 520px; 
    height: 250px; 
}

.archive-item.horizontal::before {
    background: repeating-linear-gradient(
        to right, 
        #000 0px,
        #000 30px, 
        #fff 30px,
        #fff 60px
    );
    background-size: 60px 100%; 
    background-position: left center;
}

.archive-item.horizontal .scroll-area {
    right: 50%; 
    top: auto; 
    bottom: 15px; 
    transform: translateX(50%); 
    height: 30px; 
    width: 90%; 
}

.archive-item.horizontal .yellow-strip {
    height: 100%; 
    width: 80px; 
    top: 0; 
    left: 0; 
    transition: left 0.1s ease-out;
}

/* 가로형일 때 사람 위치 보정 */
.archive-item.horizontal .walking-person {
    /* ✅ [수정됨] 가로형에서도 중앙 정렬 유지 */
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    /* 필요하다면 여기서 rotate(90deg) 등을 추가할 수 있습니다 */
}

/* ---------------------- 공통/보조 요소 스타일 ---------------------- */

.signal-wrapper {
    position: absolute;
    top: 5px;   
    left: 15px;
    display: flex;
    gap: 5px;
    z-index: 5;
}

.signal-light {
    width: 110px; 
    height: 110px;
    background-color: #222;
    border-radius: 10px;
    transition: opacity 0.3s;
    object-fit: contain; 
    
    pointer-events: none;
    -webkit-user-drag: none;
}

.signal-light:not(.active) {
    opacity: 0; 
    position: absolute;
}

.signal-light.active {
    opacity: 1;
    position: relative;
}

.archive-item.horizontal .memo-wrapper {
    top: 15px; 
    left: 150px; 
    transform: none; 
    width: 65%; 
}

.memo-wrapper {
    position: absolute;
    top: 140px; 
    left: 50%;
    transform: translateX(-50%);
    width: 85%; 
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-out, opacity 0.3s ease-in 0.2s;
    z-index: 4; 
}

.memo-wrapper.active {
    max-height: 500px; 
    padding-top: 10px; 
    opacity: 1;
}

.memo-paper {
    background-color: #fffacd; 
    padding: 15px; 
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border: 1px solid #ccc;
    line-height: 1.5;
    color: #333; 
    position: relative; 
    z-index: 12;
  /* ▼▼▼ 여기를 추가하세요! ▼▼▼ */
    max-height: 280px;  /* 카드를 벗어나지 않도록 최대 높이 제한 */
    overflow-y: auto;   /* 내용이 넘치면 스크롤바 생성 */
    
   
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}

/* ---------------------- 텍스트 폰트 스타일 (통합됨) ---------------------- */

/* ---------------------- 텍스트 폰트 스타일 (수정됨) ---------------------- */

/* 신호등 이름 (크게) */
.memo-paper h3 {
    font-family: 'Jua', sans-serif;
    font-size: 20px;
    margin-top: 0;
    margin-bottom: 7px;
    font-weight: normal;
    line-height: 1.3;
    color: #333;
    
    /* 제목도 단어가 잘리지 않게 하려면 추가 */
    word-break: keep-all; 
} /* ← 여기가 빠져 있었습니다! 닫는 괄호 추가 */

/* .sub-country는 h3 안에 넣지 말고 따로 빼주세요 (순수 CSS 기준) */
.sub-country {
    font-size: 17px;
}

/* 국가 이름 (작게, 회색으로) */
.traffic-country {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
    font-weight: 700;
    
    /* 국가 이름도 단어 유지 */
    word-break: keep-all;
}

/* 본문 설명 */
.memo-paper p {
    font-family: 'Noto Sans KR', sans-serif; 
    font-size: 15px;   
    font-weight: 400;  
    line-height: 1.6;  
    margin: 0;
    text-align: left;    
    
    /* 한글 단어 끊김 방지 (이미 작성하셨던 코드, 이제 작동할 겁니다) */
    word-break: keep-all;
}
.archive-item.horizontal .memo-paper {
    /* 카드 높이가 250px이므로, 메모지는 그보다 작아야 함 */
    max-height: 190px !important; 
    
    /* 내용이 190px 넘으면 스크롤 생성 */
    overflow-y: auto; 
}
