/*
 * 東京都犯罪データマップ スタイルシート
 * ビジネスライク・親しみやすいデザイン
 */

/* リセット */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* CSS変数 - カラーパレット（ビジネスライク） */
:root {
    /* 背景色 */
    --bg-primary: #f8f9fa;
    --bg-white: #ffffff;

    /* テキスト色 */
    --text-primary: #2c3e50;
    --text-secondary: #5a6c7d;
    --text-muted: #95a5a6;

    /* ブランドカラー */
    --brand-primary: #0066cc;
    --brand-primary-dark: #0052a3;
    --brand-primary-light: #4d94ff;

    /* UI要素 */
    --border-light: #e1e8ed;
    --border-default: #d1d9e0;
    --hover-bg: #f0f3f5;

    /* シャドウ */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

    /* その他 */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ベーススタイル */
html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN",
                 "Hiragino Sans", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ページフレーム */
.page {
    max-width: 1360px;
    margin: 0 auto;
    padding: 12px 24px 12px;
}

/* モーダル */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.modal.active {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: fixed;
    right: 24px;
    top: 80px;
    max-width: 600px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    z-index: 10001;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
}

@media (min-width: 1360px) {
    .modal-content {
        right: calc((100vw - 1360px) / 2 + 24px);
    }
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 20px;
}

.modal-body {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-primary);
}

.modal-body p {
    margin: 0 0 16px;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

.modal-body a {
    color: var(--brand-primary);
    text-decoration: none;
    word-break: break-all;
}

.modal-body a:hover {
    text-decoration: underline;
}

.modal-links {
    margin: 12px 0 0;
    padding: 0 0 0 20px;
    list-style: none;
}

.modal-links li {
    margin-bottom: 8px;
    position: relative;
}

.modal-links li:before {
    content: '•';
    position: absolute;
    left: -20px;
    color: var(--brand-primary);
}

.modal-links a {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 600;
}

.modal-links a:hover {
    text-decoration: underline;
}

/* ナビゲーションバー */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0px 0 12px;
}

.navbar-container {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar-logo {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ボタンスタイル */
.btn {
    height: 38px;
    padding: 0 20px;
    border: 1.5px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.btn:hover {
    background: var(--hover-bg);
    border-color: var(--brand-primary-light);
    color: var(--brand-primary);
}

.btn-primary {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: var(--bg-white);
}

.btn-primary:hover {
    background: var(--brand-primary-dark);
    border-color: var(--brand-primary-dark);
    color: var(--bg-white);
}

/* メインコンテナ */
.container {
    max-width: 1360px;
    margin: 0 auto;
}

/* ナビゲーションリンク（タブカード） */
.nav-links {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 20px 18px;
    margin-top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 14px;
    border: 1px solid var(--border-light);
    transition: border-radius 0.3s ease, box-shadow 0.3s ease;
}

/* スクロール時のスタイル */
.nav-links.scrolled {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    border-top-color: transparent;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
}

.nav-link {
    color: var(--brand-primary);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    padding: 4px 0 2px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--brand-primary-dark);
    border-bottom-color: var(--brand-primary-light);
}

.nav-link-active {
    color: var(--brand-primary);
}

.nav-divider {
    color: var(--text-muted);
    user-select: none;
    position: relative;
    top: -3px;
}

/* マップセクション（メインカード） */
.map-section {
    margin-top: 20px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 32px;
    border: 1px solid var(--border-light);
}

.section-title {
    margin: 0 0 16px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.section-subtitle {
    font-size: 18px;
    font-weight: 400;
}

.section-divider {
    height: 1px;
    background: var(--border-light);
    border: 0;
    margin: 0 0 24px;
}

/* マップとデータパネルのコンテナ */
.map-data-container {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 24px;
    align-items: stretch;
}

/* マップエリア（左側） */
.map-area {
    background: #fafbfc;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#map-container {
    width: 100%;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafbfc;
}

#map {
    width: 100%;
    height: 100%;
    display: block;
}

/* 地域パス（SVG） */
.region-path {
    stroke: #a0aec0;
    stroke-width: 1.5;
    cursor: pointer;
    transition: all 0.2s ease;
}

.region-path:hover {
    stroke: var(--brand-primary);
    stroke-width: 2.5;
    filter: brightness(1.05);
}

/* 地域ラベル（SVG） */
.region-label {
    text-anchor: middle;
    dominant-baseline: middle;
    font-size: 11px;
    font-weight: 600;
    fill: #1a1a2e;
    stroke: #fff;
    stroke-width: 3;
    paint-order: stroke;
    pointer-events: none;
}

/* データパネル（右側） */
.data-panel {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 24px 20px 20px;
    overflow: hidden;
}

.data-panel-header-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 16px;
}

.data-panel-header {
    margin-bottom: 0px;
}

.data-panel-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.data-count {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 0;
}

.data-count-number {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--brand-primary);
}

