/* 基本設定 */
body { 
    margin: 0; padding: 0; 
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif; 
    overflow: hidden; 
}
#map { position: absolute; top: 0; bottom: 0; width: 100%; }

:root {
    --base-unit: 60px;
    --font-base: 18px;
    --font-small: 14px;
    --spacing: 25px;
    --radius: 12px;
}

@media screen and (max-width: 600px) {
    :root {
        --base-unit: 48px !important; 
        --font-base: 15px !important;
        --font-small: 12px !important;
        --spacing: 15px !important; 
    }
    .search-icon { font-size: 20px !important; }
    .control-icon svg { width: 24px !important; height: 24px !important; }
    .maplibregl-ctrl-group button { width: 48px !important; height: 48px !important; }
    
    .search-container.expanded { 
        width: calc(100vw - (var(--spacing) * 2) - var(--base-unit) - 15px) !important; 
    }
    #layer-tab-container.expanded, #opacity-container.expanded { 
        width: calc(100vw - (var(--spacing) * 2) - var(--base-unit) - 15px) !important; 
    }
}

.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.05);
    box-sizing: border-box;
}

/* 検索窓 */
.search-wrapper { position: absolute; top: var(--spacing); left: var(--spacing); z-index: 110; }
.search-container {
    display: flex;
    align-items: center;
    width: var(--base-unit);
    height: var(--base-unit);
    background: white;
    border-radius: var(--radius);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.05);
    overflow: hidden;
    cursor: pointer;
    box-sizing: border-box;
}
.search-container.expanded { width: clamp(260px, 30vw, 500px); cursor: default; }
.search-icon { min-width: calc(var(--base-unit) - 2px); height: calc(var(--base-unit) - 2px); display: flex; align-items: center; justify-content: center; }
#search-input {
    width: 0; opacity: 0; border: none; outline: none; 
    font-size: var(--font-base);
    transition: width 0.3s, opacity 0.2s; background: transparent;
}
.search-container.expanded #search-input { width: 100%; opacity: 1; padding: 0 10px; }

/* 右上：コントロール群 */
.right-controls-column {
    position: absolute;
    top: var(--spacing);
    right: var(--spacing);
    z-index: 110;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: flex-end;
    pointer-events: none;
}
.right-controls-column > * { pointer-events: auto; }

.expandable-container {
    display: flex;
    align-items: center;
    width: var(--base-unit);
    height: var(--base-unit);
    background: white;
    border-radius: var(--radius);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    border: 1px solid rgba(0,0,0,0.05);
    overflow: hidden;
    cursor: pointer;
    box-sizing: border-box;
}
#layer-tab-container.expanded { width: 320px; cursor: default; }
#opacity-container.expanded { width: 240px; cursor: default; }

