﻿/**
 * Chapter Relations Map - Leaflet Version
 * Sanxia JCI
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0a1628;
    font-family: 'Noto Sans TC', 'Noto Sans KR', sans-serif;
    color: #fff;
}

/* ===== Map Container ===== */
#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ===== Edge Fade Overlay ===== */
.edge-fade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 400;
    background: radial-gradient( ellipse 55% 55% at 50% 50%, transparent 0%, transparent 40%, rgba(10, 22, 40, 0.3) 60%, rgba(10, 22, 40, 0.6) 75%, rgba(10, 22, 40, 0.85) 90%, #0a1628 100% );
}

/* ===== Custom Markers ===== */
.custom-marker {
    position: relative;
    width: 28px;
    height: 36px;
    cursor: pointer;
    overflow: visible !important;
}

.marker-pin {
    position: absolute;
    top: 0;
    left: 0;
    width: 28px;
    height: 36px;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.5));
    transition: transform 0.3s ease;
    z-index: 10;
}

.custom-marker:hover .marker-pin {
    transform: scale(1.15);
}

.marker-pin svg {
    width: 100%;
    height: 100%;
}

/* ===== Marker Label ===== */
.marker-label {
    position: absolute;
    padding: 6px 12px;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    border-radius: 6px;
    white-space: nowrap;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 5;
    transition: opacity 0.5s ease;
}

/* Label 位置 */
.label-pos-bottom {
    top: 42px;
    left: 50%;
    transform: translateX(-50%);
    border-top: 3px solid;
}

.label-pos-top {
    bottom: 42px;
    left: 50%;
    transform: translateX(-50%);
    border-bottom: 3px solid;
    border-top: none;
}

.label-pos-left {
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    border-right: 3px solid;
    border-top: none;
}

.label-pos-right {
    left: 40px;
    top: 50%;
    transform: translateY(-50%);
    border-left: 3px solid;
    border-top: none;
}

/* ===== 東亞視圖時只隱藏台灣標籤 ===== */
.asia-view-active .marker-label.taiwan-label {
    opacity: 0 !important;
    pointer-events: none;
}

/* 韓國標籤始終顯示 - 更強的選擇器 */
.marker-label.korea-label {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: 1000 !important;
}

.asia-view-active .marker-label.korea-label {
    opacity: 1 !important;
    visibility: visible !important;
}

/* ===== Label 邊框顏色 ===== */
.marker-main .label-pos-bottom {
    border-top-color: #ffc857;
}

.marker-mother .label-pos-bottom {
    border-top-color: #ef4444;
}

.marker-brother .label-pos-bottom {
    border-top-color: #3b82f6;
}

.marker-friend .label-pos-bottom {
    border-top-color: #22c55e;
}

.marker-sister .label-pos-bottom {
    border-top-color: #ec4899;
}

.marker-main .label-pos-top {
    border-bottom-color: #ffc857;
}

.marker-mother .label-pos-top {
    border-bottom-color: #ef4444;
}

.marker-brother .label-pos-top {
    border-bottom-color: #3b82f6;
}

.marker-friend .label-pos-top {
    border-bottom-color: #22c55e;
}

.marker-sister .label-pos-top {
    border-bottom-color: #ec4899;
}

.marker-main .label-pos-left {
    border-right-color: #ffc857;
}

.marker-mother .label-pos-left {
    border-right-color: #ef4444;
}

.marker-brother .label-pos-left {
    border-right-color: #3b82f6;
}

.marker-friend .label-pos-left {
    border-right-color: #22c55e;
}

.marker-sister .label-pos-left {
    border-right-color: #ec4899;
}

.marker-main .label-pos-right {
    border-left-color: #ffc857;
}

.marker-mother .label-pos-right {
    border-left-color: #ef4444;
}

.marker-brother .label-pos-right {
    border-left-color: #3b82f6;
}

.marker-friend .label-pos-right {
    border-left-color: #22c55e;
}

