/* ========== 出发!等时旅行手帐 ========== */
:root {
  --paper: #f6efdd;
  --paper-deep: #efe5cc;
  --ink: #4a3f33;
  --ink-soft: #8a7a64;
  --accent: #e8694a;
  --accent-2: #3f8f7b;
  --card: #fffdf6;
  --tape: rgba(244, 180, 132, .55);
  font-size: 15px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: "Yuanti SC", "YouYuan", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 20% 10%, #fbf5e6 0%, transparent 55%),
    radial-gradient(ellipse at 85% 90%, #f1e6c8 0%, transparent 50%),
    var(--paper);
}

#app { position: relative; width: 100vw; height: 100vh; }

/* ---------- 地图舞台 ---------- */
#map-stage { position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: none; }
#map-stage.dragging { cursor: grabbing; }

#viewport { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
#iso-canvas, #svg-top { position: absolute; left: 0; top: 0; overflow: visible; }
#iso-canvas { pointer-events: none; }
#svg-top { z-index: 5; }

#grain {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: .05; pointer-events: none; mix-blend-mode: multiply;
}

/* ---------- 城市贴纸标记 ---------- */
.marker { cursor: pointer; }
/* 避让收拢:完整贴纸 → 仅emoji圆贴(compact)→ 小圆点(dot) */
.marker .mini {
  display: none; fill: var(--accent-2); stroke: #fffdf6; stroke-width: 1.5;
  filter: drop-shadow(0 1px 1px rgba(90, 70, 40, .3));
}
.marker.compact .label, .marker.compact .time-tag, .marker.compact .time-tag-bg { display: none; }
.marker.dot .sticker-bg, .marker.dot .emoji, .marker.dot .label,
.marker.dot .time-tag, .marker.dot .time-tag-bg { display: none; }
.marker.dot .mini { display: block; }
.marker.off { display: none; }
/* 位移平摊:牵引线 + 真实位置锚点 */
.marker .leader {
  stroke: #c2a87d; stroke-width: 1.2; stroke-dasharray: 3 3;
  display: none; pointer-events: none;
}
.marker .anchor { fill: #c2a87d; display: none; pointer-events: none; }
.marker.displaced .leader, .marker.displaced .anchor { display: block; }
.marker .sticker-bg {
  fill: #fffdf6; stroke: #e3d5b8; stroke-width: 1.5;
  filter: drop-shadow(0 2px 2px rgba(90, 70, 40, .25));
  transition: transform .15s;
}
.marker:hover .sticker-bg { stroke: var(--accent); }
.marker.selected .sticker-bg { stroke: var(--accent); stroke-width: 2.5; }
.marker .emoji { font-size: 17px; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.marker .label {
  font-size: 11px; text-anchor: middle; fill: var(--ink);
  paint-order: stroke; stroke: rgba(255, 253, 246, .9); stroke-width: 3px;
  font-weight: 600; pointer-events: none;
}
.marker .time-tag {
  font-size: 9.5px; text-anchor: middle; fill: #fff; font-weight: 700; pointer-events: none;
}
.marker .time-tag-bg { fill: var(--accent-2); rx: 6; pointer-events: none; }

.home-ring { fill: none; stroke: var(--accent); stroke-width: 2; opacity: .8; animation: pulse 2.2s ease-out infinite; }
@keyframes pulse {
  0%   { transform: scale(.4); opacity: .9; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* 路线 */
.route-line {
  fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round;
  stroke-dasharray: 7 8; vector-effect: non-scaling-stroke;
  animation: march 1.2s linear infinite;
}
@keyframes march { to { stroke-dashoffset: -15; } }
.route-vehicle { font-size: 20px; text-anchor: middle; dominant-baseline: central; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 18px; left: 18px; z-index: 20;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
#hud > * { pointer-events: auto; }

#title-card {
  display: flex; gap: 14px; align-items: center;
  background: var(--card);
  border: 1.5px solid #e3d5b8; border-radius: 14px;
  padding: 12px 18px 12px 12px;
  box-shadow: 3px 4px 0 rgba(90, 70, 40, .12);
  transform: rotate(-.6deg);
}
#stamp {
  width: 52px; height: 60px; flex: none;
  border: 2px dashed var(--accent); border-radius: 6px;
  color: var(--accent); font-size: 17px; font-weight: 800; line-height: 1.1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  transform: rotate(-4deg); position: relative; background: #fff7ee;
}
.stamp-en { font-size: 5.5px; letter-spacing: .5px; margin-top: 3px; font-weight: 600; }
h1 { font-size: 21px; letter-spacing: 1px; }
.subtitle { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }

#mode-tabs {
  display: flex; gap: 6px; background: var(--card);
  border: 1.5px solid #e3d5b8; border-radius: 12px; padding: 6px;
  box-shadow: 3px 4px 0 rgba(90, 70, 40, .12);
  width: fit-content; transform: rotate(.4deg);
}
.mode-tab {
  border: none; background: transparent; font-family: inherit; color: var(--ink-soft);
  font-size: 13.5px; font-weight: 700; padding: 7px 13px; border-radius: 9px; cursor: pointer;
  transition: all .15s;
}
.mode-tab:hover { background: #f5ecd8; color: var(--ink); }
.mode-tab.active { background: var(--accent); color: #fff; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); }

/* ---------- 图例 ---------- */
#legend {
  position: absolute; left: 18px; bottom: 18px; z-index: 20;
  background: var(--card); border: 1.5px solid #e3d5b8; border-radius: 12px;
  padding: 10px 14px; box-shadow: 3px 4px 0 rgba(90, 70, 40, .12);
  transform: rotate(-.4deg); max-width: 330px;
}
.legend-title { font-size: 11.5px; font-weight: 700; color: var(--ink-soft); margin-bottom: 7px; }
#legend-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 4px;
  color: #5a4a33; position: relative;
  /* 和纸胶带效果 */
  clip-path: polygon(2% 0, 98% 4%, 100% 96%, 1% 100%);
  opacity: .92;
}
#btn-about {
  margin-top: 8px; border: none; background: none; font-family: inherit;
  font-size: 11px; color: var(--accent-2); cursor: pointer; text-decoration: underline dotted;
  padding: 0;
}

/* ---------- 缩放 ---------- */
#zoom-ctrl {
  position: absolute; right: 18px; bottom: 18px; z-index: 20;
  display: flex; flex-direction: column; gap: 5px;
}
#zoom-ctrl button {
  width: 36px; height: 36px; border-radius: 10px; border: 1.5px solid #e3d5b8;
  background: var(--card); font-size: 17px; color: var(--ink); cursor: pointer;
  box-shadow: 2px 3px 0 rgba(90, 70, 40, .12); font-family: inherit;
}
#zoom-ctrl button:hover { background: #f5ecd8; }

