/* ============================================================
   抗战长卷 · 3D 地形沙盘重构
   2D SVG 由同一份历史数据驱动的立体地形画布替换
   ============================================================ */

.war-terrain-canvas {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

.war-terrain-canvas:active {
  cursor: grabbing;
}

.war-terrain-vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    linear-gradient(90deg, rgba(9, 5, 7, 0.38), transparent 9%, transparent 91%, rgba(9, 5, 7, 0.42)),
    linear-gradient(0deg, rgba(9, 5, 7, 0.45), transparent 16%, transparent 88%, rgba(9, 5, 7, 0.32));
  pointer-events: none;
}

.war-sand-ready #mapSvg,
.war-sand-ready .war-darkness,
.war-sand-ready .map-compass,
.war-sand-ready .map-legend,
.war-sand-ready .map-stamp {
  display: none !important;
}

.war-sand-ready .map-frame {
  height: 100%;
  min-height: 360px;
  transform: none !important;
  background:
    radial-gradient(circle at 50% 47%, rgba(130, 12, 36, 0.16), transparent 52%),
    #090607;
}

.war-sand-ready .map-frame::after {
  background: none;
  box-shadow:
    inset 0 0 0 1px rgba(230, 57, 70, 0.14),
    inset 0 0 90px rgba(0, 0, 0, 0.62);
}

.war-terrain-hud {
  position: absolute;
  top: 14px;
  right: 58px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 14px;
  color: rgba(245, 239, 230, 0.38);
  font-family: var(--sans);
  font-size: 8px;
  letter-spacing: 0.08em;
  pointer-events: none;
}

.war-terrain-hud span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 236, 231, 0.68);
}

.war-terrain-hud i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red-pomegranate);
  box-shadow: 0 0 10px var(--red);
  animation: warTerrainPulse 1.8s ease-in-out infinite;
}

@keyframes warTerrainPulse {
  50% { opacity: 0.4; transform: scale(0.72); }
}

.war-layer-controls {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 8;
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(245, 239, 230, 0.1);
  background: rgba(11, 7, 9, 0.8);
  backdrop-filter: blur(8px);
}

.war-layer-controls button {
  height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  color: rgba(245, 239, 230, 0.38);
  background: transparent;
  font-family: var(--sans);
  font-size: 8px;
  letter-spacing: 0.06em;
}

.war-layer-controls button b {
  margin-left: 3px;
  color: rgba(230, 57, 70, 0.76);
  font-weight: 500;
}

.war-layer-controls button:hover,
.war-layer-controls button.active {
  color: #fff7f2;
  border-color: rgba(230, 57, 70, 0.34);
  background: rgba(200, 16, 46, 0.14);
}

