/* ============================================================
   news_map/styles.css — prefecture sentiment heatmap UI
   ============================================================ */

.service-news-map {
    --map-accent: #0d9488;
    --map-accent-hover: #0f766e;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 0;
    background: var(--color-bg-shell);
}

/* 検索バー */
.map-search-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border);
    background: #ffffff;
}

.map-search-form {
    display: flex;
    flex: 1;
    min-width: 260px;
    gap: 8px;
}

.map-search-form input {
    flex: 1;
    min-width: 0;
    min-height: 38px;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--fs-base);
}

.map-search-btn {
    flex-shrink: 0;
    min-height: 38px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-md);
    color: #ffffff;
    background: var(--map-accent);
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.map-search-btn:hover {
    background: var(--map-accent-hover);
}

.map-status {
    flex: 1 1 240px;
    min-width: 180px;
    color: var(--color-text-secondary);
    font-size: var(--fs-sm);
}

/* 地図表示指標の切替。radioを残してキーボード操作と読み上げに対応する。 */
.map-metric-switch {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
    gap: 2px;
    margin: 0;
    padding: 3px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: #f1f5f9;
}

.map-metric-switch legend {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.map-metric-option {
    position: relative;
    display: inline-flex;
    cursor: pointer;
}

.map-metric-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.map-metric-option span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 10px;
    border-radius: calc(var(--radius-md) - 2px);
    color: var(--color-text-secondary);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    white-space: nowrap;
    transition: color var(--transition-fast), background var(--transition-fast),
        box-shadow var(--transition-fast);
}

.map-metric-option input:checked + span {
    color: #ffffff;
    background: var(--map-accent);
    box-shadow: var(--shadow-sm);
}

.map-metric-option input:focus-visible + span {
    outline: 3px solid rgba(13, 148, 136, 0.3);
    outline-offset: 2px;
}

/* メインレイアウト: 地図 + サイドバー + フッター */
.map-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    grid-template-rows: minmax(0, 1fr) auto;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.map-main > .detail-sidebar {
    grid-column: 2;
    grid-row: 1 / -1;
    width: 390px;
    min-width: 0;
    overflow-y: auto;
    border-left: 1px solid var(--color-border);
    background: var(--color-bg-surface);
}

.map-main > .footer {
    grid-column: 1;
}

.map-column {
    display: flex;
    min-width: 0;
    min-height: 0;
    padding: 16px 16px 0;
}

.map-container {
    position: relative;
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: radial-gradient(
        circle at center,
        #ffffff 0%,
        #f8fafc 58%,
        #eef2f7 100%
    );
    box-shadow: var(--shadow-sm);
}

/* 本土地図（SVGポリゴン） */
#mapSvg {
    display: block;
    flex: 1;
}

.prefecture-path {
    transition: opacity var(--transition-fast);
}

.prefecture-path:hover {
    opacity: 0.8;
}

.map-empty-text {
    fill: var(--color-text-muted);
    font-size: 14px;
}

/* 沖縄の別枠表示（左上） */
.okinawa-inset {
    position: absolute;
    top: 40px;
    left: 40px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    width: 330px;
    height: 270px;
    padding: 10px 10px 6px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow-sm);
}

.okinawa-inset-label {
    margin-bottom: 2px;
    color: var(--color-text-secondary);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    text-align: center;
}

#okinawaSvg {
    flex: 1;
    min-height: 0;
}

#okinawaSvg .prefecture-path {
    stroke-width: 0.6;
}

/* ツールチップ */
.map-tooltip {
    position: fixed;
    z-index: 30;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    color: #f8fafc;
    background: rgba(15, 23, 42, 0.92);
    font-size: var(--fs-xs);
    line-height: 1.5;
    pointer-events: none;
    box-shadow: var(--shadow-md);
    max-width: 300px;
}

.map-tooltip strong {
    display: block;
    font-size: var(--fs-sm);
    margin-bottom: 2px;
}

.map-tooltip .tooltip-score {
    color: rgba(248, 250, 252, 0.82);
}

.map-tooltip .tooltip-primary {
    color: #ffffff;
    font-weight: var(--fw-semibold);
}

