/* style.css - Final Fixed Version (MaHwang Theme) */

:root {
    /* [기본 테마 색상] */
    --bg-color: #f0f2f5;          
    --card-bg: #ffffff;           
    --text-main: #222222;         
    --text-sub: #555555;          
    --border: #dddddd;            
    --shadow: 0 4px 12px rgba(0,0,0,0.08); 

    /* [포인트 컬러 - 기본값 (서울/파랑)] */
    /* 이 값은 JS에서 지역 버튼을 누르면 실시간으로 바뀝니다 */
    --accent-blue: #339af0;       
    
    /* [순위별 메달 테마] */
    --gold-bg: #fffbe6; --gold-border: #ffe58f; --gold-text: #d48806; 
    --silver-bg: #f8f9fa; --silver-border: #dee2e6; --silver-text: #495057; 
    --bronze-bg: #ffe3ce; --bronze-border: #ffbb96; --bronze-text: #d4380d; 
}

/* [지역별 네온 컬러 정의] - 제목 빛번짐 효과용 */
body.seoul { --point-color: #4dabf7; }  /* 서울: 밝은 파랑 네온 */
body.busan { --point-color: #00e676; }  /* 부산: 형광 초록 네온 */
body.jeju  { --point-color: #ff9100; }  /* 제주: 형광 오렌지 네온 */

/* [기본 리셋] */
body {
    font-family: 'Noto Sans KR', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

/* [컨테이너] */
.container { 
    max-width: 640px; 
    margin: 0 auto; 
    padding: 0; 
    padding-bottom: 25px;
    background-color: var(--bg-color);
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.05);
}

/* =========================================
   [헤더 영역] 배경 이미지 + 마황 스타일
   ========================================= */
header {
    /* 배경 이미지 (경로 확인 필수) */
    background-image: url('background_only.png'); 
    background-size: cover;       
    background-position: center;  
    background-repeat: no-repeat; 
    
    /* 어두운 오버레이 */
    background-blend-mode: overlay;
    background-color: rgba(0, 0, 0, 0.6); 

    text-align: center;
    padding: 100px 20px 40px 20px; 
    border-bottom: none; 
    margin-bottom: 0; 
}

header h1 {
    font-size: 2.2rem;    
    margin: 0 0 10px 0;   
    font-weight: 900;     
    color: #ffffff;       
    text-shadow: 0 4px 10px rgba(0,0,0,0.8); 
    line-height: 1.2;
    word-break: keep-all; 
}

/* [지역 이름 네온 효과] */
.loc-highlight {
    color: var(--point-color, #4dabf7) !important; 
    text-shadow: 0 0 15px var(--point-color, #4dabf7); 
    font-weight: 900;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

/* [부제 강조] */
header h1 span:not(.loc-highlight) {
    display: inline-block;
    color: #ffd700;       
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.6); 
}

header p {
    font-size: 1.1rem;
    font-weight: 500;
    color: #e0e0e0;       
    margin: 0;
    text-shadow: 0 2px 5px rgba(0,0,0,0.8);
}

/* =========================================
   [경고/안내 박스 (Glassmorphism)]
   ========================================= */
.warning-box {
    text-align: center; 
    padding: 20px; 
    margin: 20px 20px 30px 20px; /* 헤더 바로 아래 */
    border-radius: 12px; 
    
    /* 반투명 유리 효과 */
    background: rgba(255, 255, 255, 0.9); 
    backdrop-filter: blur(5px); 
    
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1); 
    
    color: #222222; 
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.6;
    word-break: keep-all; 
}
.warning-box p { margin: 5px 0; text-shadow: none; }

/* =========================================
   [네비게이션 & 버튼]
   ========================================= */
.day-selector { display: flex; gap: 12px; margin: 0 25px 20px; }
.day-btn { 
    flex: 1; padding: 15px; font-size: 1.1rem; 
    border: 2px solid var(--border); background: #ffffff; color: var(--text-sub); 
    border-radius: 12px; cursor: pointer; font-weight: bold; transition: 0.2s; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.day-btn.active { 
    /* 지역별 색상 적용 (JS에서 --accent-blue 변경됨) */
    background: var(--accent-blue); 
    color: #fff; 
    border-color: var(--accent-blue); 
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); 
}

.sub-nav { display: flex; justify-content: center; gap: 15px; margin-bottom: 25px; }
.loc-btn { 
    padding: 10px 25px; background: #e9ecef; color: var(--text-main); 
    border: 2px solid var(--border); border-radius: 30px; 
    font-size: 1rem; font-weight: bold; cursor: pointer; 
}
.loc-btn.active { 
    background: var(--accent-blue); 
    color: #fff; 
    border-color: var(--accent-blue); 
}

/* =========================================
   [스티키 헤더 & 경주 버튼]
   ========================================= */
#sticky-header {
    position: sticky; top: 0; z-index: 1000;
    background: rgba(240, 242, 245, 0.95); /* 배경색 일체화 */
    backdrop-filter: blur(5px);
    border-bottom: 1px solid #ddd;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05); 
    padding-top: 10px; 
}

#race-selector {
    display: flex; gap: 8px; overflow-x: auto; white-space: nowrap;
    padding: 10px 25px 15px; margin: 0;
    scrollbar-width: none; -ms-overflow-style: none;
}
#race-selector::-webkit-scrollbar { display: none; }

.race-btn { 
    flex: 0 0 auto; min-width: 55px; height: 55px;
    border-radius: 50%; border: 2px solid var(--border); 
    background: #fff; color: var(--text-main); 
    font-size: 1.1rem; cursor: pointer; 
    display: flex; align-items: center; justify-content: center; 
    font-weight: bold; box-shadow: 0 2px 5px rgba(0,0,0,0.1); transition: 0.2s; 
}
.race-btn.active { 
    background: var(--accent-blue); 
    color: #fff; border-color: var(--accent-blue); 
    transform: scale(1.05); box-shadow: 0 4px 8px rgba(0,0,0,0.15); 
}

/* =========================================
 /* =========================================
   [메인 콘텐츠] - 통합 정보 박스 적용
   ========================================= */
#result-area { 
    padding: 10px 25px; 
    display: block; 
}

/* 1. 통합 정보 박스 (제목+거리+혼전도+버튼+전개도) */
.unified-info-box {
    background: #ffffff;
    border: 1px solid #e9ecef;
    /* [핵심] 왼쪽 포인트 컬러 (지역별 색상 --accent-blue 적용됨) */
    border-left: 6px solid var(--accent-blue); 
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    gap: 15px; /* 상단 정보와 하단 전개도 사이 간격 */
}

/* 2. 상단: 제목 & 버튼 영역 */
.race-top-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* 위쪽 정렬 */
    flex-wrap: wrap;         /* 모바일에서 줄바꿈 허용 */
    gap: 15px;
}