.war-archive-dock {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 8;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.war-archive-dock button {
  display: grid;
  grid-template-columns: 1fr auto;
  min-width: 138px;
  padding: 9px 10px;
  border: 1px solid rgba(230, 57, 70, 0.24);
  color: rgba(245, 239, 230, 0.7);
  background: rgba(17, 10, 13, 0.86);
  text-align: left;
  backdrop-filter: blur(9px);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.war-archive-dock button:hover {
  border-color: rgba(230, 57, 70, 0.62);
  background: rgba(111, 14, 31, 0.48);
  transform: translateY(-2px);
}

.war-archive-dock span {
  font-family: var(--portal-kai);
  font-size: 13px;
}

.war-archive-dock strong {
  color: #fff2ef;
  font-family: var(--portal-serif);
  font-size: 18px;
  font-weight: 400;
}

.war-archive-dock small {
  grid-column: 1 / -1;
  margin-top: 3px;
  color: rgba(245, 239, 230, 0.28);
  font-family: var(--sans);
  font-size: 7px;
}

.war-terrain-loading {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: rgba(245, 239, 230, 0.43);
  background:
    radial-gradient(circle, rgba(200, 16, 46, 0.1), transparent 38%),
    #090607;
  transition: opacity 450ms ease, visibility 450ms ease;
}

.war-terrain-loading > span {
  color: var(--red);
  font-size: 38px;
  animation: terrainStarRise 1.5s ease-in-out infinite;
}

@keyframes terrainStarRise {
  50% { opacity: 0.45; transform: translateY(-6px) rotate(14deg); }
}

.war-terrain-loading p {
  margin: 0;
  font-family: var(--portal-serif);
  font-size: 10px;
  letter-spacing: 0.16em;
}

.war-terrain-loading.done {
  visibility: hidden;
  opacity: 0;
}

.war-terrain-tooltip {
  position: absolute;
  z-index: 10;
  max-width: 220px;
  padding: 8px 10px;
  color: #fff5ef;
  border: 1px solid rgba(230, 57, 70, 0.46);
  background: rgba(15, 8, 11, 0.93);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.48);
  font-family: var(--portal-sans);
  font-size: 9px;
  line-height: 1.55;
  pointer-events: none;
  transform: translate(13px, -50%);
}

.war-terrain-tooltip strong {
  display: block;
  color: #fff7f2;
  font-family: var(--portal-kai);
  font-size: 13px;
  font-weight: 400;
}

.war-terrain-tooltip span {
  color: rgba(245, 239, 230, 0.47);
}

/* 主展区改为一张完整沙盘桌，事件档案浮在沙盘右侧 */
.app-shell .experience {
  position: relative;
  grid-template-columns: minmax(0, 1fr);
  padding-right: 0;
}

.app-shell .map-panel {
  grid-column: 1;
  border-color: rgba(230, 57, 70, 0.2);
  background:
    linear-gradient(145deg, rgba(200, 16, 46, 0.045), transparent 35%),
    #100b0d;
}

.app-shell .chronicle {
  position: absolute;
  top: 54px;
  right: 14px;
  bottom: 12px;
  z-index: 24;
  width: min(390px, 34vw);
  border: 1px solid rgba(230, 57, 70, 0.36);
  background:
    linear-gradient(160deg, rgba(200, 16, 46, 0.1), transparent 40%),
    rgba(18, 11, 14, 0.96);
  box-shadow:
    0 26px 70px rgba(0, 0, 0, 0.65),
    inset 0 0 0 1px rgba(255, 255, 255, 0.025);
  backdrop-filter: blur(15px);
  transition:
    opacity 260ms ease,
    transform 360ms cubic-bezier(0.18, 0.74, 0.22, 1),
    visibility 260ms ease;
}

.app-shell .chronicle::before {
  inset: 7px;
  border: 1px solid rgba(245, 239, 230, 0.055);
}

body.event-panel-collapsed .app-shell .chronicle {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 30px));
}

.event-panel-handle {
  position: absolute;
  top: 62px;
  right: 0;
  z-index: 25;
  display: grid;
  width: 48px;
  min-height: 130px;
  padding: 9px 5px;
  place-items: center;
  gap: 8px;
  border: 1px solid rgba(230, 57, 70, 0.4);
  border-right: 0;
  color: rgba(245, 239, 230, 0.7);
  background:
    linear-gradient(180deg, rgba(200, 16, 46, 0.2), transparent),
    #180e12;
  box-shadow: -9px 16px 28px rgba(0, 0, 0, 0.35);
  transition: opacity 180ms ease, transform 180ms ease, background 180ms ease;
}

.event-panel-handle:hover {
  color: #fff;
  background: #50101d;
}

body:not(.event-panel-collapsed) .event-panel-handle {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(12px);
}

.event-panel-handle > span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  color: #fff7f2;
  background: var(--red);
  font-family: var(--portal-kai);
  font-size: 14px;
}

.event-panel-handle strong,
.event-panel-handle small {
  font-family: var(--portal-sans);
  font-size: 8px;
  font-weight: 400;
  letter-spacing: 0.13em;
  writing-mode: vertical-rl;
}

