/* =================================================================
 * Style for PrefMap (Travel Record Theme)
 * ================================================================= */

:root {
    --map-sea-fixed: #e6f4f9;
    --map-stroke-fixed: #94a3b8;
    --st-none-bg: #ffffff;
    --st-none-fg: #475569;
    --st-visited-bg: #5e3687;
    --st-visited-fg: #ffffff;
    --st-visited-ui: #8b5cf6;
}

/* =================================================================
 * Layout & Containers
 * ================================================================= */

/* PC向け基本レイアウト */
.app-main-layout {
    height: calc(100vh - 60px);
    min-height: 600px;
}

.map-column-bg {
    background-color: var(--map-sea-fixed) !important;
    transition: background-color 0.5s ease;
    /* コントローラーの基準点 */
    position: relative;
    z-index: 1;
}

.map-header-overlay {
    z-index: 10;
    background: rgba(var(--bs-body-bg-rgb), 0.8);
    backdrop-filter: blur(5px);
    position: relative;
    /* 重なり防止 */
}

.sidebar-column {
    z-index: 20;
    background-color: #fff;
}

.svg-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.25rem;
    box-sizing: border-box;
}

.capture-mode {
    background-color: var(--map-sea-fixed) !important;
    padding: 1rem !important;
}

/* =================================================================
 * Zoom Controls
 * ================================================================= */
.zoom-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 16px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(5px);
    white-space: nowrap;
}

.zoom-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #fff;
    color: #475569;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.zoom-btn:hover {
    background: #f1f5f9;
    transform: translateY(-2px);
}

.zoom-btn.active {
    background: var(--st-visited-ui);
    color: #fff;
    border-color: var(--st-visited-ui);
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.4);
}

/* =================================================================
 * Mobile Optimization (スマホ崩れ対策)
 * ================================================================= */
@media (max-width: 991px) {
    /* タブレット・スマホ */

    /* 1. レイアウト調整: 固定ヘッダー回避 */
    .app-main-layout {
        height: auto !important;
        min-height: 100vh;
        padding-top: 60px !important;
    }

    .row.h-100 {
        height: auto !important;
    }

    /* 2. マップエリアの高さを画面の60%に固定 */
    .map-column-bg {
        height: 60vh !important;
        min-height: 400px;
        flex: none !important;
    }

    /* ★追加: マップ表示エリアの下部に余白を作り、コントローラーとの重なりを防ぐ */
    .svg-container {
        padding-bottom: 80px !important;
        box-sizing: border-box !important;
    }

    /* 3. ヘッダーの崩れ修正 */
    .map-header-overlay {
        flex-direction: column;
        align-items: flex-start !important;
        padding: 12px 15px !important;
        gap: 4px;
    }

    .map-header-overlay h1 {
        font-size: 1rem !important;
        white-space: normal !important;
        line-height: 1.4;
        margin-bottom: 4px;
    }

    .map-legend {
        width: 100%;
        justify-content: flex-start;
        font-size: 0.75rem;
        margin-top: 2px;
    }

    /* 4. コントローラーのスマホ調整 */
    .zoom-controls {
        bottom: 20px;
        width: 92%;
        max-width: 400px;
        justify-content: space-between;
        padding: 8px 10px;
        overflow-x: auto;
    }

    .zoom-btn {
        width: 36px;
        height: 36px;
        font-size: 10px;
    }

    /* 5. サイドバー調整 */
    .sidebar-column {
        height: auto !important;
        border-left: none !important;
        border-top: 1px solid #e2e8f0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05) !important;
    }
}

/* =================================================================
 * SVG / Map Interaction
 * ================================================================= */

svg {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    filter: drop-shadow(4px 6px 12px rgba(100, 100, 111, 0.15));
    transition: none;
}

