/* riskmap 渲染层样式 · P1 国际版 */

:root {
  --header-height: 76px;
  /* Grade colors for legend textures are assigned from presentation by app.js. */

  --ink: #1f2328;
  --ink-2: #5b6470;
  --card: #ffffff;
  --shadow: 0 2px 12px rgba(16, 24, 40, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

/* 海洋背景与本地 Natural Earth 陆地轮廓组成地图，无外部瓦片依赖。 */
#map {
  position: absolute;
  inset: var(--header-height) 0 0;
  background: #e7edf2;
}

.hidden { display: none !important; }
.map-information{position:absolute;left:12px;bottom:8px;z-index:1000;display:flex;flex-wrap:wrap;gap:4px 12px;max-width:calc(100% - 24px);padding:5px 9px;background:rgba(255,255,255,.96);border:1px solid #dce2e8;border-radius:7px;font-size:11px;line-height:1.6}
.map-information a{color:#185fa5;text-underline-offset:2px}
.skip-link { position:absolute; top:-100px; left:16px; z-index:1500; padding:12px; background:white; color:#185FA5; }
.skip-link:focus { top:8px; }
#panel { overflow-wrap:anywhere; }

.regional-flag, .adv-health { color: #8E2F26; font-size: 12px; }
.regional-flag { padding: 8px; border: 1px solid #F2C9C4; border-radius: 6px; background: #FDF0EE; }
.source-health { display: block; color: var(--ink-2); font-size: 10px; margin: 3px 0 7px 21px; }
#sources .source-health { grid-column: 2; margin: 0 0 5px; overflow-wrap: anywhere; }
.swatch.striped { background: repeating-linear-gradient(135deg, var(--no-rating) 0 4px, var(--regional-edge) 4px 5px, var(--lv4) 5px 7px, var(--regional-edge) 7px 8px); }
.swatch.unavailable { background-image:radial-gradient(#283746 1px,transparent 1px); background-size:8px 8px; }
.legend-note { font-size:11px; max-width:240px; margin:10px 0 0; color:var(--ink-2); }
.summary-heading,.summary-basis { font-size:12px; line-height:1.45; color:var(--ink-2); margin:6px 0; }
.country-label { background:#fff; color:#1f2328; border:1px solid #53606D; font-size:13px; font-weight:600; box-shadow:var(--shadow); }
#sources { left: 64px !important; max-width: 330px; }
#panel { max-height: calc(100vh - var(--header-height) - 32px); overflow-y: auto; }

.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; border:0; }
.no-script { position:relative; z-index:1300; margin:0; padding:24px; background:white; line-height:1.5; }
.site-header { position:relative; z-index:1300; height:var(--header-height); display:flex; align-items:center; gap:24px; padding:12px 24px; background:var(--card); border-bottom:1px solid #dce2e8; }
.site-header h1 { margin:0; font-size:20px; line-height:1.2; white-space:nowrap; }
.site-header nav { margin-left:auto; font-size:14px; }
.site-header a, .search-results a { color:#185FA5; text-underline-offset:3px; }
.finder { position:relative; flex:1; max-width:520px; min-width:180px; }
#country-search { display:flex; gap:8px; }
#country-query { width:100%; min-width:0; border:1px solid #a4b0bd; border-radius:7px; font:inherit; font-size:14px; padding:10px; background:white; }
#country-search button, .search-results button { border:1px solid #a4b0bd; border-radius:7px; background:#f4f7fa; color:#185FA5; font:inherit; font-size:13px; padding:8px 12px; cursor:pointer; }
#country-search button:disabled { cursor:wait; opacity:.6; }
.search-results { position:absolute; top:calc(100% + 8px); left:0; right:0; background:white; border:1px solid #ccd5de; border-radius:10px; box-shadow:var(--shadow); max-height:min(60vh,480px); overflow-y:auto; padding:8px 12px; }
#search-count { margin:4px 0 10px; font-size:12px; color:var(--ink-2); }
#country-results { list-style:none; padding:0; margin:0; }
#country-results li { display:flex; align-items:center; gap:12px; padding:12px 0; border-top:1px solid #e5eaf0; }
#country-results li div { flex:1; min-width:0; overflow-wrap:anywhere; }
#country-results a { font-size:15px; font-weight:600; }
#country-results small { display:block; font-size:11px; color:var(--ink-2); margin-top:4px; }
#country-results button { flex-shrink:0; }
:focus-visible { outline:3px solid #185FA5; outline-offset:3px; }
#search-state:not(.sr-only) { display:block; font-size:12px; color:#8E2F26; padding-top:6px; }
.control-summary { cursor:pointer; font-size:11px; font-weight:600; color:var(--ink-2); line-height:24px; }
details[open] > .control-summary { margin-bottom:8px; }

/* ------------------------------------------------------------ 图例 */

#legend {
  max-width:300px;
  max-height:calc(100dvh - var(--header-height) - 40px);
  overflow-y:auto;
  position: absolute;
  right: 16px;
  bottom: 24px;
  z-index: 1000;
  min-width: 212px;
  padding: 12px 14px;
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.5;
}

#legend h2 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

#legend ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

#legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
}

#legend li.sep {
  margin-top: 6px;
  padding-top: 7px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.swatch {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px #53606D;
}

/* ------------------------------------------------------------ 详情框 */

#panel {
  position: absolute;
  top: calc(var(--header-height) + 16px);
  right: 16px;
  z-index: 1200;
  width: 288px;
  padding: 14px 16px;
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13px;
}

#panel .name {
  margin-bottom: 8px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  padding-right: 18px;
}

#panel .lvl {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-weight: 500;
}

#panel .lvl .dot {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

#panel .meta {
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--ink-2);
}

#panel .link {
  font-size: 12px;
  color: #185FA5;
  text-decoration: none;
}

#panel .link:hover { text-decoration: underline; }

#panel .close {
  position: absolute;
  top: 8px;
  right: 10px;
  padding: 8px;
  width: 36px;
  height: 36px;
  border: 0;
  background: none;
  color: var(--ink-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

#panel .close:hover { color: var(--ink); }
.share-view { margin-top:12px; padding-top:10px; border-top:1px solid #dce2e8; }
.share-view summary { cursor:pointer; color:#185FA5; padding:6px 0; }
.share-view label { display:block; margin:8px 0 4px; font-size:12px; }
.share-view input { width:100%; min-width:0; padding:8px; border:1px solid #a4b0bd; border-radius:6px; font:inherit; }
.share-view button { margin-top:8px; padding:8px 12px; background:#f4f7fa; color:#185FA5; border:1px solid #a4b0bd; border-radius:6px; font:inherit; cursor:pointer; }
.copy-status { font-size:12px; margin:6px 0 0; }

/* ------------------------------------------------------------ 多源区块（P2 新增） */

#panel .advisories {
  margin: 10px 0;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

#panel .advisories h3 {
  margin: 0 0 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

#panel .advisories ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

#panel .adv-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 5px 0;
}

#panel .adv-row + .adv-row {
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

#panel .adv-row .dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  margin-top: 4px;
  border-radius: 50%;
}

/* 该源没有评级：不画实心色点，留一个空心位保持缩进对齐 */
#panel .adv-row .dot.na {
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.16);
}

#panel .adv-body {
  flex: 1 1 auto;
  min-width: 0;
}

#panel .adv-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

#panel .adv-src {
  font-size: 12px;
  font-weight: 600;
}

#panel .adv-date {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--ink-2);
}

#panel .adv-val {
  margin-top: 1px;
  font-size: 12px;
}

#panel .adv-val.na { color: var(--ink-2); }

/* 地区级警示原文。抓来的文本可能很长，这里允许换行但不隐藏（最多 200 字符） */
#panel .adv-note {
  margin-top: 3px;
  padding-left: 7px;
  border-left: 2px solid rgba(0, 0, 0, 0.1);
  font-size: 11px;
  line-height: 1.45;
  color: var(--ink-2);
  word-break: break-word;
}

