/* ─── リセット＆変数（共通設定） ─────────────────────────────── */
/* 全ての要素の余白をゼロにして、サイズ計算を統一する（おまじない） */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ★色やフォントをここで一括管理しています。色を変えたい場合はここを変更！ */
:root {
    --ocean: #006994;   /* 海の色（ボタンなどに使用） */
    --coral: #e8634b;   /* サンゴ色（アクセントカラー） */
    --sand: #f5e6c8;    /* 砂浜の色（文字色などに使用） */
    --forest: #0a3d2e;  /* 森の色（背景やヘッダーに使用） */
    --white: #ffffff;   /* 白色 */
    --shadow: rgba(0, 0, 0, 0.25); /* 影の色 */
    --radius: 14px;     /* 角の丸み */
    --font-heading: 'Noto Serif JP', serif; /* 見出し用フォント */
    --font-body: 'Zen Kaku Gothic New', sans-serif; /* 本文用フォント */
}

/* 画面全体の基本設定 */
html, body {
    width: 100%;
    height: 100%;
    overflow: hidden; /* スクロールバーを出さない */
    font-family: var(--font-body);
    background: var(--forest);
}

/* ─── スプラッシュ画面（起動画面） ─────────────────────────────────── */
#splash {
    position: fixed;
    inset: 0;
    z-index: 9999; /* 一番手前に表示 */
    background: var(--forest);
    display: flex; /* 中身を中央揃えにする設定 */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px; /* 要素の隙間 */
    transition: opacity 0.9s ease, visibility 0.9s ease; /* ふわっと消えるアニメーション */
}

/* プログラムからこのクラスが付与されると画面が消える */
#splash.hide {
    opacity: 0;
    visibility: hidden;
}

/* ロゴ画像のアニメーション設定 */
#splash-logo {
    width: min(200px, 55vw); /* スマホサイズに合わせて調整 */
    height: auto;
    object-fit: contain;
    animation: logoFloat 2s ease-in-out infinite alternate; /* ふわふわ上下に動く */
}

/* 画像が読み込めなかった時の予備ロゴデザイン */
#splash-logo-fallback { display: none; width: min(200px, 55vw); text-align: center; }
#splash-logo-fallback .logo-circle {
    width: 100px; height: 100px; background: linear-gradient(135deg, var(--ocean), var(--coral));
    border-radius: 50%; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center;
    font-size: 2.4rem; box-shadow: 0 0 40px rgba(0, 105, 148, 0.6);
}
#splash-logo-fallback .logo-title { color: var(--sand); font-family: var(--font-heading); font-size: 1.3rem; letter-spacing: .12em; }

/* ふわふわ動かすためのアニメーション定義 */
@keyframes logoFloat {
    from { transform: translateY(0px); }
    to { transform: translateY(-10px); }
}

/* サブタイトル（OKINAWA SPOT GUIDE） */
#splash-subtitle {
    color: var(--sand);
    font-family: var(--font-heading);
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    letter-spacing: .2em;
    opacity: 0.75;
}

/* ローディングの丸（3つ） */
#splash-loader { display: flex; gap: 6px; margin-top: 8px; }
#splash-loader span {
    width: 8px; height: 8px; background: var(--coral); border-radius: 50%;
    animation: bounce 0.9s ease-in-out infinite alternate; /* ピョンピョン跳ねる */
}
/* 2番目、3番目の丸の動きを少し遅らせる */
#splash-loader span:nth-child(2) { animation-delay: 0.2s; }
#splash-loader span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(-10px); opacity: 0.4; }
}

/* ─── 地図エリア ─────────────────────────────────── */
#map {
    position: fixed; inset: 0; width: 100%; height: 100%;
    opacity: 0; transition: opacity 0.9s ease 0.3s; /* 最初は透明で、後からふわっと表示 */
}
#map.visible { opacity: 1; }

/* ─── ヘッダーバー ─────────────────────────────────────── */
#header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 500; height: 56px;
    background: linear-gradient(180deg, rgba(10, 61, 46, 0.92) 0%, rgba(10, 61, 46, 0) 100%); /* 上から下へ透明になるグラデーション */
    padding: 0 16px; display: flex; align-items: center; gap: 10px;
    pointer-events: none; /* クリックをすり抜けさせる */
}
#header-title { color: var(--white); font-family: var(--font-heading); font-size: 1.05rem; letter-spacing: .12em; text-shadow: 0 1px 4px var(--shadow); }
#header-wave { font-size: 1.3rem; line-height: 1; }

