/* ============================================================
   かみやま遊山マップ  —  styles
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Yu Gothic", YuGothic, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  color: #2b2b28;
  background: #f7f3e8;
  -webkit-font-smoothing: antialiased;
}

/* Material Symbols helper */
.ms {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  line-height: 1;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}
.fill { font-variation-settings: 'FILL' 1; }

/* Scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d8cdb4; border-radius: 9px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #c4b694; background-clip: content-box; }

/* ============ LAYOUT ============ */
.app { display: flex; height: 100vh; width: 100%; overflow: hidden; }

/* ---- Left rail ---- */
.rail {
  width: 150px; flex-shrink: 0; background: #2f6f4e;
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0 12px; gap: 5px; z-index: 1000;
  box-shadow: 2px 0 10px rgba(0,0,0,.08);
}
.rail-logo { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-bottom: 8px; }
.rail-logo-text { font-family: 'Zen Maru Gothic'; font-weight: 700; font-size: 20px; color: #cfe6d6; letter-spacing: .04em; text-align: center; }
.rail-cats { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 100%; }
.rail-spacer { flex: 1; }

.railbtn-cat {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  width: 108px; padding: 10px 0; border-radius: 14px; cursor: pointer;
  transition: background .12s, transform .1s;
}
.railbtn-cat:active { transform: scale(.94); }
.railbtn-cat.active { background: #fff; }
.railbtn-cat.dim:not(.active) { opacity: .62; }
.railbtn-cat .cat-label { font-size: 15px; font-weight: 700; line-height: 1.15; text-align: center; }
.railbtn-cat .cat-count { font-size: 13.5px; }

.rail-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 108px; padding: 10px 0; border-radius: 14px; cursor: pointer;
  border: none; font-family: inherit; transition: background .12s, transform .1s;
}
.rail-btn:active { transform: scale(.94); }
.rail-btn-fav { background: #c97b3d; }
.rail-btn-qr  { background: rgba(255,255,255,.16); }
.rail-btn-label { font-size: 13.5px; font-weight: 700; color: #fff; }

/* ---- Center map ---- */
.map-wrap { flex: 1; position: relative; min-width: 0; }
#kmap { position: absolute; inset: 0; }
.leaflet-container { font-family: inherit; background: #e9ede0; }
.leaflet-popup-content-wrapper { border-radius: 12px; }

.map-topbar {
  position: absolute; top: 14px; left: 14px; right: 14px;
  display: flex; gap: 10px; align-items: center; pointer-events: none; z-index: 600;
}
.searchbox {
  display: flex; align-items: center; gap: 8px; background: #fffdf8;
  border-radius: 999px; padding: 9px 15px; box-shadow: 0 2px 10px rgba(0,0,0,.13);
  pointer-events: auto; min-width: 230px;
}
.searchbox input {
  border: none; outline: none; background: transparent; font-size: 18px;
  font-family: inherit; color: #2b2b28; width: 230px;
}
.searchbox-clear { font-size: 19px; color: #bcae93; cursor: pointer; }

.status-pill {
  display: flex; align-items: center; gap: 7px; background: #fffdf8;
  border-radius: 999px; padding: 9px 15px; box-shadow: 0 2px 10px rgba(0,0,0,.13); pointer-events: auto;
}
.status-pill span:last-child { font-size: 14.5px; font-weight: 700; color: #2b2b28; }

.recenter-btn {
  position: absolute; bottom: 24px; left: 14px; z-index: 600;
  display: flex; align-items: center; gap: 6px; background: #fffdf8;
  border-radius: 999px; padding: 9px 14px; box-shadow: 0 2px 8px rgba(0,0,0,.16);
  cursor: pointer; border: none; font-family: inherit;
}
.recenter-btn span:last-child { font-size: 13.5px; font-weight: 700; color: #2b2b28; }

/* ---- Map pins ---- */
.kpin { filter: drop-shadow(0 2px 3px rgba(0,0,0,.28)); }
.kpin.sel { animation: kbounce .5s ease; }
@keyframes kbounce { 0%{transform:translateY(0)} 30%{transform:translateY(-8px)} 60%{transform:translateY(-2px)} 100%{transform:translateY(0)} }
.leaflet-marker-icon.kpulse { z-index: 1500 !important; }

/* ---- Right list ---- */
.panel {
  width: 600px; flex-shrink: 0; border-left: 1px solid #e7ddc6;
  display: flex; flex-direction: column; background: #faf6ec; z-index: 500; position: relative;
}
.panel-head { padding: 14px 16px 12px; border-bottom: 1px solid #ece3cf; background: #fffdf8; }
.panel-head > div { display: flex; align-items: baseline; justify-content: space-between; }
.panel-title { font-family: 'Zen Maru Gothic'; font-weight: 700; font-size: 20px; color: #2b2b28;
  display: flex; align-items: baseline; justify-content: space-between; }
.panel-count { font-size: 14px; color: #9a9181; font-weight: 400; }
.panel-sort { display: inline-flex; align-items: center; gap: 3px; font-size: 16.5px; color: #6f6657; cursor: pointer; }
.panel-list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px; display: flex; flex-direction: column; gap: 10px; }

/* list card */
.lcard {
  position: relative; display: flex; gap: 11px; padding: 11px; border-radius: 13px;
  background: #fff; cursor: pointer; border: 1px solid #ece3cf;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s;
}
.lcard:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.1); }
.lcard.sel { border: 2px solid #2f6f4e; box-shadow: 0 4px 12px rgba(47,111,78,.13); }
.lcard-img { width: 80px; height: 80px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: #e9ede0; }
.lcard-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lcard-badge {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 3px;
  font-size: 12px; font-weight: 700; border-radius: 5px; padding: 2px 8px;
}
.lcard-title {
  font-family: 'Zen Maru Gothic'; font-weight: 700; font-size: 16.5px; color: #2b2b28; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.lcard-meta { font-size: 12.5px; color: #7a7263; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.lcard-fav {
  position: absolute; top: 9px; right: 9px; width: 30px; height: 30px; border-radius: 50%;
  font-size: 22px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}

.empty-state {
  display: flex; flex-direction: column; align-items: center; padding: 40px 20px;
  color: #9a9181; text-align: center; gap: 8px;
}

/* ---- Detail panel (overlays list) ---- */
#detail-panel:empty { display: none; }
.kdetail {
  position: absolute; inset: 0; background: #fff; display: flex; flex-direction: column; z-index: 30;
  animation: kslide .26s cubic-bezier(.22,.61,.36,1);
}
@keyframes kslide { from{transform:translateX(28px);opacity:0} to{transform:translateX(0);opacity:1} }
.kdetail-back {
  display: flex; align-items: center; gap: 7px; padding: 12px 15px;
  border-bottom: 1px solid #ece3cf; background: #fffdf8; cursor: pointer; flex-shrink: 0;
}
.kdetail-back span:last-child { font-size: 14.5px; font-weight: 700; color: #2f6f4e; }
.kdetail-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; }
.kdetail-hero { position: relative; }
.kdetail-hero img { width: 100%; height: 300px; object-fit: cover; display: block; background: #e9ede0; }
.kdetail-favbtn {
  position: absolute; top: 12px; right: 12px; width: 40px; height: 40px; border-radius: 50%;
  font-size: 22px; display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.22);
}
.kdetail-body { padding: 14px 17px 16px; }
.kdetail-tags { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.kdetail-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; border-radius: 6px; padding: 3px 10px; }
.kdetail-sub { font-size: 13px; color: #9a9181; }
.kdetail-approx { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: #b08948; background: #fbf2df; border-radius: 5px; padding: 2px 8px; }
.kdetail-title { font-family: 'Zen Maru Gothic'; font-weight: 700; font-size: 22px; color: #2b2b28; margin: 9px 0 7px; line-height: 1.35; }
.kdetail-desc { font-size: 14px; color: #5d564a; line-height: 1.8; margin-bottom: 13px; }
.kdetail-info { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.kdetail-info-row { display: flex; align-items: flex-start; gap: 9px; font-size: 14px; color: #3d382f; }
.kdetail-info-row .ms { font-size: 18px; color: #2f6f4e; flex-shrink: 0; }
.kdetail-closed { color: #a85877; margin-left: 8px; }
.kdetail-actions { display: flex; gap: 8px; }
.kdetail-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px; font-size: 14px; font-weight: 700; border-radius: 10px; padding: 12px; text-decoration: none; }
.kdetail-btn.ghost { color: #c97b3d; border: 1.5px solid #e6c9a8; }
.kdetail-btn.solid { color: #fff; background: #2f6f4e; }

.kdetail-nearby { display: flex; flex-direction: column; margin-top: 14px; padding-top: 13px; border-top: 1px dashed #e2d8bf; }
.kdetail-nearby-head { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 700; color: #2f6f4e; margin-bottom: 9px; }
.kdetail-nearby-row { display: flex; gap: 9px; }
.nearby-card { flex: 1; min-width: 0; cursor: pointer; border-radius: 11px; overflow: hidden; border: 1px solid #ece3cf; background: #fff; transition: transform .12s ease, box-shadow .12s ease; }
.nearby-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.1); }
.nearby-card img { width: 100%; height: 80px; object-fit: cover; display: block; background: #e9ede0; }
.nearby-card-body { padding: 6px 8px; }
.nearby-card-title { font-size: 16px; font-weight: 700; color: #2b2b28; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nearby-card-meta { font-size: 13.5px; font-weight: 700; margin-top: 2px; }

/* ============ MODALS ============ */
.modalbg { position: fixed; inset: 0; background: rgba(43,43,40,.5); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 24px; animation: fadebg .18s ease; }
@keyframes fadebg { from{opacity:0} to{opacity:1} }
.modal { animation: fadein .22s ease; }
@keyframes fadein { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* Favorites modal */
.fav-modal { width: min(460px,100%); max-height: 84vh; background: #fffdf8; border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3); display: flex; flex-direction: column; overflow: hidden; }
.fav-head { padding: 18px 20px 14px; border-bottom: 1px solid #ece3cf; display: flex; align-items: center; gap: 10px; }
.fav-head-title { font-family: 'Zen Maru Gothic'; font-weight: 700; font-size: 18px; }
.fav-head-sub { font-size: 13px; color: #9a9181; }
.fav-list { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 9px; }
.fav-row { display: flex; gap: 11px; align-items: center; padding: 9px; border-radius: 12px; background: #fff; border: 1px solid #ece3cf; }
.fav-row img { width: 52px; height: 52px; border-radius: 9px; object-fit: cover; flex-shrink: 0; background: #e9ede0; }
.fav-row-body { flex: 1; min-width: 0; }
.fav-row-title { font-size: 14.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fav-row-meta { font-size: 12px; font-weight: 700; margin-top: 2px; }
.fav-foot { padding: 14px 16px; border-top: 1px solid #ece3cf; display: flex; gap: 9px; }
.fav-foot-clear { display: inline-flex; align-items: center; justify-content: center; gap: 5px; font-size: 13px; font-weight: 700; color: #a85877; border: 1.5px solid #e6c4d2; border-radius: 11px; padding: 11px 16px; cursor: pointer; }
.fav-foot-qr { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 700; color: #fff; border-radius: 11px; padding: 11px; }

/* QR modal */
.qr-modal { width: min(380px,100%); background: #fffdf8; border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; text-align: center; }
.qr-head { background: linear-gradient(160deg,#2f6f4e,#3a8460); padding: 20px 24px 18px; color: #fff; position: relative; }
.qr-head-close { position: absolute; top: 14px; right: 14px; font-size: 22px; color: rgba(255,255,255,.85); cursor: pointer; }
.qr-head-title { font-family: 'Zen Maru Gothic'; font-weight: 700; font-size: 19px; }
.qr-head-sub { font-size: 13px; color: rgba(255,255,255,.85); margin-top: 4px; line-height: 1.6; }
.qr-body { padding: 24px; }
.qr-box { width: 208px; height: 208px; margin: 0 auto; background: #fff; border-radius: 14px; padding: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.08); display: flex; align-items: center; justify-content: center; }
.qr-hint { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 14px; font-size: 13px; color: #6f6657; }
.qr-url { margin-top: 14px; padding: 10px 14px; background: #f4efe2; border-radius: 10px; font-size: 12px; color: #8a8275; word-break: break-all; line-height: 1.5; }

.modal-close { cursor: pointer; }

/* ============ RESPONSIVE ============ */
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .rail {
    width: 100%; flex-direction: row; height: auto; padding: 8px 10px;
    gap: 8px; overflow-x: auto; box-shadow: 0 2px 10px rgba(0,0,0,.08);
  }
  .rail-logo { margin-bottom: 0; flex-direction: row; gap: 6px; flex-shrink: 0; }
  .rail-logo-text { text-align: left; }
  .rail-cats { flex-direction: row; width: auto; flex-shrink: 0; }
  .railbtn-cat, .rail-btn { width: 64px; padding: 6px 0; flex-shrink: 0; }
  .rail-spacer { display: none; }
  .map-wrap { flex: 1; min-height: 38vh; }
  .panel { width: 100%; max-height: 46vh; border-left: none; border-top: 1px solid #e7ddc6; }
}