/* ------------------------------------------------------------ 数据源开关 */

#sources {
  position: absolute;
  top: calc(var(--header-height) + 16px);
  left: 16px;
  z-index: 1000;
  min-width: 200px;
  padding: 12px 14px;
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 1.5;
}

#sources h2 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

#sources ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

#sources li {
  display: grid;
  grid-template-columns: 14px 1fr;
  align-items: start;
  column-gap: 7px;
  padding: 2px 0;
}

#sources input {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: #185FA5;
  cursor: pointer;
}

#sources label { cursor: pointer; }

#sources .hint {
  margin: 7px 0 0;
  padding-top: 6px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 11px;
  line-height: 1.4;
  color: var(--ink-2);
}

/* 一个源都没勾时提示变红（此时全图是灰的，用户需要知道为什么） */
#sources .hint.warn { color: #A32D2D; }

/* ------------------------------------------------------------ 状态条 */

#status {
  position: absolute;
  top: calc(var(--header-height) + 16px);
  left: 50%;
  z-index: 1100;
  max-width: 80vw;
  transform: translateX(-50%);
  padding: 9px 14px;
  border-radius: 8px;
  background: #1f2328;
  color: #ffffff;
  font-size: 13px;
  box-shadow: var(--shadow);
}

#status.error { background: #A32D2D; }

