/* 台儿庄古城 · 演出时刻与倒计时 */
:root {
  --ink: #3a2a1a;
  --paper: #e9d8ad;
  --navy: #1f3a5f;
  --navy-2: #2c4d7c;
  --red: #c0392b;
  --amber: #f4b942;
  --mscale: 1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--paper);
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Heiti SC", sans-serif;
  color: var(--ink);
}

/* 全屏视口 */
#viewport {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 45%, rgba(255, 244, 214, 0.9), rgba(224, 200, 150, 0.75) 60%, rgba(190, 160, 110, 0.85) 100%);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
#viewport:active { cursor: grabbing; }

/* 旋转框架：手机/平板竖屏时整体左旋 90°（横过来看即恢复正位） */
#frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  /* width/height/transform 由 JS 设置 */
}

/* 地图舞台 */
#stage {
  position: relative;
  flex: 0 0 auto;
}

#map {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

#markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* 流动演出路线层 */
#routes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

/* 单个标注：锚点 0x0，位置由 % 决定 */
.marker {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: auto;
}

/* 标注随地图一起左旋，因此不做反向翻转 */
.marker__inner {
  position: absolute;
  transform-origin: 0 0;
}

/* 定位标签图标：经典地图定位针，尖端指向该演出地点 */
.pin {
  position: absolute;
  left: calc(-12px * var(--mscale));
  top: calc(-30px * var(--mscale));
  width: calc(24px * var(--mscale));
  height: calc(30px * var(--mscale));
  background: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='30'%20viewBox='0%200%2024%2030'%3E%3Cpath%20d='M12%200C5.4%200%200%205.4%200%2012L12%2030L24%2012C24%205.4%2018.6%200%2012%200Z'%20fill='%23c0392b'%20stroke='%23ffffff'%20stroke-width='1.5'/%3E%3Ccircle%20cx='12'%20cy='12'%20r='5'%20fill='%23ffffff'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.card {
  position: absolute;
  min-width: calc(120px * var(--mscale));
  max-width: calc(200px * var(--mscale));
  padding: calc(6px * var(--mscale)) calc(8px * var(--mscale));
  background: rgba(31, 58, 95, 0.92);
  color: #fff;
  border-radius: calc(6px * var(--mscale));
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  line-height: 1.25;
  white-space: normal;
}

.marker__inner.marker--right .card { left: calc(24px * var(--mscale)); top: calc(-18px * var(--mscale)); transform: translateY(-50%); }
.marker__inner.marker--left  .card { right: calc(24px * var(--mscale)); top: calc(-18px * var(--mscale)); transform: translateY(-50%); }
.marker__inner.marker--top   .card { left: 50%; bottom: calc(33px * var(--mscale)); transform: translateX(-50%); }
.marker__inner.marker--bottom .card { left: 50%; top: calc(8px * var(--mscale)); transform: translateX(-50%); }

.card__name { font-size: calc(13px * var(--mscale)); font-weight: 700; color: var(--amber); }
.card__venue { font-size: calc(10px * var(--mscale)); opacity: 0.8; }
.card__time { margin-top: calc(2px * var(--mscale)); font-size: calc(11px * var(--mscale)); display: flex; align-items: center; gap: calc(6px * var(--mscale)); }
.card__status { color: #cfe3ff; white-space: normal; }
.card__remain { font-weight: 700; font-variant-numeric: tabular-nums; color: #fff; }

/* 同一地点多场演出的合并卡片 */
.card__multi {
  font-size: calc(11px * var(--mscale));
  font-weight: 700;
  color: var(--amber);
  margin-bottom: calc(3px * var(--mscale));
}
.card__row + .card__row {
  margin-top: calc(4px * var(--mscale));
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  padding-top: calc(4px * var(--mscale));
}

.marker[data-mode="playing"] .card { background: rgba(192, 57, 43, 0.95); }
.marker[data-mode="ended"] .card { opacity: 0.75; }
.marker[data-mode="ended"] .card__remain { color: #ffd8a8; }

/* 从节目单定位到地图标签时的抖动动画 */
@keyframes gz-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-8px, 0); }
  40% { transform: translate(8px, 0); }
  60% { transform: translate(-5px, 0); }
  80% { transform: translate(5px, 0); }
}
.marker.shake { animation: gz-shake 0.55s ease; }

/* 标题(台儿庄古城·演出时刻)已移除 */

/* ------------------------- 节目时间表按钮（在框架左上角，左旋后落到屏幕左下角） ------------------------- */
.top-btns {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 30;
  display: flex;
  gap: 8px;
}
#togglePanel, #toggleEnded {
  padding: 9px 14px;
  border: none;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  white-space: nowrap;
}
#togglePanel { background: var(--navy); color: #fff; }
#toggleEnded { background: var(--navy); color: #fff; }
#toggleEnded.on { background: var(--red); }
#togglePanel:hover, #toggleEnded:hover { filter: brightness(1.1); }

/* ------------------------- 缩放控制（手机端隐藏） ------------------------- */
#zoomctrl {
  position: absolute;
  right: 12px;
  bottom: 14px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px;
  background: rgba(31, 58, 95, 0.85);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
#zoomctrl button {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}
#zoomctrl button:hover { background: rgba(255, 255, 255, 0.28); }
#zoomctrl button:active { background: rgba(255, 255, 255, 0.4); }
#zoomctrl #zoomReset { font-size: 18px; }

html.is-mobile #zoomctrl { display: none; }   /* 手机端用捏合/拖动，隐藏三按钮 */

