/* XA mobile contact bar + WeChat detail dialog.
   Independent of theme style.css / header.php / footer.php. */

.xa-mbar,
.xa-mbar * { box-sizing: border-box; }

.xa-mbar {
  display: none;
}

/* Dialog always defined; closed unless .is-open */
.xa-wechat-detail,
.xa-wechat-detail * { box-sizing: border-box; }
.xa-wechat-detail[hidden],
.xa-wechat-detail:not(.is-open) {
  display: none !important;
}
.xa-wechat-detail.is-open {
  display: flex !important;
  position: fixed;
  inset: 0;
  z-index: 100060;
  align-items: center;
  justify-content: center;
  padding: 16px 16px calc(80px + env(safe-area-inset-bottom, 0px));
  background: rgba(10, 10, 10, 0.62);
  -webkit-tap-highlight-color: transparent;
  font-family: var(--sans, system-ui, sans-serif);
  pointer-events: auto !important;
}
.xa-wechat-detail-card {
  position: relative;
  width: min(320px, 100%);
  max-height: min(78vh, calc(100dvh - 96px - env(safe-area-inset-bottom, 0px)));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: #fffdf7;
  border: 1px solid var(--line, #d7ddd9);
  border-radius: 12px;
  border-top: 4px solid var(--brick, #2E4F4A);
  padding: 22px 18px 16px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  pointer-events: auto !important;
}
.xa-wechat-detail-close {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  color: #4a5550;
  cursor: pointer;
  padding: 0;
  pointer-events: auto !important;
}
.xa-wechat-detail-close:hover,
.xa-wechat-detail-close:focus-visible {
  background: #eef2f0;
  outline: 2px solid var(--ochre, #c4a35a);
  outline-offset: 1px;
}
.xa-wechat-detail-title {
  margin: 0 28px 8px 0;
  font-size: 18px;
  line-height: 1.35;
  color: var(--brick-d, #223B37);
  font-weight: 700;
  text-align: left;
}
.xa-wechat-detail-hint {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.5;
  color: #4a5550;
  text-align: left;
}
.xa-wechat-detail-idrow {
  margin: 0 0 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 6px 10px;
  font-size: 15px;
  line-height: 1.4;
}
.xa-wechat-detail-idlbl {
  color: #4a5550;
  font-weight: 600;
}
.xa-wechat-detail-id {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 4px 2px;
  font: inherit;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--brick, #2E4F4A);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  user-select: all;
  -webkit-user-select: all;
  pointer-events: auto !important;
}
.xa-wechat-detail-id:hover,
.xa-wechat-detail-id:focus-visible {
  color: var(--brick-d, #223B37);
  outline: 2px solid var(--ochre, #c4a35a);
  outline-offset: 2px;
}
.xa-wechat-detail-status {
  min-height: 1.3em;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--brick, #2E4F4A);
  line-height: 1.3;
}
.xa-wechat-detail-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0 0 14px;
  padding: 10px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--brick, #2E4F4A);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto !important;
}
.xa-wechat-detail-copy:hover,
.xa-wechat-detail-copy:focus-visible {
  background: var(--brick-d, #223B37);
  outline: 2px solid var(--ochre, #c4a35a);
  outline-offset: 2px;
}
.xa-wechat-detail-qr {
  display: block;
  width: min(200px, 70vw);
  height: auto;
  max-width: 100%;
  margin: 0 auto 8px;
  background: #fff;
  border-radius: 8px;
}
.xa-wechat-detail-tip {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #4a5550;
}
body.xa-wechat-detail-open {
  overflow: hidden;
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
}

@media (max-width: 900px) {
  body {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }
  footer {
    padding-bottom: calc(28px + 64px + env(safe-area-inset-bottom, 0px));
  }

  nav.dock {
    display: none !important;
  }

  /* Hide desktop float pill visuals; keep node for optional click → same dialog */
  #xa-float {
    z-index: 80;
    pointer-events: none !important;
  }
  #xa-float > .xa-float-btn {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
  #xa-float .xa-float-panel {
    display: none !important;
  }

  .xa-mbar {
    display: flex !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9990;
    background: #18211f;
    border-top: 3px solid var(--brick, #2E4F4A);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.18);
    font-family: var(--sans, system-ui, sans-serif);
    -webkit-tap-highlight-color: transparent;
    max-height: calc(72px + env(safe-area-inset-bottom, 0px));
    pointer-events: auto !important;
  }
  .xa-mbar-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 56px;
    max-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    margin: 0;
    padding: 8px 6px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #fff !important;
    text-decoration: none !important;
    font: inherit;
    font-size: 12px;
    line-height: 1.15;
    cursor: pointer;
    text-align: center;
    pointer-events: auto !important;
    position: relative;
    z-index: 1;
  }
  .xa-mbar-btn + .xa-mbar-btn {
    border-left: 1px solid rgba(255, 255, 255, 0.14);
  }
  .xa-mbar-wechat {
    background: var(--brick, #2E4F4A);
  }
  .xa-mbar-btn:hover,
  .xa-mbar-btn:focus-visible {
    background: #2a3834;
    color: #fff !important;
    outline: none;
  }
  .xa-mbar-wechat:hover,
  .xa-mbar-wechat:focus-visible {
    background: var(--brick-d, #223B37);
  }
  .xa-mbar-btn:focus-visible {
    outline: 2px solid var(--ochre, #c4a35a);
    outline-offset: -2px;
  }
  .xa-mbar-ico { display: block; flex: none; }
  .xa-mbar-label {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 2px;
    font-size: 12px;
    font-weight: 600;
  }

  .entry-content,
  .article,
  .post-content,
  main,
  .wrap {
    overflow-wrap: anywhere;
    word-break: normal;
  }
  a[href^="mailto:"],
  .tb-mail,
  .info dd {
    overflow-wrap: anywhere;
  }
  .entry-content table,
  .article table,
  .post-content table,
  main table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  a[href^="tel:"] {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .topbar .wrap {
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .topbar .tb-left {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    flex: 1 1 100%;
    max-width: 100%;
  }
  .topbar .tb-addr {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
  }
  .nav { height: auto; min-height: 0; }
  .nav .wrap {
    height: auto;
    min-height: 56px;
    max-height: none;
    padding-top: 8px;
    padding-bottom: 8px;
    align-items: center;
  }
  .nav .brand {
    gap: 6px;
    max-width: min(58vw, 210px);
  }
  .nav .brand-home img {
    max-width: min(140px, 36vw);
    height: auto;
  }
  .nav .city-switch summary.city,
  .nav .brand .city {
    padding-left: 6px;
    letter-spacing: 0.06em;
    font-size: 11px;
  }
  .xa-lang-btn-label { max-width: 5.2em; }
  .nav-tools { gap: 4px; }
}

@media (max-width: 390px) {
  .nav .brand {
    gap: 5px;
    max-width: min(52vw, 180px);
  }
  .nav .brand-home img {
    max-width: min(118px, 32vw);
  }
  .nav .burger {
    padding: 5px 8px;
    font-size: 12px;
  }
  .xa-lang-btn {
    padding: 4px 7px;
    font-size: 11.5px;
  }
  .xa-lang-btn-label { max-width: 4.2em; }
  .xa-mbar-btn { min-height: 52px; }
}

@media (min-width: 901px) {
  /* Desktop: float pill stays; clicking it also opens full detail via JS delegation */
  .xa-mbar { display: none !important; }
}

@media print {
  .xa-mbar,
  .xa-wechat-detail,
  #xa-float,
  nav.dock {
    display: none !important;
  }
}

/* Email entry: same desktop contact pill, three equal mobile columns. */
.xa-float-email { margin-top: 8px; text-decoration: none; justify-content: center; white-space: nowrap; }
@media (max-width: 900px) {
  #xa-float > .xa-float-email { display: none !important; }
  .xa-mbar { flex-wrap: nowrap; }
  .xa-mbar-email { overflow-wrap: normal; white-space: nowrap; }
}