.marker-sister .label-pos-right {
    border-left-color: #ec4899;
}

/* ===== Pin 顏色 ===== */
.marker-main .marker-pin svg {
    fill: #ffc857;
}

.marker-mother .marker-pin svg {
    fill: #ef4444;
}

.marker-brother .marker-pin svg {
    fill: #3b82f6;
}

.marker-friend .marker-pin svg {
    fill: #22c55e;
}

.marker-sister .marker-pin svg {
    fill: #ec4899;
}

/* ===== Main Marker Pulse ===== */
.marker-main .marker-pin::before {
    content: '';
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: radial-gradient(circle, rgba(255, 200, 87, 0.5) 0%, transparent 70%);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
    z-index: -1;
}

@keyframes pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0.2;
    }
}

/* ===== Label 文字 ===== */
.marker-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
}

.marker-name-kr {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 2px;
}

.marker-type {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Marker Animation ===== */
.marker-hidden {
    opacity: 0;
    transform: translateY(-30px);
}

.marker-dropping {
    animation: pin-drop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes pin-drop {
    0% {
        opacity: 0;
        transform: translateY(-60px) scale(0.5);
    }

    60% {
        opacity: 1;
        transform: translateY(5px) scale(1.05);
    }

    80% {
        transform: translateY(-3px) scale(0.98);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.marker-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Side List Container ===== */
.side-list-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 450;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 80px 20px;
    opacity: 0;
    transition: opacity 0.8s ease;
}

    .side-list-container.visible {
        opacity: 1;
    }

.side-list {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 16px 20px;
    min-width: 160px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.side-list-taiwan {
    margin-left: 20px;
}

.side-list-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.side-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 0.8rem;
    color: #fff;
}

    .side-list-item .item-dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .side-list-item .item-type {
        font-size: 0.65rem;
        color: rgba(255, 255, 255, 0.5);
        margin-left: auto;
    }

.item-main .item-dot {
    background: #ffc857;
}

.item-mother .item-dot {
    background: #ef4444;
}

.item-brother .item-dot {
    background: #3b82f6;
}

.item-friend .item-dot {
    background: #22c55e;
}

.item-sister .item-dot {
    background: #ec4899;
}

/* 東亞視圖時隱藏左下角的 legend */
.asia-view-active .legend {
    opacity: 0;
    pointer-events: none;
}

/* ===== Connection Line ===== */
.connection-line {
    stroke: url(#lineGradient);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 12 6;
    fill: none;
    animation: dash-flow 20s linear infinite;
}

@keyframes dash-flow {
    to {
        stroke-dashoffset: -200;
    }
}

/* ===== Page Title ===== */
.page-title {
    position: fixed;
    top: 30px;
    left: 0;
    right: 0;
    text-align: center;
    z-index: 500;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.8s ease;
}

    .page-title.visible {
        opacity: 1;
        transform: translateY(0);
    }

    .page-title h1 {
        font-size: 1.8rem;
        font-weight: 700;
        color: #ffc857;
        text-shadow: 0 2px 20px rgba(255, 200, 87, 0.4);
        margin-bottom: 6px;
    }

    .page-title p {
        font-size: 0.9rem;
        color: rgba(255, 255, 255, 0.7);
    }

/* ===== Legend ===== */
.legend {
    position: fixed;
    bottom: 30px;
    left: 30px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(12px);
    padding: 16px 20px;
    border-radius: 12px;
    z-index: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
    opacity: 0;
    transform: translateX(-20px);
    transition: all 0.6s ease;
}

    .legend.visible {
        opacity: 1;
        transform: translateX(0);
    }

.legend-title {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: rgba(255, 255, 255, 0.9);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
}

    .legend-item:last-child {
        margin-bottom: 0;
    }

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

    .legend-dot.main {
        background: #ffc857;
    }

    .legend-dot.mother {
        background: #ef4444;
    }

    .legend-dot.brother {
        background: #3b82f6;
    }

    .legend-dot.friend {
        background: #22c55e;
    }

    .legend-dot.sister {
        background: #ec4899;
    }

/* ===== Site Navigation Link (右上角官網連結) ===== */
.site-nav-link {
    position: fixed;
    top: 20px;
    right: 80px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
    padding: 10px 18px;
    border-radius: 25px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    z-index: 700;
}

    .site-nav-link:hover {
        background: rgba(255, 200, 87, 0.2);
        border-color: rgba(255, 200, 87, 0.4);
        color: #ffc857;
        transform: translateY(-2px);
    }

    .site-nav-link svg {
        width: 18px;
        height: 18px;
        fill: currentColor;
    }

/* ===== Buttons ===== */
.skip-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    z-index: 600;
    transition: all 0.3s ease;
}

    .skip-btn:hover {
        background: rgba(255, 255, 255, 0.2);
        color: #fff;
    }

.enter-btn {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ffc857 0%, #ff9f43 100%);
    color: #1a1a2e;
    border: none;
    padding: 16px 36px;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 600;
    opacity: 0;
    transition: all 0.4s ease;
    box-shadow: 0 4px 20px rgba(255, 200, 87, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

    .enter-btn svg {
        transition: transform 0.3s ease;
    }

    .enter-btn.visible {
        opacity: 1;
    }

    .enter-btn:hover {
        transform: translateX(-50%) scale(1.05);
        box-shadow: 0 6px 30px rgba(255, 200, 87, 0.6);
    }

        .enter-btn:hover svg {
            transform: translateX(4px);
        }

/* ===== Loading Screen ===== */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a1628;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.6s ease;
}

    .loading-screen.hidden {
        opacity: 0;
        pointer-events: none;
    }

.loading-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 200, 87, 0.2);
    border-top-color: #ffc857;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Leaflet Customization ===== */
.leaflet-control-container {
    display: none !important;
}

.marker-icon-wrapper {
    overflow: visible !important;
}

.leaflet-marker-icon {
    overflow: visible !important;
}

.leaflet-container {
    background: #0a1628 !important;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .site-nav-link {
        top: 15px;
        right: 20px;
        padding: 8px 14px;
        font-size: 0.8rem;
    }

        .site-nav-link svg {
            width: 16px;
            height: 16px;
        }

    .skip-btn {
        bottom: 15px;
        right: 15px;
        padding: 8px 12px;
        font-size: 0.75rem;
    }

    .enter-btn {
        padding: 14px 28px;
        font-size: 1rem;
        bottom: 70px;
    }

    .custom-marker {
        width: 24px;
        height: 30px;
    }

    .marker-pin {
        width: 24px;
        height: 30px;
    }

    .marker-label {
        padding: 4px 8px;
    }

    .label-pos-bottom {
        top: 34px;
    }

    .label-pos-top {
        bottom: 34px;
    }

    .label-pos-left {
        right: 32px;
    }

    .label-pos-right {
        left: 32px;
    }

    .marker-name {
        font-size: 0.7rem;
    }

    .marker-type {
        font-size: 0.5rem;
    }

    .page-title h1 {
        font-size: 1.3rem;
    }

    .legend {
        padding: 12px;
        bottom: 20px;
        left: 20px;
    }

    /* 手機版側邊列表放右下角 */
    .side-list-container {
        justify-content: flex-end;
        align-items: flex-end;
        padding: 100px 15px 160px;
    }

    .side-list {
        min-width: auto;
        max-width: 150px;
        padding: 10px 14px;
    }

    .side-list-taiwan {
        margin-left: 0;
        margin-right: 10px;
    }

    .side-list-title {
        font-size: 0.7rem;
        margin-bottom: 8px;
    }

    .side-list-item {
        padding: 5px 0;
        font-size: 0.65rem;
        gap: 8px;
    }

        .side-list-item .item-dot {
            width: 8px;
            height: 8px;
        }

        .side-list-item .item-type {
            font-size: 0.5rem;
        }
}
