/* ==========================================================================
   Muslims Around the World (/muslims-around-the-world): the map stage, its
   legend and controls, the profile panel and the country cards. Builds on
   explore-islam.css (.ex tokens). Logical properties; dark mode via the
   same tokens.
   ========================================================================== */

.mw {
  /* A green sequential scale for the share of Muslims (light to deep), on a cream and sage map. */
  --mw-sea: #f1f4ee;
  --mw-land: #ece4cf;
  --mw-border: #fffdf6;
  --mw-1: #c9ecd8;
  --mw-2: #7cc9a6;
  --mw-3: #1f7a63;
  --mw-4: #0d3b29;
  --mw-nofig: #e8d9a8;
}
[data-theme="dark"] .mw, body.dark .mw {
  --mw-sea: #071a13;
  --mw-land: #1a2a26;
  --mw-border: #050b0e;
  --mw-1: #14402f;
  --mw-2: #1f7a63;
  --mw-3: #2eb872;
  --mw-4: #a7e8c3;
  --mw-nofig: #5b5232;
}

.mw-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; margin-bottom: 1rem; }
.mw-regions { display: flex; flex-wrap: wrap; gap: .4rem; }
.mw-chip { border: 1px solid var(--ex-border-strong); background: var(--ex-surface); color: var(--ex-ink); border-radius: 999px; padding: .45rem .95rem; font-weight: 600; font-size: .88rem; cursor: pointer; transition: all .2s; }
.mw-chip:hover { border-color: var(--ex-emerald); }
.mw-chip.is-active { background: var(--ex-deep); border-color: var(--ex-deep); color: #fff; }
[data-theme="dark"] .mw-chip.is-active, body.dark .mw-chip.is-active { background: var(--ex-gold-2); border-color: var(--ex-gold-2); color: #1b1607; }
.mw-picker { position: relative; display: flex; align-items: center; margin: 0; }
.mw-picker i { position: absolute; inset-inline-start: .9rem; color: var(--ex-muted); pointer-events: none; }
.mw-picker select { appearance: none; -webkit-appearance: none; min-width: 15rem; padding: .6rem 2.2rem .6rem 2.4rem; border-radius: 999px; border: 1px solid var(--ex-border-strong); background: var(--ex-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%235e6375' d='M8 11 3 6h10z'/%3E%3C/svg%3E") no-repeat right .9rem center; color: var(--ex-ink); font-weight: 600; font-size: .92rem; }
[dir="rtl"] .mw-picker select { background-position: left .9rem center; }

.mw-stage { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 1rem; align-items: stretch; }
.mw-map-wrap { position: relative; border-radius: 24px; background: var(--mw-sea); border: 1px solid var(--ex-border); box-shadow: var(--ex-shadow-lg); overflow: hidden; }
.mw-map { position: relative; width: 100%; aspect-ratio: 1.85 / 1; min-height: 240px; }
.mw-map svg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: pan-y; }
.mw-map svg:active { cursor: grabbing; }
.mw-map .sphere { fill: var(--mw-sea); }
.mw-map .graticule { fill: none; stroke: color-mix(in srgb, var(--ex-ink) 7%, transparent); stroke-width: .5; }
.mw-map .hx-country { fill: var(--mw-land); stroke: var(--mw-border); stroke-width: .6; vector-effect: non-scaling-stroke; transition: fill .2s, opacity .3s; }
.mw-map .hx-country.has-profile { cursor: pointer; }
.mw-map .hx-country.is-1 { fill: var(--mw-1); }
.mw-map .hx-country.is-2 { fill: var(--mw-2); }
.mw-map .hx-country.is-3 { fill: var(--mw-3); }
.mw-map .hx-country.is-4 { fill: var(--mw-4); }
.mw-map .hx-country.is-nofig { fill: var(--mw-nofig); }
.mw-map .hx-country.has-profile:hover { filter: brightness(1.08); stroke: var(--ex-gold-2); }
.mw-map .hx-country.is-selected { stroke: #8a6414; stroke-width: 1.5; fill: #e0b44f; }
.mw-map .hx-country.is-dim, .mw-marker.is-dim { opacity: .28; }
.mw-marker { stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: pointer; fill: var(--mw-3); }
.mw-marker.is-1 { fill: var(--mw-1); stroke: var(--mw-3); }
.mw-marker.is-2 { fill: var(--mw-2); }
.mw-marker.is-4 { fill: var(--mw-4); }
.mw-marker.is-nofig { fill: var(--mw-nofig); }
.mw-marker.is-selected { fill: #e0b44f; stroke: #8a6414; }
.mw-map-state { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: .6rem; color: var(--ex-muted); font-weight: 600; }
.mw-map-state.is-error { color: #b4472f; padding: 1rem; text-align: center; }
.mw-spinner { width: 1.4rem; height: 1.4rem; border-radius: 50%; border: 3px solid var(--ex-border-strong); border-top-color: var(--ex-emerald); animation: mw-spin 1s linear infinite; }
@keyframes mw-spin { to { transform: rotate(360deg); } }
.mw-tooltip { position: absolute; z-index: 5; display: flex; flex-direction: column; gap: .1rem; padding: .5rem .75rem; border-radius: 10px; background: var(--ex-deep); color: #fff; font-size: .84rem; pointer-events: none; box-shadow: var(--ex-shadow); max-width: 180px; }
.mw-tooltip strong { font-size: .92rem; }
.mw-legend { position: absolute; inset-inline-start: .9rem; inset-block-end: .9rem; padding: .6rem .8rem; border-radius: 12px; background: color-mix(in srgb, var(--ex-surface) 90%, transparent); backdrop-filter: blur(6px); border: 1px solid var(--ex-border); font-size: .78rem; max-width: 15rem; }
.mw-legend-title { margin: 0 0 .35rem; font-weight: 700; color: var(--ex-ink); }
.mw-legend ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .15rem; }
.mw-legend li { display: flex; align-items: center; gap: .45rem; color: var(--ex-muted); }
.mw-swatch { width: .9rem; height: .9rem; border-radius: 4px; border: 1px solid var(--ex-border-strong); }
.mw-swatch.is-1 { background: var(--mw-1); }
.mw-swatch.is-2 { background: var(--mw-2); }
.mw-swatch.is-3 { background: var(--mw-3); }
.mw-swatch.is-4 { background: var(--mw-4); }
.mw-swatch.is-none { background: var(--mw-nofig); }
.mw-zoom { position: absolute; inset-inline-end: .75rem; inset-block-start: .75rem; display: grid; gap: .35rem; }
.mw-zoom-btn { width: 2.3rem; height: 2.3rem; border-radius: 10px; border: 1px solid var(--ex-border); background: var(--ex-surface); color: var(--ex-ink); display: grid; place-items: center; cursor: pointer; box-shadow: var(--ex-shadow); }
.mw-zoom-btn:hover { border-color: var(--ex-emerald); }

.mw-panel { position: relative; border-radius: 24px; background: var(--ex-surface); border: 1px solid var(--ex-border); box-shadow: var(--ex-shadow); overflow: hidden; display: flex; flex-direction: column; }
.mw-panel-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .4rem; padding: 2rem 1.5rem; color: var(--ex-muted); background: radial-gradient(20rem 12rem at 50% 0%, rgba(224, 180, 79, .14), transparent 70%); }
.mw-panel-empty i { font-size: 2rem; color: var(--ex-gold); }
.mw-panel-empty p { margin: 0; }
.mw-panel-title { font-family: var(--ex-display); font-size: 1.3rem; color: var(--ex-ink); font-weight: 600; }
.mw-panel-body { padding: 1.25rem 1.35rem; overflow-y: auto; max-height: min(70vh, 40rem); animation: ex-rise .3s var(--ex-ease) both; }
.mw-panel-body .mw-country-name { font-family: var(--ex-display); font-size: 1.65rem; margin: 0 0 .25rem; color: var(--ex-ink); }
.mw-panel-link { margin-top: 1rem; font-size: .88rem; }
.mw-note { margin: 1rem 0 0; font-size: .86rem; color: var(--ex-muted); line-height: 1.6; }

.mw-region { margin-bottom: 2rem; }
.mw-region-title { font-family: var(--ex-display); font-size: 1.35rem; color: var(--ex-ink); margin: 0 0 .9rem; padding-bottom: .5rem; border-bottom: 1px solid var(--ex-border); }
.mw-cards { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; padding: 0; margin: 0; }
.mw-country { display: flex; flex-direction: column; gap: .5rem; height: 100%; padding: 1.15rem 1.2rem; border-radius: var(--ex-radius); background: var(--ex-surface); border: 1px solid var(--ex-border); box-shadow: var(--ex-shadow); scroll-margin-top: 6rem; }
.mw-country-head { display: flex; flex-direction: column; gap: .2rem; }
.mw-country-name { font-family: var(--ex-display); font-size: 1.2rem; font-weight: 600; color: var(--ex-ink); margin: 0; }
.mw-country-stat { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .5rem; margin: 0; }
.mw-share { font-family: var(--ex-display); font-size: 1.35rem; font-weight: 600; color: var(--ex-emerald); }
.mw-stat-text { font-size: .84rem; color: var(--ex-muted); }
.mw-country-summary { margin: 0; color: var(--ex-text); line-height: 1.6; font-size: .95rem; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.mw-panel-body .mw-country-summary { -webkit-line-clamp: unset; display: block; }
.mw-open { align-self: flex-start; margin-top: auto; }
.mw-more summary { cursor: pointer; font-size: .88rem; font-weight: 600; color: var(--ex-emerald); }
.mw-full { display: grid; gap: .9rem; margin-top: .75rem; }
.mw-block { padding: .9rem 1rem; border-radius: var(--ex-radius-sm); background: var(--ex-surface-2); }
.mw-block p { margin: 0 0 .4rem; line-height: 1.6; }
.mw-block p:last-child { margin: 0; }
.mw-block-title { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; font-weight: 700; color: var(--ex-ink); font-size: .92rem; }
.mw-block-title i { color: var(--ex-gold); }
.mw-since { background: var(--ex-gold-soft); }
.mw-customs { background: color-mix(in srgb, var(--ex-violet) 9%, var(--ex-surface)); border: 1px dashed color-mix(in srgb, var(--ex-violet) 40%, transparent); }
.mw-tag { display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: color-mix(in srgb, var(--ex-violet) 16%, transparent); color: var(--ex-violet); font-size: .74rem; font-weight: 700; }
.mw-customs-note { font-size: .82rem; color: var(--ex-muted); font-style: italic; }
.mw-sources { display: grid; gap: .35rem; font-size: .82rem; color: var(--ex-muted); }
.mw-sources p { margin: 0; line-height: 1.5; }
.mw-sources a { color: var(--ex-muted); }
.mw-about { padding: clamp(1.25rem, 1rem + 1vw, 2rem); border-radius: var(--ex-radius); background: var(--ex-surface); border: 1px solid var(--ex-border); }
.mw-about ul { line-height: 1.7; color: var(--ex-text); padding-inline-start: 1.2rem; }
.mw-about-sources { margin: 1rem 0 .25rem; }
.mw-about-list { font-size: .88rem; color: var(--ex-muted) !important; }

@media (max-width: 1199.98px) {
  .mw-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 991.98px) {
  .mw-stage { grid-template-columns: 1fr; }
  .mw-panel-body { max-height: none; }
  .mw-map { aspect-ratio: 1.6 / 1; }
}
@media (max-width: 767.98px) {
  .mw-cards { grid-template-columns: 1fr; }
  .mw-picker, .mw-picker select { width: 100%; }
  .mw-legend { position: static; max-width: none; margin: .5rem; }
  .mw-legend ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mw-map { aspect-ratio: 1.45 / 1; }
}