.event-panel-handle small {
  color: rgba(230, 57, 70, 0.7);
}

.event-panel-close {
  display: grid;
  width: 25px;
  height: 25px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(245, 239, 230, 0.15);
  color: rgba(245, 239, 230, 0.54);
  background: transparent;
  font-family: var(--portal-sans);
  font-size: 15px;
  line-height: 1;
}

.event-panel-close:hover {
  color: #fff;
  border-color: rgba(230, 57, 70, 0.65);
}

.event-panel-illustration {
  position: relative;
  margin: 12px 0 5px;
  overflow: hidden;
  border: 4px solid #e8dfd3;
  background: #201518;
  box-shadow:
    0 3px 0 rgba(0, 0, 0, 0.35),
    0 16px 30px rgba(0, 0, 0, 0.42);
  transform: rotate(-0.35deg);
}

.event-panel-illustration::after {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.06), transparent 38%, rgba(64, 5, 15, 0.12));
  content: "";
  pointer-events: none;
}

.event-panel-illustration img {
  display: block;
  width: 100%;
  height: 132px;
  object-fit: cover;
  filter: sepia(0.25) saturate(0.76) contrast(1.07) brightness(0.86);
}

.event-panel-illustration figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 31px;
  padding: 3px 7px 1px;
  color: #42221f;
  background: #ece3d7;
  font-family: var(--portal-serif);
  font-size: 8px;
}

.event-panel-illustration figcaption span {
  color: #8c1c13;
  white-space: nowrap;
}