/* ---------- Tooltip ---------- */
#tooltip {
  position: absolute; z-index: 30; pointer-events: none;
  background: var(--ink); color: #fff7ea; font-size: 12px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap;
  transform: translate(-50%, -130%);
  box-shadow: 0 3px 8px rgba(0,0,0,.25);
}
#tooltip .t-sub { font-weight: 400; opacity: .75; font-size: 11px; }
.hidden { display: none !important; }

/* ---------- 城市面板 ---------- */
#panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 420px; max-width: 92vw;
  z-index: 40; background: var(--card);
  border-left: 1.5px solid #e3d5b8;
  box-shadow: -8px 0 24px rgba(90, 70, 40, .18);
  overflow-y: auto; overscroll-behavior: contain;
  animation: slide-in .25s ease-out;
}
@keyframes slide-in { from { transform: translateX(40px); opacity: 0; } }
#panel-close {
  position: sticky; top: 10px; margin-left: 12px; z-index: 5;
  width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid #e3d5b8;
  background: var(--card); cursor: pointer; font-size: 14px; color: var(--ink-soft);
  font-family: inherit;
}
#panel-handle {
  display: none; position: sticky; top: 0; z-index: 6;
  padding: 10px 0 8px; touch-action: none; cursor: grab;
  background: linear-gradient(var(--card) 60%, rgba(255, 253, 246, 0));
}
#panel-handle::before {
  content: ""; display: block; width: 44px; height: 5px; border-radius: 3px;
  background: #d9c9a6; margin: 0 auto;
}
#panel-body { padding: 0 22px 30px; margin-top: -18px; }