.race-title-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;                 /* 남는 공간 차지 */
    min-width: 200px;
}

.race-title-group h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-main); 
    font-weight: 900;
    line-height: 1.2;
    /* 기존의 border-left는 박스 전체로 옮겼으니 제거 */
}

/* 3. 뱃지 그룹 (거리, 혼전도) */
.badge-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.badge-dist { 
    background: var(--text-main); 
    padding: 4px 12px; 
    border-radius: 20px; 
    font-size: 0.9rem; 
    color: #fff; 
    font-weight: bold; 
    white-space: nowrap; 
}

.badge-chaos {
    display: inline-block; 
    padding: 4px 12px; 
    border-radius: 20px; 
    font-size: 0.9rem; 
    font-weight: bold; 
    color: #fff; 
    white-space: nowrap; 
}
.badge-chaos.normal { background: #20c997; } 
.badge-chaos.chaos { background: #fd7e14; } 
.badge-chaos.chaos-high { background: #e03131; animation: blink 2s infinite; }
.badge-chaos.favorite { background: #1971c2; box-shadow: 0 0 8px rgba(25, 113, 194, 0.4); }
@keyframes blink { 0% { opacity: 1; } 50% { opacity: 0.7; } 100% { opacity: 1; } }

/* 4. 유틸 버튼 (듣기, 공유) */
.util-btn-group { 
    display: flex; 
    gap: 8px; 
    flex-shrink: 0; /* 버튼 크기 줄어들지 않게 고정 */
}

.util-btn {
    white-space: nowrap; 
    padding: 8px 12px; 
    border-radius: 8px; 
    font-weight: bold; 
    font-size: 0.9rem; 
    cursor: pointer; 
    border: none; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    color: #fff; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.1s;
}
.util-btn:active { transform: scale(0.95); }

/* 5. 구분선 (점선) */
.info-divider {
    height: 1px;
    border-bottom: 1px dashed #e0e0e0;
    margin: 5px 0;
    width: 100%;
}

/* 6. 하단: AI 전개도 스타일 */
#ai-style-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.style-header-inline {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--accent-blue); /* 지역색 적용 */
    display: flex;
    align-items: center;
}

.style-content-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* 전개도 칩 디자인 */
.style-group-inline {
    display: flex;
    align-items: center;
    background: #f8f9fa; /* 연한 회색 배경 */
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #dee2e6;
}

.style-name {
    font-size: 0.85rem;
    font-weight: bold;
    margin-right: 10px;
    padding-right: 10px;
    border-right: 1px solid #ccc;
    color: #555;
}
.s-label-front { color: #0056b3; } /* 선행 - 파랑 */
.s-label-back { color: #c92a2a; }  /* 추입 - 빨강 */

.style-nums { display: flex; gap: 6px; }
.s-horse-no-sm {
    font-family: 'Roboto', sans-serif;
    font-size: 0.95rem;
    font-weight: 900;
    color: #333;
}

/* 카드 및 테이블 */
.card { 
    background: var(--card-bg); border-radius: 16px; padding: 25px; 
    margin-bottom: 25px; border: 1px solid var(--border); box-shadow: var(--shadow); 
}
.tab-header {
    display: flex; gap: 10px; margin-bottom: 15px; 
    background: #f1f3f5; padding: 5px; border-radius: 12px;
}
.tab-btn {
    flex: 1; border: none; background: transparent; padding: 10px; 
    font-size: 1rem; font-weight: bold; color: #868e96; cursor: pointer; border-radius: 8px; 
}
.tab-btn.active {
    background: #fff; color: var(--text-main); box-shadow: 0 2px 5px rgba(0,0,0,0.05); color: #ff5e00; 
}

.pred-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; font-size: 1.1rem; }
.pred-table th { text-align: left; color: var(--text-sub); padding: 10px 15px; font-size: 1rem; font-weight: normal; }
.pred-table td { padding: 15px; background: #fff; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.pred-table td:first-child { border-left: 1px solid var(--border); border-radius: 10px 0 0 10px; }
.pred-table td:last-child { border-right: 1px solid var(--border); border-radius: 0 10px 10px 0; }
.pred-table tr:nth-child(1) td { background: var(--gold-bg); border-color: var(--gold-border); color: #000; font-weight: bold; }
.pred-table tr:nth-child(1) td:first-child { color: var(--gold-text); font-size: 1.5rem; font-weight: 900; }
.pred-table tr:nth-child(2) td { background: var(--silver-bg); border-color: var(--silver-border); }
.pred-table tr:nth-child(2) td:first-child { color: var(--silver-text); font-size: 1.4rem; font-weight: 900; }
.pred-table tr:nth-child(3) td { background: var(--bronze-bg); border-color: var(--bronze-border); }
.pred-table tr:nth-child(3) td:first-child { color: var(--bronze-text); font-size: 1.3rem; font-weight: 900; }

.horse-no { 
    font-weight: 900; font-size: 1.3rem; color: var(--text-main); 
    display: inline-block; width: 34px; text-align: center; 
    background: rgba(0,0,0,0.05); border-radius: 50%; padding: 2px; border: 1px solid rgba(0,0,0,0.1); 
}

/* style.css 수정 */

/* 하단 소개 섹션 스타일 */
section {
    background-color: #f8f9fa; 
    padding: 20px; 
    text-align: center; 
    font-size: 0.9rem; /* 글자 크기를 살짝 키워도 좋습니다 (기존 0.8rem -> 0.9rem) */
    color: #666; 
    margin-top: 30px;
    
    /* [핵심] 단어 단위 줄바꿈 적용 */
    word-break: keep-all; 
}

section h3 {
    font-size: 1.1rem; 
    color: #333; 
    margin-bottom: 15px;
    font-weight: 800;
}

section p {
    /* 문단 간격 및 행간 조정으로 가독성 확보 */
    margin-bottom: 10px;
    line-height: 1.7; 
}

/* 전개도 및 전략 */
.style-box-container {
    background: #fff; border: 1px solid #e9ecef; border-left: 5px solid var(--accent-blue); 
    border-radius: 8px; padding: 12px 15px; margin-bottom: 20px; 
    box-shadow: 0 2px 6px rgba(0,0,0,0.03); display: flex; flex-direction: column; gap: 8px;
}
.style-header-inline { font-size: 0.95rem; font-weight: 800; color: var(--text-main); display: flex; align-items: center; }
.style-content-inline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.style-group-inline { display: flex; align-items: center; background: #f8f9fa; padding: 4px 10px; border-radius: 20px; border: 1px solid #dee2e6; }
.style-name { font-size: 0.8rem; font-weight: bold; margin-right: 8px; padding-right: 8px; border-right: 1px solid #ccc; color: #555; }
.s-label-front { color: #0056b3; } .s-label-back { color: #c92a2a; }
.style-nums { display: flex; gap: 5px; }
.s-horse-no-sm { font-family: 'Roboto', sans-serif; font-size: 0.9rem; font-weight: 900; color: #222; }

.strategy-card h3 { margin-top: 0; font-size: 1.3rem; color: var(--text-main); border-bottom: 2px solid #eee; padding-bottom: 15px; margin-bottom: 20px; }
.strategy-box { background: #f1f3f5; padding: 20px; border-radius: 12px; margin-top: 15px; border: 1px solid #e9ecef; }
.strategy-box h4 { margin: 0 0 15px 0; font-size: 1.1rem; color: var(--accent-blue); font-weight: bold; }
.picks-list li { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 1.15rem; padding: 10px; background: #fff; border-radius: 8px; border: 1px solid var(--border); }
.tag { font-size: 0.9rem; padding: 4px 8px; border-radius: 6px; margin-right: 8px; font-weight: bold; color: #fff; display: inline-block; }
.tag.gold { background: #ffc107; color: #000; } .tag.silver { background: #adb5bd; color: #fff; } .tag.challenge { background: #fd7e14; color: #fff; } .tag.normal { background: #6c757d; color: #fff; }

.hidden { display: none !important; }
#loading, #error-msg { text-align: center; color: var(--text-sub); padding: 30px; font-size: 1.2rem; font-weight: bold; }
footer:not(.warning-box) { text-align: center; padding: 30px 20px; background: #fff; border-radius: 12px; margin-top: 40px; margin-left: 25px; margin-right: 25px; border: 1px solid var(--border); }
footer:not(.warning-box) p { margin: 5px 0; font-size: 0.9rem; color: #666; }
.copyright { font-family: 'Arial', sans-serif; font-size: 0.8rem; color: #999; letter-spacing: 1px; margin-top: 10px; }

/* =========================================
   [Portal Button] 베이직 -> 더 블랙 이동 버튼
   ========================================= */
.portal-section {
    margin: 0 0 30px 0; /* 광고와 전략 카드 사이 간격 조절 */
    padding: 0 5px;     /* 모바일 좌우 여백 확보 */
}

.portal-card-btn.to-black {
    display: flex;
    justify-content: space-between;
    align-items: center;
    
    /* 기본 상태: 베이직 테마와 어울리는 흰색 */
    background: #ffffff;
    border: 1px solid #ddd;
    border-left: 6px solid #222; /* 왼쪽 포인트는 검정색 (Black 암시) */
    
    padding: 18px 20px;
    border-radius: 12px;
    text-decoration: none;
    color: #333;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}

/* 호버 효과: 검정색으로 변신 (The Black 느낌) */
.portal-card-btn.to-black:hover {
    background: #111;       /* 배경 검정 */
    border-color: #000;
    color: #fff;            /* 글자 흰색 */
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.2);
}

.portal-content {
    display: flex;
    flex-direction: column;
    text-align: left;
    gap: 4px;
}

/* 서브 텍스트 (너무 뻔한가요?...) */
.portal-card-btn.to-black .sub-text {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
    transition: color 0.3s;
}

/* 호버 시 서브 텍스트 색상 변경 */
.portal-card-btn.to-black:hover .sub-text {
    color: #ccc; /* 검정 배경 위니까 밝은 회색으로 */
}

/* [수정] 메인 텍스트 스타일 */
.portal-card-btn.to-black .main-text {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: inherit; /* 부모 색상 상속 (호버 시 색상 반전 자연스럽게) */
}

/* 🌟 [핵심] THE BLACK 강조 스타일 */
.portal-card-btn.to-black .main-text strong {
    font-family: 'Roboto', 'Noto Sans KR', sans-serif; /* 굵은 고딕 계열 */
    font-weight: 900;       /* 최대 두께 (Ultra Bold) */
    font-size: 1.15em;      /* 주변 글자보다 15% 더 크게 */
    letter-spacing: -0.2px; /* 글자 사이를 살짝 좁혀서 단단하게 */
    margin-left: 2px;       /* 앞 글자와 살짝 띄우기 */
}

/* (참고) 호버 효과는 기존 코드 유지 */
.portal-card-btn.to-black:hover {
    background: #111;
    border-color: #000;
    color: #fff;
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.2);
}

/* 📱 모바일 최적화 */
@media (max-width: 480px) {
    header { padding: 80px 15px 30px 15px; } 
    header h1 { font-size: 1.8rem; }
    header h1 span:not(.loc-highlight) { display: block; margin-top: 5px; font-size: 0.9em; }
    header p { font-size: 0.95rem; }
    .day-selector { margin: 0 15px 20px; }
    #result-area { padding: 10px 15px; }
    footer:not(.warning-box) { margin-left: 15px; margin-right: 15px; }
}