/* ─── スポット数のバッジ（右上） ───────────────────────────────── */
#spot-count {
    position: fixed; top: 14px; right: 16px; z-index: 501;
    background: rgba(0, 105, 148, 0.88); color: var(--white); font-size: 0.75rem;
    padding: 4px 10px; border-radius: 20px; backdrop-filter: blur(4px); /* 背景を少しぼかす */
    display: none; /* 最初は隠しておく */
}

/* ─── 現在地ボタン（右下） ─────────────────────────────────── */
#btn-locate {
    position: fixed;
    /* iPhoneの画面下のバーに被らないようにする工夫（env） */
    bottom: max(30px, env(safe-area-inset-bottom, 30px)); 
    right: 16px; z-index: 500; width: 52px; height: 52px;
    background: var(--white); border: none; border-radius: 50%;
    box-shadow: 0 4px 16px var(--shadow); display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: transform 0.15s ease, box-shadow 0.15s ease;
}
/* 押した時のへこむ動き */
#btn-locate:active { transform: scale(0.92); box-shadow: 0 2px 8px var(--shadow); }
/* アイコンの線の色と太さ */
#btn-locate svg { width: 24px; height: 24px; fill: none; stroke: var(--ocean); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: stroke 0.2s; }
/* 検索中の色変更 */
#btn-locate.locating svg { stroke: var(--coral); }

/* ─── 地図のポップアップ（吹き出し）のデザイン上書き ───────────────────────── */
/* Leafletの標準デザインを打ち消してオシャレにしています */
.leaflet-popup-content-wrapper { border-radius: var(--radius) !important; padding: 0 !important; overflow: hidden !important; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2) !important; min-width: 230px; max-width: min(300px, 86vw); }
.leaflet-popup-tip { background: var(--white) !important; }
.leaflet-popup-content { margin: 0 !important; width: auto !important; }

/* ポップアップの中身のデザイン */
.popup-card { font-family: var(--font-body); }
.popup-img { width: 100%; height: 160px; object-fit: cover; display: block; background: #c5dce8; }
.popup-img-placeholder { width: 100%; height: 160px; background: linear-gradient(135deg, var(--ocean), #1a8ab0); display: flex; align-items: center; justify-content: center; font-size: 2.5rem; }
.popup-body { padding: 12px 14px 14px; }
.popup-name { font-family: var(--font-heading); font-size: 1rem; color: var(--forest); margin-bottom: 5px; line-height: 1.4; }
.popup-address { font-size: 0.78rem; color: #555; margin-bottom: 12px; line-height: 1.5; }
.popup-address::before { content: '📍 '; }

/* ポップアップ内のボタン */
.popup-actions { display: flex; gap: 8px; }
.popup-btn { flex: 1; display: block; text-align: center; text-decoration: none; font-size: 0.78rem; font-weight: 700; padding: 8px 6px; border-radius: 8px; transition: opacity 0.15s; letter-spacing: .04em; }
.popup-btn:active { opacity: 0.75; }
.popup-btn-detail { background: var(--forest); color: var(--white); }
.popup-btn-navi { background: var(--ocean); color: var(--white); }

/* ─── マーカー（地図上のピン）のデザイン ─────────────────────────────────── */
.custom-marker {
    width: 36px; height: 36px; background: var(--coral);
    border: 3px solid var(--white); border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}
/* マーカーの中の白い丸 */
.custom-marker::after { content: ''; position: absolute; inset: 5px; background: var(--white); border-radius: 50%; }

/* ─── 現在地の青いパルス（波紋）デザイン ─────────────────────────────────── */
.location-pulse {
    width: 16px; height: 16px; background: var(--ocean); border: 3px solid white; border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(0, 105, 148, 0.5); animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0, 105, 148, 0.6); }
    70% { box-shadow: 0 0 0 14px rgba(0, 105, 148, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 105, 148, 0); }
}

/* ─── トースト通知（「現在地を表示しました」などのポップアップ） ────────────────────────────── */
#toast {
    position: fixed;
    /* ボタンの上に表示されるように高さを計算 */
    bottom: max(100px, calc(env(safe-area-inset-bottom, 30px) + 74px)); 
    left: 50%; transform: translateX(-50%); z-index: 600;
    background: rgba(10, 61, 46, 0.92); color: var(--white); font-size: 0.82rem;
    padding: 9px 18px; border-radius: 24px; backdrop-filter: blur(6px);
    white-space: nowrap; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease;
}
#toast.show { opacity: 1; visibility: visible; }

/* ─── 右下のクレジット表記（コピーライト）を小さくする ─────────────────────── */
.leaflet-control-attribution { font-size: 9px !important; background: rgba(255, 255, 255, 0.7) !important; }