/* ------------------------- 节目时间表面板（桌面窄宽；手机左旋时按屏幕宽度） ------------------------- */
#panel {
  position: absolute;
  top: 48px;
  left: 4px;
  z-index: 25;
  width: min(340px, 90vw);   /* 非手机页面保持正常窄宽，不对齐页面宽度 */
  max-height: calc(100vh - 70px);
  touch-action: pan-y;       /* 列表中可滚动，不影响地图 */
  display: flex;
  flex-direction: column;
  background: rgba(255, 250, 235, 0.98);
  border: 1px solid rgba(31, 58, 95, 0.2);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  transform: translateX(calc(100% + 20px));
  opacity: 0;
  transition: transform 0.28s ease, opacity 0.28s ease;
  pointer-events: none;
}
#panel.open { transform: translateX(0); opacity: 1; pointer-events: auto; }
/* 手机竖屏左旋时：按屏幕宽度设置高度 */
html.is-rotated #panel {
  width: calc(100vw - 24px);
  max-height: min(360px, 70vw);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--navy);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  font-size: 11px;
  font-weight: 600;
  color: #4a2a00;
  background: var(--amber);
  border-radius: 10px;
  vertical-align: middle;
}
#panelClose {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  opacity: 0.85;
}
#panelClose:hover { opacity: 1; }

#listBody { flex: 1 1 auto; min-height: 0; margin: 0; padding: 6px 0; list-style: none; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.list__item { padding: 8px 12px; border-bottom: 1px solid rgba(31, 58, 95, 0.12); display: flex; align-items: center; gap: 10px; }
.list__item:last-child { border-bottom: none; }
.list__main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.list__name { font-size: 13px; font-weight: 700; color: var(--ink); }
.list__times { font-size: 11px; color: #9a8a68; margin-top: 1px; }   /* 演出时间，稍小灰色 */
.list__meta { font-size: 11px; color: #7a6a52; }
.list__time { text-align: right; min-width: 92px; }
.list__status { display: block; font-size: 11px; color: var(--navy); }
.list__remain { display: block; font-size: 14px; font-weight: 700; color: var(--red); font-variant-numeric: tabular-nums; }
.list__item[data-mode="playing"] .list__remain { color: #c0392b; }
.list__item[data-mode="ended"] .list__status { color: #95794f; }
.list__item[data-mode="ended"] .list__remain { color: #95794f; font-size: 11px; }

/* ------------------------- 同一地点多场：侧边演出列表 ------------------------- */
#clusterList {
  position: fixed;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: min(300px, calc(100vw - 24px));
  max-height: 72vh;
  overflow-y: auto;
  background: rgba(255, 250, 235, 0.98);
  border: 1px solid rgba(31, 58, 95, 0.2);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
  z-index: 80; /* 高于详情浮层，保持可继续点击其它卡片 */
}
#clusterList[hidden] { display: none; }
.cl-head {
  position: sticky; top: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: var(--navy); color: #fff; font-weight: 700;
}
.cl-head button, #modalClose { background: none; border: none; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; opacity: .85; }
.cl-head button:hover, #modalClose:hover { opacity: 1; }
#clBody { list-style: none; margin: 0; padding: 6px 0; }
#clBody li { padding: 8px 12px; border-bottom: 1px solid rgba(31, 58, 95, 0.12); cursor: pointer; }
#clBody li:hover { background: #f4ecd6; }
.cli-name { font-weight: 700; font-size: 14px; color: var(--ink); }
.cli-meta { font-size: 11px; color: #7a6a52; }
.cli-time { font-size: 12px; color: var(--navy); }

/* ------------------------- 演出详情弹窗 ------------------------- */
#showModal {
  position: fixed; inset: 0;
  background: rgba(20, 20, 20, 0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 70;
}
#showModal[hidden] { display: none; }
.modal-card {
  position: relative;
  width: min(460px, calc(100vw - 40px));
  max-height: 80vh;
  overflow-y: auto;
  background: #fffdf5;
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
#modalClose { position: absolute; top: 10px; right: 12px; color: #5b4a30; font-size: 22px; }
.modal-title { font-size: 20px; font-weight: 700; color: var(--navy); margin-right: 28px; }
.modal-meta { font-size: 12px; color: #7a6a52; margin: 4px 0 2px; }
.modal-time { font-size: 14px; color: var(--navy); margin: 8px 0; font-weight: 600; }
.modal-desc { font-size: 14px; line-height: 1.6; color: var(--ink); white-space: pre-wrap; }
.desc-empty { color: #9a8a68; }
.modal-img { margin: -6px -22px 12px; }
.modal-img img { display: block; width: 100%; max-height: 240px; object-fit: cover; border-top-left-radius: 14px; border-top-right-radius: 14px; }
.modal-img-empty {
  display: flex; align-items: center; justify-content: center;
  height: 160px;
  background: #efe3c2;
  color: #9a8a68;
  font-size: 14px;
  border: 1px dashed #cfc4a4;
}

/* 手机左旋时：多演出堆叠列表/演出详情也一起左旋（竖排），且按屏幕尺寸限制 */
html.is-rotated #clusterList {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-90deg);
  width: min(300px, 62vh);      /* 旋转后此宽度对应屏幕高度 */
  max-height: min(72vh, 76vw);  /* 旋转后此高度对应屏幕宽度 */
}
html.is-rotated #showModal .modal-card {
  transform: rotate(-90deg);
  transform-origin: center center;
  width: min(460px, 72vh);      /* 旋转后宽度=原高度 */
  max-height: min(80vh, 80vw);  /* 旋转后高度=原宽度 */
}