/* ------------------------------------------------------------ Leaflet 微调 */

.leaflet-container {
  font: inherit;
  background: #eef1f4;
}

.leaflet-control-attribution {
  font-size: 10px;
  background: rgba(255, 255, 255, 0.82);
}

@media (max-width:700px) {
  :root { --header-height:124px; }
  .site-header { display:grid; grid-template-columns:1fr auto; gap:10px 12px; padding:12px 16px; }
  .site-header h1 { font-size:18px; }
  .site-header nav { grid-column:2; grid-row:1; font-size:12px; max-width:140px; text-align:right; }
  .finder { grid-column:1 / -1; grid-row:2; width:100%; max-width:none; min-width:0; }
  #country-query { font-size:16px; }
  .search-results { max-height:55vh; }
  #panel { top:auto; bottom:26px; right:8px; width:calc(100% - 16px); max-height:44vh; z-index:1200; }
  #sources { left:56px !important; max-width:calc(100vw - 64px); width:220px; font-size:12px; padding:10px; }
  .map-information { bottom:26px; }
  #legend { right:8px; bottom:96px; min-width:0; width:205px; font-size:11px; padding:10px; max-height:calc(100dvh - var(--header-height) - 196px); overflow-y:auto; }
  #legend.preview-open { display:none; }
  #panel .adv-head { flex-wrap:wrap; gap:2px 8px; }
  #panel .link { display:inline-block; padding:8px 0; }
  .share-view input { font-size:16px; }
  #status { max-width:calc(100vw - 16px); width:max-content; top:calc(var(--header-height) + 8px); }
}

/* Short phone viewports use page scrolling so controls and advice stay reachable. */
@media (max-width:700px) and (max-height:500px) {
  html,body { height:auto; min-height:100%; }
  #sources,#legend,#panel { position:relative; inset:auto; margin:12px 8px; max-width:calc(100% - 16px); width:auto; }
  #sources { left:auto !important; }
  #map { position:relative; inset:auto; height:300px; }
  #panel { max-height:none; }
  #legend { max-height:none; }
  .map-information { position:relative;left:auto;bottom:auto;margin:12px 8px;width:max-content; }
}

.cn-notice-links{padding-left:18px;margin:8px 0}.cn-notice-links li{margin:6px 0;overflow-wrap:anywhere}.cn-notice-links small{display:block;color:#53606D}.cn-notice h4{overflow-wrap:anywhere}

.cn-risk-areas { margin:6px 0 6px 16px; padding:0; overflow-wrap:anywhere; }
