/* =========================================================================
   map.css · 每日地点地图（设计书 §4.5 / §6 / §14）
   地点标记、地点卡、地点列表一律使用公共芝士黄；时段用 ☀️/🌤️/🌙 文字表达，
   不借用 🐰 粉紫 / 🐶 粉蓝。只有「来源」徽章使用人物色。
   ========================================================================= */

/* 地图模式下整页不滚动：页头 + 日期栏 + 工具栏 + 地图（+ 底部导航） */
.app[data-view="map"] {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.app[data-view="map"] main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.app[data-view="map"] .view--map { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.app[data-view="map"] .sample-banner { display: none; }

.map-toolbar {
  padding: 10px var(--gutter);
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-page);
}
.map-layout { position: relative; flex: 1; min-height: 0; }
.map-stage { position: absolute; inset: 0; }
.map-canvas { position: absolute; inset: 0; background: #EFEBE3; }
.map-canvas > .state { height: 100%; align-content: center; }

.map-notice {
  position: absolute; z-index: 500; top: 12px; left: 50%;
  width: max-content; max-width: calc(100% - 120px);
  transform: translateX(-50%);
  box-shadow: var(--shadow-1);
  text-align: center;
}

/* ---- Leaflet 外观微调 ---- */
.leaflet-container { font-family: var(--font-body); background: #EFEBE3; }
.leaflet-control-attribution { font-size: 11px; background: rgba(255, 253, 248, .92) !important; }
.leaflet-bar a { color: var(--cheese-text); }

/* ---- 自定义文字地点标记（不使用数字编号） ----
   颜色按来源：🐰 粉紫 / 🐶 粉蓝 / 两人共同为粉紫→粉蓝渐变 / 来源未确认为公共芝士黄 */
.place-marker { background: transparent; border: 0; }
.place-marker:focus-visible { outline: none; }
.place-marker__inner {
  --mk-fill: linear-gradient(var(--cheese-bg), var(--cheese-bg));
  --mk-line: linear-gradient(var(--cheese-border), var(--cheese-border));
  --mk-strong: linear-gradient(var(--cheese-main), var(--cheese-main));
  --mk-tail-fill: var(--cheese-bg);
  --mk-tail-line: var(--cheese-border);
  --mk-tail-strong: var(--cheese-main);
  --mk-ink: var(--cheese-text);
}
.place-marker__inner[data-theme="rabbit"],
.place-marker__inner[data-theme="dog"] {
  --mk-fill: linear-gradient(var(--role-bg), var(--role-bg));
  --mk-line: linear-gradient(var(--role-border), var(--role-border));
  --mk-strong: linear-gradient(var(--role-main), var(--role-main));
  --mk-tail-fill: var(--role-bg);
  --mk-tail-line: var(--role-border);
  --mk-tail-strong: var(--role-main);
  --mk-ink: var(--role-text);
}
.place-marker__inner[data-theme="shared"] {
  --mk-fill: var(--shared-bg);
  --mk-line: var(--shared-border);
  --mk-strong: var(--shared-main);
  --mk-tail-fill: var(--shared-bg-mid);
  --mk-tail-line: var(--shared-border-mid);
  --mk-tail-strong: var(--shared-main-mid);
  --mk-ink: var(--shared-text);
}
.place-marker__pin {
  position: absolute; left: -6px; top: -6px;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--mk-ink);
  background: var(--mk-strong);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}
.place-marker__text {
  position: absolute; left: 0; bottom: calc(11px + var(--lift, 0px));
  display: inline-flex; align-items: center; gap: 3px;
  width: max-content; max-width: 132px;
  padding: 6px 11px;
  transform: translateX(calc(-50% + var(--dx, 0px)));
  border: 1px solid transparent; border-radius: var(--radius-pill);
  background: var(--mk-fill) padding-box, var(--mk-line) border-box;
  color: var(--mk-ink);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .13);
  font-size: 12px; font-weight: 700; line-height: 1.3; white-space: nowrap;
}
.place-marker__text::after {
  content: "";
  position: absolute; left: calc(50% - var(--dx, 0px)); bottom: -5px;   /* 左右错开时小尖角仍对准定位点 */
  width: 8px; height: 8px;
  transform: translateX(-50%) rotate(45deg);
  border-right: 1px solid var(--mk-tail-line); border-bottom: 1px solid var(--mk-tail-line);
  background: var(--mk-tail-fill);
}
.place-marker__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.place-marker__period { flex: none; font-size: 12px; }

/* 选中：「发光贴纸」——底色加深一档 + 白色贴纸边 + 人物色细描边与柔光 + 轻轻抬起；不使用深色描边
   （由 3 个设计方向在真实页面上渲染比较后选定，见设计评审） */
.place-marker__inner { --sel-line: var(--mk-tail-line); --sel-glow: var(--mk-tail-strong); }
@supports (color: color-mix(in srgb, red 50%, transparent)) {
  /* 芝士黄在浅色地图上太淡：只给它的描边加深一点金色 */
  .place-marker__inner[data-theme="cheese"] { --sel-line: color-mix(in srgb, var(--cheese-border) 65%, var(--cheese-text)); }
}
.place-marker.is-selected .place-marker__text {
  border-width: 3px;
  background: var(--mk-fill) padding-box, linear-gradient(var(--bg-card), var(--bg-card)) border-box;
  transform: translateX(calc(-50% + var(--dx, 0px))) translateY(-4px) scale(1.03);
  transform-origin: calc(50% - var(--dx, 0px)) 100%;   /* 以小三角为中心放大，三角始终对准定位点 */
  box-shadow: none;
  /* 白边外再描一圈人物色细线（含小尖角），再加人物色柔光与抬起阴影 */
  filter:
    drop-shadow(2px 0 0 var(--sel-line)) drop-shadow(-2px 0 0 var(--sel-line))
    drop-shadow(0 2px 0 var(--sel-line)) drop-shadow(0 -2px 0 var(--sel-line))
    drop-shadow(0 0 4px var(--sel-glow))
    drop-shadow(0 4px 5px rgba(63, 58, 53, .2));
}
/* 底色加深一档：叠一层 25% 的人物主色（渐变主题同样适用；文字对比度仍 ≥ 4.8:1） */
.place-marker.is-selected .place-marker__text::before {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  border-radius: inherit;
  background: var(--mk-strong);
  opacity: .25;
}
/* 小尖角：白色，作为贴纸白边的一部分；只保留伸出标签的那一半 */
.place-marker.is-selected .place-marker__text::after {
  bottom: -8px;
  width: 12px; height: 12px;
  border-width: 0;
  background: var(--bg-card);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
/* 定位点：变大 + 白圈 + 本主题深色外圈（与未选中的定位点同色系）+ 半透明光晕 */
.place-marker.is-selected .place-marker__pin {
  z-index: 1;
  left: -8px; top: -8px; width: 16px; height: 16px;
  border: 3px solid var(--bg-card);
  background: var(--mk-strong);
  box-shadow: 0 0 0 1.5px var(--mk-ink), 0 2px 6px rgba(63, 58, 53, .28);
}
@supports (color: color-mix(in srgb, red 50%, transparent)) {
  .place-marker.is-selected .place-marker__pin {
    box-shadow: 0 0 0 1.5px var(--mk-ink),
      0 0 0 6px color-mix(in srgb, var(--sel-glow) 45%, transparent),
      0 2px 6px rgba(63, 58, 53, .28);
  }
}
.place-marker--stay.is-selected .place-marker__text::before { border-radius: 5px; }
.place-marker--stay.is-selected .place-marker__pin { border-radius: 5px; }

/* 标签在点下方：方向镜像 */
.place-marker--below.is-selected .place-marker__text { transform: translateX(calc(-50% + var(--dx, 0px))) translateY(4px) scale(1.03); transform-origin: calc(50% - var(--dx, 0px)) 0; }
.place-marker--below.is-selected .place-marker__text::after { bottom: auto; top: -8px; }

/* 选中又被键盘聚焦时：去掉滤镜，让原有的焦点框保持原样 */
.place-marker.is-selected:focus-visible .place-marker__text { filter: none; }

/* 选中航线：实线 + 白色描边 + 轻阴影；另一条航线淡一些 */
.flight-route.is-selected {
  stroke-width: 4;
  stroke-dasharray: none;
  stroke-opacity: 1;
  filter:
    drop-shadow(1.5px 0 0 var(--bg-card)) drop-shadow(-1.5px 0 0 var(--bg-card))
    drop-shadow(0 1.5px 0 var(--bg-card)) drop-shadow(0 -1.5px 0 var(--bg-card))
    drop-shadow(0 2px 3px rgba(63, 58, 53, .2));
}
svg:has(.flight-route.is-selected) .flight-route:not(.is-selected) { stroke-opacity: .7; }

.place-marker:focus-visible .place-marker__text { outline: 3px solid var(--text-main); outline-offset: 2px; }

/* 住宿（酒店）：圆角方框 + 🏨，颜色按入住人，与照片地点的胶囊形标签区分 */
.place-marker--stay .place-marker__text { border-radius: 8px; }
.place-marker--stay .place-marker__pin { border-radius: 4px; }

/* 航线（示意）：乘客色虚线弧，起降点为小圆点 */
.flight-route { fill: none; stroke-opacity: .95; }
.flight-route--rabbit { stroke: var(--rabbit-border); }
.flight-route--dog { stroke: var(--dog-border); }
.flight-end { fill: var(--bg-card); fill-opacity: 1; stroke-width: 2; }
.flight-end--rabbit { stroke: var(--rabbit-border); }
.flight-end--dog { stroke: var(--dog-border); }

/* 标签放在坐标点下方（上方放不下，或偏南那条航线的航班号） */
.place-marker--below .place-marker__text { bottom: auto; top: calc(11px + var(--lift, 0px)); }
.place-marker--below .place-marker__text::after { bottom: auto; top: -5px; transform: translateX(-50%) rotate(225deg); }

/* 往外一层摆放的标签：用一根细线连回自己的定位点 */
.place-marker.has-stem .place-marker__pin::before {
  content: "";
  position: absolute; left: 50%; bottom: 100%;
  width: 2px; height: calc(var(--lift, 0px) + 2px);
  transform: translateX(-50%);
  border-radius: 1px;
  background: var(--mk-line);
}
.place-marker--below.has-stem .place-marker__pin::before { bottom: auto; top: 100%; }

/* 地点列表里的颜色图例 */
.marker-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: -4px 0 8px; color: var(--text-sub); font-size: 12px; }
.marker-legend__item { display: inline-flex; align-items: center; gap: 4px; }
.marker-legend__swatch {
  width: 22px; height: 12px; border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: linear-gradient(var(--cheese-bg), var(--cheese-bg)) padding-box, linear-gradient(var(--cheese-border), var(--cheese-border)) border-box;
}
.marker-legend__swatch[data-theme="rabbit"],
.marker-legend__swatch[data-theme="dog"] { background: linear-gradient(var(--role-bg), var(--role-bg)) padding-box, linear-gradient(var(--role-border), var(--role-border)) border-box; }
.marker-legend__swatch[data-theme="shared"] { background: var(--shared-bg) padding-box, var(--shared-border) border-box; }

/* ---- 底部抽屉 / 侧栏 ---- */
.map-sheet {
  --sheet-peek: 156px;
  position: absolute; z-index: 600; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column;
  height: var(--sheet-h, var(--sheet-peek));
  border: 1px solid var(--cheese-border); border-bottom: 0;
  border-radius: 22px 22px 0 0;
  background: var(--bg-card);
  box-shadow: 0 -8px 30px rgba(63, 58, 53, .14);
  transition: height .28s var(--ease);
}
.map-sheet[data-state="peek"] { --sheet-h: var(--sheet-peek); }
.map-sheet[data-state="half"] { --sheet-h: 52%; }
.map-sheet[data-state="full"] { --sheet-h: calc(100% - 48px); }
.map-sheet.is-dragging { transition: none; }

.map-sheet__handle {
  flex: none; display: grid; place-items: center;
  width: 100%; height: 30px;
  border: 0; background: transparent;
  cursor: grab; touch-action: none;
}
.map-sheet__handle::before {
  content: "";
  width: 44px; height: 5px; border-radius: 3px;
  background: var(--cheese-border);
}
.map-sheet__body {
  flex: 1; min-height: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 0 var(--gutter) 20px;
}

.sheet-head {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 0 10px;
  background: var(--bg-card);
}
.sheet-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.sheet-sub { color: var(--text-sub); font-size: 13px; white-space: nowrap; }
.sheet-note { margin-top: 10px; color: var(--text-sub); font-size: 12px; }

.footprint-group { display: grid; gap: 8px; padding: 10px 0; border-top: 1px dashed var(--border-soft); }
.footprint-group__label { color: var(--cheese-text); font-size: 13px; font-weight: 700; }
.footprint-list { display: grid; gap: 6px; }

.visit-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 52px;
  padding: 8px 12px;
  border: 1px solid var(--border-soft); border-radius: 14px;
  background: var(--bg-card);
  text-align: left;
}
.visit-item:hover { background: var(--cheese-bg); border-color: var(--cheese-border); }
.visit-item[aria-current="true"] { background: var(--cheese-bg); border-color: var(--cheese-text); }
.visit-item .place-chip { flex: none; max-width: 48%; }
.visit-item__title { flex: 1; min-width: 0; color: var(--text-sub); font-size: 14px; overflow-wrap: anywhere; }

