/* カード収集アプリ（PWA）の見た目。
   Android 版の Material 3 に寄せているが、Web の作法に無理に合わせない。 */

:root {
  --bg: #FBF3E4;
  --surface: #FFFFFF;
  --on-surface: #1F1B16;
  --muted: #6B625A;
  --line: #E4D9C6;
  --primary: #1A73E8;
  --subject: #1A73E8;
  --distribution: #7C3AED;
  --acquired: #15803D;
  --warn: #C2410C;
  --tabbar-h: 58px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* hidden 属性より display の指定が強い。この1行が無いと、
   .tab-panel { display:flex } のせいで**隠したはずのタブや詳細画面が
   全部重なって出る**（実際に踏んだ）。表示の切り替えは hidden で行うので、
   ここで必ず打ち消しておくこと。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--on-surface);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP",
    "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button { font: inherit; color: inherit; }

.boot {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  color: var(--muted);
}

#app { height: 100%; display: flex; flex-direction: column; }

.tab-panel {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.tab-panel.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pad { padding: 12px 16px calc(16px + var(--safe-b)); }

/* ---- 地図 ---- */
.map { position: absolute; inset: 0; }

.filter-notice, .selection-bar {
  position: absolute; left: 8px; right: 8px;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 4px 4px 10px;
  border-radius: 10px;
  background: #DDE6F5;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
  font-size: 13px;
  z-index: 5;
}
.filter-notice { top: calc(8px + env(safe-area-inset-top, 0px)); }
.selection-bar { top: calc(8px + env(safe-area-inset-top, 0px)); background: #FDE9C8; }
/* 両方出るときは選択バーを上に。押したピンの方が関心が強い。 */
.filter-notice.with-selection { top: calc(52px + env(safe-area-inset-top, 0px)); }
.fn-icon { opacity: .6; }
.fn-text, .sel-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-mark { font-size: 15px; }

.icon-btn {
  border: 0; background: transparent; cursor: pointer;
  width: 30px; height: 30px; border-radius: 15px; font-size: 15px;
}
.icon-btn:active { background: rgba(0,0,0,.08); }
.text-btn {
  border: 0; background: transparent; color: var(--primary);
  cursor: pointer; padding: 4px 8px; font-size: 13px; border-radius: 8px;
}

/* 右下の積み方（下から順に）。
     出典バッジ  10〜 34px   ← 地理院タイルの表示要件。隠してはいけない
     現在地      44〜 73px
     縮尺        86〜104px
     ズーム(+-) 110〜168px

   **MapLibre の流し込みに任せず、位置を直接決めている。**
   既定では float で積まれ、要素を1つ足すだけで全部の位置がずれる。
   高さを決め打ちにして、触ったときに何が動くかを分かるようにする。
   （右上に置けないのは、選択バーが画面幅いっぱいに出るため。6.3.1） */
.fab {
  position: absolute; right: 16px; bottom: 44px;
  width: 29px; height: 29px; padding: 0;
  border: 0; border-radius: 4px;
  background: #fff; color: #333; cursor: pointer;
  box-shadow: 0 0 0 2px rgba(0,0,0,.1);
  display: grid; place-items: center;
  z-index: 5;
}
.fab:active { background: #F2F2F2; }
.fab svg { width: 19px; height: 19px; display: block; }

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-group {
  position: absolute; right: 16px; bottom: 110px; margin: 0;
}
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-scale {
  position: absolute; right: 16px; bottom: 86px; margin: 0;
  background: rgba(255,255,255,.85); font-size: 11px;
}

.legend {
  position: absolute; left: 6px; bottom: 30px;
  background: rgba(255,255,255,.92);
  border-radius: 6px; padding: 5px 8px;
  font-size: 11px; line-height: 1.55;
  z-index: 5;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.legend-row {
  display: flex; align-items: center; gap: 4px;
  border: 0; background: transparent; padding: 0; width: 100%;
  cursor: pointer; text-align: left; font-size: 11px;
}
.legend-row.static { cursor: default; }
.legend-row.off .lg-text { color: #999; text-decoration: line-through; }
.legend-row.off .lg-mark { opacity: .3; }
.lg-mark { width: 14px; display: inline-block; }
.legend-note { color: #555; margin-top: 2px; }

/* ---- 一覧 ---- */
.list-head { background: var(--bg); border-bottom: 1px solid var(--line); }
.search {
  width: calc(100% - 24px); margin: 8px 12px;
  padding: 10px 12px; font-size: 15px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: inherit;
}
.filter-head {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px 6px 16px; border: 0; background: transparent; cursor: pointer;
  text-align: left;
}
.fh-labels { flex: 1; min-width: 0; }
.fh-title { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
.fh-title.on { color: var(--primary); }
.fh-summary { display: block; font-size: 11px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fh-caret { color: var(--muted); }

.filter-panel { padding: 0 16px 10px; }
.group-label { font-size: 11px; font-weight: 700; color: var(--muted); margin: 8px 0 2px; }
.check-row { display: flex; align-items: center; gap: 8px; padding: 5px 0; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); }
.select {
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: inherit; font-size: 14px; min-width: 160px;
}

.list { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.list-count { padding: 6px 16px; font-size: 12px; color: var(--muted); }
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.row-main { flex: 1; min-width: 0; }
.row-title { display: flex; align-items: baseline; gap: 6px; }
.row-name { font-weight: 700; }
.row-series { font-size: 12px; color: var(--muted); }
.row-sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.badge {
  font-size: 10px; padding: 1px 6px; border-radius: 8px;
  background: var(--warn); color: #fff;
}
.check {
  width: 34px; height: 34px; border-radius: 17px; border: 2px solid #B9AE9C;
  background: transparent; cursor: pointer; flex: none;
}
.check.on { background: var(--acquired); border-color: var(--acquired); color: #fff; }

/* ---- タブバー ---- */
.tabbar {
  display: flex; border-top: 1px solid var(--line); background: #F3E7D3;
  padding-bottom: var(--safe-b);
  flex: none;
}
.tab-btn {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 0 5px; font-size: 11px; color: var(--muted);
}
.tab-btn .tb-ic { font-size: 19px; line-height: 1.1; }
.tab-btn.is-on { color: var(--primary); font-weight: 700; }

/* ---- ボトムシート ---- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.32); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  max-height: 72vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 16px calc(16px + var(--safe-b));
  box-shadow: 0 -2px 16px rgba(0,0,0,.2);
}
.sheet-grip {
  width: 36px; height: 4px; border-radius: 2px; background: #CFC4B4;
  margin: 8px auto 10px;
}
.sheet h2 { margin: 2px 0 4px; font-size: 19px; }
.kind { font-size: 13px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.muted { color: var(--muted); font-size: 13px; }
.related {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 6px; border: 0; border-top: 1px solid var(--line);
  background: transparent; cursor: pointer; text-align: left;
}
/* 重なっているピンの選択肢。**シートの一番上。**
   押したつもりと違うものが開いたときに、最初に目に入る場所に置く。 */
.overlap {
  margin: 2px 0 10px;
  border: 1px solid #E2C99A; border-radius: 10px;
  background: #FFF8EC; overflow: hidden;
}
.overlap-head {
  font-size: 12px; font-weight: 700; color: #7A5A20;
  padding: 6px 10px 4px;
}
.overlap-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 10px; border: 0; border-top: 1px solid #EFDFC2;
  background: transparent; cursor: pointer; text-align: left;
  font: inherit; color: inherit;
}
.overlap-row.on { background: #FFEFD2; }
.overlap-row:active { background: #F6E3C4; }
.overlap-now { font-size: 11px; color: var(--muted); flex: none; }

.related.on { background: #FFF4DF; }
.related.disabled { opacity: .45; }
.related-main { flex: 1; min-width: 0; }
.related-title { font-size: 12px; color: var(--muted); }
.related-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- 詳細 ---- */
.detail {
  position: fixed; inset: 0; z-index: 30; background: var(--bg);
  display: flex; flex-direction: column;
}
.detail-head {
  display: flex; align-items: center; gap: 6px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 8px 8px;
  flex: none;
}
.detail-head h1 { font-size: 19px; margin: 0; }
.detail-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 0 16px calc(24px + var(--safe-b));
}
.card-box {
  background: #EFE4D2; border-radius: 12px; padding: 12px; margin: 8px 0 14px;
}
.section-title { font-weight: 700; margin: 14px 0 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.chip {
  font-size: 12px; padding: 2px 9px; border-radius: 10px;
  background: #E0D5C2; color: var(--muted);
}
.chip.warn { background: var(--warn); color: #fff; }
.btn {
  border: 0; border-radius: 20px; padding: 9px 16px; cursor: pointer;
  background: #5C6B8A; color: #fff; font-size: 14px;
}
.btn.tonal { background: #E0D5C2; color: #33302B; }
.btn.block { display: block; width: 100%; margin: 6px 0; }

/* 取得済みの切り替え。**色で示す。**
   文字だけだと押しても変わった気がせず、押せていないのか
   二重に押したのかが分からない。地図の凡例と同じ緑を使う。 */
.btn.acq {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 700; padding: 12px 16px;
}
.btn.acq.on { background: var(--acquired); }
.acq-mark { font-size: 16px; line-height: 1; }
/* 変わった瞬間だけ跳ねる。色の変化を見落としても、動きで気づける。 */
@keyframes acq-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.btn.acq.pop { animation: acq-pop .3s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .btn.acq.pop { animation: none; }
}
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.field { margin-top: 6px; }
.field-label { font-size: 11px; color: var(--muted); }

/* 見落とされては困る注意書き。消えるトーストと違い、見に行けば必ずある。 */
.note-warn {
  margin: 10px 0; padding: 9px 11px;
  border-left: 4px solid var(--warn); border-radius: 0 8px 8px 0;
  background: #FBEAE0; font-size: 12px; line-height: 1.6;
}

/* 券面画像。**枠の高さを決め打ちして中身を contain で収める。**
   外部から読むので届くまで大きさが分からず、高さが可変だと
   読み込んだ瞬間に下の内容が飛ぶ。縦長のカードでも横長の写真でも同じ枠に入る。 */
.card-image { margin: 10px 0 4px; text-align: center; }
.card-image img {
  height: clamp(240px, 42vh, 400px);
  max-width: 100%; object-fit: contain;
  border-radius: 10px; cursor: zoom-in;
  background: #E6DAC8;   /* 透過pngでも枠が浮かないように下地を敷く */
}
.card-image figcaption {
  font-size: 11px; color: var(--muted); margin-top: 4px;
  line-height: 1.5;
}
/* 出典へのリンク。button のままだと枠と余白が付いて本文から浮く。 */
.linklike {
  border: 0; background: none; padding: 0; cursor: pointer;
  font: inherit; color: #4A6FA5; text-decoration: underline;
}

/* ---- ログイン ---- */
.login {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  display: grid; place-items: center; padding: 24px;
}
.login-box {
  width: 100%; max-width: 340px;
  background: var(--surface); border-radius: 14px; padding: 20px;
  box-shadow: 0 2px 14px rgba(0,0,0,.12);
}
.login-box h2 { margin: 0 0 4px; font-size: 20px; }
.login-field { display: block; margin: 12px 0; }
.login-field span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.login-field input {
  width: 100%; padding: 10px 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: inherit;
}
.login-error {
  color: var(--warn); font-size: 13px; margin: 8px 0 0;
}

.toast {
  position: fixed; left: 50%; bottom: calc(80px + var(--safe-b));
  transform: translateX(-50%); z-index: 60;
  background: #2E2A24; color: #fff; font-size: 13px;
  padding: 9px 16px; border-radius: 20px; max-width: 88vw;
  box-shadow: 0 2px 10px rgba(0,0,0,.3);
}

.stat-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.stat-name { width: 120px; font-size: 13px; }
.bar { flex: 1; height: 8px; background: #E0D5C2; border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--acquired); }
.stat-num { font-size: 12px; color: var(--muted); width: 84px; text-align: right; }