.p-head { display: flex; align-items: center; gap: 13px; padding: 14px 0 4px; }
.p-emoji {
  font-size: 42px; width: 70px; height: 70px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 2px solid #e3d5b8; border-radius: 18px;
  box-shadow: 2px 3px 0 rgba(90,70,40,.12); transform: rotate(-3deg);
}
.p-head h2 { font-size: 25px; letter-spacing: 2px; }
.p-tagline { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }
.p-region {
  display: inline-block; font-size: 10.5px; font-weight: 700; color: #fff;
  background: var(--accent-2); border-radius: 4px; padding: 1px 7px; margin-top: 5px;
  clip-path: polygon(3% 0, 100% 6%, 97% 100%, 0 94%);
}

.p-section { margin-top: 20px; }
.p-section > h3 {
  font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 7px;
}
.p-section > h3::after { content: ""; flex: 1; border-bottom: 2px dotted #d9c9a6; }

/* 交通卡片 */
.t-card {
  border: 1.5px solid #e9ddc2; border-radius: 12px; padding: 10px 13px; margin-bottom: 9px;
  background: #fffefa; position: relative;
}
.t-card.recommended { border-color: var(--accent); background: #fff6ef; }
.t-best-badge {
  position: absolute; top: -9px; right: 12px; background: var(--accent); color: #fff;
  font-size: 10.5px; font-weight: 800; padding: 2px 9px; border-radius: 99px;
  box-shadow: 0 2px 4px rgba(232,105,74,.4); transform: rotate(2deg);
}
.t-row { display: flex; align-items: baseline; gap: 9px; }
.t-mode { font-size: 14.5px; font-weight: 800; }
.t-total { font-size: 17px; font-weight: 800; color: var(--accent); margin-left: auto; }
.t-total small { font-size: 11px; color: var(--ink-soft); font-weight: 600; }
.t-breakdown {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  font-size: 11px; color: var(--ink-soft); margin-top: 6px; line-height: 1.7;
}
.t-seg { background: #f3ecd9; border-radius: 5px; padding: 1px 6px; white-space: nowrap; }
.t-arrow { color: #c9b893; }
.t-note { font-size: 11px; color: var(--ink-soft); margin-top: 6px; line-height: 1.55; }
.t-walk {
  font-size: 11.5px; color: var(--ink-soft); margin-top: 4px; padding: 7px 11px;
  background: #f6f1e2; border-radius: 9px; line-height: 1.6;
}

.reco-say {
  font-size: 12.5px; line-height: 1.7; background: #eef6f1; border-radius: 10px;
  padding: 9px 13px; margin-bottom: 12px; color: #3c6b5c; border: 1px dashed #9cc7b5;
}

/* 景点 */
.spot { display: flex; gap: 11px; margin-bottom: 11px; align-items: flex-start; }
.spot-e {
  font-size: 21px; width: 38px; height: 38px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 1.5px solid #e9ddc2; border-radius: 11px;
  box-shadow: 1px 2px 0 rgba(90,70,40,.1);
}
.spot:nth-child(odd) .spot-e { transform: rotate(-2.5deg); }
.spot:nth-child(even) .spot-e { transform: rotate(2deg); }
.spot-n { font-size: 13.5px; font-weight: 800; }
.spot-d { font-size: 11.5px; color: var(--ink-soft); line-height: 1.55; margin-top: 2px; }

/* 行程 */
.day { display: flex; gap: 10px; margin-bottom: 10px; }
.day-tag {
  flex: none; font-size: 11px; font-weight: 800; color: #fff; background: var(--ink);
  width: 34px; height: 22px; border-radius: 6px; display: flex; align-items: center;
  justify-content: center; transform: rotate(-2deg); margin-top: 1px;
}
.day-plan { font-size: 12.5px; line-height: 1.7; }

.p-tips {
  margin-top: 18px; font-size: 12px; line-height: 1.8; color: #6b5a3e;
  background: #fdf6e0; border-radius: 10px; padding: 11px 14px;
  border: 1px solid #efe2bd;
}
.p-tips b { color: var(--accent); }

/* ---------- 关于弹窗 ---------- */
#about-modal {
  position: absolute; inset: 0; z-index: 60; background: rgba(74, 63, 51, .35);
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px);
}
#about-card {
  width: 560px; max-width: 92vw; max-height: 84vh; overflow-y: auto;
  background: var(--card); border-radius: 16px; border: 1.5px solid #e3d5b8;
  padding: 26px 30px; position: relative; box-shadow: 0 14px 40px rgba(60,45,25,.3);
}
#about-card h2 { font-size: 19px; margin-bottom: 12px; }
#about-card h3 { font-size: 14px; margin: 14px 0 6px; color: var(--accent-2); }
#about-card p, #about-card li { font-size: 12.5px; line-height: 1.8; }
#about-card ul { padding-left: 18px; }
#about-card .fine { color: var(--ink-soft); font-size: 11.5px; margin-top: 8px; }
#about-close {
  position: absolute; top: 14px; right: 14px; width: 28px; height: 28px;
  border-radius: 50%; border: 1.5px solid #e3d5b8; background: #fff;
  cursor: pointer; font-family: inherit; color: var(--ink-soft);
}