.control-icon {
    min-width: calc(var(--base-unit) - 2px);
    height: calc(var(--base-unit) - 2px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.control-content {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    padding-right: 15px;
    white-space: nowrap;
}
.expanded .control-content { opacity: 1; pointer-events: auto; }

.layer-options { gap: 8px; }
.layer-options button {
    white-space: nowrap; padding: 8px 12px; border: 1px solid #eee; border-radius: 8px;
    background: #f9f9f9; font-weight: bold; font-size: 13px; cursor: pointer;
}
.layer-options button.active { background: #333; color: white; border-color: #333; }

.opacity-panel-content { gap: 10px; width: 100%; }
.control-label { font-size: var(--font-small); font-weight: bold; color: #555; min-width: 45px; }
input[type="range"] { width: 100%; cursor: pointer; accent-color: #333; display: block; }

/* 標準コントロール */
.maplibregl-ctrl-top-right {
    position: absolute !important;
    top: calc(var(--spacing) + (var(--base-unit) * 2) + 30px) !important;
    right: var(--spacing) !important;
    left: auto !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
    z-index: 100 !important;
}
.maplibregl-ctrl-group {
    background: none !important;
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 15px !important;
}
.maplibregl-ctrl-group button {
    width: var(--base-unit) !important;
    height: var(--base-unit) !important;
    background: white !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15) !important;
    border: 1px solid rgba(0,0,0,0.05) !important;
    border-radius: var(--radius) !important;
    margin: 0 !important;
}

.search-results {
    position: absolute; top: calc(var(--base-unit) + 10px); left: 0; right: 0; background: white;
    border-radius: var(--radius); max-height: 50vh; overflow-y: auto; display: none;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}
.search-item { padding: 12px 16px; cursor: pointer; border-bottom: 1px solid #f0f0f0; font-size: var(--font-base); font-weight: bold; }
.search-item span { font-size: var(--font-small); display: block; opacity: 0.7; }
.search-item.selected { background-color: #e65a5a; color: white; }

/* マップロゴ */
.map-logo-container {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    pointer-events: none;
    display: flex;
    justify-content: center;
    width: auto;
    background: transparent !important;
}
.map-logo {
    height: 70px;
    width: auto;
    background: transparent !important;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.2));
    opacity: 0.95;
    border: none !important;
}

@media screen and (max-width: 600px) {
    .map-logo-container { bottom: 45px; }
    .map-logo { height: 50px; max-width: 250px; }
}

/* 右下：参考文献・インフォメーションパネル */
.bottom-right-container {
    position: absolute;
    bottom: calc(var(--spacing) + 25px); 
    right: var(--spacing);
    z-index: 110;
    pointer-events: none;
}
.bottom-right-container > * { pointer-events: auto; }

#info-container {
    flex-direction: column;
    align-items: stretch;
    height: var(--base-unit);
}
#info-container.expanded { 
    width: 320px; 
    height: auto; 
    /* PC: 下の余白(spacing+25) + コントロール群全高(spacing + unit*2 + 15 + 30 + unit*3 + 15*2) + 上の余白(spacing) */
    max-height: calc(100vh - (var(--spacing) * 3) - 450px); 
    cursor: default; 
}
#info-container .control-icon { align-self: flex-end; }

.info-panel-content {
    display: none;
    flex-direction: column;
    width: 100%;
    padding: 15px;
    box-sizing: border-box;
    overflow-y: auto;
}
#info-container.expanded .info-panel-content { display: flex; opacity: 1; pointer-events: auto; }

.info-inner { width: 100%; white-space: normal; }

.info-title { 
    margin: 20px 0 10px 0; 
    font-size: 16px; 
    border-left: 4px solid #333; 
    padding-left: 10px;
    line-height: 1.2;
    font-weight: bold;
}
.info-inner h3:first-child { margin-top: 0; }

.info-list { 
    list-style: none; 
    padding: 0; 
    margin: 0; 
}

.info-list li { 
    margin-bottom: 12px; 
    padding: 10px 15px; 
    background: #f0f7ff; 
    border-left: 4px solid #006cd8; 
    border-radius: 2px 6px 6px 2px;
    font-size: 13px;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.info-list li:last-child { margin-bottom: 0; }

.info-label { 
    font-weight: bold; 
    color: #004a94; 
    margin-right: 8px;
    display: inline-block;
    min-width: 60px;
}

.info-list a { 
    display: block;
    font-size: 11px;
    margin-top: 4px;
    color: #006cd8; 
    text-decoration: none; 
    word-break: break-all;
}

.info-list a:hover { text-decoration: underline !important; }

/* お問い合わせ（X連携）用スタイル */
.x-contact-container {
    display: flex;
    align-items: center;
    gap: 10px;
}
.x-icon {
    width: 20px;
    height: 20px;
    fill: #004a94;
    flex-shrink: 0;
}
.x-text-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.x-name {
    font-size: 14px;
    font-weight: bold;
    color: #333;
}
.x-id {
    font-size: 16px !important;
    font-weight: bold;
    color: #006cd8 !important;
    text-decoration: none !important;
}

/* 注意事項用スタイル */
.disclaimer { 
    margin-bottom: 15px;
    padding: 10px 15px; 
    background: #f0f7ff; 
    border-left: 4px solid #006cd8; 
    border-radius: 2px 6px 6px 2px;
}
.disclaimer-list {
    margin: 0;
    padding: 0 0 0 1.2em;
    list-style-type: disc;
    font-size: 13px; 
    color: #555;
    line-height: 1.6;
}
.disclaimer-list li { margin-bottom: 4px; }
.disclaimer-list li:last-child { margin-bottom: 0; }

@media screen and (max-width: 600px) {
    #info-container.expanded { 
        width: calc(100vw - (var(--spacing) * 2)) !important; 
        /* スマホ用詳細計算: 
           bottom位置(spacing+25) + top余白(spacing) + layer/opacity(unit*2 + 15) 
           + ctrl-top(30) + ctrl-group(unit*3 + 15*2) + 上の空き(spacing)
           計算結果、約450px〜差し引くことで3Dボタンの下端に揃います。 */
        max-height: calc(100vh - (var(--spacing) * 3) - 380px) !important; 
    }
}