svg path,
svg rect {
    fill: var(--st-none-bg);
    stroke: var(--map-stroke-fixed);
    stroke-width: 1px !important;
    vector-effect: non-scaling-stroke;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

svg path:hover,
svg rect:hover,
svg g[id^="pref-"]:hover> :is(path, rect) {
    opacity: 1;
    filter: brightness(0.9);
    stroke: #333;
    stroke-width: 2px !important;
    z-index: 10;
}

.pref-label {
    font-weight: 700;
    pointer-events: none;
    text-anchor: middle;
    dominant-baseline: central;
    user-select: none;
    font-family: "Helvetica Neue", Arial, sans-serif;
    font-size: 11px;
    fill: var(--st-none-fg) !important;
    stroke: none !important;
    transition: fill 0.3s ease;
    cursor: pointer;
    pointer-events: auto;
}

.pref-label.vertical {
    writing-mode: vertical-rl;
    text-orientation: upright;
    letter-spacing: 0.1em;
    font-family: "Yu Gothic", "YuGothic", "Hiragino Kaku Gothic ProN", sans-serif;
}

/* =================================================================
 * Sidebar UI Components
 * ================================================================= */

.stats-list-text {
    font-size: 11px;
    line-height: 1.5;
    opacity: 0.8;
}

.stats-list-text.muted {
    opacity: 0.6;
}

.progress-total {
    height: 16px;
}

.progress-region {
    height: 6px;
}

.region-rate-text {
    font-size: 0.9em;
}

.btn-x-share {
    background-color: #000;
    border-color: #000;
    color: #fff;
}

.btn-x-share:hover {
    background-color: #333;
    border-color: #333;
    color: #fff;
}

.step-icon {
    width: 32px;
    height: 32px;
    font-weight: bold;
}

/* =================================================================
 * Status Coloring Utility
 * ================================================================= */

/* 未訪問 */
.fill-status-0 {
    fill: var(--st-none-bg) !important;
}

g.fill-status-0 :is(path, rect) {
    fill: var(--st-none-bg) !important;
}

.pref-label.fill-status-0 {
    fill: var(--st-none-fg) !important;
}

/* 訪問済み */
.fill-status-1 {
    fill: var(--st-visited-bg) !important;
}

g.fill-status-1 :is(path, rect) {
    fill: var(--st-visited-bg) !important;
}

.pref-label.fill-status-1 {
    fill: var(--st-visited-fg) !important;
}

/* UIパーツ */
.bg-status-0 {
    background-color: var(--st-none-bg) !important;
    border: 1px solid #cbd5e1;
}

.bg-status-1 {
    background-color: var(--st-visited-ui) !important;
}

.text-status-1 {
    color: var(--st-visited-ui) !important;
}

.map-legend .bg-status-1 {
    background: linear-gradient(135deg,
            #284c84 0%, #397d90 14%, #7ab789 28%, #efc34b 42%,
            #e78129 56%, #c43e32 70%, #aa71b9 84%, #603788 100%) !important;
    border: none !important;
}

.legend-box {
    width: 12px;
    height: 12px;
    display: inline-block;
    border-radius: 2px;
}

/* =================================================================
 * Region Specific Colors
 * ================================================================= */

/* 北海道 */
#pref-hokkaido.fill-status-1,
#pref-hokkaido.fill-status-1 :is(path, rect) {
    fill: #284c84 !important;
}

/* 東北 */
:is(#pref-aomori, #pref-iwate, #pref-miyagi, #pref-akita, #pref-yamagata, #pref-fukushima).fill-status-1,
:is(#pref-aomori, #pref-iwate, #pref-miyagi, #pref-akita, #pref-yamagata, #pref-fukushima).fill-status-1 :is(path, rect) {
    fill: #397d90 !important;
}

/* 関東 */
:is(#pref-ibaraki, #pref-tochigi, #pref-gunma, #pref-saitama, #pref-chiba, #pref-tokyo, #pref-kanagawa).fill-status-1,
:is(#pref-ibaraki, #pref-tochigi, #pref-gunma, #pref-saitama, #pref-chiba, #pref-tokyo, #pref-kanagawa).fill-status-1 :is(path, rect) {
    fill: #7ab789 !important;
}

/* 中部 */
:is(#pref-niigata, #pref-toyama, #pref-ishikawa, #pref-fukui, #pref-yamanashi, #pref-nagano, #pref-gifu, #pref-shizuoka, #pref-aichi).fill-status-1,
:is(#pref-niigata, #pref-toyama, #pref-ishikawa, #pref-fukui, #pref-yamanashi, #pref-nagano, #pref-gifu, #pref-shizuoka, #pref-aichi).fill-status-1 :is(path, rect) {
    fill: #efc34b !important;
}

/* 近畿 */
:is(#pref-mie, #pref-shiga, #pref-kyoto, #pref-osaka, #pref-hyogo, #pref-nara, #pref-wakayama).fill-status-1,
:is(#pref-mie, #pref-shiga, #pref-kyoto, #pref-osaka, #pref-hyogo, #pref-nara, #pref-wakayama).fill-status-1 :is(path, rect) {
    fill: #e78129 !important;
}

/* 中国 */
:is(#pref-tottori, #pref-shimane, #pref-okayama, #pref-hiroshima, #pref-yamaguchi).fill-status-1,
:is(#pref-tottori, #pref-shimane, #pref-okayama, #pref-hiroshima, #pref-yamaguchi).fill-status-1 :is(path, rect) {
    fill: #c43e32 !important;
}

/* 四国 */
:is(#pref-tokushima, #pref-kagawa, #pref-ehime, #pref-kochi).fill-status-1,
:is(#pref-tokushima, #pref-kagawa, #pref-ehime, #pref-kochi).fill-status-1 :is(path, rect) {
    fill: #aa71b9 !important;
}

/* 九州・沖縄 */
:is(#pref-fukuoka, #pref-saga, #pref-nagasaki, #pref-kumamoto, #pref-oita, #pref-miyazaki, #pref-kagoshima, #pref-okinawa).fill-status-1,
:is(#pref-fukuoka, #pref-saga, #pref-nagasaki, #pref-kumamoto, #pref-oita, #pref-miyazaki, #pref-kagoshima, #pref-okinawa).fill-status-1 :is(path, rect) {
    fill: #603788 !important;
}