/* 滚动条 */
#panel::-webkit-scrollbar, #about-card::-webkit-scrollbar { width: 8px; }
#panel::-webkit-scrollbar-thumb, #about-card::-webkit-scrollbar-thumb {
  background: #ddcda6; border-radius: 8px;
}

/* ---------- 移动端 ---------- */
@media (max-width: 768px) {
  :root { font-size: 14px; }

  #hud { top: 10px; left: 10px; right: 10px; gap: 7px; }
  #title-card { padding: 8px 12px; gap: 8px; transform: none; border-radius: 12px; }
  #stamp { display: none; }
  h1 { font-size: 16px; letter-spacing: .5px; }
  .subtitle { font-size: 10.5px; }
  #mode-tabs { width: 100%; transform: none; padding: 4px; gap: 3px; }
  .mode-tab {
    flex: 1 1 0; min-width: 0; padding: 8px 0; font-size: 11.5px;
    text-align: center; white-space: nowrap;
  }

  #legend {
    left: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    max-width: 64vw; padding: 8px 10px; transform: none;
  }
  .legend-title { font-size: 10px; margin-bottom: 5px; }
  .chip { font-size: 9.5px; padding: 2px 6px; }
  #btn-about { margin-top: 6px; font-size: 10.5px; }
  #zoom-ctrl { display: none; }          /* 双指捏合/双击缩放替代 */
  #tooltip { display: none !important; } /* 触屏无悬停 */

  /* 城市面板 → 底部抽屉 */
  #panel {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-width: 100%;
    height: 74vh;
    border-left: none; border-top: 1.5px solid #e3d5b8;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -10px 28px rgba(90, 70, 40, .28);
    animation: slide-up .28s ease-out;
    padding-bottom: env(safe-area-inset-bottom);
  }
  #panel-handle { display: block; }
  #panel-close { display: block; margin-left: auto; margin-right: 14px; margin-top: -34px; z-index: 8; }
  #panel-body { margin-top: 4px; padding: 0 16px 34px; }
  .p-head { padding-top: 6px; }
  .p-head h2 { font-size: 21px; }
  .p-emoji { width: 56px; height: 56px; font-size: 34px; border-radius: 15px; }

  #about-card { padding: 22px 18px; max-height: 80vh; }
}
@keyframes slide-up { from { transform: translateY(70px); opacity: 0; } }