/* 地点详情卡（公共芝士黄） */
.visit-card { display: grid; gap: 12px; }
.visit-card__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.visit-card__cover {
  display: block; width: 100%;
  aspect-ratio: 2 / 1; padding: 0; overflow: hidden;
  border: 1px solid var(--cheese-border); border-radius: var(--radius);
  background: var(--cheese-bg);
}
.visit-card__cover img { width: 100%; height: 100%; object-fit: cover; }
.visit-card > .place-chip { justify-self: start; }
.visit-card__title { font-size: 20px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
/* 标题只作为读屏焦点落点，不显示焦点框 */
.visit-card__title:focus { outline: none; }
.visit-card__official { margin-top: -6px; color: var(--text-sub); font-size: 14px; }
.visit-card__hint { color: var(--text-sub); font-size: 13px; }
.visit-card__facts {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--cheese-border); border-radius: 14px;
  background: var(--cheese-bg); color: var(--cheese-text);
  font-size: 14px;
}
.visit-card__facts dt { font-weight: 700; }
.visit-card__facts dd { color: var(--text-main); }
.visit-card__desc { font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.visit-card__strip {
  display: grid; grid-auto-flow: column; grid-auto-columns: 88px; gap: 8px;
  overflow-x: auto; padding-bottom: 4px;
}
.strip-item {
  position: relative; display: block;
  aspect-ratio: 1; padding: 0; overflow: hidden;
  border: 2px solid var(--role-border); border-radius: 12px;
  background: var(--unknown-bg);
}
.strip-item img { width: 100%; height: 100%; object-fit: cover; }
.strip-item .play-icon { width: 32px; height: 32px; font-size: 12px; }
.visit-card__actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }

/* ---- 电脑：地图全宽 + 右侧地点列表 ---- */
@media (min-width: 1024px) {
  .map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; }
  .map-stage { position: relative; inset: auto; }
  .map-sheet {
    position: relative; left: auto; right: auto; bottom: auto;
    height: auto;
    border: 0; border-left: 1px solid var(--cheese-border); border-radius: 0;
    box-shadow: none; transition: none;
  }
  .map-sheet__handle { display: none; }
  .map-sheet__body { padding-top: 16px; }
  .visit-card__cover { aspect-ratio: 16 / 9; }
}