.data-count-unit {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
}

.data-divider {
    border-top: 1px dashed #9ea6ae;
    margin: 15px 0;
}

.data-breakdown {
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    line-height: 1.4;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    margin-bottom: 2px;
}

.breakdown-item:hover {
    background: var(--hover-bg);
}

.breakdown-label {
    color: var(--text-primary);
    font-size: 14px;
}

.breakdown-count {
    font-weight: 700;
    color: var(--brand-primary);
    min-width: 36px;
    text-align: right;
    font-size: 14px;
}

/* ツールチップ */
.tooltip {
    position: absolute;
    background: rgba(44, 62, 80, 0.95);
    color: white;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    pointer-events: none;
    display: none;
    z-index: 1000;
    white-space: nowrap;
}

.tooltip-visible {
    display: block;
}

/* ローディング */
.loading {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-light);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* エラーメッセージ */
.error-title {
    color: #e53e3e;
    margin-bottom: 16px;
}

.error-description {
    margin-bottom: 12px;
}

.error-list {
    text-align: left;
    max-width: 500px;
    margin: 20px auto;
    line-height: 1.8;
}

.error-detail {
    color: #999;
    font-size: 12px;
    margin-top: 20px;
}

/* マップ凡例 */
.map-legend {
    padding-top: 20px;
}

.legend-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.legend-items {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.legend-color-box {
    width: 100%;
    height: 15px;
    border: 1px solid var(--border-default);
    border-radius: 3px;
}

.legend-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.3;
}

/* グラフセクション */
.graph-section {
    margin-top: 20px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 32px;
    border: 1px solid var(--border-light);
}

.graph-controls {
    margin-bottom: 24px;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.checkbox-item label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
}

.graph-container {
    position: relative;
    height: 400px;
    background: var(--bg-white);
}

/* 地域ごとの犯罪発生状況セクション */
.regional-section {
    margin-top: 20px;
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 32px;
    border: 1px solid var(--border-light);
}

.region-nav-group {
    margin-bottom: 32px;
}

.region-nav-item {
    margin-bottom: 20px;
}

.region-nav-item:last-child {
    margin-bottom: 0;
}

.region-nav-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 10px;
}