.map-tooltip .tooltip-breakdown {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid rgba(248, 250, 252, 0.18);
    color: rgba(248, 250, 252, 0.9);
}

/* ローディングオーバーレイ */
.map-loading {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    color: var(--color-text-secondary);
    background: rgba(248, 250, 252, 0.8);
    font-size: 20px;
    font-weight: var(--fw-semibold);
}

.map-loading .spinner {
    width: 56px;
    height: 56px;
    border: 5px solid rgba(15, 23, 42, 0.15);
    border-top-color: var(--map-accent, #0d9488);
}

/* 凡例（地図右下） */
.map-legend {
    position: absolute;
    right: 14px;
    bottom: 14px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    min-width: 230px;
    padding: 7px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: var(--shadow-sm);
    font-size: var(--fs-xs);
    color: var(--color-text-secondary);
}

.map-legend-title {
    color: var(--color-text-primary);
    font-weight: var(--fw-bold);
    text-align: center;
}

.map-legend-scale {
    display: flex;
    align-items: center;
    gap: 7px;
}

.map-legend-label {
    white-space: nowrap;
}

.map-legend-bar {
    display: inline-block;
    flex: 1;
    min-width: 110px;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(
        to right,
        #ffffcc 0%,
        #ffeda0 13.33%,
        #feb24c 33.33%,
        #f03b20 66.67%,
        #bd0026 100%
    );
}

.map-legend[data-metric="score"] .map-legend-bar {
    background: linear-gradient(
        to right,
        #d73027 0%,
        #fee08b 20%,
        #1a9850 60%,
        #2166ac 100%
    );
}

/* 使い方パネル（ポップアップ）: company_graph と同等のスタイル */
.help-panel {
    position: relative;
}

.help-panel-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.08);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    cursor: pointer;
    list-style: none;
    white-space: nowrap;
    transition: border-color var(--transition-fast), color var(--transition-fast),
        background var(--transition-fast);
}

.help-panel-toggle::-webkit-details-marker {
    display: none;
}

.help-panel-toggle:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.16);
}

.help-panel[open] .help-panel-toggle {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.18);
}

.help-panel-content {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    z-index: 1000;
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding: 22px 24px;
    border: 1px solid var(--color-border);
    border-radius: 14px;
    color: var(--color-text-primary);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, #f4fbfa 100%);
    box-shadow: var(--shadow-lg);
}

.help-panel-eyebrow {
    margin-bottom: 8px;
    color: var(--map-accent, var(--color-accent-text));
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    letter-spacing: 0.03em;
}

.help-panel-title {
    margin-bottom: 12px;
    color: var(--color-text-primary);
    font-size: var(--fs-xl);
    line-height: 1.4;
}

.help-panel-description {
    margin-bottom: 16px;
    color: var(--color-text-secondary);
    font-size: var(--fs-sm);
    line-height: 1.7;
}

.help-panel-section + .help-panel-section {
    margin-top: 16px;
}

.help-panel-section-title {
    margin-bottom: 8px;
    color: var(--color-text-primary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
}

.help-panel-content ul {
    margin: 0;
    padding-left: 20px;
    color: var(--color-text-secondary);
    font-size: var(--fs-sm);
    line-height: 1.7;
}

.help-panel-content li + li {
    margin-top: 4px;
}

/* help-panel 内の色凡例ドット */
.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 4px;
    border-radius: 50%;
    vertical-align: middle;
}
.legend-negative {
    background: #d73027;
}
.legend-rate-zero {
    background: #ffffcc;
    border: 1px solid #d6d39f;
}
.legend-rate-high {
    background: #bd0026;
}
.legend-neutral {
    background: #fee08b;
}
.legend-positive {
    background: #1a9850;
}
.legend-strong-positive {
    background: #2166ac;
}
.legend-none {
    background: #e8e8e8;
}

/* サイドバー記事一覧（company_graph の detail-sidebar 相当） */
.sidebar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 24px 28px;
    color: var(--color-text-muted);
    text-align: center;
}