.event-panel-illustration figcaption strong {
  overflow: hidden;
  font-weight: 400;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-shell .chronicle-top {
  border-bottom-color: rgba(230, 57, 70, 0.22);
}

.app-shell .event-category {
  color: #fff1ed;
  border-color: rgba(230, 57, 70, 0.48);
  background: #8c1c13;
}

.app-shell .event-copy h2 {
  color: #fff6f0;
  text-shadow: 0 4px 22px rgba(0, 0, 0, 0.6);
}

.app-shell .event-date {
  color: rgba(245, 239, 230, 0.48);
}

.app-shell .event-subtitle {
  color: #e87984;
}

.app-shell .chronicle-actions {
  border-top-color: rgba(230, 57, 70, 0.19);
}

.app-shell .chronicle .primary-action {
  border-color: rgba(230, 57, 70, 0.62);
  color: #fff9f5;
  background: var(--red-deep);
}

/* 沙盘统一为红黑白展陈色；历史档案也使用同一套展签语言 */
.app-shell {
  background:
    radial-gradient(900px 580px at 58% -8%, rgba(200, 16, 46, 0.09), transparent 65%),
    #090708;
}

.app-shell .topbar {
  border-bottom-color: rgba(230, 57, 70, 0.18);
  background:
    linear-gradient(180deg, rgba(200, 16, 46, 0.05), transparent 62%),
    #0e0a0c;
}

.app-shell .brand-seal {
  color: #fff7f2;
  border-color: rgba(255, 255, 255, 0.25);
  background: #9e1b32;
}

.app-shell .map-statline {
  border-color: rgba(230, 57, 70, 0.14);
  background: #110b0e;
}

.app-shell .time-deck {
  border-color: rgba(230, 57, 70, 0.22);
  background:
    linear-gradient(180deg, rgba(200, 16, 46, 0.04), transparent 42%),
    #0e0a0c;
}

.app-shell .timeline-track {
  border-color: rgba(230, 57, 70, 0.18);
  background: linear-gradient(180deg, #080506, #190a0f 58%, #0b0608);
}

.app-shell .timeline-fill {
  background: linear-gradient(180deg, #ff7a87, #c8102e 45%, #7e1221);
  box-shadow: 0 0 15px rgba(200, 16, 46, 0.4);
}

.app-shell .chapter-nav button.active {
  color: #fff;
  border-color: rgba(230, 57, 70, 0.45);
  background: rgba(200, 16, 46, 0.15);
}

.archive-drawer {
  border-left-color: rgba(230, 57, 70, 0.28);
  background:
    radial-gradient(600px 400px at 100% 0%, rgba(200, 16, 46, 0.12), transparent 65%),
    #110b0e;
}

.archive-drawer .drawer-head {
  border-bottom-color: rgba(230, 57, 70, 0.2);
}

.archive-drawer .history-tab.active {
  color: #fff;
  border-bottom-color: var(--red);
  background: rgba(200, 16, 46, 0.1);
}

.archive-drawer .battle-entry,
.archive-drawer .archive-entry {
  border-color: rgba(245, 239, 230, 0.09);
  background:
    linear-gradient(145deg, rgba(200, 16, 46, 0.035), transparent 48%),
    #171013;
}

.archive-drawer .battle-entry:hover,
.archive-drawer .archive-entry:hover,
.archive-drawer .battle-entry[open],
.archive-drawer .archive-entry[open] {
  border-color: rgba(230, 57, 70, 0.35);
  background:
    linear-gradient(145deg, rgba(200, 16, 46, 0.09), transparent 50%),
    #1a1014;
}

.archive-drawer .battle-entry-title,
.archive-drawer .archive-entry h3 {
  color: #fff5ef;
  font-family: var(--portal-kai);
}

.archive-drawer .battle-entry-body p,
.archive-drawer .archive-body p {
  color: rgba(245, 239, 230, 0.68);
  font-family: var(--portal-serif);
  font-size: 12.5px;
  line-height: 1.85;
}

.archive-drawer .battle-entry-date,
.archive-drawer .battle-entry-sub,
.archive-drawer .archive-entry p {
  color: rgba(245, 239, 230, 0.43);
}

.archive-drawer .battle-result-badge {
  border-color: rgba(230, 57, 70, 0.28);
  background: rgba(200, 16, 46, 0.09);
}

.archive-drawer .battle-tag,
.archive-drawer .archive-state {
  border-color: rgba(245, 239, 230, 0.13);
  color: rgba(245, 239, 230, 0.55);
  background: rgba(255, 255, 255, 0.025);
}

.archive-drawer select,
.archive-drawer .battle-select {
  color: #f5efe6;
  border-color: rgba(245, 239, 230, 0.18);
  background: #201217;
}

.archive-drawer select option,
.archive-drawer .battle-select option {
  color: #f5efe6;
  background: #160d10;
}

@media (max-width: 1100px) {
  .app-shell .chronicle {
    width: min(360px, 42vw);
  }

  .war-archive-dock {
    grid-template-columns: 1fr;
  }

  .war-archive-dock button {
    min-width: 150px;
  }
}

@media (max-width: 900px) {
  .app-shell .chronicle {
    top: 60px;
    right: 10px;
    bottom: 10px;
    width: min(370px, calc(100% - 38px));
  }

  .event-panel-handle {
    right: 5px;
  }

  .war-terrain-hud {
    display: none;
  }

  .war-layer-controls {
    top: 10px;
    left: 10px;
  }

  .war-archive-dock {
    right: 10px;
    bottom: 10px;
    display: none;
  }
}

@media (max-width: 640px) {
  .app-shell .map-heading h1 {
    font-size: 13px;
  }

  .app-shell .month-casualty,
  .app-shell .casualty-method {
    display: none;
  }

  .event-panel-illustration img {
    height: 110px;
  }

  .war-layer-controls button {
    height: 25px;
    padding: 0 7px;
  }

  .war-layer-controls button b {
    display: none;
  }

  .event-panel-handle {
    top: 54px;
    min-height: 108px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .war-terrain-hud i,
  .war-terrain-loading > span {
    animation: none !important;
  }
}