.region-nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.region-link {
    color: var(--brand-primary);
    font-size: 14px;
    font-weight: 400;
    text-decoration: none;
    white-space: nowrap;
    padding: 2px 0;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.region-link:hover {
    color: var(--brand-primary-dark);
    border-bottom-color: var(--brand-primary-light);
}

.region-cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.region-card {
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    scroll-margin-top: 80px;
}

.region-card-header {
    margin-bottom: 16px;
    position: relative;
}

.region-card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.region-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.region-breakdown-link {
    display: flex;
    align-items: center;
    gap: 2px;
    font-size: 12px;
    font-weight: 400;
    color: var(--brand-primary);
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.region-breakdown-link:hover {
    color: var(--brand-primary-dark);
}

.region-breakdown-link svg {
    flex-shrink: 0;
    position: relative;
    top: 1px;
}

.region-breakdown-tooltip {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: rgba(44, 62, 80, 0.95);
    color: white;
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    z-index: 1000;
    min-width: 250px;
    display: none;
    box-shadow: var(--shadow-md);
}

.region-breakdown-tooltip.visible {
    display: block;
}

.breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.breakdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.breakdown-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.region-tooltip-label {
    flex: 1;
    font-size: 11px;
}

.region-tooltip-count {
    font-weight: 600;
    font-size: 11px;
}

.region-tooltip-total {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    font-weight: 600;
    text-align: right;
}

.region-chart-container {
    position: relative;
    height: 200px;
    background: var(--bg-white);
}

/* フッター */
.footer {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    border: 1px solid var(--border-light);
}

.footer-content {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.8;
}

.footer-link {
    color: var(--brand-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.footer-link:hover {
    color: var(--brand-primary-dark);
    text-decoration: underline;
}

.footer-divider {
    margin: 0 12px;
    color: var(--text-muted);
}

.footer-note {
    margin-top: 12px;
    font-size: 12px;
}

/* 特殊詐欺のトレンドセクション */
.fraud-section {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 24px;
    border: 1px solid var(--border-light);
}

.fraud-intro {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 24px;
    text-align: center;
}

.fraud-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.fraud-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.fraud-card:hover {
    box-shadow: var(--shadow-sm);
}

.fraud-card-header {
    background: var(--bg-white);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.fraud-card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.fraud-card-body {
    padding: 20px;
}

.fraud-description {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.fraud-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-white);
    border: 1px solid var(--brand-primary);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--brand-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.fraud-toggle:hover {
    background: var(--hover-bg);
}

.fraud-toggle.active {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
}

.fraud-toggle-text {
    flex: 1;
    text-align: left;
}

.fraud-toggle-icon {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.fraud-toggle.active .fraud-toggle-icon {
    transform: rotate(180deg);
}

.fraud-examples {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, margin-top 0.4s ease;
}

.fraud-examples.active {
    max-height: 1000px;
    margin-top: 16px;
}

.fraud-examples ul {
    list-style: none;
    padding: 0;
    margin: 0;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}

.fraud-examples li {
    padding: 10px 16px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
}

.fraud-examples li:last-child {
    border-bottom: none;
}

.fraud-examples li:before {
    content: "・";
    color: var(--brand-primary);
    font-weight: bold;
    margin-right: 8px;
}

/* おすすめ防犯グッズセクション */
.security-products-section {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 40px 32px;
    margin-bottom: 24px;
    border: 1px solid var(--border-light);
}

.security-products-intro {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 32px;
    text-align: center;
}

.products-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

.product-card {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 24px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: border-color 0.2s ease;
}

.product-card:hover {
    border-color: var(--brand-primary);
}

.product-image {
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}

.product-content {
    display: flex;
    flex-direction: column;
}

.product-name {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 12px 0;
    line-height: 1.4;
}

.product-name a {
    color: var(--brand-primary);
    text-decoration: underline;
    transition: filter 0.2s ease;
}

.product-name a:hover {
    filter: brightness(1.3);
}

.product-description {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.product-sources {
    display: inline;
    margin-left: 4px;
}

.source-link {
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 8px;
    border: 1px solid var(--border-default);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.source-link:hover {
    color: var(--brand-primary);
    border-color: var(--brand-primary);
    background: var(--hover-bg);
}

.amazon-button {
    display: block;
    background: #ffd814;
    color: #000000;
    font-size: 16px;
    font-weight: 600;
    padding: 16px 20px;
    border-radius: 9999px;
    text-decoration: none;
    text-align: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(255, 216, 20, 0.2);
    width: 33%;
    margin: 0 auto;
}

.amazon-button:hover {
    background: #f7ca00;
    box-shadow: 0 4px 8px rgba(255, 216, 20, 0.3);
}

/* レスポンシブ */
@media (max-width: 1024px) {
    .map-data-container {
        grid-template-columns: 1fr;
    }

    .region-cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal-content {
        right: 20px;
        max-width: calc(100% - 40px);
    }
}

@media (max-width: 768px) {
    .page {
        padding: 20px 16px 32px;
    }

    .navbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .navbar-logo {
        font-size: 22px;
    }

    .navbar-actions {
        gap: 8px;
        width: 100%;
    }

    .btn {
        flex: 1;
        justify-content: center;
        font-size: 13px;
        padding: 0 16px;
    }

    .nav-links {
        padding: 16px 14px;
        gap: 12px;
    }

    .nav-link {
        font-size: 13px;
    }

    .section-title {
        font-size: 20px;
    }

    .map-section,
    .legend-section,
    .footer {
        padding: 24px 20px;
    }

    .map-data-container {
        gap: 20px;
    }

    .legend-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: 12px;
    }

    .region-cards-grid {
        grid-template-columns: 1fr;
    }

    .fraud-grid {
        grid-template-columns: 1fr;
    }

    .fraud-section {
        padding: 24px 20px;
    }

    .modal-content {
        right: 16px;
        top: 60px;
        max-width: calc(100% - 32px);
        padding: 24px 20px;
    }

    .modal-title {
        font-size: 18px;
        margin-bottom: 16px;
    }

    .modal-body {
        font-size: 13px;
    }
}