.sidebar-placeholder p {
    max-width: 290px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.sidebar-loading {
    color: var(--color-text-secondary);
}

.sidebar-error {
    color: #b42318;
}

.prefecture-detail-content {
    padding: 16px 18px;
}

.prefecture-detail-content h3 {
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--map-accent, var(--color-accent));
    color: var(--color-text-primary);
    font-size: var(--fs-xl);
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.prefecture-sentiment-summary {
    padding: 14px;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #fff7ed 0%, #fff1f2 100%);
}

.sentiment-summary-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 3px 8px;
}

.sentiment-summary-heading > span:first-child {
    flex-basis: 100%;
    color: var(--color-text-secondary);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
}

.sentiment-summary-heading strong {
    color: #b91c1c;
    font-size: 28px;
    line-height: 1.2;
}

.sentiment-summary-rate-label {
    color: #991b1b;
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
}

.sentiment-breakdown {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    margin: 12px 0 0;
}

.sentiment-breakdown-item {
    min-width: 0;
    padding: 7px 6px;
    border-left: 3px solid;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.78);
}

.sentiment-breakdown-item dt {
    color: var(--color-text-muted);
    font-size: 11px;
    line-height: 1.3;
}

.sentiment-breakdown-item dd {
    margin: 3px 0 0;
    color: var(--color-text-primary);
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
}

.sentiment-breakdown-negative {
    border-color: #dc2626;
}

.sentiment-breakdown-neutral {
    border-color: #f59e0b;
}

.sentiment-breakdown-positive {
    border-color: #0d9488;
}

.sentiment-summary-note {
    margin: 10px 0 0;
    color: var(--color-text-muted);
    font-size: 11px;
    line-height: 1.5;
}

.prefecture-detail-content .section-title {
    margin-top: 20px;
    color: var(--color-text-muted);
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    letter-spacing: 0;
    text-transform: uppercase;
}

.prefecture-detail-content .article-list {
    display: block;
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
}

.prefecture-detail-content .article-list li {
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--color-border);
}

.prefecture-detail-content .article-list li:last-child {
    border-bottom: none;
}

/* 記事左の sentiment バー */
.prefecture-detail-content .article-item {
    position: relative;
}

.prefecture-detail-content .article-item.has-sentiment-positive,
.prefecture-detail-content .article-item.has-sentiment-negative,
.prefecture-detail-content .article-item.has-sentiment-neutral {
    padding-left: 14px;
}

.prefecture-detail-content .article-item.has-sentiment-positive::before,
.prefecture-detail-content .article-item.has-sentiment-negative::before,
.prefecture-detail-content .article-item.has-sentiment-neutral::before {
    position: absolute;
    top: 2px;
    bottom: 16px;
    left: 0;
    width: 6px;
    border-radius: 3px;
    background: var(--sentiment-bar-color);
    content: "";
}

.prefecture-detail-content .article-list a {
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: var(--color-text-primary);
    text-decoration: none;
}

.prefecture-detail-content .article-list a:hover .article-title {
    color: var(--map-accent, var(--color-accent-text));
}

.prefecture-detail-content .article-date,
.prefecture-detail-content .article-source {
    color: var(--color-text-muted);
    font-size: var(--fs-sm);
}

.prefecture-detail-content .article-source {
    max-width: none;
    padding: 0;
    border: none;
    background: transparent;
    font-weight: var(--fw-medium);
}

.prefecture-detail-content .article-title {
    margin: 0;
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    line-height: 1.45;
}

.prefecture-detail-content .empty {
    color: var(--color-text-muted);
    text-align: center;
    padding: 24px 0;
}

/* レスポンシブ: 狭画面ではサイドバーを下に */
@media (max-width: 900px) {
    .map-main {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(280px, 1fr) minmax(240px, 40vh) auto;
    }
    .map-main > .detail-sidebar {
        grid-column: 1;
        grid-row: 2;
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--color-border);
    }
    .map-main > .footer {
        grid-row: 3;
    }
}

@media (max-width: 620px) {
    .map-search-form,
    .map-status {
        flex-basis: 100%;
    }

    .map-metric-switch {
        width: 100%;
    }

    .map-metric-option {
        flex: 1;
    }

    .map-metric-option span {
        justify-content: center;
        width: 100%;
    }

    .map-legend {
        right: 8px;
        bottom: 8px;
        min-width: min(230px, calc(100% - 16px));
    }
}
